I am trying to write a simple bash script that will copy the entire contents of a folder including hidden files and folders into another folder, but I want to exclude certain specific folders. How could I achieve this?
相关问题
- How to get the return code of a shell script in lu
- JQ: Select when attribute value exists in a bash a
- Invoking Mirth Connect CLI with Powershell script
- Why should we check WIFEXITED after wait in order
- Emacs shell: save commit message
相关文章
- 使用2台跳板机的情况下如何使用scp传文件
- In IntelliJ IDEA, how can I create a key binding t
- Check if directory exists on remote machine with s
- shell中反引号 `` 赋值变量问题
- How get the time in milliseconds in FreeBSD?
- Is there a non-java, cross platform way to launch
- Making new files automatically executable?
- Reverse four length of letters with sed in unix
Use rsync:
Note that using
source
andsource/
are different. A trailing slash means to copy the contents of the foldersource
intodestination
. Without the trailing slash, it means copy the foldersource
intodestination
.Alternatively, if you have lots of directories (or files) to exclude, you can use
--exclude-from=FILE
, whereFILE
is the name of a file containing files or directories to exclude.--exclude
may also contain wildcards, such as--exclude=*/.svn*
Similar to Jeff's idea (untested):
Use tar along with a pipe.
You can even use this technique across ssh.
you can use tar, with --exclude option , and then untar it in destination. eg
see the man page of tar for more info
Untested...
You can use
find
with the-prune
option.An example from
man find
: