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

grep -rlw --include="*.dat" -e "ERROR24" /home/tests/logs > /home/files/data/result/listErrors.txt

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.

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)

zgrep -rlw --include="*.dat" -e "ERROR24" /home/tests/logs > /home/files/data/result/listErrors.txt

---------- Post updated 11-02-17 at 02:42 AM ---------- Previous update was 11-01-17 at 02:10 PM ----------

hello
it is not working... i am getting this :

/usr/bin/zgrep: -rlw: option not supported 

do you see how i could do that please?

Did you consult the man page? man zgrep :

it seems that you can't red the content wihtout extracting...
so i need to extract before applying the grep -r

Not necessarily - you can implement recursion by other means, e.g. the find command.

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.