LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-14-2007, 09:31 PM   #1
nguyendh
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.

Thanks,

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

Rep: Reputation: 133Reputation: 133
tar czvf foo.tar.gz *.php
 
Old 04-14-2007, 09:52 PM   #3
AceofSpades19
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, 10:07 PM   #4
nguyendh
LQ Newbie
 
Registered: Apr 2006
Posts: 3

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

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

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

 
Old 04-16-2007, 10:26 AM   #7
Micro420
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
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
 
  


Reply


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 12:03 PM
How you install file with TAR.BZ2 extension?.. thanks suse2166 Linux - Software 14 01-03-2005 04:55 PM
file extension tar.tar wilbertcsci Linux - General 2 10-08-2003 09: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 01:24 PM
Quick question about tar phil1076 Linux - General 5 02-05-2002 01:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:25 AM.

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