In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to copy files to multiple directories in the Linux operating system, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Use one command in Linux to copy directories to multiple folders.
In Linux, the cp command is often used to copy files from one folder to another. The simplest syntax is as follows:
# cp [options... .] Source (s) destination
Alternatively, you can use the advanced copy command, which displays a progress bar when copying large files or folders.
Take a look at the following command, usually you will use two different commands to copy the same file to a different folder:
# cp-v / home/aaronkilik/bin/sys_info.sh / home/aaronkilik/test # cp-v / home/aaronkilik/bin/sys_info.sh / home/aaronkilik/tmp
Copy files to multiple folders
Suppose you want to copy a specific file to five or more folders, does that mean you need to type five or more cp commands?
To get rid of this problem, you can use the cp command with the echo command, pipe, xargs command:
# echo / home/aaronkilik/test/ / home/aaronkilik/tmp | xargs-n 1 cp-v / home/aaronkilik/bin/sys_info.sh
In the above command, the path to the directory (dir1, dir2, dir3...dirN) is piped into the xargs command, meaning:
-n 1-tells the xargs command to take at most one argument per command line and sends it to the cp command.
Cp-used to copy files.
-v-enable detail mode to display more replication details.
Copy files to multiple locations in Linux
Try reading the man pages of cp, echo, and xargs to find all useful and advanced usage information:
The above $man cp $man echo $man xargs is all the contents of the article "how to copy files to multiple directories in the Linux operating system". 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.