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.
-
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.– poigeMar 6, 2012 at 17:52
-
linux.die.net/man/1/tar– ZoredacheMar 6, 2012 at 18:02
-
@Zoredache, are you sure it explains why tar can't support -t AND -x? :-)– poigeMar 6, 2012 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.– ZoredacheMar 6, 2012 at 18:12
-
@Zoredache I prefer the BSD manpage myself - the options section shows the mutually-exclusive combinations better :-)– voretaq7Mar 6, 2012 at 18:13
3 Answers
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.
-
«you either want to extract its contents (-x), or you want to list them» — you're deeply wrong in your assumption.– poigeMar 6, 2012 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...– voretaq7Mar 6, 2012 at 17:53
-
You're not wrong regarding list of modes, you're wrong when saying "either".– poigeMar 6, 2012 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 howtar
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)" :-)– voretaq7Mar 6, 2012 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?– poigeMar 6, 2012 at 18:25
Will -xv
not give you the equivalent of -xt
?
-
2
-
-
@Bryan, yeah, I'm aware of «-v», but it's kinda strange there's an extra option, in addition to 2 basic operation.– poigeMar 6, 2012 at 17:50
-
1@poige Do not fear more information. If you don't need it This is what
awk
(orcut
) 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.– voretaq7Mar 6, 2012 at 17:56 -
@voretaq7, anyways, I don't see any reason why those modes are mutually exclusive. They seem to be not, actually.– poigeMar 6, 2012 at 18:07
tar has 5 "modes" (-c,-r,-t,-u,-x) which cannot be combined. All other arguments are just options to the desired mode.