2013年4月9日 星期二

awk的BEGIN與END區塊


BEGIN
 A BEGIN rule is executed, once, before the first input record has been read

PS:
If an awk program only has a BEGIN rule, and no other rules, then the program exits after the BEGIN rule has been run. (Older versions of awk used to keep reading and ignoring input until end of file was seen.)



END
An END rule is executed, once, after all the input has been read


BEGIN and END rules must have actions; there is no default action for these rules since there is no current record when they run.



Reference
[1] awk的BEGIN與END區塊, http://lalakiwe.myweb.hinet.net/Documents/awk/awk_appendix.html
[2] http://www.staff.science.uu.nl/~oostr102/docs/nawk/nawk_52.html

沒有留言:

張貼留言