|
Home > Archive > Unix Shell > November 2007 > What is the meaning of a dash surrounded with spaces?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
What is the meaning of a dash surrounded with spaces?
|
|
| Charles A. Landemaine 2007-11-28, 7:34 pm |
| 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
| |
| Janis Papanagnou 2007-11-29, 1:36 am |
| 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
| |
| Erik Max Francis 2007-11-29, 1:36 am |
| 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
| |
| Charles A. Landemaine 2007-11-29, 1:29 pm |
| 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.
| |
|
| On 29 Nov., 14:44, "Charles A. Landemaine" <landema...@gmail.com>
wrote:
> Janis Papanagnou wrote:
>
> 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.
| |
| Maxwell Lol 2007-11-29, 1:29 pm |
| "Charles A. Landemaine" <landemaine@gmail.com> 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.
| |
| Charles A. Landemaine 2007-11-29, 1:29 pm |
| Janis wrote:
>
> 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.
|
|
|
|
|