cp - Unix, Linux Command


Advertisements


NAME

cp - To copy one or more files to another location.

SYNOPSIS

cp [options]... Source Dest
cp [options]... Source... Directory

DESCRIPTION

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.

The backup suffix is >, unless set with SIMPLE_BACKUP_SUFFIX. The version control can be set with VERSION_CONTROL, values are: t, numbered make numbered backups nil, existing numbered if numbered backups exist, simple otherwise never, simple 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.

OPTIONS

TagDescription
-a, --archivesame as -dpR
-b, --backupmake backup before removal
-d, --no-dereferencepreserve links
-f, --forceremove existing destinations, never prompt
-i, --interactiveprompt before overwrite
-l, --linklink files instead of copying
-p, --preservepreserve file attributes if possible
-P, --parentsappend source path to DIRECTORY
-rcopy recursively, non-directories as files
--sparse=WHENcontrol creation of sparse files
-R, --recursivecopy directories recursively
-s, --symbolic-linkmake symbolic links instead of copying
-S, --suffix=SUFFIXoverride the usual backup suffix
-u, --updatecopy only when the SOURCE file is newer than the destination file or when the destination file is missing
-v, --verboseexplain what is being done
-V, --version-control=WORDoverride the usual version control
-x, --one-file-systemstay on this file system
--helpdisplay this help and exit
--versionoutput version information and exit.

EXAMPLES

Copy sample.txt to sample.bak.

$ cat sample.txt
This is a sample file
$ cp sample.txt sample.bak
$ cat sample.bak
This is a sample file

Copy sample directory to home directory

$ cp -f /user/sample/* >


Advertisements