SUMMARY:Extracting files with a specific pattern from a tarred tape!

From: Vinay Somashekar (vinay@scisun.sci.ccny.cuny.edu)
Date: Tue Jan 04 1994 - 13:18:12 CST


Hi everybody,

here's a summary of the responses I've got so far. I hav'nt checked them out yet
but many thanx to all who responded!

ORIGINAL QUESTION
-----------------

<Q>: Hi netters,
<Q>:
<Q>:
<Q>: HAPPY NEW YEAR!!
<Q>:
<Q>: here's my question:
<Q>: -------------------
<Q>:
<Q>: how does one extract specific files from a tape which is stored in 'tar' format.
<Q>:
<Q>: OS: Sun OS 4.1.3
<Q>:
<Q>: Here's the situation:
<Q>: ---------------------
<Q>:
<Q>: A user has his whole homedirectory totalling about 600Mbytes, tarred onto a 8mm
<Q>: tape.
<Q>: user_homedir% tar cvf . /dev/rst10
<Q>: user_homedir%
<Q>:
<Q>: Now he has new a/c at another location where he is allocated limited space of
<Q>: only 20Mbytes on the hard disk.
<Q>: Since I cannot extract all the tarred files from the tape onto his new a/c,
<Q>: due to space constraints, the user requested that I get a specific type of
<Q>: files only from the homedirectory(excluding subdirectories).
<Q>:
<Q>: Example: Suppose the tape contents are as follows,
<Q>:
<Q>: user_new_a/c% tar tvf /dev/rst2
<Q>: ---- blah blah .....blah ./hello1.dat
<Q>: ---- blah blah .....blah ./hello1.f
<Q>: ---- blah blah .....blah ./hellof.dat
<Q>: ---- blah blah .....blah ./hello2.dat
<Q>: ---- blah blah .....blah ./subdir/subhello1.f
<Q>: ---- blah blah .....blah ./dir/subdir/ssubhello1.f
<Q>: ---- blah blah .....blah ./dir/subdir/ssubhello2.f
<Q>: ---- blah blah .....blah ./hello2.f
<Q>: ---- blah blah .....blah ./test1.f
<Q>: ---- blah blah .....blah ./test2.f
<Q>: .
<Q>: .
<Q>: .
<Q>: .
<Q>: and so on...
<Q>:
<Q>: The user requires all files with .f (dot f) extension at the
<Q>: main directory level only. i.e these files are
<Q>:
<Q>: hello1.f hello2.f test1.f test2.f
<Q>:
<Q>: from the above example only 4 files are to be extracted.
<Q>:
<Q>: Here is what I tried (but with no success):
<Q>: ------------------------------------------
<Q>:
<Q>: user_new_a/c% tar xvf /dev/rst2 `tar tf /dev/rst2 | grep '\.*.\.f'`
<Q>:
<Q>: the tape drive goes into motion but I get no output.
<Q>:
<Q>:
<Q>: Can someone tell me how I can go about solving this problem?
<Q>:
<Q>: Thanx
<Q>:
<Q>: cheers,
<Q>:
<Q>: -vinay
<Q>:
<Q>: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
<Q>: # Vinay Somashekar Room Tel. # e-mail #
<Q>: # Computer Science NAC 8/216 (212)650-6181 vinay@cs-mail.engr.ccny.cuny.edu#
<Q>: # Science Computing J 302 (212)650-7885 or 7886 vinay@sci.ccny.cuny.edu #
<Q>: # CCNY/CUNY N.Y. N.Y. 10031 #
<Q>: #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
<Q>:

RESPONSES IN NO PARTICULAR ORDER:
---------------------------------

[1] From helen!rlm@surfcty.com Sat Jan 1 14:38:52 1994

I believe that Gnu tar does what you want. You can find a copy on
ftp.uu.net: /packages/gnu/tar-* .

Robert L. McMillin | rlm@helen.surfcty.com | Netcom: rlm@netcom.com
13442 Wilson St. | Garden Grove, CA | 92644
            voice: 714-638-2459 | fax: 714-638-2384
            I'm only a guest at surfcty.com; THEY certainly wouldn't have these opinions!

*********************************************************************************************
[2] From a540ami@pic.ucla.edu Sun Jan 2 00:07:14 1994

I'm not sure whether you mistyped in your message, but if you intended to put:

user_new_a/c% tar xvf /dev/rst2 `tar tf /dev/rst2 | grep '\.*.\.f'`

then the problem is in the nested tar ^^^^^ command. Use the tvf options.

Also, it occurs to me that the filespec "'\.*.\.f'" doesn't need all the
dashes since it's in single quotes.

                                --Ami

*********************************************************************************************
[3] From acmrlb@gsusgi2.gsu.edu Sun Jan 2 08:20:27 1994

Try GNU tar - then you can put the list in a file and tell gtar to
get only those files. Example gtar -xvT <file> -f /dev/rst2

Or list the tape to a file tar tvf /dev/rst2 > /tmp/file 2>&1
Then grep out the .f files - to a file, then use
tar xvf /dev/rst2 `cat <file>`

user_new_a/c% tar tvf /dev/rst2

-- 
Ron Bolin					BellSouth Telecommunications
Georgia State Univ			        acmrlb@gsusgi2.gsu.edu
BellSouth Tele					rlb@bsts03.bss.com
Voice						404-529-3945

********************************************************************************************* [4] From bob@snuffy.penfield.ny.us Sun Jan 2 12:18:54 1994

To extract specific files from a tape like this you have to use it's name as it actually appears -- i.e. './test2.f' -- so to extract specific files would look something like:

tar xvf /dev/rst2 ./hello1.dat ./subdir/subhello1.f ./dir/subdir/ssubhello1.f

if you just want a particular directory and all it's files you can shorten this up to:

tar xvf /dev/rst2 ./dir/subdir

Hoep this helps...

-- * Bob Smith + mx: bob@snuffy.penfield.ny.us * * 838 Harmon Rd. + uucp: ur-valhalla!snuffy!bob * * Penfield, NY 14526 + office|voice mail: +1 716 724-6186 *

********************************************************************************************* [5] From eplunix!raoul@harvard.harvard.edu Sun Jan 2 14:14:23 1994

Gack: either do a "tar xvwf /dev/rst2" and interactively select the files to extract, or do a "tar tf /dev/rst2 >tar.list; tar xvf /dev/rst2 `grep \.f tar.list`" to get a list of what's on the tape and extract on that basis.

Your tar jobs are probably interacting badly

********************************************************************************************* [6] From tonyr@sw.stratus.com Mon Jan 3 10:48:57 1994

try running the tar tf into a file and then running the tar x `cat file` I think the tar `tar` is causing problems. also this way you can examine the tar t output to see if it makes sense.

-- -Tony Rudie' <tonyr@sw.stratus.com>

********************************************************************************************* [7] From era@TYRELL.NET Mon Jan 3 22:05:34 1994

Catch the list of files into a temp file. 'tar' does not deal well with multiple executions on one line.

I would use a different regular expression than you chose in your attempt:

tar tf /dev/rst2 >tempfile tar xvf /dev/rst2 `egrep '^\./[^/]*\.f$' tempfile`

That RE means:

^ start of line \. a literal DOT / a literal SLASH [^/]* as many non-slashes as you find ( this limits you to the top dir) \. a literal DOT f$ an 'f' at the end of line

Ed Allen era@tyrell.net

********************************************************************************************* [8] From richard@totaltec.com Mon Jan 3 23:38:43 1994

Have you tried "%tar xvf /dev/rst?? *.f" ?

let me know if it works.

Rich ********************************************************************************************* [9] From A.D.Hoekstra@wb.utwente.nl Tue Jan 4 09:16:15 1994

The first tar in your command probably wants to start executing while the tape in the drive is rewinding after the second tar (which get executed first).

Why not split the command into something like tar tf /dev/rst2 | grep '\.*.\.f' >tmpfile tar xvf /dev/rst2 `cat tmpfile` (or tar xvf /dev/rst2 -I tmpfile)

All the best, Andre++ -- ------------------------------------------------------------------------------- Mechatronics Research Centre Twente -- Mobile Autonomous Robot Twente adh@wb.utwente.nl -- ahoekstr@cs.utwente.nl -- +31 53 893296 Twente University WB/WA P.O. box 217 NL-7500 AE ENSCHEDE THE NETHERLANDS

********************************************************************************************* [10] From mjd@saul.cis.upenn.edu Tue Jan 4 09:34:28 1994

One way is:

tar tf tarfile | grep PATTERN > /tmp/want tar xvf tarfile `cat /tmp/want`

Rememeber that grep patterns are different from shell filename patterns.

********************************************************************************************* [11] From: idod@bga.com (Ido Dubrawsky)

Well, I can think of a couple of things you might want to try. The first is the following:

tar -xvf /dev/rst8 -I include_files

where include_files contains the names of the file which you wish to extract. I normally use this to tar up my /home directory, /usr/gnu, and /usr/local on my machine.

Another possibility which you may want to try, is:

tar -xwvf /dev/rst8

The w will cause tar to wait for your confirmation on each and every file. If you answer with anything other than a 'y', tar will go on to the next file. This method is _not_ recommended in your case as being good because the tar archive is 600MB big and you'd probably spend several days just getting the files that you want.

I hope this helps,

Ido Dubrawsky idod@bga.com idod@vern.bga.com

*********************************************************************************************

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~# # Vinay Somashekar Room Tel. # e-mail # # Computer Science NAC 8/216 (212)650-6181 vinay@cs-mail.engr.ccny.cuny.edu# # Science Computing J 302 (212)650-7885 or 7886 vinay@sci.ccny.cuny.edu # # CCNY/CUNY N.Y. N.Y. 10031 # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:53 CDT