Purpose: Use the grep command to find a string that matches a condition in a file
Format: grep "Options" "Find Mode" "File name"
When looking for a string, you want to display the following:
1) file name-------------------------grep displays the target file name by default when looking
2) where the line number----------------------------use the-n option
Grep-rn "string" file name
R (Recursive) recursion
N (number) displays the line numbers of the target locations
String: The string to find
FileName: The target file to locate, or * to find all files and directories in the current directory
Grep-n "abc" Test1.txt find string ABC in Test1.txt
GREP-RN "ABC" * in When directory recursively finds string ABC
Attention:
Can join-W to match whole word
GREP-RNW "abc" Test1.txt "
This article from "Van Gogh said my brain is sick" blog, declined reprint!
The grep lookup string for the Advanced Linux command