On Thu, Aug 16, 2018 at 10:40:14AM -0400, cyaiplexys wrote:
I'm trying to make a gzipped tarball. I want to exclude only a certain list of dot files but NOT ALL dot files (in other words tar the other dot files not on the list).I have (this is just an example):tar -czf archive.tgz /home/me/dirToARchive/. --exclude=/home/me/dirToARchive/.mysetuptemp --exclude=/home/me/dirToARchive/.myotherdotfile --exclude=/home/me/dirToARchive/.anotherdotfileIn the directory I want to Include *all other* dot files not in the --exclude above.I found it doesn't matter if I put the --excludes before the -czf or after everything, I still end up with EVERY dot file in the directory instead of ONLY the ones that are NOT on the list.I'm not great with tar, I admit. Is there a way to do what I'm proposing?
$ find /home/me/dirToARchive -print -depth | grep -v -x -f paths-to-exclude.txt | cpio -o -H ustar | gz > archive.tar.gz
cpio takes a list of filenames to archive on stdin, so we use find to list what we want, then filter that list through grep ("-f foo" says to get a list of filter expressions from file foo) before passing to cpio (which we've told to make a tar archive rather than its native format).
-- For more information, please reread.
Description: PGP signature