"tar czf file.tar.gz dirname" or "tar -czf file.tar.gz dirname"? "tar czf file.tar.gz dirname" or "tar -czf file.tar.gz dirname"? unix unix

"tar czf file.tar.gz dirname" or "tar -czf file.tar.gz dirname"?


It's all in the info pages:

“Like short options, "old options" are single letters. However, old options must be written together as a single clumped set[...] this old style syntax makes it difficult to match option letters with their corresponding arguments, and is often confusing. In the command tar cvbf 20 /dev/rmt0, for example, 20 is the argument for -b, /dev/rmt0 is the argument for -f, and -v does not have a corresponding argument. Even using short options like in tar -c -v -b 20 -f /dev/rmt0 is clearer, putting all arguments next to the option they pertain to.”

And you don't want to confuse your users, do you?


$ man tar 

The bundled-arguments format is supported for compatibility with historic implementations. It consists of an initial word (with no leading - character) in which each character indicates an option. Arguments follow as separate words. The order of the arguments must match the order of the corresponding characters in the bundled command word. For example,

  tar tbf 32 file.tar

specifies three flags t, b, and f. The b and f flags both require arguments, so there must be two additional items on the command line. The 32 is the argument to the b flag, and file.tar is the argument to the f flag.


while @user502515 is right, I always use tar cvf and I hope @Captain is still using it as well. It's cleaner and if some users find it confusing they can go man tar and learn it. I accept that the new syntax is more explicit, but the old one is beautiful and besides, it's fun to use syntax from 1979.