Need a couple of more complex examples

View: New views
4 Messages — Rating Filter:   Alert me  

Need a couple of more complex examples

by Dr. David Kirkby :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

drkirkby@hawk:~$ /usr/local/bin/tar --help
Usage: tar [OPTION...] [FILE]...
GNU `tar' saves many files together into a single tape or disk archive, and can
restore individual files from the archive.

Examples:
   tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
   tar -tvf archive.tar         # List all files in archive.tar verbosely.
   tar -xf archive.tar          # Extract all files from archive.tar.

  Main operation mode:


shows three examples of using tar. I agree these are some of the more common
ones, though personally I use the 'j' and 'z' options quite a bit.

However, there are no examples of how to use the longer format options. So how
for example would I the '--atime-preserve=replace' or '--no-same-owner' options?
My initial attempts at doing something like

tar cvfz --posix foo-1.25.tar.gz foo-1.25

resulted in me creating a file '--posix' rather than the required foo-1.25.tar.gz.

I'm sure I'll work it out in the end, but just a couple of examples where the
long options are used along with the shorter options (c and x being the obvious
example) would be really useful.


Dave



Re: Need a couple of more complex examples

by Sergey Poznyakoff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dr. David Kirkby <david.kirkby@...> ha escrit:

> drkirkby@hawk:~$ /usr/local/bin/tar --help
[...]
> However, there are no examples of how to use the longer format
> options.

For more examples and detailed discussions of them, please read the tar
documentation. The help summary is not intended to replace it.

> So how for example would I the '--atime-preserve=replace' or
> '--no-same-owner' options? My initial attempts at doing something like
>

The use of the three option formats is discussed in detail in Section
3.3 "The Three Option Styles" of the GNU Tar Manual. In particular,
the ways of mixing different option styles are described in
Subsection 3.3.3 "Old Option Style".

> tar cvfz --posix foo-1.25.tar.gz foo-1.25

The correct ways to do what you intended to do are:

  tar -cvzf foo-1.25.tar.gz --posix foo-1.25
  tar --posix -cvzf foo-1.25.tar.gz foo-1.25
  tar cvfz foo-1.25.tar.gz --posix foo-1.25
  tar --create --verbose --file foo-1.25.tar.gz --gzip --posix foo-1.25
 
Regards,
Sergey



Re: Need a couple of more complex examples

by Dr. David Kirkby :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sergey Poznyakoff wrote:

> Dr. David Kirkby <david.kirkby@...> ha escrit:
>
>> drkirkby@hawk:~$ /usr/local/bin/tar --help
> [...]
>> However, there are no examples of how to use the longer format
>> options.
>
> For more examples and detailed discussions of them, please read the tar
> documentation. The help summary is not intended to replace it.
>

Thank you Sergey,

I realise the help summary is not the place to learn everything about tar. But
*one* single example showing the use of both the normal short options, plus a
single long option, would take up only a single line of extra output.

Something as simple as:

"tar -cf foo.tar --posix foo (create POSIX format tar file of directory 'foo')"

would have indicated something very useful. I personally would have thought that
a good tradeoff, for the single extra line of output it took up.

I realise my subject title had the world 'couple' in it, but one could replace
that by 'single'!

Currently,

$ tar --help

outputs 278 lines. Personally I would have thought increasing the volume of
output by 0.4% would have been a small price to pay for the potential gain.

Dave



Re: Need a couple of more complex examples

by Karl Berry :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

      tar -cvzf foo-1.25.tar.gz --posix foo-1.25

I don't know about using --posix in particular(*), but I concur with
Dr. Kirkby that it would be useful to show one example of mixing short
and long options.  What comes up most often in my work is

  tar -czf foo.tar.gz --exclude=somebigfile .

karl

(*) my experience with TeX Live has shown that --posix is definitely not
portable in practice on current systems (various Solaris and/or BSD
and/or Windows tars fail).  Therefore I don't think something as visible
as a --help example should use --posix.  --ustar, on the other hand,
seems to work.