An Entrepreneur, Coach, IT Consultant, Strategic Adviser, and a Traveler craving to explore and contribute to forming a better society.

Friday, December 5, 2008

Shell Scripting #0006 - How to search inside a file in Unix?

No comments :
Keywords: Linux, Shell Scripts, Scripting, Bash, Grep, Regex, Regular Expression

Problem: You have a folder with numerous files in it and you have to look for a specific word in all the files inside the folder. How to search inside a file in Unix?


File(s) contains a word in a particular directory or Search Recursively inside a folder (Category: Shell Scripting)

grep -inR "word_to_search" * 
-i ---> Incase-sesitive 
-n ---> Number of the line, the word is lying 
-R ---> Recursive 
* ---> Search in all the folder(recursively)
sh> grep -inR "needle" *

No comments :