您的位置:首页 > 其它

如何将一个目录中的文件拷贝到另一个目录,并在拷贝时忽略你不想要的文件或目录

2016-05-25 17:02 991 查看
这个需求不要用cp命令了,因为那牵扯到太多的正则表达式,太复杂。简单一点的方法是用rsync命令。

用法示例:

rsync -av --progress a/ b/ --exclude 3/

以上命令将目录a中的所有内容复制到目录b中,并在复制过程中忽略掉目录a中的目录3

注意:

--exclude 参数后的路径必须是相对于拷贝源的,此例中即是相对与目录a的。而且此处不能用绝对路径只能用相对路径!!!!!

如,这样就不对了:rsync -av --progress a/ b/ --exclude /home/liyaochuan/work/test/a/3/

可以有多个--exclude参数,

如:rsync -av --progress a/ b/ --exclude 3/ --exclude 2/ 

以下内容只针对我当前的狗日的被强奸的工作模式做个笔记,请略过!

目前的工作,在顶层目录用svn up命令更新完代码后,按照如下步骤来管理狗日的本地base和狗日的本地mode:

0. 先在狗日的 v90_pro中的kernel中执行clean

make distclean

将编译中间文件删除干净,后续才能方便的做这狗日的更新!

1. 在顶层目录执行svn up

liyaochuan@dttzd-05:~/work/V$ svn up 

2. 

用git管理狗日的base中的kernel

cd ~/work/V/base/kernel/linux-3.10

git add .

git commit -m "add the the update of the fuck base on revision xxxx "

用git管理狗日的mode中的kernel

cd ~/work/V/mode/kernel/linux-3.10

git add .

git commit -m "add the the update of the fuck mode on revision xxxx "

3. 将狗日的base目录和狗日的mode目录合并成狗日的v90_pro目录

先把狗日的base中的全部内容复制到狗日的 v90_pro中,忽略掉kernel中的.git

cd ~/work/V

rsync -av --progress base/ v90_pro/ --exclude kernel/linux-3.10/.git/

再把狗日的mode中的全部内容复制到狗日的 v90_pro中,忽略掉kernel中的.git

cd ~/work/V

rsync -av --progress mode/ v90_pro/ --exclude kernel/linux-3.10/.git/

 完毕,用git管理一下这狗日的v90_pro中的kernel

cd ~/work/V/v90_pro/kernel/linux-3.10

git add .

git commit -m "add the the update of the fuck base and the fuck mode on revision xxxx "

好了可以了。最后在fuck一次这狗日的base和狗日的mode
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  rsync -av --exclude 复制 cp