Sunday, October 7, 2007

Tip for the day: TAR IS A ZIP

Ever want to tar and compress a file all in one command:

tar cf - /home/foo | compress > foo.tar.Z

gzip can be used the same way
tar cf - /home/foo | gzip > foo.tar.Z

If you wanted to capture the output so you had an index file of what the tar file contains:

For sh, ksh use:
tar cvf - /home/foo 2>foo.idx | compress > foo.tar.Z

For csh use:
(tar cvf - /home/foo | compress > /foo.tar.Z) >&foo.idx

and an index file will be created.

No comments: