LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-15-2009, 10:54 PM   #1
kristhor
Member
 
Registered: Sep 2008
Distribution: Debian, Ubuntu
Posts: 75

Rep: Reputation: 15
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/

??
 
Old 05-15-2009, 11:23 PM   #2
joseph2020
Member
 
Registered: Mar 2009
Location: USA
Distribution: Ubuntu 12.04
Posts: 235

Rep: Reputation: Disabled
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.
 
Old 05-15-2009, 11:25 PM   #3
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
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.
 
Old 05-15-2009, 11:45 PM   #4
kristhor
Member
 
Registered: Sep 2008
Distribution: Debian, Ubuntu
Posts: 75

Original Poster
Rep: Reputation: 15
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
 
Old 05-16-2009, 07:16 AM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
I believe that the original tar for unix systems required the -

Therefore it is probably there for backward compatibility
 
Old 05-16-2009, 12:35 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
tar-command not found while compiling glibc-libidn-2.7.tar.bz2 of lfs6.3 aditya_gpch Linux From Scratch 1 05-14-2008 12:27 AM
tar command alias command rlg Linux - Newbie 0 03-11-2008 08:21 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 03:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration