I recently found out this solution to less through compressed gz files parellelly based on the cores available.
find . -name "*.gz" | xargs -n 1 -P 3 zgrep -H '{pattern to search}'
P.S. 3 is the number of cores
I was wondering if there was a way to do it for bz2 files as well. Currently I am using this command:
find -type f -name '*.bz2' -execdir bzgrep "{text to find}" {} /dev/null \;
bzgrep
forzgrep
in thexargs
? - blmless
in your question anywhere at all... and you're parallelizing the easy way, multiple files at the same time but only one thread of execution per file, as opposed to the only-sometimes-possible way, decompressing the same file from multiple points in parallel (which requires the compressor to be configured to periodically reset itself and build a new table -- enabling parallel decoding at some cost to performance and output size). - Charles Duffyfind
in line-oriented form, but filenames are allowed to contain literal newlines. To be fully safe, you need to use NUL delimiters (which can't exist in filenames or other content represented by C strings). - Charles Duffy