AWK Language Programming (1996)
by Arnold D. Robbins
1999569AWK Language Programming1996Arnold D. Robbins


AWK Language Programming


A User's Guide for GNU AWK
Edition 1.0
January 1996

Arnold D. Robbins

Based on The GAWK Manual,
by Robbins, Close, Rubin, and Stallman


To boldly go where no man has gone before" is a Registered Trademark of Paramount Pictures Corporation.

Copyright © 1989, 1991 - 1996 Free Software Foundation, Inc.


This is Edition 1.0 of AWK Language Programming,
for the 3.0 (or later) version of the GNU implementation of AWK.


Published by the Free Software Foundation
59 Temple Place — Suite 330
Boston, MA 02111-1307 USA
Phone: +1-617-542-5942
Fax (including Japan): +1-617-542-2652
Printed copies are available for $25 each.
ISBN 1-882114-26-4

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modi ed versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modi ed versions, except that this permission notice may be stated in a translation approved by the Foundation.


Cover art by Etienne Suvasa.

To Miriam, for making me complete.

To Chana, for the joy you bring us.

To Rivka, for the exponential increase.

Short Contents

Preface
....................................................................................................................................................................................................................................................
1
1
Introduction
....................................................................................................................................................................................................................................................
5
2
Getting Started with awk
....................................................................................................................................................................................................................................................
9
3
Useful One Line Programs
....................................................................................................................................................................................................................................................
21
4
Regular Expressions
....................................................................................................................................................................................................................................................
23
5
Reading Input Files
....................................................................................................................................................................................................................................................
37
6
Printing Output
....................................................................................................................................................................................................................................................
61
7
Expressions
....................................................................................................................................................................................................................................................
77
8
Patterns and Actions
....................................................................................................................................................................................................................................................
97
9
Control Statements in Actions
....................................................................................................................................................................................................................................................
105
10
Built-in Variables
....................................................................................................................................................................................................................................................
115
11
Arrays in awk
....................................................................................................................................................................................................................................................
123
12
Built-in Functions
....................................................................................................................................................................................................................................................
135
13
User-defined Functions
....................................................................................................................................................................................................................................................
153
14
Running awk
....................................................................................................................................................................................................................................................
161
15
A Library of awk Functions
....................................................................................................................................................................................................................................................
169
16
Practical awk Programs
....................................................................................................................................................................................................................................................
203
17
The Evolution of the awk Language
....................................................................................................................................................................................................................................................
251
Appendix A gawk Summary
....................................................................................................................................................................................................................................................
257
Appendix B Installing gawk
....................................................................................................................................................................................................................................................
277
Appendix C Implementation Notes
....................................................................................................................................................................................................................................................
293
Appendix D Glossary
....................................................................................................................................................................................................................................................
299
GNU GENERAL PUBLIC LICENSE
....................................................................................................................................................................................................................................................
307
Index
....................................................................................................................................................................................................................................................
315


This work is Copyright © Free Software Foundation, Inc. and is free because it is licensed under the Old FSF Documentation License.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Free Software Foundation.

Public domainPublic domainfalsefalse