1.从百度百科查看到:
- {i}
- {i,j} 匹配指定数目的字符,这些字符是在它之前的表达式定义的。例如正则表达式A[0-9]{3} 能够匹配字符"A"后面跟着正好3个数字字符的串,例如A123、A348等,但是不匹配A1234。而正则表达式[0-9]{4,6} 匹配连续的任意4个、5个或者6个数字字符。注意:这个元字符不是所有的软件都支持的。
2.测试:
- [yangkai@admin awkdir]$ cat filea |awk '/[0-9]{3,}/'
- [yangkai@admin awkdir]$ cat filea |awk --re '/[0-9]{3,}/'
- 10/05766798607,11/20050325191329,29/0.1,14/05766798607
- 10/05767158557,11/20050325191329,29/0.08,14/05767158557
- [yangkai@admin awkdir]$ grep "[0-9]{5}"
- [yangkai@admin awkdir]$ grep "[0-9]{5}" filea
- [yangkai@admin awkdir]$ egrep "[0-9]{5}" filea
- 10/05766798607,11/20050325191329,29/0.1,14/05766798607
- 10/05767158557,11/20050325191329,29/0.08,14/05767158557
- [yangkai@admin awkdir]$ grep -E "[0-9]{5}" filea
- 10/05766798607,11/20050325191329,29/0.1,14/05766798607
- 10/05767158557,11/20050325191329,29/0.08,14/05767158557
- [yangkai@admin awkdir]$
3.man awk:
- -W re-interval
- --re-interval
- Enable the use of interval expressions in regular expression matching (see Regular Expressions, below).
- Interval expressions were not traditionally available in the AWK language. The POSIX standard added them, to
- make awk and egrep consistent with each other. However, their use is likely to break old AWK programs, so
- gawk only provides them if they are requested with this option, or when --posix is specified.
4.不是所有软件都适用。。。