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