|
|
HP-UX Reference Volume 1 of 5 > ccp(1) |
|
NAMEcp — copy files and directory subtrees SYNOPSIScp [-f|-i] [-p] [-e extarg ] file1 new_file cp [-f|-i] [-p] [-e extarg ] file1 [file2 ...] dest_directory cp [-f|-i] [-p] [-R|-r] [-e extarg ] directory1 [directory2 ...] dest_directory DESCRIPTIONcp copies:
cp fails if file1 and new_file are the same (be cautious when using shell metacharacters). When destination is a directory, one or more files are copied into that directory. If two or more files are copied, the destination must be a directory. When copying a single file to a new file, if new_file exists, its contents are destroyed. If the access permissions of the destination dest_directory or existing destination file new_file forbid writing, cp aborts and produces an error message ``cannot create file''. To copy one or more directory subtrees to another directory, the -r option is required. The -r option is ignored if used when copying a file to another file or files to a directory. If new_file is a link to an existing file with other links, cp overwrites the existing file and retains all links. If copying a file to an existing file, cp does not change existing file access permission bits, owner, or group. When copying files to a directory or to a new file that does not already exist, cp creates a new file with the same file permission bits as file1, modified by the file creation mask of the user if the -p option was not specified, and then bitwise inclusively ORed with S_IRWXU. The owner and group of the new file or files are those of the user. The last modification time of new_file (and last access time, if new_file did not exist) and the last access time of the source file1 are set to the time the copy was made. Options
Access Control Lists (ACLs)If new_file is a new file, or if a new file is created in dest_directory, it inherits the access control list of the original file1, file2, etc., altered to reflect any difference in ownership between the two files (see acl(5)). EXTERNAL INFLUENCESEnvironment VariablesLC_CTYPE determines the interpretation of text as single and/or multi-byte characters. LANG and LC_CTYPE determine the local language equivalent of y (for yes/no queries). LANG determines the language in which messages are displayed. If LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, cp behaves as if all internationalization variables are set to "C". See environ(5). EXAMPLESThe following command moves the directory sourcedir and its contents to a new location (targetdir) in the file system. Since cp creates the new directory, the destination directory targetdir should not already exist. cp -r sourcedir targetdir && rm -rf sourcedir The -r option copies the subtree (files and subdirectories) in directory sourcedir to directory targetdir. The double ampersand (&&) causes a conditional action. If the operation on the left side of the && is successful, the right side is executed (and removes the old directory). If the operation on the left of the && is not successful, the old directory is not removed. This example is equivalent to: mv sourcedir targetdir To copy all files and directory subtrees in the current directory to an existing targetdir, use: cp -r * targetdir To copy all files and directory subtrees in sourcedir to targetdir, use: cp -r sourcedir/* targetdir Note that directory pathnames can precede both sourcedir and targetdir. To create a zero-length file, use any of the following: cat /dev/null >file cp /dev/null file touch file SEE ALSOcpio(1), ln(1), mv(1), rm(1), link(1M), lstat(2), readlink(2), stat(2), symlink(2), symlink(4), acl(5). |
|