In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The purpose of this article is to share with you about the use of the cp command for linux to copy files. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Linux copy file command is: "cp" command, English full name "copy file", can be used to copy one or more source files or directories to the specified destination file or directory; it can copy a single source file into a specified file name of a specific file or an existing directory.
The Linux cp (English full spelling: copy file) command is mainly used to copy files or directories.
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-a: this parameter has the same effect as specifying the "- dpR" parameter at the same time;-d: when copying a symbolic connection, the target file or directory is also established as a symbolic connection and points to the original file or directory connected to the source file or directory;-f: forcibly copy the file or directory, regardless of whether the target file or directory already exists;-I: ask the user before overwriting an existing file -l: establish a hard connection to the source file instead of copying the file;-p: retain the attributes of the source file or directory;-Rhampr: recursive processing, processing all files in the specified directory with subdirectories;-s: establish a symbolic connection to the source file instead of copying the file -u: after using this parameter, the file will be copied only when the change time of the source file is longer than that of the target file, or when the target file with corresponding names does not exist;-S: when backing up the file, replace the default suffix of the file with the specified suffix "SUFFIX";-b: back up the target file before overwriting the existing file destination;-v: show the operation performed by the command in detail. Parameter source file: make a list of source files. By default, the cp command cannot copy directories, and if you want to copy directories, you must use the-R option; destination file: specify the target file. When the Source File is multiple files, the destination File is required to be the specified directory. Example
If you copy a file to an object file and the target file already exists, the contents of the target file will be corrupted. All parameters in this command can be either absolute or relative pathnames. It usually comes in handy. Or dots.. In the form of. For example, the following command copies the specified file to the current directory:
Cp.. / mary/homework/assign.
The directories specified by all target files must already exist and cannot be created by the cp command. If you do not have permission to copy files, the system displays an error message.
Copy the file file to the directory / usr/men/tmp and rename it file1
Cp file / usr/men/tmp/file1
Copy all files and their subdirectories under the directory / usr/men to the directory / usr/zh
Cp-r / usr/men / usr/zh
Interactively copy all .c files starting with m in the directory / usr/men to the directory / usr/zh
Cp-I / usr/men massif. C / usr/zh
When we use the cp command to copy files under Linux, we sometimes need to overwrite some files with the same name, and when we overwrite files, we will be prompted: we need to press Y constantly to determine the execution of the overwrite. It's okay to have a small number of files, but hundreds of them are estimated to vomit blood by Y, so I summed up a method for a long time:
Cp aaa/* / bbb
Copy all the files under the aaa directory to the / bbb directory. If there are files with the same name as aaa in the / bbb directory, press Y to confirm and skip the subdirectories under the aaa directory.
Cp-r aaa/* / bbb
This time you still need to press Y to confirm the operation, but no subdirectories are ignored.
Cp-r-an aaa/* / bbb
You still need to press Y to confirm the operation, and the aaa directory and subdirectories and file attributes are also passed to / bbb.
\ cp-r-an aaa/* / bbb
Successful, no prompt to press Y, passed directory properties, did not skip the directory.
Thank you for reading! What is the use of the cp command on linux copying files to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
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.