2021年1月17日星期日

Difference of BRE(Basic Regex) and ERE(Extended Regex) on using sed, grep, awk.

 Special Chars:

BRE.[\*^$
ERE.[\()*+?{|^$

ex. pattern for abc-adafaadsf abc adaadefaa 

BRE: abc\|def
ERE: abc|def

ex. pattern for match count.

BRE: abc\{3,5\}
ERE: abc{3,5}
so, when using command of awk, grep, sed. don't forget using -r for ERE(extended regex). 
but, when writing a shell script, using BRE is better, because 6 chars of 「.[\*^$」 are specials,
but there more special chars 「.[\()*+?{|^$」 for ERE. 
Which is better, as you select.


没有评论: