cp linux command of

Linux cp command is used to copy a file or directory.

Syntax: cp [ Options ] Source or dest      cp [ Options ] Source ... Directory

Parameter Description:

  • -a: This option is typically used when copying a directory, it retains links, file properties, and copy all the contents of the directory. Its role is equal dpR parameter combinations.
  • -d: Reserved links when copied. Here's a link is a shortcut to Windows systems.
  • -f: overwrite the destination file already exists, without prompting.
  • -i: In contrast with the -f option, prompt before overwriting the destination file, it asks the user to confirm whether to overwrite the answer target file will be overwritten when "y".
  • -p: In addition to copying the contents of the file, the time and also modify the access rights are also copied to the new file.
  • -r: If the source file is given a file directory, then copy all the subdirectories and files in this directory.
  • -l: do not copy the file, but the file is generated links.
-a equivalent -pdr (-a maintain the original property -r recursive copy -p: keeping property)
-rf forced recursive copy
eg:
When copying a file cp -a a.txt b.txt, also copy the properties of the original file, so the resulting file will be exactly the same, such as having the same group, owner and execute permissions
cp -r ./test ./test1 recursive copy folder, all files will be copied test, but should be noted that the goal must be a directory, not a file name
CP - R & lt Test / copy all files under NewTest usage instruction "CP" current directory "test /" note to the new directory "newtest": when the user uses the copy instruction directory, you must use the parameter "-r" or "- R ".

Guess you like

Origin www.cnblogs.com/carey9420/p/11983487.html