[UCLA-LUG] TAR

tchow racerx@ucla.edu
Sun, 05 Sep 1999 15:14:46 -0700


This is a multi-part message in MIME format.
--------------BD0E5D26076725EF9D576B55
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

some quirks about tar fred posted a while ago:
note:  there are many utilities other than tar that
require a "-f" parameter (or something similar) for a
file you are working on.  otherwise, it assumes stdin
for input.  sfv, rar, bzip2 come to mind...  this stdin
thing for tar and other programs was confusing to me at
first seeing as how the man pages don't really say "tar
-x"  assume stdin.
tchow

--------------BD0E5D26076725EF9D576B55
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Received: from serval.noc.ucla.edu by cougar.noc.ucla.edu
 (Sun Internet Mail Server sims.3.5.1999.03.02.17.58.p5)
 with ESMTP id <0FBI00AO0BRU2C@cougar.noc.ucla.edu>; Mon,
 10 May 1999 01:04:42 -0700 (PDT)
Received: from linux.ucla.edu (CSUA-3.CS.UCLA.EDU [131.179.96.233])
 by serval.noc.ucla.edu (8.9.1a/8.9.1) with ESMTP id BAA17397; Mon,
 10 May 1999 01:04:41 -0700 (PDT)
Received: from kuato (kuato [127.0.0.1]) by linux.ucla.edu (8.8.7/8.8.7)
 with ESMTP id BAA03929; Mon, 10 May 1999 01:02:17 -0700
Received: from fire.csua.ucla.edu (phaethon@CSUA1.CS.UCLA.EDU [131.179.96.114])
 by linux.ucla.edu (8.8.7/8.8.7) with ESMTP id BAA03908 for
 <linux@linux.ucla.edu>; Mon, 10 May 1999 01:02:10 -0700
Received: (from phaethon@localhost) by fire.csua.ucla.edu (8.8.7/8.8.7)
 id BAA11908 for linux@linux.ucla.edu; Mon, 10 May 1999 01:04:30 -0700
Date: Mon, 10 May 1999 01:04:30 -0700
From: Frederick Lee <phaethon@fire.csua.ucla.edu>
Subject: Re: [UCLA-LUG] [UCLA-LUG]
Sender: linux-admin@linux.ucla.edu
To: linux@linux.ucla.edu
Errors-to: linux-admin@linux.ucla.edu
Reply-to: linux@linux.ucla.edu
Message-id: <199905100804.BAA11908@fire.csua.ucla.edu>
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII
Precedence: bulk
X-Mailman-Version: 1.0b11
List-Id: <linux.linux.ucla.edu>
X-BeenThere: linux@linux.ucla.edu

Said Francis Lau <francis@ucla.edu>:
>i know this might be an easy task for people using linux for a while but
>i'm having trouble using the tar extract stuff. i have a file called
>lin8026.tar in an msdos disk that's supposed to make my ethernet card
>work. so how do i use this tar command?
>i've tried
>tar -x lin8026     after i've mounted the floppy... but the thing just
>freezes
>?????

Little known quirks(?) of command-line parameters...

For GNU tar, the switch "-f" indicates which file to use/operate on.
If this is not provided, tar will assume stdin, the standard input.
Otherwise known as, "the keyboard".

Any non-switch (non-option) words mean the file(s) to extract from the tar
archive.

In short, what you typed came out to mean:
"I'm providing the tar file by typing it by hand, and I want you to extract
the file 'lin8026' that is encoded in the tar file (that I just typed)"  :)

This is why tar looked like it froze.  It was expecting the tar data to
come from the keyboard.

When this happens, you can interrupt (kill) the tar program with Control-C.
This will end the tar program and return you to the shell.  You can
interrupt almost all programs with Control-C.

What you probably meant was "tar -xf lin8026.tar", which comes out to
mean "using the archive named 'lin8026.tar' (-f), extract (-x) all the files
from it (since no particular file was asked for)".
Note that GNU utilities allow you to mash multiple one-letter switches into
one block that starts with a dash.  The unmashed version would be
"tar -x -f lin8026"
 or, the long version :)
"tar --extract --file=lin8026"

However, tar normally extracts to the current working directory.  In your
case, the floppy itself, which isn't too useful in many cases.  Best to copy
to destination then extract, or use the "-C" switch (which tells tar to
extract into the given directory, e.g. "tar -xf lin8026.tar -C /usr/src/linux",
or, long-wise, "tar --extract --file=lin8026.tar --directory=/usr/src/linux").


Note that pipes replace the keyboard for stdin, if there are any pipes.
For example, this would work just as well:
  cat lin8026.tar | tar -x
And tar would read in the archive from standard input, which, in this case,
comes from the pipe, rather than the keyboard (since there *is* a pipe), which
gets it's data from the cat, which gets its data from the file lin8026.tar.
Doing "cat | tar -x", though,  gets you into the same quagmire as before :)
In this case, cat, without a paramter, will try to get data from stdin,
which is now the keyboard.


Hope that wasn't too confusing...


-Fred

_______________________________________________
Linux maillist  -  Linux@linux.ucla.edu
http://linux.ucla.edu/mailman/listinfo/linux


--------------BD0E5D26076725EF9D576B55--