old-www/LDP/Bash-Beginners-Guide/html/chap_06.html

360 lines
4.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>The GNU awk programming language</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Bash Guide for Beginners"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Exercises"
HREF="sect_05_05.html"><LINK
REL="NEXT"
TITLE="Getting started with gawk"
HREF="sect_06_01.html"></HEAD
><BODY
CLASS="chapter"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Bash Guide for Beginners</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sect_05_05.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sect_06_01.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="chapter"
><H1
><A
NAME="chap_06"
></A
>Chapter 6. The GNU awk programming language</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
>6.1. <A
HREF="sect_06_01.html"
>Getting started with gawk</A
></DT
><DD
><DL
><DT
>6.1.1. <A
HREF="sect_06_01.html#sect_06_01_01"
>What is gawk?</A
></DT
><DT
>6.1.2. <A
HREF="sect_06_01.html#sect_06_01_02"
>Gawk commands</A
></DT
></DL
></DD
><DT
>6.2. <A
HREF="sect_06_02.html"
>The print program</A
></DT
><DD
><DL
><DT
>6.2.1. <A
HREF="sect_06_02.html#sect_06_02_01"
>Printing selected fields</A
></DT
><DT
>6.2.2. <A
HREF="sect_06_02.html#sect_06_02_02"
>Formatting fields</A
></DT
><DT
>6.2.3. <A
HREF="sect_06_02.html#sect_06_02_03"
>The print command and regular expressions</A
></DT
><DT
>6.2.4. <A
HREF="sect_06_02.html#sect_06_02_04"
>Special patterns</A
></DT
><DT
>6.2.5. <A
HREF="sect_06_02.html#sect_06_02_05"
>Gawk scripts</A
></DT
></DL
></DD
><DT
>6.3. <A
HREF="sect_06_03.html"
>Gawk variables</A
></DT
><DD
><DL
><DT
>6.3.1. <A
HREF="sect_06_03.html#sect_06_03_01"
>The input field separator</A
></DT
><DT
>6.3.2. <A
HREF="sect_06_03.html#sect_06_03_02"
>The output separators</A
></DT
><DT
>6.3.3. <A
HREF="sect_06_03.html#sect_06_03_03"
>The number of records</A
></DT
><DT
>6.3.4. <A
HREF="sect_06_03.html#sect_06_03_04"
>User defined variables</A
></DT
><DT
>6.3.5. <A
HREF="sect_06_03.html#sect_06_03_05"
>More examples</A
></DT
><DT
>6.3.6. <A
HREF="sect_06_03.html#sect_06_03_06"
>The printf program</A
></DT
></DL
></DD
><DT
>6.4. <A
HREF="sect_06_04.html"
>Summary</A
></DT
><DT
>6.5. <A
HREF="sect_06_05.html"
>Exercises</A
></DT
></DL
></DIV
><BLOCKQUOTE
CLASS="ABSTRACT"
><DIV
CLASS="abstract"
><A
NAME="AEN3998"
></A
><P
></P
><P
>In this chapter we will discuss:</P
><P
><P
></P
><UL
><LI
><P
>What is <SPAN
CLASS="application"
>gawk</SPAN
>?</P
></LI
><LI
><P
>Using <SPAN
CLASS="application"
>gawk</SPAN
> commands on the command line</P
></LI
><LI
><P
>How to format text with <SPAN
CLASS="application"
>gawk</SPAN
></P
></LI
><LI
><P
>How <SPAN
CLASS="application"
>gawk</SPAN
> uses regular expressions</P
></LI
><LI
><P
><SPAN
CLASS="application"
>Gawk</SPAN
> in scripts</P
></LI
><LI
><P
><SPAN
CLASS="application"
>Gawk</SPAN
> and variables</P
></LI
></UL
></P
><P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>To make it more fun</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>As with <B
CLASS="command"
>sed</B
>, entire books have been written about various versions of <B
CLASS="command"
>awk</B
>. This introduction is far from complete and is only intended for understanding examples in the following chapters. For more information, best start with the documentation that comes with <SPAN
CLASS="application"
>GNU awk</SPAN
>: <SPAN
CLASS="QUOTE"
>"GAWK: Effective AWK Programming: A User's Guide for GNU Awk"</SPAN
>.</P
></TD
></TR
></TABLE
></DIV
></P
><P
></P
></DIV
></BLOCKQUOTE
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sect_05_05.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sect_06_01.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Exercises</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Getting started with gawk</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>