How to exclude one or more directories from the CP directory under Linux

Source: Internet
Author: User

Description: The/home directory contains the data directory, the data directory contains a, B, C, D, e five directories, now to the data directory in addition to the E directory in all directories except for the/bak directory system operations www.osyunwei.com Warm reminder: qihang01 original content copyright, reproduced please specify the source and the original link method one: Terminal command line execute the following command Cp-r ' Find/home/data-type d  -path/home/data/e  -prune-o -print | Sed 1d '/bak####################################################### #脚本实现脚本存放路径/home/osyunwei.shvi/home/  osyunwei.sh   #编辑脚本, add the following code #!/bin/shcp-r ' Find/home/data-type d  -path/home/data/e  -prune-o-print | sed 1d '/bakchmod +x  /home/osyunwei.sh   #添加脚本执行权限cd/home  #进入脚本存放目录./osyunwei.sh   #执行脚本 ############# ########################################## #系统运维 www.osyunwei.com Warm reminder: qihang01 original content All rights reserved, Reprint please specify the source and the original link method two: When using the CP command to copy, can only exclude a directory is not copied, if you want to exclude two or more directories, you need to use the rsync command to implement, see the following example if you want to exclude the/home/data directory under a, B, C, three directories , while copying all other directories, execute the following command yum install rsync   #安装rsyncrsync-av--exclude data/a  --exclude data/b  --exclude data  /C Data   /bak Note: The path behind--exclude cannot be an absolute path, it must be a relative path, or an error will occur.

  

Methods to exclude one or more directories from the CP directory under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.