JustinK
07-02-2001, 08:10 PM
I hope this is the right place for this.
I've been trying recently to figure out a way to tar up just certain file extensions in a directory and all its subdirectories. Does anyone happen to know if it can be done via just one command line? Been playing with stuff all day, but have yet to come up with anything. I'd appretiate any help anyone could give. :)
Originally posted by JustinK
I hope this is the right place for this.
I've been trying recently to figure out a way to tar up just certain file extensions in a directory and all its subdirectories. Does anyone happen to know if it can be done via just one command line? Been playing with stuff all day, but have yet to come up with anything. I'd appretiate any help anyone could give. :)
It cannot be done the "straight forward" way, no.
You can hower use find to do it. Something like this
find . | grep '\.txt$' > filenames
tar -T filenames -cvzf archive.tar.gz
--
Jens Kristian Søgaard, Mermaid Consulting I/S,
jens@mermaidconsulting.dk,
http://www.mermaidconsulting.com/
jtan15
07-02-2001, 08:33 PM
This should do the trick:
tar cvfz FILENAME.tar.gz *.extension */*.extension */*/*.extension
You of course want to replace ".extension" with the extension you are looking for, e.g. ".cgi". If you want to go more even more directories deep, just keep the pattern going with */*/*/*.extension as the next parameter.
Hope this helps. :)
JustinK
07-02-2001, 10:30 PM
Oohkay. I'll try those out. Just wondering if I was stressing over something I shouldn't be. :) Tried grep before but just getting used to all the commands is taking me awhile. I had grep at the end of it. ::sighs:: If all else fails, there's always creating a script to do the work for me. ;)
Madman2020
07-04-2001, 02:53 AM
I believe you can also do a tar --exclude=*.filename as well. But I would man tar to be sure.