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

Introduction to the basis of regular symbols

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Overview of course knowledge.

1) system regular symbol

Basic regularity

Extended regularity

2. Review of course knowledge

1) File attributes section

Indoe block concept understanding characteristic function birth process viewing process

Soft link hard link concept understanding characteristics function birth process viewing process

Find hard link files based on inode number

2) system symbol information

Basic symbol: # $! | | "''``> |

< :set list ^$ ---匹配空行信息 grep -v "^$" /etc/selinux/config --- 利用v进行取反, 排除空行显示 排除空行 . ------匹配任意一个字符且只有一个字符 ----- 匹配符号前面一个字符连续出现0次或者多次 .* -----匹配任意所有字符信息 \ -----转义 (将意思进行转变) 符号 1)将有意义的信息变得没意义 ![](https://s1.51cto.com/images/blog/201912/22/448b68a923aa9e9e3d7728d2db51ca7a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) 2)将没意义的信息的信息变的有意义(自我识别) \b ----退格键,向左删除 \n-----换行符 \t-----制表符 \r-----回车符 3)[ ]------匹配多个字符信息 [^ ] ------ 将匹配多个字符取反 扩展正则符号: grep -E ------扩展正则符号 / egerp 扩展正则符号 sed -r -----扩展正则符号 ----匹配符号前面一个字符连续出现一次或者多次 ?------匹配符号前面一个字符连续出现0次或者一次

{}-the specified number of consecutive occurrences of one character in front of the matching symbol

{n, m}-one character in front of the matching symbol appears at least n times in a row and m times at most

{n}-one character in front of the matching symbol appears continuously for the specified n times

{n,}-the character in front of the matching symbol appears at least n times in a row, with no limit at most

{, m}-one character in front of the matching symbol appears at least o times in a row and m times at most

| |-matches multiple string information |

()-aggregate the information of multiple characters into a whole

()-the latter item refers to the information in the preceding paragraph

Note: when the latter item refers to the preceding item, a maximum of 9 parentheses can be used

Regular symbol exercises:

Exercise 1: filter the ID card number information, filter the correct ID card information

Test file information

Old boy 110109197706078765

Old girl 105110111100281236

Old dog oldboy

Zhang San 117237

Li Si 123123oldboy

Wang Wu 1231236192 30917203710237

Exercise 2: how to extract file permission values

Idea 1: what command can display file permissions

Stat / etc/hosts

Idea 2: take out the target information line # stat / etc/hosts | grep Uid idea 3: take the specified information in the trip # stat / etc/hosts | grep Uid | grep-E "[0-7] {4}"-o

Exercise 3: how to remove IP address information

Ip a s eth0

Exercise 4: remove disk utilization

Df-h | grep / dev/sda3 | grep-E "[0-9] {1pm 3}%"-o

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

Servers

Wechat

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

12
Report