Linux finds common command methods for file content.
Find the line matching the specified string from the file contents:
$ grep "string found" file name
Example: Looking for the. In file containing the specified string in the first level folder in the current directory
grep "Thermcontact" */*.in
Find the line that matches the regular expression from the file contents:
$ grep–e "Regular expression" file name
Find is case insensitive:
$ grep–i "string found" file name
To find the number of matching rows:
$ grep-c "string found" file name
Find rows that do not match the specified string from the file contents:
$ grep–v "string found" file name
From the root directory, look for all text files with a. log extension and find the line that contains "ERROR"
Find/-type f-name "*.log" | Xargs grep "ERROR"
Example: Starting from the current directory, find all text files with an. in extension and find the line containing "Thermcontact"
Find. -name "*.in" | Xargs grep "Thermcontact"
How to find file contents in Linux