I have a case where multiple .bz2 files are situated in subdirectories. And I want to search for a text, from all files, using bzcat and grep command linux commands.
I am able to search one-one file by using the following command:
bzcat <filename.bz2> | grep -ia 'text string' | less
But I now I need to do the above for all files in subdirectories.
You can use
bzgrepinstead ofbzcatandgrep. This is faster.To grep recursively in a directory tree use
find:findis searching recursively for all files with the*.bz2extension and applies the command specified with-execdirto them.