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?
Asked
Active
Viewed 6.6k times
3
Martin Schröder
- 6,772
- 1
- 19
- 35
Samatha
- 63
- 1
- 1
- 2
-
5Possible duplicate of [How to uncompress separated tgz files?](https://askubuntu.com/questions/230602/how-to-uncompress-separated-tgz-files) kasper_341's answer – karel Jul 21 '19 at 06:12
-
1http://man7.org/linux/man-pages/man1/tar.1.html Under "device selection and switching"; also the [-f ARCHIVE] in the usage lines are a good hint. See also [how to search within a man page](https://askubuntu.com/questions/20752/how-can-i-search-within-a-manpage) or view the man page on the web and use your browser search feature. – Jason C Jul 21 '19 at 15:44
-
Possible duplicate of [How to unzip .tgz file using the terminal?](https://askubuntu.com/questions/499807/how-to-unzip-tgz-file-using-the-terminal) – Melebius Oct 09 '19 at 14:19
3 Answers
9
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).
muclux
- 5,034
- 4
- 20
- 43
6
-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
pa4080
- 29,351
- 10
- 85
- 161
-
2It 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 '19 at 15:44
-
1https://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 '19 at 16:53
-
1
5
-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
Rob Sweet
- 81
- 3