Opening a .tar.gz file with a single command

前端 未结 7 1447
时光取名叫无心
时光取名叫无心 2021-01-31 15:13

When I download a .tar.gz file, I open it with two commands, first gunzip and then tar.

Is it possible to open it with just one command?

7条回答
  •  情深已故
    2021-01-31 15:36

    The only thing that I would add is that z usually only works on gnu tar. The typical UNIX tar won't have this in my experience at least. – Jon Mar 16 at 16:19

    The z option works well on my OS-X 10.5 as well.

    When it comes to memorizing, I think it´s easy to think of what you want and not just some letters.

    1. If you want to create an archive, then c will be the first option, else x will be the first option if you want to extract.
    2. If you want to compress/decompress with the gzip/gunzip program, then the next option should be z for zip. (All archives ending with .gz must be unzipped with the z option)
    3. The last mandatory option is f for the file.

    Then you usually end up with these two commands:

    • tar czf file.tar.gz /folder_to_archive/*
    • tar xzf file.tar.gz

提交回复
热议问题