[Techtalk] tar xfvj

Telsa Gwynne hobbit at aloss.ukuu.org.uk
Tue Mar 2 10:47:22 EST 2004


On Mon, Mar 01, 2004 at 10:04:47PM -0500 or thereabouts, Angelina Carlton wrote:
> on my Debian pc
> tar (GNU tar) 1.13.25
> i have used -j for bz2 files

Red Hat Fedora here, same tar version, and ditto. 

-j (--bzip or j) is not an obvious mnemonic, but I think they were
running out by then! It is, however, a legitimate GNU tar option
these days.

As for the order: 

> On Mon, 2004-03-01 at 21:45, Carla Schroder quoted:
> > $ tar xfvj /path/to/linux-2.6.0-test7.tar.bz2

No, I wouldn't do that.

> if I use: tar cfvj jpg.bz2 *.jpg
> tar: jpg.bz2: Cannot stat: No such file or directory 
> but  tar cjvf jpg.bz2 *.jpg works, so I can assume the f needs 
> to be last? however, when extracting, tar xfvj jpg.bz2 it works 
> fine even though the f isnt last. this isnt much help ;-)

There is a long explanation in the info page for tar about
the differences between mnemonic (long option) options, short
options (one hyphen and one letter) and old-style options
(no hyphen, one letter). 

It's horrendous. Edited highlights. 

  Short options: 
  ...which require arguments take their arguments immediately 
  following the option, usually separated by white space.  It
  is also possible to stick the argument right after the short 
  option name, using no intervening space. 
  Short options' letters may be clumped together, but you are not
  required to do this (as compared to old options; see below).  
  When short options are clumped as a set, use one (single) dash 
  for them all, e.g. ``tar' -cvf'.  Only the last option in such 
  a set is allowed to have an argument.

  Old options:
  ...must be written together as a single clumped set, without
  spaces separating them or dashes preceding them. This set of
  letters must be the first to appear on the command line, after
  the `tar' program name and some white space; old options cannot 
  appear anywhere else.  [...] When options that need arguments 
  are given together with the command, all the associated arguments 
  follow, in the same order as the options.

The example they give is 
     $ tar cvbf 20 /dev/rmt0
(where 20 is the argument for b and /dev/rmt0 is the argument for f)

So yeah, the command line Carla quotes will work. But if you
then add another option in which wants an argument, you have
to be _very_ careful that the argument goes in the right 
place relative to the /path/to/linux...bz2 or something weird
will happen.

I am staring at this and at Angelina's example trying to 
work out what is actually going on and whether the bits I
have quoted will explain it. But it's too early in the morning
for me, clearly!

I now use long options and "--file=/path/to/file" for things 
like back-ups, because it seems so much safer: when you are
specifying specific files to back up, specific locations to 
back up _to_, and specific file types not to include, the
long options are much, much, clearer!

Long ago, I destroyed the tape archive because the tape
was in the machine, the tape drive was (unaccountably)
world-writable, and I missed an argument whilst using tar,
so tar thought "where shall I put this? I'll use my default.
And I am a tape-archive tool so I shall write onto the tape".

The system operator who got to re-do the backups was not
amused. 

Telsa



More information about the Techtalk mailing list