Special character of grep-General Linux technology-Linux technology and application information. The following is a detailed description. First, check ^ $:
$ Grep-n' \ ^ 'grep.txt
$ Grep-n' ^ 'grep.txt
$ Grep-n "^" grep.txt
$ Grep-n "\ ^" grep.txt
Both the first and last lines match the row containing ^ characters, while the two lines in the middle both output all rows, as shown in the same way as $.
Let's look at "* [] () | \ +?
$ Grep-N'. 'grep.txt
$ Grep-n' \. 'grep.txt
$ Grep-n "." grep.txt
$ Grep-n "\." grep.txt
The first and third outputs all rows, and the other two outputs contain rows.
The above four forms of command output can contain * +? .
For the above four forms of commands, if the command line does not contain \, you can output the line containing |, and add \ to output all lines.
$ Grep-n' \ 'grep.txt
Grep: Trailing backslash
$ Grep-n' \ 'grep.txt
31 :\
$ Grep-n "\" grep.txt
>-Bash: unexpected EOF while looking for matching '"'
-Bash: syntax error: unexpected end of file
$ Grep-n "\" grep.txt
Grep: Trailing backslash
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service