Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-14-2007, 10:31 PM   #1
LQ Newbie
Registered: Apr 2006
Posts: 3

Rep: Reputation: 0
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.


Old 04-14-2007, 10:52 PM   #2
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
tar czvf foo.tar.gz *.php
Old 04-14-2007, 10:52 PM   #3
Senior Member
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 58
use a wildcard
Old 04-14-2007, 11:07 PM   #4
LQ Newbie
Registered: Apr 2006
Posts: 3

Original Poster
Rep: Reputation: 0
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
Old 04-15-2007, 01:39 PM   #5
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 76
How about
$ find -iname '*.php' | xargs tar czvf foo.tar.gz
Old 04-16-2007, 04:09 AM   #6
LQ Newbie
Registered: Apr 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Originally Posted by osor
How about
$ 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.

Old 04-16-2007, 11:26 AM   #7
Senior Member
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
quick tar question neocontrol Linux - Software 1 07-10-2006 01:03 PM
How you install file with TAR.BZ2 extension?.. thanks suse2166 Linux - Software 14 01-03-2005 05:55 PM
file extension tar.tar wilbertcsci Linux - General 2 10-08-2003 10:21 AM
how to install sound and modem driver in tar.gz file extension in linux 7.3 nomi Linux - General 2 09-17-2003 02:24 PM
Quick question about tar phil1076 Linux - General 5 02-05-2002 02:12 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:55 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration