Search code examples
linuxcentoszipgziptar

difference between tar zxf vs -xvf


I have a downloaded version of http://agentzh.org/misc/nginx/openresty-1.9.7.3.tar . I rename it to openresty-1.9.7.3.tar.gz.

I am trying to do the following in centOS-6.x:

tar zxf openresty-1.9.7.3.tar.gz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

whereas :

tar -xvf openresty-1.9.7.3.tar.gz works and untars to openresty-1.9.7.3.tar.gz.

Any reasons why the first one won't work? It works in my personal laptop but won't wont work in a server.


Solution

  • zxf means: gunzip (the 'z' letter) and extract (the 'x' letter) from file (the 'f' letter, and the file name follows).
    xvf means: extract (the 'x' letter) and be verbose (the 'v' letter) from file (the 'f' letter, and the file name follows).

    You renamed the openresty-1.9.7.3.tar to openresty-1.9.7.3.tar.gz, but this didn't make it gzipped tar archive. So first command fails, because this can't be gunzipped. Second command just verbosely extract the archive, without trying to gunzip it.