Mike,

You are correct. The semicolon is implied by the closing brace. In can also
be implied by a line feed in a script.

Seth




On Wed, Nov 20, 2013 at 12:50 PM, Mike Miller <mbmiller+l at gmail.com> wrote:

> On Wed, 20 Nov 2013, Kathryn Hogg wrote:
>
>  On 2013-11-20 00:16, Mike Miller wrote:
>>
>>  On Tue, 19 Nov 2013, Kathryn Hogg wrote:
>>>
>>
>> BEGIN is a special pattern that is applied once before any lines are
>> read. My second line doesn't have a pattern so its applied to all lines.
>>
>>
>>> echo "a;2; 3;4;5 ;abcdefghijk;7;8;9" | awk -F';' 'BEGIN { OFS=";"}
>>> {$6=substr($6, 0, 3); print $0;}'
>>> a;2; 3;4;5 ;abc;7;8;9
>>>
>>> echo "a;2; 3;4;5 ;abcdefghijk;7;8;9" | awk -F';' '{OFS=";"}
>>> {$6=substr($6, 0, 3); print $0}'
>>> a;2; 3;4;5 ;abc;7;8;9
>>>
>>
>> The difference here is that in the first case, OFS is set exactly once at
>> the beginning of the script.  In the second, OFS is set for every line that
>> is read from the file.  Its a bit wasteful but not too bad.
>>
>
> Does that mean that with BEGIN it will run a little faster?
>
> Did the semicolon at the end do anything?  As in "print $0;}"
>
> Thanks, Kathryn!
>
> Mike
>
> _______________________________________________
> TCLUG Mailing List - Minneapolis/St. Paul, Minnesota
> tclug-list at mn-linux.org
> http://mailman.mn-linux.org/mailman/listinfo/tclug-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mn-linux.org/pipermail/tclug-list/attachments/20131120/a420f033/attachment.html>