Shell review notes ---- search and replace, shell review notes ----
Search for documents
It is quite convenient to search for text (match text matching text) using the grep program. Traditionally, there are three programs that can be used to search for the entire text file.
- Grep's earliest text match program. The simplest method is to use a fixed string.
$ Who | grep-F austen // use the-F option in the example to find the fixed string austen.
In fact, as long as the matching mode does not contain the meta character of the regular expression (metacharacter), grep's default behavior mode is equivalent to using-F.
$ Who | grep austen
- Egrep extended type grep. This program uses extended regular expressions-this is a set of more powerful regular expressions, the cost of using it is better than more computing resources.
- Fgrep Fast grep (Fast grep). This version matches fixed strings rather than regular expressions. It uses an optimized algorithm to effectively match fixed strings.
Regular Expression
A regular expression is a representation that allows you to search for texts that match a specific criterion. This Representation allows you to write an expression that selects or matches multiple data strings.
In addition to the traditional UNIX regular expressions, POSIX regular expressions can also be:
- Write a regular expression that indicates the sequence of characters and equivalent characters specific to locale.
- Write Regular Expressions without having to worry about the underlying character set of the system.