Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

closed as not constructive by Zoredache, Chris S Mar 6 '12 at 18:07

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

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

3 Answers

up vote 7 down vote accepted

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.

share|improve this answer
    
«you either want to extract its contents (-x), or you want to list them» — you're deeply wrong in your assumption. –  poige Mar 6 '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 6 '12 at 17:53
    
You're not wrong regarding list of modes, you're wrong when saying "either". –  poige Mar 6 '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 6 '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 6 '12 at 18:25
show 1 more comment

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

share|improve this answer
2  
actually it gives you more information than -t would. –  voretaq7 Mar 6 '12 at 17:21
    
@voretaq7, that's what I'm in general afraid of –  poige Mar 6 '12 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 '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 6 '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 6 '12 at 18:07
add comment

tar has 5 "modes" (-c,-r,-t,-u,-x) which cannot be combined. All other arguments are just options to the desired mode.

share|improve this answer
add comment

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