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/02 Report--
Today Xiaobian to share with you how to use linux cp command related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after some harvest, let's find out about it together.
CP command
Contents Basic operations
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 filename or into an existing directory. cp command also supports copying multiple files at the same time. When copying multiple files at once, 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 symbolic links, the target file or directory is also established as a symbolic link 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 link to the source file instead of copying the file;-p: preserve the attributes of the source file or directory;-R/r: Recursive processing, all files and subdirectories under the specified directory are processed together;-s: symbolic connection is established for source files instead of copying files;-u: files are copied only when the change time of source files is newer than that of target files or when target files with corresponding names do not exist;-S: when files are backed up, the default suffix of files is replaced by the specified suffix "SUFFIX";-b: target files are backed up before overwriting existing file targets;-v: Details the actions performed by the command. parameters
Source documents: Create a list of source documents. By default, the cp command cannot copy directories, and if you want to copy directories, you must use the-R option;
Target File: Specifies the target file. When the "source file" is multiple files, the "target file" is required to be the specified directory.
examples
If you copy a file into a destination file and the destination file already exists, the contents of the destination file will be corrupted. All parameters in this command can be either absolute or relative pathnames. It's usually used a little bit. Or dot.. form. For example, the following command copies the specified file to the current directory:
cp ../ mary/homework/assign .
All directories specified by the target file must already exist. The cp command cannot create directories. If you do not have permission to copy files, an error message appears.
Copy file to directory/usr/men/tmp and rename file1
cp file /usr/men/tmp/file1
Copy all files and subdirectories from directory/usr/men to directory/usr/zh
cp -r /usr/men /usr/zh
Interactively copy all.c files starting with m from directory/usr/men to directory/usr/zh
cp -i /usr/men m*.c /usr/zh
When we copy files using cp command under Linux, sometimes we need to overwrite some files with the same name. When overwriting files, there will be prompts: you need to keep pressing Y to determine the execution of overwriting. It was fine if the number of files was not large, but if there were a few hundred, I would probably vomit blood by pressing Y. Therefore, after a long time, I summarized a method:
cp aaa/* /bbb Copy all files under aaa directory to/bbb directory. At this time, if there is a file with the same name as aaa under/bbb directory, press Y to confirm and skip the subdirectory under aaa directory. cp -r aaa/* /bbb This time you still need to press Y to confirm the operation, but the subdirectory is not ignored. cp -r -a aaa/* /bbb still needs to press Y to confirm the operation, and the aaa directory and subdirectory and file attributes are also passed to/bbb.\ cp -r -a aaa/* /bbb Success, no prompt to press Y, directory attributes passed, directory not skipped. The above is "linux cp command how to use" all the content of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to 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.