I have list of compressed files in a directory /var/log/bb e.g. console.log.1.xz, console.log.2.xz etc. I would like to grep a particular string from these files in a single command. Any ideas on how to achieve this
I have been trying like this
sudo xzcat /var/log/bb | grep 'string'
CodePudding user response:
Using find
find /var/log/bb -iname '*.xz' -type f -exec grep 'string' {}
Using grep
$ grep 'string' /var/log/bb/*.xz
CodePudding user response:
Suggesting:
grep -l 'string' $(find /var/log/bb -type f -name "*.xz")