UNIX Script : Regarding find command

How do I search for specific text in a file in a directory.
Ex: I need to search for a file that contains systeminfo@localhost in /usr/local
Who is Participating?
omarfaridConnect With a Mentor Commented:

cd /usr/local
grep 'systeminfo@localhost'

or if you have sub directories, then

find /usr/local -type f | xargs grep 'systeminfo@localhost'
Deepak KosarajuConnect With a Mentor DevOps EngineerCommented:
grep -i "systeminfo@localhost" /usr/local/\*
lwoodtriConnect With a Mentor Commented:

grep -R -a1 -b1 systeminfo@locahost /usr/local/*

-a1 -b1 shows the data 1 line above and below the text line begin searched on!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.