Monday 23 June 2014

Find inside a file or directory

Problem: Find a word inside a file or directory

Solution: grep command can be used to find a word inside a file.


[root@iravath search]# grep -rnw '.' -e "Apple"
./names.txt:3:Apple
 
The above command search for word "Apple" inside a file. The word "Apple" was found in names.txt at line number 3.