In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use the cp command". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The cp command is used to copy one or more source files or directories to a specified destination file or directory. It can copy a single source file into a specific file with a specified file name or an existing directory. The cp command also supports copying multiple files at the same time, and when copying multiple files at a time, the target file parameter must be an existing directory, otherwise an error will occur.
Syntax cp (option) (parameter) option
-an or-archive this parameter has the same effect as specifying the "- dpR" parameter at the same time
-b or-backup delete, overwrite the destination file and back up first, and the backed up file or directory is also established as a symbolic link and points to the source file or directory linked to the source file or directory. If this parameter is not added, if a symbolic link is encountered during the copy process, the source file or directory will be copied directly.
-f or-force forcibly copy a file or directory, regardless of whether the destination file or directory already exists
Ask the user before-I or-interactive overwrite the file
-l or-link establish a hard link to the source file instead of copying the file
-p or-preserve retains the attributes of the source file or directory, including owner, group, permissions, and time
-P or-parents retains the path to the source file or directory, which can be absolute or relative, and the destination directory must already be abundant in the
-r Recursive processing, which processes the files in the specified directory with the subdirectories. If the form of the source file or directory does not belong to the directory or symbolic link, it will be treated as an ordinary file.
Recursive processing of-R or-recursive to process files and subdirectories in a specified directory
-s or-symbolic-link establish symbolic links to source files instead of copying files
After-S or-suffix= backs up the destination file with the "- b" parameter, a backup string is added to the suffix of the backup file. The default backup suffix string is the symbol "~"
After-u or-update use this parameter, the file will be copied only when the modification time (Modification Time) of the source file is updated compared to the destination file, or the destination file with corresponding names does not exist.
-v or-verbose shows the execution process
-V or-version-control= specifies the following three ways to name backup files when backing up files:
Numbered or t, the backup number will be used, and a ~ 1 ~ string will be added to the suffix. Simple or never will use a simple backup. The default backup suffix string is ~. You can also use-S to specify that existing or nil will use the current mode. The program will first check whether there is a backup number, if so, use a backup number, if not, use a simple backup.
The file system of the file or directory copied by-x or-one-file-system must be the same as the file system on which the cp instruction is executed, otherwise it will not copy or process files located in other partitions.
-help displays online help
-sparse= sets the time to save rare files
-version display version
Example
Copy a file, only if the modification time of the source file is newer than the modification time of the destination file
Cp-u-v file1 file2
Copy the file file1 to the file file2
Cp file1 file2
Copy the file file1 to the file file2 interactively
Cp-I file1 file2
. Copy the file file1 to file2, and specify a forced copy mode because the destination file already exists
Cp-f file1 file2
Copy the directory dir1 to the directory dir2
Cp-R file1 file2
Copy the files file1, file2, file3 and directory dir1 to dir2 at the same time
Cp-R file1 file2 file3 dir1 dir2
Preserve file properties when copying
Cp-p a.txt tmp/
Preserve the directory structure of files when copying
Cp-P / var/tmp/a.txt. / temp/
Backup files are generated during replication
Cp-b a.txt tmp/
The backup file is produced when copying, and the tail mark is in ~ 1 ~ format.
Cp-b-V t a.txt / tmp
Specify the tail mark of the backup file
This is the end of cp-b-S _ bak a.txt / tmp "how to use the cp command". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.