Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

Please help me to achieve it.

share|improve this question

3 Answers 3

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.

share|improve this answer

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

share|improve this answer

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 -
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.