There are lots of utilities that can emulate grep
. Few, if any, of them will be faster or use less memory than grep
for the options you're using. Since you're using fixed strings rather than regular expressions, you could make grep
run faster by using the -F
option. But, you didn't mention searching compressed and/or gzipped files until post #7 in this thread. Uncompressing or unzipping a file and searching the converted plain text is obviously going to take a LOT more memory and/or swap space and a LOT more time than searching a plain text file.
The fact that you're processing your compressed files, your gzipped files, and your plain text files with:
zgrep 11263511 *.trace.log*
and processing your plain text files with names containing .trace
again with:
grep 1215456 *.trace.log
probably won't affect swap space, but it will make processing the files in your directory take longer.
If you have the space, you'd be better off keeping your log files uncompressed until you're done searching them. With uncompressed, unzipped files, grep
shouldn't need a lot of memory or swap space. I have no idea whether zgrep
takes a lot more memory and swap, but I wouldn't be surprised if it does.
If you want to search for two (or more) patterns in all of your log files, it will take a minuscule bit more space and run a LOT faster if you combine them in a single invocation of grep
.
For example:
zgrep -Fe 11263511 -e 1215456 *.trace.log.*
grep -Fe 11263511 -e 1215456 *.log
If the zgrep
commands really are taking too much swap, you might need less if you uncompress
your compressed files, gunzip
your gzipped files, grep
the files you uncompressed and unzipped, and then compress
or gzip
them again. (But, that will be slower, and uncompress
and gunzip
may eat up as much swap as zgrep
.)