Tar and compress a file in one step
Creating a compressed archive in UNIX in a single step is faster and is often the only method when disk space is limited.
To archive and compress a directory called ‘target’ in the current working directory into a file called target.tgz use:
tar cf - target | gzip -c > target.tgz
The - in the place of a tar output filename directs tar to send its output to the standard output which is redirected to gzip. Substituting bzip2, when available in your operating system, will also work and generally provides better compression ratios.






Add New Comment
Viewing 2 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment