In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use the cp command in Linux", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to use the cp command in Linux" this article.
The Linux common command cp 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
Cp copies a source file or directory to a destination file or directory
Add that the cp command also supports copying multiple files at the same time, 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 the 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;-Rmax r: recursive processing, all files in the specified directory are processed together 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
Target file: specify the target file. When the Source File is multiple files, the destination File is required to be the specified directory.
In the first line below the example is the cp command and the specific parameters (- r is "recursive",-u is "update", and-v is "detailed"). The next three lines display information about the copied file, and the last line displays a command line prompt. In this way, I only copy the new files to my storage device, and I use the "update" and "detailed" options of cp.
Generally speaking, the parameter-r can also be used in a more detailed style-recursive. But in a short way, it can also be used in this way-ruv.
Cp-r-u-v / usr/men/tmp ~ / men/tmp version backup-the backup=numbered parameter means "I'm going to make a backup, and it's a serial backup." So one backup is No.1, the second is No.2, and so on.
$cp-- force-- backup=numbered test1.py test1.py $ls test1.py test1.py.~1~ test1.py.~2~ 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 copies all files and their subdirectories under the directory / usr/men to the directory / usr/zh
Cp-r / usr/men / usr/zh interactively copies all .c files starting with m in the directory / usr/men to the directory / usr/zh
Cp-I / usr/men muse.c / usr/zh We use the cp command under Linux to copy files, sometimes we need to overwrite some files with the same name, and when we overwrite files, we will have a hint: we need to press Y constantly to make sure that the overwrite is performed. 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# still needs to press Y to confirm the operation this time, but the subdirectories are not ignored. Cp-r-an aaa/* / bbb# still needs 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# succeeded without prompting to press Y, passed directory attributes, and did not skip directories. Recursively force a directory to be copied to the specified directory to overwrite existing files
Cp-rfb. / *.. / backup# copies all files in the current directory to a sibling directory in the current directory, backup folder, and copies hidden files in the directory, such as .babelrc.
Cp-r aaa/.*. / bbb# copies all files starting with `.` in the aaa directory to the bbb directory. Cp-an aaa. / bbb/ # remember that the best'/'in the following directory is copied to the current directory with the parameter `- a`
Cp aaa.conf. / # copying aaa.conf to the current directory is all the content of the article "how to use the cp command in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.