Retaining tar.gz after gunzip


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Retaining tar.gz after gunzip
# 1  
Old 02-26-2007
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.
# 2  
Old 02-26-2007
In other words, you want to run gunzip on abc.tar.gz and after the command is complete, you want both abc.tar and abc.tar.gz available?

Do this:
Code:
gzip -dc abc.tar.gz > abc.tar

Note that gzip -d is the same as gunzip. If you run gunzip just run gunzip -c. Check the man page to see what the -c switch does.
# 3  
Old 02-26-2007
Code:
gzcat fnam.tar.gz | tar xf -

will extract AND retain the file, or

Code:
gzcat fnam.tar.gz > fnam.tar

will gunzip it without removing the compressed version.

(gzcat = gzip -dc )
# 4  
Old 02-26-2007
thank you very much for the quick responses... my prob solved.
finally ended up using
gzcat fnam.tar.gz | tar xf -
# 5  
Old 02-26-2007
You can also do the below while unzipping

gzip -dc <filename>| cat - >$(basename <filename>'.gz')

For eg.
gzip -dc new.gz | cat - >$(basename new.gz '.gz')
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Retaining value outside loop

Hi, I m new to shell scripting. I did some research and understand that unix treats while and other loops as new shell and hence the variable loose its value outside of the loop. I found solution for integer variable but in mycase this is a string variable. here variable loc is a... (6 Replies)
Discussion started by: knowyrtech
6 Replies

2. 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

3. Shell Programming and Scripting

Retaining whitespaces...

There's an input file(input.txt) which has the following details : CBA BA <Please note the second record has a LEADING WHITESPACE which is VALID> I am using the following code to read the content of the said file line by line: while read p ; do echo "$p" done < input.txt This is the... (1 Reply)
Discussion started by: kumarjt
1 Replies

4. 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

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

7. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: scotbuff
2 Replies

8. Shell Programming and Scripting

variable not retaining value

Bourne shell Solaris I'm trying to set a flag to perform an action only when data is found. So I initialize the flag with: X=0 Then I read the data: if ; then while read a b c do X=1 done < ${inputFile} fi The problem is that X will be set to 1 inside the while loop but when... (5 Replies)
Discussion started by: gillbates
5 Replies

9. 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

10. 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
Login or Register to Ask a Question