-5

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.

7
  • 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 6, 2012 at 17:52
  • linux.die.net/man/1/tar
    – Zoredache
    Mar 6, 2012 at 18:02
  • @Zoredache, are you sure it explains why tar can't support -t AND -x? :-)
    – poige
    Mar 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.
    – Zoredache
    Mar 6, 2012 at 18:12
  • @Zoredache I prefer the BSD manpage myself - the options section shows the mutually-exclusive combinations better :-)
    – voretaq7
    Mar 6, 2012 at 18:13

3 Answers 3

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.

6
  • «you either want to extract its contents (-x), or you want to list them» — you're deeply wrong in your assumption.
    – poige
    Mar 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...
    – voretaq7
    Mar 6, 2012 at 17:53
  • You're not wrong regarding list of modes, you're wrong when saying "either".
    – poige
    Mar 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 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 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?
    – poige
    Mar 6, 2012 at 18:25
4

Will -xv not give you the equivalent of -xt?

5
  • 2
    actually it gives you more information than -t would.
    – voretaq7
    Mar 6, 2012 at 17:21
  • @voretaq7, that's what I'm in general afraid of
    – poige
    Mar 6, 2012 at 17:46
  • @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 6, 2012 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 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.
    – poige
    Mar 6, 2012 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.

0

Not the answer you're looking for? Browse other questions tagged .