I find myself using
grep (or on my local machine ag*) to sift through lots of files looking for a string.
Recently, I SSHed into a server and wanted to search though a bunch of log files that had been gzipped (i.e. they ended in
I didn’t want to unzip all of the files and make a mess on the server. I wanted to search the files without modifying them.
So instead of using grep
grep -i -r 'string to find' ./
I was able to use a combination of
find -name \*.gz -print0 | xargs -0 zgrep 'string to find'
and did indeed find instances of “string to find” in the one of the gzipped files.
* Note: I understand there are other command line tools that search even faster than
ag but I’ve not yet found
ag to be slow enough in any situation that it is worth my time to upgrade.