Question is due curiosity mostly… — it's kinda strange and awkward limitation considering tar's inability to list content w/o reading the whole (sometimes huge) file.
Asked
Active
Viewed 1,410 times
-5
-
To clarify (from comments): yeah, I'm aware of «-v», but it's kinda strange there's an extra option, in addition to 2 basic operation, meanwhile it seems there's nothing wrong in allowing both of them simultaneously. – poige Mar 06 '12 at 17:52
-
http://linux.die.net/man/1/tar – Zoredache Mar 06 '12 at 18:02
-
@Zoredache, are you sure it explains why tar can't support -t AND -x? :-) – poige Mar 06 '12 at 18:04
-
This question isn't very useful. You should only ask practical, answerable questions. Asking why software is designed a certain way is pointless. If you have a real problem related to perceived design limitations, then you should ask that instead. As for the man page, I added it because you were asking for details about options in a now-deleted comment. – Zoredache Mar 06 '12 at 18:12
-
@Zoredache I prefer [the BSD manpage](http://www.FreeBSD.org/cgi/man.cgi?query=tar&apropos=0&sektion=0&manpath=FreeBSD+9.0-RELEASE&arch=default&format=html) myself - the options section shows the mutually-exclusive combinations better :-) – voretaq7 Mar 06 '12 at 18:13
-
@Zoredache, are you mistaken regarding "were asking for details about options in a now-deleted comment, aren't you? – poige Mar 06 '12 at 18:21
-
Hard to know. I am pretty sure I saw a comment on @h0tw1r3 post asking about the other options. Thought it was you. I cannot see deleted comments, so I cannot confirm. – Zoredache Mar 06 '12 at 18:27
3 Answers
7
Any reason for tar: Can't specify both -x and -t
?*
Yes: Because in the designer's eyes this would be useless. If you have a tar file you either want to extract its contents (-x
), or you want to list them (-t
). Much like you can't specify -c -t
(You're creating an archive, why would you want to list the things you're adding to it, which you've presumably specified on the command line?)
As Bryan pointed out, if you want to see what's being extracted you can pass the -v
flag to tar -x
(or -c
)and it will print what it's processing.

voretaq7
- 79,879
- 17
- 130
- 214
-
«you either want to extract its contents (-x), or you want to list them» — you're deeply wrong in your assumption. – poige Mar 06 '12 at 17:45
-
@poige What else do you want to do to this archive? List, Extract or Append are pretty much your only options, just like a real tape... – voretaq7 Mar 06 '12 at 17:53
-
You're not wrong regarding list of modes, you're wrong when saying "either". – poige Mar 06 '12 at 17:58
-
@poige . . . and this is why they gave you the `-v` (verbose, "show me what you're doing") flag -- For the times when you want to see what you are extracting with `-x`, or want more information than just a simple list of filenames from `-t`). I'm afraid the answer to your question is "That's just how `tar` works.", with the usual open source follow-up of "(And if you don't like it, feel free to change the code on your box)" :-) – voretaq7 Mar 06 '12 at 18:11
-
UNIX' tools tend to avoid redundant entities, actually. That's why it's kinda strange to me. Also, I'm not sure whether «-t»'s output strictly coincides to «-xv». Are you? Wouldn't be some additional info shown in case of "-xv", comparing to "-t" only? – poige Mar 06 '12 at 18:25
-
http://svnweb.freebsd.org/base/stable/9/contrib/libarchive/tar/bsdtar.c?revision=229592&view=markup — regarding to BSD's at least, it's clear that they treat «-v» almost the same way as «-t», with the only exception for «-t» — which "sets mode". Both options increase verbosity, in general and in the same way. – poige Mar 06 '12 at 18:40
4
Will -xv
not give you the equivalent of -xt
?

Bryan
- 7,628
- 15
- 69
- 94
-
2
-
-
@Bryan, yeah, I'm aware of «-v», but it's kinda strange there's an extra option, in addition to 2 basic operation. – poige Mar 06 '12 at 17:50
-
1@poige Do not fear more information. If you don't need it This is what `awk` (or `cut`) are for. Remember that `-v` is a side-effect operator: It works exactly the same on `-t` or `-v`, but your primary operation is still *extracting* or *listing* the archive's contents. – voretaq7 Mar 06 '12 at 17:56
-
@voretaq7, anyways, I don't see any reason why those modes are mutually exclusive. They seem to be not, actually. – poige Mar 06 '12 at 18:07
2
tar has 5 "modes" (-c,-r,-t,-u,-x) which cannot be combined. All other arguments are just options to the desired mode.

h0tw1r3
- 2,776
- 19
- 17