\unnumbchapentry{Preface}{1}
\unnumbsecentry{History of \code {awk} and \code {gawk}}{1}
\unnumbsecentry{The GNU Project and This Book}{1}
\unnumbsecentry{Acknowledgements}{3}
\chapentry{Introduction}{1}{5}
\secentry{Using This Book}{1}{1}{5}
\unnumbsubsecentry{Dark Corners}{6}
\secentry{Typographical Conventions}{1}{2}{6}
\secentry{Data Files for the Examples}{1}{3}{7}
\chapentry{Getting Started with \code {awk}}{2}{9}
\secentry{A Rose By Any Other Name}{2}{1}{9}
\secentry{How to Run \code {awk} Programs}{2}{2}{10}
\subsecentry{One-shot Throw-away \code {awk} Programs}{2}{2}{1}{10}
\subsecentry{Running \code {awk} without Input Files}{2}{2}{2}{11}
\subsecentry{Running Long Programs}{2}{2}{3}{11}
\subsecentry{Executable \code {awk} Programs}{2}{2}{4}{12}
\subsecentry{Comments in \code {awk} Programs}{2}{2}{5}{13}
\secentry{A Very Simple Example}{2}{3}{13}
\secentry{An Example with Two Rules}{2}{4}{14}
\secentry{A More Complex Example}{2}{5}{15}
\secentry{\code {awk} Statements Versus Lines}{2}{6}{16}
\secentry{Other Features of \code {awk}}{2}{7}{18}
\secentry{When to Use \code {awk}}{2}{8}{18}
\chapentry{Useful One Line Programs}{3}{21}
\chapentry{Regular Expressions}{4}{23}
\secentry{How to Use Regular Expressions}{4}{1}{23}
\secentry{Escape Sequences}{4}{2}{24}
\secentry{Regular Expression Operators}{4}{3}{26}
\secentry{Additional Regexp Operators Only in \code {gawk}}{4}{4}{31}
\secentry{Case-sensitivity in Matching}{4}{5}{33}
\secentry{How Much Text Matches?}{4}{6}{34}
\secentry{Using Dynamic Regexps}{4}{7}{35}
\chapentry{Reading Input Files}{5}{37}
\secentry{How Input is Split into Records}{5}{1}{37}
\secentry{Examining Fields}{5}{2}{40}
\secentry{Non-constant Field Numbers}{5}{3}{41}
\secentry{Changing the Contents of a Field}{5}{4}{42}
\secentry{Specifying How Fields are Separated}{5}{5}{44}
\subsecentry{The Basics of Field Separating}{5}{5}{1}{44}
\subsecentry{Using Regular Expressions to Separate Fields}{5}{5}{2}{45}
\subsecentry{Making Each Character a Separate Field}{5}{5}{3}{46}
\subsecentry{Setting \code {FS} from the Command Line}{5}{5}{4}{46}
\subsecentry{Field Splitting Summary}{5}{5}{5}{48}
\secentry{Reading Fixed-width Data}{5}{6}{49}
\secentry{Multiple-Line Records}{5}{7}{50}
\secentry{Explicit Input with \code {getline}}{5}{8}{53}
\subsecentry{Introduction to \code {getline}}{5}{8}{1}{53}
\subsecentry{Using \code {getline} with No Arguments}{5}{8}{2}{53}
\subsecentry{Using \code {getline} Into a Variable}{5}{8}{3}{54}
\subsecentry{Using \code {getline} from a File}{5}{8}{4}{55}
\subsecentry{Using \code {getline} Into a Variable from a File}{5}{8}{5}{56}
\subsecentry{Using \code {getline} from a Pipe}{5}{8}{6}{56}
\subsecentry{Using \code {getline} Into a Variable from a Pipe}{5}{8}{7}{57}
\subsecentry{Summary of \code {getline} Variants}{5}{8}{8}{58}
\chapentry{Printing Output}{6}{59}
\secentry{The \code {print} Statement}{6}{1}{59}
\secentry{Examples of \code {print} Statements}{6}{2}{59}
\secentry{Output Separators}{6}{3}{61}
\secentry{Controlling Numeric Output with \code {print}}{6}{4}{62}
\secentry{Using \code {printf} Statements for Fancier Printing}{6}{5}{62}
\subsecentry{Introduction to the \code {printf} Statement}{6}{5}{1}{62}
\subsecentry{Format-Control Letters}{6}{5}{2}{63}
\subsecentry{Modifiers for \code {printf} Formats}{6}{5}{3}{64}
\subsecentry{Examples Using \code {printf}}{6}{5}{4}{66}
\secentry{Redirecting Output of \code {print} and \code {printf}}{6}{6}{67}
\secentry{Special File Names in \code {gawk}}{6}{7}{69}
\secentry{Closing Input and Output Files and Pipes}{6}{8}{71}
\chapentry{Expressions}{7}{75}
\secentry{Constant Expressions}{7}{1}{75}
\subsecentry{Numeric and String Constants}{7}{1}{1}{75}
\subsecentry{Regular Expression Constants}{7}{1}{2}{75}
\secentry{Using Regular Expression Constants}{7}{2}{76}
\secentry{Variables}{7}{3}{77}
\subsecentry{Using Variables in a Program}{7}{3}{1}{77}
\subsecentry{Assigning Variables on the Command Line}{7}{3}{2}{78}
\secentry{Conversion of Strings and Numbers}{7}{4}{79}
\secentry{Arithmetic Operators}{7}{5}{80}
\secentry{String Concatenation}{7}{6}{81}
\secentry{Assignment Expressions}{7}{7}{82}
\secentry{Increment and Decrement Operators}{7}{8}{85}
\secentry{True and False in \code {awk}}{7}{9}{86}
\secentry{Variable Typing and Comparison Expressions}{7}{10}{86}
\secentry{Boolean Expressions}{7}{11}{89}
\secentry{Conditional Expressions}{7}{12}{90}
\secentry{Function Calls}{7}{13}{91}
\secentry{Operator Precedence (How Operators Nest)}{7}{14}{92}
\chapentry{Patterns and Actions}{8}{95}
\secentry{Pattern Elements}{8}{1}{95}
\subsecentry{Kinds of Patterns}{8}{1}{1}{95}
\subsecentry{Regular Expressions as Patterns}{8}{1}{2}{95}
\subsecentry{Expressions as Patterns}{8}{1}{3}{96}
\subsecentry{Specifying Record Ranges with Patterns}{8}{1}{4}{97}
\subsecentry{The \code {BEGIN} and \code {END} Special Patterns}{8}{1}{5}{98}
\subsubsecentry{Startup and Cleanup Actions}{8}{1}{5}{1}{98}
\subsubsecentry{Input/Output from \code {BEGIN} and \code {END} Rules}{8}{1}{5}{2}{99}
\subsecentry{The Empty Pattern}{8}{1}{6}{100}
\secentry{Overview of Actions}{8}{2}{100}
\chapentry{Control Statements in Actions}{9}{103}
\secentry{The \code {if}-\code {else} Statement}{9}{1}{103}
\secentry{The \code {while} Statement}{9}{2}{104}
\secentry{The \code {do}-\code {while} Statement}{9}{3}{104}
\secentry{The \code {for} Statement}{9}{4}{105}
\secentry{The \code {break} Statement}{9}{5}{106}
\secentry{The \code {continue} Statement}{9}{6}{107}
\secentry{The \code {next} Statement}{9}{7}{108}
\secentry{The \code {nextfile} Statement}{9}{8}{109}
\secentry{The \code {exit} Statement}{9}{9}{110}
\chapentry{Built-in Variables}{10}{113}
\secentry{Built-in Variables that Control \code {awk}}{10}{1}{113}
\secentry{Built-in Variables that Convey Information}{10}{2}{115}
\secentry{Using \code {ARGC} and \code {ARGV}}{10}{3}{117}
\chapentry{Arrays in \code {awk}}{11}{121}
\secentry{Introduction to Arrays}{11}{1}{121}
\secentry{Referring to an Array Element}{11}{2}{122}
\secentry{Assigning Array Elements}{11}{3}{123}
\secentry{Basic Array Example}{11}{4}{123}
\secentry{Scanning All Elements of an Array}{11}{5}{124}
\secentry{The \code {delete} Statement}{11}{6}{125}
\secentry{Using Numbers to Subscript Arrays}{11}{7}{127}
\secentry{Using Uninitialized Variables as Subscripts}{11}{8}{127}
\secentry{Multi-dimensional Arrays}{11}{9}{128}
\secentry{Scanning Multi-dimensional Arrays}{11}{10}{130}
\secentry{Using Array Memory Efficiently}{11}{11}{130}
\chapentry{Built-in Functions}{12}{133}
\secentry{Calling Built-in Functions}{12}{1}{133}
\secentry{Numeric Built-in Functions}{12}{2}{134}
\secentry{Built-in Functions for String Manipulation}{12}{3}{135}
\secentry{Built-in Functions for Input/Output}{12}{4}{143}
\secentry{Functions for Dealing with Time Stamps}{12}{5}{146}
\chapentry{User-defined Functions}{13}{151}
\secentry{Function Definition Syntax}{13}{1}{151}
\secentry{Function Definition Examples}{13}{2}{152}
\secentry{Calling User-defined Functions}{13}{3}{154}
\secentry{The \code {return} Statement}{13}{4}{156}
\chapentry{Running \code {awk}}{14}{159}
\secentry{Command Line Options}{14}{1}{159}
\secentry{Other Command Line Arguments}{14}{2}{163}
\secentry{The \code {AWKPATH} Environment Variable}{14}{3}{164}
\secentry{Obsolete Options and/or Features}{14}{4}{165}
\secentry{Undocumented Options and Features}{14}{5}{165}
\secentry{Known Bugs in \code {gawk}}{14}{6}{165}
\chapentry{A Library of \code {awk} Functions}{15}{167}
\secentry{Simulating \code {gawk}-specific Features}{15}{1}{167}
\secentry{Implementing \code {nextfile} as a Function}{15}{2}{167}
\secentry{Assertions}{15}{3}{169}
\secentry{Rounding Numbers}{15}{4}{171}
\secentry{Translating Between Characters and Numbers}{15}{5}{172}
\secentry{Merging an Array Into a String}{15}{6}{174}
\secentry{Turning Dates Into Timestamps}{15}{7}{175}
\secentry{Managing the Time of Day}{15}{8}{180}
\secentry{Noting Data File Boundaries}{15}{9}{182}
\secentry{Processing Command Line Options}{15}{10}{184}
\secentry{Reading the User Database}{15}{11}{189}
\secentry{Reading the Group Database}{15}{12}{194}
\secentry{Naming Library Function Global Variables}{15}{13}{199}
\chapentry{Practical \code {awk} Programs}{16}{201}
\secentry{Re-inventing Wheels for Fun and Profit}{16}{1}{201}
\subsecentry{Cutting Out Fields and Columns}{16}{1}{1}{201}
\subsecentry{Searching for Regular Expressions in Files}{16}{1}{2}{206}
\subsecentry{Printing Out User Information}{16}{1}{3}{210}
\subsecentry{Splitting a Large File Into Pieces}{16}{1}{4}{212}
\subsecentry{Duplicating Output Into Multiple Files}{16}{1}{5}{214}
\subsecentry{Printing Non-duplicated Lines of Text}{16}{1}{6}{216}
\subsecentry{Counting Things}{16}{1}{7}{220}
\secentry{A Grab Bag of \code {awk} Programs}{16}{2}{223}
\subsecentry{Finding Duplicated Words in a Document}{16}{2}{1}{223}
\subsecentry{An Alarm Clock Program}{16}{2}{2}{223}
\subsecentry{Transliterating Characters}{16}{2}{3}{226}
\subsecentry{Printing Mailing Labels}{16}{2}{4}{228}
\subsecentry{Generating Word Usage Counts}{16}{2}{5}{230}
\subsecentry{Removing Duplicates from Unsorted Text}{16}{2}{6}{232}
\subsecentry{Extracting Programs from Texinfo Source Files}{16}{2}{7}{233}
\subsecentry{A Simple Stream Editor}{16}{2}{8}{237}
\subsecentry{An Easy Way to Use Library Functions}{16}{2}{9}{239}
\chapentry{The Evolution of the \code {awk} Language}{17}{247}
\secentry{Major Changes between V7 and SVR3.1}{17}{1}{247}
\secentry{Changes between SVR3.1 and SVR4}{17}{2}{248}
\secentry{Changes between SVR4 and POSIX \code {awk}}{17}{3}{248}
\secentry{Extensions in the Bell Laboratories \code {awk}}{17}{4}{249}
\secentry{Extensions in \code {gawk} Not in POSIX \code {awk}}{17}{5}{249}
\chapentry{\code {gawk} Summary}{Appendix{} A}{253}
\secentry{Command Line Options Summary}{A}{1}{253}
\secentry{Language Summary}{A}{2}{254}
\secentry{Variables and Fields}{A}{3}{255}
\subsecentry{Fields}{A}{3}{1}{255}
\subsecentry{Built-in Variables}{A}{3}{2}{256}
\subsecentry{Arrays}{A}{3}{3}{258}
\subsecentry{Data Types}{A}{3}{4}{258}
\secentry{Patterns}{A}{4}{259}
\subsecentry{Pattern Summary}{A}{4}{1}{259}
\subsecentry{Regular Expressions}{A}{4}{2}{260}
\secentry{Actions}{A}{5}{262}
\subsecentry{Operators}{A}{5}{1}{262}
\subsecentry{Control Statements}{A}{5}{2}{263}
\subsecentry{I/O Statements}{A}{5}{3}{264}
\subsecentry{\code {printf} Summary}{A}{5}{4}{265}
\subsecentry{Special File Names}{A}{5}{5}{267}
\subsecentry{Built-in Functions}{A}{5}{6}{267}
\subsecentry{Time Functions}{A}{5}{7}{269}
\subsecentry{String Constants}{A}{5}{8}{270}
\secentry{User-defined Functions}{A}{6}{271}
\secentry{Historical Features}{A}{7}{271}
\chapentry{Installing \code {gawk}}{Appendix{} B}{273}
\secentry{The \code {gawk} Distribution}{B}{1}{273}
\subsecentry{Getting the \code {gawk} Distribution}{B}{1}{1}{273}
\subsecentry{Extracting the Distribution}{B}{1}{2}{275}
\subsecentry{Contents of the \code {gawk} Distribution}{B}{1}{3}{275}
\secentry{Compiling and Installing \code {gawk} on Unix}{B}{2}{278}
\subsecentry{Compiling \code {gawk} for Unix}{B}{2}{1}{278}
\subsecentry{The Configuration Process}{B}{2}{2}{279}
\secentry{How to Compile and Install \code {gawk} on VMS}{B}{3}{279}
\subsecentry{Compiling \code {gawk} on VMS}{B}{3}{1}{279}
\subsecentry{Installing \code {gawk} on VMS}{B}{3}{2}{280}
\subsecentry{Running \code {gawk} on VMS}{B}{3}{3}{281}
\subsecentry{Building and Using \code {gawk} on VMS POSIX}{B}{3}{4}{281}
\secentry{MS-DOS and OS/2 Installation and Compilation}{B}{4}{282}
\secentry{Installing \code {gawk} on the Atari ST}{B}{5}{283}
\subsecentry{Compiling \code {gawk} on the Atari ST}{B}{5}{1}{283}
\subsecentry{Running \code {gawk} on the Atari ST}{B}{5}{2}{284}
\secentry{Installing \code {gawk} on an Amiga}{B}{6}{285}
\secentry{Reporting Problems and Bugs}{B}{7}{285}
\secentry{Other Freely Available \code {awk} Implementations}{B}{8}{287}
\chapentry{Implementation Notes}{Appendix{} C}{289}
\secentry{Downward Compatibility and Debugging}{C}{1}{289}
\secentry{Making Additions to \code {gawk}}{C}{2}{289}
\subsecentry{Adding New Features}{C}{2}{1}{289}
\subsecentry{Porting \code {gawk} to a New Operating System}{C}{2}{2}{291}
\secentry{Probable Future Extensions}{C}{3}{293}
\secentry{Suggestions for Improvements}{C}{4}{294}
\chapentry{Glossary}{Appendix{} D}{295}
\unnumbchapentry{GNU GENERAL PUBLIC LICENSE}{303}
\unnumbsecentry{Preamble}{303}
\unnumbsecentry{TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION}{304}
\unnumbsecentry{How to Apply These Terms to Your New Programs}{309}
\unnumbchapentry{Index}{311}
