Yes. However, if you had skipped the -f, it would have been valid. Without the filename argument, it assumes it should extract from the tape drive (TAR = Tape ARchive). The tape device is probably something like /dev/rmt0, but you don’t need to specify that. Using the -f is technically an exception which means “instead of extracting from the tape like you’d normally do, pretend that this file is the tape device instead.”
GNU tar, at least a modern one, that is the one that happens to come with my system, won’t try to read from /dev but stdin and then complain that it’s a terminal and refuse.
Use the first file operand […] as the name of the archive instead of the system-dependent default.
That is GNU is compliant, here, the default is system-dependent. f - is required to be stdin, though, so you can bunzip2 foo.tar.bz2 | tar xf - or such in a portable manner, don’t have to rely on tar having a z option (which is nonstandard) or it auto-detecting compression (even more nonstandard). What is not standard either is tar -x: Tar doesn’t take leading hyphens. Tar is one of those programs so old its command line syntax got standardised before command line syntax standards were established. OTOH it’s not nearly as bad as dd, you can interpret how tar does things in the same way as git pull: It’s a subcommand, not a flag.
“one of those programs so old its…syntax got standardized before command line syntax standards were established.”
–This is wild to learn, but also confusing. How does tar not take leading hyphens, but I’ve only ever used it as such without error of any kind? Not even bragging I’ve been doing that for 10+ years too lol
Yes. However, if you had skipped the -f, it would have been valid. Without the filename argument, it assumes it should extract from the tape drive (TAR = Tape ARchive). The tape device is probably something like /dev/rmt0, but you don’t need to specify that. Using the -f is technically an exception which means “instead of extracting from the tape like you’d normally do, pretend that this file is the tape device instead.”
GNU tar, at least a modern one, that is the one that happens to come with my system, won’t try to read from
/dev
but stdin and then complain that it’s a terminal and refuse.Quoth POSIX on the
f
flag:That is GNU is compliant, here, the default is system-dependent.
f -
is required to be stdin, though, so you canbunzip2 foo.tar.bz2 | tar xf -
or such in a portable manner, don’t have to rely on tar having az
option (which is nonstandard) or it auto-detecting compression (even more nonstandard). What is not standard either istar -x
: Tar doesn’t take leading hyphens. Tar is one of those programs so old its command line syntax got standardised before command line syntax standards were established. OTOH it’s not nearly as bad asdd
, you can interpret how tar does things in the same way asgit pull
: It’s a subcommand, not a flag.“one of those programs so old its…syntax got standardized before command line syntax standards were established.” –This is wild to learn, but also confusing. How does tar not take leading hyphens, but I’ve only ever used it as such without error of any kind? Not even bragging I’ve been doing that for 10+ years too lol