Sponsored Content
Top Forums Shell Programming and Scripting Elegant gunzip of tar Contents Post 302260661 by scotbuff on Friday 21st of November 2008 10:51:48 AM
Old 11-21-2008
Elegant gunzip of tar Contents

I am faced with a situation where I have directories of gunzipped contents bundled into a tar file. It might look something like this.
x coop/batch/bin/ha90x20.gz, 632641 bytes, 1236 tape blocks
x coop/batch/icm/HA90X20.icm.gz, 1821 bytes, 4 tape blocks
x coop/batch/aeenv.gz, 4117 bytes, 9 tape blocks
x lib/libiclm.a.gz, 5998416 bytes, 11716 tape blocks
x lib/libiclm.sl.gz, 5260938 bytes, 10276 tape blocks
x lib/libime.a.gz, 5816597 bytes, 11361 tape blocks
x lib/libime.sl.gz, 4856468 bytes, 9486 tape blocks
x lib/libimisc.a.gz, 5497949 bytes, 10739 tape blocks
x lib/libimisc.sl.gz, 4591464 bytes, 8968 tape blocks
x lib/libipc.a.gz, 1250457 bytes, 2443 tape blocks
x lib/libipc.sl.gz, 1102578 bytes, 2154 tape blocks
x lib/libipr.a.gz, 5148901 bytes, 10057 tape blocks
x lib/libipr.sl.gz, 4334738 bytes, 8467 tape blocks
This is a small sample, we always have quite a bit more that could be completely different files. Anyway, we have always done a "tar xvf" on the tar files, followed by a find and gunzip of all files that are gunzipped. A problem has arose where there are files that already exist that the customer has gzipped. Is there an elegant way I can pipe the contents of the tar files through gunzip so that I only gunzip the contents of the tar file all in one fell swoop.

I have tried something like this but the gunzip never executes, I receive no errors, it just does not seem to execute.
ls *.tar | while read tarfilename
do
tar xvf ${tarfilename} |awk '{print $2}' |sed 's/,//g' |xargs -i gunzip -fdrv {}
done

I am on HPUX. I am leaning toward the need to write the output of the tar command to a file and work from that, but why can I not use that output on the fly? Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Solaris

Combination of gunzip and tar on Solaris

Hello I'm trying to use a combination of gunzip and tar to unpack and unzip a *.tar.gz file. I tried gunzip ~/myfile.tar.gz | gtar -x This will unzip the file, but it won't unpack. Any hints? thanks a lot Dan (5 Replies)
Discussion started by: dwidmer
5 Replies

2. Shell Programming and Scripting

Tar and gunzip piping

I am using IRIX 6.5.11 and tcsh. I have created an arcihive by using the command "tar -cvf - /stuff/ /more/stuff|gzip --best>/stuff.tar.gz" It made an archive of my files without taking up huge amounts of disk space with uncompressed files. How do I extract files from the archive without... (2 Replies)
Discussion started by: madyodacolon
2 Replies

3. Shell Programming and Scripting

Retaining tar.gz after gunzip

gunzip fnam.tar.gz After this command execution... .gz file no longer exists... and only fnam.tar is present. Is it possible to retain the tar.gz file after after using the above command thx in advance. (4 Replies)
Discussion started by: devs
4 Replies

4. AIX

how to take tar backup of the contents of a file

Hi I have a file named files.2.backup which holds the location of some directory and file i,e $ cat files.2.backup /d01/app/oracle/product/7.3.2/dbs/fortest_syst_01.dbf /d01/app/oracle/product/7.3.2/dbs/fortest_temp_01.dbf /d01/app/oracle/product/7.3.2/dbs/fortestdata_01.dbf... (5 Replies)
Discussion started by: sumanbangladesh
5 Replies

5. Solaris

Listing Contents of tar.gz file

Hi fellows, Can you please share any command with which I can list down the file names inside a tar.gz file. I have tried with these possibilities but in vain. bash-3.00$ tar -ztvf file.tar.gz tar: z: unknown function modifier bash-3.00$ tar ztvf file.tar.gz tar: z: unknown function... (1 Reply)
Discussion started by: Zaib
1 Replies

6. Shell Programming and Scripting

How to grep the contents inside a tar file

Hi All I have searched the possibility of this options everywhere but am unable to find it in any forum. I have a tar file inside which there are n number of files and i dont know them. I need to grep a word inside the tar file and need to know in which file the word resides. > cat a... (2 Replies)
Discussion started by: Whiteboard
2 Replies

7. Shell Programming and Scripting

Extract contents of tar ball without extracting files

Hi, I'm using a tar command tar -xOvf /home/mytar.tar My intention is to extract data in files which are inside various directories, without extracting files to the disk. Is this the best way to achieve it? Thanks, Chetan (3 Replies)
Discussion started by: chetan.c
3 Replies

8. AIX

Gunzip tar A directory checksum error on media

Hi, what is the directory checksum error ? # sed 's/^M$//' test4_bkp_19Jan13.tgz | tar -tvf - tar: 0511-169 A directory checksum error on media; -265745505 not equal to 76225. # mv test4_bkp_19Jan13.tgz test4.gz # gunzip < /ebs2/test4.gz | tar -xvf - tar: 0511-169 A directory checksum... (4 Replies)
Discussion started by: filosophizer
4 Replies

9. UNIX for Dummies Questions & Answers

Gunzip and tar command

Hi I wanted to tar and gunzip a file named backup tar: backup.tar: Wrote only 2244 of 10240 bytes tar: Error is not recoverable: exiting now Please tell me what I am doing wrong? Please do help. (4 Replies)
Discussion started by: sonia102
4 Replies

10. UNIX for Dummies Questions & Answers

Listing contents of .tar.gz files

Hi All, I would like to know couple of ways to list the content available in tar and gzipped file without extracting. i.e., I would like to display the contents of test.tar.gz without extracting. Note :: please suggest a command other that tar -ztvf (9 Replies)
Discussion started by: Girish19
9 Replies
FMS(8)							       AFS Command Reference							    FMS(8)

NAME
       fms - Determine a tape's capacity and a tape device's filemark size

SYNOPSIS
       fms -tape <tape special file> [-help]

       fms -t <tape special file> [-h]

DESCRIPTION
       The fms command determines the capacity of the tape currently in the tape device identified by the -tape argument, along with the size of
       the filemark for the device. The filemark is also referred to as the device's end-of-file (EOF) marker, and can differ for each combination
       of tape and tape device.

       As the Tape Coordinator writes a dump, it writes a filemark between the data included from each volume and also tracks the amount of space
       left before the end of the tape (EOT). For some tape devices, the filemark is large enough (multiple megabytes) that failure to consider it
       leads the Tape Coordinator significantly to overestimate the available space.

       The intended use of this command is to determine tape capacity and filemark size values that can be specified in a tape device's entry in
       the /var/lib/openafs/backup/tapeconfig file. For certain types of tape drives, the Tape Coordinator operates more efficiently when the
       tapeconfig file lists accurate values. For further discussion, see the OpenAFS Administration Guide chapter on configuring the Backup
       System.

       Insert a tape in the drive before issuing this command.

CAUTIONS
       Do not use this command on compressing tape devices in compression mode or with tape devices that handle tapes of multigigabyte (or
       multiterabyte) capacity. It does not produce accurate results in those cases.  For alternate suggestions on the values to record in the
       tapeconfig file for compressing drives, see the OpenAFS Administration Guide chapter on configuring the Backup System.

       Running the command completely overwrites the tape, so use a blank one or one that can be recycled.

       Because it writes filemarks to the complete length of the tape, the command can take from several hours to more than a day to complete.

OPTIONS
       -tape <tape special file>
	   Specifies the UNIX device name of the tape device for which to determine filemark size and the capacity of the tape it currently
	   contains. The format varies on different system types, but usually begins with /dev; an example is /dev/sd0a.

       -help
	   Prints the online help for this command. All other valid options are ignored.

OUTPUT
       The command generates output both on the standard output stream and in the fms.log file that it creates in the current working directory.
       The output reports the capacity of the tape in the device and the device's filemark size.

       The first few lines of output include status information about the execution of the command, including such information as the number of
       blocks and the number of file marks written to the tape by the command. The last two lines of both screen and file output provide the
       following information:

       o   "Tape capacity is number bytes": specifies the size, in bytes, of the tape in the device.

       o   "File marks are number bytes": specifies the device's filemark size in bytes.

       The following message indicates that the fms command interpreter cannot access the tape device. The command halts.

	  Can't open tape drive I<device>

       The following message indicates that the command interpreter cannot create the fms.log log file. Again, the command halts.

	  Can't open log file

EXAMPLES
       The following command illustrates the output for the device called /dev/rmt1h:

	  % fms /dev/rmt1h
	  wrote block: 130408
	  Finished data capacity test - rewinding
	  wrote 1109 blocks, 1109 file marks
	  Finished file mark test
	  Tape capacity is 2136604672 bytes
	  File marks are 1910205 bytes

       The following appears in the fms.log file:

	  fms test started
	  wrote 9230 blocks
	  Finished file mark test
	  Tape capacity is 151224320 bytes
	  File marks are 2375680 bytes

PRIVILEGE REQUIRED
       The issuer must be able to insert and write to files in the currently working directory, if the fms.log file does not already exist. If it
       already exists, the issuer need only be able to write to it.

SEE ALSO
       fms.log(5), tapeconfig(5)

COPYRIGHT
       IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.

       This documentation is covered by the IBM Public License Version 1.0.  It was converted from HTML to POD by software written by Chas
       Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.

OpenAFS 							    2012-03-26								    FMS(8)
All times are GMT -4. The time now is 07:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy