Goldman Sachs Interview Question

Write shell script to search for a given string in all files in given directory.

Interview Answers

Anonymous

May 18, 2010

find . -name "*" | xargs grep -i "" $1

Anonymous

Jul 5, 2010

Y not just use grep "string" *

Anonymous

Oct 3, 2014

grep -rnw 'directory' -e "string" where -r is recursive -n is line number -w stands match the whole word directory could be any path like '/path/.....' string would be the match you trying to find