Use grep and find commands to find file content in Linux
Find lines matching a specified string from the contents of a file:
$ grep "search string" filename
Example: Find the .in file containing the specified string in the first-level folder in the current directory
grep "thermcontact" /.in
Find lines matching a regular expression from the contents of a file:
$ grep –e "regular expression" filename
Lookups are case-insensitive:
$ grep –i "string to be searched" filename
Find the number of matching rows:
$ grep -c "search string" filename
Find lines from the contents of a file that do not match a specified string:
$ grep –v "Find string" filename
Find all text files with extension .log starting from the root directory and find the line containing "ERROR":
$ find / -type f -name "*.log" | xargs grep "ERROR"
Example: Find all text files with extension .in starting from the current directory and find the lines containing "thermcontact":
find . -name "*.in" | xargs grep "thermcontact"