Answers:
grep -Inr "your file name"
where,
I -> Indicates exclude binary file for the current search.
n -> Prefix each line of output with the 1-based line number
within its input file
r -> Read all files under each directory.
Example:
grep -Inr "helloworld"
Description:
This will search the given word in all files recursively under the current path except in the binary files. If the match found it will display the file and line number where exactly it appears.
grep -Inr --exclude='*.FileType' "Search word"
Example:
grep -Inr --exclude='*.html' "helloworld"
Description:
This will search the given word in all files recursively under the current path except in the binary files and .html files. Because as we specifically mentioned exclude the files of type html. If the match found it will display the file and line number where exactly it appears.
0 comments: