Grep is your tool of choice to search through file in Linux.
There is 3 main way to feed inputs in grep:
grep search file
grep -r search ./dir
cat file | grep search
grep -i search file
grep -v search file
grep -w search file
grep -x search file
grep -e search1 -e search2 file
grep -n search file
grep -A1 search file
grep -B1 search file
grep -C1 search file
grep -m1 search file
grep -c search file
grep -E search file
example: grep -E t$ file
(search for lines ending in "t")
useful when you pass grep to something else before printing.
grep --color=always
Will print everything but color your search pattern.
grep "search\|$" file
The search text "search\|$" is actually a trick, it will match lines that have pattern
OR lines that have an end. Because all lines have an end, all lines are matched, but the end of a line isn't actually any characters, so it won't be colored.[1]
1]: [bash - Colorized grep -- viewing the entire file with highlighted matches - Stack Overflow