Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

uncompress files *.tar.gz

Status
Not open for further replies.

malpa

Technical User
Feb 8, 2004
122
CO
Hi

I have files *.tar.gz. Is it possilble to descompress and search a register at the same time to standard output?

Similar when I search a register in a file file.Z or file.gz or file.bz2 to standard output

zcat file.Z | grep xxx or
bunzip2 -c file.bz2 | grep xxx or
gzip -c file.gz | grep xxx

in this situacion I don´t descompress a file to the hard disc, only in memory.


thanks malpa
 
Since tar doesn't actually change the data in any way, just joins it together in a format suitable for archiving to tape, you should just be able to use exactly the same method as you would use for a single compressed file.

It depends why you are doing this... is it to identify which file in the .tar.gz file contains the matching string, or is it just to find the matching string?

Annihilannic.
 
Perhaps you want to look for a filename in the gzipped tar archive

[tt]gzip -c file.gz | tar -tf- | grep filename[/tt]



HTH,

p5wizard
 
Hi

thanks for your timely answer.

All days I run tar command.

Example

cat file.txt

fdsafasdfsafasf
sweqrwerweqreqe
saerqwerwerqwer

tar zcvf file.txt.gz file.txt


Now I want to search "fdsafasdfsafasf" into the file.txt, but the file that contain this register now is a tar file.

I want to run something similar to this

zcat file.txt.Z | grep dsafasdfsafasf >stdout (standard output)

but the problem is that the file.txt is contained into the tar file.

is it possible?????

tar zxvf file.txt.gz |.....| grep dsafasdfsafasf > stdout (standard ouput)


or always I have to do this

step1 tar zxvf
tar zxvf file.txt.gz
setp2 grep
grep dsafasdfsafasf file.txt

I want to do this but one step, without generate or write into the hard disc a file.txt, I want to do this in memory only.

thanks malpa



 
okay

"the one Who does not know, is like which does not see"

man tar and ready

I´m sorry for my question.

tar zcvf file.txt.gz file.txt file1.txt file2.txt

after that

gunzip -c file.txt.gz | /usr/xpg4/bin/grep -E 'dsafasdfsafasf'

thanks malpa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top