[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The rule of using '{}' (awk)
From: |
John Cowan |
Subject: |
Re: The rule of using '{}' (awk) |
Date: |
Fri, 21 Aug 2009 11:34:50 -0400 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Peng Yu scripsit:
> I get the following syntax error. The error is fixed if I remove the
> out most '{}'. I am wondering what the rule is to use '{}' in awk.,
> $ awk '{!/#.*/ {print $1,$2,$3}}' data.txt
> awk: {!/#.*/ {print $1,$2,$3}}
> awk: ^ syntax error
Awk statements contain a pattern and an action; both are optional.
The action part is enclosed in braces. If you enclose the whole thing
in braces, it looks like an action part, and awk doesn't like the
regular expression followed by the block without any separator (; or newline)
between them. Removing the outer braces is the Right Thing.
This isn't an appropriate question for this list, however, which is about
gawk bugs.
--
Business before pleasure, if not too bloomering long before.
--Nicholas van Rijn
John Cowan <address@hidden>
http://www.ccil.org/~cowan