Thursday, October 28, 2010

Tar and gzip a folder in one line

Sometimes you don't have a fancy GUI to right-click and zip up a folder. All you have is the humble shell. We're talking about Linux or Solaris or AIX or any other Unix-based OS here.

The one-liner to tar and gzip your folder in one shot is

tar cvf - /home/yossarian | gzip - > yossarian.tar.gz

But what does it mean? Simply put, tar the folder called "/home/yossarian" and feed the resulting tar from the stdout of the tar command into the stdin of the gzip command to compress it, then further redirect the output of the gzip command into a filled "yossarian.tar.gz".

It's that simple. Hope this helps you when you need to compress entire folders in the terminal sometime.

Yossarian

No comments:

Post a Comment