First, regular expressions
In computer science, regular expressions are used to describe or match a series of strings that conform to a certain syntactic rule; in a text editor or some tool (such as bash environment), regular expressions are often used to retrieve text content that conforms to a pattern. In Linux, regular expressions are patterns written by a class of characters. Filter the strings needed in the bash environment by implementing well-defined patterns.
A regular expression is made up of a series of ordinary characters and some meta characters. Ordinary characters mainly include uppercase and lowercase letters and numbers. Metacharacters has a special meaning. It does not represent the meaning of the character itself and is used for additional functional descriptions. Regular expressions have basic regular expressions and extended regular expressions, and I'll list some common metacharacters that are commonly used in Linux, and explain them with relevant examples:
1. Basic Regular Expressions
2. Extending Regular Expressions
The following main lists the partial metacharacters different from the basic regular expressions
3. There are some other escape characters in Linux, but there are only a few enumerated and explained in common. Interested friends can view the help system provided in the man document through the man 7 regex.
Ii. Use of GREP commands
Let me show you how to use the grep command to do pattern matching using regular expressions. Let me first introduce the basic use of GREP commands.
grep (Global search Regular Expression and Printing), which represents a comprehensive search of regular expressions and prints, is a powerful text search tool that can use regular expressions to search for text and print matching rows. grep has three kinds, including grep, Egrep, and Fgrep.
The following are indicated respectively:
This paper url:http://www.bianceng.cn/os/linux/201410/45620.htm