日期:2014-05-16  浏览次数:20830 次

Linux文件操作命令(添加删除修改)

[root@test etc]# rm --help?????????
用法:rm [选项]... 文件...
Remove (unlink) the FILE(s).

-f, --force?????????? ignore nonexistent files, never prompt
-i, --interactive???? prompt before any removal
--no-preserve-root 不特殊对待“/”(默认值)
--preserve-root?? 不允许在“/”上递归操作
-r, -R, --recursive?? 递归删除目录及其内容
-v, --verbose???????? 详细显示进行的步骤
--help???? 显示此帮助信息并退出
--version? 输出版本信息并退出

默认情况下,rm 不删除目录。使用 --recursive (-r 或 -R)选项可以删除每个列出的
目录及其下面的内容。

要删除第一个字符为“-”的文件 (例如“-foo”),请使用以下其中一种方法:
rm -- -foo

rm ./-foo

请注意,如果使用 rm 来删除文件,通常仍可以将该文件恢复原状。如果想保证
该文件的内容无法还原,请考虑使用 shred。

[root@test etc]# cp --help
用法:cp [选项]... [-T] 源 目的
或:cp [选项]... 源... 目录
或:cp [选项]... -t 目录 源...
将<源>文件复制至<目的>,或将多个<源>复制至<目录>。

长选项必须用的参数在使用短选项时也是必须的。
-a, --archive??????????????? same as -dR --preserve=all
--backup[=CONTROL]?????? make a backup of each existing destination file
-b?????????????????????????? like --backup but does not accept an argument
--copy-contents????????? copy contents of special files when recursive
-d?????????????????????????? same as --no-dereference --preserve=link
-f, --force????????????????? if an existing destination file cannot be
opened, remove it and try again
-i, --interactive??????????? prompt before overwrite
-H?????????????????????????? follow command-line symbolic links
-l, --link?????????????????? 链接文件而不复制
-L, --dereference??????????? 总是跟随符号链接
-P, --no-dereference???????? 从不跟随符号链接
-p?????????????????????????? same as --preserve=mode,ownership,timestamps
--preserve[=ATTR_LIST]?? preserve the specified attributes (default:
mode,ownership,timestamps), if possible
additional attributes: context, links,
xattr, all
-c?????????????????????????? same as --preserve=context
--no-preserve=ATTR_LIST? don't preserve the specified attributes
--parents??????????????? use full source file name under DIRECTORY
-R, -r, --recursive????????? 复制目录及目录内的所有项目
--remove-destination???? 尝试打开目的地文件前先删除已存在的目的地
文件 (与 --force 选项作对比)
--sparse=WHEN??????????? control creation of sparse files
--strip-trailing-slashes remove any trailing slashes from each SOURCE
argument
-s, --symbolic-link????????? make symbolic links instead of copying
-S, --suffix=SUFFIX????????? override the usual backup suffix
-t, --target-directory=DIRECTORY? copy all SOURCE arguments into DIRECTORY
-T, --no-target-directory??? treat DEST as a normal file
-u, --update???????????????? 只在<源>文件比目的地文件新,或目的地文件
不存在时才进行复制
-v, --verbose??????????????? 详细显示进行的步骤
-x, --one-file-system??????? 不会跨越文件系统进行操作
-Z, --context=CONTEXT??????? set security context of copy to CONTEXT
--help???? 显示此帮助信息并退出
--version? 输出版本信息并退出

默认使用模式中,<源>文件是否 sparse 文件会由一种粗略的方式决定,而且相应
的<目的地>文件也会是 sparse 文件。此方式等于使用 --sparse=auto 选项。指定
--sparse=always 则只要<源>文件含有足够长的 0 字节都会产生 sparse 的
<目的地>文件。
使用 --sparse=never 会禁止产生 sparse 文件。

备份文件的后缀为“~”,除非以 --suffix 选项或是 SIMPLE_BACKUP_SUFFIX
环境变量指定。版本控制的方式可透过 --backup 选项或 VERSION_CONTROL 环境
变量来选择。以下是可用的变量值:

none, off?????? 不会进行备份 (即使使用了 --backup 选项)
numbered, t???? 备份文件会加上数字
existing, nil?? 若有数字的备份文件已经存在则使用数字,否则使用普通方式备份
simple, never?? 永远使用普通方式备份

有一个特别情况:如果同时指定 --force 和 --backup 选项,而且<源>和<目的地>
是同一个已存在的一般文件的话,cp 会将<源>文件备份。

[root@test etc]# mv --help
用法:mv [选项]... [-T] 源 目的
或:mv [选项]... 源... 目录
或:mv [选项]... -t 目录 源...
将<源>名称重命名为<目的地>名称,或将<源>文件移动至<目录>。

长选项必须用的参数在使用短选项时也是必须的。
--backup[=CONTROL]?????? make a backup of each existing destination file
-b?????????????????????????? like --backup but does not accept an argument
-f, --force????????????????? do not prompt before overwriting
-i, --interactive??????????? prompt before overwrite
--strip