Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-23-2010, 01:02 PM   #1
Registered: May 2010
Posts: 354

Rep: Reputation: 34
Tar syntax

I'm sure this is easy for the pros who hang out here, but I'm lost

info tar para 4.6 gives an example - two parts confuse me

the example
tar --directory=srcdir --create --file=- .
I'm confused by the 3rd and 4th args
in the 3rd, "--file=-" apparently <dash> is used as a wild card. I don't see this convention explained in the tar documentation and don't recognize it based on my limited undrstanding of the POSIX regular expression syntax

the 4th arg consists of a period - I dont understand why it is there

Maybe someone can help lift my ignorance

Last edited by rmknox; 08-23-2010 at 01:04 PM.
Old 08-23-2010, 01:44 PM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
In general, the '-' notation is used as shorthand for either standard input or standard output, as appropriate to the scenario. In your example case I would say it means that the resulting tarball would be written to standard output. The '.' notation is the top directory from which to build the tarball. Do 'ls -la' at a shell prompt, and you will see the directory '.', referring to the toplevel directory specified, often the current working directory (as in this case).
--- rod.
1 members found this post helpful.
Old 08-23-2010, 01:49 PM   #3
LQ Guru
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 9,368

Rep: Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981Reputation: 981
info tar is the interminable info page. have fun. no manpage.

I use tar this way
tar -options where options include one from each line

c or x for create or extract
z or j for gzip or bzip2
v for verbose
f for filename which is the tar filename and has to be after the f

then if you are creating a tar,
- for stdin

e.g. tar -xzvf some.tar.gz to open it
tar -cjf some.tar.bz2 /mydir/* to tar the directory tree under mydir.
1 members found this post helpful.


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
tar | ssh (tar > .tar) syntax issues EarlMosier Linux - Software 6 12-21-2006 12:28 AM
Tar for backups ? Proper syntax ? Reefcrazed Linux - Newbie 8 02-21-2006 05:18 PM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 03:15 AM
Tar syntax to backup system... robbow52 Debian 5 08-05-2004 11:35 AM
Tar syntax JTD Linux - Newbie 2 10-28-2003 04:28 PM > Forums > Linux Forums > Linux - Newbie

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

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