Re: awk RE
- From
- mz1@stlport.org (2:5020/400)
- To
- Valentin Davydov (2:5054/37.63)
- Date
- 2006-11-17T19:59:58Z
- Area
- RU.UNIX.BSD
From: mz1@stlport.org
Valentin Davydov <val@sqdp.trc-net.co.jp> wrote:
> $ man awk
> Patterns are arbitrary Boolean combinations (with ! || &&) of regular
> expressions and relational expressions. Regular expressions are as in
> egrep; see grep(1). Isolated regular expressions in a pattern apply to
> the entire line. Regular expressions may also occur in relational
> expressions, using the operators ~ and !~. /re/ is a constant regular
> expression; any string (constant or variable) may be used as a regular
> expression, except in the position of an isolated regular expression in
> a pattern.
>
> $ echo 000111 | egrep '^0{3}'
> 000111
> $ echo 000111 | awk '/^0{3}/'
> $
>
> Это очередная бага в авке или я чего-то не понимаю?
>
> Вал. Дав.
Далее оттуда же:
For /regular expression/ patterns, the associated statement is exe-
cuted for each input record that matches the regular expression.
Т.е. надо просто матча недостаточно, нужно что-то сделать с ним:
$ echo 000111 | awk '/^0{3}/p'
000111
Андрей Левочкин
--- ifmail v.2.15dev5.3
* Origin: Demos online service (2:5020/400)
SEEN-BY: 50/12 400/814 450/159 1024 461/43 132 640 469/999 4616/3 4625/8
SEEN-BY: 4641/444 5000/76 5000 5006/1 5007/1 5010/70 5011/13 5012/46 5015/28
SEEN-BY: 5019/31 5020/18 175 194 400 545 982 1057 1909 1922 2238 2395 2871
SEEN-BY: 5020/4441 5021/29 5025/3 5026/14 45 5027/12 5030/1080 1957 5034/10 13
SEEN-BY: 5035/3 38 5036/1 5045/7 5049/1 5051/15 5054/1 4 8 9 11 28 35 36 37 45
SEEN-BY: 5054/63 66 67 70 75 84 85 5059/9 5060/88 5061/15 5062/10 5063/3
SEEN-BY: 5064/7 5066/18 5075/5 5076/1 5077/70 5080/1003 5084/9 5085/13 5095/20
SEEN-BY: 5096/18 6001/10
PATH: 5020/400 545 5054/1 37