Apr 24

tar a file or directory and 7zip it in one go

Category: Linux   — Published by goeszen on April 24, 2012 at 8:04 pm

tar cf - <path or file> | 7zr a -si <output>.tar.7z

This means: tar "c" creates an archive, to "f" file (or device), in this case stdout ("-", the minus), all piped to 7-zip, here 7zr, reads from stdin ("-si") and outputs a 7zip file - all connected by the pipe.

An interesting variant might be to pipe tar output to lz4. lz4 is a little command line tool implementing the LZ4 compression scheme. It's very fast, similar to Google's Snappy/Zippy, and provides a light compression without slowing down write throughput that much:

tar cf - <path or file> | lz4 - <output>.tar.lz4

More file archiving/compression posts:

Leave a Reply