Linux cp -r 没有隐藏文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11557114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cp -r without hidden files
提问by Rahul
I have two directories and one is empty.
我有两个目录,一个是空的。
The first directory has many sub directories with hidden files. When I cp -r
content from first directory to the second one, the hidden files gets copied too. Any solutions to escape them?
第一个目录有许多带有隐藏文件的子目录。当我cp -r
从第一个目录内容到第二个目录时,隐藏文件也会被复制。有什么办法可以逃脱它们吗?
采纳答案by Eugene Yarmash
You can use rsync:
您可以使用 rsync:
rsync -av --exclude=".*" src dest
回答by Tuxdude
You can do
你可以做
cp -r SRC_DIR/* DEST_DIR
to exclude all .files and .dirs in the SRC_DIR level, but still it would copy any hidden files in the next level of sub-directories.
排除 SRC_DIR 级别中的所有 .files 和 .dirs,但它仍然会复制下一级子目录中的任何隐藏文件。
回答by slitvinov
rsynchas "-C" option
rsync有“-C”选项
http://rsync.samba.org/ftp/rsync/rsync.html
http://rsync.samba.org/ftp/rsync/rsync.html
Example:
例子:
rsync -vazC dir1 dir2