LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Quick question about tar (backup) with same file extension (https://www.linuxquestions.org/questions/linux-general-1/quick-question-about-tar-backup-with-same-file-extension-546112/)

nguyendh 04-14-2007 09:31 PM

Quick question about tar (backup) with same file extension
 
Hi everyone,

I have my php files scatter all over the place and i only want to make a copy of these php file only.
I wonder if i can use tar to backup all file end with php extension.

Thanks,

Duy

jay73 04-14-2007 09:52 PM

tar czvf foo.tar.gz *.php

AceofSpades19 04-14-2007 09:52 PM

use a wildcard

nguyendh 04-14-2007 10:07 PM

Quote:

Originally Posted by jay73
tar czvf foo.tar.gz *.php

Thanks for reply. I tried as you suggested but it does not work. I received an error:
tar: *.php: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors

osor 04-15-2007 12:39 PM

How about
Code:

$ find -iname '*.php' | xargs tar czvf foo.tar.gz

nguyendh 04-16-2007 03:09 AM

Quote:

Originally Posted by osor
How about
Code:

$ find -iname '*.php' | xargs tar czvf foo.tar.gz

Your suggestion works. Thanks much for your help. It would be great if you explain what the command does.

:newbie:

Micro420 04-16-2007 10:26 AM

Code:

find -iname '*.php' | xargs tar czvf foo.tar.gz
find all files with extension .php. When those files with php extension are found, pass the results onto tar and execute tar to create and compress the file called foo.tar.gz


All times are GMT -5. The time now is 08:22 AM.