Friday, December 5, 2008
Shell Scripting #0006 - How to search inside a file in Unix?
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?
Solution:
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?
Solution:
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)
Example:
sh> grep -inR "needle" *
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment