linux - Using find to exclude a directory and tar up everything else in a directory -
linux - Using find to exclude a directory and tar up everything else in a directory -
i have next in directory:
dir1 dir2 file1 file2
i want tar except dir1
when do:
find . -path '*dir1*' -prune -o -print
i don't see dir1 in output ( expected)
but when do:
find . -path '*dir1*' -prune -o -exec tar -czvf documents.tgz '{}' \+
i see dir1 gets tarred in documents.tgz. why ?
if using "find" not mandatory requirement, assuming "main_dir" parent directory name.
tar --exclude=main_dir/dir1 -cvzf tarred_file.gz main_dir/
linux bash find gnu-coreutils
Comments
Post a Comment