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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s