Cp (Unix)
If the user has write access to a target file, the command copies the content by opening it in update mode. This preserves the file's inode instead of creating a new file with default permissions. The command was part of Version 1 Unix,[1] and is specified by POSIX. The implementation from GNU has many additional options beyond the POSIX specification.[2] The command is bundled in GNU Core Utilities[3] and is available in the EFI shell.[4] Options
ModesThe command has three principal modes of operation as inferred from command-line arguments.[5] Copy fileFor a path to an existing file followed by a path that does not refer to an existing directory, the file at the first path is copied to the second path. cp [-fHip][--] sourcefile targetfile Copy files to directoryFor one or more paths to existing files followed by a path to an existing directory, the files are copied to the directory. cp [-fHip] [--] sourcefile... targetdirectory Copy directoryWith the recurse command-line option, typically cp -r|-R [-fHip] [--] sourcedirectory... targetdirectory ExamplesThis copies file prog.c to file prog.bak. If prog.bak does not already exist, this creates it. If it does exist, its content will be replaced. cp prog.c prog.bak This copies the files jones and smith into the pre-existing directory clients. cp jones smith clients This copies file smith to a file named smith.jr. Instead of creating a file with the current date and time stamp, the command copies the date and time from the original. The copy also receives other metadata from the original including access control protection. cp -p smith smith.jr This reclusively copies the directory clients, including its files, subdirectories, and the files in those subdirectories, to a new directory customers/clients. cp -R clients customers Some implementations behave differently in recursive mode, depending on the termination of the directory path. Using See alsoWikibooks has a book on the topic of: Guide to Unix/Commands/File System Utilities#cp
References
External links
|
Portal di Ensiklopedia Dunia