Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A summary of the usage of regularities and sed.

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

A summary of the usage of regularities and sed.

Generally use egrep

Egrep [option] "pattern" FILE

-v: display content other than the matching result

-I: ignore case

-o: show only the matching content (more commonly used)

-- color uses colors to display the matching content.

-A 1 means to match the line after the content: EX egrep-A 1'^ ssh' / etc/passwd means to match to the line that begins with SSH.

-B1 displays 1 line that matches to the front of the content

-C 1 indicates that one line before and after matching to the content

Egrep source characters:

+: indicates that the preceding character is matched at least once. Egrep-- color 'aroomb' / etc/fstab

| |: match | either side a | b means match a | b (a | b) c means ac or bc a | bc, which means an or bc. |

? Match 0 times or once

*: match the preceding characters any number of times

. Match the preceding characters once

. *: it means any character, any number of times, egrep "a. Roomb" / etc/fstab means to grab / etc/fstab a followed by any character one or more times. For example, a123b abb ab aab aiienwkjen23b meets the conditions.

(1) grouping, which can be used for backward references and is often used with {}

{npencil m} means to match the preceding character or word or phrase only n times, up to m times. Egrep'ab {1pc4} c'/ etc/fstab

EX / tmp/1 content is he like his liker

He love his like

He like his lover wants to match to the fourth word and end the second word with r.

Egrep "l (. *) e\ 1er" / tmp/1

Egrep-o "(\.) (3)" / etc/fstab

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report