0

This question already has an answer here:

I am learning about the basics of Linux and archiving/compressing TAR files i have stumbled across tar -xvf and was wondering what it does. I have checked the man pages and know that x means extract and v means verbose but what does f do?

marked as duplicate by karel, Fabby, Elder Geek, Martin Schröder, Kulfy Jul 21 at 17:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

6

As the man page says, -f or --file= defines the ARCHIVE file from which to extract. It's in the chapter 'Device selection and switching' (line #561 in my version).

5

-f option in tar means that the next argument is the name of the target tar file. So after the -f option you can't place another option, for example the following syntax is wrong:

tar -xvf --verbose file.tar # Incorrect

The following variants should be correct:

tar -xvf file.tar --verbose 
tar -xv --verbose -f file.tar
  • 1
    It might be interesting that, depending on your implementation and version of tar, and/or whatever option parsing library it uses, tar -xfv may or may not work. – Jörg W Mittag Jul 21 at 15:44
  • unix.stackexchange.com/a/1283/57213 "-f" tells tar that the next parameter is the file name of the archive or STDOUT if it is "-" – Bernhard Döbler Jul 21 at 16:53
  • Hi, @JörgWMittag, consider tar -xfv is not tar -xf -v. – pa4080 Jul 21 at 20:18
1

-xvf is the short (unix style) version of

--extract --verbose --file=

As a new tar user one useful option to learn is -t (--test) in place of -x, which lists to the screen without actually extracting it.

-tvf

Not the answer you're looking for? Browse other questions tagged or ask your own question.