Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.