LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar command (https://www.linuxquestions.org/questions/linux-newbie-8/tar-command-726331/)

kristhor 05-15-2009 09:54 PM

tar command
 
Hi, im sorry if this is a stupid question but Ive tried to google and read up on it but cant seem to figure it out. What is the difference between:

tar xvzf file.tar.gz dir/

and

tar -xvzf file.tar.gz dir/

??

joseph2020 05-15-2009 10:23 PM

kristhor,

Quote:

What is the difference between:
tar xvzf file.tar.gz dir/ and tar -xvzf file.tar.gz dir/
I am not an expert by any means, but as far as I know you have to use the " - ". That tells tar to use those options. In a console window type
Code:

man tar
this will show you all the options and you will see all of them use the " - " . I hope that helps.

stress_junkie 05-15-2009 10:25 PM

In tar there is no difference between using the dash in front of the parameters or not using the dash. Other commands such as ps do have different behavior between using the dash and not using the dash.

The use of the dash or not using the dash is a legacy from BSD Bourne shell. It is a silly thing.

kristhor 05-15-2009 10:45 PM

thanx, I thought there was no difference, hence the problem finding something telling me otherwise. I just thought it was a little confusing seeing both versions used even in the same book :)

Disillusionist 05-16-2009 06:16 AM

I believe that the original tar for unix systems required the -

Therefore it is probably there for backward compatibility

colucix 05-16-2009 11:35 AM

An excerpt from the GNU tar manual:
Quote:

Like short options, old options are single letters. However, old options must be written together as a single clumped set, without spaces separating them or dashes preceding them. This set of letters must be the first to appear on the command line, after the tar program name and some white space; old options cannot appear anywhere else. The letter of an old option is exactly the same letter as the corresponding short option. For example, the old option ‘t’ is the same as the short option ‘-t’, and consequently, the same as the long option ‘--list’. So for example, the command ‘tar cv’ specifies the option ‘-v’ in addition to the operation ‘-c’.
The full story here.


All times are GMT -5. The time now is 04:51 AM.