复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的 行首的空白字符

复制/etc/profile至/tmp/目录:

cp 命令

解释说明:cp - copy files and directories

格式:

cp [OPTION]… [-T] SOURCE DEST

cp [OPTION]… SOURCE… DIRECTORY

cp [OPTION]… -t DIRECTORY SOURCE…

常用选项:

-i 覆盖前提示 //如果不提示的话,会直接覆盖有风险

-n 不覆盖,注意两者顺序

-r, -R 递归复制目录及内部的所有内容

-a 归档,相当于-dR --preserv=all //一般用来备份

-d --no-dereference --preserv=links 不复制原文件,只复制链接名

–preserv[=ATTR_LIST] mode: 权限、ownership: 属主属组、timestamp: 、links、xattr、context、all

-p 等同–preserv=mode,ownership,timestamp

-v --verbose

-f --force // if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used)

-u --update 只复制源比目标更新文件或目标不存在的文件

-b 目标存在,覆盖前先备份,形式为 filename~

复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的 行首的空白字符
用查找替换命令删除/tmp/profile文件中的 行首的空白字符

使用vim /tmp/profile

可以先用查找命令,找到其行首的空白字符:

复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的 行首的空白字符
后在vim中使用替换:

格式:s/要查找的内容/替换为的内容/修饰符

//如果要替换全局的要%s/要查找的内容/替换为的内容/g

复制/etc/profile至/tmp/目录,用查找替换命令删除/tmp/profile文件中的 行首的空白字符
//然后直接回车。