10. Sed Regular Expression

^

$

.

[]

[^]

[-] interval

\? -E does not require \

\+ -E does not require \

*

{n} or {n,}

|

\ escape character

\r

\n

POSIX type regex

[:alnum:]

[:alpha:]

[:blank:]

[:digit:]

[:lower:]

I don’t think it’s useful. I don’t use it much anyway.

metacharacter meaning
\b word boundary
\B non-word boundaries
\s space
\S non-space
\w word
\W non-word
\` exact match

Regarding the enhanced regular expression, some unix or linux versions may be different. It is recommended to use the -E option for ubuntu. You can also use the -r option. The same function is used.

There is no -E option in the ubuntu documentation but it can still be used

dingmac@ubuntu:~$ seq 105 | sed -En '/[0-9]{3,}/p' 
100
101
102
103
104
105
dingmac@ubuntu:~$ seq 105 | sed -rn '/[0-9]{3,}/p' 
100
101
102
103
104
105
dingmac@ubuntu:~$ seq 105 | sed -n '/[0-9]{3,}/p'
NOTHING...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325881948&siteId=291194637