What is the meaning of a dash surrounded with spaces?

What is the meaning of a dash surrounded with spaces?

am 29.11.2007 02:28:41 von landemaine_REMOVE_

Hello,

I was reading the 7zip man page and I was wondering the meaning of the
first dash in this example:

tar cf - directory | 7za a -si directory.tar.7z

Could you tell me please?
Thanks,

--
Charles A. Landemaine
http://landemaine.blogspot.com

Re: What is the meaning of a dash surrounded with spaces?

am 29.11.2007 02:36:27 von Janis Papanagnou

Charles A. Landemaine wrote:
> Hello,
>
> I was reading the 7zip man page and I was wondering the meaning of the
> first dash in this example:
>
> tar cf - directory | 7za a -si directory.tar.7z
>
> Could you tell me please?
> Thanks,
>

'c' tells tar to create an archive
'f' introduces a subsequent name for the archive file
'-' tells that the archive should go to standard output
instead of to a file on disk

The reason is to make it possible to pass the tar'ed data further through
the pipe into the next process.

Janis

Re: What is the meaning of a dash surrounded with spaces?

am 29.11.2007 06:31:06 von Erik Max Francis

Charles A. Landemaine wrote:

> I was reading the 7zip man page and I was wondering the meaning of the
> first dash in this example:
>
> tar cf - directory | 7za a -si directory.tar.7z
>
> Could you tell me please?

A dash as an argument is just a dash, and each program is free to teach
it however it likes. A common convention is that, when used in
replacement for a filename, means either stdin or stdout, depending on
whether the filename was intended to be read or written.

--
Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
Who knows whether any of us will be around in 1972?
-- John F. Kennedy

Re: What is the meaning of a dash surrounded with spaces?

am 29.11.2007 14:44:09 von landemaine

Janis Papanagnou wrote:
> 'f' introduces a subsequent name for the archive file
> '-' tells that the archive should go to standard output
> instead of to a file on disk

Thanks Janis and Erik. Wouldn't it make more sense then to use:

tar cf directory - | 7za a -si directory.tar.7z

Instead of:

tar cf - directory | 7za a -si directory.tar.7z

So that "f" is tied to "directory"? Anyway, it's working fine, this is
the most important :)

--
Charles.

Re: What is the meaning of a dash surrounded with spaces?

am 29.11.2007 15:19:55 von Janis Papanagnou

On 29 Nov., 14:44, "Charles A. Landemaine"
wrote:
> Janis Papanagnou wrote:
> > 'f' introduces a subsequent name for the archive file
> > '-' tells that the archive should go to standard output
> > instead of to a file on disk
>
> Thanks Janis and Erik. Wouldn't it make more sense then to use:
>
> tar cf directory - | 7za a -si directory.tar.7z

No. You usually have more than one file/directory to archive and tar
would need a separate handling for the last argument, technically.
Is it more intuitive? Don't know. As long as there's an 'f' option I
find it clearer that the argument for f is following immediately.

> Instead of:
>
> tar cf - directory | 7za a -si directory.tar.7z

In all environments where I worked it was necessary that the archive
name is specified immediately after the option f, then followed by an
arbitrary number of files to archive. So your first variant wouldn't
have worked.

>
> So that "f" is tied to "directory"?

But it isn't; it's tied to the archive name, not to the files to be
archived.

Janis

> Anyway, it's working fine, this is
> the most important :)
>
> --
> Charles.

Re: What is the meaning of a dash surrounded with spaces?

am 29.11.2007 19:10:59 von Maxwell Lol

"Charles A. Landemaine" writes:

> Thanks Janis and Erik. Wouldn't it make more sense then to use:
>
> tar cf directory - | 7za a -si directory.tar.7z
>
> Instead of:
>
> tar cf - directory | 7za a -si directory.tar.7z

tar can archive more than one directory and file.
You want to be able to do things like
tar cf - *.jpg

where *.jpg expands to zero or more files.

Re: What is the meaning of a dash surrounded with spaces?

am 29.11.2007 19:14:39 von landemaine

Janis wrote:
> > So that "f" is tied to "directory"?
>
> But it isn't; it's tied to the archive name, not to the files to be
> archived.

Ah, yes, this is why I found it strange. Now it makes sense.
Thanks, Janis,

--
Charles.