Tuesday, July 26, 2022

[SOLVED] how to search for a particular string from a .gz file?

Issue

I want to search for a particular string from a .gz file containing a text file without extracting in linux terminal. I know how to search for a string from a text file using grep "text to search" ./myfile.txt. But how to make it work for .gz files?


Solution

gunzip -c mygzfile.gz | grep "string to be searched"

But this would only work if the .gz file contains text file which is true in your case.



Answered By - 4aRk Kn1gh7
Answer Checked By - Clifford M. (WPSolving Volunteer)