【linux 正则表达式】4-正则表达式基础

https://edu.aliyun.com/lesson_1734_14288#_14288

netstat -n

netstat -n | findstr 250 findstr类似于grep
findstr /?

  • 字符匹配

grep root /etc/passwd
grep "r..t" /etc/passwd
grep -v "r..t" /etc/passwd 取反
grep "[^123]" /etc/passwd 取反

ifconfig eth0
ifconfig eth0|grep netmask|grep -o '[[:digit].]' -o 匹配一个放一行里面
"o*" 表示任意次,包括0次 默认是贪婪模式

  • 位置锚定

"^root"
"root$"
"^root$"
grep -v "^$" f1 取反,非空行

数字,字母,下划线都叫单词

  • 分组

a或b开头

原文地址:https://www.cnblogs.com/sec875/p/13452200.html