tar gzip on the fly Steve Stonebraker October 18, 2011 You can Tar + gzip on the fly in linux # tar cvf - somedir | gzip -c > somedir.tar.gz Tags: tar gzip on the fly
3 thoughts on “tar gzip on the fly”
Why not just use -z for gzip or -j for bzip2 to do it inline instead of piping it to gzip?
tar -czvf somedir.tar.gz somedir/
bzip2 version (better compression):
tar -cjvf somedir.tar.bz2 somedir/
Thanks for the tip =). I think I am so use to this format because I work with lzop a lot and tar does not support lzop natively.
Yep, that makes sense.
LZO has faster throughput than gzip too but I still prefer gzip for shallow compression needs and bzip2 for when I really need to mash a square peg in a round hole. 🙂
Here’s an interesting benchmark comparison that someone did:
bzip2 has always been slower than gzip IMHO but the compression ratio is far superior and since both gzip and bzip2 can be done inline with tar, I’ve rarely found a performance need to move into the newer compression project LZO. That said though, you’d think being around since 1996 would warrant a tar flag for LZO… still don’t know why it hasn’t been added. Oh well.