Tar up key files by extension?

Score
0
Vote Up
April 18, 2007 at 18:07:52 Pacific
Specs: OS X/*nix, average

I would like to recursively troll through my OS X and or nix systems, find files of importance based on file extension, and put them in a compressed tar. The problem I am having is getting Tar to accept the standard input from the prior commands. Here is what I have so far using .doc just as an example:

find / -type f -print | grep -iE '\.doc$' | tar -czvf test.tar.gz

Something like that is my goal...

Currently I am writing all results fromthe find/grep to a text file, then using the Include-files switch with Tar to tar them up via and && which just isn't as pleasing. Any ideas?

HippieJoe

PS. I tried using cpio with format tar then pushing it to gzip...i kept getting archive truncated errors.


Reply ↓  Report •


#1
Vote Down
Score
0
Vote Up
May 4, 2007 at 16:16:53 Pacific

Old post, but ....

do you have to have a one-liner?

Can not help you, however ...... e.g.

find . -name '*.java' >flist.txt
tar czvf a.tar.gz --files-from flist.txt

Guy



Reply ↓  Report •

#2
Vote Down
Score
1
Vote Up
May 4, 2007 at 16:29:57 Pacific

OK, the one-liner (on Linux, YMMV with OSX):

find . -name '*.java' | tar czvf a.tar.gz --files-from -



Reply ↓  Report •

#3
Vote Down
Score
0
Vote Up
May 24, 2007 at 13:39:41 Pacific

Guy,

Thanks a ton!! I never could get that standard out switch in the right place...I was using a two liner like your first suggestion. I like this much better!

The solution to find all files, tar and gzip them when the file ENDS in a .txt
(thanks to Guy):

find . -mount -depth -type f -print | grep -iE '*\.txt$' | tar -czvf ../test.tar.gz -T -

Thank you!

HippieJoe


Reply ↓  Report •

Reply to Message Icon Start New Discussion
Related Posts

« Open Source Email Server ... Installing a RUN file.... »

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.

Ask the Community!
Describe your Problem
Example: Hard Drive Not Detected on My PC