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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list tgz files

Status
Not open for further replies.

bas1080

IS-IT--Management
Sep 2, 2003
21
US
Is there a way to list the contents of tgz files.
 
zcat file.tgz|tar -tvf-

or

gzcat file.tgz|tar -tvf-

or

gunzip -c file.tgz|tar -tvf-

depending on your installation (all may work)

will produce a listing of all the files in the archive

HTH,

p5wizard
 
thanks for the reply.

If i want to filter out just one file out of the list of files, how can i go about.

Thanks in advance.
 
grep?

put

| grep name_of_file_you_want

at the back of the commands suggested earlier


HTH,

p5wizard
 
Hi,

Currently I am looking for a script where i can store the value that is the result of grep . I have tried the below for that but it is not working correctly . test_file = zcat myname.tgz | tar -tvf - |cat /etc/inet/inetd.conf | grep lpstat

My aim is to get the entry for lpstat in each inetd.conf and store it to a directory. I am trying hard to achive this.

Help will be appreciated.
 
with the below code
test_file=$(zcat myname.tgz | tar -tvf - |cat /etc/inet/inetd.conf | grep lpstat)

How can i put the values from the test_file to a file incrementally.
 
Just do
zcat myname.tgz | tar -tvf | | cat /etc/inetd.conf | grep lpstat >> test_file

Note, this works with the Bourne Again SHell. YMMV.

-Haben sie fosforos?
-No tiengo caballero, but I have un briquet.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top