GREP STRING PATTERNS FROM MULTIPLE FILES

If you have situation where you need to grep strings from multiple files which has a pattern in one go.

Use this command to find the files containing string ‘libcrs19.so ‘ in ‘/home/oracle’ directory

find /home/oracle/ -type f -exec grep 'libcrs19.so' {} \;
[oracle@orcl19x ~]$ find /home/oracle/ -type f -exec grep 'libcrs19.so' {} \;
lib/libcrs19.so
/data01/product/19.0.0/lib/libcrs19.so
/data01/product/19.0.0/lib/libcrs19.so
/data01/product/19.0.0/lib/libcrs19.so

If you want to find the filename which contain the string,then use below command

[oracle@orcl19x ~]$ find /home/oracle/ -type f -exec grep -l 'libcrs19.so' {} \;

/home/oracle/filegrowth

Leave a Reply