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
jdenver247Asked:
Who is Participating?
 
omarfaridConnect With a Mentor Commented:
try

cd /usr/local
grep 'systeminfo@localhost'

or if you have sub directories, then

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

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

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

0
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.