1833704 Members
2734 Online
110062 Solutions
New Discussion

tar command options

 
SOLVED
Go to solution
dictum9
Super Advisor

tar command options

Why does the syntax for tar different from syntax for every other hpux command?

Case in point, you are supposed to say
tar xvf
and not
tar -xvf

Every other command precedes its option or switches with "-", for example rm, cp, find and more.

I've always said

tar -xvf
and
tar -cvf
without any problems.

6 REPLIES 6
James R. Ferguson
Acclaimed Contributor
Solution

Re: tar command options

Hi:

You can use either:

# tar -xvf

(or):

# tar -xvf

Personally, I use the "-" character to denote the switch that the options that follow represent.

The best answer I can provide to your question of why the "-" is optional is that 'tar' is one very old utility; written when conformity and standards were less rigorously enforced or valued.

Regards!

...JRF...
Arunvijai_4
Honored Contributor

Re: tar command options

Hi,

You can both of them "tar tvf" or tar -tvf. I am not sure why other commands doesn't allow you to do this.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Pupil_1
Trusted Contributor

Re: tar command options

# tar
tar: usage tar [-]{txruc}[eONvVwAfblhm{op}][0-7[lmh]] [tapefile] [blocksize] [[-C directory] file] ...
#

There is the "-" in the syntax and since the command works very well without the "-" give me more flexibility !!

As JRF said, most people are used to typing
tar -cvf or tar -xvf ...
There is always something new to learn everyday !!
Ivan Ferreira
Honored Contributor

Re: tar command options

Normally if you use the "-" way, you must specify the argument for the option right after the option, for example, these commands are equivalent:

tar -cvf /dev/rmt/0m -b 1024 /

tar cvfb /dev/rmt/0m 1024 /
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Bill Hassell
Honored Contributor

Re: tar command options

tar is extremely old (decades) and it's command line design defines the first item is the key. The - is optional but it is not like any other command where -tvf is the same as -t -v -f. Also, the file you specify may be optionally followed by -C directory, again non-standard. The man page explains this.

tar's only use is for simple exchanges of data. It is inappropriate for full system backups or large system backups.


Bill Hassell, sysadmin
Peter Nikitka
Honored Contributor

Re: tar command options

Hi,

as a remark to Bill's answer:
If you have a real heterogenous environment and must exchange backup files between them, 'tar' is nearly unbeatable as backup backend utility, IMHO.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"