In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
What is the purpose of the linux cp command? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
Linux cp command is mainly used to copy files or directories, such as when specifying more than two files or directories, and the final destination is an existing directory, then it will copy all the files or directories specified previously to this directory; if you specify multiple files or directories at the same time, and the final destination is not an existing directory, an error message will appear.
Linux cp command
Function: copy files or directories
Note: the cp instruction is used to copy files or directories, just like specifying more than two files or directories, and the final destination is an existing directory, then it will copy all the files or directories specified earlier to this directory. If you specify multiple files or directories at the same time, and the final destination is not an existing directory, an error message will appear.
Parameters:
-an or-- archive this parameter has the same effect as specifying the "- dpR" parameter at the same time
-b or-- backup deletes and overwrites the destination file. The backup 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
-I or-- interactive ask the user before overwriting the file
-l or-- link establishes 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 establishes a symbolic link to the source file instead of copying the file
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 when the destination file with corresponding names does not exist.
-v or-- verbose shows the execution process
-V or-- version-control= specifies that when backing up a file, the backup file name is named in the following three ways:
1.numbered or t, the backup number will be used, a ~ 1 ~ string will be added after the suffix, and the number will be incremented in turn.
2.simple or never will use a simple backup. The default backup suffix string is ~, or you can specify it with-S
3.existing or nil will use the current method, and the program will first check whether there is a backup number, if so, use the backup number, and if not, use a simple backup
-x or-- the file system of the file or directory copied by one-file-system must be the same as the file system on which the cp instruction was executed, otherwise files located in other partitions will not be copied or processed
-- 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
Cp-b-S _ bak a.txt / tmp
Thank you for reading! After reading the above, do you have a general understanding of the function of the linux cp command? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
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.