Home > linux > Compress a folder with tar

Compress a folder with tar

To archive and compress a folder with tar use this command:


$ tar -czvf folder.tar.gz folder

Be careful with the parameters order: tar -czvf is not the same as tar -cvfz. The fist one is ok, but the second one ends with an error:

$ tar -cvfz folder.tar.gz folder
tar: folder.tar.gz: Cannot stat: No such file or directory
folder/
folder/file1.txt
folder/file2.txt
folder/file3.txt
tar: Exiting with failure status due to previous errors

An ls will show a z file. The reason is that the -f parameter takes the next argument as the filename to archive, thus the z file in our folder. So you have to use the tar -czvf syntax.

About these ads
Categories: linux Tags: , ,
  1. May 2, 2013 at 18:30

    Hi there! I simply wish to offer you a huge
    thumbs up for your great info you’ve got here on this post. I am coming back to your website for more soon.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: