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--
This article introduces the knowledge of "how to exclude one or more directories under linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Note: there is a data directory in the / home directory and five directories a, b, c, d and e in the data directory. Now copy all the directories except the e directory in the data directory to the / bak directory.
Method 1: execute the following command under the terminal command line
Cp-R `find / home/data-type d-path / home/data/e-prune-o-print | sed 1d` / bak
# # #
Script implementation
Script storage path / home/osyunwei.sh
Vi / home/osyunwei.sh # edit the script to add the following code
#! / bin/sh
Cp-R `find / home/data-type d-path / home/data/e-prune-o-print | sed 1d` / bak
Chmod + x / home/osyunwei.sh # add script execution permissions
Cd / home # enter the script storage directory
. / osyunwei.sh # execute script
# # #
Method 2: when you use the cp command to copy, you can only exclude one directory from being copied. If you want to exclude two or more directories, you need to use the rsync command to achieve it. See the following example
If you want to exclude a, b, c, and three directories under the / home/data directory, and copy all other directories at the same time, execute the following command
Yum install rsync # install rsync
Rsync-av-exclude data/a-exclude data/b-exclude data/c data/ bak
Note:-- the path after exclude cannot be an absolute path, it must be a relative path, or there will be an error.
This is the end of the content of "how to exclude one or more directories under the cp directory under linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.