Sometimes, we need to find some content in the document, commonly used grep. It finds relevant content in the document and outputs matching rows.
> Find a keyword
In System.log, find the row that contains the keyword
grep ' keyword ' System.log
Output line numbers are included in the search for easy viewing
grep ' keyword ' System.log
> Basic Regular expressions supported by default
Find lines that start with 2015-09-24
grep ' ^2015-09-24 ' System.log
> supports extended regular expressions
Regular expressions are used in various fields, and it is more convenient to use it with grep to find files.
In general, grep supports the basic expression, plus the-e option, which supports extended regular expressions.
Find rows that contain keyword1 or keyword2 with line numbers
grep ' Keyword1|keyword2 ' System.log
"Linux" uses grep to find content in a document