`cp': Copy files and directories ================================ `cp' copies files (or, optionally, directories). The copy is completely independent of the original. You can either copy one file to another, or copy arbitrarily many files to a destination directory. Synopsis: cp [OPTION]... SOURCE DEST cp [OPTION]... SOURCE... DIRECTORY If the last argument names an existing directory, `cp' copies each SOURCE file into that directory (retaining the same name). Otherwise, if only two files are given, it copies the first onto the second. It is an error if the last argument is not a directory and more than two non-option arguments are given. Generally, files are written just as they are read. For exceptions, see the `--sparse' option below. By default, `cp' does not copy directories. However, the `-R', `-a', and `-r' options cause `cp' to copy recursively by descending into source directories and copying files to corresponding destination directories. By default, `cp' follows symbolic links only when not copying recursively. This default can be overridden with the `--no-dereference' (`-d'), `--dereference' (`-L'), and `-H' options. If more than one of these options is specified, the last one silently overrides the others. `cp' generally refuses to copy a file onto itself, with the following exception: if `--force --backup' is specified with SOURCE and DEST identical, and referring to a regular file, `cp' will make a backup file, either regular or numbered, as specified in the usual ways (Note: Backup options). This is useful when you simply want to make a backup of an existing file before changing it. The program accepts the following options. Also see Note: Common options. `-a' `--archive' Preserve as much as possible of the structure and attributes of the original files in the copy (but do not attempt to preserve internal directory structure; i.e., `ls -U' may list the entries in a copied directory in a different order). Equivalent to `-dpR'. `-b' `--backup[=METHOD]' Note: Backup options. Make a backup of each file that would otherwise be overwritten or removed. 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. One useful application of this combination of options is this tiny Bourne shell script: #!/bin/sh # Usage: backup FILE... # Create a GNU-style backup of each listed FILE. for i in "$;" do cp --backup --force "$i" "$i" done `-d' `--no-dereference' Copy symbolic links as symbolic links rather than copying the files that they point to, and preserve hard links between source files in the copies. `-f' `--force' When copying without this option and an existing destination file cannot be opened for writing, the copy fails. However, with `--force'), when a destination file cannot be opened, `cp' then unlinks it and tries to open it again. Contrast this behavior with that enabled by `--link' and `--symbolic-link', whereby the destination file is never opened but rather is unlinked unconditionally. Also see the description of `--remove-destination'. `-H' If a command line argument specifies a symbolic link, then copy the file it points to rather than the symbolic link itself. However, copy (preserving its nature) any symbolic link that is encountered via recursive traversal. `-i' `--interactive' Prompt whether to overwrite existing regular destination files. `-l' `--link' Make hard links instead of copies of non-directories. `-L' `--dereference' Always follow symbolic links. `-p' `--preserve' Preserve the original files' owner, group, permissions, and timestamps. In the absence of this option, each destination file is created with the permissions of the corresponding source file, minus the bits set in the umask. Note: File permissions. `-P' `--parents' Form the name of each destination file by appending to the target directory a slash and the specified name of the source file. The last argument given to `cp' must be the name of an existing directory. For example, the command: cp --parents a/b/c existing_dir copies the file `a/b/c' to `existing_dir/a/b/c', creating any missing intermediate directories. Warning: the meaning of `-P' will change in the future to conform to POSIX. Use `--parents' for the old meaning, and `--no-dereference' for the new. `-r' Copy directories recursively, copying any non-directories and special files (e.g., symbolic links, FIFOs and device files) as if they were regular files. This means trying to read the data in each source file and writing it to the destination. It is usually a mistake to apply `cp -r' to special files like FIFOs and the ones typically found in the `/dev' directory. In most cases, `cp -r' will hang indefinitely trying to read from FIFOs and special files like `/dev/console', and it will fill up your destination disk if you use it to copy `/dev/zero'. Use the `--recursive' (`-R') option instead if you want to copy special files, preserving their special nature rather than reading from them to copy their contents. `-R' `--recursive' Copy directories recursively, preserving non-directories (contrast with `-r' just above). `--remove-destination' Remove each existing destination file before attempting to open it (contrast with `-f' above). `--sparse=WHEN' A "sparse file" contains "holes"--a sequence of zero bytes that does not occupy any physical disk blocks; the `read' system call reads these as zeroes. This can both save considerable disk space and increase speed, since many binary files contain lots of consecutive zero bytes. By default, `cp' detects holes in input source files via a crude heuristic and makes the corresponding output file sparse as well. The WHEN value can be one of the following: `auto' The default behavior: the output file is sparse if the input file is sparse. `always' Always make the output file sparse. This is useful when the input file resides on a filesystem that does not support sparse files (the most notable example is `efs' filesystems in SGI IRIX 5.3 and earlier), but the output file is on another type of filesystem. `never' Never make the output file sparse. This is useful in creating a file for use with the `mkswap' command, since such a file must not have any holes. `--strip-trailing-slashes' Remove any trailing slashes from each SOURCE argument. Note: Trailing slashes. `-s' `--symbolic-link' Make symbolic links instead of copies of non-directories. All source file names must be absolute (starting with `/') unless the destination files are in the current directory. This option merely results in an error message on systems that do not support symbolic links. `-S SUFFIX' `--suffix=SUFFIX' Append SUFFIX to each backup file made with `-b'. Note: Backup options. `--target-directory=DIRECTORY' Specify the destination DIRECTORY. Note: Target directory. `-v' `--verbose' Print the name of each file before copying it. `-V METHOD' `--version-control=METHOD' Change the type of backups made with `-b'. The METHOD argument can be `none' (or `off'), `numbered' (or `t'), `existing' (or `nil'), or `never' (or `simple'). Note: Backup options. `-x' `--one-file-system' Skip subdirectories that are on different filesystems from the one that the copy started on. However, mount point directories _are_ copied.
automatically generated by info2www version 188.8.131.52