I want to take backup of selective files say *.py under a directory. How can i do that?

Please help me to achieve it.

link|improve this question
feedback

3 Answers

Actually, you'd probably want something more like

tar cvf filename.tar `find . -name '*.py'`

The first example would only get *.py files one level deep.

link|improve this answer
feedback

tar cf filename.tar *.py Should do what you need.

link|improve this answer
feedback

In order to accommodate possible filenames with spaces and do a recursive search, use:

find . -type f -name '*.py' -print0 | tar --null cvf archive_name.tar -T -
link|improve this answer
You probably want 'cvf' as the filename has to come as the argument to f – Kamil Kisiel Feb 17 '10 at 17:17
Fixed typo. Thanks. – Dennis Williamson Feb 17 '10 at 18:02
feedback

Your Answer

 
or
required, but never shown