Linux -- cp 复制文件
CP(1) User Commands CP(1)
NAME 名称
cp - copy files and directories 拷贝文件或目录
SYNOPSIS 概要
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
DESCRIPTION 说明
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
复制文件到目标位置,或复制多文件到目标目录。
Mandatory arguments to long options are mandatory for short options too.
对于长选项必须的参数,对于短选项也是必须的。
-a, --archive
same as -dR --preserve=all
等同于-dR --preserve=all,复制时,保持文件的原有结构和属性。
--attributes-only
don't copy the file data, just the attributes
仅拷贝文件属性,不拷贝文件数据。
[root@user test]# ll total 4 -rw-r--r-- 1 root root 1 Mar 5 17:52 test [root@user test]# cp --attributes-only test test.bk [root@user test]# ll total 4 -rw-r--r-- 1 root root 1 Mar 5 17:52 test -rw-r--r-- 1 root root 0 Mar 5 18:00 test.bk [root@user test]#
--backup[=CONTROL]
make a backup of each existing destination file
对存在的目标文件作一备份。
-b
like --backup but does not accept an argument
同--backup,对存在的目标文件作一备份,但不接受参数。
--copy-contents
copy contents of special files when recursive
在递归时,拷贝特殊文件内容。
-d
same as --no-dereference --preserve=links
同--no-dereference --preserve=links,复制符号链接作为符号链接而不是复制它指向的文件。
-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)
当目标文件存在时,先删除,再复制。(当同-n一起使用时,此参数无效。)
-i, --interactive
prompt before overwrite (overrides a previous -n option)
在覆盖前给予提示(将覆盖-n参数)。
-H
follow command-line symbolic links in SOURCE
复制符号连接所指向的原始文件,而非符号连接本身。
-l, --link
hard link files instead of copying
创建硬连接,而非真正的拷贝。
-L, --dereference
always follow symbolic links in SOURCE
复制符号连接所指向的原始文件,而非符号连接本身。
-n, --no-clobber
do not overwrite an existing file (overrides a previous -i option)
不覆盖存在的目标文件,即当目标文件存在时,不操作(将覆盖-i参数)。
-P, --no-dereference
never follow symbolic links in SOURCE
复制符号连接本身,而非符号连接所指向的原始文件。
-p
same as --preserve=mode,ownership,timestamps
同--preserve=mode,ownership,timestamps,保持原文件的权限,所属者,组,时间表属性。
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all
只保护规定的属性(默认:mode,ownership,timestamps),其他属性有:context, links, xattr, all。
-c
deprecated, same as --preserve=context
不赞成使用,同--preserve=context。
--no-preserve=ATTR_LIST
don't preserve the specified attributes
只保护除此规定属性之外的属性。
--parents
use full source file name under DIRECTORY
使用完整的原文件名称作为目标文件名称,当目标位置是目录时有效。
-R, -r, --recursive
copy directories recursively
递归复制目标。
--reflink[=WHEN]
control clone/CoW copies. See below
控制创建副本方式。
--remove-destination
remove each existing destination file before attempting to open it (contrast with --force)
删除每个现有目标文件之前试图打开它(与--force对照)。
--sparse=WHEN
control creation of sparse files. See below
控制创建稀疏文件。
--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
将目标目录作为普通文件
[root@user test]# ls -lR .: total 8 drwxr-xr-x 3 root root 4096 Mar 5 17:52 dtest -rw-r--r-- 1 root root 1 Mar 5 17:52 test ./dtest: total 4 drwxr-xr-x 2 root root 4096 Mar 5 17:52 test ./dtest/test: total 0 [root@user test]# cp -T test ./dtest/test cp: overwrite './dtest/test'? y cp: cannot overwrite directory './dtest/test' with non-directory [root@user test]# cp test ./dtest/test [root@user test]# ls -lR .: total 8 drwxr-xr-x 3 root root 4096 Mar 5 17:52 dtest -rw-r--r-- 1 root root 1 Mar 5 17:52 test ./dtest: total 4 drwxr-xr-x 2 root root 4096 Mar 5 17:53 test ./dtest/test: total 4 -rw-r--r-- 1 root root 1 Mar 5 17:53 test [root@user test]#
-u, --update
copy only when the SOURCE file is newer than the destination file or when the destination file is missing
如果目的地有相同名称的文件存在,以修改时间为参考,保留最新时间的文件,如果目的地没有相同名称的文件存在,则直接复制。
-v, --verbose
explain what is being done
显示当前进度。
-x, --one-file-system
stay on this file system
跳过来自不同文件系统的子目录。
-Z, --context[=CTX]
set SELinux security context of destination file to default type, or to CTX if specified
--help display this help and exit
显示此命令的帮助信息并退出。
--version
output version information and exit
显示版本信息并退出。
By default, sparse SOURCE files are detected by a crude heuristic and the corresponding DEST file is made sparse as well. That is the behavior selected by --sparse=auto. Specify --sparse=always to create a sparse DEST file whenever the SOURCE file contains a long enough sequence of zero bytes. Use --sparse=never to inhibit creation of sparse files.
默认情况下,缺省使用--sparse=auto,会自动检测源文件是否为稀疏原文件,以决定目标文件是否为稀疏文件。当指定--sparse=always,会一直创建目标文件为稀疏文件,无论源文件中是否存在足量的0字节序列。使用--sparse=never禁止创建稀疏文件。
When --reflink[=always] is specified, perform a lightweight copy, where the data blocks are copied only when modified. If this is not possible the copy fails, or if --reflink=auto is specified, fall back to a standard copy.
当指定--reflink或--reflink=always,指定一个轻量级的复制,即coW,当修改时,只复制被修改的数据块。如果避免拷贝失败,或指定--reflink=auto,回退到标准复制。
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values:
除非设置了--suffix选项或SIMPLE_BACKUP_SUFFIX变量,否则使用'~'后缀。版本控制方式由--backup选项决定,或由VERSION_CONTROL环境变量决定。可选方式如下:
none, off
never make backups (even if --backup is given)
虽然给定--backup参数,但不生成备份文件,即不作备份
numbered, t
make numbered backups
生成编号备份文件
existing, nil
numbered if numbered backups exist, simple otherwise
如果存在编号备份文件,则使用编号备份文件,否则使用默认的备份方式
simple, never
always make simple backups
生成简易的备份文件,默认的备份方式
As a special case, cp makes a backup of SOURCE when the force and backup options are given and SOURCE and DEST are the same name for an existing, regular file.
作为一个特殊案例,当同时给定force和backup,原文件名同目标存在的常规文件的名称相同时,备份原文件。
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report cp translation bugs to <http://translationproject.org/team/>
AUTHOR
Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
COPYRIGHT
Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
SEE ALSO
The full documentation for cp is maintained as a Texinfo manual. If the info and cp programs are properly installed at your site, the command
info coreutils 'cp invocation'
should give you access to the complete manual.
cp 的完整文档是以Texinfo手册形式维护的。如果info和cp程序都已经安装,那么执行命令:
info coreutils 'cp invocation'
应该会让你访问到整篇手册。
GNU coreutils 8.22 June 2014 CP(1)
相关推荐
Linux必备命令--之cp命令详解
Linux下的cp命令详解,希望对大家有用,谢谢合作!
putty之pscp命令详解
Linux cp命令 Linux cp命令主要用于复制文件或目录。 语法 cp [options] source dest 或 cp [options] source... directory 参数说明: -a:此选项通常在复制目录时使用,它保留链接、文件属性,并复制目录下的所有...
本篇文章主要介绍了Linux 的cp命令详解, cp指令用于复制文件或目录,有兴趣的可以了解一下。
Linux Find 命令详解 非常详尽
Linux 文件处理命令详解 Linux 文件处理命令详解是 Linux 操作系统中的一种重要知识点,它提供了多种文件处理命令,帮助用户快速和高效地处理文件。本文将从基本概念开始,介绍 Linux 文件处理命令的格式和使用方法...
主要介绍了Linux 中的文件复制cp命令和scp命令详解的相关资料,需要的朋友可以参考下
本文为大家详细介绍Linux中cp命令和scp命令的使用。
主要描述linux中常用到的命令:cd,ls,chown ,cp,cup,find,less,ln...等。
13. cp 14. mv 15. rm 16. find 17. grep 18. more 19. less 20. head 21. tail 22. cut 23. at 24. crontab 25. sleep 26. kill 27. ps pstree 28. top 29. expr 30. locate 31. split 33. man,info 34. alias 35....
详细解释JAVA命令在编程JAVA程序时的一些可选参数,用以生成适合的目标程序和性能调优
Linux常用命令 – 已学 cd (路径的切换) rm(后接-rf 可删除文件或文件夹) ls(查看当前路径下的文件和文件夹) mkdir(创建文件夹) touch(创建文件) cat(查看文件内容)mv (移动文件,也可以重命名...
可以直接打印 共11页 第一章 目录及文件操作命令 2 1.1 ls 2 1.2 pwd 2 1.3 cd 2 1.4 mkdir 2 1.5 rmdir 2 1.6 cat 2 1.7 head 2 1.8 more 2 1.9 cp 3 1.10 mv 3 1.11 rm 3 ...UNIX的Shell命令详解 10
本篇文章主要介绍了Linux中拷贝 cp命令中拷贝所有的写法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下。
协处理器是一种芯片,用于减轻系统微处理器的特定处理任务。例如,数学协处理器可以控制数字处理;图形协处理器可以处理视频绘制。例如,intel pentium 微处理器就包括内置的数学协处理器。。。
大数据基础-Linux基础详解课程
Linux系统命令及其使用详解:cat cd chmod ch cp cut
介绍 tree 命令英文理解为树的意思,其功能是是创建文件...tree命令详解 -a 显示所有文件和目录。 -A 使用ASNI绘图字符显示树状图而非以ASCII字符组合。 -C 在文件和目录清单加上色彩,便于区分各种类型。