LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Tar syntax (https://www.linuxquestions.org/questions/linux-newbie-8/tar-syntax-828033/)

rmknox 08-23-2010 01:02 PM

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
Code:

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
thanks
Dick

theNbomr 08-23-2010 01:44 PM

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.

business_kid 08-23-2010 01:49 PM

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
/some/files/

e.g. tar -xzvf some.tar.gz to open it
tar -cjf some.tar.bz2 /mydir/* to tar the directory tree under mydir.


All times are GMT -5. The time now is 06:19 AM.