hi all
i have directory
/usr
under this directory i have subdirectories
tmp1,tmp2,tmp3
like this
/usr/tmp1
/usr/tmp2
/usr/tmp3
and so on
i want to search string in files (i don't know the name of the files)and i want to serch it in all the directories under the /usr
how shell i do that
i'll be glad if you could explain the command too
best regards
find /usr -name "*.*" -exec grep "string-to-search" {} /dev/null \;
See man find for more details and options.
hi vino
what is the meaning of
{} /dev/null \;
isn't this if i don't know in which directory to search ?
See the man pages of find. Look at the explanation of the flag -exec under the section ACTIONS.
As for /dev/null, it is some hack which makes grep spit out the filename before showing the matching lines.
See this for the difference
grep $USER /etc/passwd
and
grep $USER /etc/passwd /dev/null