LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 11-25-2009, 12:29 PM   #1
slinky66
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Rep: Reputation: 0
using tar to compress specific files in a directory named a certain way


Hi All,

I need to create a tar archive of only files that start with "60-", located in a directory with a lot of other files that I don't want in the archive.

I tried this but it doesn't work:

tar -zcvf backfill.tar.gz | grep "60-"

Can someone help?

Thanks
 
Old 11-25-2009, 12:43 PM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 138Reputation: 138
Quote:
Originally Posted by slinky66 View Post
Hi All,

I need to create a tar archive of only files that start with "60-", located in a directory with a lot of other files that I don't want in the archive.

I tried this but it doesn't work:

tar -zcvf backfill.tar.gz | grep "60-"

Can someone help?

Thanks
You're over-complicating it:

Code:
tar -zcvf backfill.tar.gz 60-*


John G
 
Old 11-25-2009, 01:02 PM   #3
slinky66
LQ Newbie
 
Registered: Nov 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks. When I ran the command the way you suggested,I received the "argument list too long" message so I created a text file containing the list of files:

find /usr/www/htdocs/images/closeup | grep "60-" > filelist.txt

And then, fed the text file to tar:

tar -zcvf backfill.tar.gz --files-from filelist.txt

Worked fine.

Thanks
 
Old 11-25-2009, 01:31 PM   #4
fara78
LQ Newbie
 
Registered: Apr 2005
Posts: 21

Rep: Reputation: 15
i think this works too

tar -zcvf backfill.tar.gz `ls 60\-*`
 
  


Reply

Tags
file, specific, tar


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
tar doesn't compress .hidden files in the same directory it is run in? BassKozz Linux - Newbie 2 06-02-2009 04:46 PM
tar extract specific directory lrt Linux - Software 7 12-01-2007 08:40 AM
Is it possible to unpack a *.tar into a specific directory whammack Linux - Software 3 01-29-2007 06:04 PM
compress a directory using tar muskiediver Linux - General 4 07-18-2006 10:24 AM
How To extract .tar.gz To A Specific Directory? George2 Linux - Software 4 02-18-2006 07:01 AM


All times are GMT -5. The time now is 12:37 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration