Tar Tricks

On September 29, 2009, in Mac, Terminal, by Kevin

Terminal_larger

I’m frequently asked by support people to send them log files, which can be pretty big. So how do I send a 25MB directory of logs to someone? Stupid tar tricks ofcourse!

To just tar a directory and leave it full sized

tar -cvf archive.tar /directory/to/tar

where c is create, v is verbose and f is to name the archive.

To get a smaller file, tar w/ gzip compression

tar -cvzf archive.tar.gz /directory/to/tar

where c is create, v is verbose, z is to use gzip to compress and f is to name archive.

To make an even smaller archive using bzip2

tar -cvjf archive.tar.bz2 /directory/to/tar

where c is create, v is verbose, j is use bzip2 to compress (j, yeah that makes sense) and f is to name archive. You can replace c with x to extract, leaving off the directory path.

tar -xvf archive.tar

tar -xvzf archive.tar

and

tar -xvjf archive.tar

respectively.