PDA

View Full Version : tar question - include only *.py files



wrightee
May 5th, 2008, 12:05 PM
Hi - sorry, this isn't really programming talk but I couldn't figure out where else to put it.. I have a bit of a crisis going on and need to tar up all files that match a pattern in a directory tree; I figured out excluding stuff but aren't sure on including only files that match a pattern. Could someone please put me out of my misery! Thanks in advance.

tseliot
May 5th, 2008, 12:12 PM
Try this:

tar -cvvf foo.tar ~/*.py

or

tar -cvvf foo.tar your_directory/*.py

wrightee
May 5th, 2008, 12:25 PM
That half worked.. though I need to go down into the directory tree and find all the *.py's there too; this restricts to current directory.. how can I make it descend? Thanks for your help so far.

wrightee
May 5th, 2008, 12:51 PM
find . -name \*.py|xargs tar cvfz osp.tar.gz

That worked.