find ~/bin/ -name "*sh" -print0 | xargs -0t tar -zcvf foofile.tar.gz

Compress files found with find

tar options may change ;) c to compress into a tar file, z for gzip (j for bzip) man tar -print0 and -0t are usefull for names with spaces, \, etc.

5
By: lhb
2009-02-17 08:48:34

These Might Interest You

  • The gzexe utility allows you to compress executables in place and have them automatically uncompress and execute when you run them. FYI: You can compress any executable sha-bang scripts as well (py, pl, sh, tcl, etc.).


    5
    gzexe name ...
    bogomips · 2010-09-27 19:57:43 0

  • -2
    for i in "*.txt"; do tar -c -v -z -f $i.tar.gz "$i" && rm -v "$i"; done
    Nichlas · 2011-06-25 20:39:06 0
  • Creates a PDF file where each page will be a layer from de original TIFF file. You can apply many other filters and transformations. convert multi_layer.tif -page a4 -compress jpg multi_page.pdf To set the page size convert multi_layer.tif -crop 590x790+20+30 -compress jpg multi_page.pdf To include only a portion of the image (discard first horizontal 20 pixels and first vertical 30 pixels, include the next 590 horizontal and 790 vertical pixels) convert multi_layer.tif -delete 1,3,5-10 -compress jpg multi_page.pdf Discard mentioned layers


    0
    convert multi_layer.tif -compress jpg multi_page.pdf
    algol · 2013-09-26 14:44:01 0
  • This command will copy a folder tree (keeping the parent folders) through ssh. It will: - compress the data - stream the compressed data through ssh - decompress the data on the local folder This command will take no additional space on the host machine (no need to create compressed tar files, transfer it and then delete it on the host). There is some situations (like mirroring a remote machine) where you simply cant wait for a huge time taking scp command or cant compress the data to a tarball on the host because of file system space limitation, so this command can do the job quite well. This command performs very well mainly when a lot of data is involved in the process. If you copying a low amount of data, use scp instead (easier to type) Show Sample Output


    12
    ssh <host> 'tar -cz /<folder>/<subfolder>' | tar -xvz
    polaco · 2009-11-10 20:06:47 4

  • 2
    find /path/to/files -type f -mtime +7 | grep -v \.gz | xargs gzip
    f4nt · 2009-02-21 15:57:05 3
  • Should do exactly the same - compress every file in the current directory. You can even use it recursively: gzip -r .


    -3
    gzip *
    funky · 2010-03-29 10:58:40 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: