• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7005
  • Last Modified:

TGZ Untar / Unzip piping

Oke this is the situation. I have a tgz file a little bigger then 1.8Gig, When i extract it it explodes to about 17Gb + space i dont have on this mount (15Gb).

Now i have seen allot of "Huge" Log files that where also compressed into this tgz file. My question now is, is it possible to extend this command :

gunzip < my_file.tgz | tar -xv

to automaticly unzip | tar all logfiles to /dev/null ?

So ordanairy files unzip normally but if a "log" file comes by extract ir to the /dev/null device (remove it) sparing that space... ?

-regards Chris
0
dutchclan
Asked:
dutchclan
  • 3
  • 2
1 Solution
 
DonConsolioCommented:
1) create a table of contents of your tar file

e.g.
gunzip < my_file.tgz | tar -tv >excludelist.tmp

2) edit excludelist / grep in list

e.g.
grep '/var/log/messages' excludelist.tmp >excludelist.txt
vi excludelist.txt
...

3) extract with the --exclude-from option

e.g.
gunzip < my_file.tgz | tar -xv --exclude-from=excludelist.txt
0
 
dutchclanAuthor Commented:
Will try this monday (when im back at work). Sounds like a "applicable" sollution indeed

TIA

Regards Chris
0
 
ahoffmannCommented:
tar zxf my_file.tgz path/to/file/to-be-extracted
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
dutchclanAuthor Commented:
it was allot of work finaly digging through that file, But it worked. Understand you "grep" suggestion wasnt it for the fact that not all log files where nicely in one dir and didnt all have the same extention (if any).

But thx again, worked like a bliss :D
0
 
dutchclanAuthor Commented:
>> tar zxf my_file.tgz path/to/file/to-be-extracted

The complete gzt file contained over 1Mil of files of wich 40 where excluded finally, not something ill be writing out all day ;-)

0
 
DonConsolioCommented:
Thanks - but why the "B" grade ? What was wrong with my answer ?
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now