Hi All,
Is there a way to do a "cp -r" and have it exclude certain directories?
Many thanks, -T
On 01Aug2019 14:13, ToddAndMargo ToddAndMargo@zoho.com wrote:
Is there a way to do a "cp -r" and have it exclude certain directories?
Aside from "chmod 0 those_directories..."?
Or: "cp -r a b; rm -r b/c b/d ..."?
Use rsync:
rsync -ia --exclude=/local/path/to/subdir1 --exclude=....... this that
Note that the leading "/" in the --exclude anchors the pattern to the top of "this", not the root directory.
Also note that there are a few rsync options which -a does not include, notably (IIRC) -H (preserve hard links - may consume memory), -X (extended attributes) and -A (acls).
Test with the -n option first.
Cheers, Cameron Simpson cs@cskk.id.au
On Thu, 2019-08-01 at 14:13 -0700, ToddAndMargo via users wrote:
Is there a way to do a "cp -r" and have it exclude certain directories?
Probably by using mind-bending regular expression rules.
rsync has a --exclude operand (which handles globs): rsync -axAXv --delete -e "ssh -p 20026" --exclude 'tmp.session/*' --exclude 'documents/*' /home/webmaster/public_html/server1.example.com/DocumentRoot/ rsync://server2.example.com/backup/ If you rsync'ing locally, you won't need the -e operand.
Bill
On 8/1/2019 5:13 PM, ToddAndMargo via users wrote:
Hi All,
Is there a way to do a "cp -r" and have it exclude certain directories?
Many thanks, -T _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
On Sat, Aug 3, 2019 at 9:49 AM ToddAndMargo via users users@lists.fedoraproject.org wrote:
Is there a way to do a "cp -r" and have it exclude certain directories?
The bash shell has myriads of ways to generate glob expressions that can filter only those directories that you want. And including only those means excluding all the others. 'bash glob' on the net will give you some idea.
Hope that helps.
Le 01/08/2019 à 23:13, ToddAndMargo via users a écrit :
Hi All,
Is there a way to do a "cp -r" and have it exclude certain directories?
export GLOBIGNORE= directories to exclude separated by colons cp -r ......
Den 2019-08-01 kl. 23:13, skrev ToddAndMargo via users:
Hi All,
Is there a way to do a "cp -r" and have it exclude certain directories?
I can't see how you can do that, but you can do thiss with rsync. Look at the man page for rsync. Look at following options:
--exclude=PATTERN exclude files matching PATTERN --exclude-from=FILE read exclude patterns from FILE
Many thanks, -T _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
On Thu, 2019-08-01 at 14:13 -0700, ToddAndMargo via users wrote:
Is there a way to do a "cp -r" and have it exclude certain directories?
Assuming that you only need to exclude one file or dir, how about: $ cd <src-dir> $ find . -depth | grep -v '^<excluded-path>' | cpio -pdumv <dest-dir> $ cd -
no.
You can do excludes (dir and files/wildcards) with rsync so you might want to look at using it instead.
On Sat, Aug 3, 2019 at 12:03 AM ToddAndMargo via users users@lists.fedoraproject.org wrote:
Hi All,
Is there a way to do a "cp -r" and have it exclude certain directories?
Many thanks, -T _______________________________________________ users mailing list -- users@lists.fedoraproject.org To unsubscribe send an email to users-leave@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org