I'm searching successfully with this command : search for a list of suspicious IPs from a txt file ips.txt
in a logs directory (compressed files).
root@yop# find /mylogs/ -exec zgrep -i -f ips.txt {} \; > ips.result.txt
I want now to use parallel with it.. to speed up the search. I'm not able to find correct args for it at the moment.. I mean use the pattern file (one per line) and also export it in a result file.
Is there any parallel guru for it please ?
The more close command i found was this : grep-or-anything-else-many-files-with-multiprocessor-power
But wasn't able to use it with a file list of patterns and export results to a file too...
Please help, thanks all.
Get GNU parallel (e.g. brew install parallel , apt-get install parallel , etc.). Run grep in parallel blocks on a single file. Run grep on multiple files in parallel, in this case all files in a directory and its subdirectories. Add /dev/null to force grep to prepend the filename to the matching line.
If you just want to run multiple jobs at once, consider using GNU parallel:
parallel zgrep -i -f ips.txt :::: <(find /mylogs -type f) > results.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With