Tuesday, October 30, 2007

Oh How I Hate Command Line Tar

It's cuz I'm dyslexic and I always get things backwards. Which comes first? The file I'm trying to create or the one I'm trying to tar up? Here's the answer for future reference.


tar -cf [the file you want to create] [the file(s)/directory(ies) you want to tar]


The "c" stands for "create". The "f" stands for "file" (the default is to pipe the tarred stuff to stdin). You can also turn it into a gzip file in the same go with the letter "z" or into a b-zip file with the letter "j".

Something of note: man tar actually gives useful examples, unlike most man pages which give information but no examples to help the slow of brain (like me).

Here are some examples from the man page as it lives on our office Web servers which are running CentOS Linux:

EXAMPLES
tar -xvf foo.tar
verbosely extract foo.tar

tar -xzf foo.tar.gz
extract gzipped foo.tar.gz

tar -cjf foo.tar.bz2 bar/
create bzipped tar archive of the directory bar called
foo.tar.bz2

tar -xjf foo.tar.bz2 -C bar/
extract bzipped foo.tar.bz2 after changing directory to bar

tar -xzf foo.tar.gz blah.txt
extract the file blah.txt from foo.tar.bz2

No comments: