Linux read specific content file from tar.gz files without extracting
hello
i wish to write the result of these below conditions in a file:
1. in a specific folder, i have many tar.gz files.
2. each tar.gz file contains ".dat" file in sub folders.
3. i wish to get the full path of these .dat files, if i find in it a specific word ("ERROR24").
4. all this wihtout extracting the tar.gz files
i have found and tested the below one that writes in a file the result, but i don't how to look in a tar.gz file.
there are too many tar.gz to be done manually...
can you please help update the previous request in order to get the same result but searching in each tar.gz files present in the specific folder?
thanks for your help.
Moderator's Comments:
Please use CODE tags as required by forum rules!
Last edited by RudiC; 11-01-2017 at 03:12 PM..
Reason: Added CODE tags.
You can't search / grep / analyze files that are compressed / zipped etc. with the "normal" *nix text tools as data are no text any more.
Did you consider e.g. zgrep?
thanks for your advice.
so it means all i have to do is to test like that?
(i can't test right know... i don't have my linux laptop... tomorrow i'll be able to)
---------- Post updated 11-02-17 at 02:42 AM ---------- Previous update was 11-01-17 at 02:10 PM ----------
Quote:
Originally Posted by RudiC
You can't search / grep / analyze files that are compressed / zipped etc. with the "normal" *nix text tools as data are no text any more.
Did you consider e.g. zgrep?
It seems that you can't read the content without extracting...
Literally true, even with tools like zgrep. What zgrep actually does is gunzip < inputfile | grep ... so decompression is not skipped, it just avoids making a temp file. And it's definitely not meant for tar files.
Why does not work a cd in a shell schript file.
How do you get to run it?
I use these code:
#!/bin/sh
cd workspace
array=($(ls -d */))
echo ${array}
But it doesn't change to workspace
editby bakunin: please user CODE-tags as required by the rules. Thank you. (12 Replies)
Hello,
Please help me with this!! Thanks in advance!!
I have a file named file.gc with the content:
1-- Mon Sep 10 08:53:09 CDT 2012
2revoke connect from FR2261;
3delete from mkt_allow where grantee = 'FR2261';
4grant connect to FR2261 with '******';
5alter user FR2261 comment... (0 Replies)
Hi All,
I have the file in this format
**** Results Data ****
Time or Step
1
2
20
0.000000000e+00 0s 0s 0s
1.024000000e+00 Us 0s 0s
1.100000000e+00 1s 0s 0s
1.100000001e+00 1s 0s 1s
2.024000000e+00 Us Us 1s
2.024000001e+00 ... (7 Replies)
Is anyone out there? I'm trying to run a script i wrote that extracts multiple .tar files in succession by pasting it into standard input. It does extract them all but I cant get it to stop looping and when I hit enter I get a tar command error like its still looking for files to extract.
ie;
... (2 Replies)
I have tried:
tar -xfv mytarfile.tar archive/tabv/*
tar -xfv mytarfile.tar --wildcards 'archive/tabv/*'
tar -xf mytarfile.tar -v --wildcards 'archive/tabv/*'
tar -xfv mytarfile.tar --wildcards --no-anchored 'archive/tabv/*'
tar -xfv mytarfile.tar --wildcards `archive/tabv/*`
and none... (5 Replies)
Hey guys complete n00b here so I'll try my best at explaining.
I'm creating a backup and restore utility and decided to use tar. I create a backup folder in each user's account and when backing up (say word processing files), I use the following:
tar cvf /home/user/backup/wpbackup.tar... (2 Replies)
Hi All,
I want to read the content of the particular file from tar.Z without extracting.
aaa.tar.Z contains a file called one.txt, I want to read the content of the one.txt without extracting.
Please help me to read the content of it.
Regards,
Kalai. (12 Replies)
Hi All,
I would like to extract specific file from a zip archive.
I have a zip archive "sample.zip".
sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc...
I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file.
... (4 Replies)
so i have hundreds of files named history.20071112.tar
(history.YYYYMMDD.tar)
and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis
here is what i have so far:
for FILE in `cat dirlist`
do
tar xvf $FILE ./status_*
done
dirlist is a text... (4 Replies)
If a zip file contains several zip files, but if the file names of the files needed are known, is there a variation of the unzip command that will allow those few (individual) files to be extracted?
---
Example:
Zip file name: zip.zip
unzip -l zip.zip will display file01, file02, file03, etc.... (1 Reply)