Hi, i am asking a command to find a string in file(s) from multiple level directory structures.
help would be really appreciated.
Hi, i am asking a command to find a string in file(s) from multiple level directory structures.
help would be really appreciated.
Isn't that the same question you asked in your previous thread (7 months ago)?
well caught
Generic answer as O/P has not stated Operating System accurately or Shell.
search="our search string"
#
find . -type f -print | while read filename
do
found=`grep "${search}" "${filename}"`
if [ ! "${found}""X" = "X" ]
then
echo "File ${filename} : ${found}"
fi
done
Ps. I only posted this because all the answers to the original post were wrong.
The following
$ find . -type f -exec grep -l string {} \;
Will list all the file in the current directory and in sub-directories containing the string.