Computing.Net > Forums > Linux > Tar up key files by extension?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Tar up key files by extension?

Reply to Message Icon

Name: hippiejoeland (by HippieJoeLand)
Date: April 18, 2007 at 18:07:52 Pacific
OS: OS X/*nix
CPU/Ram: average
Product: 1-2GB
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Guy
Date: May 4, 2007 at 16:16:53 Pacific
Reply:

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



0

Response Number 2
Name: Guy
Date: May 4, 2007 at 16:29:57 Pacific
Reply:

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

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



0

Response Number 3
Name: hippiejoeland (by HippieJoeLand)
Date: May 24, 2007 at 13:39:41 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: Tar up key files by extension?

How do you clean up temp files? www.computing.net/answers/linux/how-do-you-clean-up-temp-files/8102.html

Dose linux screw up Mac files? www.computing.net/answers/linux/dose-linux-screw-up-mac-files/24083.html

HELP! with unpacking .TGZ file www.computing.net/answers/linux/help-with-unpacking-tgz-file/9852.html