[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
www/software/gawk .symlinks gawk.html manual/ga...
From: |
Karl Berry |
Subject: |
www/software/gawk .symlinks gawk.html manual/ga... |
Date: |
Thu, 21 Jun 2007 15:44:03 +0000 |
CVSROOT: /web/www
Module name: www
Changes by: Karl Berry <karl> 07/06/21 15:43:57
Removed files:
software/gawk : .symlinks gawk.html
software/gawk/manual: gawk.dvi.gz gawk.html gawk.html.gz
gawk.html_node.tar.gz gawk.info.tar.gz
gawk.pdf gawk.ps.gz gawk.texi.tar.gz
gawk.txt gawk.txt.gz index.html
software/gawk/manual/gawkinet: gawkinet.dvi.gz gawkinet.html
gawkinet.html.gz
gawkinet.html_node.tar.gz
gawkinet.info.tar.gz gawkinet.pdf
gawkinet.ps.gz
gawkinet.texi.tar.gz gawkinet.txt
gawkinet.txt.gz index.html
software/gawk/manual/gawkinet/html_node: Basic-Protocols.html
CGI-Lib.html
Caveats.html
Challenges.html
Comparing-Protocols.html
Datagram-Communications.html
Email.html
File-_002finet_002fraw.html
File-_002finet_002ftcp.html
File-_002finet_002fudp.html
GETURL.html
GNU-Free-Documentation-License.html
Gawk-Special-Files.html
Index.html
Interacting-Service.html
Interacting.html
Introduction.html
Links.html MAZE.html
MOBAGWHO.html
Making-Connections.html
PANIC.html
PROTBASE.html
Ports.html Preface.html
Primitive-Service.html
REMCONF.html
STATIST.html
STOXPRED.html
Setting-Up.html
Simple-Server.html
Some-Applications-and-Techniques.html
Special-File-Fields.html
Stream-Communications.html
TCP-Connecting.html
The-TCP_002fIP-Protocols.html
Troubleshooting.html
URLCHK.html
Using-Networking.html
WEBGRAB.html
Web-page.html
index.html
table_002dinet_002dcomponents.html
software/gawk/manual/html_node: ARGC-and-ARGV.html
AWKPATH-Variable.html
Acknowledgments.html
Action-Overview.html
Adding-Code.html
Additional-Configuration-Options.html
Additions.html
Advanced-Features.html
Alarm-Program.html
Amiga-Installation.html
Arithmetic-Ops.html
Array-Example.html
Array-Intro.html
Array-Sorting.html Arrays.html
Assert-Function.html
Assigning-Elements.html
Assignment-Ops.html
Assignment-Options.html
Atari-Compiling.html
Atari-Installation.html
Atari-Using.html
Auto_002dset.html
BEGIN_002fEND.html BTL.html
Basic-Concepts.html
Basic-Data-Typing.html
Basic-High-Level.html
Basic-Printf.html
BeOS-Installation.html
Bitwise-Functions.html
Boolean-Ops.html
Break-Statement.html Bugs.html
Built_002din-Variables.html
Built_002din.html
Calling-Built_002din.html
Case_002dsensitivity.html
Changing-Fields.html
Character-Lists.html
Cliff-Random-Function.html
Clones.html
Close-Files-And-Pipes.html
Command-Line-Field-Separator.html
Command-Line.html Comments.html
Compatibility-Mode.html
Computed-Regexps.html
Concatenation.html
Conditional-Exp.html
Configuration-Philosophy.html
Constant-Size.html
Constants.html
Continue-Statement.html
Contributors.html
Control-Letters.html
Conventions.html Conversion.html
Copying.html Cut-Program.html
Cygwin.html
Data-File-Management.html
Definition-Syntax.html
Delete.html
Distribution-contents.html
Do-Statement.html
Dupword-Program.html
Dynamic-Extensions.html
Dynamic-Typing.html
Egrep-Program.html
Empty-Files.html Empty.html
Escape-Sequences.html
Executable-Scripts.html
Exit-Statement.html
Explaining-gettext.html
Expression-Patterns.html
Expressions.html
Extract-Program.html
Extracting.html
Field-Separators.html
Field-Splitting-Summary.html
Fields.html File-Checking.html
Filetrans-Function.html
Floating-Point-Issues.html
For-Statement.html Foreword.html
Format-Modifiers.html
Function-Calls.html
Function-Caveats.html
Function-Example.html
Functions.html
Future-Extensions.html
GNU-Free-Documentation-License.html
GNU-Regexp-Operators.html
Gawk-Distribution.html
Gawk-I18N.html
General-Functions.html
Getline-Notes.html
Getline-Summary.html
Getline.html
Getline_002fCoprocess.html
Getline_002fFile.html
Getline_002fPipe.html
Getline_002fVariable.html
Getline_002fVariable_002fCoprocess.html
Getline_002fVariable_002fFile.html
Getline_002fVariable_002fPipe.html
Getopt-Function.html
Gettimeofday-Function.html
Getting-Started.html
Getting.html Glossary.html
Gory-Details.html
Group-Functions.html
History-Sorting.html
History.html
How-To-Contribute.html
I18N-Example.html
I18N-Functions.html
I18N-Portability.html
I18N-and-L10N.html
I_002fO-And-BEGIN_002fEND.html
I_002fO-Functions.html
Id-Program.html
If-Statement.html
Igawk-Program.html
Ignoring-Assigns.html
Increment-Ops.html Index.html
Installation.html
Internal-File-Description.html
Internal-File-Ops.html
Internals.html
Internationalization.html
Invoking-Gawk.html
Join-Function.html
Known-Bugs.html
Labels-Program.html
Language-History.html
Leftmost-Longest.html
Library-Functions.html
Library-Names.html Locales.html
Long.html Manual-History.html
Miscellaneous-Programs.html
More-Complex.html
Multi_002ddimensional.html
Multi_002dscanning.html
Multiple-Line.html Names.html
New-Ports.html
Next-Statement.html
Nextfile-Function.html
Nextfile-Statement.html
Non_002dUnix-Installation.html
Nonconstant-Fields.html
Nondecimal-Data.html
Nondecimal_002dnumbers.html
Notes.html
Numeric-Array-Subscripts.html
Numeric-Functions.html OFMT.html
Obsolete.html One_002dshot.html
Options.html
Ordinal-Functions.html
Other-Arguments.html
Other-Features.html
Other-Versions.html
Output-Separators.html
PC-Binary-Installation.html
PC-Compiling.html
PC-Dynamic.html
PC-Installation.html
PC-Using.html POSIX.html
POSIX_002fGNU.html
Passwd-Functions.html
Pattern-Overview.html
Patterns-and-Actions.html
Plain-Getline.html
Portal-Files.html
Precedence.html Preface.html
Print-Examples.html Print.html
Printf-Examples.html
Printf-Ordering.html Printf.html
Printing.html Profiling.html
Programmer-i18n.html
Quick-Installation.html
Quoting.html Ranges.html
Read-Terminal.html
Reading-Files.html Records.html
Redirection.html
Reference-to-Elements.html
Regexp-Constants.html
Regexp-Field-Splitting.html
Regexp-Operators.html
Regexp-Patterns.html
Regexp-Usage.html Regexp.html
Return-Statement.html
Rewind-Function.html
Round-Function.html
Running-Examples.html
Running-gawk.html SVR4.html
Sample-Data-Files.html
Sample-Library.html
Sample-Programs.html
Scalar-Constants.html
Scanning-an-Array.html
Simple-Sed.html
Single-Character-Fields.html
Special-Caveats.html
Special-FD.html
Special-Files.html
Special-Network.html
Special-Process.html
Split-Program.html
Statements.html
Statements_002fLines.html
String-Extraction.html
String-Functions.html
Strtonum-Function.html
Switch-Statement.html
TCP_002fIP-Networking.html
Tandem-Installation.html
Tee-Program.html
This-Manual.html
Time-Functions.html
Translate-Program.html
Translator-i18n.html
Truth-Values.html Two-Rules.html
Two_002dway-I_002fO.html
Typing-and-Comparison.html
Undocumented.html
Uninitialized-Subscripts.html
Uniq-Program.html
Unix-Installation.html
Unsupported.html
User_002ddefined.html
User_002dmodified.html
Using-BEGIN_002fEND.html
Using-Constant-Regexps.html
Using-Internal-File-Ops.html
Using-Shell-Variables.html
Using-Variables.html
V7_002fSVR3_002e1.html
VMS-Compilation.html
VMS-Installation-Details.html
VMS-Installation.html
VMS-POSIX.html VMS-Running.html
Variables.html Very-Simple.html
Wc-Program.html When.html
While-Statement.html
Word-Sorting.html index.html
table_002dassign_002dops.html
table_002dbitwise_002dops.html
table_002dchar_002dclasses.html
table_002dgensub_002descapes.html
table_002dgetline_002dvariants.html
table_002dposix_002d2001_002dsub.html
table_002drelational_002dops.html
table_002dsub_002descapes.html
table_002dsub_002dposix_002d92.html
table_002dsub_002dproposed.html
Log message:
gawk is its own savannah project
CVSWeb URLs:
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/.symlinks?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/gawk.html?cvsroot=www&r1=1.8&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.dvi.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.html?cvsroot=www&r1=1.6&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.html.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.html_node.tar.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.info.tar.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.pdf?cvsroot=www&rev=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.ps.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.texi.tar.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.txt?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawk.txt.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/index.html?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.dvi.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.html?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.html.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.html_node.tar.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.info.tar.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.pdf?cvsroot=www&rev=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.ps.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.texi.tar.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.txt?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/gawkinet.txt.gz?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/index.html?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Basic-Protocols.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/CGI-Lib.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Caveats.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Challenges.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Comparing-Protocols.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Datagram-Communications.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Email.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/File-_002finet_002fraw.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/File-_002finet_002ftcp.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/File-_002finet_002fudp.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/GETURL.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/GNU-Free-Documentation-License.html?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Gawk-Special-Files.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Index.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Interacting-Service.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Interacting.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Introduction.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Links.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/MAZE.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/MOBAGWHO.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Making-Connections.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/PANIC.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/PROTBASE.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Ports.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Preface.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Primitive-Service.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/REMCONF.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/STATIST.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/STOXPRED.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Setting-Up.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Simple-Server.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Some-Applications-and-Techniques.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Special-File-Fields.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Stream-Communications.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/TCP-Connecting.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/The-TCP_002fIP-Protocols.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Troubleshooting.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/URLCHK.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Using-Networking.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/WEBGRAB.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/Web-page.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/index.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/gawkinet/html_node/table_002dinet_002dcomponents.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/ARGC-and-ARGV.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/AWKPATH-Variable.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Acknowledgments.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Action-Overview.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Adding-Code.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Additional-Configuration-Options.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Additions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Advanced-Features.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Alarm-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Amiga-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Arithmetic-Ops.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Array-Example.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Array-Intro.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Array-Sorting.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Arrays.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Assert-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Assigning-Elements.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Assignment-Ops.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Assignment-Options.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Atari-Compiling.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Atari-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Atari-Using.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Auto_002dset.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/BEGIN_002fEND.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/BTL.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Basic-Concepts.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Basic-Data-Typing.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Basic-High-Level.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Basic-Printf.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/BeOS-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Bitwise-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Boolean-Ops.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Break-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Bugs.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Built_002din-Variables.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Built_002din.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Calling-Built_002din.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Case_002dsensitivity.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Changing-Fields.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Character-Lists.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Cliff-Random-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Clones.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Close-Files-And-Pipes.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Command-Line-Field-Separator.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Command-Line.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Comments.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Compatibility-Mode.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Computed-Regexps.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Concatenation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Conditional-Exp.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Configuration-Philosophy.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Constant-Size.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Constants.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Continue-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Contributors.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Control-Letters.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Conventions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Conversion.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Copying.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Cut-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Cygwin.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Data-File-Management.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Definition-Syntax.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Delete.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Distribution-contents.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Do-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Dupword-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Dynamic-Extensions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Dynamic-Typing.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Egrep-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Empty-Files.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Empty.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Escape-Sequences.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Executable-Scripts.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Exit-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Explaining-gettext.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Expression-Patterns.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Expressions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Extract-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Extracting.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Field-Separators.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Field-Splitting-Summary.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Fields.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/File-Checking.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Filetrans-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Floating-Point-Issues.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/For-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Foreword.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Format-Modifiers.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Function-Calls.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Function-Caveats.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Function-Example.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Future-Extensions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/GNU-Free-Documentation-License.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/GNU-Regexp-Operators.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Gawk-Distribution.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Gawk-I18N.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/General-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline-Notes.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline-Summary.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fCoprocess.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fFile.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fPipe.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fVariable.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fVariable_002fCoprocess.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fVariable_002fFile.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getline_002fVariable_002fPipe.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getopt-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Gettimeofday-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getting-Started.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Getting.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Glossary.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Gory-Details.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Group-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/History-Sorting.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/History.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/How-To-Contribute.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/I18N-Example.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/I18N-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/I18N-Portability.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/I18N-and-L10N.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/I_002fO-And-BEGIN_002fEND.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/I_002fO-Functions.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Id-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/If-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Igawk-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Ignoring-Assigns.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Increment-Ops.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Index.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Internal-File-Description.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Internal-File-Ops.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Internals.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Internationalization.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Invoking-Gawk.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Join-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Known-Bugs.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Labels-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Language-History.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Leftmost-Longest.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Library-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Library-Names.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Locales.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Long.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Manual-History.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Miscellaneous-Programs.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/More-Complex.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Multi_002ddimensional.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Multi_002dscanning.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Multiple-Line.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Names.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/New-Ports.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Next-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Nextfile-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Nextfile-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Non_002dUnix-Installation.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Nonconstant-Fields.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Nondecimal-Data.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Nondecimal_002dnumbers.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Notes.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Numeric-Array-Subscripts.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Numeric-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/OFMT.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Obsolete.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/One_002dshot.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Options.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Ordinal-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Other-Arguments.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Other-Features.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Other-Versions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Output-Separators.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/PC-Binary-Installation.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/PC-Compiling.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/PC-Dynamic.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/PC-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/PC-Using.html?cvsroot=www&r1=1.4&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/POSIX.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/POSIX_002fGNU.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Passwd-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Pattern-Overview.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Patterns-and-Actions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Plain-Getline.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Portal-Files.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Precedence.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Preface.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Print-Examples.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Print.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Printf-Examples.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Printf-Ordering.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Printf.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Printing.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Profiling.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Programmer-i18n.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Quick-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Quoting.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Ranges.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Read-Terminal.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Reading-Files.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Records.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Redirection.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Reference-to-Elements.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Regexp-Constants.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Regexp-Field-Splitting.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Regexp-Operators.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Regexp-Patterns.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Regexp-Usage.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Regexp.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Return-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Rewind-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Round-Function.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Running-Examples.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Running-gawk.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/SVR4.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Sample-Data-Files.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Sample-Library.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Sample-Programs.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Scalar-Constants.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Scanning-an-Array.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Simple-Sed.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Single-Character-Fields.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Special-Caveats.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Special-FD.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Special-Files.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Special-Network.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Special-Process.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Split-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Statements.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Statements_002fLines.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/String-Extraction.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/String-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Strtonum-Function.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Switch-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/TCP_002fIP-Networking.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Tandem-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Tee-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/This-Manual.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Time-Functions.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Translate-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Translator-i18n.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Truth-Values.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Two-Rules.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Two_002dway-I_002fO.html?cvsroot=www&r1=1.2&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Typing-and-Comparison.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Undocumented.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Uninitialized-Subscripts.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Uniq-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Unix-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Unsupported.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/User_002ddefined.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/User_002dmodified.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Using-BEGIN_002fEND.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Using-Constant-Regexps.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Using-Internal-File-Ops.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Using-Shell-Variables.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Using-Variables.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/V7_002fSVR3_002e1.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/VMS-Compilation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/VMS-Installation-Details.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/VMS-Installation.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/VMS-POSIX.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/VMS-Running.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Variables.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Very-Simple.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Wc-Program.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/When.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/While-Statement.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/Word-Sorting.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/index.html?cvsroot=www&r1=1.3&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dassign_002dops.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dbitwise_002dops.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dchar_002dclasses.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dgensub_002descapes.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dgetline_002dvariants.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dposix_002d2001_002dsub.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002drelational_002dops.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dsub_002descapes.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dsub_002dposix_002d92.html?cvsroot=www&r1=1.1&r2=0
http://web.cvs.savannah.gnu.org/viewcvs/www/software/gawk/manual/html_node/table_002dsub_002dproposed.html?cvsroot=www&r1=1.1&r2=0
Patches:
Index: .symlinks
===================================================================
RCS file: .symlinks
diff -N .symlinks
--- .symlinks 28 Feb 2001 00:18:16 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2 +0,0 @@
-gawk.html index.html
-gawk.html gawk.es.html
Index: gawk.html
===================================================================
RCS file: gawk.html
diff -N gawk.html
--- gawk.html 31 Aug 2004 22:19:54 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Gawk - GNU Project - Free Software Foundation (FSF)</TITLE>
-<LINK REV="made" HREF="mailto:address@hidden">
-<META NAME="keywords" CONTENT="gawk">
-</HEAD>
-<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#1F00FF" ALINK="#FF0000"
VLINK="#9900DD">
-<H3>Gawk</H3>
-<A HREF="/graphics/agnuhead.html"><IMG SRC="/graphics/gnu-head-sm.jpg"
-ALT=" [image of the Head of a GNU] "
-WIDTH="129" HEIGHT="122"></A>
-
-<P>
-If you are like many computer users, you would frequently like to
-make changes in various text files wherever certain patterns appear,
-or extract data from parts of certain lines while discarding the rest.
-To write a program to do this in a language such as C or Pascal is a
-time-consuming inconvenience that may take many lines of code.
-The job is easy with awk, especially the GNU implementation: gawk.
-
-<P>
-The awk utility interprets a special-purpose programming language
-that makes it possible to handle simple data-reformatting jobs with
-just a few lines of code.
-
-<P>
-The source code for GNU awk is available from
-the GNU project's
-<A HREF="http://ftp.gnu.org/gnu/gawk/">ftp server</A>.
-
-<P>The <A HREF="/software/gawk/manual/">gawk manual is available online</A>.
-
-<P> A separate manual for the special TCP/IP networking features of GNU
-awk is also <A HREF="/software/gawk/manual/gawkinet/">available online:
-gawkinet</A>.
-
-<P>
-Bug reports for gawk should be sent to
-<A HREF="mailto:address@hidden">the gawk bug report mailing list</A>.
-
-<HR>
-
-Return to <A HREF="/home.html">GNU's home page</A>.
-
-<P>
-Please send FSF & GNU inquiries & questions to
-
-<A HREF="mailto:address@hidden"><EM>address@hidden</EM></A>.
-There are also <A HREF="/home.html#ContactInfo">other ways to contact</A> the
FSF.
-
-<P>
-Please send comments on these web pages to
-<A HREF="mailto:address@hidden"><EM>address@hidden</EM></A>,
-send other questions to
-<A HREF="mailto:address@hidden"><EM>address@hidden</EM></A>.
-
-<P>
-Copyright (C) 2004 Free Software Foundation, Inc.,
-59 Temple Place - Suite 330, Boston, MA 02111, USA
-
-<P>
-Verbatim copying and distribution of this entire article is
-permitted in any medium, provided this notice is preserved.
-<P>
-Updated:
-<!-- timestamp start -->
-$Date: 2004/08/31 22:19:54 $ $Author: karl $
-<!-- timestamp end -->
-<HR>
-</BODY>
-</HTML>
Index: manual/gawk.dvi.gz
===================================================================
RCS file: manual/gawk.dvi.gz
diff -N manual/gawk.dvi.gz
Binary files /tmp/cvsHfKro9 and /dev/null differ
Index: manual/gawk.html
===================================================================
RCS file: manual/gawk.html
diff -N manual/gawk.html
--- manual/gawk.html 7 Feb 2007 02:36:51 -0000 1.6
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,26600 +0,0 @@
-<html lang="en">
-<head>
-<title>The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="top" href="#Top">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<h1 class="settitle">The GNU Awk User's Guide</h1>
-<div class="node">
-<p><hr>
-<a name="Top"></a>Next: <a rel="next" accesskey="n"
href="#Foreword">Foreword</a>,
-Up: <a rel="up" accesskey="u" href="#dir">(dir)</a>
-<br>
-</div>
-
-<h2 class="unnumbered">General Introduction</h2>
-
-<!-- Preface node should come right after the Top -->
-<!-- node, in `unnumbered' sections, then the chapter, `What is gawk'. -->
-<!-- Licensing nodes are appendices, they're not central to AWK. -->
-<p>This file documents <samp><span class="command">awk</span></samp>, a
program that you can use to select
-particular records in a file and perform operations upon them.
-
- <p>Copyright © 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003 Free Software Foundation, Inc.
- <pre class="sp">
-
-
-</pre>
-
-This is Edition 3 of <cite>GAWK: Effective AWK Programming: A User's Guide for
GNU Awk</cite>,
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
- <p>Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being “GNU General Public License”, the
Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-“GNU Free Documentation License”.
-
- <ol type=a start=1>
-<li>“A GNU Manual”
-
- <li>“You have freedom to copy and modify this GNU Manual, like GNU
-software. Copies published by the Free Software Foundation raise
-funds for GNU development.”
- </ol>
-
-<ul class="menu">
-<li><a accesskey="1" href="#Foreword">Foreword</a>:
Some nice words about this
- Web page.
-<li><a accesskey="2" href="#Preface">Preface</a>: What
this Web page is about; brief
- history and acknowledgments.
-<li><a accesskey="3" href="#Getting-Started">Getting Started</a>:
A basic introduction to using
- <samp><span
class="command">awk</span></samp>. How to run an <samp><span
class="command">awk</span></samp>
- program. Command-line syntax.
-<li><a accesskey="4" href="#Regexp">Regexp</a>: All
about matching things using regular
- expressions.
-<li><a accesskey="5" href="#Reading-Files">Reading Files</a>:
How to read files and manipulate fields.
-<li><a accesskey="6" href="#Printing">Printing</a>: How
to print using <samp><span class="command">awk</span></samp>. Describes
- the <code>print</code> and
<code>printf</code>
- statements. Also describes redirection of
- output.
-<li><a accesskey="7" href="#Expressions">Expressions</a>:
Expressions are the basic building blocks
- of statements.
-<li><a accesskey="8" href="#Patterns-and-Actions">Patterns and Actions</a>:
Overviews of patterns and actions.
-<li><a accesskey="9" href="#Arrays">Arrays</a>: The
description and use of arrays. Also
- includes array-oriented control statements.
-<li><a href="#Functions">Functions</a>: Built-in and
user-defined functions.
-<li><a href="#Internationalization">Internationalization</a>:
Getting <samp><span class="command">gawk</span></samp> to speak your
- language.
-<li><a href="#Advanced-Features">Advanced Features</a>: Stuff
for advanced users, specific to
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="#Invoking-Gawk">Invoking Gawk</a>: How to run
<samp><span class="command">gawk</span></samp>.
-<li><a href="#Library-Functions">Library Functions</a>: A
Library of <samp><span class="command">awk</span></samp> Functions.
-<li><a href="#Sample-Programs">Sample Programs</a>: Many
<samp><span class="command">awk</span></samp> programs with complete
- explanations.
-<li><a href="#Language-History">Language History</a>: The
evolution of the <samp><span class="command">awk</span></samp>
- language.
-<li><a href="#Installation">Installation</a>: Installing
<samp><span class="command">gawk</span></samp> under various
- operating systems.
-<li><a href="#Notes">Notes</a>: Notes about
<samp><span class="command">gawk</span></samp> extensions and
- possible future work.
-<li><a href="#Basic-Concepts">Basic Concepts</a>: A very
quick intoduction to programming
- concepts.
-<li><a href="#Glossary">Glossary</a>: An explanation of
some unfamiliar terms.
-<li><a href="#Copying">Copying</a>: Your right to copy
and distribute
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="#GNU-Free-Documentation-License">GNU Free Documentation
License</a>: The license for this Web page.
-<li><a href="#Index">Index</a>: Concept and Variable
Index.
-
-<li><a href="#History">History</a>: The history of
<samp><span class="command">gawk</span></samp> and
- <samp><span
class="command">awk</span></samp>.
-<li><a href="#Names">Names</a>: What name to use to
find <samp><span class="command">awk</span></samp>.
-<li><a href="#This-Manual">This Manual</a>: Using this Web
page. Includes
- sample input files that you can use.
-<li><a href="#Conventions">Conventions</a>: Typographical
Conventions.
-<li><a href="#Manual-History">Manual History</a>: Brief
history of the GNU project and this
- Web page.
-<li><a href="#How-To-Contribute">How To Contribute</a>: Helping
to save the world.
-<li><a href="#Acknowledgments">Acknowledgments</a>:
Acknowledgments.
-<li><a href="#Running-gawk">Running gawk</a>: How to run
<samp><span class="command">gawk</span></samp> programs;
- includes command-line syntax.
-<li><a href="#One_002dshot">One-shot</a>: Running a
short throwaway <samp><span class="command">awk</span></samp>
- program.
-<li><a href="#Read-Terminal">Read Terminal</a>: Using no
input files (input from terminal
- instead).
-<li><a href="#Long">Long</a>: Putting permanent
<samp><span class="command">awk</span></samp> programs in
- files.
-<li><a href="#Executable-Scripts">Executable Scripts</a>: Making
self-contained <samp><span class="command">awk</span></samp>
- programs.
-<li><a href="#Comments">Comments</a>: Adding
documentation to <samp><span class="command">gawk</span></samp>
- programs.
-<li><a href="#Quoting">Quoting</a>: More discussion of
shell quoting issues.
-<li><a href="#Sample-Data-Files">Sample Data Files</a>: Sample
data files for use in the
- <samp><span
class="command">awk</span></samp> programs illustrated in this
- Web page.
-<li><a href="#Very-Simple">Very Simple</a>: A very simple
example.
-<li><a href="#Two-Rules">Two Rules</a>: A less simple
one-line example using two
- rules.
-<li><a href="#More-Complex">More Complex</a>: A more
complex example.
-<li><a href="#Statements_002fLines">Statements/Lines</a>:
Subdividing or combining statements into
- lines.
-<li><a href="#Other-Features">Other Features</a>: Other
Features of <samp><span class="command">awk</span></samp>.
-<li><a href="#When">When</a>: When to use
<samp><span class="command">gawk</span></samp> and when to use
- other things.
-<li><a href="#Regexp-Usage">Regexp Usage</a>: How to Use
Regular Expressions.
-<li><a href="#Escape-Sequences">Escape Sequences</a>: How to
write nonprinting characters.
-<li><a href="#Regexp-Operators">Regexp Operators</a>: Regular
Expression Operators.
-<li><a href="#Character-Lists">Character Lists</a>: What can
go between `<samp><span class="samp">[...]</span></samp>'.
-<li><a href="#GNU-Regexp-Operators">GNU Regexp Operators</a>:
Operators specific to GNU software.
-<li><a href="#Case_002dsensitivity">Case-sensitivity</a>: How
to do case-insensitive matching.
-<li><a href="#Leftmost-Longest">Leftmost Longest</a>: How much
text matches.
-<li><a href="#Computed-Regexps">Computed Regexps</a>: Using
Dynamic Regexps.
-<li><a href="#Locales">Locales</a>: How the locale
affects things.
-<li><a href="#Records">Records</a>: Controlling how
data is split into records.
-<li><a href="#Fields">Fields</a>: An introduction to
fields.
-<li><a href="#Nonconstant-Fields">Nonconstant Fields</a>:
Nonconstant Field Numbers.
-<li><a href="#Changing-Fields">Changing Fields</a>: Changing
the Contents of a Field.
-<li><a href="#Field-Separators">Field Separators</a>: The field
separator and how to change it.
-<li><a href="#Regexp-Field-Splitting">Regexp Field Splitting</a>:
Using regexps as the field separator.
-<li><a href="#Single-Character-Fields">Single Character Fields</a>:
Making each character a separate field.
-<li><a href="#Command-Line-Field-Separator">Command Line Field Separator</a>:
Setting <code>FS</code> from the command-line.
-<li><a href="#Field-Splitting-Summary">Field Splitting Summary</a>:
Some final points and a summary table.
-<li><a href="#Constant-Size">Constant Size</a>: Reading
constant width data.
-<li><a href="#Multiple-Line">Multiple Line</a>: Reading
multi-line records.
-<li><a href="#Getline">Getline</a>: Reading files
under explicit program
- control using the <code>getline</code>
function.
-<li><a href="#Plain-Getline">Plain Getline</a>: Using
<code>getline</code> with no arguments.
-<li><a href="#Getline_002fVariable">Getline/Variable</a>: Using
<code>getline</code> into a variable.
-<li><a href="#Getline_002fFile">Getline/File</a>: Using
<code>getline</code> from a file.
-<li><a href="#Getline_002fVariable_002fFile">Getline/Variable/File</a>:
Using <code>getline</code> into a variable from a
- file.
-<li><a href="#Getline_002fPipe">Getline/Pipe</a>: Using
<code>getline</code> from a pipe.
-<li><a href="#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>:
Using <code>getline</code> into a variable from a
- pipe.
-<li><a href="#Getline_002fCoprocess">Getline/Coprocess</a>:
Using <code>getline</code> from a coprocess.
-<li><a
href="#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>:
Using <code>getline</code> into a variable from a
- coprocess.
-<li><a href="#Getline-Notes">Getline Notes</a>: Important
things to know about
- <code>getline</code>.
-<li><a href="#Getline-Summary">Getline Summary</a>: Summary of
<code>getline</code> Variants.
-<li><a href="#Print">Print</a>: The
<code>print</code> statement.
-<li><a href="#Print-Examples">Print Examples</a>: Simple
examples of <code>print</code> statements.
-<li><a href="#Output-Separators">Output Separators</a>: The
output separators and how to change
- them.
-<li><a href="#OFMT">OFMT</a>: Controlling Numeric
Output With
- <code>print</code>.
-<li><a href="#Printf">Printf</a>: The
<code>printf</code> statement.
-<li><a href="#Basic-Printf">Basic Printf</a>: Syntax of the
<code>printf</code> statement.
-<li><a href="#Control-Letters">Control Letters</a>:
Format-control letters.
-<li><a href="#Format-Modifiers">Format Modifiers</a>:
Format-specification modifiers.
-<li><a href="#Printf-Examples">Printf Examples</a>: Several
examples.
-<li><a href="#Redirection">Redirection</a>: How to
redirect output to multiple files
- and pipes.
-<li><a href="#Special-Files">Special Files</a>: File name
interpretation in <samp><span class="command">gawk</span></samp>.
- <samp><span
class="command">gawk</span></samp> allows access to inherited
- file descriptors.
-<li><a href="#Special-FD">Special FD</a>: Special files
for I/O.
-<li><a href="#Special-Process">Special Process</a>: Special
files for process information.
-<li><a href="#Special-Network">Special Network</a>: Special
files for network communications.
-<li><a href="#Special-Caveats">Special Caveats</a>: Things to
watch out for.
-<li><a href="#Close-Files-And-Pipes">Close Files And Pipes</a>:
Closing Input and Output Files and Pipes.
-<li><a href="#Constants">Constants</a>: String, numeric
and regexp constants.
-<li><a href="#Scalar-Constants">Scalar Constants</a>: Numeric
and string constants.
-<li><a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>:
What are octal and hex numbers.
-<li><a href="#Regexp-Constants">Regexp Constants</a>: Regular
Expression constants.
-<li><a href="#Using-Constant-Regexps">Using Constant Regexps</a>:
When and how to use a regexp constant.
-<li><a href="#Variables">Variables</a>: Variables give
names to values for later
- use.
-<li><a href="#Using-Variables">Using Variables</a>: Using
variables in your programs.
-<li><a href="#Assignment-Options">Assignment Options</a>: Setting
variables on the command-line and a
- summary of command-line syntax. This is an
- advanced method of input.
-<li><a href="#Conversion">Conversion</a>: The conversion
of strings to numbers and
- vice versa.
-<li><a href="#Arithmetic-Ops">Arithmetic Ops</a>: Arithmetic
operations (`<samp><span class="samp">+</span></samp>', `<samp><span
class="samp">-</span></samp>',
- etc.)
-<li><a href="#Concatenation">Concatenation</a>:
Concatenating strings.
-<li><a href="#Assignment-Ops">Assignment Ops</a>: Changing
the value of a variable or a
- field.
-<li><a href="#Increment-Ops">Increment Ops</a>: Incrementing
the numeric value of a
- variable.
-<li><a href="#Truth-Values">Truth Values</a>: What is
``true'' and what is ``false''.
-<li><a href="#Typing-and-Comparison">Typing and Comparison</a>: How
variables acquire types and how this
- affects comparison of numbers and strings
- with `<samp><span
class="samp"><</span></samp>', etc.
-<li><a href="#Boolean-Ops">Boolean Ops</a>: Combining
comparison expressions using
- boolean operators `<samp><span
class="samp">||</span></samp>' (``or''),
- `<samp><span
class="samp">&&</span></samp>' (``and'') and `<samp><span
class="samp">!</span></samp>' (``not'').
-<li><a href="#Conditional-Exp">Conditional Exp</a>:
Conditional expressions select between two
- subexpressions under control of a third
- subexpression.
-<li><a href="#Function-Calls">Function Calls</a>: A function
call is an expression.
-<li><a href="#Precedence">Precedence</a>: How various
operators nest.
-<li><a href="#Pattern-Overview">Pattern Overview</a>: What goes
into a pattern.
-<li><a href="#Regexp-Patterns">Regexp Patterns</a>: Using
regexps as patterns.
-<li><a href="#Expression-Patterns">Expression Patterns</a>: Any
expression can be used as a pattern.
-<li><a href="#Ranges">Ranges</a>: Pairs of patterns
specify record ranges.
-<li><a href="#BEGIN_002fEND">BEGIN/END</a>: Specifying
initialization and cleanup
- rules.
-<li><a href="#Using-BEGIN_002fEND">Using BEGIN/END</a>: How
and why to use BEGIN/END rules.
-<li><a href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a>:
I/O issues in BEGIN/END rules.
-<li><a href="#Empty">Empty</a>: The empty pattern,
which matches every
- record.
-<li><a href="#Using-Shell-Variables">Using Shell Variables</a>: How
to use shell variables with
- <samp><span
class="command">awk</span></samp>.
-<li><a href="#Action-Overview">Action Overview</a>: What goes
into an action.
-<li><a href="#Statements">Statements</a>: Describes the
various control statements in
- detail.
-<li><a href="#If-Statement">If Statement</a>: Conditionally
execute some <samp><span class="command">awk</span></samp>
- statements.
-<li><a href="#While-Statement">While Statement</a>: Loop until
some condition is satisfied.
-<li><a href="#Do-Statement">Do Statement</a>: Do specified
action while looping until
- some condition is satisfied.
-<li><a href="#For-Statement">For Statement</a>: Another
looping statement, that provides
- initialization and increment clauses.
-<li><a href="#Switch-Statement">Switch Statement</a>:
Switch/case evaluation for conditional
- execution of statements based on a value.
-<li><a href="#Break-Statement">Break Statement</a>:
Immediately exit the innermost enclosing
- loop.
-<li><a href="#Continue-Statement">Continue Statement</a>: Skip to
the end of the innermost enclosing
- loop.
-<li><a href="#Next-Statement">Next Statement</a>: Stop
processing the current input record.
-<li><a href="#Nextfile-Statement">Nextfile Statement</a>: Stop
processing the current file.
-<li><a href="#Exit-Statement">Exit Statement</a>: Stop
execution of <samp><span class="command">awk</span></samp>.
-<li><a href="#Built_002din-Variables">Built-in Variables</a>:
Summarizes the built-in variables.
-<li><a href="#User_002dmodified">User-modified</a>: Built-in
variables that you change to
- control <samp><span
class="command">awk</span></samp>.
-<li><a href="#Auto_002dset">Auto-set</a>: Built-in
variables where <samp><span class="command">awk</span></samp>
- gives you information.
-<li><a href="#ARGC-and-ARGV">ARGC and ARGV</a>: Ways to use
<code>ARGC</code> and <code>ARGV</code>.
-<li><a href="#Array-Intro">Array Intro</a>: Introduction
to Arrays
-<li><a href="#Reference-to-Elements">Reference to Elements</a>: How
to examine one element of an array.
-<li><a href="#Assigning-Elements">Assigning Elements</a>: How to
change an element of an array.
-<li><a href="#Array-Example">Array Example</a>: Basic
Example of an Array
-<li><a href="#Scanning-an-Array">Scanning an Array</a>: A
variation of the <code>for</code> statement. It
- loops through the indices of an array's
- existing elements.
-<li><a href="#Delete">Delete</a>: The
<code>delete</code> statement removes an
- element from an array.
-<li><a href="#Numeric-Array-Subscripts">Numeric Array Subscripts</a>:
How to use numbers as subscripts in
- <samp><span
class="command">awk</span></samp>.
-<li><a href="#Uninitialized-Subscripts">Uninitialized Subscripts</a>:
Using Uninitialized variables as
- subscripts.
-<li><a href="#Multi_002ddimensional">Multi-dimensional</a>:
Emulating multidimensional arrays in
- <samp><span
class="command">awk</span></samp>.
-<li><a href="#Multi_002dscanning">Multi-scanning</a>:
Scanning multidimensional arrays.
-<li><a href="#Array-Sorting">Array Sorting</a>: Sorting
array values and indices.
-<li><a href="#Built_002din">Built-in</a>: Summarizes
the built-in functions.
-<li><a href="#Calling-Built_002din">Calling Built-in</a>: How
to call built-in functions.
-<li><a href="#Numeric-Functions">Numeric Functions</a>:
Functions that work with numbers, including
- <code>int</code>, <code>sin</code> and
<code>rand</code>.
-<li><a href="#String-Functions">String Functions</a>: Functions
for string manipulation, such as
- <code>split</code>, <code>match</code> and
- <code>sprintf</code>.
-<li><a href="#Gory-Details">Gory Details</a>: More than you
want to know about `<samp><span class="samp">\</span></samp>'
- and `<samp><span
class="samp">&</span></samp>' with <code>sub</code>, <code>gsub</code>,
- and <code>gensub</code>.
-<li><a href="#I_002fO-Functions">I/O Functions</a>:
Functions for files and shell commands.
-<li><a href="#Time-Functions">Time Functions</a>: Functions
for dealing with timestamps.
-<li><a href="#Bitwise-Functions">Bitwise Functions</a>:
Functions for bitwise operations.
-<li><a href="#I18N-Functions">I18N Functions</a>: Functions
for string translation.
-<li><a href="#User_002ddefined">User-defined</a>: Describes
User-defined functions in detail.
-<li><a href="#Definition-Syntax">Definition Syntax</a>: How to
write definitions and what they
- mean.
-<li><a href="#Function-Example">Function Example</a>: An
example function definition and what it
- does.
-<li><a href="#Function-Caveats">Function Caveats</a>: Things to
watch out for.
-<li><a href="#Return-Statement">Return Statement</a>:
Specifying the value a function returns.
-<li><a href="#Dynamic-Typing">Dynamic Typing</a>: How
variable types can change at runtime.
-<li><a href="#I18N-and-L10N">I18N and L10N</a>:
Internationalization and Localization.
-<li><a href="#Explaining-gettext">Explaining gettext</a>: How GNU
<code>gettext</code> works.
-<li><a href="#Programmer-i18n">Programmer i18n</a>: Features
for the programmer.
-<li><a href="#Translator-i18n">Translator i18n</a>: Features
for the translator.
-<li><a href="#String-Extraction">String Extraction</a>:
Extracting marked strings.
-<li><a href="#Printf-Ordering">Printf Ordering</a>:
Rearranging <code>printf</code> arguments.
-<li><a href="#I18N-Portability">I18N Portability</a>:
<samp><span class="command">awk</span></samp>-level portability issues.
-<li><a href="#I18N-Example">I18N Example</a>: A simple i18n
example.
-<li><a href="#Gawk-I18N">Gawk I18N</a>: <samp><span
class="command">gawk</span></samp> is also internationalized.
-<li><a href="#Nondecimal-Data">Nondecimal Data</a>: Allowing
nondecimal input data.
-<li><a href="#Two_002dway-I_002fO">Two-way I/O</a>:
Two-way communications with another
- process.
-<li><a href="#TCP_002fIP-Networking">TCP/IP Networking</a>:
Using <samp><span class="command">gawk</span></samp> for network
- programming.
-<li><a href="#Portal-Files">Portal Files</a>: Using
<samp><span class="command">gawk</span></samp> with BSD portals.
-<li><a href="#Profiling">Profiling</a>: Profiling your
<samp><span class="command">awk</span></samp> programs.
-<li><a href="#Command-Line">Command Line</a>: How to run
<samp><span class="command">awk</span></samp>.
-<li><a href="#Options">Options</a>: Command-line
options and their meanings.
-<li><a href="#Other-Arguments">Other Arguments</a>: Input file
names and variable assignments.
-<li><a href="#AWKPATH-Variable">AWKPATH Variable</a>: Searching
directories for <samp><span class="command">awk</span></samp>
- programs.
-<li><a href="#Obsolete">Obsolete</a>: Obsolete Options
and/or features.
-<li><a href="#Undocumented">Undocumented</a>: Undocumented
Options and Features.
-<li><a href="#Known-Bugs">Known Bugs</a>: Known Bugs in
<samp><span class="command">gawk</span></samp>.
-<li><a href="#Library-Names">Library Names</a>: How to best
name private global variables
- in library functions.
-<li><a href="#General-Functions">General Functions</a>:
Functions that are of general use.
-<li><a href="#Nextfile-Function">Nextfile Function</a>: Two
implementations of a <code>nextfile</code>
- function.
-<li><a href="#Assert-Function">Assert Function</a>: A function
for assertions in <samp><span class="command">awk</span></samp>
- programs.
-<li><a href="#Round-Function">Round Function</a>: A function
for rounding if <code>sprintf</code>
- does not do it correctly.
-<li><a href="#Cliff-Random-Function">Cliff Random Function</a>: The
Cliff Random Number Generator.
-<li><a href="#Ordinal-Functions">Ordinal Functions</a>:
Functions for using characters as numbers
- and vice versa.
-<li><a href="#Join-Function">Join Function</a>: A function
to join an array into a string.
-<li><a href="#Gettimeofday-Function">Gettimeofday Function</a>: A
function to get formatted times.
-<li><a href="#Data-File-Management">Data File Management</a>:
Functions for managing command-line data
- files.
-<li><a href="#Filetrans-Function">Filetrans Function</a>: A
function for handling data file
- transitions.
-<li><a href="#Rewind-Function">Rewind Function</a>: A function
for rereading the current file.
-<li><a href="#File-Checking">File Checking</a>: Checking
that data files are readable.
-<li><a href="#Empty-Files">Empty Files</a>: Checking for
zero-length files.
-<li><a href="#Ignoring-Assigns">Ignoring Assigns</a>: Treating
assignments as file names.
-<li><a href="#Getopt-Function">Getopt Function</a>: A function
for processing command-line
- arguments.
-<li><a href="#Passwd-Functions">Passwd Functions</a>: Functions
for getting user information.
-<li><a href="#Group-Functions">Group Functions</a>: Functions
for getting group information.
-<li><a href="#Running-Examples">Running Examples</a>: How to
run these examples.
-<li><a href="#Clones">Clones</a>: Clones of common
utilities.
-<li><a href="#Cut-Program">Cut Program</a>: The
<samp><span class="command">cut</span></samp> utility.
-<li><a href="#Egrep-Program">Egrep Program</a>: The
<samp><span class="command">egrep</span></samp> utility.
-<li><a href="#Id-Program">Id Program</a>: The <samp><span
class="command">id</span></samp> utility.
-<li><a href="#Split-Program">Split Program</a>: The
<samp><span class="command">split</span></samp> utility.
-<li><a href="#Tee-Program">Tee Program</a>: The
<samp><span class="command">tee</span></samp> utility.
-<li><a href="#Uniq-Program">Uniq Program</a>: The
<samp><span class="command">uniq</span></samp> utility.
-<li><a href="#Wc-Program">Wc Program</a>: The <samp><span
class="command">wc</span></samp> utility.
-<li><a href="#Miscellaneous-Programs">Miscellaneous Programs</a>:
Some interesting <samp><span class="command">awk</span></samp> programs.
-<li><a href="#Dupword-Program">Dupword Program</a>: Finding
duplicated words in a document.
-<li><a href="#Alarm-Program">Alarm Program</a>: An alarm
clock.
-<li><a href="#Translate-Program">Translate Program</a>: A
program similar to the <samp><span class="command">tr</span></samp>
- utility.
-<li><a href="#Labels-Program">Labels Program</a>: Printing
mailing labels.
-<li><a href="#Word-Sorting">Word Sorting</a>: A program to
produce a word usage count.
-<li><a href="#History-Sorting">History Sorting</a>:
Eliminating duplicate entries from a
- history file.
-<li><a href="#Extract-Program">Extract Program</a>: Pulling
out programs from Texinfo source
- files.
-<li><a href="#Simple-Sed">Simple Sed</a>: A Simple Stream
Editor.
-<li><a href="#Igawk-Program">Igawk Program</a>: A wrapper
for <samp><span class="command">awk</span></samp> that includes
- files.
-<li><a href="#V7_002fSVR3_002e1">V7/SVR3.1</a>: The
major changes between V7 and System V
- Release 3.1.
-<li><a href="#SVR4">SVR4</a>: Minor changes between
System V Releases 3.1
- and 4.
-<li><a href="#POSIX">POSIX</a>: New features from
the POSIX standard.
-<li><a href="#BTL">BTL</a>: New features from the
Bell Laboratories
- version of <samp><span
class="command">awk</span></samp>.
-<li><a href="#POSIX_002fGNU">POSIX/GNU</a>: The
extensions in <samp><span class="command">gawk</span></samp> not in
- POSIX <samp><span
class="command">awk</span></samp>.
-<li><a href="#Contributors">Contributors</a>: The major
contributors to <samp><span class="command">gawk</span></samp>.
-<li><a href="#Gawk-Distribution">Gawk Distribution</a>: What is
in the <samp><span class="command">gawk</span></samp> distribution.
-<li><a href="#Getting">Getting</a>: How to get the
distribution.
-<li><a href="#Extracting">Extracting</a>: How to extract
the distribution.
-<li><a href="#Distribution-contents">Distribution contents</a>: What
is in the distribution.
-<li><a href="#Unix-Installation">Unix Installation</a>:
Installing <samp><span class="command">gawk</span></samp> under various
- versions of Unix.
-<li><a href="#Quick-Installation">Quick Installation</a>:
Compiling <samp><span class="command">gawk</span></samp> under Unix.
-<li><a href="#Additional-Configuration-Options">Additional Configuration
Options</a>: Other compile-time options.
-<li><a href="#Configuration-Philosophy">Configuration Philosophy</a>:
How it's all supposed to work.
-<li><a href="#Non_002dUnix-Installation">Non-Unix Installation</a>:
Installation on Other Operating Systems.
-<li><a href="#Amiga-Installation">Amiga Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on an Amiga.
-<li><a href="#BeOS-Installation">BeOS Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on BeOS.
-<li><a href="#PC-Installation">PC Installation</a>: Installing
and Compiling <samp><span class="command">gawk</span></samp> on
- MS-DOS and OS/2.
-<li><a href="#PC-Binary-Installation">PC Binary Installation</a>:
Installing a prepared distribution.
-<li><a href="#PC-Compiling">PC Compiling</a>: Compiling
<samp><span class="command">gawk</span></samp> for MS-DOS, Windows32,
- and OS/2.
-<li><a href="#PC-Using">PC Using</a>: Running
<samp><span class="command">gawk</span></samp> on MS-DOS, Windows32 and
- OS/2.
-<li><a href="#PC-Dynamic">PC Dynamic</a>: Compiling
<samp><span class="command">gawk</span></samp> for dynamic
- libraries.
-<li><a href="#Cygwin">Cygwin</a>: Building and
running <samp><span class="command">gawk</span></samp> for
- Cygwin.
-<li><a href="#VMS-Installation">VMS Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on VMS.
-<li><a href="#VMS-Compilation">VMS Compilation</a>: How to
compile <samp><span class="command">gawk</span></samp> under VMS.
-<li><a href="#VMS-Installation-Details">VMS Installation Details</a>:
How to install <samp><span class="command">gawk</span></samp> under VMS.
-<li><a href="#VMS-Running">VMS Running</a>: How to run
<samp><span class="command">gawk</span></samp> under VMS.
-<li><a href="#VMS-POSIX">VMS POSIX</a>: Alternate
instructions for VMS POSIX.
-<li><a href="#Unsupported">Unsupported</a>: Systems whose
ports are no longer
- supported.
-<li><a href="#Atari-Installation">Atari Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on the Atari ST.
-<li><a href="#Atari-Compiling">Atari Compiling</a>: Compiling
<samp><span class="command">gawk</span></samp> on Atari.
-<li><a href="#Atari-Using">Atari Using</a>: Running
<samp><span class="command">gawk</span></samp> on Atari.
-<li><a href="#Tandem-Installation">Tandem Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on a Tandem.
-<li><a href="#Bugs">Bugs</a>: Reporting Problems
and Bugs.
-<li><a href="#Other-Versions">Other Versions</a>: Other
freely available <samp><span class="command">awk</span></samp>
- implementations.
-<li><a href="#Compatibility-Mode">Compatibility Mode</a>: How to
disable certain <samp><span class="command">gawk</span></samp>
- extensions.
-<li><a href="#Additions">Additions</a>: Making Additions
To <samp><span class="command">gawk</span></samp>.
-<li><a href="#Adding-Code">Adding Code</a>: Adding code to
the main body of
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="#New-Ports">New Ports</a>: Porting
<samp><span class="command">gawk</span></samp> to a new operating
- system.
-<li><a href="#Dynamic-Extensions">Dynamic Extensions</a>: Adding
new built-in functions to
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="#Internals">Internals</a>: A brief look at
some <samp><span class="command">gawk</span></samp>
- internals.
-<li><a href="#Sample-Library">Sample Library</a>: A example
of new functions.
-<li><a href="#Internal-File-Description">Internal File Description</a>:
What the new functions will do.
-<li><a href="#Internal-File-Ops">Internal File Ops</a>: The code
for internal file operations.
-<li><a href="#Using-Internal-File-Ops">Using Internal File Ops</a>:
How to use an external extension.
-<li><a href="#Future-Extensions">Future Extensions</a>: New
features that may be implemented one
- day.
-<li><a href="#Basic-High-Level">Basic High Level</a>: The high
level view.
-<li><a href="#Basic-Data-Typing">Basic Data Typing</a>: A very
quick intro to data types.
-<li><a href="#Floating-Point-Issues">Floating Point Issues</a>:
Stuff to know about floating-point numbers.
-</ul>
-
-<!-- dedication for Info file -->
- <div class="shortcontents">
-<h2>Short Contents</h2>
-<ul>
-<li><a href="#toc_Top">General Introduction</a></li>
-<li><a href="#toc_Foreword">Foreword</a></li>
-<li><a href="#toc_Preface">Preface</a></li>
-<li><a href="#toc_Getting-Started">1 Getting Started with <samp><span
class="command">awk</span></samp></a></li>
-<li><a href="#toc_Regexp">2 Regular Expressions</a></li>
-<li><a href="#toc_Reading-Files">3 Reading Input Files</a></li>
-<li><a href="#toc_Printing">4 Printing Output</a></li>
-<li><a href="#toc_Expressions">5 Expressions</a></li>
-<li><a href="#toc_Patterns-and-Actions">6 Patterns, Actions, and
Variables</a></li>
-<li><a href="#toc_Arrays">7 Arrays in <samp><span
class="command">awk</span></samp></a></li>
-<li><a href="#toc_Functions">8 Functions</a></li>
-<li><a href="#toc_Internationalization">9 Internationalization with
<samp><span class="command">gawk</span></samp></a></li>
-<li><a href="#toc_Advanced-Features">10 Advanced Features of <samp><span
class="command">gawk</span></samp></a></li>
-<li><a href="#toc_Invoking-Gawk">11 Running <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></a></li>
-<li><a href="#toc_Library-Functions">12 A Library of <samp><span
class="command">awk</span></samp> Functions</a></li>
-<li><a href="#toc_Sample-Programs">13 Practical <samp><span
class="command">awk</span></samp> Programs</a></li>
-<li><a href="#toc_Language-History">Appendix A The Evolution of the
<samp><span class="command">awk</span></samp> Language</a></li>
-<li><a href="#toc_Installation">Appendix B Installing <samp><span
class="command">gawk</span></samp></a></li>
-<li><a href="#toc_Notes">Appendix C Implementation Notes</a></li>
-<li><a href="#toc_Basic-Concepts">Appendix D Basic Programming
Concepts</a></li>
-<li><a href="#toc_Glossary">Glossary</a></li>
-<li><a href="#toc_Copying">GNU General Public License</a></li>
-<li><a href="#toc_GNU-Free-Documentation-License">GNU Free Documentation
License</a></li>
-<li><a href="#toc_Index">Index</a></li>
-</ul>
-</div>
-
- <div class="contents">
-<h2>Table of Contents</h2>
-<ul>
-<li><a name="toc_Top" href="#Top">General Introduction</a>
-<li><a name="toc_Foreword" href="#Foreword">Foreword</a>
-<li><a name="toc_Preface" href="#Preface">Preface</a>
-<ul>
-<li><a href="#History">History of <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></a>
-<li><a href="#Names">A Rose by Any Other Name</a>
-<li><a href="#This-Manual">Using This Book</a>
-<li><a href="#Conventions">Typographical Conventions</a>
-<li><a href="#Manual-History">The GNU Project and This Book</a>
-<li><a href="#How-To-Contribute">How to Contribute</a>
-<li><a href="#Acknowledgments">Acknowledgments</a>
-</li></ul>
-<li><a name="toc_Getting-Started" href="#Getting-Started">1 Getting Started
with <samp><span class="command">awk</span></samp></a>
-<ul>
-<li><a href="#Running-gawk">1.1 How to Run <samp><span
class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="#One_002dshot">1.1.1 One-Shot Throwaway <samp><span
class="command">awk</span></samp> Programs</a>
-<li><a href="#Read-Terminal">1.1.2 Running <samp><span
class="command">awk</span></samp> Without Input Files</a>
-<li><a href="#Long">1.1.3 Running Long Programs</a>
-<li><a href="#Executable-Scripts">1.1.4 Executable <samp><span
class="command">awk</span></samp> Programs</a>
-<li><a href="#Comments">1.1.5 Comments in <samp><span
class="command">awk</span></samp> Programs</a>
-<li><a href="#Quoting">1.1.6 Shell-Quoting Issues</a>
-</li></ul>
-<li><a href="#Sample-Data-Files">1.2 Data Files for the Examples</a>
-<li><a href="#Very-Simple">1.3 Some Simple Examples</a>
-<li><a href="#Two-Rules">1.4 An Example with Two Rules</a>
-<li><a href="#More-Complex">1.5 A More Complex Example</a>
-<li><a href="#Statements_002fLines">1.6 <samp><span
class="command">awk</span></samp> Statements Versus Lines</a>
-<li><a href="#Other-Features">1.7 Other Features of <samp><span
class="command">awk</span></samp></a>
-<li><a href="#When">1.8 When to Use <samp><span
class="command">awk</span></samp></a>
-</li></ul>
-<li><a name="toc_Regexp" href="#Regexp">2 Regular Expressions</a>
-<ul>
-<li><a href="#Regexp-Usage">2.1 How to Use Regular Expressions</a>
-<li><a href="#Escape-Sequences">2.2 Escape Sequences</a>
-<li><a href="#Regexp-Operators">2.3 Regular Expression Operators</a>
-<li><a href="#Character-Lists">2.4 Using Character Lists</a>
-<li><a href="#GNU-Regexp-Operators">2.5 <samp><span
class="command">gawk</span></samp>-Specific Regexp Operators</a>
-<li><a href="#Case_002dsensitivity">2.6 Case Sensitivity in Matching</a>
-<li><a href="#Leftmost-Longest">2.7 How Much Text Matches?</a>
-<li><a href="#Computed-Regexps">2.8 Using Dynamic Regexps</a>
-<li><a href="#Locales">2.9 Where You Are Makes A Difference</a>
-</li></ul>
-<li><a name="toc_Reading-Files" href="#Reading-Files">3 Reading Input Files</a>
-<ul>
-<li><a href="#Records">3.1 How Input Is Split into Records</a>
-<li><a href="#Fields">3.2 Examining Fields</a>
-<li><a href="#Nonconstant-Fields">3.3 Nonconstant Field Numbers</a>
-<li><a href="#Changing-Fields">3.4 Changing the Contents of a Field</a>
-<li><a href="#Field-Separators">3.5 Specifying How Fields Are Separated</a>
-<ul>
-<li><a href="#Regexp-Field-Splitting">3.5.1 Using Regular Expressions to
Separate Fields</a>
-<li><a href="#Single-Character-Fields">3.5.2 Making Each Character a Separate
Field</a>
-<li><a href="#Command-Line-Field-Separator">3.5.3 Setting <code>FS</code> from
the Command Line</a>
-<li><a href="#Field-Splitting-Summary">3.5.4 Field-Splitting Summary</a>
-</li></ul>
-<li><a href="#Constant-Size">3.6 Reading Fixed-Width Data</a>
-<li><a href="#Multiple-Line">3.7 Multiple-Line Records</a>
-<li><a href="#Getline">3.8 Explicit Input with <code>getline</code></a>
-<ul>
-<li><a href="#Plain-Getline">3.8.1 Using <code>getline</code> with No
Arguments</a>
-<li><a href="#Getline_002fVariable">3.8.2 Using <code>getline</code> into a
Variable</a>
-<li><a href="#Getline_002fFile">3.8.3 Using <code>getline</code> from a
File</a>
-<li><a href="#Getline_002fVariable_002fFile">3.8.4 Using <code>getline</code>
into a Variable from a File</a>
-<li><a href="#Getline_002fPipe">3.8.5 Using <code>getline</code> from a
Pipe</a>
-<li><a href="#Getline_002fVariable_002fPipe">3.8.6 Using <code>getline</code>
into a Variable from a Pipe</a>
-<li><a href="#Getline_002fCoprocess">3.8.7 Using <code>getline</code> from a
Coprocess</a>
-<li><a href="#Getline_002fVariable_002fCoprocess">3.8.8 Using
<code>getline</code> into a Variable from a Coprocess</a>
-<li><a href="#Getline-Notes">3.8.9 Points to Remember About
<code>getline</code></a>
-<li><a href="#Getline-Summary">3.8.10 Summary of <code>getline</code>
Variants</a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Printing" href="#Printing">4 Printing Output</a>
-<ul>
-<li><a href="#Print">4.1 The <code>print</code> Statement</a>
-<li><a href="#Print-Examples">4.2 Examples of <code>print</code> Statements</a>
-<li><a href="#Output-Separators">4.3 Output Separators</a>
-<li><a href="#OFMT">4.4 Controlling Numeric Output with <code>print</code></a>
-<li><a href="#Printf">4.5 Using <code>printf</code> Statements for Fancier
Printing</a>
-<ul>
-<li><a href="#Basic-Printf">4.5.1 Introduction to the <code>printf</code>
Statement</a>
-<li><a href="#Control-Letters">4.5.2 Format-Control Letters</a>
-<li><a href="#Format-Modifiers">4.5.3 Modifiers for <code>printf</code>
Formats</a>
-<li><a href="#Printf-Examples">4.5.4 Examples Using <code>printf</code></a>
-</li></ul>
-<li><a href="#Redirection">4.6 Redirecting Output of <code>print</code> and
<code>printf</code></a>
-<li><a href="#Special-Files">4.7 Special File Names in <samp><span
class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Special-FD">4.7.1 Special Files for Standard Descriptors</a>
-<li><a href="#Special-Process">4.7.2 Special Files for Process-Related
Information</a>
-<li><a href="#Special-Network">4.7.3 Special Files for Network
Communications</a>
-<li><a href="#Special-Caveats">4.7.4 Special File Name Caveats</a>
-</li></ul>
-<li><a href="#Close-Files-And-Pipes">4.8 Closing Input and Output
Redirections</a>
-</li></ul>
-<li><a name="toc_Expressions" href="#Expressions">5 Expressions</a>
-<ul>
-<li><a href="#Constants">5.1 Constant Expressions</a>
-<ul>
-<li><a href="#Scalar-Constants">5.1.1 Numeric and String Constants</a>
-<li><a href="#Nondecimal_002dnumbers">5.1.2 Octal and Hexadecimal Numbers</a>
-<li><a href="#Regexp-Constants">5.1.3 Regular Expression Constants</a>
-</li></ul>
-<li><a href="#Using-Constant-Regexps">5.2 Using Regular Expression
Constants</a>
-<li><a href="#Variables">5.3 Variables</a>
-<ul>
-<li><a href="#Using-Variables">5.3.1 Using Variables in a Program</a>
-<li><a href="#Assignment-Options">5.3.2 Assigning Variables on the Command
Line</a>
-</li></ul>
-<li><a href="#Conversion">5.4 Conversion of Strings and Numbers</a>
-<li><a href="#Arithmetic-Ops">5.5 Arithmetic Operators</a>
-<li><a href="#Concatenation">5.6 String Concatenation</a>
-<li><a href="#Assignment-Ops">5.7 Assignment Expressions</a>
-<li><a href="#Increment-Ops">5.8 Increment and Decrement Operators</a>
-<li><a href="#Truth-Values">5.9 True and False in <samp><span
class="command">awk</span></samp></a>
-<li><a href="#Typing-and-Comparison">5.10 Variable Typing and Comparison
Expressions</a>
-<li><a href="#Boolean-Ops">5.11 Boolean Expressions</a>
-<li><a href="#Conditional-Exp">5.12 Conditional Expressions</a>
-<li><a href="#Function-Calls">5.13 Function Calls</a>
-<li><a href="#Precedence">5.14 Operator Precedence (How Operators Nest)</a>
-</li></ul>
-<li><a name="toc_Patterns-and-Actions" href="#Patterns-and-Actions">6
Patterns, Actions, and Variables</a>
-<ul>
-<li><a href="#Pattern-Overview">6.1 Pattern Elements</a>
-<ul>
-<li><a href="#Regexp-Patterns">6.1.1 Regular Expressions as Patterns</a>
-<li><a href="#Expression-Patterns">6.1.2 Expressions as Patterns</a>
-<li><a href="#Ranges">6.1.3 Specifying Record Ranges with Patterns</a>
-<li><a href="#BEGIN_002fEND">6.1.4 The <code>BEGIN</code> and <code>END</code>
Special Patterns</a>
-<ul>
-<li><a href="#Using-BEGIN_002fEND">6.1.4.1 Startup and Cleanup Actions</a>
-<li><a href="#I_002fO-And-BEGIN_002fEND">6.1.4.2 Input/Output from
<code>BEGIN</code> and <code>END</code> Rules</a>
-</li></ul>
-<li><a href="#Empty">6.1.5 The Empty Pattern</a>
-</li></ul>
-<li><a href="#Using-Shell-Variables">6.2 Using Shell Variables in Programs</a>
-<li><a href="#Action-Overview">6.3 Actions</a>
-<li><a href="#Statements">6.4 Control Statements in Actions</a>
-<ul>
-<li><a href="#If-Statement">6.4.1 The <code>if</code>-<code>else</code>
Statement</a>
-<li><a href="#While-Statement">6.4.2 The <code>while</code> Statement</a>
-<li><a href="#Do-Statement">6.4.3 The <code>do</code>-<code>while</code>
Statement</a>
-<li><a href="#For-Statement">6.4.4 The <code>for</code> Statement</a>
-<li><a href="#Switch-Statement">6.4.5 The <code>switch</code> Statement</a>
-<li><a href="#Break-Statement">6.4.6 The <code>break</code> Statement</a>
-<li><a href="#Continue-Statement">6.4.7 The <code>continue</code> Statement</a>
-<li><a href="#Next-Statement">6.4.8 The <code>next</code> Statement</a>
-<li><a href="#Nextfile-Statement">6.4.9 Using <samp><span
class="command">gawk</span></samp>'s <code>nextfile</code> Statement</a>
-<li><a href="#Exit-Statement">6.4.10 The <code>exit</code> Statement</a>
-</li></ul>
-<li><a href="#Built_002din-Variables">6.5 Built-in Variables</a>
-<ul>
-<li><a href="#User_002dmodified">6.5.1 Built-in Variables That Control
<samp><span class="command">awk</span></samp></a>
-<li><a href="#Auto_002dset">6.5.2 Built-in Variables That Convey
Information</a>
-<li><a href="#ARGC-and-ARGV">6.5.3 Using <code>ARGC</code> and
<code>ARGV</code></a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Arrays" href="#Arrays">7 Arrays in <samp><span
class="command">awk</span></samp></a>
-<ul>
-<li><a href="#Array-Intro">7.1 Introduction to Arrays</a>
-<li><a href="#Reference-to-Elements">7.2 Referring to an Array Element</a>
-<li><a href="#Assigning-Elements">7.3 Assigning Array Elements</a>
-<li><a href="#Array-Example">7.4 Basic Array Example</a>
-<li><a href="#Scanning-an-Array">7.5 Scanning All Elements of an Array</a>
-<li><a href="#Delete">7.6 The <code>delete</code> Statement</a>
-<li><a href="#Numeric-Array-Subscripts">7.7 Using Numbers to Subscript
Arrays</a>
-<li><a href="#Uninitialized-Subscripts">7.8 Using Uninitialized Variables as
Subscripts</a>
-<li><a href="#Multi_002ddimensional">7.9 Multidimensional Arrays</a>
-<li><a href="#Multi_002dscanning">7.10 Scanning Multidimensional Arrays</a>
-<li><a href="#Array-Sorting">7.11 Sorting Array Values and Indices with
<samp><span class="command">gawk</span></samp></a>
-</li></ul>
-<li><a name="toc_Functions" href="#Functions">8 Functions</a>
-<ul>
-<li><a href="#Built_002din">8.1 Built-in Functions</a>
-<ul>
-<li><a href="#Calling-Built_002din">8.1.1 Calling Built-in Functions</a>
-<li><a href="#Numeric-Functions">8.1.2 Numeric Functions</a>
-<li><a href="#String-Functions">8.1.3 String-Manipulation Functions</a>
-<ul>
-<li><a href="#Gory-Details">8.1.3.1 More About `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' with <code>sub</code>, <code>gsub</code>, and
<code>gensub</code></a>
-</li></ul>
-<li><a href="#I_002fO-Functions">8.1.4 Input/Output Functions</a>
-<li><a href="#Time-Functions">8.1.5 Using <samp><span
class="command">gawk</span></samp>'s Timestamp Functions</a>
-<li><a href="#Bitwise-Functions">8.1.6 Bit-Manipulation Functions of
<samp><span class="command">gawk</span></samp></a>
-<li><a href="#I18N-Functions">8.1.7 Using <samp><span
class="command">gawk</span></samp>'s String-Translation Functions</a>
-</li></ul>
-<li><a href="#User_002ddefined">8.2 User-Defined Functions</a>
-<ul>
-<li><a href="#Definition-Syntax">8.2.1 Function Definition Syntax</a>
-<li><a href="#Function-Example">8.2.2 Function Definition Examples</a>
-<li><a href="#Function-Caveats">8.2.3 Calling User-Defined Functions</a>
-<li><a href="#Return-Statement">8.2.4 The <code>return</code> Statement</a>
-<li><a href="#Dynamic-Typing">8.2.5 Functions and Their Effects on Variable
Typing</a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Internationalization" href="#Internationalization">9
Internationalization with <samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#I18N-and-L10N">9.1 Internationalization and Localization</a>
-<li><a href="#Explaining-gettext">9.2 GNU <code>gettext</code></a>
-<li><a href="#Programmer-i18n">9.3 Internationalizing <samp><span
class="command">awk</span></samp> Programs</a>
-<li><a href="#Translator-i18n">9.4 Translating <samp><span
class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="#String-Extraction">9.4.1 Extracting Marked Strings</a>
-<li><a href="#Printf-Ordering">9.4.2 Rearranging <code>printf</code>
Arguments</a>
-<li><a href="#I18N-Portability">9.4.3 <samp><span
class="command">awk</span></samp> Portability Issues</a>
-</li></ul>
-<li><a href="#I18N-Example">9.5 A Simple Internationalization Example</a>
-<li><a href="#Gawk-I18N">9.6 <samp><span class="command">gawk</span></samp>
Can Speak Your Language</a>
-</li></ul>
-<li><a name="toc_Advanced-Features" href="#Advanced-Features">10 Advanced
Features of <samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Nondecimal-Data">10.1 Allowing Nondecimal Input Data</a>
-<li><a href="#Two_002dway-I_002fO">10.2 Two-Way Communications with Another
Process</a>
-<li><a href="#TCP_002fIP-Networking">10.3 Using <samp><span
class="command">gawk</span></samp> for Network Programming</a>
-<li><a href="#Portal-Files">10.4 Using <samp><span
class="command">gawk</span></samp> with BSD Portals</a>
-<li><a href="#Profiling">10.5 Profiling Your <samp><span
class="command">awk</span></samp> Programs</a>
-</li></ul>
-<li><a name="toc_Invoking-Gawk" href="#Invoking-Gawk">11 Running <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Command-Line">11.1 Invoking <samp><span
class="command">awk</span></samp></a>
-<li><a href="#Options">11.2 Command-Line Options</a>
-<li><a href="#Other-Arguments">11.3 Other Command-Line Arguments</a>
-<li><a href="#AWKPATH-Variable">11.4 The <samp><span
class="env">AWKPATH</span></samp> Environment Variable</a>
-<li><a href="#Obsolete">11.5 Obsolete Options and/or Features</a>
-<li><a href="#Undocumented">11.6 Undocumented Options and Features</a>
-<li><a href="#Known-Bugs">11.7 Known Bugs in <samp><span
class="command">gawk</span></samp></a>
-</li></ul>
-<li><a name="toc_Library-Functions" href="#Library-Functions">12 A Library of
<samp><span class="command">awk</span></samp> Functions</a>
-<ul>
-<li><a href="#Library-Names">12.1 Naming Library Function Global Variables</a>
-<li><a href="#General-Functions">12.2 General Programming</a>
-<ul>
-<li><a href="#Nextfile-Function">12.2.1 Implementing <code>nextfile</code> as
a Function</a>
-<li><a href="#Strtonum-Function">12.2.2 Converting Strings To Numbers</a>
-<li><a href="#Assert-Function">12.2.3 Assertions</a>
-<li><a href="#Round-Function">12.2.4 Rounding Numbers</a>
-<li><a href="#Cliff-Random-Function">12.2.5 The Cliff Random Number
Generator</a>
-<li><a href="#Ordinal-Functions">12.2.6 Translating Between Characters and
Numbers</a>
-<li><a href="#Join-Function">12.2.7 Merging an Array into a String</a>
-<li><a href="#Gettimeofday-Function">12.2.8 Managing the Time of Day</a>
-</li></ul>
-<li><a href="#Data-File-Management">12.3 Data File Management</a>
-<ul>
-<li><a href="#Filetrans-Function">12.3.1 Noting Data File Boundaries</a>
-<li><a href="#Rewind-Function">12.3.2 Rereading the Current File</a>
-<li><a href="#File-Checking">12.3.3 Checking for Readable Data Files</a>
-<li><a href="#Empty-Files">12.3.4 Checking For Zero-length Files</a>
-<li><a href="#Ignoring-Assigns">12.3.5 Treating Assignments as File Names</a>
-</li></ul>
-<li><a href="#Getopt-Function">12.4 Processing Command-Line Options</a>
-<li><a href="#Passwd-Functions">12.5 Reading the User Database</a>
-<li><a href="#Group-Functions">12.6 Reading the Group Database</a>
-</li></ul>
-<li><a name="toc_Sample-Programs" href="#Sample-Programs">13 Practical
<samp><span class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="#Running-Examples">13.1 Running the Example Programs</a>
-<li><a href="#Clones">13.2 Reinventing Wheels for Fun and Profit</a>
-<ul>
-<li><a href="#Cut-Program">13.2.1 Cutting out Fields and Columns</a>
-<li><a href="#Egrep-Program">13.2.2 Searching for Regular Expressions in
Files</a>
-<li><a href="#Id-Program">13.2.3 Printing out User Information</a>
-<li><a href="#Split-Program">13.2.4 Splitting a Large File into Pieces</a>
-<li><a href="#Tee-Program">13.2.5 Duplicating Output into Multiple Files</a>
-<li><a href="#Uniq-Program">13.2.6 Printing Nonduplicated Lines of Text</a>
-<li><a href="#Wc-Program">13.2.7 Counting Things</a>
-</li></ul>
-<li><a href="#Miscellaneous-Programs">13.3 A Grab Bag of <samp><span
class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="#Dupword-Program">13.3.1 Finding Duplicated Words in a
Document</a>
-<li><a href="#Alarm-Program">13.3.2 An Alarm Clock Program</a>
-<li><a href="#Translate-Program">13.3.3 Transliterating Characters</a>
-<li><a href="#Labels-Program">13.3.4 Printing Mailing Labels</a>
-<li><a href="#Word-Sorting">13.3.5 Generating Word-Usage Counts</a>
-<li><a href="#History-Sorting">13.3.6 Removing Duplicates from Unsorted
Text</a>
-<li><a href="#Extract-Program">13.3.7 Extracting Programs from Texinfo Source
Files</a>
-<li><a href="#Simple-Sed">13.3.8 A Simple Stream Editor</a>
-<li><a href="#Igawk-Program">13.3.9 An Easy Way to Use Library Functions</a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Language-History" href="#Language-History">Appendix A The
Evolution of the <samp><span class="command">awk</span></samp> Language</a>
-<ul>
-<li><a href="#V7_002fSVR3_002e1">A.1 Major Changes Between V7 and SVR3.1</a>
-<li><a href="#SVR4">A.2 Changes Between SVR3.1 and SVR4</a>
-<li><a href="#POSIX">A.3 Changes Between SVR4 and POSIX <samp><span
class="command">awk</span></samp></a>
-<li><a href="#BTL">A.4 Extensions in the Bell Laboratories <samp><span
class="command">awk</span></samp></a>
-<li><a href="#POSIX_002fGNU">A.5 Extensions in <samp><span
class="command">gawk</span></samp> Not in POSIX <samp><span
class="command">awk</span></samp></a>
-<li><a href="#Contributors">A.6 Major Contributors to <samp><span
class="command">gawk</span></samp></a>
-</li></ul>
-<li><a name="toc_Installation" href="#Installation">Appendix B Installing
<samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Gawk-Distribution">B.1 The <samp><span
class="command">gawk</span></samp> Distribution</a>
-<ul>
-<li><a href="#Getting">B.1.1 Getting the <samp><span
class="command">gawk</span></samp> Distribution</a>
-<li><a href="#Extracting">B.1.2 Extracting the Distribution</a>
-<li><a href="#Distribution-contents">B.1.3 Contents of the <samp><span
class="command">gawk</span></samp> Distribution</a>
-</li></ul>
-<li><a href="#Unix-Installation">B.2 Compiling and Installing <samp><span
class="command">gawk</span></samp> on Unix</a>
-<ul>
-<li><a href="#Quick-Installation">B.2.1 Compiling <samp><span
class="command">gawk</span></samp> for Unix</a>
-<li><a href="#Additional-Configuration-Options">B.2.2 Additional Configuration
Options</a>
-<li><a href="#Configuration-Philosophy">B.2.3 The Configuration Process</a>
-</li></ul>
-<li><a href="#Non_002dUnix-Installation">B.3 Installation on Other Operating
Systems</a>
-<ul>
-<li><a href="#Amiga-Installation">B.3.1 Installing <samp><span
class="command">gawk</span></samp> on an Amiga</a>
-<li><a href="#BeOS-Installation">B.3.2 Installing <samp><span
class="command">gawk</span></samp> on BeOS</a>
-<li><a href="#PC-Installation">B.3.3 Installation on PC Operating Systems</a>
-<ul>
-<li><a href="#PC-Binary-Installation">B.3.3.1 Installing a Prepared
Distribution for PC Systems</a>
-<li><a href="#PC-Compiling">B.3.3.2 Compiling <samp><span
class="command">gawk</span></samp> for PC Operating Systems</a>
-<li><a href="#PC-Dynamic">B.3.3.3 Compiling <samp><span
class="command">gawk</span></samp> For Dynamic Libraries</a>
-<li><a href="#PC-Using">B.3.3.4 Using <samp><span
class="command">gawk</span></samp> on PC Operating Systems</a>
-<li><a href="#Cygwin">B.3.3.5 Using <samp><span
class="command">gawk</span></samp> In The Cygwin Environment</a>
-</li></ul>
-<li><a href="#VMS-Installation">B.3.4 How to Compile and Install <samp><span
class="command">gawk</span></samp> on VMS</a>
-<ul>
-<li><a href="#VMS-Compilation">B.3.4.1 Compiling <samp><span
class="command">gawk</span></samp> on VMS</a>
-<li><a href="#VMS-Installation-Details">B.3.4.2 Installing <samp><span
class="command">gawk</span></samp> on VMS</a>
-<li><a href="#VMS-Running">B.3.4.3 Running <samp><span
class="command">gawk</span></samp> on VMS</a>
-<li><a href="#VMS-POSIX">B.3.4.4 Building and Using <samp><span
class="command">gawk</span></samp> on VMS POSIX</a>
-</li></ul>
-</li></ul>
-<li><a href="#Unsupported">B.4 Unsupported Operating System Ports</a>
-<ul>
-<li><a href="#Atari-Installation">B.4.1 Installing <samp><span
class="command">gawk</span></samp> on the Atari ST</a>
-<ul>
-<li><a href="#Atari-Compiling">B.4.1.1 Compiling <samp><span
class="command">gawk</span></samp> on the Atari ST</a>
-<li><a href="#Atari-Using">B.4.1.2 Running <samp><span
class="command">gawk</span></samp> on the Atari ST</a>
-</li></ul>
-<li><a href="#Tandem-Installation">B.4.2 Installing <samp><span
class="command">gawk</span></samp> on a Tandem</a>
-</li></ul>
-<li><a href="#Bugs">B.5 Reporting Problems and Bugs</a>
-<li><a href="#Other-Versions">B.6 Other Freely Available <samp><span
class="command">awk</span></samp> Implementations</a>
-</li></ul>
-<li><a name="toc_Notes" href="#Notes">Appendix C Implementation Notes</a>
-<ul>
-<li><a href="#Compatibility-Mode">C.1 Downward Compatibility and Debugging</a>
-<li><a href="#Additions">C.2 Making Additions to <samp><span
class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Adding-Code">C.2.1 Adding New Features</a>
-<li><a href="#New-Ports">C.2.2 Porting <samp><span
class="command">gawk</span></samp> to a New Operating System</a>
-</li></ul>
-<li><a href="#Dynamic-Extensions">C.3 Adding New Built-in Functions to
<samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Internals">C.3.1 A Minimal Introduction to <samp><span
class="command">gawk</span></samp> Internals</a>
-<li><a href="#Sample-Library">C.3.2 Directory and File Operation Built-ins</a>
-<ul>
-<li><a href="#Internal-File-Description">C.3.2.1 Using <code>chdir</code> and
<code>stat</code></a>
-<li><a href="#Internal-File-Ops">C.3.2.2 C Code for <code>chdir</code> and
<code>stat</code></a>
-<li><a href="#Using-Internal-File-Ops">C.3.2.3 Integrating the Extensions</a>
-</li></ul>
-</li></ul>
-<li><a href="#Future-Extensions">C.4 Probable Future Extensions</a>
-</li></ul>
-<li><a name="toc_Basic-Concepts" href="#Basic-Concepts">Appendix D Basic
Programming Concepts</a>
-<ul>
-<li><a href="#Basic-High-Level">D.1 What a Program Does</a>
-<li><a href="#Basic-Data-Typing">D.2 Data Values in a Computer</a>
-<li><a href="#Floating-Point-Issues">D.3 Floating-Point Number Caveats</a>
-</li></ul>
-<li><a name="toc_Glossary" href="#Glossary">Glossary</a>
-<li><a name="toc_Copying" href="#Copying">GNU General Public License</a>
-<ul>
-<li><a href="#Copying">Preamble</a>
-<li><a href="#Copying">Terms and Conditions for Copying, Distribution and
Modification</a>
-<li><a href="#Copying">How to Apply These Terms to Your New Programs</a>
-</li></ul>
-<li><a name="toc_GNU-Free-Documentation-License"
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>
-<ul>
-<li><a href="#GNU-Free-Documentation-License">ADDENDUM: How to use this
License for your documents</a>
-</li></ul>
-<li><a name="toc_Index" href="#Index">Index</a>
-</li></ul>
-</div>
-
-<div class="node">
-<p><hr>
-<a name="Foreword"></a>Next: <a rel="next" accesskey="n"
href="#Preface">Preface</a>,
-Previous: <a rel="previous" accesskey="p" href="#Top">Top</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">Foreword</h2>
-
-<p>Arnold Robbins and I are good friends. We were introduced 11 years ago
-by circumstances—and our favorite programming language, AWK.
-The circumstances started a couple of years
-earlier. I was working at a new job and noticed an unplugged
-Unix computer sitting in the corner. No one knew how to use it,
-and neither did I. However,
-a couple of days later it was running, and
-I was <code>root</code> and the one-and-only user.
-That day, I began the transition from statistician to Unix programmer.
-
- <p>On one of many trips to the library or bookstore in search of
-books on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and
-Weinberger, <cite>The AWK Programming Language</cite>, Addison-Wesley,
-1988. AWK's simple programming paradigm—find a pattern in the
-input and then perform an action—often reduced complex or tedious
-data manipulations to few lines of code. I was excited to try my
-hand at programming in AWK.
-
- <p>Alas, the <samp><span class="command">awk</span></samp> on my computer
was a limited version of the
-language described in the AWK book. I discovered that my computer
-had “old <samp><span class="command">awk</span></samp>” and the
AWK book described “new <samp><span
class="command">awk</span></samp>.”
-I learned that this was typical; the old version refused to step
-aside or relinquish its name. If a system had a new <samp><span
class="command">awk</span></samp>, it was
-invariably called <samp><span class="command">nawk</span></samp>, and few
systems had it.
-The best way to get a new <samp><span class="command">awk</span></samp> was to
<samp><span class="command">ftp</span></samp> the source code for
-<samp><span class="command">gawk</span></samp> from
<code>prep.ai.mit.edu</code>. <samp><span class="command">gawk</span></samp>
was a version of
-new <samp><span class="command">awk</span></samp> written by David Trueman and
Arnold, and available under
-the GNU General Public License.
-
- <p>(Incidentally,
-it's no longer difficult to find a new <samp><span
class="command">awk</span></samp>. <samp><span
class="command">gawk</span></samp> ships with
-Linux, and you can download binaries or source code for almost
-any system; my wife uses <samp><span class="command">gawk</span></samp> on her
VMS box.)
-
- <p>My Unix system started out unplugged from the wall; it certainly was not
-plugged into a network. So, oblivious to the existence of <samp><span
class="command">gawk</span></samp>
-and the Unix community in general, and desiring a new <samp><span
class="command">awk</span></samp>, I wrote
-my own, called <samp><span class="command">mawk</span></samp>.
-Before I was finished I knew about <samp><span
class="command">gawk</span></samp>,
-but it was too late to stop, so I eventually posted
-to a <code>comp.sources</code> newsgroup.
-
- <p>A few days after my posting, I got a friendly email
-from Arnold introducing
-himself. He suggested we share design and algorithms and
-attached a draft of the POSIX standard so
-that I could update <samp><span class="command">mawk</span></samp> to support
language extensions added
-after publication of the AWK book.
-
- <p>Frankly, if our roles had
-been reversed, I would not have been so open and we probably would
-have never met. I'm glad we did meet.
-He is an AWK expert's AWK expert and a genuinely nice person.
-Arnold contributes significant amounts of his
-expertise and time to the Free Software Foundation.
-
- <p>This book is the <samp><span class="command">gawk</span></samp>
reference manual, but at its core it
-is a book about AWK programming that
-will appeal to a wide audience.
-It is a definitive reference to the AWK language as defined by the
-1987 Bell Labs release and codified in the 1992 POSIX Utilities
-standard.
-
- <p>On the other hand, the novice AWK programmer can study
-a wealth of practical programs that emphasize
-the power of AWK's basic idioms:
-data driven control-flow, pattern matching with regular expressions,
-and associative arrays.
-Those looking for something new can try out <samp><span
class="command">gawk</span></samp>'s
-interface to network protocols via special <samp><span
class="file">/inet</span></samp> files.
-
- <p>The programs in this book make clear that an AWK program is
-typically much smaller and faster to develop than
-a counterpart written in C.
-Consequently, there is often a payoff to prototype an
-algorithm or design in AWK to get it running quickly and expose
-problems early. Often, the interpreted performance is adequate
-and the AWK prototype becomes the product.
-
- <p>The new <samp><span class="command">pgawk</span></samp> (profiling
<samp><span class="command">gawk</span></samp>), produces
-program execution counts.
-I recently experimented with an algorithm that for
-n lines of input, exhibited
-~ C n^2
-performance, while
-theory predicted
-~ C n log n
-behavior. A few minutes poring
-over the <samp><span class="file">awkprof.out</span></samp> profile pinpointed
the problem to
-a single line of code. <samp><span class="command">pgawk</span></samp> is a
welcome addition to
-my programmer's toolbox.
-
- <p>Arnold has distilled over a decade of experience writing and
-using AWK programs, and developing <samp><span
class="command">gawk</span></samp>, into this book. If you use
-AWK or want to learn how, then read this book.
-
-<pre class="display"> Michael Brennan
- Author of <samp><span class="command">mawk</span></samp>
-</pre>
- <div class="node">
-<p><hr>
-<a name="Preface"></a>Next: <a rel="next" accesskey="n"
href="#Getting-Started">Getting Started</a>,
-Previous: <a rel="previous" accesskey="p" href="#Foreword">Foreword</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">Preface</h2>
-
-<!-- I saw a comment somewhere that the preface should describe the book
itself, -->
-<!-- and the introduction should describe what the book covers. -->
-<!-- 12/2000: Chuck wants the preface & intro combined. -->
-<p>Several kinds of tasks occur repeatedly
-when working with text files.
-You might want to extract certain lines and discard the rest.
-Or you may need to make changes wherever certain patterns appear,
-but leave the rest of the file alone.
-Writing single-use programs for these tasks in languages such as C, C++, or
Pascal
-is time-consuming and inconvenient.
-Such jobs are often easier with <samp><span class="command">awk</span></samp>.
-The <samp><span class="command">awk</span></samp> utility interprets a
special-purpose programming language
-that makes it easy to handle simple data-reformatting jobs.
-
- <p>The GNU implementation of <samp><span class="command">awk</span></samp>
is called <samp><span class="command">gawk</span></samp>; it is fully
-compatible with the System V Release 4 version of
-<samp><span class="command">awk</span></samp>. <samp><span
class="command">gawk</span></samp> is also compatible with the POSIX
-specification of the <samp><span class="command">awk</span></samp> language.
This means that all
-properly written <samp><span class="command">awk</span></samp> programs should
work with <samp><span class="command">gawk</span></samp>.
-Thus, we usually don't distinguish between <samp><span
class="command">gawk</span></samp> and other
-<samp><span class="command">awk</span></samp> implementations.
-
- <p><a
name="index-_0040command_007bawk_007d_002c-POSIX-and_002c-See-Also-POSIX-_0040command_007bawk_007d-1"></a><a
name="index-_0040command_007bawk_007d_002c-POSIX-and-2"></a><a
name="index-POSIX_002c-_0040command_007bawk_007d-and-3"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-4"></a><a
name="index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-5"></a><a
name="index-_0040command_007bawk_007d_002c-uses-for-6"></a>Using <samp><span
class="command">awk</span></samp> allows you to:
-
- <ul>
-<li>Manage small, personal databases
-
- <li>Generate reports
-
- <li>Validate data
-
- <li>Produce indexes and perform other document preparation tasks
-
- <li>Experiment with algorithms that you can adapt later to other computer
-languages
-</ul>
-
- <p><a
name="index-_0040command_007bawk_007d_002c-See-Also-_0040command_007bgawk_007d-7"></a><a
name="index-_0040command_007bgawk_007d_002c-See-Also-_0040command_007bawk_007d-8"></a><a
name="index-_0040command_007bgawk_007d_002c-uses-for-9"></a>In addition,
-<samp><span class="command">gawk</span></samp>
-provides facilities that make it easy to:
-
- <ul>
-<li>Extract bits and pieces of data for processing
-
- <li>Sort data
-
- <li>Perform simple network communications
-</ul>
-
- <p>This Web page teaches you about the <samp><span
class="command">awk</span></samp> language and
-how you can use it effectively. You should already be familiar with basic
-system commands, such as <samp><span class="command">cat</span></samp> and
<samp><span class="command">ls</span></samp>,<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> as well as basic shell
-facilities, such as input/output (I/O) redirection and pipes.
-
- <p><a
name="index-GNU-_0040command_007bawk_007d_002c-See-_0040command_007bgawk_007d-10"></a>Implementations
of the <samp><span class="command">awk</span></samp> language are available
for many
-different computing environments. This Web page, while describing
-the <samp><span class="command">awk</span></samp> language in general, also
describes the particular
-implementation of <samp><span class="command">awk</span></samp> called
<samp><span class="command">gawk</span></samp> (which stands for
-“GNU awk”). <samp><span class="command">gawk</span></samp> runs
on a broad range of Unix systems,
-ranging from 80386 PC-based computers up through large-scale systems,
-such as Crays. <samp><span class="command">gawk</span></samp> has also been
ported to Mac OS X,
-MS-DOS, Microsoft Windows (all versions) and OS/2 PCs, Atari and Amiga
-microcomputers, BeOS, Tandem D20, and VMS.
-
-<ul class="menu">
-<li><a accesskey="1" href="#History">History</a>: The
history of <samp><span class="command">gawk</span></samp> and
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="2" href="#Names">Names</a>: What name
to use to find <samp><span class="command">awk</span></samp>.
-<li><a accesskey="3" href="#This-Manual">This Manual</a>:
Using this Web page. Includes sample
- input files that you can use.
-<li><a accesskey="4" href="#Conventions">Conventions</a>:
Typographical Conventions.
-<li><a accesskey="5" href="#Manual-History">Manual History</a>:
Brief history of the GNU project and this
- Web page.
-<li><a accesskey="6" href="#How-To-Contribute">How To Contribute</a>:
Helping to save the world.
-<li><a accesskey="7" href="#Acknowledgments">Acknowledgments</a>:
Acknowledgments.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="History"></a>Next: <a rel="next" accesskey="n"
href="#Names">Names</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="unnumberedsec">History of <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-recipe-for-a-programming-language-11"></a><a
name="index-programming-language_002c-recipe-for-12"></a><div
align="center">Recipe For A Programming Language</div>
-
-<p><table summary=""><tr align="left"><td valign="top"></td><td valign="top">1
part <code>egrep</code> </td><td valign="top">1 part <code>snobol</code>
-<br></td></tr><tr align="left"><td valign="top"></td><td valign="top">2 parts
<code>ed</code> </td><td valign="top">3 parts C
-<br></td></tr></table>
-
- <blockquote>
-Blend all parts well using <code>lex</code> and <code>yacc</code>.
-Document minimally and release.
-
- <p>After eight years, add another part <code>egrep</code> and two
-more parts C. Document very well and release.
-</blockquote>
-
- <p><a name="index-Aho_002c-Alfred-13"></a><a
name="index-Weinberger_002c-Peter-14"></a><a
name="index-Kernighan_002c-Brian-15"></a><a
name="index-_0040command_007bawk_007d_002c-history-of-16"></a>The name
<samp><span class="command">awk</span></samp> comes from the initials of its
designers: Alfred V.
-Aho, Peter J. Weinberger and Brian W. Kernighan. The original version of
-<samp><span class="command">awk</span></samp> was written in 1977 at AT&T
Bell Laboratories.
-In 1985, a new version made the programming
-language more powerful, introducing user-defined functions, multiple input
-streams, and computed regular expressions.
-This new version became widely available with Unix System V
-Release 3.1 (SVR3.1).
-The version in SVR4 added some new features and cleaned
-up the behavior in some of the “dark corners” of the language.
-The specification for <samp><span class="command">awk</span></samp> in the
POSIX Command Language
-and Utilities standard further clarified the language.
-Both the <samp><span class="command">gawk</span></samp> designers and the
original Bell Laboratories <samp><span class="command">awk</span></samp>
-designers provided feedback for the POSIX specification.
-
- <p><a name="index-Rubin_002c-Paul-17"></a><a
name="index-Fenlason_002c-Jay-18"></a><a
name="index-Trueman_002c-David-19"></a>Paul Rubin wrote the GNU implementation,
<samp><span class="command">gawk</span></samp>, in 1986.
-Jay Fenlason completed it, with advice from Richard Stallman. John Woods
-contributed parts of the code as well. In 1988 and 1989, David Trueman, with
-help from me, thoroughly reworked <samp><span
class="command">gawk</span></samp> for compatibility
-with the newer <samp><span class="command">awk</span></samp>.
-Circa 1995, I became the primary maintainer.
-Current development focuses on bug fixes,
-performance improvements, standards compliance, and occasionally, new features.
-
- <p>In May of 1997, Jürgen Kahrs felt the need for network access
-from <samp><span class="command">awk</span></samp>, and with a little help
from me, set about adding
-features to do this for <samp><span class="command">gawk</span></samp>. At
that time, he also
-wrote the bulk of
-<cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>
-(a separate document, available as part of the <samp><span
class="command">gawk</span></samp> distribution).
-His code finally became part of the main <samp><span
class="command">gawk</span></samp> distribution
-with <samp><span class="command">gawk</span></samp> version 3.1.
-
- <p>See <a href="#Contributors">Contributors</a>,
-for a complete list of those who made important contributions to <samp><span
class="command">gawk</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="Names"></a>Next: <a rel="next" accesskey="n"
href="#This-Manual">This Manual</a>,
-Previous: <a rel="previous" accesskey="p" href="#History">History</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="section">A Rose by Any Other Name</h3>
-
-<p><a name="index-_0040command_007bawk_007d_002c-new-vs_002e-old-20"></a>The
<samp><span class="command">awk</span></samp> language has evolved over the
years. Full details are
-provided in <a href="#Language-History">Language History</a>.
-The language described in this Web page
-is often referred to as “new <samp><span
class="command">awk</span></samp>” (<samp><span
class="command">nawk</span></samp>).
-
- <p><a
name="index-_0040command_007bawk_007d_002c-versions-of-21"></a>Because of this,
many systems have multiple
-versions of <samp><span class="command">awk</span></samp>.
-Some systems have an <samp><span class="command">awk</span></samp> utility
that implements the
-original version of the <samp><span class="command">awk</span></samp> language
and a <samp><span class="command">nawk</span></samp> utility
-for the new
-version.
-Others have an <samp><span class="command">oawk</span></samp> version for the
“old <samp><span class="command">awk</span></samp>”
-language and plain <samp><span class="command">awk</span></samp> for the new
one. Still others only
-have one version, which is usually the new one.<a rel="footnote" href="#fn-2"
name="fnd-2"><sup>2</sup></a>
-
- <p><a name="index-_0040command_007bnawk_007d-utility-22"></a><a
name="index-_0040command_007boawk_007d-utility-23"></a>All in all, this makes
it difficult for you to know which version of
-<samp><span class="command">awk</span></samp> you should run when writing your
programs. The best advice
-I can give here is to check your local documentation. Look for <samp><span
class="command">awk</span></samp>,
-<samp><span class="command">oawk</span></samp>, and <samp><span
class="command">nawk</span></samp>, as well as for <samp><span
class="command">gawk</span></samp>.
-It is likely that you already
-have some version of new <samp><span class="command">awk</span></samp> on your
system, which is what
-you should use when running your programs. (Of course, if you're reading
-this Web page, chances are good that you have <samp><span
class="command">gawk</span></samp>!)
-
- <p>Throughout this Web page, whenever we refer to a language feature
-that should be available in any complete implementation of POSIX <samp><span
class="command">awk</span></samp>,
-we simply use the term <samp><span class="command">awk</span></samp>. When
referring to a feature that is
-specific to the GNU implementation, we use the term <samp><span
class="command">gawk</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="This-Manual"></a>Next: <a rel="next" accesskey="n"
href="#Conventions">Conventions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Names">Names</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="section">Using This Book</h3>
-
-<p><a name="index-_0040command_007bawk_007d_002c-terms-describing-24"></a>
-The term <samp><span class="command">awk</span></samp> refers to a particular
program as well as to the language you
-use to tell this program what to do. When we need to be careful, we call
-the language “the <samp><span class="command">awk</span></samp>
language,”
-and the program “the <samp><span class="command">awk</span></samp>
utility.”
-This Web page explains
-both the <samp><span class="command">awk</span></samp> language and how to run
the <samp><span class="command">awk</span></samp> utility.
-The term <dfn><samp></dfn><span class="command">awk</span><dfn></samp>
program</dfn> refers to a program written by you in
-the <samp><span class="command">awk</span></samp> programming language.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-25"></a><a
name="index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-26"></a><a
name="index-POSIX-_0040command_007bawk_007d-27"></a>Primarily, this Web page
explains the features of <samp><span class="command">awk</span></samp>,
-as defined in the POSIX standard. It does so in the context of the
-<samp><span class="command">gawk</span></samp> implementation. While doing
so, it also
-attempts to describe important differences between <samp><span
class="command">gawk</span></samp>
-and other <samp><span class="command">awk</span></samp> implementations.<a
rel="footnote" href="#fn-3" name="fnd-3"><sup>3</sup></a>
-Finally, any <samp><span class="command">gawk</span></samp> features that are
not in
-the POSIX standard for <samp><span class="command">awk</span></samp> are noted.
-
- <p>This Web page has the difficult task of being both a tutorial and a
reference.
-If you are a novice, feel free to skip over details that seem too complex.
-You should also ignore the many cross-references; they are for the
-expert user and for the online Info version of the document.
-
- <p>There are
-subsections labelled
-as <strong>Advanced Notes</strong>
-scattered throughout the Web page.
-They add a more complete explanation of points that are relevant, but not
likely
-to be of interest on first reading.
-All appear in the index, under the heading “advanced features.”
-
- <p>Most of the time, the examples use complete <samp><span
class="command">awk</span></samp> programs.
-In some of the more advanced sections, only the part of the <samp><span
class="command">awk</span></samp>
-program that illustrates the concept currently being described is shown.
-
- <p>While this Web page is aimed principally at people who have not been
-exposed
-to <samp><span class="command">awk</span></samp>, there is a lot of
information here that even the <samp><span class="command">awk</span></samp>
-expert should find useful. In particular, the description of POSIX
-<samp><span class="command">awk</span></samp> and the example programs in
-<a href="#Library-Functions">Library Functions</a>, and in
-<a href="#Sample-Programs">Sample Programs</a>,
-should be of interest.
-
- <p><a href="#Getting-Started">Getting Started</a>,
-provides the essentials you need to know to begin using <samp><span
class="command">awk</span></samp>.
-
- <p><a href="#Regexp">Regexp</a>,
-introduces regular expressions in general, and in particular the flavors
-supported by POSIX <samp><span class="command">awk</span></samp> and
<samp><span class="command">gawk</span></samp>.
-
- <p><a href="#Reading-Files">Reading Files</a>,
-describes how <samp><span class="command">awk</span></samp> reads your data.
-It introduces the concepts of records and fields, as well
-as the <code>getline</code> command.
-I/O redirection is first described here.
-
- <p><a href="#Printing">Printing</a>,
-describes how <samp><span class="command">awk</span></samp> programs can
produce output with
-<code>print</code> and <code>printf</code>.
-
- <p><a href="#Expressions">Expressions</a>,
-describes expressions, which are the basic building blocks
-for getting most things done in a program.
-
- <p><a href="#Patterns-and-Actions">Patterns and Actions</a>,
-describes how to write patterns for matching records, actions for
-doing something when a record is matched, and the built-in variables
-<samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp> use.
-
- <p><a href="#Arrays">Arrays</a>,
-covers <samp><span class="command">awk</span></samp>'s one-and-only data
structure: associative arrays.
-Deleting array elements and whole arrays is also described, as well as
-sorting arrays in <samp><span class="command">gawk</span></samp>.
-
- <p><a href="#Functions">Functions</a>,
-describes the built-in functions <samp><span class="command">awk</span></samp>
and
-<samp><span class="command">gawk</span></samp> provide, as well as how to
define
-your own functions.
-
- <p><a href="#Internationalization">Internationalization</a>,
-describes special features in <samp><span class="command">gawk</span></samp>
for translating program
-messages into different languages at runtime.
-
- <p><a href="#Advanced-Features">Advanced Features</a>,
-describes a number of <samp><span class="command">gawk</span></samp>-specific
advanced features.
-Of particular note
-are the abilities to have two-way communications with another process,
-perform TCP/IP networking, and
-profile your <samp><span class="command">awk</span></samp> programs.
-
- <p><a href="#Invoking-Gawk">Invoking Gawk</a>,
-describes how to run <samp><span class="command">gawk</span></samp>, the
meaning of its
-command-line options, and how it finds <samp><span
class="command">awk</span></samp>
-program source files.
-
- <p><a href="#Library-Functions">Library Functions</a>, and
-<a href="#Sample-Programs">Sample Programs</a>,
-provide many sample <samp><span class="command">awk</span></samp> programs.
-Reading them allows you to see <samp><span class="command">awk</span></samp>
-solving real problems.
-
- <p><a href="#Language-History">Language History</a>,
-describes how the <samp><span class="command">awk</span></samp> language has
evolved since
-first release to present. It also describes how <samp><span
class="command">gawk</span></samp>
-has acquired features over time.
-
- <p><a href="#Installation">Installation</a>,
-describes how to get <samp><span class="command">gawk</span></samp>, how to
compile it
-under Unix, and how to compile and use it on different
-non-Unix systems. It also describes how to report bugs
-in <samp><span class="command">gawk</span></samp> and where to get three other
freely
-available implementations of <samp><span class="command">awk</span></samp>.
-
- <p><a href="#Notes">Notes</a>,
-describes how to disable <samp><span class="command">gawk</span></samp>'s
extensions, as
-well as how to contribute new code to <samp><span
class="command">gawk</span></samp>,
-how to write extension libraries, and some possible
-future directions for <samp><span class="command">gawk</span></samp>
development.
-
- <p><a href="#Basic-Concepts">Basic Concepts</a>,
-provides some very cursory background material for those who
-are completely unfamiliar with computer programming.
-Also centralized there is a discussion of some of the issues
-surrounding floating-point numbers.
-
- <p>The
-<a href="#Glossary">Glossary</a>,
-defines most, if not all, the significant terms used
-throughout the book.
-If you find terms that you aren't familiar with, try looking them up here.
-
- <p><a href="#Copying">Copying</a>, and
-<a href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
-present the licenses that cover the <samp><span
class="command">gawk</span></samp> source code
-and this Web page, respectively.
-
-<div class="node">
-<p><hr>
-<a name="Conventions"></a>Next: <a rel="next" accesskey="n"
href="#Manual-History">Manual History</a>,
-Previous: <a rel="previous" accesskey="p" href="#This-Manual">This
Manual</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="section">Typographical Conventions</h3>
-
-<p><a name="index-Texinfo-28"></a>This Web page is written using Texinfo, the
GNU documentation
-formatting language.
-A single Texinfo source file is used to produce both the printed and online
-versions of the documentation.
-Because of this, the typographical conventions
-are slightly different than in other books you may have read.
-
- <p>Examples you would type at the command-line are preceded by the common
-shell primary and secondary prompts, `<samp><span
class="samp">$</span></samp>' and `<samp><span
class="samp">></span></samp>'.
-Output from the command is preceded by the glyph “-|”.
-This typically represents the command's standard output.
-Error messages, and other output on the command's standard error, are preceded
-by the glyph “error-->”. For example:
-
-<pre class="example"> $ echo hi on stdout
- -| hi on stdout
- $ echo hello on stderr 1>&2
- error--> hello on stderr
-</pre>
- <p>In the text, command names appear in <code>this font</code>, while code
segments
-appear in the same font and quoted, `<samp><span class="samp">like
this</span></samp>'. Some things are
-emphasized <em>like this</em>, and if a point needs to be made
-strongly, it is done <strong>like this</strong>. The first occurrence of
-a new term is usually its <dfn>definition</dfn> and appears in the same
-font as the previous occurrence of “definition” in this sentence.
-file names are indicated like this: <samp><span
class="file">/path/to/ourfile</span></samp>.
-
- <p>Characters that you type at the keyboard look <kbd>like this</kbd>. In
particular,
-there are special characters called “control characters.” These
are
-characters that you type by holding down both the <kbd>CONTROL</kbd> key and
-another key, at the same time. For example, a <kbd>Ctrl-d</kbd> is typed
-by first pressing and holding the <kbd>CONTROL</kbd> key, next
-pressing the <kbd>d</kbd> key and finally releasing both keys.
-
-<!-- fakenode - for prepinfo -->
-<h5 class="subsubheading">Dark Corners</h5>
-
-<p><a name="index-Kernighan_002c-Brian-29"></a><blockquote>
-<i>Dark corners are basically fractal — no matter how much
-you illuminate, there's always a smaller but darker one.</i><br>
-Brian Kernighan
-</blockquote>
-
- <p><a name="index-d_002ec_002e_002c-See-dark-corner-30"></a><a
name="index-dark-corner-31"></a>Until the POSIX standard (and <cite>The Gawk
Manual</cite>),
-many features of <samp><span class="command">awk</span></samp> were either
poorly documented or not
-documented at all. Descriptions of such features
-(often called “dark corners”) are noted in this Web page with
-“(d.c.)”.
-They also appear in the index under the heading “dark corner.”
-
- <p>As noted by the opening quote, though, any
-coverage of dark corners
-is, by definition, something that is incomplete.
-
-<div class="node">
-<p><hr>
-<a name="Manual-History"></a>Next: <a rel="next" accesskey="n"
href="#How-To-Contribute">How To Contribute</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Conventions">Conventions</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="unnumberedsec">The GNU Project and This Book</h3>
-
-<p><a name="index-FSF-_0028Free-Software-Foundation_0029-32"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-33"></a><a
name="index-Stallman_002c-Richard-34"></a>The Free Software Foundation (FSF) is
a nonprofit organization dedicated
-to the production and distribution of freely distributable software.
-It was founded by Richard M. Stallman, the author of the original
-Emacs editor. GNU Emacs is the most widely used version of Emacs today.
-
- <p><a name="index-GNU-Project-35"></a><a
name="index-GPL-_0028General-Public-License_0029-36"></a><a
name="index-General-Public-License_002c-See-GPL-37"></a><a
name="index-documentation_002c-online-38"></a>The GNU<a rel="footnote"
href="#fn-4" name="fnd-4"><sup>4</sup></a>
-Project is an ongoing effort on the part of the Free Software
-Foundation to create a complete, freely distributable, POSIX-compliant
-computing environment.
-The FSF uses the “GNU General Public License” (GPL) to ensure that
-their software's
-source code is always available to the end user. A
-copy of the GPL is included
-in this Web page
-for your reference
-(see <a href="#Copying">Copying</a>).
-The GPL applies to the C language source code for <samp><span
class="command">gawk</span></samp>.
-To find out more about the FSF and the GNU Project online,
-see <a href="http://www.gnu.org">the GNU Project's home page</a>.
-This Web page may also be read from
-<a href="http://www.gnu.org/manual/gawk/">their web site</a>.
-
- <p>A shell, an editor (Emacs), highly portable optimizing C, C++, and
-Objective-C compilers, a symbolic debugger and dozens of large and
-small utilities (such as <samp><span class="command">gawk</span></samp>), have
all been completed and are
-freely available. The GNU operating
-system kernel (the HURD), has been released but is still in an early
-stage of development.
-
- <p><a name="index-Linux-39"></a><a name="index-GNU_002fLinux-40"></a><a
name="index-operating-systems_002c-BSD_002dbased-41"></a><a
name="index-Alpha-_0028DEC_0029-42"></a>Until the GNU operating system is more
fully developed, you should
-consider using GNU/Linux, a freely distributable, Unix-like operating
-system for Intel 80386, DEC Alpha, Sun SPARC, IBM S/390, and other
-systems.<a rel="footnote" href="#fn-5" name="fnd-5"><sup>5</sup></a>
-There are
-many books on GNU/Linux. One that is freely available is <cite>Linux
-Installation and Getting Started</cite>, by Matt Welsh.
-Many GNU/Linux distributions are often available in computer stores or
-bundled on CD-ROMs with books about Linux.
-(There are three other freely available, Unix-like operating systems for
-80386 and other systems: NetBSD, FreeBSD, and OpenBSD. All are based on the
-4.4-Lite Berkeley Software Distribution, and they use recent versions
-of <samp><span class="command">gawk</span></samp> for their versions of
<samp><span class="command">awk</span></samp>.)
-
- <p>The Web page you are reading is actually free—at least, the
-information in it is free to anyone. The machine-readable
-source code for the Web page comes with <samp><span
class="command">gawk</span></samp>; anyone
-may take this Web page to a copying machine and make as many
-copies as they like. (Take a moment to check the Free Documentation
-License in <a href="#GNU-Free-Documentation-License">GNU Free Documentation
License</a>.)
-
- <p>Although you could just print it out yourself, bound books are much
-easier to read and use. Furthermore,
-the proceeds from sales of this book go back to the FSF
-to help fund development of more free software.
-
- <p><a name="index-Close_002c-Diane-43"></a>The Web page itself has gone
through a number of previous editions.
-Paul Rubin wrote the very first draft of <cite>The GAWK Manual</cite>;
-it was around 40 pages in size.
-Diane Close and Richard Stallman improved it, yielding a
-version that was
-around 90 pages long and barely described the original, “old”
-version of <samp><span class="command">awk</span></samp>.
-
- <p>I started working with that version in the fall of 1988.
-As work on it progressed,
-the FSF published several preliminary versions (numbered 0.<var>x</var>).
-In 1996, Edition 1.0 was released with <samp><span
class="command">gawk</span></samp> 3.0.0.
-The FSF published the first two editions under
-the title <cite>The GNU Awk User's Guide</cite>.
-
- <p>This edition maintains the basic structure of Edition 1.0,
-but with significant additional material, reflecting the host of new features
-in <samp><span class="command">gawk</span></samp> version 3.1.
-Of particular note is
-<a href="#Array-Sorting">Array Sorting</a>,
-as well as
-<a href="#Bitwise-Functions">Bitwise Functions</a>,
-<a href="#Internationalization">Internationalization</a>,
-and also
-<a href="#Advanced-Features">Advanced Features</a>,
-and
-<a href="#Dynamic-Extensions">Dynamic Extensions</a>.
-
- <p><cite>GAWK: Effective AWK Programming</cite> will undoubtedly continue
to evolve.
-An electronic version
-comes with the <samp><span class="command">gawk</span></samp> distribution
from the FSF.
-If you find an error in this Web page, please report it!
-See <a href="#Bugs">Bugs</a>, for information on submitting
-problem reports electronically, or write to me in care of the publisher.
-
-<div class="node">
-<p><hr>
-<a name="How-To-Contribute"></a>Next: <a rel="next" accesskey="n"
href="#Acknowledgments">Acknowledgments</a>,
-Previous: <a rel="previous" accesskey="p" href="#Manual-History">Manual
History</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="unnumberedsec">How to Contribute</h3>
-
-<p>As the maintainer of GNU <samp><span class="command">awk</span></samp>,
-I am starting a collection of publicly available <samp><span
class="command">awk</span></samp>
-programs.
-For more information,
-see <a
href="ftp://ftp.freefriends.org/arnold/Awkstuff">ftp://ftp.freefriends.org/arnold/Awkstuff</a>.
-If you have written an interesting <samp><span
class="command">awk</span></samp> program, or have written a
-<samp><span class="command">gawk</span></samp> extension that you would like to
-share with the rest of the world, please contact me (<a
href="mailto:address@hidden">address@hidden</a>).
-Making things available on the Internet helps keep the
-<samp><span class="command">gawk</span></samp> distribution down to manageable
size.
-
-<div class="node">
-<p><hr>
-<a name="Acknowledgments"></a>Previous: <a rel="previous" accesskey="p"
href="#How-To-Contribute">How To Contribute</a>,
-Up: <a rel="up" accesskey="u" href="#Preface">Preface</a>
-<br>
-</div>
-
-<h3 class="unnumberedsec">Acknowledgments</h3>
-
-<p>The initial draft of <cite>The GAWK Manual</cite> had the following
acknowledgments:
-
- <blockquote>
-Many people need to be thanked for their assistance in producing this
-manual. Jay Fenlason contributed many ideas and sample programs. Richard
-Mlynarik and Robert Chassell gave helpful comments on drafts of this
-manual. The paper <cite>A Supplemental Document for <samp></cite><span
class="command">awk</span><cite></samp></cite> by John W.
-Pierce of the Chemistry Department at UC San Diego, pinpointed several
-issues relevant both to <samp><span class="command">awk</span></samp>
implementation and to this manual, that
-would otherwise have escaped us.
-</blockquote>
-
- <p><a name="index-Stallman_002c-Richard-44"></a>I would like to acknowledge
Richard M. Stallman, for his vision of a
-better world and for his courage in founding the FSF and starting the
-GNU Project.
-
- <p>The following people (in alphabetical order)
-provided helpful comments on various
-versions of this book, up to and including this edition.
-Rick Adams,
-Nelson H.F. Beebe,
-Karl Berry,
-Dr. Michael Brennan,
-Rich Burridge,
-Claire Cloutier,
-Diane Close,
-Scott Deifik,
-Christopher (“Topher”) Eliot,
-Jeffrey Friedl,
-Dr. Darrel Hankerson,
-Michal Jaegermann,
-Dr. Richard J. LeBlanc,
-Michael Lijewski,
-Pat Rankin,
-Miriam Robbins,
-Mary Sheehan,
-and
-Chuck Toporek.
-
- <p><a name="index-Berry_002c-Karl-45"></a><a
name="index-Chassell_002c-Robert-J_002e_0040_003a-46"></a><!-- @cindex Texinfo
-->
-Robert J. Chassell provided much valuable advice on
-the use of Texinfo.
-He also deserves special thanks for
-convincing me <em>not</em> to title this Web page
-<cite>How To Gawk Politely</cite>.
-Karl Berry helped significantly with the TeX part of Texinfo.
-
- <p><a name="index-Hartholz_002c-Marshall-47"></a><a
name="index-Hartholz_002c-Elaine-48"></a><a
name="index-Schreiber_002c-Bert-49"></a><a
name="index-Schreiber_002c-Rita-50"></a>I would like to thank Marshall and
Elaine Hartholz of Seattle and
-Dr. Bert and Rita Schreiber of Detroit for large amounts of quiet vacation
-time in their homes, which allowed me to make significant progress on
-this Web page and on <samp><span class="command">gawk</span></samp> itself.
-
- <p><a name="index-Hughes_002c-Phil-51"></a>Phil Hughes of SSC
-contributed in a very important way by loaning me his laptop GNU/Linux
-system, not once, but twice, which allowed me to do a lot of work while
-away from home.
-
- <p><a name="index-Trueman_002c-David-52"></a>David Trueman deserves special
credit; he has done a yeoman job
-of evolving <samp><span class="command">gawk</span></samp> so that it performs
well and without bugs.
-Although he is no longer involved with <samp><span
class="command">gawk</span></samp>,
-working with him on this project was a significant pleasure.
-
- <p><a name="index-Drepper_002c-Ulrich-53"></a><a
name="index-GNITS-mailing-list-54"></a><a
name="index-mailing-list_002c-GNITS-55"></a>The intrepid members of the GNITS
mailing list, and most notably Ulrich
-Drepper, provided invaluable help and feedback for the design of the
-internationalization features.
-
- <p><a name="index-Beebe_002c-Nelson-56"></a><a
name="index-Brown_002c-Martin-57"></a><a
name="index-Buening_002c-Andreas-58"></a><a
name="index-Deifik_002c-Scott-59"></a><a
name="index-Hankerson_002c-Darrel-60"></a><a
name="index-Hasegawa_002c-Isamu-61"></a><a
name="index-Jaegermann_002c-Michal-62"></a><a
name="index-Kahrs_002c-J_0040_0022urgen-63"></a><a
name="index-Rankin_002c-Pat-64"></a><a
name="index-Rommel_002c-Kai-Uwe-65"></a><a
name="index-Zaretskii_002c-Eli-66"></a>Nelson Beebe,
-Martin Brown,
-Andreas Buening,
-Scott Deifik,
-Darrel Hankerson,
-Isamu Hasegawa,
-Michal Jaegermann,
-Jürgen Kahrs,
-Pat Rankin,
-Kai Uwe Rommel,
-and Eli Zaretskii
-(in alphabetical order)
-make up the
-<samp><span class="command">gawk</span></samp> “crack portability
team.” Without their hard work and
-help, <samp><span class="command">gawk</span></samp> would not be nearly the
fine program it is today. It
-has been and continues to be a pleasure working with this team of fine
-people.
-
- <p><a name="index-Kernighan_002c-Brian-67"></a>David and I would like to
thank Brian Kernighan of Bell Laboratories for
-invaluable assistance during the testing and debugging of <samp><span
class="command">gawk</span></samp>, and for
-help in clarifying numerous points about the language. We could not have
-done nearly as good a job on either <samp><span
class="command">gawk</span></samp> or its documentation without
-his help.
-
- <p>Chuck Toporek, Mary Sheehan, and Claire Coutier of O'Reilly &
Associates contributed
-significant editorial help for this Web page for the
-3.1 release of <samp><span class="command">gawk</span></samp>.
-
- <p><a name="index-Robbins_002c-Miriam-68"></a><a
name="index-Robbins_002c-Jean-69"></a><a
name="index-Robbins_002c-Harry-70"></a><a name="index-G_002dd-71"></a>I must
thank my wonderful wife, Miriam, for her patience through
-the many versions of this project, for her proofreading,
-and for sharing me with the computer.
-I would like to thank my parents for their love, and for the grace with
-which they raised and educated me.
-Finally, I also must acknowledge my gratitude to G-d, for the many
opportunities
-He has sent my way, as well as for the gifts He has given me with which to
-take advantage of those opportunities.
- <pre class="sp">
-
-
-</pre>
-Arnold Robbins <br>
-Nof Ayalon <br>
-ISRAEL <br>
-March, 2001
-
-<div class="node">
-<p><hr>
-<a name="Getting-Started"></a>Next: <a rel="next" accesskey="n"
href="#Regexp">Regexp</a>,
-Previous: <a rel="previous" accesskey="p" href="#Preface">Preface</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">1 Getting Started with <samp><span
class="command">awk</span></samp></h2>
-
-<!-- @cindex script, definition of -->
-<!-- @cindex rule, definition of -->
-<!-- @cindex program, definition of -->
-<!-- @cindex basic function of @command{awk} -->
-<p><a name="index-_0040command_007bawk_007d_002c-function-of-72"></a>
-The basic function of <samp><span class="command">awk</span></samp> is to
search files for lines (or other
-units of text) that contain certain patterns. When a line matches one
-of the patterns, <samp><span class="command">awk</span></samp> performs
specified actions on that line.
-<samp><span class="command">awk</span></samp> keeps processing input lines in
this way until it reaches
-the end of the input files.
-
- <p><a name="index-_0040command_007bawk_007d_002c-uses-for-73"></a><a
name="index-programming-languages_0040comma_007b_007d-data_002ddriven-vs_002e-procedural-74"></a><a
name="index-_0040command_007bawk_007d-programs-75"></a>Programs in <samp><span
class="command">awk</span></samp> are different from programs in most other
languages,
-because <samp><span class="command">awk</span></samp> programs are
<dfn>data-driven</dfn>; that is, you describe
-the data you want to work with and then what to do when you find it.
-Most other languages are <dfn>procedural</dfn>; you have to describe, in great
-detail, every step the program is to take. When working with procedural
-languages, it is usually much
-harder to clearly describe the data your program will process.
-For this reason, <samp><span class="command">awk</span></samp> programs are
often refreshingly easy to
-read and write.
-
- <p><a name="index-program_002c-definition-of-76"></a><a
name="index-rule_002c-definition-of-77"></a>When you run <samp><span
class="command">awk</span></samp>, you specify an <samp><span
class="command">awk</span></samp> <dfn>program</dfn> that
-tells <samp><span class="command">awk</span></samp> what to do. The program
consists of a series of
-<dfn>rules</dfn>. (It may also contain <dfn>function definitions</dfn>,
-an advanced feature that we will ignore for now.
-See <a href="#User_002ddefined">User-defined</a>.) Each rule specifies one
-pattern to search for and one action to perform
-upon finding the pattern.
-
- <p>Syntactically, a rule consists of a pattern followed by an action. The
-action is enclosed in curly braces to separate it from the pattern.
-Newlines usually separate rules. Therefore, an <samp><span
class="command">awk</span></samp>
-program looks like this:
-
-<pre class="example"> <var>pattern</var> { <var>action</var> }
- <var>pattern</var> { <var>action</var> }
- ...
-</pre>
- <ul class="menu">
-<li><a accesskey="1" href="#Running-gawk">Running gawk</a>:
How to run <samp><span class="command">gawk</span></samp> programs; includes
- command-line syntax.
-<li><a accesskey="2" href="#Sample-Data-Files">Sample Data Files</a>:
Sample data files for use in the <samp><span class="command">awk</span></samp>
- programs illustrated in this Web page.
-<li><a accesskey="3" href="#Very-Simple">Very Simple</a>: A
very simple example.
-<li><a accesskey="4" href="#Two-Rules">Two Rules</a>: A
less simple one-line example using two
- rules.
-<li><a accesskey="5" href="#More-Complex">More Complex</a>: A
more complex example.
-<li><a accesskey="6" href="#Statements_002fLines">Statements/Lines</a>:
Subdividing or combining statements into
- lines.
-<li><a accesskey="7" href="#Other-Features">Other Features</a>:
Other Features of <samp><span class="command">awk</span></samp>.
-<li><a accesskey="8" href="#When">When</a>: When to
use <samp><span class="command">gawk</span></samp> and when to use
- other things.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Running-gawk"></a>Next: <a rel="next" accesskey="n"
href="#Sample-Data-Files">Sample Data Files</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.1 How to Run <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-running-78"></a>There are
several ways to run an <samp><span class="command">awk</span></samp> program.
If the program is
-short, it is easiest to include it in the command that runs <samp><span
class="command">awk</span></samp>,
-like this:
-
-<pre class="example"> awk '<var>program</var>' <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p><a name="index-command-line_002c-formats-79"></a>When the program is
long, it is usually more convenient to put it in a file
-and run it with a command like this:
-
-<pre class="example"> awk -f <var>program-file</var>
<var>input-file1</var> <var>input-file2</var> ...
-</pre>
- <p>This section discusses both mechanisms, along with several
-variations of each.
-
-<ul class="menu">
-<li><a accesskey="1" href="#One_002dshot">One-shot</a>:
Running a short throwaway <samp><span class="command">awk</span></samp>
- program.
-<li><a accesskey="2" href="#Read-Terminal">Read Terminal</a>:
Using no input files (input from terminal
- instead).
-<li><a accesskey="3" href="#Long">Long</a>: Putting
permanent <samp><span class="command">awk</span></samp> programs in
- files.
-<li><a accesskey="4" href="#Executable-Scripts">Executable Scripts</a>:
Making self-contained <samp><span class="command">awk</span></samp>
programs.
-<li><a accesskey="5" href="#Comments">Comments</a>: Adding
documentation to <samp><span class="command">gawk</span></samp>
- programs.
-<li><a accesskey="6" href="#Quoting">Quoting</a>: More
discussion of shell quoting issues.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="One_002dshot"></a>Next: <a rel="next" accesskey="n"
href="#Read-Terminal">Read Terminal</a>,
-Up: <a rel="up" accesskey="u" href="#Running-gawk">Running gawk</a>
-<br>
-</div>
-
-<h4 class="subsection">1.1.1 One-Shot Throwaway <samp><span
class="command">awk</span></samp> Programs</h4>
-
-<p>Once you are familiar with <samp><span class="command">awk</span></samp>,
you will often type in simple
-programs the moment you want to use them. Then you can write the
-program as the first argument of the <samp><span
class="command">awk</span></samp> command, like this:
-
-<pre class="example"> awk '<var>program</var>' <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p class="noindent">where <var>program</var> consists of a series of
<var>patterns</var> and
-<var>actions</var>, as described earlier.
-
- <p><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029-80"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029-81"></a>This
command format instructs the <dfn>shell</dfn>, or command interpreter,
-to start <samp><span class="command">awk</span></samp> and use the
<var>program</var> to process records in the
-input file(s). There are single quotes around <var>program</var> so
-the shell won't interpret any <samp><span class="command">awk</span></samp>
characters as special shell
-characters. The quotes also cause the shell to treat all of
<var>program</var> as
-a single argument for <samp><span class="command">awk</span></samp>, and allow
<var>program</var> to be more
-than one line long.
-
- <p><a name="index-shells_002c-scripts-82"></a><a
name="index-_0040command_007bawk_007d-programs_002c-running_002c-from-shell-scripts-83"></a>This
format is also useful for running short or medium-sized <samp><span
class="command">awk</span></samp>
-programs from shell scripts, because it avoids the need for a separate
-file for the <samp><span class="command">awk</span></samp> program. A
self-contained shell script is more
-reliable because there are no other files to misplace.
-
- <p><a href="#Very-Simple">Very Simple</a>,
-later in this chapter,
-presents several short,
-self-contained programs.
-
-<!-- Removed for gawk 3.1, doesn't really add anything here. -->
-<div class="node">
-<p><hr>
-<a name="Read-Terminal"></a>Next: <a rel="next" accesskey="n"
href="#Long">Long</a>,
-Previous: <a rel="previous" accesskey="p"
href="#One_002dshot">One-shot</a>,
-Up: <a rel="up" accesskey="u" href="#Running-gawk">Running gawk</a>
-<br>
-</div>
-
-<h4 class="subsection">1.1.2 Running <samp><span
class="command">awk</span></samp> Without Input Files</h4>
-
-<p><a name="index-standard-input-84"></a><a
name="index-input_002c-standard-85"></a><a
name="index-input-files_002c-running-_0040command_007bawk_007d-without-86"></a>You
can also run <samp><span class="command">awk</span></samp> without any input
files. If you type the
-following command line:
-
-<pre class="example"> awk '<var>program</var>'
-</pre>
- <p class="noindent"><samp><span class="command">awk</span></samp> applies
the <var>program</var> to the <dfn>standard input</dfn>,
-which usually means whatever you type on the terminal. This continues
-until you indicate end-of-file by typing <kbd>Ctrl-d</kbd>.
-(On other operating systems, the end-of-file character may be different.
-For example, on OS/2 and MS-DOS, it is <kbd>Ctrl-z</kbd>.)
-
- <p><a name="index-files_002c-input_002c-See-input-files-87"></a><a
name="index-input-files_002c-running-_0040command_007bawk_007d-without-88"></a><a
name="index-_0040command_007bawk_007d-programs_002c-running_002c-without-input-files-89"></a>As
an example, the following program prints a friendly piece of advice
-(from Douglas Adams's <cite>The Hitchhiker's Guide to the Galaxy</cite>),
-to keep you from worrying about the complexities of computer programming
-(<code>BEGIN</code> is a feature we haven't discussed yet):
-
-<pre class="example"> $ awk "BEGIN { print \"Don't Panic!\" }"
- -| Don't Panic!
-</pre>
- <p><a name="index-quoting-90"></a><a
name="index-double-quote-_0028_0040code_007b_0022_007d_0029-91"></a><a
name="index-_0040code_007b_0022_007d-_0028double-quote_0029-92"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029-93"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029-94"></a>This program
does not read any input. The `<samp><span class="samp">\</span></samp>' before
each of the
-inner double quotes is necessary because of the shell's quoting
-rules—in particular because it mixes both single quotes and
-double quotes.<a rel="footnote" href="#fn-6" name="fnd-6"><sup>6</sup></a>
-
- <p>This next simple <samp><span class="command">awk</span></samp> program
-emulates the <samp><span class="command">cat</span></samp> utility; it copies
whatever you type on the
-keyboard to its standard output (why this works is explained shortly).
-
-<pre class="example"> $ awk '{ print }'
- Now is the time for all good men
- -| Now is the time for all good men
- to come to the aid of their country.
- -| to come to the aid of their country.
- Four score and seven years ago, ...
- -| Four score and seven years ago, ...
- What, me worry?
- -| What, me worry?
- <kbd>Ctrl-d</kbd>
-</pre>
- <div class="node">
-<p><hr>
-<a name="Long"></a>Next: <a rel="next" accesskey="n"
href="#Executable-Scripts">Executable Scripts</a>,
-Previous: <a rel="previous" accesskey="p" href="#Read-Terminal">Read
Terminal</a>,
-Up: <a rel="up" accesskey="u" href="#Running-gawk">Running gawk</a>
-<br>
-</div>
-
-<h4 class="subsection">1.1.3 Running Long Programs</h4>
-
-<p><a name="index-_0040command_007bawk_007d-programs_002c-running-95"></a><a
name="index-_0040command_007bawk_007d-programs_002c-lengthy-96"></a><a
name="index-files_002c-_0040command_007bawk_007d-programs-in-97"></a>Sometimes
your <samp><span class="command">awk</span></samp> programs can be very long.
In this case, it is
-more convenient to put the program into a separate file. In order to tell
-<samp><span class="command">awk</span></samp> to use that file for its
program, you type:
-
-<pre class="example"> awk -f <var>source-file</var> <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p><a name="index-_0040code_007b_002df_007d-option-98"></a><a
name="index-command-line_002c-options-99"></a><a
name="index-options_002c-command_002dline-100"></a>The <samp><span
class="option">-f</span></samp> instructs the <samp><span
class="command">awk</span></samp> utility to get the <samp><span
class="command">awk</span></samp> program
-from the file <var>source-file</var>. Any file name can be used for
-<var>source-file</var>. For example, you could put the program:
-
-<pre class="example"> BEGIN { print "Don't Panic!" }
-</pre>
- <p class="noindent">into the file <samp><span
class="file">advice</span></samp>. Then this command:
-
-<pre class="example"> awk -f advice
-</pre>
- <p class="noindent">does the same thing as this one:
-
-<pre class="example"> awk "BEGIN { print \"Don't Panic!\" }"
-</pre>
- <p><a name="index-quoting-101"></a>This was explained earlier
-(see <a href="#Read-Terminal">Read Terminal</a>).
-Note that you don't usually need single quotes around the file name that you
-specify with <samp><span class="option">-f</span></samp>, because most file
names don't contain any of the shell's
-special characters. Notice that in <samp><span
class="file">advice</span></samp>, the <samp><span
class="command">awk</span></samp>
-program did not have single quotes around it. The quotes are only needed
-for programs that are provided on the <samp><span
class="command">awk</span></samp> command line.
-
-<!-- STARTOFRANGE sq1x -->
-<p><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029-102"></a><!--
STARTOFRANGE qs2x -->
-<a name="index-_0040code_007b_0027_007d-_0028single-quote_0029-103"></a>If you
want to identify your <samp><span class="command">awk</span></samp> program
files clearly as such,
-you can add the extension <samp><span class="file">.awk</span></samp> to the
file name. This doesn't
-affect the execution of the <samp><span class="command">awk</span></samp>
program but it does make
-“housekeeping” easier.
-
-<div class="node">
-<p><hr>
-<a name="Executable-Scripts"></a>Next: <a rel="next" accesskey="n"
href="#Comments">Comments</a>,
-Previous: <a rel="previous" accesskey="p" href="#Long">Long</a>,
-Up: <a rel="up" accesskey="u" href="#Running-gawk">Running gawk</a>
-<br>
-</div>
-
-<h4 class="subsection">1.1.4 Executable <samp><span
class="command">awk</span></samp> Programs</h4>
-
-<p><a name="index-_0040command_007bawk_007d-programs-104"></a><a
name="index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-105"></a><a
name="index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-106"></a><a
name="index-Unix_002c-_0040command_007bawk_007d-scripts-and-107"></a><a
name="index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-108"></a><a
name="index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-109"></a>
-Once you have learned <samp><span class="command">awk</span></samp>, you may
want to write self-contained
-<samp><span class="command">awk</span></samp> scripts, using the `<samp><span
class="samp">#!</span></samp>' script mechanism. You can do
-this on many Unix systems<a rel="footnote" href="#fn-7"
name="fnd-7"><sup>7</sup></a> as well as on the GNU system.
-For example, you could update the file <samp><span
class="file">advice</span></samp> to look like this:
-
-<pre class="example"> #! /bin/awk -f
-
- BEGIN { print "Don't Panic!" }
-</pre>
- <p class="noindent">After making this file executable (with the <samp><span
class="command">chmod</span></samp> utility),
-simply type `<samp><span class="samp">advice</span></samp>'
-at the shell and the system arranges to run <samp><span
class="command">awk</span></samp><a rel="footnote" href="#fn-8"
name="fnd-8"><sup>8</sup></a> as if you had
-typed `<samp><span class="samp">awk -f advice</span></samp>':
-
-<pre class="example"> $ chmod +x advice
- $ advice
- -| Don't Panic!
-</pre>
- <p class="noindent">(We assume you have the current directory in your
shell's search
-path variable (typically <code>$PATH</code>). If not, you may need
-to type `<samp><span class="samp">./advice</span></samp>' at the shell.)
-
- <p>Self-contained <samp><span class="command">awk</span></samp> scripts are
useful when you want to write a
-program that users can invoke without their having to know that the program is
-written in <samp><span class="command">awk</span></samp>.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Portability Issues with `<samp><span
class="samp">#!</span></samp>'</h4>
-
-<p><a
name="index-portability_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-110"></a>
-Some systems limit the length of the interpreter name to 32 characters.
-Often, this can be dealt with by using a symbolic link.
-
- <p>You should not put more than one argument on the `<samp><span
class="samp">#!</span></samp>'
-line after the path to <samp><span class="command">awk</span></samp>. It does
not work. The operating system
-treats the rest of the line as a single argument and passes it to <samp><span
class="command">awk</span></samp>.
-Doing this leads to confusing behavior—most likely a usage diagnostic
-of some sort from <samp><span class="command">awk</span></samp>.
-
- <p><a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-portability-and-111"></a><a
name="index-portability_002c-_0040code_007bARGV_007d-variable-112"></a>Finally,
-the value of <code>ARGV[0]</code>
-(see <a href="#Built_002din-Variables">Built-in Variables</a>)
-varies depending upon your operating system.
-Some systems put `<samp><span class="samp">awk</span></samp>' there, some put
the full pathname
-of <samp><span class="command">awk</span></samp> (such as <samp><span
class="file">/bin/awk</span></samp>), and some put the name
-of your script (`<samp><span class="samp">advice</span></samp>'). Don't rely
on the value of <code>ARGV[0]</code>
-to provide your script name.
-
-<div class="node">
-<p><hr>
-<a name="Comments"></a>Next: <a rel="next" accesskey="n"
href="#Quoting">Quoting</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Executable-Scripts">Executable Scripts</a>,
-Up: <a rel="up" accesskey="u" href="#Running-gawk">Running gawk</a>
-<br>
-</div>
-
-<h4 class="subsection">1.1.5 Comments in <samp><span
class="command">awk</span></samp> Programs</h4>
-
-<p><a
name="index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-commenting-113"></a><a
name="index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-commenting-114"></a><a
name="index-commenting-115"></a><a
name="index-_0040command_007bawk_007d-programs_002c-documenting-116"></a>
-A <dfn>comment</dfn> is some text that is included in a program for the sake
-of human readers; it is not really an executable part of the program. Comments
-can explain what the program does and how it works. Nearly all
-programming languages have provisions for comments, as programs are
-typically hard to understand without them.
-
- <p>In the <samp><span class="command">awk</span></samp> language, a comment
starts with the sharp sign
-character (`<samp><span class="samp">#</span></samp>') and continues to the
end of the line.
-The `<samp><span class="samp">#</span></samp>' does not have to be the first
character on the line. The
-<samp><span class="command">awk</span></samp> language ignores the rest of a
line following a sharp sign.
-For example, we could have put the following into <samp><span
class="file">advice</span></samp>:
-
-<pre class="example"> # This program prints a nice friendly message. It
helps
- # keep novice users from being afraid of the computer.
- BEGIN { print "Don't Panic!" }
-</pre>
- <p>You can put comment lines into keyboard-composed throwaway <samp><span
class="command">awk</span></samp>
-programs, but this usually isn't very useful; the purpose of a
-comment is to help you or another person understand the program
-when reading it at a later time.
-
- <p><a name="index-quoting-117"></a><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-vs_002e-apostrophe-118"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-vs_002e-apostrophe-119"></a><strong>Caution:</strong>
As mentioned in
-<a href="#One_002dshot">One-shot</a>,
-you can enclose small to medium programs in single quotes, in order to keep
-your shell scripts self-contained. When doing so, <em>don't</em> put
-an apostrophe (i.e., a single quote) into a comment (or anywhere else
-in your program). The shell interprets the quote as the closing
-quote for the entire program. As a result, usually the shell
-prints a message about mismatched quotes, and if <samp><span
class="command">awk</span></samp> actually
-runs, it will probably print strange messages about syntax errors.
-For example, look at the following:
-
-<pre class="example"> $ awk '{ print "hello" } # let's be cute'
- >
-</pre>
- <p>The shell sees that the first two quotes match, and that
-a new quoted object begins at the end of the command line.
-It therefore prompts with the secondary prompt, waiting for more input.
-With Unix <samp><span class="command">awk</span></samp>, closing the quoted
string produces this result:
-
-<pre class="example"> $ awk '{ print "hello" } # let's be cute'
- > '
- error--> awk: can't open file be
- error--> source line number 1
-</pre>
- <p><a name="index-_0040code_007b_005c_007d-_0028backslash_0029-120"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029-121"></a>Putting a
backslash before the single quote in `<samp><span
class="samp">let's</span></samp>' wouldn't help,
-since backslashes are not special inside single quotes.
-The next subsection describes the shell's quoting rules.
-
-<div class="node">
-<p><hr>
-<a name="Quoting"></a>Previous: <a rel="previous" accesskey="p"
href="#Comments">Comments</a>,
-Up: <a rel="up" accesskey="u" href="#Running-gawk">Running gawk</a>
-<br>
-</div>
-
-<h4 class="subsection">1.1.6 Shell-Quoting Issues</h4>
-
-<p><a name="index-quoting_002c-rules-for-122"></a>
-For short to medium length <samp><span class="command">awk</span></samp>
programs, it is most convenient
-to enter the program on the <samp><span class="command">awk</span></samp>
command line.
-This is best done by enclosing the entire program in single quotes.
-This is true whether you are entering the program interactively at
-the shell prompt, or writing it as part of a larger shell script:
-
-<pre class="example"> awk '<var>program text</var>' <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p><a name="index-shells_002c-quoting_002c-rules-for-123"></a><a
name="index-Bourne-shell_002c-quoting-rules-for-124"></a>Once you are working
with the shell, it is helpful to have a basic
-knowledge of shell quoting rules. The following rules apply only to
-POSIX-compliant, Bourne-style shells (such as <samp><span
class="command">bash</span></samp>, the GNU Bourne-Again
-Shell). If you use <samp><span class="command">csh</span></samp>, you're on
your own.
-
- <ul>
-<li>Quoted items can be concatenated with nonquoted items as well as with other
-quoted items. The shell turns everything into one argument for
-the command.
-
- <li>Preceding any single character with a backslash (`<samp><span
class="samp">\</span></samp>') quotes
-that character. The shell removes the backslash and passes the quoted
-character on to the command.
-
- <li><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029-125"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029-126"></a><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029-127"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029-128"></a>Single
quotes protect everything between the opening and closing quotes.
-The shell does no interpretation of the quoted text, passing it on verbatim
-to the command.
-It is <em>impossible</em> to embed a single quote inside single-quoted text.
-Refer back to
-<a href="#Comments">Comments</a>,
-for an example of what happens if you try.
-
- <li><a
name="index-double-quote-_0028_0040code_007b_0022_007d_0029-129"></a><a
name="index-_0040code_007b_0022_007d-_0028double-quote_0029-130"></a>Double
quotes protect most things between the opening and closing quotes.
-The shell does at least variable and command substitution on the quoted text.
-Different shells may do additional kinds of processing on double-quoted text.
-
- <p>Since certain characters within double-quoted text are processed by
the shell,
-they must be <dfn>escaped</dfn> within the text. Of note are the characters
-`<samp><span class="samp">$</span></samp>', `<samp><span
class="samp">`</span></samp>', `<samp><span class="samp">\</span></samp>', and
`<samp><span class="samp">"</span></samp>', all of which must be preceded by
-a backslash within double-quoted text if they are to be passed on literally
-to the program. (The leading backslash is stripped first.)
-Thus, the example seen
-previously
-in <a href="#Read-Terminal">Read Terminal</a>,
-is applicable:
-
- <pre class="example"> $ awk "BEGIN { print \"Don't Panic!\" }"
- -| Don't Panic!
- </pre>
- <p><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-with-double-quotes-131"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-with-double-quotes-132"></a>Note
that the single quote is not special within double quotes.
-
- <li>Null strings are removed when they occur as part of a non-null
-command-line argument, while explicit non-null objects are kept.
-For example, to specify that the field separator <code>FS</code> should
-be set to the null string, use:
-
- <pre class="example"> awk -F "" '<var>program</var>'
<var>files</var> # correct
- </pre>
- <p class="noindent"><a
name="index-null-strings_002c-quoting-and-133"></a>Don't use this:
-
- <pre class="example"> awk -F"" '<var>program</var>'
<var>files</var> # wrong!
- </pre>
- <p class="noindent">In the second case, <samp><span
class="command">awk</span></samp> will attempt to use the text of the program
-as the value of <code>FS</code>, and the first file name as the text of the
program!
-This results in syntax errors at best, and confusing behavior at worst.
-</ul>
-
- <p><a name="index-quoting_002c-tricks-for-134"></a>Mixing single and double
quotes is difficult. You have to resort
-to shell quoting tricks, like this:
-
-<pre class="example"> $ awk 'BEGIN { print "Here is a single quote
<'"'"'>" }'
- -| Here is a single quote <'>
-</pre>
- <p class="noindent">This program consists of three concatenated quoted
strings. The first and the
-third are single-quoted, the second is double-quoted.
-
- <p>This can be “simplified” to:
-
-<pre class="example"> $ awk 'BEGIN { print "Here is a single quote
<'\''>" }'
- -| Here is a single quote <'>
-</pre>
- <p class="noindent">Judge for yourself which of these two is the more
readable.
-
- <p>Another option is to use double quotes, escaping the embedded,
<samp><span class="command">awk</span></samp>-level
-double quotes:
-
-<pre class="example"> $ awk "BEGIN { print \"Here is a single quote
<'>\" }"
- -| Here is a single quote <'>
-</pre>
- <p class="noindent"><!-- ENDOFRANGE sq1x -->
-<!-- ENDOFRANGE qs2x -->
-This option is also painful, because double quotes, backslashes, and dollar
signs
-are very common in <samp><span class="command">awk</span></samp> programs.
-
- <p>A third option is to use the octal escape sequence equivalents for the
-single- and double-quote characters, like so:
-
-<pre class="example"> $ awk 'BEGIN { print "Here is a single quote
<\47>" }'
- -| Here is a single quote <'>
- $ awk 'BEGIN { print "Here is a double quote <\42>" }'
- -| Here is a double quote <">
-</pre>
- <p class="noindent">This works nicely, except that you should comment
clearly what the
-escapes mean.
-
- <p>A fourth option is to use command-line variable assignment, like this:
-
-<pre class="example"> $ awk -v sq="'" 'BEGIN { print "Here is a single
quote <" sq ">" }'
- -| Here is a single quote <'>
-</pre>
- <p>If you really need both single and double quotes in your <samp><span
class="command">awk</span></samp>
-program, it is probably best to move it into a separate file, where
-the shell won't be part of the picture, and you can say what you mean.
-
-<div class="node">
-<p><hr>
-<a name="Sample-Data-Files"></a>Next: <a rel="next" accesskey="n"
href="#Very-Simple">Very Simple</a>,
-Previous: <a rel="previous" accesskey="p" href="#Running-gawk">Running
gawk</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.2 Data Files for the Examples</h3>
-
-<!-- For gawk >= 3.2, update these data files. No-one has such slow modems! -->
-<p><a name="index-input-files_002c-examples-135"></a><a
name="index-_0040code_007bBBS_002dlist_007d-file-136"></a>Many of the examples
in this Web page take their input from two sample
-data files. The first, <samp><span class="file">BBS-list</span></samp>,
represents a list of
-computer bulletin board systems together with information about those systems.
-The second data file, called <samp><span
class="file">inventory-shipped</span></samp>, contains
-information about monthly shipments. In both files,
-each line is considered to be one <dfn>record</dfn>.
-
- <p>In the data file <samp><span class="file">BBS-list</span></samp>, each
record contains the name of a computer
-bulletin board, its phone number, the board's baud rate(s), and a code for
-the number of hours it is operational. An `<samp><span
class="samp">A</span></samp>' in the last column
-means the board operates 24 hours a day. A `<samp><span
class="samp">B</span></samp>' in the last
-column means the board only operates on evening and weekend hours.
-A `<samp><span class="samp">C</span></samp>' means the board operates only on
weekends:
-
-<!-- 2e: Update the baud rates to reflect today's faster modems -->
-<pre class="example"> <!-- system if test ! -d eg ; then mkdir eg
; fi -->
- <!-- system if test ! -d eg/lib ; then mkdir eg/lib ; fi -->
- <!-- system if test ! -d eg/data ; then mkdir eg/data ; fi -->
- <!-- system if test ! -d eg/prog ; then mkdir eg/prog ; fi -->
- <!-- system if test ! -d eg/misc ; then mkdir eg/misc ; fi -->
- <!-- file eg/data/BBS-list -->
- aardvark 555-5553 1200/300 B
- alpo-net 555-3412 2400/1200/300 A
- barfly 555-7685 1200/300 A
- bites 555-1675 2400/1200/300 A
- camelot 555-0542 300 C
- core 555-2912 1200/300 C
- fooey 555-1234 2400/1200/300 B
- foot 555-6699 1200/300 B
- macfoo 555-6480 1200/300 A
- sdace 555-3430 2400/1200/300 A
- sabafoo 555-2127 1200/300 C
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007binventory_002dshipped_007d-file-137"></a>The data
file <samp><span class="file">inventory-shipped</span></samp> represents
-information about shipments during the year.
-Each record contains the month, the number
-of green crates shipped, the number of red boxes shipped, the number of
-orange bags shipped, and the number of blue packages shipped,
-respectively. There are 16 entries, covering the 12 months of last year
-and the first four months of the current year.
-
-<pre class="example"> <!-- file eg/data/inventory-shipped -->
- Jan 13 25 15 115
- Feb 15 32 24 226
- Mar 15 24 34 228
- Apr 31 52 63 420
- May 16 34 29 208
- Jun 31 42 75 492
- Jul 24 34 67 436
- Aug 15 34 47 316
- Sep 13 55 37 277
- Oct 29 54 68 525
- Nov 20 87 82 577
- Dec 17 35 61 401
-
- Jan 21 36 64 620
- Feb 26 58 80 652
- Mar 24 75 70 495
- Apr 21 70 74 514
- <!-- endfile -->
-</pre>
- <div class="node">
-<p><hr>
-<a name="Very-Simple"></a>Next: <a rel="next" accesskey="n"
href="#Two-Rules">Two Rules</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Sample-Data-Files">Sample Data Files</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.3 Some Simple Examples</h3>
-
-<p>The following command runs a simple <samp><span
class="command">awk</span></samp> program that searches the
-input file <samp><span class="file">BBS-list</span></samp> for the character
string `<samp><span class="samp">foo</span></samp>' (a
-grouping of characters is usually called a <dfn>string</dfn>;
-the term <dfn>string</dfn> is based on similar usage in English, such
-as “a string of pearls,” or “a string of cars in a
train”):
-
-<pre class="example"> awk '/foo/ { print $0 }' BBS-list
-</pre>
- <p class="noindent">When lines containing `<samp><span
class="samp">foo</span></samp>' are found, they are printed because
-`<samp><span class="samp">print $0</span></samp>'<!-- /@w --> means print
the current line. (Just `<samp><span class="samp">print</span></samp>' by
-itself means the same thing, so we could have written that
-instead.)
-
- <p>You will notice that slashes (`<samp><span
class="samp">/</span></samp>') surround the string `<samp><span
class="samp">foo</span></samp>'
-in the <samp><span class="command">awk</span></samp> program. The slashes
indicate that `<samp><span class="samp">foo</span></samp>'
-is the pattern to search for. This type of pattern is called a
-<dfn>regular expression</dfn>, which is covered in more detail later
-(see <a href="#Regexp">Regexp</a>).
-The pattern is allowed to match parts of words.
-There are
-single quotes around the <samp><span class="command">awk</span></samp> program
so that the shell won't
-interpret any of it as special shell characters.
-
- <p>Here is what this program prints:
-
-<pre class="example"> $ awk '/foo/ { print $0 }' BBS-list
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sabafoo 555-2127 1200/300 C
-</pre>
- <p><a name="index-actions_002c-default-138"></a><a
name="index-patterns_002c-default-139"></a>In an <samp><span
class="command">awk</span></samp> rule, either the pattern or the action can be
omitted,
-but not both. If the pattern is omitted, then the action is performed
-for <em>every</em> input line. If the action is omitted, the default
-action is to print all lines that match the pattern.
-
- <p><a name="index-actions_002c-empty-140"></a>Thus, we could leave out the
action (the <code>print</code> statement and the curly
-braces) in the previous example and the result would be the same: all
-lines matching the pattern `<samp><span class="samp">foo</span></samp>' are
printed. By comparison,
-omitting the <code>print</code> statement but retaining the curly braces makes
an
-empty action that does nothing (i.e., no lines are printed).
-
- <p><a
name="index-_0040command_007bawk_007d-programs_002c-one_002dline-examples-141"></a>Many
practical <samp><span class="command">awk</span></samp> programs are just a
line or two. Following is a
-collection of useful, short programs to get you started. Some of these
-programs contain constructs that haven't been covered yet. (The description
-of the program will give you a good idea of what is going on, but please
-read the rest of the Web page to become an <samp><span
class="command">awk</span></samp> expert!)
-Most of the examples use a data file named <samp><span
class="file">data</span></samp>. This is just a
-placeholder; if you use these programs yourself, substitute
-your own file names for <samp><span class="file">data</span></samp>.
-For future reference, note that there is often more than
-one way to do things in <samp><span class="command">awk</span></samp>. At
some point, you may want
-to look back at these examples and see if
-you can come up with different ways to do the same things shown here:
-
- <ul>
-<li>Print the length of the longest input line:
-
- <pre class="example"> awk '{ if (length($0) > max) max =
length($0) }
- END { print max }' data
- </pre>
- <li>Print every line that is longer than 80 characters:
-
- <pre class="example"> awk 'length($0) > 80' data
- </pre>
- <p>The sole rule has a relational expression as its pattern and it has no
-action—so the default action, printing the record, is used.
-
- <p><a name="index-_0040command_007bexpand_007d-utility-142"></a><li>Print
the length of the longest line in <samp><span class="file">data</span></samp>:
-
- <pre class="example"> expand data | awk '{ if (x < length())
x = length() }
- END { print "maximum line length is " x }'
- </pre>
- <p>The input is processed by the <samp><span
class="command">expand</span></samp> utility to change tabs
-into spaces, so the widths compared are actually the right-margin columns.
-
- <li>Print every line that has at least one field:
-
- <pre class="example"> awk 'NF > 0' data
- </pre>
- <p>This is an easy way to delete blank lines from a file (or rather, to
-create a new file similar to the old file but from which the blank lines
-have been removed).
-
- <li>Print seven random numbers from 0 to 100, inclusive:
-
- <pre class="example"> awk 'BEGIN { for (i = 1; i <= 7; i++)
- print int(101 * rand()) }'
- </pre>
- <li>Print the total number of bytes used by <var>files</var>:
-
- <pre class="example"> ls -l <var>files</var> | awk '{ x += $5 }
- END { print "total bytes: " x }'
- </pre>
- <li>Print the total number of kilobytes used by <var>files</var>:
-
- <!-- Don't use \ continuation, not discussed yet -->
-<pre class="example"> ls -l <var>files</var> | awk '{ x += $5 }
- END { print "total K-bytes: " (x + 1023)/1024 }'
- </pre>
- <li>Print a sorted list of the login names of all users:
-
- <pre class="example"> awk -F: '{ print $1 }' /etc/passwd | sort
- </pre>
- <li>Count the lines in a file:
-
- <pre class="example"> awk 'END { print NR }' data
- </pre>
- <li>Print the even-numbered lines in the data file:
-
- <pre class="example"> awk 'NR % 2 == 0' data
- </pre>
- <p>If you use the expression `<samp><span class="samp">NR % 2 ==
1</span></samp>' instead,
-the program would print the odd-numbered lines.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Two-Rules"></a>Next: <a rel="next" accesskey="n"
href="#More-Complex">More Complex</a>,
-Previous: <a rel="previous" accesskey="p" href="#Very-Simple">Very
Simple</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.4 An Example with Two Rules</h3>
-
-<p><a name="index-_0040command_007bawk_007d-programs-143"></a>
-The <samp><span class="command">awk</span></samp> utility reads the input
files one line at a
-time. For each line, <samp><span class="command">awk</span></samp> tries the
patterns of each of the rules.
-If several patterns match, then several actions are run in the order in
-which they appear in the <samp><span class="command">awk</span></samp>
program. If no patterns match, then
-no actions are run.
-
- <p>After processing all the rules that match the line (and perhaps there
are none),
-<samp><span class="command">awk</span></samp> reads the next line. (However,
-see <a href="#Next-Statement">Next Statement</a>,
-and also see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-This continues until the program reaches the end of the file.
-For example, the following <samp><span class="command">awk</span></samp>
program contains two rules:
-
-<pre class="example"> /12/ { print $0 }
- /21/ { print $0 }
-</pre>
- <p class="noindent">The first rule has the string `<samp><span
class="samp">12</span></samp>' as the
-pattern and `<samp><span class="samp">print $0</span></samp>' as the action.
The second rule has the
-string `<samp><span class="samp">21</span></samp>' as the pattern and also has
`<samp><span class="samp">print $0</span></samp>' as the
-action. Each rule's action is enclosed in its own pair of braces.
-
- <p>This program prints every line that contains the string
-`<samp><span class="samp">12</span></samp>' <em>or</em> the string
`<samp><span class="samp">21</span></samp>'. If a line contains both
-strings, it is printed twice, once by each rule.
-
- <p>This is what happens if we run this program on our two sample data files,
-<samp><span class="file">BBS-list</span></samp> and <samp><span
class="file">inventory-shipped</span></samp>:
-
-<pre class="example"> $ awk '/12/ { print $0 }
- > /21/ { print $0 }' BBS-list inventory-shipped
- -| aardvark 555-5553 1200/300 B
- -| alpo-net 555-3412 2400/1200/300 A
- -| barfly 555-7685 1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| core 555-2912 1200/300 C
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sdace 555-3430 2400/1200/300 A
- -| sabafoo 555-2127 1200/300 C
- -| sabafoo 555-2127 1200/300 C
- -| Jan 21 36 64 620
- -| Apr 21 70 74 514
-</pre>
- <p class="noindent">Note how the line beginning with `<samp><span
class="samp">sabafoo</span></samp>'
-in <samp><span class="file">BBS-list</span></samp> was printed twice, once for
each rule.
-
-<div class="node">
-<p><hr>
-<a name="More-Complex"></a>Next: <a rel="next" accesskey="n"
href="#Statements_002fLines">Statements/Lines</a>,
-Previous: <a rel="previous" accesskey="p" href="#Two-Rules">Two Rules</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.5 A More Complex Example</h3>
-
-<p>Now that we've mastered some simple tasks, let's look at
-what typical <samp><span class="command">awk</span></samp>
-programs do. This example shows how <samp><span
class="command">awk</span></samp> can be used to
-summarize, select, and rearrange the output of another utility. It uses
-features that haven't been covered yet, so don't worry if you don't
-understand all the details:
-
-<pre class="example"> ls -l | awk '$6 == "Nov" { sum += $5 }
- END { print sum }'
-</pre>
- <p><a
name="index-_0040command_007bcsh_007d-utility_002c-backslash-continuation-and-144"></a><a
name="index-_0040command_007bls_007d-utility-145"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-146"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-147"></a>This
command prints the total number of bytes in all the files in the
-current directory that were last modified in November (of any year).
-<a rel="footnote" href="#fn-9" name="fnd-9"><sup>9</sup></a>
-The `<samp><span class="samp">ls -l</span></samp>'<!-- /@w --> part of
this example is a system command that gives
-you a listing of the files in a directory, including each file's size and the
date
-the file was last modified. Its output looks like this:
-
-<pre class="example"> -rw-r--r-- 1 arnold user 1933 Nov 7 13:05
Makefile
- -rw-r--r-- 1 arnold user 10809 Nov 7 13:03 awk.h
- -rw-r--r-- 1 arnold user 983 Apr 13 12:14 awk.tab.h
- -rw-r--r-- 1 arnold user 31869 Jun 15 12:20 awk.y
- -rw-r--r-- 1 arnold user 22414 Nov 7 13:03 awk1.c
- -rw-r--r-- 1 arnold user 37455 Nov 7 13:03 awk2.c
- -rw-r--r-- 1 arnold user 27511 Dec 9 13:07 awk3.c
- -rw-r--r-- 1 arnold user 7989 Nov 7 13:03 awk4.c
-</pre>
- <p class="noindent"><a
name="index-line-continuations_002c-with-C-shell-148"></a>The first field
contains read-write permissions, the second field contains
-the number of links to the file, and the third field identifies the owner of
-the file. The fourth field identifies the group of the file.
-The fifth field contains the size of the file in bytes. The
-sixth, seventh, and eighth fields contain the month, day, and time,
-respectively, that the file was last modified. Finally, the ninth field
-contains the name of the file.<a rel="footnote" href="#fn-10"
name="fnd-10"><sup>10</sup></a>
-
-<!-- @cindex automatic initialization -->
-<p><a name="index-initialization_002c-automatic-149"></a>The `<samp><span
class="samp">$6 == "Nov"</span></samp>' in our <samp><span
class="command">awk</span></samp> program is an expression that
-tests whether the sixth field of the output from `<samp><span
class="samp">ls -l</span></samp>'<!-- /@w -->
-matches the string `<samp><span class="samp">Nov</span></samp>'. Each time a
line has the string
-`<samp><span class="samp">Nov</span></samp>' for its sixth field, the action
`<samp><span class="samp">sum += $5</span></samp>' is
-performed. This adds the fifth field (the file's size) to the variable
-<code>sum</code>. As a result, when <samp><span
class="command">awk</span></samp> has finished reading all the
-input lines, <code>sum</code> is the total of the sizes of the files whose
-lines matched the pattern. (This works because <samp><span
class="command">awk</span></samp> variables
-are automatically initialized to zero.)
-
- <p>After the last line of output from <samp><span
class="command">ls</span></samp> has been processed, the
-<code>END</code> rule executes and prints the value of <code>sum</code>.
-In this example, the value of <code>sum</code> is 80600.
-
- <p>These more advanced <samp><span class="command">awk</span></samp>
techniques are covered in later sections
-(see <a href="#Action-Overview">Action Overview</a>). Before you can move on
to more
-advanced <samp><span class="command">awk</span></samp> programming, you have
to know how <samp><span class="command">awk</span></samp> interprets
-your input and displays your output. By manipulating fields and using
-<code>print</code> statements, you can produce some very useful and
-impressive-looking reports.
-
-<div class="node">
-<p><hr>
-<a name="Statements_002fLines"></a>Next: <a rel="next" accesskey="n"
href="#Other-Features">Other Features</a>,
-Previous: <a rel="previous" accesskey="p" href="#More-Complex">More
Complex</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.6 <samp><span class="command">awk</span></samp>
Statements Versus Lines</h3>
-
-<p><a name="index-line-breaks-150"></a><a name="index-newlines-151"></a>
-Most often, each line in an <samp><span class="command">awk</span></samp>
program is a separate statement or
-separate rule, like this:
-
-<pre class="example"> awk '/12/ { print $0 }
- /21/ { print $0 }' BBS-list inventory-shipped
-</pre>
- <p><a
name="index-_0040command_007bgawk_007d_002c-newlines-in-152"></a>However,
<samp><span class="command">gawk</span></samp> ignores newlines after any of
the following
-symbols and keywords:
-
-<pre class="example"> , { ? : || && do else
-</pre>
- <p class="noindent">A newline at any other point is considered the end of
the
-statement.<a rel="footnote" href="#fn-11" name="fnd-11"><sup>11</sup></a>
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-153"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-154"></a>If
you would like to split a single statement into two lines at a point
-where a newline would terminate it, you can <dfn>continue</dfn> it by ending
the
-first line with a backslash character (`<samp><span
class="samp">\</span></samp>'). The backslash must be
-the final character on the line in order to be recognized as a continuation
-character. A backslash is allowed anywhere in the statement, even
-in the middle of a string or regular expression. For example:
-
-<pre class="example"> awk '/This regular expression is too long, so
continue it\
- on the next line/ { print $1 }'
-</pre>
- <p class="noindent"><a
name="index-portability_002c-backslash-continuation-and-155"></a>We have
generally not used backslash continuation in the sample programs
-in this Web page. In <samp><span class="command">gawk</span></samp>, there is
no limit on the
-length of a line, so backslash continuation is never strictly necessary;
-it just makes programs more readable. For this same reason, as well as
-for clarity, we have kept most statements short in the sample programs
-presented throughout the Web page. Backslash continuation is
-most useful when your <samp><span class="command">awk</span></samp> program is
in a separate source file
-instead of entered from the command line. You should also note that
-many <samp><span class="command">awk</span></samp> implementations are more
particular about where you
-may use backslash continuation. For example, they may not allow you to
-split a string constant using backslash continuation. Thus, for maximum
-portability of your <samp><span class="command">awk</span></samp> programs, it
is best not to split your
-lines in the middle of a regular expression or a string.
-<!-- 10/2000: gawk, mawk, and current bell labs awk allow it, -->
-<!-- solaris 2.7 nawk does not. Solaris /usr/xpg4/bin/awk does though! sigh.
-->
-
- <p><a name="index-_0040command_007bcsh_007d-utility-156"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-157"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-158"></a><strong>Caution:</strong>
<em>Backslash continuation does not work as described
-with the C shell.</em> It works for <samp><span
class="command">awk</span></samp> programs in files and
-for one-shot programs, <em>provided</em> you are using a POSIX-compliant
-shell, such as the Unix Bourne shell or <samp><span
class="command">bash</span></samp>. But the C shell behaves
-differently! There, you must use two backslashes in a row, followed by
-a newline. Note also that when using the C shell, <em>every</em> newline
-in your awk program must be escaped with a backslash. To illustrate:
-
-<pre class="example"> % awk 'BEGIN { \
- ? print \\
- ? "hello, world" \
- ? }'
- -| hello, world
-</pre>
- <p class="noindent">Here, the `<samp><span class="samp">%</span></samp>'
and `<samp><span class="samp">?</span></samp>' are the C shell's primary and
secondary
-prompts, analogous to the standard shell's `<samp><span
class="samp">$</span></samp>' and `<samp><span class="samp">></span></samp>'.
-
- <p>Compare the previous example to how it is done with a POSIX-compliant
shell:
-
-<pre class="example"> $ awk 'BEGIN {
- > print \
- > "hello, world"
- > }'
- -| hello, world
-</pre>
- <p><samp><span class="command">awk</span></samp> is a line-oriented
language. Each rule's action has to
-begin on the same line as the pattern. To have the pattern and action
-on separate lines, you <em>must</em> use backslash continuation; there
-is no other option.
-
- <p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-comments-and-159"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-comments-and-160"></a><a
name="index-commenting_002c-backslash-continuation-and-161"></a>Another thing
to keep in mind is that backslash continuation and
-comments do not mix. As soon as <samp><span class="command">awk</span></samp>
sees the `<samp><span class="samp">#</span></samp>' that
-starts a comment, it ignores <em>everything</em> on the rest of the
-line. For example:
-
-<pre class="example"> $ gawk 'BEGIN { print "dont panic" # a friendly \
- > BEGIN rule
- > }'
- error--> gawk: cmd. line:2: BEGIN rule
- error--> gawk: cmd. line:2: ^ parse error
-</pre>
- <p class="noindent">In this case, it looks like the backslash would
continue the comment onto the
-next line. However, the backslash-newline combination is never even
-noticed because it is “hidden” inside the comment. Thus, the
-<code>BEGIN</code> is noted as a syntax error.
-
- <p><a name="index-statements_002c-multiple-162"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029-163"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029-164"></a>When
<samp><span class="command">awk</span></samp> statements within one rule are
short, you might want to put
-more than one of them on a line. This is accomplished by separating the
statements
-with a semicolon (`<samp><span class="samp">;</span></samp>').
-This also applies to the rules themselves.
-Thus, the program shown at the start of this section
-could also be written this way:
-
-<pre class="example"> /12/ { print $0 } ; /21/ { print $0 }
-</pre>
- <blockquote>
-<b>NOTE:</b> The requirement that states that rules on the same line must be
-separated with a semicolon was not in the original <samp><span
class="command">awk</span></samp>
-language; it was added for consistency with the treatment of statements
-within an action.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="Other-Features"></a>Next: <a rel="next" accesskey="n"
href="#When">When</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Statements_002fLines">Statements/Lines</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.7 Other Features of <samp><span
class="command">awk</span></samp></h3>
-
-<p><a name="index-variables-165"></a>The <samp><span
class="command">awk</span></samp> language provides a number of predefined, or
-<dfn>built-in</dfn>, variables that your programs can use to get information
-from <samp><span class="command">awk</span></samp>. There are other variables
your program can set
-as well to control how <samp><span class="command">awk</span></samp> processes
your data.
-
- <p>In addition, <samp><span class="command">awk</span></samp> provides a
number of built-in functions for doing
-common computational and string-related operations.
-<samp><span class="command">gawk</span></samp> provides built-in functions for
working with timestamps,
-performing bit manipulation, and for runtime string translation.
-
- <p>As we develop our presentation of the <samp><span
class="command">awk</span></samp> language, we introduce
-most of the variables and many of the functions. They are defined
-systematically in <a href="#Built_002din-Variables">Built-in Variables</a>, and
-<a href="#Built_002din">Built-in</a>.
-
-<div class="node">
-<p><hr>
-<a name="When"></a>Previous: <a rel="previous" accesskey="p"
href="#Other-Features">Other Features</a>,
-Up: <a rel="up" accesskey="u" href="#Getting-Started">Getting Started</a>
-<br>
-</div>
-
-<h3 class="section">1.8 When to Use <samp><span
class="command">awk</span></samp></h3>
-
-<p><a name="index-_0040command_007bawk_007d_002c-uses-for-166"></a>Now that
you've seen some of what <samp><span class="command">awk</span></samp> can do,
-you might wonder how <samp><span class="command">awk</span></samp> could be
useful for you. By using
-utility programs, advanced patterns, field separators, arithmetic
-statements, and other selection criteria, you can produce much more
-complex output. The <samp><span class="command">awk</span></samp> language is
very useful for producing
-reports from large amounts of raw data, such as summarizing information
-from the output of other utility programs like <samp><span
class="command">ls</span></samp>.
-(See <a href="#More-Complex">More Complex</a>.)
-
- <p>Programs written with <samp><span class="command">awk</span></samp> are
usually much smaller than they would
-be in other languages. This makes <samp><span
class="command">awk</span></samp> programs easy to compose and
-use. Often, <samp><span class="command">awk</span></samp> programs can be
quickly composed at your terminal,
-used once, and thrown away. Because <samp><span
class="command">awk</span></samp> programs are interpreted, you
-can avoid the (usually lengthy) compilation part of the typical
-edit-compile-test-debug cycle of software development.
-
- <p>Complex programs have been written in <samp><span
class="command">awk</span></samp>, including a complete
-retargetable assembler for eight-bit microprocessors (see <a
href="#Glossary">Glossary</a>, for
-more information), and a microcode assembler for a special-purpose Prolog
-computer. More recently, <samp><span class="command">gawk</span></samp> was
used for writing a Wiki
-clone.<a rel="footnote" href="#fn-12" name="fnd-12"><sup>12</sup></a>
-While the original <samp><span class="command">awk</span></samp>'s
capabilities were strained by tasks
-of such complexity, modern versions are more capable. Even the Bell
-Labs version of <samp><span class="command">awk</span></samp> has fewer
predefined limits, and those
-that it has are much larger than they used to be.
-
- <p><a
name="index-_0040command_007bawk_007d-programs_002c-complex-167"></a>If you
find yourself writing <samp><span class="command">awk</span></samp> scripts of
more than, say, a few
-hundred lines, you might consider using a different programming
-language. Emacs Lisp is a good choice if you need sophisticated string
-or pattern matching capabilities. The shell is also good at string and
-pattern matching; in addition, it allows powerful use of the system
-utilities. More conventional languages, such as C, C++, and Java, offer
-better facilities for system programming and for managing the complexity
-of large programs. Programs in these languages may require more lines
-of source code than the equivalent <samp><span
class="command">awk</span></samp> programs, but they are
-easier to maintain and usually run more efficiently.
-
-<div class="node">
-<p><hr>
-<a name="Regexp"></a>Next: <a rel="next" accesskey="n"
href="#Reading-Files">Reading Files</a>,
-Previous: <a rel="previous" accesskey="p" href="#Getting-Started">Getting
Started</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">2 Regular Expressions</h2>
-
-<p><a name="index-regexp_002c-See-regular-expressions-168"></a><!--
STARTOFRANGE regexp -->
-<a name="index-regular-expressions-169"></a>
-A <dfn>regular expression</dfn>, or <dfn>regexp</dfn>, is a way of describing a
-set of strings.
-Because regular expressions are such a fundamental part of <samp><span
class="command">awk</span></samp>
-programming, their format and use deserve a separate chapter.
-
- <p><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029-170"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029-171"></a>A regular
expression enclosed in slashes (`<samp><span class="samp">/</span></samp>')
-is an <samp><span class="command">awk</span></samp> pattern that matches every
input record whose text
-belongs to that set.
-The simplest regular expression is a sequence of letters, numbers, or
-both. Such a regexp matches any string that contains that sequence.
-Thus, the regexp `<samp><span class="samp">foo</span></samp>' matches any
string containing `<samp><span class="samp">foo</span></samp>'.
-Therefore, the pattern <code>/foo/</code> matches any input record containing
-the three characters `<samp><span class="samp">foo</span></samp>'
<em>anywhere</em> in the record. Other
-kinds of regexps let you specify more complicated classes of strings.
-
- <p>Initially, the examples in this chapter are simple.
-As we explain more about how
-regular expressions work, we will present more complicated instances.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Regexp-Usage">Regexp Usage</a>:
How to Use Regular Expressions.
-<li><a accesskey="2" href="#Escape-Sequences">Escape Sequences</a>:
How to write nonprinting characters.
-<li><a accesskey="3" href="#Regexp-Operators">Regexp Operators</a>:
Regular Expression Operators.
-<li><a accesskey="4" href="#Character-Lists">Character Lists</a>:
What can go between `<samp><span class="samp">[...]</span></samp>'.
-<li><a accesskey="5" href="#GNU-Regexp-Operators">GNU Regexp Operators</a>:
Operators specific to GNU software.
-<li><a accesskey="6" href="#Case_002dsensitivity">Case-sensitivity</a>:
How to do case-insensitive matching.
-<li><a accesskey="7" href="#Leftmost-Longest">Leftmost Longest</a>:
How much text matches.
-<li><a accesskey="8" href="#Computed-Regexps">Computed Regexps</a>:
Using Dynamic Regexps.
-<li><a accesskey="9" href="#Locales">Locales</a>: How the
locale affects things.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Regexp-Usage"></a>Next: <a rel="next" accesskey="n"
href="#Escape-Sequences">Escape Sequences</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.1 How to Use Regular Expressions</h3>
-
-<p><a name="index-regular-expressions_002c-as-patterns-172"></a>A regular
expression can be used as a pattern by enclosing it in
-slashes. Then the regular expression is tested against the
-entire text of each record. (Normally, it only needs
-to match some part of the text in order to succeed.) For example, the
-following prints the second field of each record that contains the string
-`<samp><span class="samp">foo</span></samp>' anywhere in it:
-
-<pre class="example"> $ awk '/foo/ { print $2 }' BBS-list
- -| 555-1234
- -| 555-6699
- -| 555-6480
- -| 555-2127
-</pre>
- <p><a name="index-regular-expressions_002c-operators-173"></a><a
name="index-operators_002c-string_002dmatching-174"></a><!-- @cindex operators,
@code{~} -->
-<a name="index-string_002dmatching-operators-175"></a><code>~</code> (tilde),
<code>~</code> operator
-<a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-176"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-177"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-178"></a><!--
@cindex operators, @code{!~} -->
-<a name="index-_0040code_007bif_007d-statement-179"></a><a
name="index-_0040code_007bwhile_007d-statement-180"></a><a
name="index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-181"></a><!--
@cindex statements, @code{if} -->
-<!-- @cindex statements, @code{while} -->
-<!-- @cindex statements, @code{do} -->
-Regular expressions can also be used in matching expressions. These
-expressions allow you to specify the string to match against; it need
-not be the entire current input record. The two operators `<samp><span
class="samp">~</span></samp>'
-and `<samp><span class="samp">!~</span></samp>' perform regular expression
comparisons. Expressions
-using these operators can be used as patterns, or in <code>if</code>,
-<code>while</code>, <code>for</code>, and <code>do</code> statements.
-(See <a href="#Statements">Statements</a>.)
-For example:
-
-<pre class="example"> <var>exp</var> ~ /<var>regexp</var>/
-</pre>
- <p class="noindent">is true if the expression <var>exp</var> (taken as a
string)
-matches <var>regexp</var>. The following example matches, or selects,
-all input records with the uppercase letter `<samp><span
class="samp">J</span></samp>' somewhere in the
-first field:
-
-<pre class="example"> $ awk '$1 ~ /J/' inventory-shipped
- -| Jan 13 25 15 115
- -| Jun 31 42 75 492
- -| Jul 24 34 67 436
- -| Jan 21 36 64 620
-</pre>
- <p>So does this:
-
-<pre class="example"> awk '{ if ($1 ~ /J/) print }' inventory-shipped
-</pre>
- <p>This next example is true if the expression <var>exp</var>
-(taken as a character string)
-does <em>not</em> match <var>regexp</var>:
-
-<pre class="example"> <var>exp</var> !~ /<var>regexp</var>/
-</pre>
- <p>The following example matches,
-or selects, all input records whose first field <em>does not</em> contain
-the uppercase letter `<samp><span class="samp">J</span></samp>':
-
-<pre class="example"> $ awk '$1 !~ /J/' inventory-shipped
- -| Feb 15 32 24 226
- -| Mar 15 24 34 228
- -| Apr 31 52 63 420
- -| May 16 34 29 208
- ...
-</pre>
- <p><a name="index-regexp-constants-182"></a><a
name="index-regular-expressions_002c-constants_002c-See-regexp-constants-183"></a>When
a regexp is enclosed in slashes, such as <code>/foo/</code>, we call it
-a <dfn>regexp constant</dfn>, much like <code>5.27</code> is a numeric
constant and
-<code>"foo"</code> is a string constant.
-
-<div class="node">
-<p><hr>
-<a name="Escape-Sequences"></a>Next: <a rel="next" accesskey="n"
href="#Regexp-Operators">Regexp Operators</a>,
-Previous: <a rel="previous" accesskey="p" href="#Regexp-Usage">Regexp
Usage</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.2 Escape Sequences</h3>
-
-<p><a name="index-escape-sequences-184"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences-185"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences-186"></a>Some
characters cannot be included literally in string constants
-(<code>"foo"</code>) or regexp constants (<code>/foo/</code>).
-Instead, they should be represented with <dfn>escape sequences</dfn>,
-which are character sequences beginning with a backslash (`<samp><span
class="samp">\</span></samp>').
-One use of an escape sequence is to include a double-quote character in
-a string constant. Because a plain double quote ends the string, you
-must use `<samp><span class="samp">\"</span></samp>' to represent an actual
double-quote character as a
-part of the string. For example:
-
-<pre class="example"> $ awk 'BEGIN { print "He said \"hi!\" to her." }'
- -| He said "hi!" to her.
-</pre>
- <p>The backslash character itself is another character that cannot be
-included normally; you must write `<samp><span class="samp">\\</span></samp>'
to put one backslash in the
-string or regexp. Thus, the string whose contents are the two characters
-`<samp><span class="samp">"</span></samp>' and `<samp><span
class="samp">\</span></samp>' must be written <code>"\"\\"</code>.
-
- <p>Backslash also represents unprintable characters
-such as TAB or newline. While there is nothing to stop you from entering most
-unprintable characters directly in a string constant or regexp constant,
-they may look ugly.
-
- <p>The following table lists
-all the escape sequences used in <samp><span class="command">awk</span></samp>
and
-what they represent. Unless noted otherwise, all these escape
-sequences apply to both string constants and regexp constants:
-
- <dl>
-<dt><code>\\</code><dd>A literal backslash, `<samp><span
class="samp">\</span></samp>'.
-
- <!-- @cindex @command{awk} language, V.4 version -->
-<p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ca_007d-escape-sequence-187"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ca_007d-escape-sequence-188"></a><br><dt><code>\a</code><dd>The
“alert” character, <kbd>Ctrl-g</kbd>, ASCII code 7 (BEL).
-(This usually makes some sort of audible noise.)
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cb_007d-escape-sequence-189"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cb_007d-escape-sequence-190"></a><br><dt><code>\b</code><dd>Backspace,
<kbd>Ctrl-h</kbd>, ASCII code 8 (BS).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cf_007d-escape-sequence-191"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cf_007d-escape-sequence-192"></a><br><dt><code>\f</code><dd>Formfeed,
<kbd>Ctrl-l</kbd>, ASCII code 12 (FF).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cn_007d-escape-sequence-193"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cn_007d-escape-sequence-194"></a><br><dt><code>\n</code><dd>Newline,
<kbd>Ctrl-j</kbd>, ASCII code 10 (LF).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cr_007d-escape-sequence-195"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cr_007d-escape-sequence-196"></a><br><dt><code>\r</code><dd>Carriage
return, <kbd>Ctrl-m</kbd>, ASCII code 13 (CR).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ct_007d-escape-sequence-197"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ct_007d-escape-sequence-198"></a><br><dt><code>\t</code><dd>Horizontal
TAB, <kbd>Ctrl-i</kbd>, ASCII code 9 (HT).
-
- <!-- @cindex @command{awk} language, V.4 version -->
-<p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cv_007d-escape-sequence-199"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cv_007d-escape-sequence-200"></a><br><dt><code>\v</code><dd>Vertical
tab, <kbd>Ctrl-k</kbd>, ASCII code 11 (VT).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-201"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-202"></a><br><dt><code>\</code><var>nnn</var><dd>The
octal value <var>nnn</var>, where <var>nnn</var> stands for 1 to 3 digits
-between `<samp><span class="samp">0</span></samp>' and `<samp><span
class="samp">7</span></samp>'. For example, the code for the ASCII ESC
-(escape) character is `<samp><span class="samp">\033</span></samp>'.
-
- <!-- @cindex @command{awk} language, V.4 version -->
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cx_007d-escape-sequence-203"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cx_007d-escape-sequence-204"></a><br><dt><code>\x</code><var>hh</var><code>...</code><dd>The
hexadecimal value <var>hh</var>, where <var>hh</var> stands for a sequence
-of hexadecimal digits (`<samp><span
class="samp">0</span></samp>'–`<samp><span class="samp">9</span></samp>',
and either `<samp><span class="samp">A</span></samp>'–`<samp><span
class="samp">F</span></samp>'
-or `<samp><span class="samp">a</span></samp>'–`<samp><span
class="samp">f</span></samp>'). Like the same construct
-in ISO C, the escape sequence continues until the first nonhexadecimal
-digit is seen. However, using more than two hexadecimal digits produces
-undefined results. (The `<samp><span class="samp">\x</span></samp>' escape
sequence is not allowed in
-POSIX <samp><span class="command">awk</span></samp>.)
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-205"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-206"></a><br><dt><code>\/</code><dd>A
literal slash (necessary for regexp constants only).
-This expression is used when you want to write a regexp
-constant that contains a slash. Because the regexp is delimited by
-slashes, you need to escape the slash that is part of the pattern,
-in order to tell <samp><span class="command">awk</span></samp> to keep
processing the rest of the regexp.
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-207"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-208"></a><br><dt><code>\"</code><dd>A
literal double quote (necessary for string constants only).
-This expression is used when you want to write a string
-constant that contains a double quote. Because the string is delimited by
-double quotes, you need to escape the quote that is part of the string,
-in order to tell <samp><span class="command">awk</span></samp> to keep
processing the rest of the string.
-</dl>
-
- <p>In <samp><span class="command">gawk</span></samp>, a number of
additional two-character sequences that begin
-with a backslash have special meaning in regexps.
-See <a href="#GNU-Regexp-Operators">GNU Regexp Operators</a>.
-
- <p>In a regexp, a backslash before any character that is not in the
previous list
-and not listed in
-<a href="#GNU-Regexp-Operators">GNU Regexp Operators</a>,
-means that the next character should be taken literally, even if it would
-normally be a regexp operator. For example, <code>/a\+b/</code> matches the
three
-characters `<samp><span class="samp">a+b</span></samp>'.
-
- <p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences-209"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences-210"></a><a
name="index-portability-211"></a>For complete portability, do not use a
backslash before any character not
-shown in the previous list.
-
- <p>To summarize:
-
- <ul>
-<li>The escape sequences in the table above are always processed first,
-for both string constants and regexp constants. This happens very early,
-as soon as <samp><span class="command">awk</span></samp> reads your program.
-
- <li><samp><span class="command">gawk</span></samp> processes both regexp
constants and dynamic regexps
-(see <a href="#Computed-Regexps">Computed Regexps</a>),
-for the special operators listed in
-<a href="#GNU-Regexp-Operators">GNU Regexp Operators</a>.
-
- <li>A backslash before any other character means to treat that character
-literally.
-</ul>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Backslash Before Regular Characters</h4>
-
-<p><a name="index-portability_002c-backslash-in-escape-sequences-212"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-backslashes-in-string-constants-213"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences_002c-POSIX-and-214"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences_002c-POSIX-and-215"></a>
-<a
name="index-troubleshooting_002c-backslash-before-nonspecial-character-216"></a>If
you place a backslash in a string constant before something that is
-not one of the characters previously listed, POSIX <samp><span
class="command">awk</span></samp> purposely
-leaves what happens as undefined. There are two choices:
-
-<!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<dl>
-<dt>Strip the backslash out<dd>This is what Unix <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp> both do.
-For example, <code>"a\qc"</code> is the same as <code>"aqc"</code>.
-(Because this is such an easy bug both to introduce and to miss,
-<samp><span class="command">gawk</span></samp> warns you about it.)
-Consider `<samp><span class="samp">FS = "[ \t]+\|[ \t]+"<!-- /@w
--></span></samp>' to use vertical bars
-surrounded by whitespace as the field separator. There should be
-two backslashes in the string `<samp><span class="samp">FS =
"[ \t]+\\|[ \t]+"<!-- /@w --></span></samp>'.)
-<!-- I did this! This is why I added the warning. -->
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-escape-sequences-217"></a><a
name="index-Unix-_0040command_007bawk_007d_002c-backslashes-in-escape-sequences-218"></a><br><dt>Leave
the backslash alone<dd>Some other <samp><span
class="command">awk</span></samp> implementations do this.
-In such implementations, typing <code>"a\qc"</code> is the same as typing
-<code>"a\\qc"</code>.
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Escape Sequences for Metacharacters</h4>
-
-<p><a name="index-metacharacters_002c-escape-sequences-for-219"></a>
-Suppose you use an octal or hexadecimal
-escape to represent a regexp metacharacter.
-(See <a href="#Regexp-Operators">Regexp Operators</a>.)
-Does <samp><span class="command">awk</span></samp> treat the character as a
literal character or as a regexp
-operator?
-
- <p><a
name="index-dark-corner_002c-escape-sequences_002c-for-metacharacters-220"></a>Historically,
such characters were taken literally.
-(d.c.)
-However, the POSIX standard indicates that they should be treated
-as real metacharacters, which is what <samp><span
class="command">gawk</span></samp> does.
-In compatibility mode (see <a href="#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> treats the characters
represented by octal and hexadecimal
-escape sequences literally when used in regexp constants. Thus,
-<code>/a\52b/</code> is equivalent to <code>/a\*b/</code>.
-
-<div class="node">
-<p><hr>
-<a name="Regexp-Operators"></a>Next: <a rel="next" accesskey="n"
href="#Character-Lists">Character Lists</a>,
-Previous: <a rel="previous" accesskey="p" href="#Escape-Sequences">Escape
Sequences</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.3 Regular Expression Operators</h3>
-
-<!-- STARTOFRANGE regexpo -->
-<p><a name="index-regular-expressions_002c-operators-221"></a>
-You can combine regular expressions with special characters,
-called <dfn>regular expression operators</dfn> or <dfn>metacharacters</dfn>, to
-increase the power and versatility of regular expressions.
-
- <p>The escape sequences described
-earlier
-in <a href="#Escape-Sequences">Escape Sequences</a>,
-are valid inside a regexp. They are introduced by a `<samp><span
class="samp">\</span></samp>' and
-are recognized and converted into corresponding real characters as
-the very first step in processing regexps.
-
- <p>Here is a list of metacharacters. All characters that are not escape
-sequences and that are not listed in the table stand for themselves:
-
-
-<a name="index-backslash-_0028_0040code_007b_005c_007d_0029-222"></a>
-<a name="index-_0040code_007b_005c_007d-_0028backslash_0029-223"></a>
-<dl><dt><code>\</code><dd>This is used to suppress the special meaning of a
character when
-matching. For example, `<samp><span class="samp">\$</span></samp>'
-matches the character `<samp><span class="samp">$</span></samp>'.
-
- <p><a name="index-regular-expressions_002c-anchors-in-224"></a><a
name="index-Texinfo_002c-chapter-beginnings-in-files-225"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029-226"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029-227"></a><br><dt><code>^</code><dd>This
matches the beginning of a string. For example, `<samp><span
class="samp">address@hidden</span></samp>'
-matches `<samp><span class="samp">@chapter</span></samp>' at the beginning of
a string and can be used
-to identify chapter beginnings in Texinfo source files.
-The `<samp><span class="samp">^</span></samp>' is known as an
<dfn>anchor</dfn>, because it anchors the pattern to
-match only at the beginning of the string.
-
- <p>It is important to realize that `<samp><span
class="samp">^</span></samp>' does not match the beginning of
-a line embedded in a string.
-The condition is not true in the following example:
-
- <pre class="example"> if ("line1\nLINE 2" ~ /^L/) ...
- </pre>
- <p><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029-228"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029-229"></a><br><dt><code>$</code><dd>This
is similar to `<samp><span class="samp">^</span></samp>', but it matches only
at the end of a string.
-For example, `<samp><span class="samp">p$</span></samp>'
-matches a record that ends with a `<samp><span class="samp">p</span></samp>'.
The `<samp><span class="samp">$</span></samp>' is an anchor
-and does not match the end of a line embedded in a string.
-The condition in the following example is not true:
-
- <pre class="example"> if ("line1\nLINE 2" ~ /1$/) ...
- </pre>
- <p><a name="index-_0040code_007b_002e_007d-_0028period_0029-230"></a><a
name="index-period-_0028_0040code_007b_002e_007d_0029-231"></a><br><dt><code>.</code><dd>This
matches any single character,
-<em>including</em> the newline character. For example, `<samp><span
class="samp">.P</span></samp>'
-matches any single character followed by a `<samp><span
class="samp">P</span></samp>' in a string. Using
-concatenation, we can make a regular expression such as `<samp><span
class="samp">U.A</span></samp>', which
-matches any three-character sequence that begins with `<samp><span
class="samp">U</span></samp>' and ends
-with `<samp><span class="samp">A</span></samp>'.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-period-_0028_0040code_007b_002e_007d_0029_0040comma_007b_007d-using-232"></a>In
strict POSIX mode (see <a href="#Options">Options</a>),
-`<samp><span class="samp">.</span></samp>' does not match the <span
class="sc">nul</span>
-character, which is a character with all bits equal to zero.
-Otherwise, <span class="sc">nul</span> is just another character. Other
versions of <samp><span class="command">awk</span></samp>
-may not be able to match the <span class="sc">nul</span> character.
-
- <p><a
name="index-_0040code_007b_005b_005d_007d-_0028square-brackets_0029-233"></a><a
name="index-square-brackets-_0028_0040code_007b_005b_005d_007d_0029-234"></a><a
name="index-character-lists-235"></a><a
name="index-character-sets_002c-See-Also-character-lists-236"></a><a
name="index-bracket-expressions_002c-See-character-lists-237"></a><br><dt><code>[...]</code><dd>This
is called a <dfn>character list</dfn>.<a rel="footnote" href="#fn-13"
name="fnd-13"><sup>13</sup></a>
-It matches any <em>one</em> of the characters that are enclosed in
-the square brackets. For example, `<samp><span
class="samp">[MVX]</span></samp>' matches any one of
-the characters `<samp><span class="samp">M</span></samp>', `<samp><span
class="samp">V</span></samp>', or `<samp><span class="samp">X</span></samp>' in
a string. A full
-discussion of what can be inside the square brackets of a character list
-is given in
-<a href="#Character-Lists">Character Lists</a>.
-
- <p><a
name="index-character-lists_002c-complemented-238"></a><br><dt><code>[^
...]</code><dd>This is a <dfn>complemented character list</dfn>. The first
character after
-the `<samp><span class="samp">[</span></samp>' <em>must</em> be a `<samp><span
class="samp">^</span></samp>'. It matches any characters
-<em>except</em> those in the square brackets. For example, `<samp><span
class="samp">[^awk]</span></samp>'
-matches any character that is not an `<samp><span
class="samp">a</span></samp>', `<samp><span class="samp">w</span></samp>',
-or `<samp><span class="samp">k</span></samp>'.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029-239"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029-240"></a><br><dt><code>|</code><dd>This
is the <dfn>alternation operator</dfn> and it is used to specify
-alternatives.
-The `<samp><span class="samp">|</span></samp>' has the lowest precedence of
all the regular
-expression operators.
-For example, `<samp><span class="samp">^P|[[:digit:]]</span></samp>'
-matches any string that matches either `<samp><span
class="samp">^P</span></samp>' or `<samp><span
class="samp">[[:digit:]]</span></samp>'. This
-means it matches any string that starts with `<samp><span
class="samp">P</span></samp>' or contains a digit.
-
- <p>The alternation applies to the largest possible regexps on either side.
-
- <p><a
name="index-_0040code_007b_0028_0029_007d-_0028parentheses_0029-241"></a><a
name="index-parentheses-_0040code_007b_0028_0029_007d-242"></a><br><dt><code>(...)</code><dd>Parentheses
are used for grouping in regular expressions, as in
-arithmetic. They can be used to concatenate regular expressions
-containing the alternation operator, `<samp><span
class="samp">|</span></samp>'. For example,
-`<samp><span class="samp">@(samp|code)\{[^}]+\}</span></samp>' matches both
`<samp><span class="samp">@code{foo}</span></samp>' and
-`<samp><span class="samp">@samp{bar}</span></samp>'.
-(These are Texinfo formatting control sequences. The `<samp><span
class="samp">+</span></samp>' is
-explained further on in this list.)
-
- <p><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-243"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-244"></a><br><dt><code>*</code><dd>This
symbol means that the preceding regular expression should be
-repeated as many times as necessary to find a match. For example,
`<samp><span class="samp">ph*</span></samp>'
-applies the `<samp><span class="samp">*</span></samp>' symbol to the preceding
`<samp><span class="samp">h</span></samp>' and looks for matches
-of one `<samp><span class="samp">p</span></samp>' followed by any number of
`<samp><span class="samp">h</span></samp>'s. This also matches
-just `<samp><span class="samp">p</span></samp>' if no `<samp><span
class="samp">h</span></samp>'s are present.
-
- <p>The `<samp><span class="samp">*</span></samp>' repeats the
<em>smallest</em> possible preceding expression.
-(Use parentheses if you want to repeat a larger expression.) It finds
-as many repetitions as possible. For example,
-`<samp><span class="samp">awk '/\(c[ad][ad]*r x\)/ { print }'
sample</span></samp>'
-prints every record in <samp><span class="file">sample</span></samp>
containing a string of the form
-`<samp><span class="samp">(car x)</span></samp>', `<samp><span
class="samp">(cdr x)</span></samp>', `<samp><span class="samp">(cadr
x)</span></samp>', and so on.
-Notice the escaping of the parentheses by preceding them
-with backslashes.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029-245"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029-246"></a><br><dt><code>+</code><dd>This
symbol is similar to `<samp><span class="samp">*</span></samp>', except that
the preceding expression must be
-matched at least once. This means that `<samp><span
class="samp">wh+y</span></samp>'
-would match `<samp><span class="samp">why</span></samp>' and `<samp><span
class="samp">whhy</span></samp>', but not `<samp><span
class="samp">wy</span></samp>', whereas
-`<samp><span class="samp">wh*y</span></samp>' would match all three of these
strings.
-The following is a simpler
-way of writing the last `<samp><span class="samp">*</span></samp>' example:
-
- <pre class="example"> awk '/\(c[ad]+r x\)/ { print }' sample
- </pre>
- <p><a
name="index-_0040code_007b_003f_007d-_0028question-mark_0029-247"></a><a
name="index-question-mark-_0028_0040code_007b_003f_007d_0029-248"></a><br><dt><code>?</code><dd>This
symbol is similar to `<samp><span class="samp">*</span></samp>', except that
the preceding expression can be
-matched either once or not at all. For example, `<samp><span
class="samp">fe?d</span></samp>'
-matches `<samp><span class="samp">fed</span></samp>' and `<samp><span
class="samp">fd</span></samp>', but nothing else.
-
- <p><a
name="index-interval-expressions-249"></a><br><dt><code>{</code><var>n</var><code>}</code><dt><code>{</code><var>n</var><code>,}</code><dt><code>{</code><var>n</var><code>,</code><var>m</var><code>}</code><dd>One
or two numbers inside braces denote an <dfn>interval expression</dfn>.
-If there is one number in the braces, the preceding regexp is repeated
-<var>n</var> times.
-If there are two numbers separated by a comma, the preceding regexp is
-repeated <var>n</var> to <var>m</var> times.
-If there is one number followed by a comma, then the preceding regexp
-is repeated at least <var>n</var> times:
-
- <dl>
-<dt><code>wh{3}y</code><dd>Matches `<samp><span
class="samp">whhhy</span></samp>', but not `<samp><span
class="samp">why</span></samp>' or `<samp><span
class="samp">whhhhy</span></samp>'.
-
- <br><dt><code>wh{3,5}y</code><dd>Matches `<samp><span
class="samp">whhhy</span></samp>', `<samp><span
class="samp">whhhhy</span></samp>', or `<samp><span
class="samp">whhhhhy</span></samp>', only.
-
- <br><dt><code>wh{2,}y</code><dd>Matches `<samp><span
class="samp">whhy</span></samp>' or `<samp><span
class="samp">whhhy</span></samp>', and so on.
-</dl>
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-interval-expressions-in-250"></a>Interval
expressions were not traditionally available in <samp><span
class="command">awk</span></samp>.
-They were added as part of the POSIX standard to make <samp><span
class="command">awk</span></samp>
-and <samp><span class="command">egrep</span></samp> consistent with each other.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-interval-expressions-and-251"></a>However,
because old programs may use `<samp><span class="samp">{</span></samp>' and
`<samp><span class="samp">}</span></samp>' in regexp
-constants, by default <samp><span class="command">gawk</span></samp> does
<em>not</em> match interval expressions
-in regexps. If either <samp><span class="option">--posix</span></samp> or
<samp><span class="option">--re-interval</span></samp> are specified
-(see <a href="#Options">Options</a>), then interval expressions
-are allowed in regexps.
-
- <p>For new programs that use `<samp><span class="samp">{</span></samp>'
and `<samp><span class="samp">}</span></samp>' in regexp constants,
-it is good practice to always escape them with a backslash. Then the
-regexp constants are valid and work the way you want them to, using
-any version of <samp><span class="command">awk</span></samp>.<a rel="footnote"
href="#fn-14" name="fnd-14"><sup>14</sup></a>
-</dl>
-
- <p><a name="index-precedence_002c-regexp-operators-252"></a><a
name="index-regular-expressions_002c-operators_002c-precedence-of-253"></a>In
regular expressions, the `<samp><span class="samp">*</span></samp>',
`<samp><span class="samp">+</span></samp>', and `<samp><span
class="samp">?</span></samp>' operators,
-as well as the braces `<samp><span class="samp">{</span></samp>' and
`<samp><span class="samp">}</span></samp>',
-have
-the highest precedence, followed by concatenation, and finally by `<samp><span
class="samp">|</span></samp>'.
-As in arithmetic, parentheses can change how operators are grouped.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-regular-expressions-and-254"></a><a
name="index-_0040command_007bgawk_007d_002c-regular-expressions_002c-precedence-255"></a>In
POSIX <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, the `<samp><span
class="samp">*</span></samp>', `<samp><span class="samp">+</span></samp>', and
`<samp><span class="samp">?</span></samp>' operators
-stand for themselves when there is nothing in the regexp that precedes them.
-For example, `<samp><span class="samp">/+/</span></samp>' matches a literal
plus sign. However, many other versions of
-<samp><span class="command">awk</span></samp> treat such a usage as a syntax
error.
-
- <p>If <samp><span class="command">gawk</span></samp> is in compatibility
mode
-(see <a href="#Options">Options</a>),
-POSIX character classes and interval expressions are not available in
-regular expressions.
-<!-- ENDOFRANGE regexpo -->
-
-<div class="node">
-<p><hr>
-<a name="Character-Lists"></a>Next: <a rel="next" accesskey="n"
href="#GNU-Regexp-Operators">GNU Regexp Operators</a>,
-Previous: <a rel="previous" accesskey="p" href="#Regexp-Operators">Regexp
Operators</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.4 Using Character Lists</h3>
-
-<!-- STARTOFRANGE charlist -->
-<p><a name="index-character-lists-256"></a><a
name="index-character-lists_002c-range-expressions-257"></a><a
name="index-range-expressions-258"></a>
-Within a character list, a <dfn>range expression</dfn> consists of two
-characters separated by a hyphen. It matches any single character that
-sorts between the two characters, using the locale's
-collating sequence and character set. For example, in the default C
-locale, `<samp><span class="samp">[a-dx-z]</span></samp>' is equivalent to
`<samp><span class="samp">[abcdxyz]</span></samp>'. Many locales
-sort characters in dictionary order, and in these locales,
-`<samp><span class="samp">[a-dx-z]</span></samp>' is typically not equivalent
to `<samp><span class="samp">[abcdxyz]</span></samp>'; instead it
-might be equivalent to `<samp><span
class="samp">[aBbCcDdxXyYz]</span></samp>', for example. To obtain
-the traditional interpretation of bracket expressions, you can use the C
-locale by setting the <samp><span class="env">LC_ALL</span></samp> environment
variable to the value
-`<samp><span class="samp">C</span></samp>'.
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-character-lists-259"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-character-lists-260"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-in-character-lists-261"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-in-character-lists-262"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-in-character-lists-263"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-in-character-lists-264"></a>To
include one of the characters `<samp><span class="samp">\</span></samp>',
`<samp><span class="samp">]</span></samp>', `<samp><span
class="samp">-</span></samp>', or `<samp><span class="samp">^</span></samp>' in
a
-character list, put a `<samp><span class="samp">\</span></samp>' in front of
it. For example:
-
-<pre class="example"> [d\]]
-</pre>
- <p class="noindent">matches either `<samp><span
class="samp">d</span></samp>' or `<samp><span class="samp">]</span></samp>'.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-character-lists-and-265"></a><a
name="index-Extended-Regular-Expressions-_0028EREs_0029-266"></a><a
name="index-EREs-_0028Extended-Regular-Expressions_0029-267"></a><a
name="index-_0040command_007begrep_007d-utility-268"></a>This treatment of
`<samp><span class="samp">\</span></samp>' in character lists
-is compatible with other <samp><span class="command">awk</span></samp>
-implementations and is also mandated by POSIX.
-The regular expressions in <samp><span class="command">awk</span></samp> are a
superset
-of the POSIX specification for Extended Regular Expressions (EREs).
-POSIX EREs are based on the regular expressions accepted by the
-traditional <samp><span class="command">egrep</span></samp> utility.
-
- <p><a name="index-character-lists_002c-character-classes-269"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-character-lists-and_002c-character-classes-270"></a><dfn>Character
classes</dfn> are a new feature introduced in the POSIX standard.
-A character class is a special notation for describing
-lists of characters that have a specific attribute, but the
-actual characters can vary from country to country and/or
-from character set to character set. For example, the notion of what
-is an alphabetic character differs between the United States and France.
-
- <p>A character class is only valid in a regexp <em>inside</em> the
-brackets of a character list. Character classes consist of `<samp><span
class="samp">[:</span></samp>',
-a keyword denoting the class, and `<samp><span class="samp">:]</span></samp>'.
-<a href="#table_002dchar_002dclasses">table-char-classes</a> lists the
character classes defined by the
-POSIX standard.
-
- <div class="float">
-<a name="table_002dchar_002dclasses"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="15%">Class
</th><th valign="top" width="85%">Meaning
-<br></th></tr><tr align="left"><td valign="top"
width="15%"><code>[:alnum:]</code> </td><td valign="top"
width="85%">Alphanumeric characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:alpha:]</code> </td><td valign="top" width="85%">Alphabetic
characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:blank:]</code> </td><td valign="top" width="85%">Space and
TAB characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:cntrl:]</code> </td><td valign="top" width="85%">Control
characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:digit:]</code> </td><td valign="top" width="85%">Numeric
characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:graph:]</code> </td><td valign="top" width="85%">Characters
that are both printable and visible.
-(A space is printable but not visible, whereas an `<samp><span
class="samp">a</span></samp>' is both.)
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:lower:]</code> </td><td valign="top" width="85%">Lowercase
alphabetic characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:print:]</code> </td><td valign="top" width="85%">Printable
characters (characters that are not control characters).
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:punct:]</code> </td><td valign="top"
width="85%">Punctuation characters (characters that are not letters, digits,
-control characters, or space characters).
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:space:]</code> </td><td valign="top" width="85%">Space
characters (such as space, TAB, and formfeed, to name a few).
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:upper:]</code> </td><td valign="top" width="85%">Uppercase
alphabetic characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:xdigit:]</code> </td><td valign="top"
width="85%">Characters that are hexadecimal digits.
- <br></td></tr></table>
-<p><strong class="float-caption">Table 2.1: POSIX Character
Classes</strong></p></div>
-
- <p>For example, before the POSIX standard, you had to write
<code>/[A-Za-z0-9]/</code>
-to match alphanumeric characters. If your
-character set had other alphabetic characters in it, this would not
-match them, and if your character set collated differently from
-ASCII, this might not even match the ASCII alphanumeric characters.
-With the POSIX character classes, you can write
-<code>/[[:alnum:]]/</code> to match the alphabetic
-and numeric characters in your character set.
-
- <p><a name="index-character-lists_002c-collating-elements-271"></a><a
name="index-character-lists_002c-non_002dASCII-272"></a><a
name="index-collating-elements-273"></a>Two additional special sequences can
appear in character lists.
-These apply to non-ASCII character sets, which can have single symbols
-(called <dfn>collating elements</dfn>) that are represented with more than one
-character. They can also have several characters that are equivalent for
-<dfn>collating</dfn>, or sorting, purposes. (For example, in French, a plain
“e”
-and a grave-accented “è” are equivalent.)
-These sequences are:
-
-
-<a name="index-character-lists_002c-collating-symbols-274"></a>
-<a name="index-collating-symbols-275"></a>
-<dl><dt>Collating symbols<dd>Multicharacter collating elements enclosed between
-`<samp><span class="samp">[.</span></samp>' and `<samp><span
class="samp">.]</span></samp>'. For example, if `<samp><span
class="samp">ch</span></samp>' is a collating element,
-then <code>[[.ch.]]</code> is a regexp that matches this collating element,
whereas
-<code>[ch]</code> is a regexp that matches either `<samp><span
class="samp">c</span></samp>' or `<samp><span class="samp">h</span></samp>'.
-
- <p><a
name="index-character-lists_002c-equivalence-classes-276"></a><br><dt>Equivalence
classes<dd>Locale-specific names for a list of
-characters that are equal. The name is enclosed between
-`<samp><span class="samp">[=</span></samp>' and `<samp><span
class="samp">=]</span></samp>'.
-For example, the name `<samp><span class="samp">e</span></samp>' might be used
to represent all of
-“e,” “è,” and “é.” In this
case, <code>[[=e=]]</code> is a regexp
-that matches any of `<samp><span class="samp">e</span></samp>', `<samp><span
class="samp">é</span></samp>', or `<samp><span
class="samp">è</span></samp>'.
-</dl>
-
- <p>These features are very valuable in non-English-speaking locales.
-
- <p><a
name="index-internationalization_002c-localization_002c-character-classes-277"></a><a
name="index-_0040command_007bgawk_007d_002c-character-classes-and-278"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-character-lists-and_002c-character-classes-279"></a><strong>Caution:</strong>
The library functions that <samp><span class="command">gawk</span></samp> uses
for regular
-expression matching currently recognize only POSIX character classes;
-they do not recognize collating symbols or equivalence classes.
-<!-- maybe one day ... -->
-<!-- ENDOFRANGE charlist -->
-
-<div class="node">
-<p><hr>
-<a name="GNU-Regexp-Operators"></a>Next: <a rel="next" accesskey="n"
href="#Case_002dsensitivity">Case-sensitivity</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Character-Lists">Character Lists</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.5 <samp><span
class="command">gawk</span></samp>-Specific Regexp Operators</h3>
-
-<!-- This section adapted (long ago) from the regex-0.12 manual -->
-<!-- STARTOFRANGE regexpg -->
-<p><a
name="index-regular-expressions_002c-operators_002c-_0040command_007bgawk_007d-280"></a><!--
STARTOFRANGE gregexp -->
-<a
name="index-_0040command_007bgawk_007d_002c-regular-expressions_002c-operators-281"></a><a
name="index-operators_002c-GNU_002dspecific-282"></a><a
name="index-regular-expressions_002c-operators_002c-for-words-283"></a><a
name="index-word_002c-regexp-definition-of-284"></a>GNU software that deals
with regular expressions provides a number of
-additional regexp operators. These operators are described in this
-section and are specific to <samp><span class="command">gawk</span></samp>;
-they are not available in other <samp><span class="command">awk</span></samp>
implementations.
-Most of the additional operators deal with word matching.
-For our purposes, a <dfn>word</dfn> is a sequence of one or more letters,
digits,
-or underscores (`<samp><span class="samp">_</span></samp>'):
-
- <dl>
-<!-- @cindex operators, @code{\w} (@command{gawk}) -->
-<a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-285"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-286"></a><dt><code>\w</code><dd>Matches
any word-constituent character—that is, it matches any
-letter, digit, or underscore. Think of it as shorthand for
-<code>[[:alnum:]_]</code><!-- /@w -->.
-
- <!-- @cindex operators, @code{\W} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-287"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-288"></a><br><dt><code>\W</code><dd>Matches
any character that is not word-constituent.
-Think of it as shorthand for
-<code>[^[:alnum:]_]</code><!-- /@w -->.
-
- <!-- @cindex operators, @code{\<} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-289"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-290"></a><br><dt><code>\<</code><dd>Matches
the empty string at the beginning of a word.
-For example, <code>/\<away/</code> matches `<samp><span
class="samp">away</span></samp>' but not
-`<samp><span class="samp">stowaway</span></samp>'.
-
- <!-- @cindex operators, @code{\>} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-291"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-292"></a><br><dt><code>\></code><dd>Matches
the empty string at the end of a word.
-For example, <code>/stow\>/</code> matches `<samp><span
class="samp">stow</span></samp>' but not `<samp><span
class="samp">stowaway</span></samp>'.
-
- <!-- @cindex operators, @code{\y} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-293"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-294"></a><a
name="index-word-boundaries_0040comma_007b_007d-matching-295"></a><br><dt><code>\y</code><dd>Matches
the empty string at either the beginning or the
-end of a word (i.e., the word boundar<strong>y</strong>). For example,
`<samp><span class="samp">\yballs?\y</span></samp>'
-matches either `<samp><span class="samp">ball</span></samp>' or `<samp><span
class="samp">balls</span></samp>', as a separate word.
-
- <!-- @cindex operators, @code{\B} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-296"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-297"></a><br><dt><code>\B</code><dd>Matches
the empty string that occurs between two
-word-constituent characters. For example,
-<code>/\Brat\B/</code> matches `<samp><span class="samp">crate</span></samp>'
but it does not match `<samp><span class="samp">dirty rat</span></samp>'.
-`<samp><span class="samp">\B</span></samp>' is essentially the opposite of
`<samp><span class="samp">\y</span></samp>'.
-</dl>
-
- <p><a name="index-buffers_002c-operators-for-298"></a><a
name="index-regular-expressions_002c-operators_002c-for-buffers-299"></a><a
name="index-operators_002c-string_002dmatching_002c-for-buffers-300"></a>There
are two other operators that work on buffers. In Emacs, a
-<dfn>buffer</dfn> is, naturally, an Emacs buffer. For other programs,
-<samp><span class="command">gawk</span></samp>'s regexp library routines
consider the entire
-string to match as the buffer.
-The operators are:
-
- <dl>
-<dt><code>\`</code><dd><!-- @cindex operators, @code{\`} (@command{gawk}) -->
-<a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-301"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-302"></a>Matches
the empty string at the
-beginning of a buffer (string).
-
- <!-- @cindex operators, @code{\'} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-303"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-304"></a><br><dt><code>\'</code><dd>Matches
the empty string at the
-end of a buffer (string).
-</dl>
-
- <p><a name="index-_0040code_007b_005e_007d-_0028caret_0029-305"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029-306"></a><a
name="index-_0040code_007b_003f_007d-_0028question-mark_0029-307"></a><a
name="index-question-mark-_0028_0040code_007b_003f_007d_0029-308"></a>Because
`<samp><span class="samp">^</span></samp>' and `<samp><span
class="samp">$</span></samp>' always work in terms of the beginning
-and end of strings, these operators don't add any new capabilities
-for <samp><span class="command">awk</span></samp>. They are provided for
compatibility with other
-GNU software.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-word_002dboundary-operator-309"></a><a
name="index-word_002dboundary-operator-_0028_0040command_007bgawk_007d_0029-310"></a><a
name="index-operators_002c-word_002dboundary-_0028_0040command_007bgawk_007d_0029-311"></a>In
other GNU software, the word-boundary operator is `<samp><span
class="samp">\b</span></samp>'. However,
-that conflicts with the <samp><span class="command">awk</span></samp>
language's definition of `<samp><span class="samp">\b</span></samp>'
-as backspace, so <samp><span class="command">gawk</span></samp> uses a
different letter.
-An alternative method would have been to require two backslashes in the
-GNU operators, but this was deemed too confusing. The current
-method of using `<samp><span class="samp">\y</span></samp>' for the GNU
`<samp><span class="samp">\b</span></samp>' appears to be the
-lesser of two evils.
-
-<!-- NOTE!!! Keep this in sync with the same table in the summary appendix! -->
-<!-- Should really do this with file inclusion. -->
-<p><a
name="index-regular-expressions_002c-_0040command_007bgawk_007d_002c-command_002dline-options-312"></a><a
name="index-_0040command_007bgawk_007d_002c-command_002dline-options-313"></a>The
various command-line options
-(see <a href="#Options">Options</a>)
-control how <samp><span class="command">gawk</span></samp> interprets
characters in regexps:
-
- <dl>
-<dt>No options<dd>In the default case, <samp><span
class="command">gawk</span></samp> provides all the facilities of
-POSIX regexps and the
-previously described
-GNU regexp operators.
-GNU regexp operators described
-in <a href="#Regexp-Operators">Regexp Operators</a>.
-However, interval expressions are not supported.
-
- <br><dt><code>--posix</code><dd>Only POSIX regexps are supported; the GNU
operators are not special
-(e.g., `<samp><span class="samp">\w</span></samp>' matches a literal
`<samp><span class="samp">w</span></samp>'). Interval expressions
-are allowed.
-
- <br><dt><code>--traditional</code><dd>Traditional Unix <samp><span
class="command">awk</span></samp> regexps are matched. The GNU operators
-are not special, interval expressions are not available, nor
-are the POSIX character classes (<code>[[:alnum:]]</code>, etc.).
-Characters described by octal and hexadecimal escape sequences are
-treated literally, even if they represent regexp metacharacters.
-
- <br><dt><code>--re-interval</code><dd>Allow interval expressions in
regexps, even if <samp><span class="option">--traditional</span></samp>
-has been provided. (<samp><span class="option">--posix</span></samp>
automatically enables
-interval expressions, so <samp><span
class="option">--re-interval</span></samp> is redundant
-when <samp><span class="option">--posix</span></samp> is is used.)
-</dl>
- <!-- ENDOFRANGE gregexp -->
-<!-- ENDOFRANGE regexpg -->
-
-<div class="node">
-<p><hr>
-<a name="Case_002dsensitivity"></a>Next: <a rel="next" accesskey="n"
href="#Leftmost-Longest">Leftmost Longest</a>,
-Previous: <a rel="previous" accesskey="p"
href="#GNU-Regexp-Operators">GNU Regexp Operators</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.6 Case Sensitivity in Matching</h3>
-
-<!-- STARTOFRANGE regexpcs -->
-<p><a name="index-regular-expressions_002c-case-sensitivity-314"></a><!--
STARTOFRANGE csregexp -->
-<a name="index-case-sensitivity_002c-regexps-and-315"></a>Case is normally
significant in regular expressions, both when matching
-ordinary characters (i.e., not metacharacters) and inside character
-sets. Thus, a `<samp><span class="samp">w</span></samp>' in a regular
expression matches only a lowercase
-`<samp><span class="samp">w</span></samp>' and not an uppercase `<samp><span
class="samp">W</span></samp>'.
-
- <p>The simplest way to do a case-independent match is to use a character
-list—for example, `<samp><span class="samp">[Ww]</span></samp>'.
However, this can be cumbersome if
-you need to use it often, and it can make the regular expressions harder
-to read. There are two alternatives that you might prefer.
-
- <p>One way to perform a case-insensitive match at a particular point in the
-program is to convert the data to a single case, using the
-<code>tolower</code> or <code>toupper</code> built-in string functions (which
we
-haven't discussed yet;
-see <a href="#String-Functions">String Functions</a>).
-For example:
-
-<pre class="example"> tolower($1) ~ /foo/ { ... }
-</pre>
- <p class="noindent">converts the first field to lowercase before matching
against it.
-This works in any POSIX-compliant <samp><span
class="command">awk</span></samp>.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-regular-expressions_002c-case-sensitivity-316"></a><a
name="index-case-sensitivity_002c-_0040command_007bgawk_007d-317"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regular-expressions-318"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-319"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-320"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-321"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-322"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable-323"></a><!-- @cindex
variables, @code{IGNORECASE} -->
-Another method, specific to <samp><span class="command">gawk</span></samp>, is
to set the variable
-<code>IGNORECASE</code> to a nonzero value (see <a
href="#Built_002din-Variables">Built-in Variables</a>).
-When <code>IGNORECASE</code> is not zero, <em>all</em> regexp and string
-operations ignore case. Changing the value of
-<code>IGNORECASE</code> dynamically controls the case-sensitivity of the
-program as it runs. Case is significant by default because
-<code>IGNORECASE</code> (like most variables) is initialized to zero:
-
-<pre class="example"> x = "aB"
- if (x ~ /ab/) ... # this test will fail
-
- IGNORECASE = 1
- if (x ~ /ab/) ... # now it will succeed
-</pre>
- <p>In general, you cannot use <code>IGNORECASE</code> to make certain rules
-case-insensitive and other rules case-sensitive, because there is no
-straightforward way
-to set <code>IGNORECASE</code> just for the pattern of
-a particular rule.<a rel="footnote" href="#fn-15"
name="fnd-15"><sup>15</sup></a>
-To do this, use either character lists or <code>tolower</code>. However, one
-thing you can do with <code>IGNORECASE</code> only is dynamically turn
-case-sensitivity on or off for all the rules at once.
-
- <p><code>IGNORECASE</code> can be set on the command line or in a
<code>BEGIN</code> rule
-(see <a href="#Other-Arguments">Other Arguments</a>; also
-see <a href="#Using-BEGIN_002fEND">Using BEGIN/END</a>).
-Setting <code>IGNORECASE</code> from the command line is a way to make
-a program case-insensitive without having to edit it.
-
- <p>Prior to <samp><span class="command">gawk</span></samp> 3.0, the value
of <code>IGNORECASE</code>
-affected regexp operations only. It did not affect string comparison
-with `<samp><span class="samp">==</span></samp>', `<samp><span
class="samp">!=</span></samp>', and so on.
-Beginning with version 3.0, both regexp and string comparison
-operations are also affected by <code>IGNORECASE</code>.
-
-<!-- @cindex ISO 8859-1 -->
-<!-- @cindex ISO Latin-1 -->
-<p>Beginning with <samp><span class="command">gawk</span></samp> 3.0,
-the equivalences between upper-
-and lowercase characters are based on the ISO-8859-1 (ISO Latin-1)
-character set. This character set is a superset of the traditional 128
-ASCII characters, which also provides a number of characters suitable
-for use with European languages.
-
- <p>As of <samp><span class="command">gawk</span></samp> 3.1.4, the case
equivalencies are fully
-locale-aware. They are based on the C <code><ctype.h></code> facilities,
-such as <code>isalpha()</code> and <code>toupper()</code>.
-
- <p>The value of <code>IGNORECASE</code> has no effect if <samp><span
class="command">gawk</span></samp> is in
-compatibility mode (see <a href="#Options">Options</a>).
-Case is always significant in compatibility mode.
-<!-- ENDOFRANGE csregexp -->
-<!-- ENDOFRANGE regexpcs -->
-
-<div class="node">
-<p><hr>
-<a name="Leftmost-Longest"></a>Next: <a rel="next" accesskey="n"
href="#Computed-Regexps">Computed Regexps</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Case_002dsensitivity">Case-sensitivity</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.7 How Much Text Matches?</h3>
-
-<p><a
name="index-regular-expressions_002c-leftmost-longest-match-324"></a><!--
@cindex matching, leftmost longest -->
-Consider the following:
-
-<pre class="example"> echo aaaabcd | awk '{ sub(/a+/, "<A>"); print
}'
-</pre>
- <p>This example uses the <code>sub</code> function (which we haven't
discussed yet;
-see <a href="#String-Functions">String Functions</a>)
-to make a change to the input record. Here, the regexp <code>/a+/</code>
-indicates “one or more `<samp><span class="samp">a</span></samp>'
characters,” and the replacement
-text is `<samp><span class="samp"><A></span></samp>'.
-
- <p>The input contains four `<samp><span class="samp">a</span></samp>'
characters.
-<samp><span class="command">awk</span></samp> (and POSIX) regular expressions
always match
-the leftmost, <em>longest</em> sequence of input characters that can
-match. Thus, all four `<samp><span class="samp">a</span></samp>' characters
are
-replaced with `<samp><span class="samp"><A></span></samp>' in this
example:
-
-<pre class="example"> $ echo aaaabcd | awk '{ sub(/a+/, "<A>");
print }'
- -| <A>bcd
-</pre>
- <p>For simple match/no-match tests, this is not so important. But when doing
-text matching and substitutions with the <code>match</code>, <code>sub</code>,
<code>gsub</code>,
-and <code>gensub</code> functions, it is very important.
-Understanding this principle is also important for regexp-based record
-and field splitting (see <a href="#Records">Records</a>,
-and also see <a href="#Field-Separators">Field Separators</a>).
-
-<div class="node">
-<p><hr>
-<a name="Computed-Regexps"></a>Next: <a rel="next" accesskey="n"
href="#Locales">Locales</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Leftmost-Longest">Leftmost Longest</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.8 Using Dynamic Regexps</h3>
-
-<!-- STARTOFRANGE dregexp -->
-<p><a name="index-regular-expressions_002c-computed-325"></a><!-- STARTOFRANGE
regexpd -->
-<a name="index-regular-expressions_002c-dynamic-326"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-327"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-328"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-329"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-330"></a><!--
@cindex operators, @code{~} -->
-<!-- @cindex operators, @code{!~} -->
-The righthand side of a `<samp><span class="samp">~</span></samp>' or
`<samp><span class="samp">!~</span></samp>' operator need not be a
-regexp constant (i.e., a string of characters between slashes). It may
-be any expression. The expression is evaluated and converted to a string
-if necessary; the contents of the string are used as the
-regexp. A regexp that is computed in this way is called a <dfn>dynamic
-regexp</dfn>:
-
-<pre class="example"> BEGIN { digits_regexp = "[[:digit:]]+" }
- $0 ~ digits_regexp { print }
-</pre>
- <p class="noindent">This sets <code>digits_regexp</code> to a regexp that
describes one or more digits,
-and tests whether the input record matches this regexp.
-
- <p><strong>Caution:</strong> When using the `<samp><span
class="samp">~</span></samp>' and `<samp><span class="samp">!~</span></samp>'
-operators, there is a difference between a regexp constant
-enclosed in slashes and a string constant enclosed in double quotes.
-If you are going to use a string constant, you have to understand that
-the string is, in essence, scanned <em>twice</em>: the first time when
-<samp><span class="command">awk</span></samp> reads your program, and the
second time when it goes to
-match the string on the lefthand side of the operator with the pattern
-on the right. This is true of any string-valued expression (such as
-<code>digits_regexp</code>, shown previously), not just string constants.
-
- <p><a name="index-regexp-constants_002c-slashes-vs_002e-quotes-331"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-regexp-constants-332"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-regexp-constants-333"></a><a
name="index-_0040code_007b_0022_007d-_0028double-quote_0029_002c-regexp-constants-334"></a><a
name="index-double-quote-_0028_0040code_007b_0022_007d_0029_002c-regexp-constants-335"></a>What
difference does it make if the string is
-scanned twice? The answer has to do with escape sequences, and particularly
-with backslashes. To get a backslash into a regular expression inside a
-string, you have to type two backslashes.
-
- <p>For example, <code>/\*/</code> is a regexp constant for a literal
`<samp><span class="samp">*</span></samp>'.
-Only one backslash is needed. To do the same thing with a string,
-you have to type <code>"\\*"</code>. The first backslash escapes the
-second one so that the string actually contains the
-two characters `<samp><span class="samp">\</span></samp>' and `<samp><span
class="samp">*</span></samp>'.
-
- <p><a
name="index-troubleshooting_002c-regexp-constants-vs_002e-string-constants-336"></a><a
name="index-regexp-constants_002c-vs_002e-string-constants-337"></a><a
name="index-string-constants_002c-vs_002e-regexp-constants-338"></a>Given that
you can use both regexp and string constants to describe
-regular expressions, which should you use? The answer is “regexp
-constants,” for several reasons:
-
- <ul>
-<li>String constants are more complicated to write and
-more difficult to read. Using regexp constants makes your programs
-less error-prone. Not understanding the difference between the two
-kinds of constants is a common source of errors.
-
- <li>It is more efficient to use regexp constants. <samp><span
class="command">awk</span></samp> can note
-that you have supplied a regexp and store it internally in a form that
-makes pattern matching more efficient. When using a string constant,
-<samp><span class="command">awk</span></samp> must first convert the string
into this internal form and
-then perform the pattern matching.
-
- <li>Using regexp constants is better form; it shows clearly that you
-intend a regexp match.
-</ul>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Using <code>\n</code> in Character
Lists of Dynamic Regexps</h4>
-
-<p><a
name="index-regular-expressions_002c-dynamic_002c-with-embedded-newlines-339"></a><a
name="index-newlines_002c-in-dynamic-regexps-340"></a>
-Some commercial versions of <samp><span class="command">awk</span></samp> do
not allow the newline
-character to be used inside a character list for a dynamic regexp:
-
-<pre class="example"> $ awk '$0 ~ "[ \t\n]"'
- error--> awk: newline in character class [
- error--> ]...
- error--> source line number 1
- error--> context is
- error--> >>> <<<
-</pre>
- <p><a name="index-newlines_002c-in-regexp-constants-341"></a>But a newline
in a regexp constant works with no problem:
-
-<pre class="example"> $ awk '$0 ~ /[ \t\n]/'
- here is a sample line
- -| here is a sample line
- <kbd>Ctrl-d</kbd>
-</pre>
- <p><samp><span class="command">gawk</span></samp> does not have this
problem, and it isn't likely to
-occur often in practice, but it's worth noting for future reference.
-<!-- ENDOFRANGE dregexp -->
-<!-- ENDOFRANGE regexpd -->
-<!-- ENDOFRANGE regexp -->
-
-<div class="node">
-<p><hr>
-<a name="Locales"></a>Previous: <a rel="previous" accesskey="p"
href="#Computed-Regexps">Computed Regexps</a>,
-Up: <a rel="up" accesskey="u" href="#Regexp">Regexp</a>
-<br>
-</div>
-
-<h3 class="section">2.9 Where You Are Makes A Difference</h3>
-
-<p>Modern systems support the notion of <dfn>locales</dfn>: a way to tell
-the system about the local character set and language. The current
-locale setting can affect the way regexp matching works, often
-in surprising ways. In particular, many locales do case-insensitive
-matching, even when you may have specified characters of only
-one particular case.
-
- <p>The following example uses the <code>sub</code> function, which
-does text replacement
-(see <a href="#String-Functions">String Functions</a>).
-Here, the intent is to remove trailing uppercase characters:
-
-<pre class="example"> $ echo something1234abc | gawk '{ sub("[A-Z]*$",
""); print }'
- -| something1234
-</pre>
- <p class="noindent">This output is unexpected, since the `<samp><span
class="samp">abc</span></samp>' at the end of `<samp><span
class="samp">something1234abc</span></samp>'
-should not normally match `<samp><span class="samp">[A-Z]*</span></samp>'.
This result is due to the
-locale setting (and thus you may not see it on your system).
-There are two fixes. The first is to use the POSIX character
-class `<samp><span class="samp">[[:upper:]]</span></samp>', instead of
`<samp><span class="samp">[A-Z]</span></samp>'.
-The second is to change the locale setting in the environment,
-before running <samp><span class="command">gawk</span></samp>,
-by using the shell statements:
-
-<pre class="example"> LANG=C LC_ALL=C
- export LANG LC_ALL
-</pre>
- <p>The setting `<samp><span class="samp">C</span></samp>' forces
<samp><span class="command">gawk</span></samp> to behave in the traditional
-Unix manner, where case distinctions do matter.
-You may wish to put these statements into your shell startup file,
-e.g., <samp><span class="file">$HOME/.profile</span></samp>.
-
- <p>Similar considerations apply to other ranges. For example,
-`<samp><span class="samp">["-/]</span></samp>' is perfectly valid in ASCII,
but is not valid in many
-Unicode locales, such as `<samp><span class="samp">en_US.UTF-8</span></samp>'.
(In general, such
-ranges should be avoided; either list the characters individually,
-or use a POSIX character class such as `<samp><span
class="samp">[[:punct:]]</span></samp>'.)
-
- <p>For the normal case of `<samp><span class="samp">RS =
"\n"</span></samp>', the locale is largely irrelevant.
-For other single byte record separators, using `<samp><span
class="samp">LC_ALL=C</span></samp>' will give you
-much better performance when reading records. Otherwise, <samp><span
class="command">gawk</span></samp> has
-to make several function calls, <em>per input character</em> to find the record
-terminator.
-
-<div class="node">
-<p><hr>
-<a name="Reading-Files"></a>Next: <a rel="next" accesskey="n"
href="#Printing">Printing</a>,
-Previous: <a rel="previous" accesskey="p" href="#Regexp">Regexp</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">3 Reading Input Files</h2>
-
-<!-- STARTOFRANGE infir -->
-<p><a name="index-input-files_002c-reading-342"></a><a
name="index-input-files-343"></a><a
name="index-_0040code_007bFILENAME_007d-variable-344"></a>In the typical
<samp><span class="command">awk</span></samp> program, all input is read either
from the
-standard input (by default, this is the keyboard, but often it is a pipe from
another
-command) or from files whose names you specify on the <samp><span
class="command">awk</span></samp>
-command line. If you specify input files, <samp><span
class="command">awk</span></samp> reads them
-in order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
-<code>FILENAME</code>
-(see <a href="#Built_002din-Variables">Built-in Variables</a>).
-
- <p><a name="index-records-345"></a><a name="index-fields-346"></a>The input
is read in units called <dfn>records</dfn>, and is processed by the
-rules of your program one record at a time.
-By default, each record is one line. Each
-record is automatically split into chunks called <dfn>fields</dfn>.
-This makes it more convenient for programs to work on the parts of a record.
-
- <p><a name="index-_0040code_007bgetline_007d-command-347"></a>On rare
occasions, you may need to use the <code>getline</code> command.
-The <code>getline</code> command is valuable, both because it
-can do explicit input from any number of files, and because the files
-used with it do not have to be named on the <samp><span
class="command">awk</span></samp> command line
-(see <a href="#Getline">Getline</a>).
-
-<ul class="menu">
-<li><a accesskey="1" href="#Records">Records</a>:
Controlling how data is split into records.
-<li><a accesskey="2" href="#Fields">Fields</a>: An
introduction to fields.
-<li><a accesskey="3" href="#Nonconstant-Fields">Nonconstant Fields</a>:
Nonconstant Field Numbers.
-<li><a accesskey="4" href="#Changing-Fields">Changing Fields</a>:
Changing the Contents of a Field.
-<li><a accesskey="5" href="#Field-Separators">Field Separators</a>:
The field separator and how to change it.
-<li><a accesskey="6" href="#Constant-Size">Constant Size</a>:
Reading constant width data.
-<li><a accesskey="7" href="#Multiple-Line">Multiple Line</a>:
Reading multi-line records.
-<li><a accesskey="8" href="#Getline">Getline</a>: Reading
files under explicit program control
- using the <code>getline</code> function.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Records"></a>Next: <a rel="next" accesskey="n"
href="#Fields">Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.1 How Input Is Split into Records</h3>
-
-<!-- STARTOFRANGE inspl -->
-<p><a name="index-input_002c-splitting-into-records-348"></a><!-- STARTOFRANGE
recspl -->
-<a name="index-records_002c-splitting-input-into-349"></a><a
name="index-_0040code_007bNR_007d-variable-350"></a><a
name="index-_0040code_007bFNR_007d-variable-351"></a>The <samp><span
class="command">awk</span></samp> utility divides the input for your
<samp><span class="command">awk</span></samp>
-program into records and fields.
-<samp><span class="command">awk</span></samp> keeps track of the number of
records that have
-been read
-so far
-from the current input file. This value is stored in a
-built-in variable called <code>FNR</code>. It is reset to zero when a new
-file is started. Another built-in variable, <code>NR</code>, is the total
-number of input records read so far from all data files. It starts at zero,
-but is never automatically reset to zero.
-
- <p><a name="index-separators_002c-for-records-352"></a><a
name="index-record-separators-353"></a>Records are separated by a character
called the <dfn>record separator</dfn>.
-By default, the record separator is the newline character.
-This is why records are, by default, single lines.
-A different character can be used for the record separator by
-assigning the character to the built-in variable <code>RS</code>.
-
- <p><a name="index-newlines_002c-as-record-separators-354"></a><a
name="index-_0040code_007bRS_007d-variable-355"></a>Like any other variable,
-the value of <code>RS</code> can be changed in the <samp><span
class="command">awk</span></samp> program
-with the assignment operator, `<samp><span class="samp">=</span></samp>'
-(see <a href="#Assignment-Ops">Assignment Ops</a>).
-The new record-separator character should be enclosed in quotation marks,
-which indicate a string constant. Often the right time to do this is
-at the beginning of execution, before any input is processed,
-so that the very first record is read with the proper separator.
-To do this, use the special <code>BEGIN</code> pattern
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-For example:
-
- <p><a name="index-_0040code_007bBEGIN_007d-pattern-356"></a>
-<pre class="example"> awk 'BEGIN { RS = "/" }
- { print $0 }' BBS-list
-</pre>
- <p class="noindent">changes the value of <code>RS</code> to
<code>"/"</code>, before reading any input.
-This is a string whose first character is a slash; as a result, records
-are separated by slashes. Then the input file is read, and the second
-rule in the <samp><span class="command">awk</span></samp> program (the action
with no pattern) prints each
-record. Because each <code>print</code> statement adds a newline at the end of
-its output, this <samp><span class="command">awk</span></samp> program copies
the input
-with each slash changed to a newline. Here are the results of running
-the program on <samp><span class="file">BBS-list</span></samp>:
-
-<pre class="example"> $ awk 'BEGIN { RS = "/" }
- > { print $0 }' BBS-list
- -| aardvark 555-5553 1200
- -| 300 B
- -| alpo-net 555-3412 2400
- -| 1200
- -| 300 A
- -| barfly 555-7685 1200
- -| 300 A
- -| bites 555-1675 2400
- -| 1200
- -| 300 A
- -| camelot 555-0542 300 C
- -| core 555-2912 1200
- -| 300 C
- -| fooey 555-1234 2400
- -| 1200
- -| 300 B
- -| foot 555-6699 1200
- -| 300 B
- -| macfoo 555-6480 1200
- -| 300 A
- -| sdace 555-3430 2400
- -| 1200
- -| 300 A
- -| sabafoo 555-2127 1200
- -| 300 C
- -|
-</pre>
- <p class="noindent">Note that the entry for the `<samp><span
class="samp">camelot</span></samp>' BBS is not split.
-In the original data file
-(see <a href="#Sample-Data-Files">Sample Data Files</a>),
-the line looks like this:
-
-<pre class="example"> camelot 555-0542 300 C
-</pre>
- <p class="noindent">It has one baud rate only, so there are no slashes in
the record,
-unlike the others which have two or more baud rates.
-In fact, this record is treated as part of the record
-for the `<samp><span class="samp">core</span></samp>' BBS; the newline
separating them in the output
-is the original newline in the data file, not the one added by
-<samp><span class="command">awk</span></samp> when it printed the record!
-
- <p><a name="index-record-separators_002c-changing-357"></a><a
name="index-separators_002c-for-records-358"></a>Another way to change the
record separator is on the command line,
-using the variable-assignment feature
-(see <a href="#Other-Arguments">Other Arguments</a>):
-
-<pre class="example"> awk '{ print $0 }' RS="/" BBS-list
-</pre>
- <p class="noindent">This sets <code>RS</code> to `<samp><span
class="samp">/</span></samp>' before processing <samp><span
class="file">BBS-list</span></samp>.
-
- <p>Using an unusual character such as `<samp><span
class="samp">/</span></samp>' for the record separator
-produces correct behavior in the vast majority of cases. However,
-the following (extreme) pipeline prints a surprising `<samp><span
class="samp">1</span></samp>':
-
-<pre class="example"> $ echo | awk 'BEGIN { RS = "a" } ; { print NF }'
- -| 1
-</pre>
- <p>There is one field, consisting of a newline. The value of the built-in
-variable <code>NF</code> is the number of fields in the current record.
-
- <p><a name="index-dark-corner_002c-input-files-359"></a>Reaching the end of
an input file terminates the current input record,
-even if the last character in the file is not the character in
<code>RS</code>.
-(d.c.)
-
- <p><a name="index-null-strings-360"></a><a
name="index-strings_002c-empty_002c-See-null-strings-361"></a>The empty string
<code>""</code> (a string without any characters)
-has a special meaning
-as the value of <code>RS</code>. It means that records are separated
-by one or more blank lines and nothing else.
-See <a href="#Multiple-Line">Multiple Line</a>, for more details.
-
- <p>If you change the value of <code>RS</code> in the middle of an
<samp><span class="command">awk</span></samp> run,
-the new value is used to delimit subsequent records, but the record
-currently being processed, as well as records already processed, are not
-affected.
-
- <p><a name="index-_0040code_007bRT_007d-variable-362"></a><a
name="index-records_002c-terminating-363"></a><a
name="index-terminating-records-364"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-record-separators-365"></a><a
name="index-regular-expressions_002c-as-record-separators-366"></a><a
name="index-record-separators_002c-regular-expressions-as-367"></a><a
name="index-separators_002c-for-records_002c-regular-expressions-as-368"></a>After
the end of the record has been determined, <samp><span
class="command">gawk</span></samp>
-sets the variable <code>RT</code> to the text in the input that matched
-<code>RS</code>.
-When using <samp><span class="command">gawk</span></samp>,
-the value of <code>RS</code> is not limited to a one-character
-string. It can be any regular expression
-(see <a href="#Regexp">Regexp</a>).
-In general, each record
-ends at the next string that matches the regular expression; the next
-record starts at the end of the matching string. This general rule is
-actually at work in the usual case, where <code>RS</code> contains just a
-newline: a record ends at the beginning of the next matching string (the
-next newline in the input), and the following record starts just after
-the end of this string (at the first character of the following line).
-The newline, because it matches <code>RS</code>, is not part of either record.
-
- <p>When <code>RS</code> is a single character, <code>RT</code>
-contains the same single character. However, when <code>RS</code> is a
-regular expression, <code>RT</code> contains
-the actual input text that matched the regular expression.
-
- <p>The following example illustrates both of these features.
-It sets <code>RS</code> equal to a regular expression that
-matches either a newline or a series of one or more uppercase letters
-with optional leading and/or trailing whitespace:
-
-<pre class="example"> $ echo record 1 AAAA record 2 BBBB record 3 |
- > gawk 'BEGIN { RS = "\n|( *[[:upper:]]+ *)" }
- > { print "Record =", $0, "and RT =", RT }'
- -| Record = record 1 and RT = AAAA
- -| Record = record 2 and RT = BBBB
- -| Record = record 3 and RT =
- -|
-</pre>
- <p class="noindent">The final line of output has an extra blank line. This
is because the
-value of <code>RT</code> is a newline, and the <code>print</code> statement
-supplies its own terminating newline.
-See <a href="#Simple-Sed">Simple Sed</a>, for a more useful example
-of <code>RS</code> as a regexp and <code>RT</code>.
-
- <p>If you set <code>RS</code> to a regular expression that allows optional
-trailing text, such as `<samp><span class="samp">RS =
"abc(XYZ)?"</span></samp>' it is possible, due
-to implementation constraints, that <samp><span
class="command">gawk</span></samp> may match the leading
-part of the regular expression, but not the trailing part, particularly
-if the input text that could match the trailing part is fairly long.
-<samp><span class="command">gawk</span></samp> attempts to avoid this problem,
but currently, there's
-no guarantee that this will never happen.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRS_007d_002f_0040code_007bRT_007d-variables-369"></a>The
use of <code>RS</code> as a regular expression and the <code>RT</code>
-variable are <samp><span class="command">gawk</span></samp> extensions; they
are not available in
-compatibility mode
-(see <a href="#Options">Options</a>).
-In compatibility mode, only the first character of the value of
-<code>RS</code> is used to determine the end of the record.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: <code>RS = "\0"</code> Is Not
Portable</h4>
-
-<p><a
name="index-advanced-features_002c-_0040value_007bDF_007ds-as-single-record-370"></a><a
name="index-portability_002c-_0040value_007bDF_007ds-as-single-record-371"></a>There
are times when you might want to treat an entire data file as a
-single record. The only way to make this happen is to give <code>RS</code>
-a value that you know doesn't occur in the input file. This is hard
-to do in a general way, such that a program always works for arbitrary
-input files.
-<!-- can you say `understatement' boys and girls? -->
-
- <p>You might think that for text files, the <span class="sc">nul</span>
character, which
-consists of a character with all bits equal to zero, is a good
-value to use for <code>RS</code> in this case:
-
-<pre class="example"> BEGIN { RS = "\0" } # whole file becomes one record?
-</pre>
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings_002c-storing-372"></a><samp><span
class="command">gawk</span></samp> in fact accepts this, and uses the <span
class="sc">nul</span>
-character for the record separator.
-However, this usage is <em>not</em> portable
-to other <samp><span class="command">awk</span></samp> implementations.
-
- <p><a name="index-dark-corner_002c-strings_002c-storing-373"></a>All other
<samp><span class="command">awk</span></samp> implementations<a rel="footnote"
href="#fn-16" name="fnd-16"><sup>16</sup></a> store strings internally as
C-style strings. C strings use the
-<span class="sc">nul</span> character as the string terminator. In effect,
this means that
-`<samp><span class="samp">RS = "\0"</span></samp>' is the same as `<samp><span
class="samp">RS = ""</span></samp>'.
-(d.c.)
-
- <p><a name="index-records_002c-treating-files-as-374"></a><a
name="index-files_002c-as-single-records-375"></a>The best way to treat a whole
file as a single record is to
-simply read the file in, one record at a time, concatenating each
-record onto the end of the previous ones.
-<!-- ENDOFRANGE inspl -->
-<!-- ENDOFRANGE recspl -->
-
-<div class="node">
-<p><hr>
-<a name="Fields"></a>Next: <a rel="next" accesskey="n"
href="#Nonconstant-Fields">Nonconstant Fields</a>,
-Previous: <a rel="previous" accesskey="p" href="#Records">Records</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.2 Examining Fields</h3>
-
-<p><a name="index-examining-fields-376"></a><a name="index-fields-377"></a><a
name="index-accessing-fields-378"></a><!-- STARTOFRANGE fiex -->
-<a name="index-fields_002c-examining-379"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-380"></a><a
name="index-field-separators_002c-POSIX-and-381"></a><a
name="index-separators_002c-field_002c-POSIX-and-382"></a>When <samp><span
class="command">awk</span></samp> reads an input record, the record is
-automatically <dfn>parsed</dfn> or separated by the interpreter into chunks
-called <dfn>fields</dfn>. By default, fields are separated by
<dfn>whitespace</dfn>,
-like words in a line.
-Whitespace in <samp><span class="command">awk</span></samp> means any string
of one or more spaces,
-tabs, or newlines;<a rel="footnote" href="#fn-17"
name="fnd-17"><sup>17</sup></a> other characters, such as
-formfeed, vertical tab, etc. that are
-considered whitespace by other languages, are <em>not</em> considered
-whitespace by <samp><span class="command">awk</span></samp>.
-
- <p>The purpose of fields is to make it more convenient for you to refer to
-these pieces of the record. You don't have to use them—you can
-operate on the whole record if you want—but fields are what make
-simple <samp><span class="command">awk</span></samp> programs so powerful.
-
- <p><a name="index-_0040code_007b_0024_007d-field-operator-383"></a><a
name="index-field-operator-_0040code_007b_0024_007d-384"></a><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-385"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-386"></a><a
name="index-field-operators_0040comma_007b_007d-dollar-sign-as-387"></a>A
dollar-sign (`<samp><span class="samp">$</span></samp>') is used
-to refer to a field in an <samp><span class="command">awk</span></samp>
program,
-followed by the number of the field you want. Thus, <code>$1</code>
-refers to the first field, <code>$2</code> to the second, and so on.
-(Unlike the Unix shells, the field numbers are not limited to single digits.
-<code>$127</code> is the one hundred twenty-seventh field in the record.)
-For example, suppose the following is a line of input:
-
-<pre class="example"> This seems like a pretty nice example.
-</pre>
- <p class="noindent">Here the first field, or <code>$1</code>, is
`<samp><span class="samp">This</span></samp>', the second field, or
-<code>$2</code>, is `<samp><span class="samp">seems</span></samp>', and so on.
Note that the last field,
-<code>$7</code>, is `<samp><span class="samp">example.</span></samp>'.
Because there is no space between the
-`<samp><span class="samp">e</span></samp>' and the `<samp><span
class="samp">.</span></samp>', the period is considered part of the seventh
-field.
-
- <p><a name="index-_0040code_007bNF_007d-variable-388"></a><a
name="index-fields_002c-number-of-389"></a><code>NF</code> is a built-in
variable whose value is the number of fields
-in the current record. <samp><span class="command">awk</span></samp>
automatically updates the value
-of <code>NF</code> each time it reads a record. No matter how many fields
-there are, the last field in a record can be represented by <code>$NF</code>.
-So, <code>$NF</code> is the same as <code>$7</code>, which is `<samp><span
class="samp">example.</span></samp>'.
-If you try to reference a field beyond the last
-one (such as <code>$8</code> when the record has only seven fields), you get
-the empty string. (If used in a numeric operation, you get zero.)
-
- <p>The use of <code>$0</code>, which looks like a reference to the
“zero-th” field, is
-a special case: it represents the whole input record
-when you are not interested in specific fields.
-Here are some more examples:
-
-<pre class="example"> $ awk '$1 ~ /foo/ { print $0 }' BBS-list
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sabafoo 555-2127 1200/300 C
-</pre>
- <p class="noindent">This example prints each record in the file <samp><span
class="file">BBS-list</span></samp> whose first
-field contains the string `<samp><span class="samp">foo</span></samp>'. The
operator `<samp><span class="samp">~</span></samp>' is called a
-<dfn>matching operator</dfn>
-(see <a href="#Regexp-Usage">Regexp Usage</a>);
-it tests whether a string (here, the field <code>$1</code>) matches a given
regular
-expression.
-
- <p>By contrast, the following example
-looks for `<samp><span class="samp">foo</span></samp>' in <em>the entire
record</em> and prints the first
-field and the last field for each matching input record:
-
-<pre class="example"> $ awk '/foo/ { print $1, $NF }' BBS-list
- -| fooey B
- -| foot B
- -| macfoo A
- -| sabafoo C
-</pre>
- <!-- ENDOFRANGE fiex -->
-<div class="node">
-<p><hr>
-<a name="Nonconstant-Fields"></a>Next: <a rel="next" accesskey="n"
href="#Changing-Fields">Changing Fields</a>,
-Previous: <a rel="previous" accesskey="p" href="#Fields">Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.3 Nonconstant Field Numbers</h3>
-
-<p><a name="index-fields_002c-numbers-390"></a><a
name="index-field-numbers-391"></a>
-The number of a field does not need to be a constant. Any expression in
-the <samp><span class="command">awk</span></samp> language can be used after a
`<samp><span class="samp">$</span></samp>' to refer to a
-field. The value of the expression specifies the field number. If the
-value is a string, rather than a number, it is converted to a number.
-Consider this example:
-
-<pre class="example"> awk '{ print $NR }'
-</pre>
- <p class="noindent">Recall that <code>NR</code> is the number of records
read so far: one in the
-first record, two in the second, etc. So this example prints the first
-field of the first record, the second field of the second record, and so
-on. For the twentieth record, field number 20 is printed; most likely,
-the record has fewer than 20 fields, so this prints a blank line.
-Here is another example of using expressions as field numbers:
-
-<pre class="example"> awk '{ print $(2*2) }' BBS-list
-</pre>
- <p><samp><span class="command">awk</span></samp> evaluates the expression
`<samp><span class="samp">(2*2)</span></samp>' and uses
-its value as the number of the field to print. The `<samp><span
class="samp">*</span></samp>' sign
-represents multiplication, so the expression `<samp><span
class="samp">2*2</span></samp>' evaluates to four.
-The parentheses are used so that the multiplication is done before the
-`<samp><span class="samp">$</span></samp>' operation; they are necessary
whenever there is a binary
-operator in the field-number expression. This example, then, prints the
-hours of operation (the fourth field) for every line of the file
-<samp><span class="file">BBS-list</span></samp>. (All of the <samp><span
class="command">awk</span></samp> operators are listed, in
-order of decreasing precedence, in
-<a href="#Precedence">Precedence</a>.)
-
- <p>If the field number you compute is zero, you get the entire record.
-Thus, `<samp><span class="samp">$(2-2)</span></samp>' has the same value as
<code>$0</code>. Negative field
-numbers are not allowed; trying to reference one usually terminates
-the program. (The POSIX standard does not define
-what happens when you reference a negative field number. <samp><span
class="command">gawk</span></samp>
-notices this and terminates your program. Other <samp><span
class="command">awk</span></samp>
-implementations may behave differently.)
-
- <p>As mentioned in <a href="#Fields">Fields</a>,
-<samp><span class="command">awk</span></samp> stores the current record's
number of fields in the built-in
-variable <code>NF</code> (also see <a href="#Built_002din-Variables">Built-in
Variables</a>). The expression
-<code>$NF</code> is not a special feature—it is the direct consequence of
-evaluating <code>NF</code> and using its value as a field number.
-
-<div class="node">
-<p><hr>
-<a name="Changing-Fields"></a>Next: <a rel="next" accesskey="n"
href="#Field-Separators">Field Separators</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Nonconstant-Fields">Nonconstant Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.4 Changing the Contents of a Field</h3>
-
-<!-- STARTOFRANGE ficon -->
-<p><a name="index-fields_002c-changing-contents-of-392"></a>The contents of a
field, as seen by <samp><span class="command">awk</span></samp>, can be changed
within an
-<samp><span class="command">awk</span></samp> program; this changes what
<samp><span class="command">awk</span></samp> perceives as the
-current input record. (The actual input is untouched; <samp><span
class="command">awk</span></samp> <em>never</em>
-modifies the input file.)
-Consider the following example and its output:
-
-<pre class="example"> $ awk '{ nboxes = $3 ; $3 = $3 - 10
- > print nboxes, $3 }' inventory-shipped
- -| 25 15
- -| 32 22
- -| 24 14
- ...
-</pre>
- <p class="noindent">The program first saves the original value of field
three in the variable
-<code>nboxes</code>.
-The `<samp><span class="samp">-</span></samp>' sign represents subtraction, so
this program reassigns
-field three, <code>$3</code>, as the original value of field three minus ten:
-`<samp><span class="samp">$3 - 10</span></samp>'. (See <a
href="#Arithmetic-Ops">Arithmetic Ops</a>.)
-Then it prints the original and new values for field three.
-(Someone in the warehouse made a consistent mistake while inventorying
-the red boxes.)
-
- <p>For this to work, the text in field <code>$3</code> must make sense
-as a number; the string of characters must be converted to a number
-for the computer to do arithmetic on it. The number resulting
-from the subtraction is converted back to a string of characters that
-then becomes field three.
-See <a href="#Conversion">Conversion</a>.
-
- <p>When the value of a field is changed (as perceived by <samp><span
class="command">awk</span></samp>), the
-text of the input record is recalculated to contain the new field where
-the old one was. In other words, <code>$0</code> changes to reflect the
altered
-field. Thus, this program
-prints a copy of the input file, with 10 subtracted from the second
-field of each line:
-
-<pre class="example"> $ awk '{ $2 = $2 - 10; print $0 }' inventory-shipped
- -| Jan 3 25 15 115
- -| Feb 5 32 24 226
- -| Mar 5 24 34 228
- ...
-</pre>
- <p>It is also possible to also assign contents to fields that are out
-of range. For example:
-
-<pre class="example"> $ awk '{ $6 = ($5 + $4 + $3 + $2)
- > print $6 }' inventory-shipped
- -| 168
- -| 297
- -| 301
- ...
-</pre>
- <p><a name="index-adding_002c-fields-393"></a><a
name="index-fields_002c-adding-394"></a>We've just created <code>$6</code>,
whose value is the sum of fields
-<code>$2</code>, <code>$3</code>, <code>$4</code>, and <code>$5</code>. The
`<samp><span class="samp">+</span></samp>' sign
-represents addition. For the file <samp><span
class="file">inventory-shipped</span></samp>, <code>$6</code>
-represents the total number of parcels shipped for a particular month.
-
- <p>Creating a new field changes <samp><span
class="command">awk</span></samp>'s internal copy of the current
-input record, which is the value of <code>$0</code>. Thus, if you do
`<samp><span class="samp">print $0</span></samp>'
-after adding a field, the record printed includes the new field, with
-the appropriate number of field separators between it and the previously
-existing fields.
-
- <p><a name="index-_0040code_007bOFS_007d-variable-395"></a><a
name="index-output-field-separator_002c-See-_0040code_007bOFS_007d-variable-396"></a><a
name="index-field-separators_002c-See-Also-_0040code_007bOFS_007d-397"></a>This
recomputation affects and is affected by
-<code>NF</code> (the number of fields; see <a href="#Fields">Fields</a>).
-For example, the value of <code>NF</code> is set to the number of the highest
-field you create.
-The exact format of <code>$0</code> is also affected by a feature that has not
been discussed yet:
-the <dfn>output field separator</dfn>, <code>OFS</code>,
-used to separate the fields (see <a href="#Output-Separators">Output
Separators</a>).
-
- <p>Note, however, that merely <em>referencing</em> an out-of-range field
-does <em>not</em> change the value of either <code>$0</code> or
<code>NF</code>.
-Referencing an out-of-range field only produces an empty string. For
-example:
-
-<pre class="example"> if ($(NF+1) != "")
- print "can't happen"
- else
- print "everything is normal"
-</pre>
- <p class="noindent">should print `<samp><span class="samp">everything is
normal</span></samp>', because <code>NF+1</code> is certain
-to be out of range. (See <a href="#If-Statement">If Statement</a>,
-for more information about <samp><span class="command">awk</span></samp>'s
<code>if-else</code> statements.
-See <a href="#Typing-and-Comparison">Typing and Comparison</a>,
-for more information about the `<samp><span class="samp">!=</span></samp>'
operator.)
-
- <p>It is important to note that making an assignment to an existing field
-changes the
-value of <code>$0</code> but does not change the value of <code>NF</code>,
-even when you assign the empty string to a field. For example:
-
-<pre class="example"> $ echo a b c d | awk '{ OFS = ":"; $2 = ""
- > print $0; print NF }'
- -| a::c:d
- -| 4
-</pre>
- <p class="noindent">The field is still there; it just has an empty value,
denoted by
-the two colons between `<samp><span class="samp">a</span></samp>' and
`<samp><span class="samp">c</span></samp>'.
-This example shows what happens if you create a new field:
-
-<pre class="example"> $ echo a b c d | awk '{ OFS = ":"; $2 = ""; $6 =
"new"
- > print $0; print NF }'
- -| a::c:d::new
- -| 6
-</pre>
- <p class="noindent">The intervening field, <code>$5</code>, is created with
an empty value
-(indicated by the second pair of adjacent colons),
-and <code>NF</code> is updated with the value six.
-
-<!-- FIXME: Verify that this is in POSIX -->
-<p><a
name="index-dark-corner_002c-_0040code_007bNF_007d-variable_002c-decrementing-398"></a><a
name="index-_0040code_007bNF_007d-variable_002c-decrementing-399"></a>Decrementing
<code>NF</code> throws away the values of the fields
-after the new value of <code>NF</code> and recomputes <code>$0</code>.
-(d.c.)
-Here is an example:
-
-<pre class="example"> $ echo a b c d e f | awk '{ print "NF =", NF;
- > NF = 3; print $0 }'
- -| NF = 6
- -| a b c
-</pre>
- <p><a
name="index-portability_002c-_0040code_007bNF_007d-variable_0040comma_007b_007d-decrementing-400"></a><strong>Caution:</strong>
Some versions of <samp><span class="command">awk</span></samp> don't
-rebuild <code>$0</code> when <code>NF</code> is decremented. Caveat emptor.
-
- <p>Finally, there are times when it is convenient to force
-<samp><span class="command">awk</span></samp> to rebuild the entire record,
using the current
-value of the fields and <code>OFS</code>. To do this, use the
-seemingly innocuous assignment:
-
-<pre class="example"> $1 = $1 # force record to be reconstituted
- print $0 # or whatever else with $0
-</pre>
- <p class="noindent">This forces <samp><span
class="command">awk</span></samp> rebuild the record. It does help
-to add a comment, as we've shown here.
-
- <p>There is a flip side to the relationship between <code>$0</code> and
-the fields. Any assignment to <code>$0</code> causes the record to be
-reparsed into fields using the <em>current</em> value of <code>FS</code>.
-This also applies to any built-in function that updates <code>$0</code>,
-such as <code>sub</code> and <code>gsub</code>
-(see <a href="#String-Functions">String Functions</a>).
-<!-- ENDOFRANGE ficon -->
-
-<div class="node">
-<p><hr>
-<a name="Field-Separators"></a>Next: <a rel="next" accesskey="n"
href="#Constant-Size">Constant Size</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Changing-Fields">Changing Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.5 Specifying How Fields Are Separated</h3>
-
-<ul class="menu">
-<li><a accesskey="1" href="#Regexp-Field-Splitting">Regexp Field
Splitting</a>: Using regexps as the field separator.
-<li><a accesskey="2" href="#Single-Character-Fields">Single Character
Fields</a>: Making each character a separate field.
-<li><a accesskey="3" href="#Command-Line-Field-Separator">Command Line Field
Separator</a>: Setting <code>FS</code> from the command-line.
-<li><a accesskey="4" href="#Field-Splitting-Summary">Field Splitting
Summary</a>: Some final points and a summary table.
-</ul>
-
-<p><a name="index-_0040code_007bFS_007d-variable-401"></a><a
name="index-fields_002c-separating-402"></a><!-- STARTOFRANGE fisepr -->
-<a name="index-field-separators-403"></a><!-- STARTOFRANGE fisepg -->
-<a name="index-fields_002c-separating-404"></a>The <dfn>field separator</dfn>,
which is either a single character or a regular
-expression, controls the way <samp><span class="command">awk</span></samp>
splits an input record into fields.
-<samp><span class="command">awk</span></samp> scans the input record for
character sequences that
-match the separator; the fields themselves are the text between the matches.
-
- <p>In the examples that follow, we use the bullet symbol (•) to
-represent spaces in the output.
-If the field separator is `<samp><span class="samp">oo</span></samp>', then
the following line:
-
-<pre class="example"> moo goo gai pan
-</pre>
- <p class="noindent">is split into three fields: `<samp><span
class="samp">m</span></samp>', `<samp><span
class="samp">•g</span></samp>', and
-`<samp><span class="samp">•gai•pan</span></samp>'.
-Note the leading spaces in the values of the second and third fields.
-
- <p><a
name="index-troubleshooting_002c-_0040command_007bawk_007d-uses-_0040code_007bFS_007d-not-_0040code_007bIFS_007d-405"></a>The
field separator is represented by the built-in variable <code>FS</code>.
-Shell programmers take note: <samp><span class="command">awk</span></samp>
does <em>not</em> use the
-name <code>IFS</code> that is used by the POSIX-compliant shells (such as
-the Unix Bourne shell, <samp><span class="command">sh</span></samp>, or
<samp><span class="command">bash</span></samp>).
-
- <p><a
name="index-_0040code_007bFS_007d-variable_002c-changing-value-of-406"></a>The
value of <code>FS</code> can be changed in the <samp><span
class="command">awk</span></samp> program with the
-assignment operator, `<samp><span class="samp">=</span></samp>' (see <a
href="#Assignment-Ops">Assignment Ops</a>).
-Often the right time to do this is at the beginning of execution
-before any input has been processed, so that the very first record
-is read with the proper separator. To do this, use the special
-<code>BEGIN</code> pattern
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-For example, here we set the value of <code>FS</code> to the string
-<code>","</code>:
-
-<pre class="example"> awk 'BEGIN { FS = "," } ; { print $2 }'
-</pre>
- <p><a name="index-_0040code_007bBEGIN_007d-pattern-407"></a>Given the input
line:
-
-<pre class="example"> John Q. Smith, 29 Oak St., Walamazoo, MI 42139
-</pre>
- <p class="noindent">this <samp><span class="command">awk</span></samp>
program extracts and prints the string
-`<samp><span class="samp">•29•Oak•St.</span></samp>'.
-
- <p><a name="index-field-separators_002c-choice-of-408"></a><a
name="index-regular-expressions-as-field-separators-409"></a><a
name="index-field-separators_002c-regular-expressions-as-410"></a>Sometimes the
input data contains separator characters that don't
-separate fields the way you thought they would. For instance, the
-person's name in the example we just used might have a title or
-suffix attached, such as:
-
-<pre class="example"> John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139
-</pre>
- <p class="noindent">The same program would extract `<samp><span
class="samp">•LXIX</span></samp>', instead of
-`<samp><span class="samp">•29•Oak•St.</span></samp>'.
-If you were expecting the program to print the
-address, you would be surprised. The moral is to choose your data layout and
-separator characters carefully to prevent such problems.
-(If the data is not in a form that is easy to process, perhaps you
-can massage it first with a separate <samp><span
class="command">awk</span></samp> program.)
-
- <p><a name="index-newlines_002c-as-field-separators-411"></a><a
name="index-whitespace_002c-as-field-separators-412"></a>Fields are normally
separated by whitespace sequences
-(spaces, tabs, and newlines), not by single spaces. Two spaces in a row do not
-delimit an empty field. The default value of the field separator
<code>FS</code>
-is a string containing a single space, <code>" "</code><!-- /@w -->. If
<samp><span class="command">awk</span></samp>
-interpreted this value in the usual way, each space character would separate
-fields, so two spaces in a row would make an empty field between them.
-The reason this does not happen is that a single space as the value of
-<code>FS</code> is a special case—it is taken to specify the default
manner
-of delimiting fields.
-
- <p>If <code>FS</code> is any other single character, such as
<code>","</code>, then
-each occurrence of that character separates two fields. Two consecutive
-occurrences delimit an empty field. If the character occurs at the
-beginning or the end of the line, that too delimits an empty field. The
-space character is the only single character that does not follow these
-rules.
-
-<div class="node">
-<p><hr>
-<a name="Regexp-Field-Splitting"></a>Next: <a rel="next" accesskey="n"
href="#Single-Character-Fields">Single Character Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Field-Separators">Field
Separators</a>
-<br>
-</div>
-
-<h4 class="subsection">3.5.1 Using Regular Expressions to Separate Fields</h4>
-
-<!-- STARTOFRANGE regexpfs -->
-<p><a name="index-regular-expressions_002c-as-field-separators-413"></a><!--
STARTOFRANGE fsregexp -->
-<a name="index-field-separators_002c-regular-expressions-as-414"></a>The
previous subsection
-discussed the use of single characters or simple strings as the
-value of <code>FS</code>.
-More generally, the value of <code>FS</code> may be a string containing any
-regular expression. In this case, each match in the record for the regular
-expression separates fields. For example, the assignment:
-
-<pre class="example"> FS = ", \t"
-</pre>
- <p class="noindent">makes every area of an input line that consists of a
comma followed by a
-space and a TAB into a field separator.
-
- <p>For a less trivial example of a regular expression, try using
-single spaces to separate fields the way single commas are used.
-<code>FS</code> can be set to <code>"[ ]"</code><!-- /@w --> (left
bracket, space, right
-bracket). This regular expression matches a single space and nothing else
-(see <a href="#Regexp">Regexp</a>).
-
- <p>There is an important difference between the two cases of `<samp><span
class="samp">FS = " "<!-- /@w --></span></samp>'
-(a single space) and `<samp><span class="samp">FS = "[ \t\n]+"<!-- /@w
--></span></samp>'
-(a regular expression matching one or more spaces, tabs, or newlines).
-For both values of <code>FS</code>, fields are separated by <dfn>runs</dfn>
-(multiple adjacent occurrences) of spaces, tabs,
-and/or newlines. However, when the value of <code>FS</code> is
<code>" "</code><!-- /@w -->,
-<samp><span class="command">awk</span></samp> first strips leading and
trailing whitespace from
-the record and then decides where the fields are.
-For example, the following pipeline prints `<samp><span
class="samp">b</span></samp>':
-
-<pre class="example"> $ echo ' a b c d ' | awk '{ print $2 }'
- -| b
-</pre>
- <p class="noindent">However, this pipeline prints `<samp><span
class="samp">a</span></samp>' (note the extra spaces around
-each letter):
-
-<pre class="example"> $ echo ' a b c d ' | awk 'BEGIN { FS = "[ \t\n]+"
}
- > { print $2 }'
- -| a
-</pre>
- <p class="noindent"><a name="index-null-strings-415"></a><a
name="index-strings_002c-null-416"></a><a
name="index-empty-strings_002c-See-null-strings-417"></a>In this case, the
first field is <dfn>null</dfn> or empty.
-
- <p>The stripping of leading and trailing whitespace also comes into
-play whenever <code>$0</code> is recomputed. For instance, study this
pipeline:
-
-<pre class="example"> $ echo ' a b c d' | awk '{ print; $2 = $2; print }'
- -| a b c d
- -| a b c d
-</pre>
- <p class="noindent">The first <code>print</code> statement prints the
record as it was read,
-with leading whitespace intact. The assignment to <code>$2</code> rebuilds
-<code>$0</code> by concatenating <code>$1</code> through <code>$NF</code>
together,
-separated by the value of <code>OFS</code>. Because the leading whitespace
-was ignored when finding <code>$1</code>, it is not part of the new
<code>$0</code>.
-Finally, the last <code>print</code> statement prints the new <code>$0</code>.
-<!-- ENDOFRANGE regexpfs -->
-<!-- ENDOFRANGE fsregexp -->
-
-<div class="node">
-<p><hr>
-<a name="Single-Character-Fields"></a>Next: <a rel="next" accesskey="n"
href="#Command-Line-Field-Separator">Command Line Field Separator</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Regexp-Field-Splitting">Regexp Field Splitting</a>,
-Up: <a rel="up" accesskey="u" href="#Field-Separators">Field
Separators</a>
-<br>
-</div>
-
-<h4 class="subsection">3.5.2 Making Each Character a Separate Field</h4>
-
-<p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-single_002dcharacter-fields-418"></a><a
name="index-single_002dcharacter-fields-419"></a><a
name="index-fields_002c-single_002dcharacter-420"></a>There are times when you
may want to examine each character
-of a record separately. This can be done in <samp><span
class="command">gawk</span></samp> by
-simply assigning the null string (<code>""</code>) to <code>FS</code>. In this
case,
-each individual character in the record becomes a separate field.
-For example:
-
-<pre class="example"> $ echo a b | gawk 'BEGIN { FS = "" }
- > {
- > for (i = 1; i <= NF; i = i + 1)
- > print "Field", i, "is", $i
- > }'
- -| Field 1 is a
- -| Field 2 is
- -| Field 3 is b
-</pre>
- <p><a
name="index-dark-corner_002c-_0040code_007bFS_007d-as-null-string-421"></a><a
name="index-FS-variable_002c-as-null-string-422"></a>Traditionally, the
behavior of <code>FS</code> equal to <code>""</code> was not defined.
-In this case, most versions of Unix <samp><span
class="command">awk</span></samp> simply treat the entire record
-as only having one field.
-(d.c.)
-In compatibility mode
-(see <a href="#Options">Options</a>),
-if <code>FS</code> is the null string, then <samp><span
class="command">gawk</span></samp> also
-behaves this way.
-
-<div class="node">
-<p><hr>
-<a name="Command-Line-Field-Separator"></a>Next: <a rel="next"
accesskey="n" href="#Field-Splitting-Summary">Field Splitting Summary</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Single-Character-Fields">Single Character Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Field-Separators">Field
Separators</a>
-<br>
-</div>
-
-<h4 class="subsection">3.5.3 Setting <code>FS</code> from the Command Line</h4>
-
-<p><a name="index-_0040code_007b_002dF_007d-option-423"></a><a
name="index-options_002c-command_002dline-424"></a><a
name="index-command-line_002c-options-425"></a><a
name="index-field-separators_002c-on-command-line-426"></a><a
name="index-command-line_002c-_0040code_007bFS_007d-on_0040comma_007b_007d-setting-427"></a><a
name="index-_0040code_007bFS_007d-variable_002c-setting-from-command-line-428"></a>
-<code>FS</code> can be set on the command line. Use the <samp><span
class="option">-F</span></samp> option to
-do so. For example:
-
-<pre class="example"> awk -F, '<var>program</var>' <var>input-files</var>
-</pre>
- <p class="noindent">sets <code>FS</code> to the `<samp><span
class="samp">,</span></samp>' character. Notice that the option uses
-an uppercase `<samp><span class="samp">F</span></samp>' instead of a lowercase
`<samp><span class="samp">f</span></samp>'. The latter
-option (<samp><span class="option">-f</span></samp>) specifies a file
-containing an <samp><span class="command">awk</span></samp> program. Case is
significant in command-line
-options:
-the <samp><span class="option">-F</span></samp> and <samp><span
class="option">-f</span></samp> options have nothing to do with each other.
-You can use both options at the same time to set the <code>FS</code> variable
-<em>and</em> get an <samp><span class="command">awk</span></samp> program from
a file.
-
- <p>The value used for the argument to <samp><span
class="option">-F</span></samp> is processed in exactly the
-same way as assignments to the built-in variable <code>FS</code>.
-Any special characters in the field separator must be escaped
-appropriately. For example, to use a `<samp><span
class="samp">\</span></samp>' as the field separator
-on the command line, you would have to type:
-
-<pre class="example"> # same as FS = "\\"
- awk -F\\\\ '...' files ...
-</pre>
- <p class="noindent"><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-as-field-separators-429"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-as-field-separators-430"></a>Because
`<samp><span class="samp">\</span></samp>' is used for quoting in the shell,
<samp><span class="command">awk</span></samp> sees
-`<samp><span class="samp">-F\\</span></samp>'. Then <samp><span
class="command">awk</span></samp> processes the `<samp><span
class="samp">\\</span></samp>' for escape
-characters (see <a href="#Escape-Sequences">Escape Sequences</a>), finally
yielding
-a single `<samp><span class="samp">\</span></samp>' to use for the field
separator.
-
-<!-- @cindex historical features -->
-<p>As a special case, in compatibility mode
-(see <a href="#Options">Options</a>),
-if the argument to <samp><span class="option">-F</span></samp> is `<samp><span
class="samp">t</span></samp>', then <code>FS</code> is set to
-the TAB character. If you type `<samp><span class="samp">-F\t</span></samp>'
at the
-shell, without any quotes, the `<samp><span class="samp">\</span></samp>' gets
deleted, so <samp><span class="command">awk</span></samp>
-figures that you really want your fields to be separated with tabs and
-not `<samp><span class="samp">t</span></samp>'s. Use `<samp><span
class="samp">-v FS="t"</span></samp>' or `<samp><span
class="samp">-F"[t]"</span></samp>' on the command line
-if you really do want to separate your fields with `<samp><span
class="samp">t</span></samp>'s.
-
- <p>For example, let's use an <samp><span class="command">awk</span></samp>
program file called <samp><span class="file">baud.awk</span></samp>
-that contains the pattern <code>/300/</code> and the action `<samp><span
class="samp">print $1</span></samp>':
-
-<pre class="example"> /300/ { print $1 }
-</pre>
- <p>Let's also set <code>FS</code> to be the `<samp><span
class="samp">-</span></samp>' character and run the
-program on the file <samp><span class="file">BBS-list</span></samp>. The
following command prints a
-list of the names of the bulletin boards that operate at 300 baud and
-the first three digits of their phone numbers:
-
-<!-- tweaked to make the tex output look better in @smallbook -->
-<pre class="example"> $ awk -F- -f baud.awk BBS-list
- -| aardvark 555
- -| alpo
- -| barfly 555
- -| bites 555
- -| camelot 555
- -| core 555
- -| fooey 555
- -| foot 555
- -| macfoo 555
- -| sdace 555
- -| sabafoo 555
-</pre>
- <p class="noindent">Note the second line of output. The second line
-in the original file looked like this:
-
-<pre class="example"> alpo-net 555-3412 2400/1200/300 A
-</pre>
- <p>The `<samp><span class="samp">-</span></samp>' as part of the system's
name was used as the field
-separator, instead of the `<samp><span class="samp">-</span></samp>' in the
phone number that was
-originally intended. This demonstrates why you have to be careful in
-choosing your field and record separators.
-
- <p><a
name="index-Unix-_0040command_007bawk_007d_002c-password-files_0040comma_007b_007d-field-separators-and-431"></a>Perhaps
the most common use of a single character as the field
-separator occurs when processing the Unix system password file.
-On many Unix systems, each user has a separate entry in the system password
-file, one line per user. The information in these lines is separated
-by colons. The first field is the user's logon name and the second is
-the user's (encrypted or shadow) password. A password file entry might look
-like this:
-
- <p><a name="index-Robbins_002c-Arnold-432"></a>
-<pre class="example"> arnold:xyzzy:2076:10:Arnold
Robbins:/home/arnold:/bin/bash
-</pre>
- <p>The following program searches the system password file and prints
-the entries for users who have no password:
-
-<pre class="example"> awk -F: '$2 == ""' /etc/passwd
-</pre>
- <div class="node">
-<p><hr>
-<a name="Field-Splitting-Summary"></a>Previous: <a rel="previous"
accesskey="p" href="#Command-Line-Field-Separator">Command Line Field
Separator</a>,
-Up: <a rel="up" accesskey="u" href="#Field-Separators">Field
Separators</a>
-<br>
-</div>
-
-<h4 class="subsection">3.5.4 Field-Splitting Summary</h4>
-
-<p>It is important to remember that when you assign a string constant
-as the value of <code>FS</code>, it undergoes normal <samp><span
class="command">awk</span></samp> string
-processing. For example, with Unix <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>,
-the assignment `<samp><span class="samp">FS = "\.."</span></samp>' assigns the
character string <code>".."</code>
-to <code>FS</code> (the backslash is stripped). This creates a regexp meaning
-“fields are separated by occurrences of any two characters.”
-If instead you want fields to be separated by a literal period followed
-by any single character, use `<samp><span class="samp">FS =
"\\.."</span></samp>'.
-
- <p>The following table summarizes how fields are split, based on the value
-of <code>FS</code> (`<samp><span class="samp">==</span></samp>' means
“is equal to”):
-
- <dl>
-<dt><code>FS == " "</code><dd>Fields are separated by runs of whitespace.
Leading and trailing
-whitespace are ignored. This is the default.
-
- <br><dt><code>FS == </code><var>any other single
character</var><dd>Fields are separated by each occurrence of the character.
Multiple
-successive occurrences delimit empty fields, as do leading and
-trailing occurrences.
-The character can even be a regexp metacharacter; it does not need
-to be escaped.
-
- <br><dt><code>FS == </code><var>regexp</var><dd>Fields are separated by
occurrences of characters that match <var>regexp</var>.
-Leading and trailing matches of <var>regexp</var> delimit empty fields.
-
- <br><dt><code>FS == ""</code><dd>Each individual character in the record
becomes a separate field.
-(This is a <samp><span class="command">gawk</span></samp> extension; it is not
specified by the
-POSIX standard.)
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Changing <code>FS</code> Does Not
Affect the Fields</h4>
-
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-433"></a><a
name="index-field-separators_002c-POSIX-and-434"></a>According to the POSIX
standard, <samp><span class="command">awk</span></samp> is supposed to behave
-as if each record is split into fields at the time it is read.
-In particular, this means that if you change the value of <code>FS</code>
-after a record is read, the value of the fields (i.e., how they were split)
-should reflect the old value of <code>FS</code>, not the new one.
-
- <p><a name="index-dark-corner_002c-field-separators-435"></a><a
name="index-_0040command_007bsed_007d-utility-436"></a><a
name="index-stream-editors-437"></a>However, many implementations of
<samp><span class="command">awk</span></samp> do not work this way. Instead,
-they defer splitting the fields until a field is actually
-referenced. The fields are split
-using the <em>current</em> value of <code>FS</code>!
-(d.c.)
-This behavior can be difficult
-to diagnose. The following example illustrates the difference
-between the two methods.
-(The <samp><span class="command">sed</span></samp><a rel="footnote"
href="#fn-18" name="fnd-18"><sup>18</sup></a>
-command prints just the first line of <samp><span
class="file">/etc/passwd</span></samp>.)
-
-<pre class="example"> sed 1q /etc/passwd | awk '{ FS = ":" ; print $1 }'
-</pre>
- <p class="noindent">which usually prints:
-
-<pre class="example"> root
-</pre>
- <p class="noindent">on an incorrect implementation of <samp><span
class="command">awk</span></samp>, while <samp><span
class="command">gawk</span></samp>
-prints something like:
-
-<pre class="example"> root:nSijPlPhZZwgE:0:0:Root:/:
-</pre>
- <!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: <code>FS</code> and
<code>IGNORECASE</code></h4>
-
-<p>The <code>IGNORECASE</code> variable
-(see <a href="#User_002dmodified">User-modified</a>)
-affects field splitting <em>only</em> when the value of <code>FS</code> is a
regexp.
-It has no effect when <code>FS</code> is a single character, even if
-that character is a letter. Thus, in the following code:
-
-<pre class="example"> FS = "c"
- IGNORECASE = 1
- $0 = "aCa"
- print $1
-</pre>
- <p class="noindent">The output is `<samp><span
class="samp">aCa</span></samp>'. If you really want to split fields on an
-alphabetic character while ignoring case, use a regexp that will
-do it for you. E.g., `<samp><span class="samp">FS = "[c]"</span></samp>'. In
this case, <code>IGNORECASE</code>
-will take effect.
-
-<!-- ENDOFRANGE fisepr -->
-<!-- ENDOFRANGE fisepg -->
-<div class="node">
-<p><hr>
-<a name="Constant-Size"></a>Next: <a rel="next" accesskey="n"
href="#Multiple-Line">Multiple Line</a>,
-Previous: <a rel="previous" accesskey="p" href="#Field-Separators">Field
Separators</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.6 Reading Fixed-Width Data</h3>
-
-<blockquote>
-<b>NOTE:</b> This section discusses an advanced
-feature of <samp><span class="command">gawk</span></samp>. If you are a
novice <samp><span class="command">awk</span></samp> user,
-you might want to skip it on the first reading.
-</blockquote>
-
-<p><a name="index-data_002c-fixed_002dwidth-438"></a><a
name="index-fixed_002dwidth-data-439"></a><a
name="index-advanced-features_002c-fixed_002dwidth-data-440"></a><samp><span
class="command">gawk</span></samp> version 2.13 introduced a facility for
dealing with
-fixed-width fields with no distinctive field separator. For example,
-data of this nature arises in the input for old Fortran programs where
-numbers are run together, or in the output of programs that did not
-anticipate the use of their output as input for other programs.
-
- <p>An example of the latter is a table where all the columns are lined up by
-the use of a variable number of spaces and <em>empty fields are just
-spaces</em>. Clearly, <samp><span class="command">awk</span></samp>'s normal
field splitting based on <code>FS</code>
-does not work well in this case. Although a portable <samp><span
class="command">awk</span></samp> program
-can use a series of <code>substr</code> calls on <code>$0</code>
-(see <a href="#String-Functions">String Functions</a>),
-this is awkward and inefficient for a large number of fields.
-
- <p><a
name="index-troubleshooting_002c-fatal-errors_002c-field-widths_0040comma_007b_007d-specifying-441"></a><a
name="index-_0040command_007bw_007d-utility-442"></a><a
name="index-_0040code_007bFIELDWIDTHS_007d-variable-443"></a>The splitting of
an input record into fixed-width fields is specified by
-assigning a string containing space-separated numbers to the built-in
-variable <code>FIELDWIDTHS</code>. Each number specifies the width of the
field,
-<em>including</em> columns between fields. If you want to ignore the columns
-between fields, you can specify the width as a separate field that is
-subsequently ignored.
-It is a fatal error to supply a field width that is not a positive number.
-The following data is the output of the Unix <samp><span
class="command">w</span></samp> utility. It is useful
-to illustrate the use of <code>FIELDWIDTHS</code>:
-
-<pre class="example"> 10:06pm up 21 days, 14:04, 23 users
- User tty login idle JCPU PCPU what
- hzuo ttyV0 8:58pm 9 5 vi p24.tex
- hzang ttyV3 6:37pm 50 -csh
- eklye ttyV5 9:53pm 7 1 em thes.tex
- dportein ttyV6 8:17pm 1:47 -csh
- gierd ttyD3 10:00pm 1 elm
- dave ttyD4 9:47pm 4 4 w
- brent ttyp0 26Jun91 4:46 26:46 4:41 bash
- dave ttyq4 26Jun9115days 46 46 wnewmail
-</pre>
- <p>The following program takes the above input, converts the idle time to
-number of seconds, and prints out the first two fields and the calculated
-idle time:
-
- <blockquote>
-<b>NOTE:</b> This program uses a number of <samp><span
class="command">awk</span></samp> features that
-haven't been introduced yet.
-</blockquote>
-
-<pre class="example"> BEGIN { FIELDWIDTHS = "9 6 10 6 7 7 35" }
- NR > 2 {
- idle = $4
- sub(/^ */, "", idle) # strip leading spaces
- if (idle == "")
- idle = 0
- if (idle ~ /:/) {
- split(idle, t, ":")
- idle = t[1] * 60 + t[2]
- }
- if (idle ~ /days/)
- idle *= 24 * 60 * 60
-
- print $1, $2, idle
- }
-</pre>
- <p>Running the program on the data produces the following results:
-
-<pre class="example"> hzuo ttyV0 0
- hzang ttyV3 50
- eklye ttyV5 0
- dportein ttyV6 107
- gierd ttyD3 1
- dave ttyD4 0
- brent ttyp0 286
- dave ttyq4 1296000
-</pre>
- <p>Another (possibly more practical) example of fixed-width input data
-is the input from a deck of balloting cards. In some parts of
-the United States, voters mark their choices by punching holes in computer
-cards. These cards are then processed to count the votes for any particular
-candidate or on any particular issue. Because a voter may choose not to
-vote on some issue, any column on the card may be empty. An <samp><span
class="command">awk</span></samp>
-program for processing such data could use the <code>FIELDWIDTHS</code> feature
-to simplify reading the data. (Of course, getting <samp><span
class="command">gawk</span></samp> to run on
-a system with card readers is another story!)
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-splitting-fields-and-444"></a>Assigning
a value to <code>FS</code> causes <samp><span
class="command">gawk</span></samp> to use
-<code>FS</code> for field splitting again. Use `<samp><span class="samp">FS =
FS</span></samp>' to make this happen,
-without having to know the current value of <code>FS</code>.
-In order to tell which kind of field splitting is in effect,
-use <code>PROCINFO["FS"]</code>
-(see <a href="#Auto_002dset">Auto-set</a>).
-The value is <code>"FS"</code> if regular field splitting is being used,
-or it is <code>"FIELDWIDTHS"</code> if fixed-width field splitting is being
used:
-
-<pre class="example"> if (PROCINFO["FS"] == "FS")
- <var>regular field splitting</var> ...
- else
- <var>fixed-width field splitting</var> ...
-</pre>
- <p>This information is useful when writing a function
-that needs to temporarily change <code>FS</code> or <code>FIELDWIDTHS</code>,
-read some records, and then restore the original settings
-(see <a href="#Passwd-Functions">Passwd Functions</a>,
-for an example of such a function).
-
-<div class="node">
-<p><hr>
-<a name="Multiple-Line"></a>Next: <a rel="next" accesskey="n"
href="#Getline">Getline</a>,
-Previous: <a rel="previous" accesskey="p" href="#Constant-Size">Constant
Size</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.7 Multiple-Line Records</h3>
-
-<!-- STARTOFRANGE recm -->
-<p><a name="index-records_002c-multiline-445"></a><!-- STARTOFRANGE imr -->
-<a name="index-input_002c-multiline-records-446"></a><!-- STARTOFRANGE frm -->
-<a name="index-files_002c-reading_002c-multiline-records-447"></a><a
name="index-input_002c-files_002c-See-input-files-448"></a>In some databases, a
single line cannot conveniently hold all the
-information in one entry. In such cases, you can use multiline
-records. The first step in doing this is to choose your data format.
-
- <p><a
name="index-record-separators_002c-with-multiline-records-449"></a>One
technique is to use an unusual character or string to separate
-records. For example, you could use the formfeed character (written
-`<samp><span class="samp">\f</span></samp>' in <samp><span
class="command">awk</span></samp>, as in C) to separate them, making each record
-a page of the file. To do this, just set the variable <code>RS</code> to
-<code>"\f"</code> (a string containing the formfeed character). Any
-other character could equally well be used, as long as it won't be part
-of the data in a record.
-
- <p><a
name="index-_0040code_007bRS_007d-variable_002c-multiline-records-and-450"></a>Another
technique is to have blank lines separate records. By a special
-dispensation, an empty string as the value of <code>RS</code> indicates that
-records are separated by one or more blank lines. When <code>RS</code> is set
-to the empty string, each record always ends at the first blank line
-encountered. The next record doesn't start until the first nonblank
-line that follows. No matter how many blank lines appear in a row, they
-all act as one record separator.
-(Blank lines must be completely empty; lines that contain only
-whitespace do not count.)
-
- <p><a name="index-leftmost-longest-match-451"></a><a
name="index-matching_002c-leftmost-longest-452"></a>You can achieve the same
effect as `<samp><span class="samp">RS = ""</span></samp>' by assigning the
-string <code>"\n\n+"</code> to <code>RS</code>. This regexp matches the newline
-at the end of the record and one or more blank lines after the record.
-In addition, a regular expression always matches the longest possible
-sequence when there is a choice
-(see <a href="#Leftmost-Longest">Leftmost Longest</a>).
-So the next record doesn't start until
-the first nonblank line that follows—no matter how many blank lines
-appear in a row, they are considered one record separator.
-
- <p><a name="index-dark-corner_002c-multiline-records-453"></a>There is an
important difference between `<samp><span class="samp">RS = ""</span></samp>'
and
-`<samp><span class="samp">RS = "\n\n+"</span></samp>'. In the first case,
leading newlines in the input
-data file are ignored, and if a file ends without extra blank lines
-after the last record, the final newline is removed from the record.
-In the second case, this special processing is not done.
-(d.c.)
-
- <p><a name="index-field-separators_002c-in-multiline-records-454"></a>Now
that the input is separated into records, the second step is to
-separate the fields in the record. One way to do this is to divide each
-of the lines into fields in the normal manner. This happens by default
-as the result of a special feature. When <code>RS</code> is set to the empty
-string, <em>and</em> <code>FS</code> is a set to a single character,
-the newline character <em>always</em> acts as a field separator.
-This is in addition to whatever field separations result from
-<code>FS</code>.<a rel="footnote" href="#fn-19" name="fnd-19"><sup>19</sup></a>
-
- <p>The original motivation for this special exception was probably to
provide
-useful behavior in the default case (i.e., <code>FS</code> is equal
-to <code>" "</code><!-- /@w -->). This feature can be a problem if you
really don't
-want the newline character to separate fields, because there is no way to
-prevent it. However, you can work around this by using the <code>split</code>
-function to break up the record manually
-(see <a href="#String-Functions">String Functions</a>).
-If you have a single character field separator, you can work around
-the special feature in a different way, by making <code>FS</code> into a
-regexp for that single character. For example, if the field
-separator is a percent character, instead of
-`<samp><span class="samp">FS = "%"</span></samp>', use `<samp><span
class="samp">FS = "[%]"</span></samp>'.
-
- <p>Another way to separate fields is to
-put each field on a separate line: to do this, just set the
-variable <code>FS</code> to the string <code>"\n"</code>. (This single
-character seperator matches a single newline.)
-A practical example of a data file organized this way might be a mailing
-list, where each entry is separated by blank lines. Consider a mailing
-list in a file named <samp><span class="file">addresses</span></samp>, which
looks like this:
-
-<pre class="example"> Jane Doe
- 123 Main Street
- Anywhere, SE 12345-6789
-
- John Smith
- 456 Tree-lined Avenue
- Smallville, MW 98765-4321
- ...
-</pre>
- <p class="noindent">A simple program to process this file is as follows:
-
-<pre class="example"> # addrs.awk --- simple mailing list program
-
- # Records are separated by blank lines.
- # Each line is one field.
- BEGIN { RS = "" ; FS = "\n" }
-
- {
- print "Name is:", $1
- print "Address is:", $2
- print "City and State are:", $3
- print ""
- }
-</pre>
- <p>Running the program produces the following output:
-
-<pre class="example"> $ awk -f addrs.awk addresses
- -| Name is: Jane Doe
- -| Address is: 123 Main Street
- -| City and State are: Anywhere, SE 12345-6789
- -|
- -| Name is: John Smith
- -| Address is: 456 Tree-lined Avenue
- -| City and State are: Smallville, MW 98765-4321
- -|
- ...
-</pre>
- <p>See <a href="#Labels-Program">Labels Program</a>, for a more realistic
-program that deals with address lists.
-The following
-table
-summarizes how records are split, based on the
-value of
-<code>RS</code>:
-
- <dl>
-<dt><code>RS == "\n"</code><dd>Records are separated by the newline character
(`<samp><span class="samp">\n</span></samp>'). In effect,
-every line in the data file is a separate record, including blank lines.
-This is the default.
-
- <br><dt><code>RS == </code><var>any single character</var><dd>Records are
separated by each occurrence of the character. Multiple
-successive occurrences delimit empty records.
-
- <br><dt><code>RS == ""</code><dd>Records are separated by runs of blank
lines. The newline character
-always serves as a field separator, in addition to whatever value
-<code>FS</code> may have. Leading and trailing newlines in a file are ignored.
-
- <br><dt><code>RS == </code><var>regexp</var><dd>Records are separated by
occurrences of characters that match <var>regexp</var>.
-Leading and trailing matches of <var>regexp</var> delimit empty records.
-(This is a <samp><span class="command">gawk</span></samp> extension; it is not
specified by the
-POSIX standard.)
-</dl>
-
- <p><a name="index-_0040code_007bRT_007d-variable-455"></a>In all cases,
<samp><span class="command">gawk</span></samp> sets <code>RT</code> to the
input text that matched the
-value specified by <code>RS</code>.
-<!-- ENDOFRANGE recm -->
-<!-- ENDOFRANGE imr -->
-<!-- ENDOFRANGE frm -->
-
-<div class="node">
-<p><hr>
-<a name="Getline"></a>Previous: <a rel="previous" accesskey="p"
href="#Multiple-Line">Multiple Line</a>,
-Up: <a rel="up" accesskey="u" href="#Reading-Files">Reading Files</a>
-<br>
-</div>
-
-<h3 class="section">3.8 Explicit Input with <code>getline</code></h3>
-
-<!-- STARTOFRANGE getl -->
-<p><a
name="index-_0040code_007bgetline_007d-command_002c-explicit-input-with-456"></a><a
name="index-input_002c-explicit-457"></a>So far we have been getting our input
data from <samp><span class="command">awk</span></samp>'s main
-input stream—either the standard input (usually your terminal, sometimes
-the output from another program) or from the
-files specified on the command line. The <samp><span
class="command">awk</span></samp> language has a
-special built-in command called <code>getline</code> that
-can be used to read input under your explicit control.
-
- <p>The <code>getline</code> command is used in several different ways and
should
-<em>not</em> be used by beginners.
-The examples that follow the explanation of the <code>getline</code> command
-include material that has not been covered yet. Therefore, come back
-and study the <code>getline</code> command <em>after</em> you have reviewed the
-rest of this Web page and have a good knowledge of how <samp><span
class="command">awk</span></samp> works.
-
- <p><a name="index-_0040code_007bERRNO_007d-variable-458"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bgetline_007d-command-459"></a><a
name="index-_0040code_007bgetline_007d-command_002c-return-values-460"></a>The
<code>getline</code> command returns one if it finds a record and zero if
-it encounters the end of the file. If there is some error in getting
-a record, such as a file that cannot be opened, then <code>getline</code>
-returns −1. In this case, <samp><span
class="command">gawk</span></samp> sets the variable
-<code>ERRNO</code> to a string describing the error that occurred.
-
- <p>In the following examples, <var>command</var> stands for a string value
that
-represents a shell command.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Plain-Getline">Plain Getline</a>:
Using <code>getline</code> with no arguments.
-<li><a accesskey="2" href="#Getline_002fVariable">Getline/Variable</a>:
Using <code>getline</code> into a variable.
-<li><a accesskey="3" href="#Getline_002fFile">Getline/File</a>:
Using <code>getline</code> from a file.
-<li><a accesskey="4"
href="#Getline_002fVariable_002fFile">Getline/Variable/File</a>: Using
<code>getline</code> into a variable from a
- file.
-<li><a accesskey="5" href="#Getline_002fPipe">Getline/Pipe</a>:
Using <code>getline</code> from a pipe.
-<li><a accesskey="6"
href="#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>: Using
<code>getline</code> into a variable from a
- pipe.
-<li><a accesskey="7" href="#Getline_002fCoprocess">Getline/Coprocess</a>:
Using <code>getline</code> from a coprocess.
-<li><a accesskey="8"
href="#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>:
Using <code>getline</code> into a variable from a
- coprocess.
-<li><a accesskey="9" href="#Getline-Notes">Getline Notes</a>:
Important things to know about <code>getline</code>.
-<li><a href="#Getline-Summary">Getline Summary</a>: Summary of
<code>getline</code> Variants.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Plain-Getline"></a>Next: <a rel="next" accesskey="n"
href="#Getline_002fVariable">Getline/Variable</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.1 Using <code>getline</code> with No Arguments</h4>
-
-<p>The <code>getline</code> command can be used without arguments to read input
-from the current input file. All it does in this case is read the next
-input record and split it up into fields. This is useful if you've
-finished processing the current record, but want to do some special
-processing on the next record <em>right now</em>. For example:
-
-<pre class="example"> {
- if ((t = index($0, "/*")) != 0) {
- # value of `tmp' will be "" if t is 1
- tmp = substr($0, 1, t - 1)
- u = index(substr($0, t + 2), "*/")
- while (u == 0) {
- if (getline <= 0) {
- m = "unexpected EOF or error"
- m = (m ": " ERRNO)
- print m > "/dev/stderr"
- exit
- }
- t = -1
- u = index($0, "*/")
- }
- # substr expression will be "" if */
- # occurred at end of line
- $0 = tmp substr($0, u + 2)
- }
- print $0
- }
-</pre>
- <p>This <samp><span class="command">awk</span></samp> program deletes all
C-style comments (`<samp><span class="samp">/* ...
-*/</span></samp>') from the input. By replacing the `<samp><span
class="samp">print $0</span></samp>' with other
-statements, you could perform more complicated processing on the
-decommented input, such as searching for matches of a regular
-expression. (This program has a subtle problem—it does not work if one
-comment ends and another begins on the same line.)
-
- <p>This form of the <code>getline</code> command sets <code>NF</code>,
-<code>NR</code>, <code>FNR</code>, and the value of <code>$0</code>.
-
- <blockquote>
-<b>NOTE:</b> The new value of <code>$0</code> is used to test
-the patterns of any subsequent rules. The original value
-of <code>$0</code> that triggered the rule that executed <code>getline</code>
-is lost.
-By contrast, the <code>next</code> statement reads a new record
-but immediately begins processing it normally, starting with the first
-rule in the program. See <a href="#Next-Statement">Next Statement</a>.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fVariable"></a>Next: <a rel="next" accesskey="n"
href="#Getline_002fFile">Getline/File</a>,
-Previous: <a rel="previous" accesskey="p" href="#Plain-Getline">Plain
Getline</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.2 Using <code>getline</code> into a Variable</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-461"></a>
-You can use `<samp><span class="samp">getline </span><var>var</var></samp>' to
read the next record from
-<samp><span class="command">awk</span></samp>'s input into the variable
<var>var</var>. No other processing is
-done.
-For example, suppose the next line is a comment or a special string,
-and you want to read it without triggering
-any rules. This form of <code>getline</code> allows you to read that line
-and store it in a variable so that the main
-read-a-line-and-check-each-rule loop of <samp><span
class="command">awk</span></samp> never sees it.
-The following example swaps every two lines of input:
-
-<pre class="example"> {
- if ((getline tmp) > 0) {
- print tmp
- print $0
- } else
- print $0
- }
-</pre>
- <p class="noindent">It takes the following list:
-
-<pre class="example"> wan
- tew
- free
- phore
-</pre>
- <p class="noindent">and produces these results:
-
-<pre class="example"> tew
- wan
- phore
- free
-</pre>
- <p>The <code>getline</code> command used in this way sets only the variables
-<code>NR</code> and <code>FNR</code> (and of course, <var>var</var>). The
record is not
-split into fields, so the values of the fields (including <code>$0</code>) and
-the value of <code>NF</code> do not change.
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fFile"></a>Next: <a rel="next" accesskey="n"
href="#Getline_002fVariable_002fFile">Getline/Variable/File</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fVariable">Getline/Variable</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.3 Using <code>getline</code> from a File</h4>
-
-<p><a name="index-input-redirection-462"></a><a
name="index-redirection-of-input-463"></a><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-464"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-465"></a><a
name="index-operators_002c-input_002foutput-466"></a>Use `<samp><span
class="samp">getline < </span><var>file</var></samp>' to read the next
record from <var>file</var>.
-Here <var>file</var> is a string-valued expression that
-specifies the file name. `<samp><span class="samp"><
</span><var>file</var></samp>' is called a <dfn>redirection</dfn>
-because it directs input to come from a different place.
-For example, the following
-program reads its input record from the file <samp><span
class="file">secondary.input</span></samp> when it
-encounters a first field with a value equal to 10 in the current input
-file:
-
-<pre class="example"> {
- if ($1 == 10) {
- getline < "secondary.input"
- print
- } else
- print
- }
-</pre>
- <p>Because the main input stream is not used, the values of <code>NR</code>
and
-<code>FNR</code> are not changed. However, the record it reads is split into
fields in
-the normal manner, so the values of <code>$0</code> and the other fields are
-changed, resulting in a new value of <code>NF</code>.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_003c_007d-operator-and-467"></a><!--
Thanks to Paul Eggert for initial wording here -->
-According to POSIX, `<samp><span class="samp">getline <
</span><var>expression</var></samp>' is ambiguous if
-<var>expression</var> contains unparenthesized operators other than
-`<samp><span class="samp">$</span></samp>'; for example, `<samp><span
class="samp">getline < dir "/" file</span></samp>' is ambiguous
-because the concatenation operator is not parenthesized. You should
-write it as `<samp><span class="samp">getline < (dir "/"
file)</span></samp>' if you want your program
-to be portable to other <samp><span class="command">awk</span></samp>
implementations.
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fVariable_002fFile"></a>Next: <a rel="next"
accesskey="n" href="#Getline_002fPipe">Getline/Pipe</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fFile">Getline/File</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.4 Using <code>getline</code> into a Variable from a
File</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-468"></a>
-Use `<samp><span class="samp">getline </span><var>var</var><span class="samp">
< </span><var>file</var></samp>' to read input
-from the file
-<var>file</var>, and put it in the variable <var>var</var>. As above,
<var>file</var>
-is a string-valued expression that specifies the file from which to read.
-
- <p>In this version of <code>getline</code>, none of the built-in variables
are
-changed and the record is not split into fields. The only variable
-changed is <var>var</var>.
-For example, the following program copies all the input files to the
-output, except for records that say `<samp><span
class="samp">@include </span><var>filename</var></samp>'<!-- /@w -->.
-Such a record is replaced by the contents of the file
-<var>filename</var>:
-
-<pre class="example"> {
- if (NF == 2 && $1 == "@include") {
- while ((getline line < $2) > 0)
- print line
- close($2)
- } else
- print
- }
-</pre>
- <p>Note here how the name of the extra input file is not built into
-the program; it is taken directly from the data, specifically from the second
field on
-the `<samp><span class="samp">@include</span></samp>' line.
-
- <p><a name="index-_0040code_007bclose_007d-function-469"></a>The
<code>close</code> function is called to ensure that if two identical
-`<samp><span class="samp">@include</span></samp>' lines appear in the input,
the entire specified file is
-included twice.
-See <a href="#Close-Files-And-Pipes">Close Files And Pipes</a>.
-
- <p>One deficiency of this program is that it does not process nested
-`<samp><span class="samp">@include</span></samp>' statements
-(i.e., `<samp><span class="samp">@include</span></samp>' statements in
included files)
-the way a true macro preprocessor would.
-See <a href="#Igawk-Program">Igawk Program</a>, for a program
-that does handle nested `<samp><span class="samp">@include</span></samp>'
statements.
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fPipe"></a>Next: <a rel="next" accesskey="n"
href="#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fVariable_002fFile">Getline/Variable/File</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.5 Using <code>getline</code> from a Pipe</h4>
-
-<p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-470"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-471"></a><a
name="index-input-pipeline-472"></a><a
name="index-pipes_002c-input-473"></a><a
name="index-operators_002c-input_002foutput-474"></a>The output of a command
can also be piped into <code>getline</code>, using
-`<samp><var>command</var><span class="samp"> | getline</span></samp>'. In
-this case, the string <var>command</var> is run as a shell command and its
output
-is piped into <samp><span class="command">awk</span></samp> to be used as
input. This form of <code>getline</code>
-reads one record at a time from the pipe.
-For example, the following program copies its input to its output, except for
-lines that begin with `<samp><span class="samp">@execute</span></samp>', which
are replaced by the output
-produced by running the rest of the line as a shell command:
-
-<pre class="example"> {
- if ($1 == "@execute") {
- tmp = substr($0, 10)
- while ((tmp | getline) > 0)
- print
- close(tmp)
- } else
- print
- }
-</pre>
- <p class="noindent"><a
name="index-_0040code_007bclose_007d-function-475"></a>The <code>close</code>
function is called to ensure that if two identical
-`<samp><span class="samp">@execute</span></samp>' lines appear in the input,
the command is run for
-each one.
-See <a href="#Close-Files-And-Pipes">Close Files And Pipes</a>.
-<!-- Exercise!! -->
-<!-- This example is unrealistic, since you could just use system -->
-Given the input:
-
-<pre class="example"> foo
- bar
- baz
- @execute who
- bletch
-</pre>
- <p class="noindent">the program might produce:
-
- <p><a name="index-Robbins_002c-Bill-476"></a><a
name="index-Robbins_002c-Miriam-477"></a><a
name="index-Robbins_002c-Arnold-478"></a>
-<pre class="example"> foo
- bar
- baz
- arnold ttyv0 Jul 13 14:22
- miriam ttyp0 Jul 13 14:23 (murphy:0)
- bill ttyp1 Jul 13 14:23 (murphy:0)
- bletch
-</pre>
- <p class="noindent">Notice that this program ran the command <samp><span
class="command">who</span></samp> and printed the previous result.
-(If you try this program yourself, you will of course get different results,
-depending upon who is logged in on your system.)
-
- <p>This variation of <code>getline</code> splits the record into fields,
sets the
-value of <code>NF</code>, and recomputes the value of <code>$0</code>. The
values of
-<code>NR</code> and <code>FNR</code> are not changed.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_007c_007d-I_002fO-operator-and-479"></a><!--
Thanks to Paul Eggert for initial wording here -->
-According to POSIX, `<samp><var>expression</var><span class="samp"> |
getline</span></samp>' is ambiguous if
-<var>expression</var> contains unparenthesized operators other than
-`<samp><span class="samp">$</span></samp>'—for example, `<samp><span
class="samp">"echo "<!-- /@w --> "date" | getline</span></samp>' is
ambiguous
-because the concatenation operator is not parenthesized. You should
-write it as `<samp><span class="samp">("echo "<!-- /@w --> "date") |
getline</span></samp>' if you want your program
-to be portable to other <samp><span class="command">awk</span></samp>
implementations.
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fVariable_002fPipe"></a>Next: <a rel="next"
accesskey="n" href="#Getline_002fCoprocess">Getline/Coprocess</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fPipe">Getline/Pipe</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.6 Using <code>getline</code> into a Variable from a
Pipe</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-480"></a>
-When you use `<samp><var>command</var><span class="samp"> | getline
</span><var>var</var></samp>', the
-output of <var>command</var> is sent through a pipe to
-<code>getline</code> and into the variable <var>var</var>. For example, the
-following program reads the current date and time into the variable
-<code>current_time</code>, using the <samp><span
class="command">date</span></samp> utility, and then
-prints it:
-
-<pre class="example"> BEGIN {
- "date" | getline current_time
- close("date")
- print "Report printed on " current_time
- }
-</pre>
- <p>In this version of <code>getline</code>, none of the built-in variables
are
-changed and the record is not split into fields.
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fCoprocess"></a>Next: <a rel="next" accesskey="n"
href="#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.7 Using <code>getline</code> from a Coprocess</h4>
-
-<p><a name="index-coprocesses_002c-_0040code_007bgetline_007d-from-481"></a><a
name="index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-482"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-483"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-484"></a><a
name="index-operators_002c-input_002foutput-485"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-486"></a>
-Input into <code>getline</code> from a pipe is a one-way operation.
-The command that is started with `<samp><var>command</var><span class="samp">
| getline</span></samp>' only
-sends data <em>to</em> your <samp><span class="command">awk</span></samp>
program.
-
- <p>On occasion, you might want to send data to another program
-for processing and then read the results back.
-<samp><span class="command">gawk</span></samp> allows you start a
<dfn>coprocess</dfn>, with which two-way
-communications are possible. This is done with the `<samp><span
class="samp">|&</span></samp>'
-operator.
-Typically, you write data to the coprocess first and then
-read results back, as shown in the following:
-
-<pre class="example"> print "<var>some query</var>" |& "db_server"
- "db_server" |& getline
-</pre>
- <p class="noindent">which sends a query to <samp><span
class="command">db_server</span></samp> and then reads the results.
-
- <p>The values of <code>NR</code> and
-<code>FNR</code> are not changed,
-because the main input stream is not used.
-However, the record is split into fields in
-the normal manner, thus changing the values of <code>$0</code>, of the other
fields,
-and of <code>NF</code>.
-
- <p>Coprocesses are an advanced feature. They are discussed here only because
-this is the section on <code>getline</code>.
-See <a href="#Two_002dway-I_002fO">Two-way I/O</a>,
-where coprocesses are discussed in more detail.
-
-<div class="node">
-<p><hr>
-<a name="Getline_002fVariable_002fCoprocess"></a>Next: <a rel="next"
accesskey="n" href="#Getline-Notes">Getline Notes</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fCoprocess">Getline/Coprocess</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.8 Using <code>getline</code> into a Variable from a
Coprocess</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-487"></a>
-When you use `<samp><var>command</var><span class="samp"> |& getline
</span><var>var</var></samp>', the output from
-the coprocess <var>command</var> is sent through a two-way pipe to
<code>getline</code>
-and into the variable <var>var</var>.
-
- <p>In this version of <code>getline</code>, none of the built-in variables
are
-changed and the record is not split into fields. The only variable
-changed is <var>var</var>.
-
-<div class="node">
-<p><hr>
-<a name="Getline-Notes"></a>Next: <a rel="next" accesskey="n"
href="#Getline-Summary">Getline Summary</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.9 Points to Remember About <code>getline</code></h4>
-
-<p>Here are some miscellaneous points about <code>getline</code> that
-you should bear in mind:
-
- <ul>
-<li>When <code>getline</code> changes the value of <code>$0</code> and
<code>NF</code>,
-<samp><span class="command">awk</span></samp> does <em>not</em> automatically
jump to the start of the
-program and start testing the new record against every pattern.
-However, the new record is tested against any subsequent rules.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-488"></a><a
name="index-implementation-issues_002c-_0040command_007bgawk_007d_002c-limits-489"></a><a
name="index-_0040command_007bawk_007d_002c-implementations_002c-limits-490"></a><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-limits-491"></a><li>Many
<samp><span class="command">awk</span></samp> implementations limit the number
of pipelines that an <samp><span class="command">awk</span></samp>
-program may have open to just one. In <samp><span
class="command">gawk</span></samp>, there is no such limit.
-You can open as many pipelines (and coprocesses) as the underlying operating
-system permits.
-
- <p><a
name="index-side-effects_002c-_0040code_007bFILENAME_007d-variable-492"></a><a
name="index-_0040code_007bFILENAME_007d-variable_002c-_0040code_007bgetline_007d_0040comma_007b_007d-setting-with-493"></a><a
name="index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-494"></a><a
name="index-_0040code_007bgetline_007d-command_002c-_0040code_007bFILENAME_007d-variable-and-495"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bgetline_007d-and-496"></a><li>An
interesting side effect occurs if you use <code>getline</code> without a
-redirection inside a <code>BEGIN</code> rule. Because an unredirected
<code>getline</code>
-reads from the command-line data files, the first <code>getline</code> command
-causes <samp><span class="command">awk</span></samp> to set the value of
<code>FILENAME</code>. Normally,
-<code>FILENAME</code> does not have a value inside <code>BEGIN</code> rules,
because you
-have not yet started to process the command-line data files.
-(d.c.)
-(See <a href="#BEGIN_002fEND">BEGIN/END</a>,
-also see <a href="#Auto_002dset">Auto-set</a>.)
-
- <li>Using <code>FILENAME</code> with <code>getline</code>
-(`<samp><span class="samp">getline < FILENAME</span></samp>')
-is likely to be a source for
-confusion. <samp><span class="command">awk</span></samp> opens a separate
input stream from the
-current input file. However, by not using a variable, <code>$0</code>
-and <code>NR</code> are still updated. If you're doing this, it's
-probably by accident, and you should reconsider what it is you're
-trying to accomplish.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Getline-Summary"></a>Previous: <a rel="previous" accesskey="p"
href="#Getline-Notes">Getline Notes</a>,
-Up: <a rel="up" accesskey="u" href="#Getline">Getline</a>
-<br>
-</div>
-
-<h4 class="subsection">3.8.10 Summary of <code>getline</code> Variants</h4>
-
-<p><a name="index-_0040code_007bgetline_007d-command_002c-variants-497"></a>
-<a href="#table_002dgetline_002dvariants">table-getline-variants</a>
-summarizes the eight variants of <code>getline</code>,
-listing which built-in variables are set by each one.
-
- <div class="float">
-<a name="table_002dgetline_002dvariants"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="35%">Variant
</th><th valign="top" width="65%">Effect
-<br></th></tr><tr align="left"><td valign="top"
width="35%"><code>getline</code> </td><td valign="top" width="65%">Sets
<code>$0</code>, <code>NF</code>, <code>FNR</code>, and <code>NR</code>
-<br></td></tr><tr align="left"><td valign="top"
width="35%"><code>getline</code> <var>var</var> </td><td valign="top"
width="65%">Sets <var>var</var>, <code>FNR</code>, and <code>NR</code>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><code>getline
<</code> <var>file</var> </td><td valign="top" width="65%">Sets
<code>$0</code> and <code>NF</code>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><code>getline
</code><var>var</var><code> < </code><var>file</var> </td><td valign="top"
width="65%">Sets <var>var</var>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>| getline</code> </td><td valign="top" width="65%">Sets <code>$0</code>
and <code>NF</code>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>| getline</code> <var>var</var> </td><td valign="top" width="65%">Sets
<var>var</var>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>|& getline</code> </td><td valign="top" width="65%">Sets
<code>$0</code> and <code>NF</code>. This is a <samp><span
class="command">gawk</span></samp> extension
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>|& getline</code> <var>var</var> </td><td valign="top"
width="65%">Sets <var>var</var>. This is a <samp><span
class="command">gawk</span></samp> extension
- <br></td></tr></table>
-<p><strong class="float-caption">Table 3.1: getline Variants and What They
Set</strong></p></div>
-<!-- ENDOFRANGE getl -->
-<!-- ENDOFRANGE inex -->
-<!-- ENDOFRANGE infir -->
-
-<div class="node">
-<p><hr>
-<a name="Printing"></a>Next: <a rel="next" accesskey="n"
href="#Expressions">Expressions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Reading-Files">Reading
Files</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">4 Printing Output</h2>
-
-<!-- STARTOFRANGE prnt -->
-<p><a name="index-printing-498"></a><a
name="index-output_002c-printing_002c-See-printing-499"></a>One of the most
common programming actions is to <dfn>print</dfn>, or output,
-some or all of the input. Use the <code>print</code> statement
-for simple output, and the <code>printf</code> statement
-for fancier formatting.
-The <code>print</code> statement is not limited when
-computing <em>which</em> values to print. However, with two exceptions,
-you cannot specify <em>how</em> to print them—how many
-columns, whether to use exponential notation or not, and so on.
-(For the exceptions, see <a href="#Output-Separators">Output Separators</a>,
and
-<a href="#OFMT">OFMT</a>.)
-For printing with specifications, you need the <code>printf</code> statement
-(see <a href="#Printf">Printf</a>).
-
-<!-- STARTOFRANGE prnts -->
-<p><a name="index-_0040code_007bprint_007d-statement-500"></a><a
name="index-_0040code_007bprintf_007d-statement-501"></a>Besides basic and
formatted printing, this chapter
-also covers I/O redirections to files and pipes, introduces
-the special file names that <samp><span class="command">gawk</span></samp>
processes internally,
-and discusses the <code>close</code> built-in function.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Print">Print</a>: The
<code>print</code> statement.
-<li><a accesskey="2" href="#Print-Examples">Print Examples</a>:
Simple examples of <code>print</code> statements.
-<li><a accesskey="3" href="#Output-Separators">Output Separators</a>:
The output separators and how to change them.
-<li><a accesskey="4" href="#OFMT">OFMT</a>:
Controlling Numeric Output With <code>print</code>.
-<li><a accesskey="5" href="#Printf">Printf</a>: The
<code>printf</code> statement.
-<li><a accesskey="6" href="#Redirection">Redirection</a>: How
to redirect output to multiple files and
- pipes.
-<li><a accesskey="7" href="#Special-Files">Special Files</a>:
File name interpretation in <samp><span class="command">gawk</span></samp>.
- <samp><span class="command">gawk</span></samp>
allows access to inherited file
- descriptors.
-<li><a accesskey="8" href="#Close-Files-And-Pipes">Close Files And Pipes</a>:
Closing Input and Output Files and Pipes.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Print"></a>Next: <a rel="next" accesskey="n"
href="#Print-Examples">Print Examples</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.1 The <code>print</code> Statement</h3>
-
-<p>The <code>print</code> statement is used to produce output with simple,
standardized
-formatting. Specify only the strings or numbers to print, in a
-list separated by commas. They are output, separated by single spaces,
-followed by a newline. The statement looks like this:
-
-<pre class="example"> print <var>item1</var>, <var>item2</var>, ...
-</pre>
- <p class="noindent">The entire list of items may be optionally enclosed in
parentheses. The
-parentheses are necessary if any of the item expressions uses the `<samp><span
class="samp">></span></samp>'
-relational operator; otherwise it could be confused with a redirection
-(see <a href="#Redirection">Redirection</a>).
-
- <p>The items to print can be constant strings or numbers, fields of the
-current record (such as <code>$1</code>), variables, or any <samp><span
class="command">awk</span></samp>
-expression. Numeric values are converted to strings and then printed.
-
- <p><a name="index-records_002c-printing-502"></a><a
name="index-lines_002c-blank_002c-printing-503"></a><a
name="index-text_002c-printing-504"></a>The simple statement `<samp><span
class="samp">print</span></samp>' with no items is equivalent to
-`<samp><span class="samp">print $0</span></samp>': it prints the entire
current record. To print a blank
-line, use `<samp><span class="samp">print ""</span></samp>', where
<code>""</code> is the empty string.
-To print a fixed piece of text, use a string constant, such as
-<code>"Don't Panic"</code><!-- /@w -->, as one item. If you forget to
use the
-double-quote characters, your text is taken as an <samp><span
class="command">awk</span></samp>
-expression, and you will probably get an error. Keep in mind that a
-space is printed between any two items.
-
-<div class="node">
-<p><hr>
-<a name="Print-Examples"></a>Next: <a rel="next" accesskey="n"
href="#Output-Separators">Output Separators</a>,
-Previous: <a rel="previous" accesskey="p" href="#Print">Print</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.2 Examples of <code>print</code> Statements</h3>
-
-<p>Each <code>print</code> statement makes at least one line of output.
However, it
-isn't limited to only one line. If an item value is a string that contains a
-newline, the newline is output along with the rest of the string. A
-single <code>print</code> statement can make any number of lines this way.
-
- <p><a name="index-newlines_002c-printing-505"></a>The following is an
example of printing a string that contains embedded newlines
-(the `<samp><span class="samp">\n</span></samp>' is an escape sequence, used
to represent the newline
-character; see <a href="#Escape-Sequences">Escape Sequences</a>):
-
-<pre class="example"> $ awk 'BEGIN { print "line one\nline two\nline
three" }'
- -| line one
- -| line two
- -| line three
-</pre>
- <p><a name="index-fields_002c-printing-506"></a>The next example, which is
run on the <samp><span class="file">inventory-shipped</span></samp> file,
-prints the first two fields of each input record, with a space between
-them:
-
-<pre class="example"> $ awk '{ print $1, $2 }' inventory-shipped
- -| Jan 13
- -| Feb 15
- -| Mar 15
- ...
-</pre>
- <p><a
name="index-_0040code_007bprint_007d-statement_002c-commas_002c-omitting-507"></a><a
name="index-troubleshooting_002c-_0040code_007bprint_007d-statement_0040comma_007b_007d-omitting-commas-508"></a>A
common mistake in using the <code>print</code> statement is to omit the comma
-between two items. This often has the effect of making the items run
-together in the output, with no space. The reason for this is that
-juxtaposing two string expressions in <samp><span
class="command">awk</span></samp> means to concatenate
-them. Here is the same program, without the comma:
-
-<pre class="example"> $ awk '{ print $1 $2 }' inventory-shipped
- -| Jan13
- -| Feb15
- -| Mar15
- ...
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-headings_0040comma_007b_007d-adding-509"></a>To
someone unfamiliar with the <samp><span
class="file">inventory-shipped</span></samp> file, neither
-example's output makes much sense. A heading line at the beginning
-would make it clearer. Let's add some headings to our table of months
-(<code>$1</code>) and green crates shipped (<code>$2</code>). We do this
using the
-<code>BEGIN</code> pattern
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>)
-so that the headings are only printed once:
-
-<pre class="example"> awk 'BEGIN { print "Month Crates"
- print "----- ------" }
- { print $1, $2 }' inventory-shipped
-</pre>
- <p class="noindent">When run, the program prints the following:
-
-<pre class="example"> Month Crates
- ----- ------
- Jan 13
- Feb 15
- Mar 15
- ...
-</pre>
- <p class="noindent">The only problem, however, is that the headings and the
table data
-don't line up! We can fix this by printing some spaces between the
-two fields:
-
-<pre class="example"> awk 'BEGIN { print "Month Crates"
- print "----- ------" }
- { print $1, " ", $2 }' inventory-shipped
-</pre>
- <p><a
name="index-_0040code_007bprintf_007d-statement_002c-columns_0040comma_007b_007d-aligning-510"></a><a
name="index-columns_002c-aligning-511"></a>Lining up columns this way can get
pretty
-complicated when there are many columns to fix. Counting spaces for two
-or three columns is simple, but any more than this can take up
-a lot of time. This is why the <code>printf</code> statement was
-created (see <a href="#Printf">Printf</a>);
-one of its specialties is lining up columns of data.
-
- <p><a
name="index-line-continuations_002c-in-_0040code_007bprint_007d-statement-512"></a><a
name="index-_0040code_007bprint_007d-statement_002c-line-continuations-and-513"></a><blockquote>
-<b>NOTE:</b> You can continue either a <code>print</code> or
-<code>printf</code> statement simply by putting a newline after any comma
-(see <a href="#Statements_002fLines">Statements/Lines</a>).
-</blockquote>
- <!-- ENDOFRANGE prnts -->
-
-<div class="node">
-<p><hr>
-<a name="Output-Separators"></a>Next: <a rel="next" accesskey="n"
href="#OFMT">OFMT</a>,
-Previous: <a rel="previous" accesskey="p" href="#Print-Examples">Print
Examples</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.3 Output Separators</h3>
-
-<p><a name="index-_0040code_007bOFS_007d-variable-514"></a>As mentioned
previously, a <code>print</code> statement contains a list
-of items separated by commas. In the output, the items are normally
-separated by single spaces. However, this doesn't need to be the case;
-a single space is only the default. Any string of
-characters may be used as the <dfn>output field separator</dfn> by setting the
-built-in variable <code>OFS</code>. The initial value of this variable
-is the string <code>" "</code><!-- /@w -->—that is, a single space.
-
- <p>The output from an entire <code>print</code> statement is called an
-<dfn>output record</dfn>. Each <code>print</code> statement outputs one output
-record, and then outputs a string called the <dfn>output record separator</dfn>
-(or <code>ORS</code>). The initial
-value of <code>ORS</code> is the string <code>"\n"</code>; i.e., a newline
-character. Thus, each <code>print</code> statement normally makes a separate
line.
-
- <p><a name="index-output_002c-records-515"></a><a
name="index-output-record-separator_002c-See-_0040code_007bORS_007d-variable-516"></a><a
name="index-_0040code_007bORS_007d-variable-517"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bOFS_007d_002f_0040code_007bORS_007d-variables_002c-assigning-values-to-518"></a>In
order to change how output fields and records are separated, assign
-new values to the variables <code>OFS</code> and <code>ORS</code>. The usual
-place to do this is in the <code>BEGIN</code> rule
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>), so
-that it happens before any input is processed. It can also be done
-with assignments on the command line, before the names of the input
-files, or using the <samp><span class="option">-v</span></samp> command-line
option
-(see <a href="#Options">Options</a>).
-The following example prints the first and second fields of each input
-record, separated by a semicolon, with a blank line added after each
-newline:
-
-<pre class="example"> $ awk 'BEGIN { OFS = ";"; ORS = "\n\n" }
- > { print $1, $2 }' BBS-list
- -| aardvark;555-5553
- -|
- -| alpo-net;555-3412
- -|
- -| barfly;555-7685
- ...
-</pre>
- <p>If the value of <code>ORS</code> does not contain a newline, the
program's output
-is run together on a single line.
-
-<div class="node">
-<p><hr>
-<a name="OFMT"></a>Next: <a rel="next" accesskey="n"
href="#Printf">Printf</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Output-Separators">Output Separators</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.4 Controlling Numeric Output with <code>print</code></h3>
-
-<p><a name="index-numeric_002c-output-format-519"></a><a
name="index-formats_0040comma_007b_007d-numeric-output-520"></a>When the
<code>print</code> statement is used to print numeric values,
-<samp><span class="command">awk</span></samp> internally converts the number
to a string of characters
-and prints that string. <samp><span class="command">awk</span></samp> uses
the <code>sprintf</code> function
-to do this conversion
-(see <a href="#String-Functions">String Functions</a>).
-For now, it suffices to say that the <code>sprintf</code>
-function accepts a <dfn>format specification</dfn> that tells it how to format
-numbers (or strings), and that there are a number of different ways in which
-numbers can be formatted. The different format specifications are discussed
-more fully in
-<a href="#Control-Letters">Control Letters</a>.
-
- <p><a name="index-_0040code_007bsprintf_007d-function-521"></a><a
name="index-_0040code_007bOFMT_007d-variable-522"></a><a
name="index-output_002c-format-specifier_0040comma_007b_007d-_0040code_007bOFMT_007d-523"></a>The
built-in variable <code>OFMT</code> contains the default format specification
-that <code>print</code> uses with <code>sprintf</code> when it wants to
convert a
-number to a string for printing.
-The default value of <code>OFMT</code> is <code>"%.6g"</code>.
-The way <code>print</code> prints numbers can be changed
-by supplying different format specifications
-as the value of <code>OFMT</code>, as shown in the following example:
-
-<pre class="example"> $ awk 'BEGIN {
- > OFMT = "%.0f" # print numbers as integers (rounds)
- > print 17.23, 17.54 }'
- -| 17 18
-</pre>
- <p class="noindent"><a
name="index-dark-corner_002c-_0040code_007bOFMT_007d-variable-524"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-525"></a><a
name="index-_0040code_007bOFMT_007d-variable_002c-POSIX-_0040command_007bawk_007d-and-526"></a>According
to the POSIX standard, <samp><span class="command">awk</span></samp>'s
behavior is undefined
-if <code>OFMT</code> contains anything but a floating-point conversion
specification.
-(d.c.)
-
-<div class="node">
-<p><hr>
-<a name="Printf"></a>Next: <a rel="next" accesskey="n"
href="#Redirection">Redirection</a>,
-Previous: <a rel="previous" accesskey="p" href="#OFMT">OFMT</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.5 Using <code>printf</code> Statements for Fancier
Printing</h3>
-
-<!-- STARTOFRANGE printfs -->
-<p><a name="index-_0040code_007bprintf_007d-statement-527"></a><a
name="index-output_002c-formatted-528"></a><a
name="index-formatting-output-529"></a>For more precise control over the output
format than what is
-normally provided by <code>print</code>, use <code>printf</code>.
-<code>printf</code> can be used to
-specify the width to use for each item, as well as various
-formatting choices for numbers (such as what output base to use, whether to
-print an exponent, whether to print a sign, and how many digits to print
-after the decimal point). This is done by supplying a string, called
-the <dfn>format string</dfn>, that controls how and where to print the other
-arguments.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Basic-Printf">Basic Printf</a>:
Syntax of the <code>printf</code> statement.
-<li><a accesskey="2" href="#Control-Letters">Control Letters</a>:
Format-control letters.
-<li><a accesskey="3" href="#Format-Modifiers">Format Modifiers</a>:
Format-specification modifiers.
-<li><a accesskey="4" href="#Printf-Examples">Printf Examples</a>:
Several examples.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Basic-Printf"></a>Next: <a rel="next" accesskey="n"
href="#Control-Letters">Control Letters</a>,
-Up: <a rel="up" accesskey="u" href="#Printf">Printf</a>
-<br>
-</div>
-
-<h4 class="subsection">4.5.1 Introduction to the <code>printf</code>
Statement</h4>
-
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-syntax-of-530"></a>A
simple <code>printf</code> statement looks like this:
-
-<pre class="example"> printf <var>format</var>, <var>item1</var>,
<var>item2</var>, ...
-</pre>
- <p class="noindent">The entire list of arguments may optionally be enclosed
in parentheses. The
-parentheses are necessary if any of the item expressions use the `<samp><span
class="samp">></span></samp>'
-relational operator; otherwise, it can be confused with a redirection
-(see <a href="#Redirection">Redirection</a>).
-
- <p><a name="index-format-strings-531"></a>The difference between
<code>printf</code> and <code>print</code> is the <var>format</var>
-argument. This is an expression whose value is taken as a string; it
-specifies how to output each of the other arguments. It is called the
-<dfn>format string</dfn>.
-
- <p>The format string is very similar to that in the ISO C library function
-<code>printf</code>. Most of <var>format</var> is text to output verbatim.
-Scattered among this text are <dfn>format specifiers</dfn>—one per item.
-Each format specifier says to output the next item in the argument list
-at that place in the format.
-
- <p>The <code>printf</code> statement does not automatically append a newline
-to its output. It outputs only what the format string specifies.
-So if a newline is needed, you must include one in the format string.
-The output separator variables <code>OFS</code> and <code>ORS</code> have no
effect
-on <code>printf</code> statements. For example:
-
-<pre class="example"> $ awk 'BEGIN {
- > ORS = "\nOUCH!\n"; OFS = "+"
- > msg = "Dont Panic!"
- > printf "%s\n", msg
- > }'
- -| Dont Panic!
-</pre>
- <p class="noindent">Here, neither the `<samp><span
class="samp">+</span></samp>' nor the `<samp><span
class="samp">OUCH</span></samp>' appear when
-the message is printed.
-
-<div class="node">
-<p><hr>
-<a name="Control-Letters"></a>Next: <a rel="next" accesskey="n"
href="#Format-Modifiers">Format Modifiers</a>,
-Previous: <a rel="previous" accesskey="p" href="#Basic-Printf">Basic
Printf</a>,
-Up: <a rel="up" accesskey="u" href="#Printf">Printf</a>
-<br>
-</div>
-
-<h4 class="subsection">4.5.2 Format-Control Letters</h4>
-
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-format_002dcontrol-characters-532"></a><a
name="index-format-specifiers_002c-_0040code_007bprintf_007d-statement-533"></a>
-A format specifier starts with the character `<samp><span
class="samp">%</span></samp>' and ends with
-a <dfn>format-control letter</dfn>—it tells the <code>printf</code>
statement
-how to output one item. The format-control letter specifies what <em>kind</em>
-of value to print. The rest of the format specifier is made up of
-optional <dfn>modifiers</dfn> that control <em>how</em> to print the value,
such as
-the field width. Here is a list of the format-control letters:
-
- <dl>
-<dt><code>%c</code><dd>This prints a number as an ASCII character; thus,
`<samp><span class="samp">printf "%c",
-65</span></samp>' outputs the letter `<samp><span
class="samp">A</span></samp>'. (The output for a string value is
-the first character of the string.)
-
- <br><dt><code>%d</code><span class="roman">,</span><code>
%i</code><dd>These are equivalent; they both print a decimal integer.
-(The `<samp><span class="samp">%i</span></samp>' specification is for
compatibility with ISO C.)
-
- <br><dt><code>%e</code><span class="roman">,</span><code>
%E</code><dd>These print a number in scientific (exponential) notation;
-for example:
-
- <pre class="example"> printf "%4.3e\n", 1950
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">1.950e+03</span></samp>', with a total of four significant
figures, three of
-which follow the decimal point.
-(The `<samp><span class="samp">4.3</span></samp>' represents two modifiers,
-discussed in the next subsection.)
-`<samp><span class="samp">%E</span></samp>' uses `<samp><span
class="samp">E</span></samp>' instead of `<samp><span
class="samp">e</span></samp>' in the output.
-
- <br><dt><code>%f</code><dd>This prints a number in floating-point
notation.
-For example:
-
- <pre class="example"> printf "%4.3f", 1950
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">1950.000</span></samp>', with a total of four significant figures,
three of
-which follow the decimal point.
-(The `<samp><span class="samp">4.3</span></samp>' represents two modifiers,
-discussed in the next subsection.)
-
- <p>On systems supporting IEEE 754 floating point format, values
-representing negative
-infinity are formatted as
-`<samp><span class="samp">-inf</span></samp>' or `<samp><span
class="samp">-infinity</span></samp>',
-and positive infinity as
-`<samp><span class="samp">inf</span></samp>' and `<samp><span
class="samp">-infinity</span></samp>'.
-The special “not a number” value formats as `<samp><span
class="samp">-nan</span></samp>' or `<samp><span
class="samp">nan</span></samp>'.
-
- <br><dt><code>%F</code><dd>Like <code>%f</code> but the infinity and
“not a number” values are spelled
-using uppercase letters.
-
- <p>The <code>%F</code> format is a POSIX extension to ISO C; not all
systems
-support. On those that don't, <samp><span class="command">gawk</span></samp>
uses <code>%f</code> instead.
-
- <br><dt><code>%g</code><span class="roman">,</span><code>
%G</code><dd>These print a number in either scientific notation or in
floating-point
-notation, whichever uses fewer characters; if the result is printed in
-scientific notation, `<samp><span class="samp">%G</span></samp>' uses
`<samp><span class="samp">E</span></samp>' instead of `<samp><span
class="samp">e</span></samp>'.
-
- <br><dt><code>%o</code><dd>This prints an unsigned octal integer.
-
- <br><dt><code>%s</code><dd>This prints a string.
-
- <br><dt><code>%u</code><dd>This prints an unsigned decimal integer.
-(This format is of marginal use, because all numbers in <samp><span
class="command">awk</span></samp>
-are floating-point; it is provided primarily for compatibility with C.)
-
- <br><dt><code>%x</code><span class="roman">,</span><code>
%X</code><dd>These print an unsigned hexadecimal integer;
-`<samp><span class="samp">%X</span></samp>' uses the letters `<samp><span
class="samp">A</span></samp>' through `<samp><span class="samp">F</span></samp>'
-instead of `<samp><span class="samp">a</span></samp>' through `<samp><span
class="samp">f</span></samp>'.
-
- <br><dt><code>%%</code><dd>This isn't a format-control letter, but it
does have meaning—the
-sequence `<samp><span class="samp">%%</span></samp>' outputs one `<samp><span
class="samp">%</span></samp>'; it does not consume an
-argument and it ignores any modifiers.
-</dl>
-
- <p><a
name="index-dark-corner_002c-format_002dcontrol-characters-534"></a><a
name="index-_0040command_007bgawk_007d_002c-format_002dcontrol-characters-535"></a><blockquote>
-<b>NOTE:</b> When using the integer format-control letters for values that are
-outside the range of the widest C integer type, <samp><span
class="command">gawk</span></samp> switches to the
-the `<samp><span class="samp">%g</span></samp>' format specifier. If
<samp><span class="option">--lint</span></samp> is provided on the
-command line (see <a href="#Options">Options</a>), <samp><span
class="command">gawk</span></samp>
-warns about this. Other versions of <samp><span
class="command">awk</span></samp> may print invalid
-values or do something else entirely.
-(d.c.)
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="Format-Modifiers"></a>Next: <a rel="next" accesskey="n"
href="#Printf-Examples">Printf Examples</a>,
-Previous: <a rel="previous" accesskey="p" href="#Control-Letters">Control
Letters</a>,
-Up: <a rel="up" accesskey="u" href="#Printf">Printf</a>
-<br>
-</div>
-
-<h4 class="subsection">4.5.3 Modifiers for <code>printf</code> Formats</h4>
-
-<!-- STARTOFRANGE pfm -->
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-modifiers-536"></a><a
name="index-modifiers_0040comma_007b_007d-in-format-specifiers-537"></a>A
format specification can also include <dfn>modifiers</dfn> that can control
-how much of the item's value is printed, as well as how much space it gets.
-The modifiers come between the `<samp><span class="samp">%</span></samp>' and
the format-control letter.
-We will use the bullet symbol “•” in the following examples to
-represent
-spaces in the output. Here are the possible modifiers, in the order in
-which they may appear:
-
-
-<a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-538"></a>
-<a
name="index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-539"></a>
-<dl><!-- the command does NOT start a secondary -->
-<a
name="index-positional-specifiers_002c-_0040code_007bprintf_007d-statement-540"></a><dt><var>N</var><code>$</code><dd>An
integer constant followed by a `<samp><span class="samp">$</span></samp>' is a
<dfn>positional specifier</dfn>.
-Normally, format specifications are applied to arguments in the order
-given in the format string. With a positional specifier, the format
-specification is applied to a specific argument, instead of what
-would be the next argument in the list. Positional specifiers begin
-counting with one. Thus:
-
- <pre class="example"> printf "%s %s\n", "don't", "panic"
- printf "%2$s %1$s\n", "panic", "don't"
- </pre>
- <p class="noindent">prints the famous friendly message twice.
-
- <p>At first glance, this feature doesn't seem to be of much use.
-It is in fact a <samp><span class="command">gawk</span></samp> extension,
intended for use in translating
-messages at runtime.
-See <a href="#Printf-Ordering">Printf Ordering</a>,
-which describes how and why to use positional specifiers.
-For now, we will not use them.
-
- <br><dt><code>-</code><dd>The minus sign, used before the width modifier
(see later on in
-this table),
-says to left-justify
-the argument within its specified width. Normally, the argument
-is printed right-justified in the specified width. Thus:
-
- <pre class="example"> printf "%-4s", "foo"
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">foo•</span></samp>'.
-
- <br><dt><var>space</var><dd>For numeric conversions, prefix positive
values with a space and
-negative values with a minus sign.
-
- <br><dt><code>+</code><dd>The plus sign, used before the width modifier
(see later on in
-this table),
-says to always supply a sign for numeric conversions, even if the data
-to format is positive. The `<samp><span class="samp">+</span></samp>'
overrides the space modifier.
-
- <br><dt><code>#</code><dd>Use an “alternate form” for certain
control letters.
-For `<samp><span class="samp">%o</span></samp>', supply a leading zero.
-For `<samp><span class="samp">%x</span></samp>' and `<samp><span
class="samp">%X</span></samp>', supply a leading `<samp><span
class="samp">0x</span></samp>' or `<samp><span class="samp">0X</span></samp>'
for
-a nonzero result.
-For `<samp><span class="samp">%e</span></samp>', `<samp><span
class="samp">%E</span></samp>', and `<samp><span
class="samp">%f</span></samp>', the result always contains a
-decimal point.
-For `<samp><span class="samp">%g</span></samp>' and `<samp><span
class="samp">%G</span></samp>', trailing zeros are not removed from the result.
-
- <p><a name="index-dark-corner-541"></a><br><dt><code>0</code><dd>A
leading `<samp><span class="samp">0</span></samp>' (zero) acts as a flag that
indicates that output should be
-padded with zeros instead of spaces.
-This applies even to non-numeric output formats.
-(d.c.)
-This flag only has an effect when the field width is wider than the
-value to print.
-
- <br><dt><code>'</code><dd>A single quote or apostrohe character is a
POSIX extension to ISO C.
-It indicates that the integer part of a floating point value, or the
-entire part of an integer decimal value, should have a thousands-separator
-character in it. This only works in locales that support such characters.
-For example:
-
- <pre class="example"> $ <kbd>cat thousands.awk</kbd>
<i>Show source program</i>
- -| BEGIN { printf "%'d\n", 1234567 }
- $ <kbd>LC_ALL=C gawk -f thousands.awk</kbd>
<i>Run it in "C" locale</i>
- -| 1234567
- $ <kbd>LC_ALL=en_US.UTF-8 gawk -f thousands.awk</kbd>
<i>Run in US English UTF locale</i>
- -| 1,234,567
- </pre>
- <p class="noindent">For more information about locales and
internationalization issues,
-<strong>FIXME: see xxxx</strong>.
-
- <blockquote>
-<b>NOTE:</b> The `<samp><span class="samp">'</span></samp>' flag is a nice
feature, but its use complicates things: it
-now becomes difficult to use it in command-line programs. For information
-on appropriate quoting tricks, <strong>FIXME: see XXXX</strong>.
-</blockquote>
-
- <br><dt><var>width</var><dd>This is a number specifying the desired
minimum width of a field. Inserting any
-number between the `<samp><span class="samp">%</span></samp>' sign and the
format-control character forces the
-field to expand to this width. The default way to do this is to
-pad with spaces on the left. For example:
-
- <pre class="example"> printf "%4s", "foo"
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">•foo</span></samp>'.
-
- <p>The value of <var>width</var> is a minimum width, not a maximum. If
the item
-value requires more than <var>width</var> characters, it can be as wide as
-necessary. Thus, the following:
-
- <pre class="example"> printf "%4s", "foobar"
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">foobar</span></samp>'.
-
- <p>Preceding the <var>width</var> with a minus sign causes the output to
be
-padded with spaces on the right, instead of on the left.
-
- <br><dt><code>.</code><var>prec</var><dd>A period followed by an integer
constant
-specifies the precision to use when printing.
-The meaning of the precision varies by control letter:
-
- <dl>
-<dt><code>%e</code>, <code>%E</code>, <code>%f</code><dd>Number of digits to
the right of the decimal point.
-
- <br><dt><code>%g</code>, <code>%G</code><dd>Maximum number of
significant digits.
-
- <br><dt><code>%d</code>, <code>%i</code>, <code>%o</code>,
<code>%u</code>, <code>%x</code>, <code>%X</code><dd>Minimum number of digits
to print.
-
- <br><dt><code>%s</code><dd>Maximum number of characters from the
string that should print.
-</dl>
-
- <p>Thus, the following:
-
- <pre class="example"> printf "%.4s", "foobar"
- </pre>
- <p class="noindent">prints `<samp><span class="samp">foob</span></samp>'.
-</dl>
-
- <p>The C library <code>printf</code>'s dynamic <var>width</var> and
<var>prec</var>
-capability (for example, <code>"%*.*s"</code>) is supported. Instead of
-supplying explicit <var>width</var> and/or <var>prec</var> values in the format
-string, they are passed in the argument list. For example:
-
-<pre class="example"> w = 5
- p = 3
- s = "abcdefg"
- printf "%*.*s\n", w, p, s
-</pre>
- <p class="noindent">is exactly equivalent to:
-
-<pre class="example"> s = "abcdefg"
- printf "%5.3s\n", s
-</pre>
- <p class="noindent">Both programs output `<samp><span
class="samp">••abc<!-- /@w --></span></samp>'.
-Earlier versions of <samp><span class="command">awk</span></samp> did not
support this capability.
-If you must use such a version, you may simulate this feature by using
-concatenation to build up the format string, like so:
-
-<pre class="example"> w = 5
- p = 3
- s = "abcdefg"
- printf "%" w "." p "s\n", s
-</pre>
- <p class="noindent">This is not particularly easy to read but it does work.
-
-<!-- @cindex lint checks -->
-<p><a
name="index-troubleshooting_002c-fatal-errors_002c-_0040code_007bprintf_007d-format-strings-542"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bprintf_007d-format-strings-and-543"></a>C
programmers may be used to supplying additional
-`<samp><span class="samp">l</span></samp>', `<samp><span
class="samp">L</span></samp>', and `<samp><span class="samp">h</span></samp>'
-modifiers in <code>printf</code> format strings. These are not valid in
<samp><span class="command">awk</span></samp>.
-Most <samp><span class="command">awk</span></samp> implementations silently
ignore these modifiers.
-If <samp><span class="option">--lint</span></samp> is provided on the command
line
-(see <a href="#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> warns about their use. If
<samp><span class="option">--posix</span></samp> is supplied,
-their use is a fatal error.
-<!-- ENDOFRANGE pfm -->
-
-<div class="node">
-<p><hr>
-<a name="Printf-Examples"></a>Previous: <a rel="previous" accesskey="p"
href="#Format-Modifiers">Format Modifiers</a>,
-Up: <a rel="up" accesskey="u" href="#Printf">Printf</a>
-<br>
-</div>
-
-<h4 class="subsection">4.5.4 Examples Using <code>printf</code></h4>
-
-<p>The following is a simple example of
-how to use <code>printf</code> to make an aligned table:
-
-<pre class="example"> awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list
-</pre>
- <p class="noindent">This command
-prints the names of the bulletin boards (<code>$1</code>) in the file
-<samp><span class="file">BBS-list</span></samp> as a string of 10 characters
that are left-justified. It also
-prints the phone numbers (<code>$2</code>) next on the line. This
-produces an aligned two-column table of names and phone numbers,
-as shown here:
-
-<pre class="example"> $ awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list
- -| aardvark 555-5553
- -| alpo-net 555-3412
- -| barfly 555-7685
- -| bites 555-1675
- -| camelot 555-0542
- -| core 555-2912
- -| fooey 555-1234
- -| foot 555-6699
- -| macfoo 555-6480
- -| sdace 555-3430
- -| sabafoo 555-2127
-</pre>
- <p>In this case, the phone numbers had to be printed as strings because
-the numbers are separated by a dash. Printing the phone numbers as
-numbers would have produced just the first three digits: `<samp><span
class="samp">555</span></samp>'.
-This would have been pretty confusing.
-
- <p>It wasn't necessary to specify a width for the phone numbers because
-they are last on their lines. They don't need to have spaces
-after them.
-
- <p>The table could be made to look even nicer by adding headings to the
-tops of the columns. This is done using the <code>BEGIN</code> pattern
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>)
-so that the headers are only printed once, at the beginning of
-the <samp><span class="command">awk</span></samp> program:
-
-<pre class="example"> awk 'BEGIN { print "Name Number"
- print "---- ------" }
- { printf "%-10s %s\n", $1, $2 }' BBS-list
-</pre>
- <p>The above example mixed <code>print</code> and <code>printf</code>
statements in
-the same program. Using just <code>printf</code> statements can produce the
-same results:
-
-<pre class="example"> awk 'BEGIN { printf "%-10s %s\n", "Name", "Number"
- printf "%-10s %s\n", "----", "------" }
- { printf "%-10s %s\n", $1, $2 }' BBS-list
-</pre>
- <p class="noindent">Printing each column heading with the same format
specification
-used for the column elements ensures that the headings
-are aligned just like the columns.
-
- <p>The fact that the same format specification is used three times can be
-emphasized by storing it in a variable, like this:
-
-<pre class="example"> awk 'BEGIN { format = "%-10s %s\n"
- printf format, "Name", "Number"
- printf format, "----", "------" }
- { printf format, $1, $2 }' BBS-list
-</pre>
- <!-- !!! exercise -->
-<p>At this point, it would be a worthwhile exercise to use the
-<code>printf</code> statement to line up the headings and table data for the
-<samp><span class="file">inventory-shipped</span></samp> example that was
covered earlier in the section
-on the <code>print</code> statement
-(see <a href="#Print">Print</a>).
-<!-- ENDOFRANGE printfs -->
-
-<div class="node">
-<p><hr>
-<a name="Redirection"></a>Next: <a rel="next" accesskey="n"
href="#Special-Files">Special Files</a>,
-Previous: <a rel="previous" accesskey="p" href="#Printf">Printf</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.6 Redirecting Output of <code>print</code> and
<code>printf</code></h3>
-
-<p><a name="index-output-redirection-544"></a><a
name="index-redirection-of-output-545"></a>So far, the output from
<code>print</code> and <code>printf</code> has gone
-to the standard
-output, usually the terminal. Both <code>print</code> and <code>printf</code>
can
-also send their output to other places.
-This is called <dfn>redirection</dfn>.
-
- <p>A redirection appears after the <code>print</code> or
<code>printf</code> statement.
-Redirections in <samp><span class="command">awk</span></samp> are written just
like redirections in shell
-commands, except that they are written inside the <samp><span
class="command">awk</span></samp> program.
-
-<!-- the commas here are part of the see also -->
-<p><a
name="index-_0040code_007bprint_007d-statement_002c-See-Also-redirection_002c-of-output-546"></a><a
name="index-_0040code_007bprintf_007d-statement_002c-See-Also-redirection_002c-of-output-547"></a>There
are four forms of output redirection: output to a file, output
-appended to a file, output through a pipe to another command, and output
-to a coprocess. They are all shown for the <code>print</code> statement,
-but they work identically for <code>printf</code>:
-
-
-<a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-548"></a>
-<a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-549"></a>
-<a name="index-operators_002c-input_002foutput-550"></a>
-<dl><dt><code>print </code><var>items</var><code> >
</code><var>output-file</var><dd>This type of redirection prints the items into
the output file named
-<var>output-file</var>. The file name <var>output-file</var> can be any
-expression. Its value is changed to a string and then used as a
-file name (see <a href="#Expressions">Expressions</a>).
-
- <p>When this type of redirection is used, the <var>output-file</var> is
erased
-before the first output is written to it. Subsequent writes to the same
-<var>output-file</var> do not erase <var>output-file</var>, but append to it.
-(This is different from how you use redirections in shell scripts.)
-If <var>output-file</var> does not exist, it is created. For example, here
-is how an <samp><span class="command">awk</span></samp> program can write a
list of BBS names to one
-file named <samp><span class="file">name-list</span></samp>, and a list of
phone numbers to another file
-named <samp><span class="file">phone-list</span></samp>:
-
- <pre class="example"> $ awk '{ print $2 > "phone-list"
- > print $1 > "name-list" }' BBS-list
- $ cat phone-list
- -| 555-5553
- -| 555-3412
- ...
- $ cat name-list
- -| aardvark
- -| alpo-net
- ...
- </pre>
- <p class="noindent">Each output file contains one name or number per line.
-
- <p><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-551"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-552"></a><br><dt><code>print
</code><var>items</var><code> >> </code><var>output-file</var><dd>This
type of redirection prints the items into the pre-existing output file
-named <var>output-file</var>. The difference between this and the
-single-`<samp><span class="samp">></span></samp>' redirection is that the
old contents (if any) of
-<var>output-file</var> are not erased. Instead, the <samp><span
class="command">awk</span></samp> output is
-appended to the file.
-If <var>output-file</var> does not exist, then it is created.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-553"></a><a
name="index-pipes_002c-output-554"></a><a
name="index-output_002c-pipes-555"></a><br><dt><code>print
</code><var>items</var><code> | </code><var>command</var><dd>It is also
possible to send output to another program through a pipe
-instead of into a file. This type of redirection opens a pipe to
-<var>command</var>, and writes the values of <var>items</var> through this pipe
-to another process created to execute <var>command</var>.
-
- <p>The redirection argument <var>command</var> is actually an <samp><span
class="command">awk</span></samp>
-expression. Its value is converted to a string whose contents give
-the shell command to be run. For example, the following produces two
-files, one unsorted list of BBS names, and one list sorted in reverse
-alphabetical order:
-
- <pre class="example"> awk '{ print $1 > "names.unsorted"
- command = "sort -r > names.sorted"
- print $1 | command }' BBS-list
- </pre>
- <p>The unsorted list is written with an ordinary redirection, while
-the sorted list is written by piping through the <samp><span
class="command">sort</span></samp> utility.
-
- <p>The next example uses redirection to mail a message to the mailing
-list `<samp><span class="samp">bug-system</span></samp>'. This might be
useful when trouble is encountered
-in an <samp><span class="command">awk</span></samp> script run periodically
for system maintenance:
-
- <pre class="example"> report = "mail bug-system"
- print "Awk script failed:", $0 | report
- m = ("at record number " FNR " of " FILENAME)
- print m | report
- close(report)
- </pre>
- <p>The message is built using string concatenation and saved in the
variable
-<code>m</code>. It's then sent down the pipeline to the <samp><span
class="command">mail</span></samp> program.
-(The parentheses group the items to concatenate—see
-<a href="#Concatenation">Concatenation</a>.)
-
- <p>The <code>close</code> function is called here because it's a good
idea to close
-the pipe as soon as all the intended output has been sent to it.
-See <a href="#Close-Files-And-Pipes">Close Files And Pipes</a>,
-for more information.
-
- <p>This example also illustrates the use of a variable to represent
-a <var>file</var> or <var>command</var>—it is not necessary to always
-use a string constant. Using a variable is generally a good idea,
-because <samp><span class="command">awk</span></samp> requires that the string
value be spelled identically
-every time.
-
- <p><a name="index-coprocesses-556"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-557"></a><a
name="index-operators_002c-input_002foutput-558"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-559"></a><br><dt><code>print
</code><var>items</var><code> |& </code><var>command</var><dd>This type of
redirection prints the items to the input of <var>command</var>.
-The difference between this and the
-single-`<samp><span class="samp">|</span></samp>' redirection is that the
output from <var>command</var>
-can be read with <code>getline</code>.
-Thus <var>command</var> is a <dfn>coprocess</dfn>, which works together with,
-but subsidiary to, the <samp><span class="command">awk</span></samp> program.
-
- <p>This feature is a <samp><span class="command">gawk</span></samp>
extension, and is not available in
-POSIX <samp><span class="command">awk</span></samp>.
-See <a href="#Two_002dway-I_002fO">Two-way I/O</a>,
-for a more complete discussion.
-</dl>
-
- <p>Redirecting output using `<samp><span class="samp">></span></samp>',
`<samp><span class="samp">>></span></samp>', `<samp><span
class="samp">|</span></samp>', or `<samp><span
class="samp">|&</span></samp>'
-asks the system to open a file, pipe, or coprocess only if the particular
-<var>file</var> or <var>command</var> you specify has not already been written
-to by your program or if it has been closed since it was last written to.
-
- <p><a name="index-troubleshooting_002c-printing-560"></a>It is a common
error to use `<samp><span class="samp">></span></samp>' redirection for the
first <code>print</code>
-to a file, and then to use `<samp><span class="samp">>></span></samp>'
for subsequent output:
-
-<pre class="example"> # clear the file
- print "Don't panic" > "guide.txt"
- ...
- # append
- print "Avoid improbability generators" >> "guide.txt"
-</pre>
- <p class="noindent">This is indeed how redirections must be used from the
shell. But in
-<samp><span class="command">awk</span></samp>, it isn't necessary. In this
kind of case, a program should
-use `<samp><span class="samp">></span></samp>' for all the
<code>print</code> statements, since the output file
-is only opened once.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-561"></a><a
name="index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-limits-562"></a><a
name="index-_0040command_007bawk_007d_002c-implementation-issues_002c-pipes-563"></a><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-pipes-564"></a>As
mentioned earlier
-(see <a href="#Getline-Notes">Getline Notes</a>),
-many
-Many
-<samp><span class="command">awk</span></samp> implementations limit the number
of pipelines that an <samp><span class="command">awk</span></samp>
-program may have open to just one! In <samp><span
class="command">gawk</span></samp>, there is no such limit.
-<samp><span class="command">gawk</span></samp> allows a program to
-open as many pipelines as the underlying operating system permits.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Piping into <samp><span
class="command">sh</span></samp></h4>
-
-<p><a
name="index-advanced-features_002c-piping-into-_0040command_007bsh_007d-565"></a><a
name="index-shells_002c-piping-commands-into-566"></a>
-A particularly powerful way to use redirection is to build command lines
-and pipe them into the shell, <samp><span class="command">sh</span></samp>.
For example, suppose you
-have a list of files brought over from a system where all the file names
-are stored in uppercase, and you wish to rename them to have names in
-all lowercase. The following program is both simple and efficient:
-
-<!-- @cindex @command{mv} utility -->
-<pre class="example"> { printf("mv %s %s\n", $0, tolower($0)) | "sh" }
-
- END { close("sh") }
-</pre>
- <p>The <code>tolower</code> function returns its argument string with all
-uppercase characters converted to lowercase
-(see <a href="#String-Functions">String Functions</a>).
-The program builds up a list of command lines,
-using the <samp><span class="command">mv</span></samp> utility to rename the
files.
-It then sends the list to the shell for execution.
-<!-- ENDOFRANGE outre -->
-<!-- ENDOFRANGE reout -->
-
-<div class="node">
-<p><hr>
-<a name="Special-Files"></a>Next: <a rel="next" accesskey="n"
href="#Close-Files-And-Pipes">Close Files And Pipes</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Redirection">Redirection</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.7 Special File Names in <samp><span
class="command">gawk</span></samp></h3>
-
-<!-- STARTOFRANGE gfn -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-_0040value_007bFN_007ds-in-567"></a>
-<samp><span class="command">gawk</span></samp> provides a number of special
file names that it interprets
-internally. These file names provide access to standard file descriptors,
-process-related information, and TCP/IP networking.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Special-FD">Special FD</a>:
Special files for I/O.
-<li><a accesskey="2" href="#Special-Process">Special Process</a>:
Special files for process information.
-<li><a accesskey="3" href="#Special-Network">Special Network</a>:
Special files for network communications.
-<li><a accesskey="4" href="#Special-Caveats">Special Caveats</a>:
Things to watch out for.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Special-FD"></a>Next: <a rel="next" accesskey="n"
href="#Special-Process">Special Process</a>,
-Up: <a rel="up" accesskey="u" href="#Special-Files">Special Files</a>
-<br>
-</div>
-
-<h4 class="subsection">4.7.1 Special Files for Standard Descriptors</h4>
-
-<p><a name="index-standard-input-568"></a><a
name="index-input_002c-standard-569"></a><a
name="index-standard-output-570"></a><a
name="index-output_002c-standard-571"></a><a
name="index-error-output-572"></a><a name="index-file-descriptors-573"></a><a
name="index-files_002c-descriptors_002c-See-file-descriptors-574"></a>
-Running programs conventionally have three input and output streams
-already available to them for reading and writing. These are known as
-the <dfn>standard input</dfn>, <dfn>standard output</dfn>, and <dfn>standard
error
-output</dfn>. These streams are, by default, connected to your terminal, but
-they are often redirected with the shell, via the `<samp><span
class="samp"><</span></samp>', `<samp><span
class="samp"><<</span></samp>',
-`<samp><span class="samp">></span></samp>', `<samp><span
class="samp">>></span></samp>', `<samp><span
class="samp">>&</span></samp>', and `<samp><span
class="samp">|</span></samp>' operators. Standard error
-is typically used for writing error messages; the reason there are two separate
-streams, standard output and standard error, is so that they can be
-redirected separately.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-error-messages-575"></a><a
name="index-error-handling-576"></a>In other implementations of <samp><span
class="command">awk</span></samp>, the only way to write an error
-message to standard error in an <samp><span class="command">awk</span></samp>
program is as follows:
-
-<pre class="example"> print "Serious error detected!" | "cat 1>&2"
-</pre>
- <p class="noindent">This works by opening a pipeline to a shell command
that can access the
-standard error stream that it inherits from the <samp><span
class="command">awk</span></samp> process.
-This is far from elegant, and it is also inefficient, because it requires a
-separate process. So people writing <samp><span
class="command">awk</span></samp> programs often
-don't do this. Instead, they send the error messages to the
-terminal, like this:
-
-<pre class="example"> print "Serious error detected!" > "/dev/tty"
-</pre>
- <p class="noindent">This usually has the same effect but not always:
although the
-standard error stream is usually the terminal, it can be redirected; when
-that happens, writing to the terminal is not correct. In fact, if
-<samp><span class="command">awk</span></samp> is run from a background job, it
may not have a terminal at all.
-Then opening <samp><span class="file">/dev/tty</span></samp> fails.
-
- <p><samp><span class="command">gawk</span></samp> provides special file
names for accessing the three standard
-streams, as well as any other inherited open files. If the file name matches
-one of these special names when <samp><span class="command">gawk</span></samp>
redirects input or output,
-then it directly uses the stream that the file name stands for.
-These special file names work for all operating systems that <samp><span
class="command">gawk</span></samp>
-has been ported to, not just those that are POSIX-compliant:
-
- <p><a
name="index-_0040value_007bFN_007ds_002c-standard-streams-in-_0040command_007bgawk_007d-577"></a><a
name="index-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-_0028_0040command_007bgawk_007d_0029-578"></a><a
name="index-files_002c-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-579"></a><!--
@cindex @code{/dev/stdin} special file -->
-<!-- @cindex @code{/dev/stdout} special file -->
-<!-- @cindex @code{/dev/stderr} special file -->
-<!-- @cindex @code{/dev/fd} special files -->
- <dl>
-<dt><samp><span class="file">/dev/stdin</span></samp><dd>The standard input
(file descriptor 0).
-
- <br><dt><samp><span class="file">/dev/stdout</span></samp><dd>The
standard output (file descriptor 1).
-
- <br><dt><samp><span class="file">/dev/stderr</span></samp><dd>The
standard error output (file descriptor 2).
-
- <br><dt><samp><span
class="file">/dev/fd/</span><var>N</var></samp><dd>The file associated with
file descriptor <var>N</var>. Such a file must
-be opened by the program initiating the <samp><span
class="command">awk</span></samp> execution (typically
-the shell). Unless special pains are taken in the shell from which
-<samp><span class="command">gawk</span></samp> is invoked, only descriptors 0,
1, and 2 are available.
-</dl>
-
- <p>The file names <samp><span class="file">/dev/stdin</span></samp>,
<samp><span class="file">/dev/stdout</span></samp>, and <samp><span
class="file">/dev/stderr</span></samp>
-are aliases for <samp><span class="file">/dev/fd/0</span></samp>, <samp><span
class="file">/dev/fd/1</span></samp>, and <samp><span
class="file">/dev/fd/2</span></samp>,
-respectively. However, they are more self-explanatory.
-The proper way to write an error message in a <samp><span
class="command">gawk</span></samp> program
-is to use <samp><span class="file">/dev/stderr</span></samp>, like this:
-
-<pre class="example"> print "Serious error detected!" > "/dev/stderr"
-</pre>
- <p><a
name="index-troubleshooting_002c-quotes-with-_0040value_007bFN_007ds-580"></a>Note
the use of quotes around the file name.
-Like any other redirection, the value must be a string.
-It is a common error to omit the quotes, which leads
-to confusing results.
-<!-- Exercise: What does it do? :-) -->
-
-<div class="node">
-<p><hr>
-<a name="Special-Process"></a>Next: <a rel="next" accesskey="n"
href="#Special-Network">Special Network</a>,
-Previous: <a rel="previous" accesskey="p" href="#Special-FD">Special
FD</a>,
-Up: <a rel="up" accesskey="u" href="#Special-Files">Special Files</a>
-<br>
-</div>
-
-<h4 class="subsection">4.7.2 Special Files for Process-Related Information</h4>
-
-<p><a name="index-files_002c-for-process-information-581"></a><a
name="index-process-information_002c-files-for-582"></a><samp><span
class="command">gawk</span></samp> also provides special file names that give
access to information
-about the running <samp><span class="command">gawk</span></samp> process.
Each of these “files” provides
-a single record of information. To read them more than once, they must
-first be closed with the <code>close</code> function
-(see <a href="#Close-Files-And-Pipes">Close Files And Pipes</a>).
-The file names are:
-
-<!-- @cindex @code{/dev/pid} special file -->
-<!-- @cindex @code{/dev/pgrpid} special file -->
-<!-- @cindex @code{/dev/ppid} special file -->
-<!-- @cindex @code{/dev/user} special file -->
-<dl>
-<dt><samp><span class="file">/dev/pid</span></samp><dd>Reading this file
returns the process ID of the current process,
-in decimal form, terminated with a newline.
-
- <br><dt><samp><span class="file">/dev/ppid</span></samp><dd>Reading this
file returns the parent process ID of the current process,
-in decimal form, terminated with a newline.
-
- <br><dt><samp><span class="file">/dev/pgrpid</span></samp><dd>Reading
this file returns the process group ID of the current process,
-in decimal form, terminated with a newline.
-
- <br><dt><samp><span class="file">/dev/user</span></samp><dd>Reading this
file returns a single record terminated with a newline.
-The fields are separated with spaces. The fields represent the
-following information:
-
- <dl>
-<dt><code>$1</code><dd>The return value of the <code>getuid</code> system call
-(the real user ID number).
-
- <br><dt><code>$2</code><dd>The return value of the
<code>geteuid</code> system call
-(the effective user ID number).
-
- <br><dt><code>$3</code><dd>The return value of the
<code>getgid</code> system call
-(the real group ID number).
-
- <br><dt><code>$4</code><dd>The return value of the
<code>getegid</code> system call
-(the effective group ID number).
-</dl>
-
- <p>If there are any additional fields, they are the group IDs returned by
-the <code>getgroups</code> system call.
-(Multiple groups may not be supported on all systems.)
-</dl>
-
- <p>These special file names may be used on the command line as data files,
-as well as for I/O redirections within an <samp><span
class="command">awk</span></samp> program.
-They may not be used as source files with the <samp><span
class="option">-f</span></samp> option.
-
-<!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<blockquote>
-<b>NOTE:</b> The special files that provide process-related information are
now considered
-obsolete and will disappear entirely
-in the next release of <samp><span class="command">gawk</span></samp>.
-<samp><span class="command">gawk</span></samp> prints a warning message every
time you use one of
-these files.
-To obtain process-related information, use the <code>PROCINFO</code> array.
-See <a href="#Auto_002dset">Auto-set</a>.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="Special-Network"></a>Next: <a rel="next" accesskey="n"
href="#Special-Caveats">Special Caveats</a>,
-Previous: <a rel="previous" accesskey="p" href="#Special-Process">Special
Process</a>,
-Up: <a rel="up" accesskey="u" href="#Special-Files">Special Files</a>
-<br>
-</div>
-
-<h4 class="subsection">4.7.3 Special Files for Network Communications</h4>
-
-<p><a name="index-networks_002c-support-for-583"></a><a
name="index-TCP_002fIP_002c-support-for-584"></a>
-Starting with version 3.1 of <samp><span class="command">gawk</span></samp>,
<samp><span class="command">awk</span></samp> programs
-can open a two-way
-TCP/IP connection, acting as either a client or a server.
-This is done using a special file name of the form:
-
-<pre class="example"> <samp><span
class="file">/inet/</span><var>protocol</var><span
class="file">/</span><var>local-port</var><span
class="file">/</span><var>remote-host</var><span
class="file">/</span><var>remote-port</var></samp>
-</pre>
- <p>The <var>protocol</var> is one of `<samp><span
class="samp">tcp</span></samp>', `<samp><span class="samp">udp</span></samp>',
or `<samp><span class="samp">raw</span></samp>',
-and the other fields represent the other essential pieces of information
-for making a networking connection.
-These file names are used with the `<samp><span
class="samp">|&</span></samp>' operator for communicating
-with a coprocess
-(see <a href="#Two_002dway-I_002fO">Two-way I/O</a>).
-This is an advanced feature, mentioned here only for completeness.
-Full discussion is delayed until
-<a href="#TCP_002fIP-Networking">TCP/IP Networking</a>.
-
-<div class="node">
-<p><hr>
-<a name="Special-Caveats"></a>Previous: <a rel="previous" accesskey="p"
href="#Special-Network">Special Network</a>,
-Up: <a rel="up" accesskey="u" href="#Special-Files">Special Files</a>
-<br>
-</div>
-
-<h4 class="subsection">4.7.4 Special File Name Caveats</h4>
-
-<p>Here is a list of things to bear in mind when using the
-special file names that <samp><span class="command">gawk</span></samp>
provides:
-
-
-<a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-_0040value_007bFN_007ds-585"></a>
-<a name="index-_0040value_007bFN_007ds_002c-in-compatibility-mode-586"></a>
-<ul><li>Recognition of these special file names is disabled if <samp><span
class="command">gawk</span></samp> is in
-compatibility mode (see <a href="#Options">Options</a>).
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a name="index-_0040code_007bPROCINFO_007d-array-587"></a><li>The
-As mentioned earlier, the
-special files that provide process-related information are now considered
-obsolete and will disappear entirely
-in the next release of <samp><span class="command">gawk</span></samp>.
-<samp><span class="command">gawk</span></samp> prints a warning message every
time you use one of
-these files.
-To obtain process-related information, use the <code>PROCINFO</code> array.
-See <a href="#Built_002din-Variables">Built-in Variables</a>.
-
- <li>Starting with version 3.1, <samp><span
class="command">gawk</span></samp> <em>always</em>
-interprets these special file names.<a rel="footnote" href="#fn-20"
name="fnd-20"><sup>20</sup></a>
-For example, using `<samp><span class="samp">/dev/fd/4</span></samp>'
-for output actually writes on file descriptor 4, and not on a new
-file descriptor that is <code>dup</code>'ed from file descriptor 4. Most of
-the time this does not matter; however, it is important to <em>not</em>
-close any of the files related to file descriptors 0, 1, and 2.
-Doing so results in unpredictable behavior.
-</ul>
- <!-- ENDOFRANGE gfn -->
-
-<div class="node">
-<p><hr>
-<a name="Close-Files-And-Pipes"></a>Previous: <a rel="previous"
accesskey="p" href="#Special-Files">Special Files</a>,
-Up: <a rel="up" accesskey="u" href="#Printing">Printing</a>
-<br>
-</div>
-
-<h3 class="section">4.8 Closing Input and Output Redirections</h3>
-
-<p><a name="index-files_002c-output_002c-See-output-files-588"></a><!--
STARTOFRANGE ifc -->
-<a name="index-input-files_002c-closing-589"></a><!-- STARTOFRANGE ofc -->
-<a name="index-output_002c-files_0040comma_007b_007d-closing-590"></a><!--
STARTOFRANGE pc -->
-<a name="index-pipes_002c-closing-591"></a><!-- STARTOFRANGE cc -->
-<a name="index-coprocesses_002c-closing-592"></a><a
name="index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-593"></a>
-If the same file name or the same shell command is used with
<code>getline</code>
-more than once during the execution of an <samp><span
class="command">awk</span></samp> program
-(see <a href="#Getline">Getline</a>),
-the file is opened (or the command is executed) the first time only.
-At that time, the first record of input is read from that file or command.
-The next time the same file or command is used with <code>getline</code>,
-another record is read from it, and so on.
-
- <p>Similarly, when a file or pipe is opened for output, the file name or
-command associated with it is remembered by <samp><span
class="command">awk</span></samp>, and subsequent
-writes to the same file or command are appended to the previous writes.
-The file or pipe stays open until <samp><span
class="command">awk</span></samp> exits.
-
- <p><a name="index-_0040code_007bclose_007d-function-594"></a>This implies
that special steps are necessary in order to read the same
-file again from the beginning, or to rerun a shell command (rather than
-reading more output from the same command). The <code>close</code> function
-makes these things possible:
-
-<pre class="example"> close(<var>filename</var>)
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> close(<var>command</var>)
-</pre>
- <p>The argument <var>filename</var> or <var>command</var> can be any
expression. Its
-value must <em>exactly</em> match the string that was used to open the file or
-start the command (spaces and other “irrelevant” characters
-included). For example, if you open a pipe with this:
-
-<pre class="example"> "sort -r names" | getline foo
-</pre>
- <p class="noindent">then you must close it with this:
-
-<pre class="example"> close("sort -r names")
-</pre>
- <p>Once this function call is executed, the next <code>getline</code> from
that
-file or command, or the next <code>print</code> or <code>printf</code> to that
-file or command, reopens the file or reruns the command.
-Because the expression that you use to close a file or pipeline must
-exactly match the expression used to open the file or run the command,
-it is good practice to use a variable to store the file name or command.
-The previous example becomes the following:
-
-<pre class="example"> sortcom = "sort -r names"
- sortcom | getline foo
- ...
- close(sortcom)
-</pre>
- <p class="noindent">This helps avoid hard-to-find typographical errors in
your <samp><span class="command">awk</span></samp>
-programs. Here are some of the reasons for closing an output file:
-
- <ul>
-<li>To write a file and read it back later on in the same <samp><span
class="command">awk</span></samp>
-program. Close the file after writing it, then
-begin reading it with <code>getline</code>.
-
- <li>To write numerous files, successively, in the same <samp><span
class="command">awk</span></samp>
-program. If the files aren't closed, eventually <samp><span
class="command">awk</span></samp> may exceed a
-system limit on the number of open files in one process. It is best to
-close each one when the program has finished writing it.
-
- <li>To make a command finish. When output is redirected through a pipe,
-the command reading the pipe normally continues to try to read input
-as long as the pipe is open. Often this means the command cannot
-really do its work until the pipe is closed. For example, if
-output is redirected to the <samp><span class="command">mail</span></samp>
program, the message is not
-actually sent until the pipe is closed.
-
- <li>To run the same program a second time, with the same arguments.
-This is not the same thing as giving more input to the first run!
-
- <p>For example, suppose a program pipes output to the <samp><span
class="command">mail</span></samp> program.
-If it outputs several lines redirected to this pipe without closing
-it, they make a single message of several lines. By contrast, if the
-program closes the pipe after each line of output, then each line makes
-a separate message.
-</ul>
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bclose_007d-function-595"></a><a
name="index-portability_002c-_0040code_007bclose_007d-function-and-596"></a>If
you use more files than the system allows you to have open,
-<samp><span class="command">gawk</span></samp> attempts to multiplex the
available open files among
-your data files. <samp><span class="command">gawk</span></samp>'s ability to
do this depends upon the
-facilities of your operating system, so it may not always work. It is
-therefore both good practice and good portability advice to always
-use <code>close</code> on your files when you are done with them.
-In fact, if you are using a lot of pipes, it is essential that
-you close commands when done. For example, consider something like this:
-
-<pre class="example"> {
- ...
- command = ("grep " $1 " /some/file | my_prog -q " $3)
- while ((command | getline) > 0) {
- <var>process output of</var> command
- }
- # need close(command) here
- }
-</pre>
- <p>This example creates a new pipeline based on data in <em>each</em>
record.
-Without the call to <code>close</code> indicated in the comment, <samp><span
class="command">awk</span></samp>
-creates child processes to run the commands, until it eventually
-runs out of file descriptors for more pipelines.
-
- <p>Even though each command has finished (as indicated by the end-of-file
-return status from <code>getline</code>), the child process is not
-terminated;<a rel="footnote" href="#fn-21" name="fnd-21"><sup>21</sup></a>
-<!-- Good old Unix: give the marketing guys fits, that's the ticket -->
-more importantly, the file descriptor for the pipe
-is not closed and released until <code>close</code> is called or
-<samp><span class="command">awk</span></samp> exits.
-
- <p><code>close</code> will silently do nothing if given an argument that
-does not represent a file, pipe or coprocess that was opened with
-a redirection.
-
- <p>Note also that `<samp><span class="samp">close(FILENAME)</span></samp>'
has no
-“magic” effects on the implicit loop that reads through the
-files named on the command line. It is, more likely, a close
-of a file that was never opened, so <samp><span
class="command">awk</span></samp> silently
-does nothing.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-pipes_0040comma_007b_007d-closing-597"></a>When
using the `<samp><span class="samp">|&</span></samp>' operator to
communicate with a coprocess,
-it is occasionally useful to be able to close one end of the two-way
-pipe without closing the other.
-This is done by supplying a second argument to <code>close</code>.
-As in any other call to <code>close</code>,
-the first argument is the name of the command or special file used
-to start the coprocess.
-The second argument should be a string, with either of the values
-<code>"to"</code> or <code>"from"</code>. Case does not matter.
-As this is an advanced feature, a more complete discussion is
-delayed until
-<a href="#Two_002dway-I_002fO">Two-way I/O</a>,
-which discusses it in more detail and gives an example.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Using <code>close</code>'s Return
Value</h4>
-
-<p><a
name="index-advanced-features_002c-_0040code_007bclose_007d-function-598"></a><a
name="index-dark-corner_002c-_0040code_007bclose_007d-function-599"></a><a
name="index-_0040code_007bclose_007d-function_002c-return-values-600"></a><a
name="index-return-values_0040comma_007b_007d-_0040code_007bclose_007d-function-601"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bclose_007d-function-602"></a><a
name="index-Unix-_0040command_007bawk_007d_002c-_0040code_007bclose_007d-function-and-603"></a>
-In many versions of Unix <samp><span class="command">awk</span></samp>, the
<code>close</code> function
-is actually a statement. It is a syntax error to try and use the return
-value from <code>close</code>:
-(d.c.)
-
-<pre class="example"> command = "..."
- command | getline info
- retval = close(command) # syntax error in most Unix awks
-</pre>
- <p><samp><span class="command">gawk</span></samp> treats <code>close</code>
as a function.
-The return value is −1 if the argument names something
-that was never opened with a redirection, or if there is
-a system problem closing the file or process.
-In these cases, <samp><span class="command">gawk</span></samp> sets the
built-in variable
-<code>ERRNO</code> to a string describing the problem.
-
- <p>In <samp><span class="command">gawk</span></samp>,
-when closing a pipe or coprocess,
-the return value is the exit status of the command.<a rel="footnote"
href="#fn-22" name="fnd-22"><sup>22</sup></a>
-Otherwise, it is the return value from the system's <code>close</code> or
-<code>fclose</code> C functions when closing input or output
-files, respectively.
-This value is zero if the close succeeds, or −1 if
-it fails.
-
- <p>The POSIX standard is very vague; it says that <code>close</code>
-returns zero on success and non-zero otherwise. In general,
-different implementations vary in what they report when closing
-pipes; thus the return value cannot be used portably.
-(d.c.)
-
-<!-- ENDOFRANGE ifc -->
-<!-- ENDOFRANGE ofc -->
-<!-- ENDOFRANGE pc -->
-<!-- ENDOFRANGE cc -->
-<!-- ENDOFRANGE prnt -->
-<div class="node">
-<p><hr>
-<a name="Expressions"></a>Next: <a rel="next" accesskey="n"
href="#Patterns-and-Actions">Patterns and Actions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Printing">Printing</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">5 Expressions</h2>
-
-<!-- STARTOFRANGE exps -->
-<p><a name="index-expressions-604"></a>
-Expressions are the basic building blocks of <samp><span
class="command">awk</span></samp> patterns
-and actions. An expression evaluates to a value that you can print, test,
-or pass to a function. Additionally, an expression
-can assign a new value to a variable or a field by using an assignment
operator.
-
- <p>An expression can serve as a pattern or action statement on its own.
-Most other kinds of
-statements contain one or more expressions that specify the data on which to
-operate. As in other languages, expressions in <samp><span
class="command">awk</span></samp> include
-variables, array references, constants, and function calls, as well as
-combinations of these with various operators.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Constants">Constants</a>:
String, numeric and regexp constants.
-<li><a accesskey="2" href="#Using-Constant-Regexps">Using Constant
Regexps</a>: When and how to use a regexp constant.
-<li><a accesskey="3" href="#Variables">Variables</a>:
Variables give names to values for later use.
-<li><a accesskey="4" href="#Conversion">Conversion</a>: The
conversion of strings to numbers and vice
- versa.
-<li><a accesskey="5" href="#Arithmetic-Ops">Arithmetic Ops</a>:
Arithmetic operations (`<samp><span class="samp">+</span></samp>', `<samp><span
class="samp">-</span></samp>',
- etc.)
-<li><a accesskey="6" href="#Concatenation">Concatenation</a>:
Concatenating strings.
-<li><a accesskey="7" href="#Assignment-Ops">Assignment Ops</a>:
Changing the value of a variable or a field.
-<li><a accesskey="8" href="#Increment-Ops">Increment Ops</a>:
Incrementing the numeric value of a variable.
-<li><a accesskey="9" href="#Truth-Values">Truth Values</a>:
What is ``true'' and what is ``false''.
-<li><a href="#Typing-and-Comparison">Typing and Comparison</a>: How
variables acquire types and how this
- affects comparison of numbers and strings with
- `<samp><span class="samp"><</span></samp>',
etc.
-<li><a href="#Boolean-Ops">Boolean Ops</a>: Combining
comparison expressions using boolean
- operators `<samp><span
class="samp">||</span></samp>' (``or''), `<samp><span
class="samp">&&</span></samp>'
- (``and'') and `<samp><span
class="samp">!</span></samp>' (``not'').
-<li><a href="#Conditional-Exp">Conditional Exp</a>: Conditional
expressions select between two
- subexpressions under control of a third
- subexpression.
-<li><a href="#Function-Calls">Function Calls</a>: A function
call is an expression.
-<li><a href="#Precedence">Precedence</a>: How various
operators nest.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Constants"></a>Next: <a rel="next" accesskey="n"
href="#Using-Constant-Regexps">Using Constant Regexps</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.1 Constant Expressions</h3>
-
-<p><a name="index-constants_002c-types-of-605"></a>
-The simplest type of expression is the <dfn>constant</dfn>, which always has
-the same value. There are three types of constants: numeric,
-string, and regular expression.
-
- <p>Each is used in the appropriate context when you need a data
-value that isn't going to change. Numeric constants can
-have different forms, but are stored identically internally.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Scalar-Constants">Scalar Constants</a>:
Numeric and string constants.
-<li><a accesskey="2" href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>:
What are octal and hex numbers.
-<li><a accesskey="3" href="#Regexp-Constants">Regexp Constants</a>:
Regular Expression constants.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Scalar-Constants"></a>Next: <a rel="next" accesskey="n"
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>,
-Up: <a rel="up" accesskey="u" href="#Constants">Constants</a>
-<br>
-</div>
-
-<h4 class="subsection">5.1.1 Numeric and String Constants</h4>
-
-<p><a name="index-numeric_002c-constants-606"></a>A <dfn>numeric
constant</dfn> stands for a number. This number can be an
-integer, a decimal fraction, or a number in scientific (exponential)
-notation.<a rel="footnote" href="#fn-23" name="fnd-23"><sup>23</sup></a>
-Here are some examples of numeric constants that all
-have the same value:
-
-<pre class="example"> 105
- 1.05e+2
- 1050e-1
-</pre>
- <p><a name="index-string-constants-607"></a>A string constant consists of a
sequence of characters enclosed in
-double-quotation marks. For example:
-
-<pre class="example"> "parrot"
-</pre>
- <p class="noindent"><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings-608"></a><a
name="index-strings_002c-length-of-609"></a>represents the string whose
contents are `<samp><span class="samp">parrot</span></samp>'. Strings in
-<samp><span class="command">gawk</span></samp> can be of any length, and they
can contain any of the possible
-eight-bit ASCII characters including ASCII <span class="sc">nul</span>
(character code zero).
-Other <samp><span class="command">awk</span></samp>
-implementations may have difficulty with some character codes.
-
-<div class="node">
-<p><hr>
-<a name="Nondecimal_002dnumbers"></a>Next: <a rel="next" accesskey="n"
href="#Regexp-Constants">Regexp Constants</a>,
-Previous: <a rel="previous" accesskey="p" href="#Scalar-Constants">Scalar
Constants</a>,
-Up: <a rel="up" accesskey="u" href="#Constants">Constants</a>
-<br>
-</div>
-
-<h4 class="subsection">5.1.2 Octal and Hexadecimal Numbers</h4>
-
-<p><a name="index-octal-numbers-610"></a><a
name="index-hexadecimal-numbers-611"></a><a
name="index-numbers_002c-octal-612"></a><a
name="index-numbers_002c-hexadecimal-613"></a>
-In <samp><span class="command">awk</span></samp>, all numbers are in decimal;
i.e., base 10. Many other
-programming languages allow you to specify numbers in other bases, often
-octal (base 8) and hexadecimal (base 16).
-In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc.
-Just as `<samp><span class="samp">11</span></samp>', in decimal, is 1 times 10
plus 1, so
-`<samp><span class="samp">11</span></samp>', in octal, is 1 times 8, plus 1.
This equals 9 in decimal.
-In hexadecimal, there are 16 digits. Since the everyday decimal
-number system only has ten digits (`<samp><span
class="samp">0</span></samp>'–`<samp><span
class="samp">9</span></samp>'), the letters
-`<samp><span class="samp">a</span></samp>' through `<samp><span
class="samp">f</span></samp>' are used to represent the rest.
-(Case in the letters is usually irrelevant; hexadecimal `<samp><span
class="samp">a</span></samp>' and `<samp><span class="samp">A</span></samp>'
-have the same value.)
-Thus, `<samp><span class="samp">11</span></samp>', in
-hexadecimal, is 1 times 16 plus 1, which equals 17 in decimal.
-
- <p>Just by looking at plain `<samp><span class="samp">11</span></samp>',
you can't tell what base it's in.
-So, in C, C++, and other languages derived from C,
-<!-- such as PERL, but we won't mention that.... -->
-there is a special notation to help signify the base.
-Octal numbers start with a leading `<samp><span class="samp">0</span></samp>',
-and hexadecimal numbers start with a leading `<samp><span
class="samp">0x</span></samp>' or `<samp><span class="samp">0X</span></samp>':
-
- <dl>
-<dt><code>11</code><dd>Decimal value 11.
-
- <br><dt><code>011</code><dd>Octal 11, decimal value 9.
-
- <br><dt><code>0x11</code><dd>Hexadecimal 11, decimal value 17.
-</dl>
-
- <p>This example shows the difference:
-
-<pre class="example"> $ gawk 'BEGIN { printf "%d, %d, %d\n", 011, 11, 0x11
}'
- -| 9, 11, 17
-</pre>
- <p>Being able to use octal and hexadecimal constants in your programs is
most
-useful when working with data that cannot be represented conveniently as
-characters or as regular numbers, such as binary data of various sorts.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-octal-numbers-and-614"></a><a
name="index-_0040command_007bgawk_007d_002c-hexadecimal-numbers-and-615"></a><samp><span
class="command">gawk</span></samp> allows the use of octal and hexadecimal
-constants in your program text. However, such numbers in the input data
-are not treated differently; doing so by default would break old
-programs.
-(If you really need to do this, use the <samp><span
class="option">--non-decimal-data</span></samp>
-command-line option;
-see <a href="#Nondecimal-Data">Nondecimal Data</a>.)
-If you have octal or hexadecimal data,
-you can use the <code>strtonum</code> function
-(see <a href="#String-Functions">String Functions</a>)
-to convert the data into a number.
-Most of the time, you will want to use octal or hexadecimal constants
-when working with the built-in bit manipulation functions;
-see <a href="#Bitwise-Functions">Bitwise Functions</a>,
-for more information.
-
- <p>Unlike some early C implementations, `<samp><span
class="samp">8</span></samp>' and `<samp><span class="samp">9</span></samp>'
are not valid
-in octal constants; e.g., <samp><span class="command">gawk</span></samp>
treats `<samp><span class="samp">018</span></samp>' as decimal 18:
-
-<pre class="example"> $ gawk 'BEGIN { print "021 is", 021 ; print 018 }'
- -| 021 is 17
- -| 18
-</pre>
- <p><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-octal-numbers-616"></a><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-hexadecimal-numbers-617"></a>Octal
and hexadecimal source code constants are a <samp><span
class="command">gawk</span></samp> extension.
-If <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-they are not available.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: A Constant's Base Does Not Affect Its
Value</h4>
-
-<p><a
name="index-advanced-features_002c-constants_0040comma_007b_007d-values-of-618"></a>
-Once a numeric constant has
-been converted internally into a number,
-<samp><span class="command">gawk</span></samp> no longer remembers
-what the original form of the constant was; the internal value is
-always used. This has particular consequences for conversion of
-numbers to strings:
-
-<pre class="example"> $ gawk 'BEGIN { printf "0x11 is <%s>\n", 0x11
}'
- -| 0x11 is <17>
-</pre>
- <div class="node">
-<p><hr>
-<a name="Regexp-Constants"></a>Previous: <a rel="previous" accesskey="p"
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>,
-Up: <a rel="up" accesskey="u" href="#Constants">Constants</a>
-<br>
-</div>
-
-<h4 class="subsection">5.1.3 Regular Expression Constants</h4>
-
-<!-- STARTOFRANGE rec -->
-<p><a name="index-regexp-constants-619"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-620"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-621"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-622"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-623"></a>A
regexp constant is a regular expression description enclosed in
-slashes, such as <code>/^beginning and end$/<!-- /@w --></code>.
Most regexps used in
-<samp><span class="command">awk</span></samp> programs are constant, but the
`<samp><span class="samp">~</span></samp>' and `<samp><span
class="samp">!~</span></samp>'
-matching operators can also match computed or “dynamic” regexps
-(which are just ordinary strings or variables that contain a regexp).
-<!-- ENDOFRANGE cnst -->
-
-<div class="node">
-<p><hr>
-<a name="Using-Constant-Regexps"></a>Next: <a rel="next" accesskey="n"
href="#Variables">Variables</a>,
-Previous: <a rel="previous" accesskey="p" href="#Constants">Constants</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.2 Using Regular Expression Constants</h3>
-
-<p><a name="index-dark-corner_002c-regexp-constants-624"></a>When used on the
righthand side of the `<samp><span class="samp">~</span></samp>' or
`<samp><span class="samp">!~</span></samp>'
-operators, a regexp constant merely stands for the regexp that is to be
-matched.
-However, regexp constants (such as <code>/foo/</code>) may be used like simple
expressions.
-When a
-regexp constant appears by itself, it has the same meaning as if it appeared
-in a pattern, i.e., `<samp><span class="samp">($0 ~ /foo/)</span></samp>'
-(d.c.)
-See <a href="#Expression-Patterns">Expression Patterns</a>.
-This means that the following two code segments:
-
-<pre class="example"> if ($0 ~ /barfly/ || $0 ~ /camelot/)
- print "found"
-</pre>
- <p class="noindent">and:
-
-<pre class="example"> if (/barfly/ || /camelot/)
- print "found"
-</pre>
- <p class="noindent">are exactly equivalent.
-One rather bizarre consequence of this rule is that the following
-Boolean expression is valid, but does not do what the user probably
-intended:
-
-<pre class="example"> # note that /foo/ is on the left of the ~
- if (/foo/ ~ $1) print "found foo"
-</pre>
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-regexp-constants-and-625"></a><a
name="index-regexp-constants_002c-in-_0040command_007bgawk_007d-626"></a>This
code is “obviously” testing <code>$1</code> for a match against the
regexp
-<code>/foo/</code>. But in fact, the expression `<samp><span
class="samp">/foo/ ~ $1</span></samp>' actually means
-`<samp><span class="samp">($0 ~ /foo/) ~ $1</span></samp>'. In other words,
first match the input record
-against the regexp <code>/foo/</code>. The result is either zero or one,
-depending upon the success or failure of the match. That result
-is then matched against the first field in the record.
-Because it is unlikely that you would ever really want to make this kind of
-test, <samp><span class="command">gawk</span></samp> issues a warning when it
sees this construct in
-a program.
-Another consequence of this rule is that the assignment statement:
-
-<pre class="example"> matches = /foo/
-</pre>
- <p class="noindent">assigns either zero or one to the variable
<code>matches</code>, depending
-upon the contents of the current input record.
-This feature of the language has never been well documented until the
-POSIX specification.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regexp-constants-627"></a><a
name="index-dark-corner_002c-regexp-constants_002c-as-arguments-to-user_002ddefined-functions-628"></a><a
name="index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-629"></a><a
name="index-_0040code_007bsub_007d-function-630"></a><a
name="index-_0040code_007bgsub_007d-function-631"></a>Constant regular
expressions are also used as the first argument for
-the <code>gensub</code>, <code>sub</code>, and <code>gsub</code> functions,
and as the
-second argument of the <code>match</code> function
-(see <a href="#String-Functions">String Functions</a>).
-Modern implementations of <samp><span class="command">awk</span></samp>,
including <samp><span class="command">gawk</span></samp>, allow
-the third argument of <code>split</code> to be a regexp constant, but some
-older implementations do not.
-(d.c.)
-This can lead to confusion when attempting to use regexp constants
-as arguments to user-defined functions
-(see <a href="#User_002ddefined">User-defined</a>).
-For example:
-
-<pre class="example"> function mysub(pat, repl, str, global)
- {
- if (global)
- gsub(pat, repl, str)
- else
- sub(pat, repl, str)
- return str
- }
-
- {
- ...
- text = "hi! hi yourself!"
- mysub(/hi/, "howdy", text, 1)
- ...
- }
-</pre>
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p>In this example, the programmer wants to pass a regexp constant to the
-user-defined function <code>mysub</code>, which in turn passes it on to
-either <code>sub</code> or <code>gsub</code>. However, what really happens is
that
-the <code>pat</code> parameter is either one or zero, depending upon whether
-or not <code>$0</code> matches <code>/hi/</code>.
-<samp><span class="command">gawk</span></samp> issues a warning when it sees a
regexp constant used as
-a parameter to a user-defined function, since passing a truth value in
-this way is probably not what was intended.
-<!-- ENDOFRANGE rec -->
-
-<div class="node">
-<p><hr>
-<a name="Variables"></a>Next: <a rel="next" accesskey="n"
href="#Conversion">Conversion</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Using-Constant-Regexps">Using Constant Regexps</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.3 Variables</h3>
-
-<p><a name="index-variables_002c-user_002ddefined-632"></a><a
name="index-user_002ddefined_002c-variables-633"></a>Variables are ways of
storing values at one point in your program for
-use later in another part of your program. They can be manipulated
-entirely within the program text, and they can also be assigned values
-on the <samp><span class="command">awk</span></samp> command line.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Using-Variables">Using Variables</a>:
Using variables in your programs.
-<li><a accesskey="2" href="#Assignment-Options">Assignment Options</a>:
Setting variables on the command-line and a
- summary of command-line syntax. This is an
- advanced method of input.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Using-Variables"></a>Next: <a rel="next" accesskey="n"
href="#Assignment-Options">Assignment Options</a>,
-Up: <a rel="up" accesskey="u" href="#Variables">Variables</a>
-<br>
-</div>
-
-<h4 class="subsection">5.3.1 Using Variables in a Program</h4>
-
-<p>Variables let you give names to values and refer to them later. Variables
-have already been used in many of the examples. The name of a variable
-must be a sequence of letters, digits, or underscores, and it may not begin
-with a digit. Case is significant in variable names; <code>a</code> and
<code>A</code>
-are distinct variables.
-
- <p>A variable name is a valid expression by itself; it represents the
-variable's current value. Variables are given new values with
-<dfn>assignment operators</dfn>, <dfn>increment operators</dfn>, and
-<dfn>decrement operators</dfn>.
-See <a href="#Assignment-Ops">Assignment Ops</a>.
-<!-- NEXT ED: Can also be changed by sub, gsub, split -->
-
- <p><a name="index-variables_002c-built_002din-634"></a><a
name="index-variables_002c-initializing-635"></a>A few variables have special
built-in meanings, such as <code>FS</code> (the
-field separator), and <code>NF</code> (the number of fields in the current
input
-record). See <a href="#Built_002din-Variables">Built-in Variables</a>, for a
list of the built-in variables.
-These built-in variables can be used and assigned just like all other
-variables, but their values are also used or changed automatically by
-<samp><span class="command">awk</span></samp>. All built-in variables' names
are entirely uppercase.
-
- <p>Variables in <samp><span class="command">awk</span></samp> can be
assigned either numeric or string values.
-The kind of value a variable holds can change over the life of a program.
-By default, variables are initialized to the empty string, which
-is zero if converted to a number. There is no need to
-“initialize” each variable explicitly in <samp><span
class="command">awk</span></samp>,
-which is what you would do in C and in most other traditional languages.
-
-<div class="node">
-<p><hr>
-<a name="Assignment-Options"></a>Previous: <a rel="previous"
accesskey="p" href="#Using-Variables">Using Variables</a>,
-Up: <a rel="up" accesskey="u" href="#Variables">Variables</a>
-<br>
-</div>
-
-<h4 class="subsection">5.3.2 Assigning Variables on the Command Line</h4>
-
-<p><a name="index-variables_002c-assigning-on-command-line-636"></a><a
name="index-command-line_002c-variables_0040comma_007b_007d-assigning-on-637"></a>
-Any <samp><span class="command">awk</span></samp> variable can be set by
including a <dfn>variable assignment</dfn>
-among the arguments on the command line when <samp><span
class="command">awk</span></samp> is invoked
-(see <a href="#Other-Arguments">Other Arguments</a>).
-Such an assignment has the following form:
-
-<pre class="example"> <var>variable</var>=<var>text</var>
-</pre>
- <p><a
name="index-_0040code_007b_002dv_007d-option_002c-variables_0040comma_007b_007d-assigning-638"></a>With
it, a variable is set either at the beginning of the
-<samp><span class="command">awk</span></samp> run or in between input files.
-When the assignment is preceded with the <samp><span
class="option">-v</span></samp> option,
-as in the following:
-
-<pre class="example"> -v <var>variable</var>=<var>text</var>
-</pre>
- <p class="noindent">the variable is set at the very beginning, even before
the
-<code>BEGIN</code> rules are run. The <samp><span
class="option">-v</span></samp> option and its assignment
-must precede all the file name arguments, as well as the program text.
-(See <a href="#Options">Options</a>, for more information about
-the <samp><span class="option">-v</span></samp> option.)
-Otherwise, the variable assignment is performed at a time determined by
-its position among the input file arguments—after the processing of the
-preceding input file argument. For example:
-
-<pre class="example"> awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list
-</pre>
- <p class="noindent">prints the value of field number <code>n</code> for all
input records. Before
-the first file is read, the command line sets the variable <code>n</code>
-equal to four. This causes the fourth field to be printed in lines from
-the file <samp><span class="file">inventory-shipped</span></samp>. After the
first file has finished,
-but before the second file is started, <code>n</code> is set to two, so that
the
-second field is printed in lines from <samp><span
class="file">BBS-list</span></samp>:
-
-<pre class="example"> $ awk '{ print $n }' n=4 inventory-shipped n=2
BBS-list
- -| 15
- -| 24
- ...
- -| 555-5553
- -| 555-3412
- ...
-</pre>
- <p><a
name="index-dark-corner_002c-command_002dline-arguments-639"></a>Command-line
arguments are made available for explicit examination by
-the <samp><span class="command">awk</span></samp> program in the
<code>ARGV</code> array
-(see <a href="#ARGC-and-ARGV">ARGC and ARGV</a>).
-<samp><span class="command">awk</span></samp> processes the values of
command-line assignments for escape
-sequences
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-(d.c.)
-
-<div class="node">
-<p><hr>
-<a name="Conversion"></a>Next: <a rel="next" accesskey="n"
href="#Arithmetic-Ops">Arithmetic Ops</a>,
-Previous: <a rel="previous" accesskey="p" href="#Variables">Variables</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.4 Conversion of Strings and Numbers</h3>
-
-<p><a name="index-converting_002c-strings-to-numbers-640"></a><a
name="index-strings_002c-converting-641"></a><a
name="index-numbers_002c-converting-642"></a><a
name="index-converting_002c-numbers-643"></a>Strings are converted to numbers
and numbers are converted to strings, if the context
-of the <samp><span class="command">awk</span></samp> program demands it. For
example, if the value of
-either <code>foo</code> or <code>bar</code> in the expression `<samp><span
class="samp">foo + bar</span></samp>'
-happens to be a string, it is converted to a number before the addition
-is performed. If numeric values appear in string concatenation, they
-are converted to strings. Consider the following:
-
-<pre class="example"> two = 2; three = 3
- print (two three) + 4
-</pre>
- <p class="noindent">This prints the (numeric) value 27. The numeric values
of
-the variables <code>two</code> and <code>three</code> are converted to strings
and
-concatenated together. The resulting string is converted back to the
-number 23, to which 4 is then added.
-
- <p><a
name="index-null-strings_002c-converting-numbers-to-strings-644"></a><a
name="index-type-conversion-645"></a>If, for some reason, you need to force a
number to be converted to a
-string, concatenate the empty string, <code>""</code>, with that number.
-To force a string to be converted to a number, add zero to that string.
-A string is converted to a number by interpreting any numeric prefix
-of the string as numerals:
-<code>"2.5"</code> converts to 2.5, <code>"1e3"</code> converts to 1000, and
<code>"25fix"</code>
-has a numeric value of 25.
-Strings that can't be interpreted as valid numbers convert to zero.
-
- <p><a name="index-_0040code_007bCONVFMT_007d-variable-646"></a>The exact
manner in which numbers are converted into strings is controlled
-by the <samp><span class="command">awk</span></samp> built-in variable
<code>CONVFMT</code> (see <a href="#Built_002din-Variables">Built-in
Variables</a>).
-Numbers are converted using the <code>sprintf</code> function
-with <code>CONVFMT</code> as the format
-specifier
-(see <a href="#String-Functions">String Functions</a>).
-
- <p><code>CONVFMT</code>'s default value is <code>"%.6g"</code>, which
prints a value with
-at least six significant digits. For some applications, you might want to
-change it to specify more precision.
-On most modern machines,
-17 digits is enough to capture a floating-point number's
-value exactly,
-most of the time.<a rel="footnote" href="#fn-24"
name="fnd-24"><sup>24</sup></a>
-
- <p><a
name="index-dark-corner_002c-_0040code_007bCONVFMT_007d-variable-647"></a>Strange
results can occur if you set <code>CONVFMT</code> to a string that doesn't
-tell <code>sprintf</code> how to format floating-point numbers in a useful
way.
-For example, if you forget the `<samp><span class="samp">%</span></samp>' in
the format, <samp><span class="command">awk</span></samp> converts
-all numbers to the same constant string.
-As a special case, if a number is an integer, then the result of converting
-it to a string is <em>always</em> an integer, no matter what the value of
-<code>CONVFMT</code> may be. Given the following code fragment:
-
-<pre class="example"> CONVFMT = "%2.2f"
- a = 12
- b = a ""
-</pre>
- <p class="noindent"><code>b</code> has the value <code>"12"</code>, not
<code>"12.00"</code>.
-(d.c.)
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-648"></a><a
name="index-_0040code_007bOFMT_007d-variable-649"></a><a
name="index-portability_002c-new-_0040command_007bawk_007d-vs_002e-old-_0040command_007bawk_007d-650"></a><a
name="index-_0040command_007bawk_007d_002c-new-vs_002e-old_002c-_0040code_007bOFMT_007d-variable-651"></a>Prior
to the POSIX standard, <samp><span class="command">awk</span></samp> used the
value
-of <code>OFMT</code> for converting numbers to strings. <code>OFMT</code>
-specifies the output format to use when printing numbers with
<code>print</code>.
-<code>CONVFMT</code> was introduced in order to separate the semantics of
-conversion from the semantics of printing. Both <code>CONVFMT</code> and
-<code>OFMT</code> have the same default value: <code>"%.6g"</code>. In the
vast majority
-of cases, old <samp><span class="command">awk</span></samp> programs do not
change their behavior.
-However, these semantics for <code>OFMT</code> are something to keep in mind
if you must
-port your new style program to older implementations of <samp><span
class="command">awk</span></samp>.
-We recommend
-that instead of changing your programs, just port <samp><span
class="command">gawk</span></samp> itself.
-See <a href="#Print">Print</a>,
-for more information on the <code>print</code> statement.
-
- <p>Finally, once again, where you are can matter when it comes to
-converting between numbers and strings. In
-<a href="#Locales">Locales</a>, we mentioned that the
-local character set and language (the locale) can affect how <samp><span
class="command">gawk</span></samp> matches
-characters. The locale also affects numeric formats. In particular, for
<samp><span class="command">awk</span></samp>
-programs, it affects the decimal point character. The <code>"C"</code>
locale, and most
-English-language locales, use the period character (`<samp><span
class="samp">.</span></samp>') as the decimal point.
-However, many (if not most) European and non-English locales use the comma
(`<samp><span class="samp">,</span></samp>')
-as the decimal point character.
-
- <p>The POSIX standard says that <samp><span
class="command">awk</span></samp> always uses the period as the decimal
-point when reading the <samp><span class="command">awk</span></samp> program
source code, and for command-line
-variable assignments (see <a href="#Other-Arguments">Other Arguments</a>).
-However, when interpreting input data, for <code>print</code> and
<code>printf</code> output,
-and for number to string conversion, the local decimal point character is
used.
-As of version 3.1.3, <samp><span class="command">gawk</span></samp> fully
complies with this aspect
-of the standard. Here are some examples indicating the difference in behavior,
-on a GNU/Linux system:
-
-<pre class="example"> $ gawk 'BEGIN { printf "%g\n", 3.1415927 }'
- -| 3.14159
- $ LC_ALL=en_DK gawk 'BEGIN { printf "%g\n", 3.1415927 }'
- -| 3,14159
- $ echo 4,321 | gawk '{ print $1 + 1 }'
- -| 5
- $ echo 4,321 | LC_ALL=en_DK gawk '{ print $1 + 1 }'
- -| 5,321
-</pre>
- <p class="noindent">The `<samp><span class="samp">en_DK</span></samp>'
locale is for English in Denmark, where the comma acts as
-the decimal point separator. In the normal <code>"C"</code> locale,
<samp><span class="command">gawk</span></samp>
-treats `<samp><span class="samp">4,321</span></samp>' as `<samp><span
class="samp">4</span></samp>', while in the Danish locale, it's treated
-as the full number, `<samp><span class="samp">4.321</span></samp>'.
-
-<div class="node">
-<p><hr>
-<a name="Arithmetic-Ops"></a>Next: <a rel="next" accesskey="n"
href="#Concatenation">Concatenation</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Conversion">Conversion</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.5 Arithmetic Operators</h3>
-
-<p><a name="index-arithmetic-operators-652"></a><a
name="index-operators_002c-arithmetic-653"></a><!-- @cindex addition -->
-<!-- @cindex subtraction -->
-<!-- @cindex multiplication -->
-<!-- @cindex division -->
-<!-- @cindex remainder -->
-<!-- @cindex quotient -->
-<!-- @cindex exponentiation -->
-
- <p>The <samp><span class="command">awk</span></samp> language uses the
common arithmetic operators when
-evaluating expressions. All of these arithmetic operators follow normal
-precedence rules and work as you would expect them to.
-
- <p>The following example uses a file named <samp><span
class="file">grades</span></samp>, which contains
-a list of student names as well as three test scores per student (it's
-a small class):
-
-<pre class="example"> Pat 100 97 58
- Sandy 84 72 93
- Chris 72 92 89
-</pre>
- <p class="noindent">This programs takes the file <samp><span
class="file">grades</span></samp> and prints the average
-of the scores:
-
-<pre class="example"> $ awk '{ sum = $2 + $3 + $4 ; avg = sum / 3
- > print $1, avg }' grades
- -| Pat 85
- -| Sandy 83
- -| Chris 84.3333
-</pre>
- <p>The following list provides the arithmetic operators in <samp><span
class="command">awk</span></samp>, in order from
-the highest precedence to the lowest:
-
- <dl>
-<dt><code>- </code><var>x</var><dd>Negation.
-
- <br><dt><code>+ </code><var>x</var><dd>Unary plus; the expression is
converted to a number.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-arithmetic-operators-and-654"></a><br><dt><var>x</var><code>
^ </code><var>y</var><dt><var>x</var><code> **
</code><var>y</var><dd>Exponentiation; <var>x</var> raised to the <var>y</var>
power. `<samp><span class="samp">2 ^ 3</span></samp>' has
-the value eight; the character sequence `<samp><span
class="samp">**</span></samp>' is equivalent to
-`<samp><span class="samp">^</span></samp>'.
-
- <br><dt><var>x</var><code> * </code><var>y</var><dd>Multiplication.
-
- <p><a name="index-troubleshooting_002c-division-655"></a><a
name="index-division-656"></a><br><dt><var>x</var><code> /
</code><var>y</var><dd>Division; because all numbers in <samp><span
class="command">awk</span></samp> are floating-point
-numbers, the result is <em>not</em> rounded to an integer—`<samp><span
class="samp">3 / 4</span></samp>' has
-the value 0.75. (It is a common mistake, especially for C programmers,
-to forget that <em>all</em> numbers in <samp><span
class="command">awk</span></samp> are floating-point,
-and that division of integer-looking constants produces a real number,
-not an integer.)
-
- <br><dt><var>x</var><code> % </code><var>y</var><dd>Remainder; further
discussion is provided in the text, just
-after this list.
-
- <br><dt><var>x</var><code> + </code><var>y</var><dd>Addition.
-
- <br><dt><var>x</var><code> - </code><var>y</var><dd>Subtraction.
-</dl>
-
- <p>Unary plus and minus have the same precedence,
-the multiplication operators all have the same precedence, and
-addition and subtraction have the same precedence.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-trunc_002dmod-operation-657"></a><a
name="index-trunc_002dmod-operation-658"></a>When computing the remainder of
<var>x</var><code> % </code><var>y</var>,
-the quotient is rounded toward zero to an integer and
-multiplied by <var>y</var>. This result is subtracted from <var>x</var>;
-this operation is sometimes known as “trunc-mod.” The following
-relation always holds:
-
-<pre class="example"> b * int(a / b) + (a % b) == a
-</pre>
- <p>One possibly undesirable effect of this definition of remainder is that
-<var>x</var><code> % </code><var>y</var> is negative if <var>x</var> is
negative. Thus:
-
-<pre class="example"> -17 % 8 = -1
-</pre>
- <p>In other <samp><span class="command">awk</span></samp> implementations,
the signedness of the remainder
-may be machine-dependent.
-<!-- !!! what does posix say? -->
-
- <p><a
name="index-portability_002c-_0040code_007b_002a_002a_007d-operator-and-659"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-660"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-661"></a><blockquote>
-<b>NOTE:</b> The POSIX standard only specifies the use of `<samp><span
class="samp">^</span></samp>'
-for exponentiation.
-For maximum portability, do not use the `<samp><span
class="samp">**</span></samp>' operator.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="Concatenation"></a>Next: <a rel="next" accesskey="n"
href="#Assignment-Ops">Assignment Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Arithmetic-Ops">Arithmetic Ops</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.6 String Concatenation</h3>
-
-<p><a name="index-Kernighan_002c-Brian-662"></a><blockquote>
-<i>It seemed like a good idea at the time.</i><br>
-Brian Kernighan
-</blockquote>
-
- <p><a name="index-string-operators-663"></a><a
name="index-operators_002c-string-664"></a><a
name="index-concatenating-665"></a>There is only one string operation:
concatenation. It does not have a
-specific operator to represent it. Instead, concatenation is performed by
-writing expressions next to one another, with no operator. For example:
-
-<pre class="example"> $ awk '{ print "Field number one: " $1 }' BBS-list
- -| Field number one: aardvark
- -| Field number one: alpo-net
- ...
-</pre>
- <p>Without the space in the string constant after the `<samp><span
class="samp">:</span></samp>', the line
-runs together. For example:
-
-<pre class="example"> $ awk '{ print "Field number one:" $1 }' BBS-list
- -| Field number one:aardvark
- -| Field number one:alpo-net
- ...
-</pre>
- <p><a
name="index-troubleshooting_002c-string-concatenation-666"></a>Because string
concatenation does not have an explicit operator, it is
-often necessary to insure that it happens at the right time by using
-parentheses to enclose the items to concatenate. For example, the
-following code fragment does not concatenate <code>file</code> and
<code>name</code>
-as you might expect:
-
-<pre class="example"> file = "file"
- name = "name"
- print "something meaningful" > file name
-</pre>
- <p class="noindent">It is necessary to use the following:
-
-<pre class="example"> print "something meaningful" > (file name)
-</pre>
- <p><a name="index-order-of-evaluation_002c-concatenation-667"></a><a
name="index-evaluation-order_002c-concatenation-668"></a><a
name="index-side-effects-669"></a>Parentheses should be used around
concatenation in all but the
-most common contexts, such as on the righthand side of `<samp><span
class="samp">=</span></samp>'.
-Be careful about the kinds of expressions used in string concatenation.
-In particular, the order of evaluation of expressions used for concatenation
-is undefined in the <samp><span class="command">awk</span></samp> language.
Consider this example:
-
-<pre class="example"> BEGIN {
- a = "don't"
- print (a " " (a = "panic"))
- }
-</pre>
- <p class="noindent">It is not defined whether the assignment to
<code>a</code> happens
-before or after the value of <code>a</code> is retrieved for producing the
-concatenated value. The result could be either `<samp><span
class="samp">don't panic</span></samp>',
-or `<samp><span class="samp">panic panic</span></samp>'.
-<!-- see test/nasty.awk for a worse example -->
-The precedence of concatenation, when mixed with other operators, is often
-counter-intuitive. Consider this example:
-
-<pre class="example"> $ awk 'BEGIN { print -12 " " -24 }'
- -| -12-24
-</pre>
- <p>This “obviously” is concatenating −12, a space, and
−24.
-But where did the space disappear to?
-The answer lies in the combination of operator precedences and
-<samp><span class="command">awk</span></samp>'s automatic conversion rules.
To get the desired result,
-write the program in the following manner:
-
-<pre class="example"> $ awk 'BEGIN { print -12 " " (-24) }'
- -| -12 -24
-</pre>
- <p>This forces <samp><span class="command">awk</span></samp> to treat the
`<samp><span class="samp">-</span></samp>' on the `<samp><span
class="samp">-24</span></samp>' as unary.
-Otherwise, it's parsed as follows:
-
-<pre class="display"> −12 (<code>" "</code> − 24)
- => −12 (0 − 24)
- => −12 (−24)
- => −12−24
-</pre>
- <p>As mentioned earlier,
-when doing concatenation, <em>parenthesize</em>. Otherwise,
-you're never quite sure what you'll get.
-
-<div class="node">
-<p><hr>
-<a name="Assignment-Ops"></a>Next: <a rel="next" accesskey="n"
href="#Increment-Ops">Increment Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Concatenation">Concatenation</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.7 Assignment Expressions</h3>
-
-<!-- STARTOFRANGE asop -->
-<p><a name="index-assignment-operators-670"></a><!-- STARTOFRANGE opas -->
-<a name="index-operators_002c-assignment-671"></a><!-- STARTOFRANGE exas -->
-<a name="index-expressions_002c-assignment-672"></a><a
name="index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_007d-operator-673"></a><a
name="index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_007d-operator-674"></a>An
<dfn>assignment</dfn> is an expression that stores a (usually different)
-value into a variable. For example, let's assign the value one to the variable
-<code>z</code>:
-
-<pre class="example"> z = 1
-</pre>
- <p>After this expression is executed, the variable <code>z</code> has the
value one.
-Whatever old value <code>z</code> had before the assignment is forgotten.
-
- <p>Assignments can also store string values. For example, the
-following stores
-the value <code>"this food is good"</code> in the variable
<code>message</code>:
-
-<pre class="example"> thing = "food"
- predicate = "good"
- message = "this " thing " is " predicate
-</pre>
- <p class="noindent"><a
name="index-side-effects_002c-assignment-expressions-675"></a>This also
illustrates string concatenation.
-The `<samp><span class="samp">=</span></samp>' sign is called an
<dfn>assignment operator</dfn>. It is the
-simplest assignment operator because the value of the righthand
-operand is stored unchanged.
-Most operators (addition, concatenation, and so on) have no effect
-except to compute a value. If the value isn't used, there's no reason to
-use the operator. An assignment operator is different; it does
-produce a value, but even if you ignore it, the assignment still
-makes itself felt through the alteration of the variable. We call this
-a <dfn>side effect</dfn>.
-
- <p><a name="index-lvalues_002frvalues-676"></a><a
name="index-rvalues_002flvalues-677"></a><a
name="index-assignment-operators_002c-lvalues_002frvalues-678"></a><a
name="index-operators_002c-assignment-679"></a>The lefthand operand of an
assignment need not be a variable
-(see <a href="#Variables">Variables</a>); it can also be a field
-(see <a href="#Changing-Fields">Changing Fields</a>) or
-an array element (see <a href="#Arrays">Arrays</a>).
-These are all called <dfn>lvalues</dfn>,
-which means they can appear on the lefthand side of an assignment operator.
-The righthand operand may be any expression; it produces the new value
-that the assignment stores in the specified variable, field, or array
-element. (Such values are called <dfn>rvalues</dfn>.)
-
- <p><a name="index-variables_002c-types-of-680"></a>It is important to note
that variables do <em>not</em> have permanent types.
-A variable's type is simply the type of whatever value it happens
-to hold at the moment. In the following program fragment, the variable
-<code>foo</code> has a numeric value at first, and a string value later on:
-
-<pre class="example"> foo = 1
- print foo
- foo = "bar"
- print foo
-</pre>
- <p class="noindent">When the second assignment gives <code>foo</code> a
string value, the fact that
-it previously had a numeric value is forgotten.
-
- <p>String values that do not begin with a digit have a numeric value of
-zero. After executing the following code, the value of <code>foo</code> is
five:
-
-<pre class="example"> foo = "a string"
- foo = foo + 5
-</pre>
- <blockquote>
-<b>NOTE:</b> Using a variable as a number and then later as a string
-can be confusing and is poor programming style. The previous two examples
-illustrate how <samp><span class="command">awk</span></samp> works,
<em>not</em> how you should write your
-programs!
-</blockquote>
-
- <p>An assignment is an expression, so it has a value—the same value
that
-is assigned. Thus, `<samp><span class="samp">z = 1</span></samp>' is an
expression with the value one.
-One consequence of this is that you can write multiple assignments together,
-such as:
-
-<pre class="example"> x = y = z = 5
-</pre>
- <p class="noindent">This example stores the value five in all three
variables
-(<code>x</code>, <code>y</code>, and <code>z</code>).
-It does so because the
-value of `<samp><span class="samp">z = 5</span></samp>', which is five, is
stored into <code>y</code> and then
-the value of `<samp><span class="samp">y = z = 5</span></samp>', which is
five, is stored into <code>x</code>.
-
- <p>Assignments may be used anywhere an expression is called for. For
-example, it is valid to write `<samp><span class="samp">x != (y =
1)</span></samp>' to set <code>y</code> to one,
-and then test whether <code>x</code> equals one. But this style tends to make
-programs hard to read; such nesting of assignments should be avoided,
-except perhaps in a one-shot program.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-681"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-682"></a>Aside
from `<samp><span class="samp">=</span></samp>', there are several other
assignment operators that
-do arithmetic with the old value of the variable. For example, the
-operator `<samp><span class="samp">+=</span></samp>' computes a new value by
adding the righthand value
-to the old value of the variable. Thus, the following assignment adds
-five to the value of <code>foo</code>:
-
-<pre class="example"> foo += 5
-</pre>
- <p class="noindent">This is equivalent to the following:
-
-<pre class="example"> foo = foo + 5
-</pre>
- <p class="noindent">Use whichever makes the meaning of your program clearer.
-
- <p>There are situations where using `<samp><span
class="samp">+=</span></samp>' (or any assignment operator)
-is <em>not</em> the same as simply repeating the lefthand operand in the
-righthand expression. For example:
-
- <p><a name="index-Rankin_002c-Pat-683"></a>
-<pre class="example"> # Thanks to Pat Rankin for this example
- BEGIN {
- foo[rand()] += 5
- for (x in foo)
- print x, foo[x]
-
- bar[rand()] = bar[rand()] + 5
- for (x in bar)
- print x, bar[x]
- }
-</pre>
- <p><a
name="index-operators_002c-assignment_002c-evaluation-order-684"></a><a
name="index-assignment-operators_002c-evaluation-order-685"></a>The indices of
<code>bar</code> are practically guaranteed to be different, because
-<code>rand</code> returns different values each time it is called.
-(Arrays and the <code>rand</code> function haven't been covered yet.
-See <a href="#Arrays">Arrays</a>,
-and see <a href="#Numeric-Functions">Numeric Functions</a>, for more
information).
-This example illustrates an important fact about assignment
-operators: the lefthand expression is only evaluated <em>once</em>.
-It is up to the implementation as to which expression is evaluated
-first, the lefthand or the righthand.
-Consider this example:
-
-<pre class="example"> i = 1
- a[i += 2] = i + 1
-</pre>
- <p class="noindent">The value of <code>a[3]</code> could be either two or
four.
-
- <p><a href="#table_002dassign_002dops">table-assign-ops</a> lists the
arithmetic assignment operators. In each
-case, the righthand operand is an expression whose value is converted
-to a number.
-
- <p><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-686"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-687"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-688"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-689"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-690"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-691"></a><a
name="index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-692"></a><a
name="index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-693"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-694"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-695"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-696"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-697"></a><div
class="float">
-<a name="table_002dassign_002dops"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="30%">Operator
</th><th valign="top" width="70%">Effect
-<br></th></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>+=</code> <var>increment</var> </td><td valign="top" width="70%">Adds
<var>increment</var> to the value of <var>lvalue</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>-=</code> <var>decrement</var> </td><td valign="top"
width="70%">Subtracts <var>decrement</var> from the value of <var>lvalue</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>*=</code> <var>coefficient</var> </td><td valign="top"
width="70%">Multiplies the value of <var>lvalue</var> by
<var>coefficient</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>/=</code> <var>divisor</var> </td><td valign="top" width="70%">Divides
the value of <var>lvalue</var> by <var>divisor</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>%=</code> <var>modulus</var> </td><td valign="top" width="70%">Sets
<var>lvalue</var> to its remainder by <var>modulus</var>.
-<a
name="index-_0040command_007bawk_007d-language_002c-POSIX-version-698"></a><a
name="index-POSIX-_0040command_007bawk_007d-699"></a><br></td></tr><tr
align="left"><td valign="top" width="30%"><var>lvalue</var> <code>^=</code>
<var>power</var> </td><td valign="top" width="70%">
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>**=</code> <var>power</var> </td><td valign="top" width="70%">Raises
<var>lvalue</var> to the power <var>power</var>.
- <br></td></tr></table>
-<p><strong class="float-caption">Table 5.1: Arithmetic Assignment
Operators</strong></p></div>
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_002a_002a_003d_007d-operator-and-700"></a><a
name="index-portability_002c-_0040code_007b_002a_002a_003d_007d-operator-and-701"></a><blockquote>
-<b>NOTE:</b> Only the `<samp><span class="samp">^=</span></samp>' operator is
specified by POSIX.
-For maximum portability, do not use the `<samp><span
class="samp">**=</span></samp>' operator.
-</blockquote>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Syntactic Ambiguities Between
`<samp><span class="samp">/=</span></samp>' and Regular Expressions</h4>
-
-<p><a name="index-advanced-features_002c-regexp-constants-702"></a><a
name="index-dark-corner_002c-regexp-constants_002c-_0040code_007b_002f_003d_007d-operator-and-703"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-704"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-705"></a><a
name="index-regexp-constants_002c-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d_002c-_0040code_007b_002f_003d_007d-operator-and-706"></a>
-<!-- derived from email from "Nelson H. F. Beebe" <address@hidden> -->
-<!-- Date: Mon, 1 Sep 1997 13:38:35 -0600 (MDT) -->
-
- <p><a name="index-dark-corner-707"></a><a
name="index-ambiguity_002c-syntactic_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-708"></a><a
name="index-syntactic-ambiguity_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-709"></a><a
name="index-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-710"></a>There
is a syntactic ambiguity between the `<samp><span
class="samp">/=</span></samp>' assignment
-operator and regexp constants whose first character is an `<samp><span
class="samp">=</span></samp>'.
-(d.c.)
-This is most notable in commercial <samp><span
class="command">awk</span></samp> versions.
-For example:
-
-<pre class="example"> $ awk /==/ /dev/null
- error--> awk: syntax error at source line 1
- error--> context is
- error--> >>> /= <<<
- error--> awk: bailing out at source line 1
-</pre>
- <p class="noindent">A workaround is:
-
-<pre class="example"> awk '/[=]=/' /dev/null
-</pre>
- <p><samp><span class="command">gawk</span></samp> does not have this
problem,
-nor do the other
-freely available versions described in
-<a href="#Other-Versions">Other Versions</a>.
-<!-- ENDOFRANGE exas -->
-<!-- ENDOFRANGE opas -->
-<!-- ENDOFRANGE asop -->
-
-<div class="node">
-<p><hr>
-<a name="Increment-Ops"></a>Next: <a rel="next" accesskey="n"
href="#Truth-Values">Truth Values</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Assignment-Ops">Assignment Ops</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.8 Increment and Decrement Operators</h3>
-
-<!-- STARTOFRANGE inop -->
-<p><a name="index-increment-operators-711"></a><!-- STARTOFRANGE opde -->
-<a
name="index-operators_002c-decrement_002fincrement-712"></a><dfn>Increment</dfn>
and <dfn>decrement operators</dfn> increase or decrease the value of
-a variable by one. An assignment operator can do the same thing, so
-the increment operators add no power to the <samp><span
class="command">awk</span></samp> language; however, they
-are convenient abbreviations for very common operations.
-
- <p><a name="index-side-effects-713"></a><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-decrement_002fincrement-operators-714"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-decrement_002fincrement-operators-715"></a><a
name="index-side-effects_002c-decrement_002fincrement-operators-716"></a>The
operator used for adding one is written `<samp><span
class="samp">++</span></samp>'. It can be used to increment
-a variable either before or after taking its value.
-To pre-increment a variable <code>v</code>, write `<samp><span
class="samp">++v</span></samp>'. This adds
-one to the value of <code>v</code>—that new value is also the value of
the
-expression. (The assignment expression `<samp><span class="samp">v +=
1</span></samp>' is completely
-equivalent.)
-Writing the `<samp><span class="samp">++</span></samp>' after the variable
specifies post-increment. This
-increments the variable value just the same; the difference is that the
-value of the increment expression itself is the variable's <em>old</em>
-value. Thus, if <code>foo</code> has the value four, then the expression
`<samp><span class="samp">foo++</span></samp>'
-has the value four, but it changes the value of <code>foo</code> to five.
-In other words, the operator returns the old value of the variable,
-but with the side effect of incrementing it.
-
- <p>The post-increment `<samp><span class="samp">foo++</span></samp>' is
nearly the same as writing `<samp><span class="samp">(foo
-+= 1) - 1</span></samp>'. It is not perfectly equivalent because all numbers
in
-<samp><span class="command">awk</span></samp> are floating-point—in
floating-point, `<samp><span class="samp">foo + 1 - 1</span></samp>' does
-not necessarily equal <code>foo</code>. But the difference is minute as
-long as you stick to numbers that are fairly small (less than 10e12).
-
- <p><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-incrementing-fields-and-arrays-717"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-incrementing-fields-and-arrays-718"></a>Fields
and array elements are incremented
-just like variables. (Use `<samp><span class="samp">$(i++)</span></samp>'
when you want to do a field reference
-and a variable increment at the same time. The parentheses are necessary
-because of the precedence of the field reference operator `<samp><span
class="samp">$</span></samp>'.)
-
- <p><a name="index-decrement-operators-719"></a>The decrement operator
`<samp><span class="samp">--</span></samp>' works just like `<samp><span
class="samp">++</span></samp>', except that
-it subtracts one instead of adding it. As with `<samp><span
class="samp">++</span></samp>', it can be used before
-the lvalue to pre-decrement or after it to post-decrement.
-Following is a summary of increment and decrement expressions:
-
-
-<a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-720"></a>
-<a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-721"></a>
-<dl><dt><code>++</code><var>lvalue</var><dd>This expression increments
<var>lvalue</var>, and the new value becomes the
-value of the expression.
-
- <br><dt><var>lvalue</var><code>++</code><dd>This expression increments
<var>lvalue</var>, but
-the value of the expression is the <em>old</em> value of <var>lvalue</var>.
-
- <p><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-operator-722"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-operator-723"></a><br><dt><code>--</code><var>lvalue</var><dd>This
expression is
-like `<samp><span class="samp">++</span><var>lvalue</var></samp>', but instead
of adding, it subtracts. It
-decrements <var>lvalue</var> and delivers the value that is the result.
-
- <br><dt><var>lvalue</var><code>--</code><dd>This expression is
-like `<samp><var>lvalue</var><span class="samp">++</span></samp>', but instead
of adding, it subtracts. It
-decrements <var>lvalue</var>. The value of the expression is the <em>old</em>
-value of <var>lvalue</var>.
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Operator Evaluation Order</h4>
-
-<p><a
name="index-advanced-features_002c-operators_0040comma_007b_007d-precedence-724"></a><a
name="index-precedence-725"></a><a
name="index-operators_002c-precedence-726"></a><a
name="index-portability_002c-operators-727"></a><a
name="index-evaluation-order-728"></a><a
name="index-Marx_002c-Groucho-729"></a><blockquote>
-<i>Doctor, doctor! It hurts when I do this!<br>
-So don't do that!</i><br>
-Groucho Marx
-</blockquote>
-
-<p class="noindent">What happens for something like the following?
-
-<pre class="example"> b = 6
- print b += b++
-</pre>
- <p class="noindent">Or something even stranger?
-
-<pre class="example"> b = 6
- b += ++b + b++
- print b
-</pre>
- <p><a name="index-side-effects-730"></a>In other words, when do the various
side effects prescribed by the
-postfix operators (`<samp><span class="samp">b++</span></samp>') take effect?
-When side effects happen is <dfn>implementation defined</dfn>.
-In other words, it is up to the particular version of <samp><span
class="command">awk</span></samp>.
-The result for the first example may be 12 or 13, and for the second, it
-may be 22 or 23.
-
- <p>In short, doing things like this is not recommended and definitely
-not anything that you can rely upon for portability.
-You should avoid such things in your own programs.
-<!-- You'll sleep better at night and be able to look at yourself -->
-<!-- in the mirror in the morning. -->
-<!-- ENDOFRANGE inop -->
-<!-- ENDOFRANGE opde -->
-<!-- ENDOFRANGE deop -->
-
-<div class="node">
-<p><hr>
-<a name="Truth-Values"></a>Next: <a rel="next" accesskey="n"
href="#Typing-and-Comparison">Typing and Comparison</a>,
-Previous: <a rel="previous" accesskey="p" href="#Increment-Ops">Increment
Ops</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.9 True and False in <samp><span
class="command">awk</span></samp></h3>
-
-<p><a name="index-truth-values-731"></a><a
name="index-logical-false_002ftrue-732"></a><a
name="index-false_002c-logical-733"></a><a
name="index-true_002c-logical-734"></a>
-<a name="index-null-strings-735"></a>Many programming languages have a special
representation for the concepts
-of “true” and “false.” Such languages usually use the
special
-constants <code>true</code> and <code>false</code>, or perhaps their uppercase
-equivalents.
-However, <samp><span class="command">awk</span></samp> is different.
-It borrows a very simple concept of true and
-false from C. In <samp><span class="command">awk</span></samp>, any nonzero
numeric value <em>or</em> any
-nonempty string value is true. Any other value (zero or the null
-string <code>""</code>) is false. The following program prints `<samp><span
class="samp">A strange
-truth value</span></samp>' three times:
-
-<pre class="example"> BEGIN {
- if (3.1415927)
- print "A strange truth value"
- if ("Four Score And Seven Years Ago")
- print "A strange truth value"
- if (j = 57)
- print "A strange truth value"
- }
-</pre>
- <p><a name="index-dark-corner-736"></a>There is a surprising consequence of
the “nonzero or non-null” rule:
-the string constant <code>"0"</code> is actually true, because it is non-null.
-(d.c.)
-
-<div class="node">
-<p><hr>
-<a name="Typing-and-Comparison"></a>Next: <a rel="next" accesskey="n"
href="#Boolean-Ops">Boolean Ops</a>,
-Previous: <a rel="previous" accesskey="p" href="#Truth-Values">Truth
Values</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.10 Variable Typing and Comparison Expressions</h3>
-
-<blockquote>
-<i>The Guide is definitive. Reality is frequently inaccurate.</i><br>
-The Hitchhiker's Guide to the Galaxy
-</blockquote>
-
-<!-- STARTOFRANGE comex -->
-<p><a name="index-comparison-expressions-737"></a><!-- STARTOFRANGE excom -->
-<a name="index-expressions_002c-comparison-738"></a><a
name="index-expressions_002c-matching_002c-See-comparison-expressions-739"></a><a
name="index-matching_002c-expressions_002c-See-comparison-expressions-740"></a><a
name="index-relational-operators_002c-See-comparison-operators-741"></a><a
name="index-operators_002c-relational_002c-See-operators_0040comma_007b_007d-comparison-742"></a><!--
STARTOFRANGE varting -->
-<a name="index-variable-typing-743"></a><!-- STARTOFRANGE vartypc -->
-<a
name="index-variables_002c-types-of_002c-comparison-expressions-and-744"></a>Unlike
other programming languages, <samp><span class="command">awk</span></samp>
variables do not have a
-fixed type. Instead, they can be either a number or a string, depending
-upon the value that is assigned to them.
-
- <p><a name="index-numeric_002c-strings-745"></a><a
name="index-strings_002c-numeric-746"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-numeric-strings-and-747"></a>The
1992 POSIX standard introduced
-the concept of a <dfn>numeric string</dfn>, which is simply a string that looks
-like a number—for example, <code>" +2"<!-- /@w --></code>. This
concept is used
-for determining the type of a variable.
-The type of the variable is important because the types of two variables
-determine how they are compared.
-In <samp><span class="command">gawk</span></samp>, variable typing follows
these rules:
-
- <ul>
-<li>A numeric constant or the result of a numeric operation has the
<var>numeric</var>
-attribute.
-
- <li>A string constant or the result of a string operation has the
<var>string</var>
-attribute.
-
- <li>Fields, <code>getline</code> input, <code>FILENAME</code>,
<code>ARGV</code> elements,
-<code>ENVIRON</code> elements, and the
-elements of an array created by <code>split</code> that are numeric strings
-have the <var>strnum</var> attribute. Otherwise, they have the
<var>string</var>
-attribute.
-Uninitialized variables also have the <var>strnum</var> attribute.
-
- <li>Attributes propagate across assignments but are not changed by
-any use.
-<!-- (Although a use may cause the entity to acquire an additional -->
-<!-- value such that it has both a numeric and string value, this leaves the
-->
-<!-- attribute unchanged.) -->
-<!-- This is important but not relevant -->
-</ul>
-
- <p>The last rule is particularly important. In the following program,
-<code>a</code> has numeric type, even though it is later used in a string
-operation:
-
-<pre class="example"> BEGIN {
- a = 12.345
- b = a " is a cute number"
- print b
- }
-</pre>
- <p>When two operands are compared, either string comparison or numeric
comparison
-may be used. This depends upon the attributes of the operands, according to the
-following symmetric matrix:
-
-<!-- thanks to Karl Berry, address@hidden, for major help with TeX tables -->
-<pre class="display">
+——————————————————————–
- | STRING NUMERIC STRNUM
-
———–+——————————————————————–
- |
- STRING | string string string
- |
- NUMERIC | string numeric numeric
- |
- STRNUM | string numeric numeric
-
———–+——————————————————————–
-</pre>
- <p>The basic idea is that user input that looks numeric—and
<em>only</em>
-user input—should be treated as numeric, even though it is actually
-made of characters and is therefore also a string.
-Thus, for example, the string constant <code>" +3.14"</code><!-- /@w -->
-is a string, even though it looks numeric,
-and is <em>never</em> treated as number for comparison
-purposes.
-
- <p>In short, when one operand is a “pure” string, such as a
string
-constant, then a string comparison is performed. Otherwise, a
-numeric comparison is performed.<a rel="footnote" href="#fn-25"
name="fnd-25"><sup>25</sup></a>
-
- <p><dfn>Comparison expressions</dfn> compare strings or numbers for
-relationships such as equality. They are written using <dfn>relational
-operators</dfn>, which are a superset of those in C.
-<a href="#table_002drelational_002dops">table-relational-ops</a> describes
them.
-
- <p><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-748"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-749"></a><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-750"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-751"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-752"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-753"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-754"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-755"></a><a
name="index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-756"></a><a
name="index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-757"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-758"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-759"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-760"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-761"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-762"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-763"></a><a
name="index-_0040code_007bin_007d-operator-764"></a><div class="float">
-<a name="table_002drelational_002dops"></a>
- <p><table summary=""><tr align="left"><th valign="top"
width="25%">Expression </th><th valign="top" width="75%">Result
-<br></th></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code><</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is less than <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code><=</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is less than or equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>></code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is greater than <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>>=</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is greater than or equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>==</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>!=</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is not equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>~</code> <var>y</var> </td><td valign="top" width="75%">True if the
string <var>x</var> matches the regexp denoted by <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>!~</code> <var>y</var> </td><td valign="top" width="75%">True if the
string <var>x</var> does not match the regexp denoted by <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top"
width="25%"><var>subscript</var> <code>in</code> <var>array</var> </td><td
valign="top" width="75%">True if the array <var>array</var> has an element with
the subscript <var>subscript</var>.
- <br></td></tr></table>
-<p><strong class="float-caption">Table 5.2: Relational
Operators</strong></p></div>
-
- <p>Comparison expressions have the value one if true and zero if false.
-When comparing operands of mixed types, numeric operands are converted
-to strings using the value of <code>CONVFMT</code>
-(see <a href="#Conversion">Conversion</a>).
-
- <p>Strings are compared
-by comparing the first character of each, then the second character of each,
-and so on. Thus, <code>"10"</code> is less than <code>"9"</code>. If there
are two
-strings where one is a prefix of the other, the shorter string is less than
-the longer one. Thus, <code>"abc"</code> is less than <code>"abcd"</code>.
-
- <p><a
name="index-troubleshooting_002c-_0040code_007b_003d_003d_007d-operator-765"></a>It
is very easy to accidentally mistype the `<samp><span
class="samp">==</span></samp>' operator and
-leave off one of the `<samp><span class="samp">=</span></samp>' characters.
The result is still valid <samp><span class="command">awk</span></samp>
-code, but the program does not do what is intended:
-
-<pre class="example"> if (a = b) # oops! should be a == b
- ...
- else
- ...
-</pre>
- <p class="noindent">Unless <code>b</code> happens to be zero or the null
string, the <code>if</code>
-part of the test always succeeds. Because the operators are
-so similar, this kind of error is very difficult to spot when
-scanning the source code.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-comparison-operators-and-766"></a>The
following table of expressions illustrates the kind of comparison
-<samp><span class="command">gawk</span></samp> performs, as well as what the
result of the comparison is:
-
- <dl>
-<dt><code>1.5 <= 2.0</code><dd>numeric comparison (true)
-
- <br><dt><code>"abc" >= "xyz"</code><dd>string comparison (false)
-
- <br><dt><code>1.5 != " +2"</code><dd>string comparison (true)
-
- <br><dt><code>"1e2" < "3"</code><dd>string comparison (true)
-
- <br><dt><code>a = 2; b = "2"</code><dt><code>a == b</code><dd>string
comparison (true)
-
- <br><dt><code>a = 2; b = " +2"</code><br><dt><code>a ==
b</code><dd>string comparison (false)
-</dl>
-
- <p>In the next example:
-
-<pre class="example"> $ echo 1e2 3 | awk '{ print ($1 < $2) ? "true" :
"false" }'
- -| false
-</pre>
- <p><a
name="index-comparison-expressions_002c-string-vs_002e-regexp-767"></a><!--
@cindex string comparison vs. regexp comparison -->
-<!-- @cindex regexp comparison vs. string comparison -->
-the result is `<samp><span class="samp">false</span></samp>' because both
<code>$1</code> and <code>$2</code>
-are user input. They are numeric strings—therefore both have
-the <var>strnum</var> attribute, dictating a numeric comparison.
-The purpose of the comparison rules and the use of numeric strings is
-to attempt to produce the behavior that is “least surprising,”
while
-still “doing the right thing.”
-String comparisons and regular expression comparisons are very different.
-For example:
-
-<pre class="example"> x == "foo"
-</pre>
- <p class="noindent">has the value one, or is true if the variable
<code>x</code>
-is precisely `<samp><span class="samp">foo</span></samp>'. By contrast:
-
-<pre class="example"> x ~ /foo/
-</pre>
- <p class="noindent">has the value one if <code>x</code> contains
`<samp><span class="samp">foo</span></samp>', such as
-<code>"Oh, what a fool am I!"</code>.
-
- <p><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-768"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-769"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-770"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-771"></a>The
righthand operand of the `<samp><span class="samp">~</span></samp>' and
`<samp><span class="samp">!~</span></samp>' operators may be
-either a regexp constant (<code>/.../</code>) or an ordinary
-expression. In the latter case, the value of the expression as a string is
used as a
-dynamic regexp (see <a href="#Regexp-Usage">Regexp Usage</a>; also
-see <a href="#Computed-Regexps">Computed Regexps</a>).
-
- <p><a
name="index-_0040command_007bawk_007d_002c-regexp-constants-and-772"></a><a
name="index-regexp-constants-773"></a>In modern implementations of <samp><span
class="command">awk</span></samp>, a constant regular
-expression in slashes by itself is also an expression. The regexp
-<code>/</code><var>regexp</var><code>/</code> is an abbreviation for the
following comparison expression:
-
-<pre class="example"> $0 ~ /<var>regexp</var>/
-</pre>
- <p>One special place where <code>/foo/</code> is <em>not</em> an
abbreviation for
-`<samp><span class="samp">$0 ~ /foo/</span></samp>' is when it is the
righthand operand of `<samp><span class="samp">~</span></samp>' or
-`<samp><span class="samp">!~</span></samp>'.
-See <a href="#Using-Constant-Regexps">Using Constant Regexps</a>,
-where this is discussed in more detail.
-<!-- ENDOFRANGE comex -->
-<!-- ENDOFRANGE excom -->
-<!-- ENDOFRANGE vartypc -->
-<!-- ENDOFRANGE varting -->
-
-<div class="node">
-<p><hr>
-<a name="Boolean-Ops"></a>Next: <a rel="next" accesskey="n"
href="#Conditional-Exp">Conditional Exp</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Typing-and-Comparison">Typing and Comparison</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.11 Boolean Expressions</h3>
-
-<p><a name="index-and-Boolean_002dlogic-operator-774"></a><a
name="index-or-Boolean_002dlogic-operator-775"></a><a
name="index-not-Boolean_002dlogic-operator-776"></a><!-- STARTOFRANGE exbo -->
-<a name="index-expressions_002c-Boolean-777"></a><!-- STARTOFRANGE boex -->
-<a name="index-Boolean-expressions-778"></a><a
name="index-operators_002c-Boolean_002c-See-Boolean-expressions-779"></a><a
name="index-Boolean-operators_002c-See-Boolean-expressions-780"></a><a
name="index-logical-operators_002c-See-Boolean-expressions-781"></a><a
name="index-operators_002c-logical_002c-See-Boolean-expressions-782"></a>
-A <dfn>Boolean expression</dfn> is a combination of comparison expressions or
-matching expressions, using the Boolean operators “or”
-(`<samp><span class="samp">||</span></samp>'), “and” (`<samp><span
class="samp">&&</span></samp>'), and “not” (`<samp><span
class="samp">!</span></samp>'), along with
-parentheses to control nesting. The truth value of the Boolean expression is
-computed by combining the truth values of the component expressions.
-Boolean expressions are also referred to as <dfn>logical expressions</dfn>.
-The terms are equivalent.
-
- <p>Boolean expressions can be used wherever comparison and matching
-expressions can be used. They can be used in <code>if</code>,
<code>while</code>,
-<code>do</code>, and <code>for</code> statements
-(see <a href="#Statements">Statements</a>).
-They have numeric values (one if true, zero if false) that come into play
-if the result of the Boolean expression is stored in a variable or
-used in arithmetic.
-
- <p>In addition, every Boolean expression is also a valid pattern, so
-you can use one as a pattern to control the execution of rules.
-The Boolean operators are:
-
- <dl>
-<dt><var>boolean1</var><code> && </code><var>boolean2</var><dd>True if
both <var>boolean1</var> and <var>boolean2</var> are true. For example,
-the following statement prints the current input record if it contains
-both `<samp><span class="samp">2400</span></samp>' and `<samp><span
class="samp">foo</span></samp>':
-
- <pre class="example"> if ($0 ~ /2400/ && $0 ~ /foo/)
print
- </pre>
- <p><a name="index-side-effects_002c-Boolean-operators-783"></a>The
subexpression <var>boolean2</var> is evaluated only if <var>boolean1</var>
-is true. This can make a difference when <var>boolean2</var> contains
-expressions that have side effects. In the case of `<samp><span
class="samp">$0 ~ /foo/ &&
-($2 == bar++)</span></samp>', the variable <code>bar</code> is not incremented
if there is
-no substring `<samp><span class="samp">foo</span></samp>' in the record.
-
- <br><dt><var>boolean1</var><code> || </code><var>boolean2</var><dd>True
if at least one of <var>boolean1</var> or <var>boolean2</var> is true.
-For example, the following statement prints all records in the input
-that contain <em>either</em> `<samp><span class="samp">2400</span></samp>' or
-`<samp><span class="samp">foo</span></samp>' or both:
-
- <pre class="example"> if ($0 ~ /2400/ || $0 ~ /foo/) print
- </pre>
- <p>The subexpression <var>boolean2</var> is evaluated only if
<var>boolean1</var>
-is false. This can make a difference when <var>boolean2</var> contains
-expressions that have side effects.
-
- <br><dt><code>! </code><var>boolean</var><dd>True if <var>boolean</var>
is false. For example,
-the following program prints `<samp><span class="samp">no home!</span></samp>'
in
-the unusual event that the <samp><span class="env">HOME</span></samp>
environment
-variable is not defined:
-
- <pre class="example"> BEGIN { if (! ("HOME" in ENVIRON))
- print "no home!" }
- </pre>
- <p>(The <code>in</code> operator is described in
-<a href="#Reference-to-Elements">Reference to Elements</a>.)
-</dl>
-
- <p><a name="index-short_002dcircuit-operators-784"></a><a
name="index-operators_002c-short_002dcircuit-785"></a><a
name="index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-786"></a><a
name="index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007d-operator-787"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-788"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-789"></a>The
`<samp><span class="samp">&&</span></samp>' and `<samp><span
class="samp">||</span></samp>' operators are called <dfn>short-circuit</dfn>
-operators because of the way they work. Evaluation of the full expression
-is “short-circuited” if the result can be determined part way
through
-its evaluation.
-
- <p><a name="index-line-continuations-790"></a>Statements that use
`<samp><span class="samp">&&</span></samp>' or `<samp><span
class="samp">||</span></samp>' can be continued simply
-by putting a newline after them. But you cannot put a newline in front
-of either of these operators without using backslash continuation
-(see <a href="#Statements_002fLines">Statements/Lines</a>).
-
- <p><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d--operator-791"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-792"></a><a
name="index-newlines-793"></a><a name="index-variables_002c-flag-794"></a><a
name="index-flag-variables-795"></a>The actual value of an expression using the
`<samp><span class="samp">!</span></samp>' operator is
-either one or zero, depending upon the truth value of the expression it
-is applied to.
-The `<samp><span class="samp">!</span></samp>' operator is often useful for
changing the sense of a flag
-variable from false to true and back again. For example, the following
-program is one way to print lines in between special bracketing lines:
-
-<pre class="example"> $1 == "START" { interested = ! interested; next }
- interested == 1 { print }
- $1 == "END" { interested = ! interested; next }
-</pre>
- <p class="noindent">The variable <code>interested</code>, as with all
<samp><span class="command">awk</span></samp> variables, starts
-out initialized to zero, which is also false. When a line is seen whose
-first field is `<samp><span class="samp">START</span></samp>', the value of
<code>interested</code> is toggled
-to true, using `<samp><span class="samp">!</span></samp>'. The next rule
prints lines as long as
-<code>interested</code> is true. When a line is seen whose first field is
-`<samp><span class="samp">END</span></samp>', <code>interested</code> is
toggled back to false.
-
- <p><a name="index-_0040code_007bnext_007d-statement-796"></a><blockquote>
-<b>NOTE:</b> The <code>next</code> statement is discussed in
-<a href="#Next-Statement">Next Statement</a>.
-<code>next</code> tells <samp><span class="command">awk</span></samp> to skip
the rest of the rules, get the
-next record, and start processing the rules over again at the top.
-The reason it's there is to avoid printing the bracketing
-`<samp><span class="samp">START</span></samp>' and `<samp><span
class="samp">END</span></samp>' lines.
-</blockquote>
- <!-- ENDOFRANGE exbo -->
-<!-- ENDOFRANGE boex -->
-
-<div class="node">
-<p><hr>
-<a name="Conditional-Exp"></a>Next: <a rel="next" accesskey="n"
href="#Function-Calls">Function Calls</a>,
-Previous: <a rel="previous" accesskey="p" href="#Boolean-Ops">Boolean
Ops</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.12 Conditional Expressions</h3>
-
-<p><a name="index-conditional-expressions-797"></a><a
name="index-expressions_002c-conditional-798"></a><a
name="index-expressions_002c-selecting-799"></a>
-A <dfn>conditional expression</dfn> is a special kind of expression that has
-three operands. It allows you to use one expression's value to select
-one of two other expressions.
-The conditional expression is the same as in the C language,
-as shown here:
-
-<pre class="example"> <var>selector</var> ? <var>if-true-exp</var> :
<var>if-false-exp</var>
-</pre>
- <p class="noindent">There are three subexpressions. The first,
<var>selector</var>, is always
-computed first. If it is “true” (not zero or not null), then
-<var>if-true-exp</var> is computed next and its value becomes the value of
-the whole expression. Otherwise, <var>if-false-exp</var> is computed next
-and its value becomes the value of the whole expression.
-For example, the following expression produces the absolute value of
<code>x</code>:
-
-<pre class="example"> x >= 0 ? x : -x
-</pre>
- <p><a name="index-side-effects_002c-conditional-expressions-800"></a>Each
time the conditional expression is computed, only one of
-<var>if-true-exp</var> and <var>if-false-exp</var> is used; the other is
ignored.
-This is important when the expressions have side effects. For example,
-this conditional expression examines element <code>i</code> of either array
-<code>a</code> or array <code>b</code>, and increments <code>i</code>:
-
-<pre class="example"> x == y ? a[i++] : b[i++]
-</pre>
- <p class="noindent">This is guaranteed to increment <code>i</code> exactly
once, because each time
-only one of the two increment expressions is executed
-and the other is not.
-See <a href="#Arrays">Arrays</a>,
-for more information about arrays.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-line-continuations-801"></a><a
name="index-line-continuations_002c-_0040command_007bgawk_007d-802"></a><a
name="index-_0040command_007bgawk_007d_002c-line-continuation-in-803"></a>As a
minor <samp><span class="command">gawk</span></samp> extension,
-a statement that uses `<samp><span class="samp">?:</span></samp>' can be
continued simply
-by putting a newline after either character.
-However, putting a newline in front
-of either character does not work without using backslash continuation
-(see <a href="#Statements_002fLines">Statements/Lines</a>).
-If <samp><span class="option">--posix</span></samp> is specified
-(see <a href="#Options">Options</a>), then this extension is disabled.
-
-<div class="node">
-<p><hr>
-<a name="Function-Calls"></a>Next: <a rel="next" accesskey="n"
href="#Precedence">Precedence</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Conditional-Exp">Conditional Exp</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.13 Function Calls</h3>
-
-<p><a name="index-function-calls-804"></a>
-A <dfn>function</dfn> is a name for a particular calculation.
-This enables you to
-ask for it by name at any point in the program. For
-example, the function <code>sqrt</code> computes the square root of a number.
-
- <p><a name="index-functions_002c-built_002din-805"></a>A fixed set of
functions are <dfn>built-in</dfn>, which means they are
-available in every <samp><span class="command">awk</span></samp> program. The
<code>sqrt</code> function is one
-of these. See <a href="#Built_002din">Built-in</a>, for a list of built-in
-functions and their descriptions. In addition, you can define
-functions for use in your program.
-See <a href="#User_002ddefined">User-defined</a>,
-for instructions on how to do this.
-
- <p><a name="index-arguments_002c-in-function-calls-806"></a>The way to use
a function is with a <dfn>function call</dfn> expression,
-which consists of the function name followed immediately by a list of
-<dfn>arguments</dfn> in parentheses. The arguments are expressions that
-provide the raw materials for the function's calculations.
-When there is more than one argument, they are separated by commas. If
-there are no arguments, just write `<samp><span class="samp">()</span></samp>'
after the function name.
-The following examples show function calls with and without arguments:
-
-<pre class="example"> sqrt(x^2 + y^2) <i>one argument</i>
- atan2(y, x) <i>two arguments</i>
- rand() <i>no arguments</i>
-</pre>
- <p><a
name="index-troubleshooting_002c-function-call-syntax-807"></a><strong>Caution:</strong>
-Do not put any space between the function name and the open-parenthesis!
-A user-defined function name looks just like the name of a
-variable—a space would make the expression look like concatenation of
-a variable with an expression inside parentheses.
-
- <p>With built-in functions, space before the parenthesis is harmless, but
-it is best not to get into the habit of using space to avoid mistakes
-with user-defined functions. Each function expects a particular number
-of arguments. For example, the <code>sqrt</code> function must be called with
-a single argument, the number of which to take the square root:
-
-<pre class="example"> sqrt(<var>argument</var>)
-</pre>
- <p>Some of the built-in functions have one or
-more optional arguments.
-If those arguments are not supplied, the functions
-use a reasonable default value.
-See <a href="#Built_002din">Built-in</a>, for full details. If arguments
-are omitted in calls to user-defined functions, then those arguments are
-treated as local variables and initialized to the empty string
-(see <a href="#User_002ddefined">User-defined</a>).
-
- <p><a name="index-side-effects_002c-function-calls-808"></a>Like every
other expression, the function call has a value, which is
-computed by the function based on the arguments you give it. In this
-example, the value of `<samp><span
class="samp">sqrt(</span><var>argument</var><span class="samp">)</span></samp>'
is the square root of
-<var>argument</var>. A function can also have side effects, such as assigning
-values to certain variables or doing I/O.
-The following program reads numbers, one number per line, and prints the
-square root of each one:
-
-<pre class="example"> $ awk '{ print "The square root of", $1, "is",
sqrt($1) }'
- 1
- -| The square root of 1 is 1
- 3
- -| The square root of 3 is 1.73205
- 5
- -| The square root of 5 is 2.23607
- <kbd>Ctrl-d</kbd>
-</pre>
- <div class="node">
-<p><hr>
-<a name="Precedence"></a>Previous: <a rel="previous" accesskey="p"
href="#Function-Calls">Function Calls</a>,
-Up: <a rel="up" accesskey="u" href="#Expressions">Expressions</a>
-<br>
-</div>
-
-<h3 class="section">5.14 Operator Precedence (How Operators Nest)</h3>
-
-<!-- STARTOFRANGE prec -->
-<p><a name="index-precedence-809"></a><!-- STARTOFRANGE oppr -->
-<a name="index-operators_002c-precedence-810"></a>
-<dfn>Operator precedence</dfn> determines how operators are grouped when
-different operators appear close by in one expression. For example,
-`<samp><span class="samp">*</span></samp>' has higher precedence than
`<samp><span class="samp">+</span></samp>'; thus, `<samp><span class="samp">a +
b * c</span></samp>'
-means to multiply <code>b</code> and <code>c</code>, and then add
<code>a</code> to the
-product (i.e., `<samp><span class="samp">a + (b * c)</span></samp>').
-
- <p>The normal precedence of the operators can be overruled by using
parentheses.
-Think of the precedence rules as saying where the
-parentheses are assumed to be. In
-fact, it is wise to always use parentheses whenever there is an unusual
-combination of operators, because other people who read the program may
-not remember what the precedence is in this case.
-Even experienced programmers occasionally forget the exact rules,
-which leads to mistakes.
-Explicit parentheses help prevent
-any such mistakes.
-
- <p>When operators of equal precedence are used together, the leftmost
-operator groups first, except for the assignment, conditional, and
-exponentiation operators, which group in the opposite order.
-Thus, `<samp><span class="samp">a - b + c</span></samp>' groups as
`<samp><span class="samp">(a - b) + c</span></samp>' and
-`<samp><span class="samp">a = b = c</span></samp>' groups as `<samp><span
class="samp">a = (b = c)</span></samp>'.
-
- <p>The precedence of prefix unary operators does not matter as long as only
-unary operators are involved, because there is only one way to interpret
-them: innermost first. Thus, `<samp><span class="samp">$++i</span></samp>'
means `<samp><span class="samp">$(++i)</span></samp>' and
-`<samp><span class="samp">++$x</span></samp>' means `<samp><span
class="samp">++($x)</span></samp>'. However, when another operator follows
-the operand, then the precedence of the unary operators can matter.
-`<samp><span class="samp">$x^2</span></samp>' means `<samp><span
class="samp">($x)^2</span></samp>', but `<samp><span
class="samp">-x^2</span></samp>' means
-`<samp><span class="samp">-(x^2)</span></samp>', because `<samp><span
class="samp">-</span></samp>' has lower precedence than `<samp><span
class="samp">^</span></samp>',
-whereas `<samp><span class="samp">$</span></samp>' has higher precedence.
-This table presents <samp><span class="command">awk</span></samp>'s operators,
in order of highest
-to lowest precedence:
-
-<!-- use @code in the items, looks better in TeX w/o all the quotes -->
-<dl>
-<dt><code>(...)</code><dd>Grouping.
-
- <p><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-811"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-812"></a><br><dt><code>$</code><dd>Field.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-813"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-814"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operator-815"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operators-816"></a><br><dt><code>++
--</code><dd>Increment, decrement.
-
- <p><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-817"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-818"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-819"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-820"></a><br><dt><code>^
**</code><dd>Exponentiation. These operators group right-to-left.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_007d-operator-821"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_007d-operator-822"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_007d-operator-823"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_007d-operator-824"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-825"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-826"></a><br><dt><code>+
- !</code><dd>Unary plus, minus, logical “not.”
-
- <p><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-827"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-828"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_007d-operator-829"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_007d-operator-830"></a><a
name="index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_007d-operator-831"></a><a
name="index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_007d-operator-832"></a><br><dt><code>*
/ %</code><dd>Multiplication, division, modulus.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_007d-operator-833"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_007d-operator-834"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_007d-operator-835"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_007d-operator-836"></a><br><dt><code>+
-</code><dd>Addition, subtraction.
-
- <br><dt><span class="roman">String Concatenation</span><dd>No special
symbol is used to indicate concatenation.
-The operands are simply written side by side
-(see <a href="#Concatenation">Concatenation</a>).
-
- <p><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-837"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-838"></a><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-839"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-840"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-841"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-842"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-843"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-844"></a><a
name="index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-845"></a><a
name="index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-846"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-847"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-848"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-849"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-850"></a><a
name="index-operators_002c-input_002foutput-851"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-852"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-853"></a><a
name="index-operators_002c-input_002foutput-854"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-855"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-856"></a><a
name="index-operators_002c-input_002foutput-857"></a><br><dt><code>< <=
== !=</code><dt><code>> >= >> | |&</code><dd>Relational and
redirection.
-The relational operators and the redirections have the same precedence
-level. Characters such as `<samp><span class="samp">></span></samp>' serve
both as relationals and as
-redirections; the context distinguishes between the two meanings.
-
- <p><a
name="index-_0040code_007bprint_007d-statement_002c-I_002fO-operators-in-858"></a><a
name="index-_0040code_007bprintf_007d-statement_002c-I_002fO-operators-in-859"></a>Note
that the I/O redirection operators in <code>print</code> and
<code>printf</code>
-statements belong to the statement level, not to expressions. The
-redirection does not produce an expression that could be the operand of
-another operator. As a result, it does not make sense to use a
-redirection operator near another operator of lower precedence without
-parentheses. Such combinations (for example, `<samp><span class="samp">print
foo > a ? b : c</span></samp>'),
-result in syntax errors.
-The correct way to write this statement is `<samp><span class="samp">print foo
> (a ? b : c)</span></samp>'.
-
- <p><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-860"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-861"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-862"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-863"></a><br><dt><code>~
!~</code><dd>Matching, nonmatching.
-
- <p><a
name="index-_0040code_007bin_007d-operator-864"></a><br><dt><code>in</code><dd>Array
membership.
-
- <p><a
name="index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-865"></a><a
name="index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007doperator-866"></a><br><dt><code>&&</code><dd>Logical
“and”.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-867"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-868"></a><br><dt><code>||</code><dd>Logical
“or”.
-
- <p><a
name="index-_0040code_007b_003f_007d-_0028question-mark_0029_002c-_0040code_007b_003f_003a_007d-operator-869"></a><a
name="index-question-mark-_0028_0040code_007b_003f_007d_0029_002c-_0040code_007b_003f_003a_007d-operator-870"></a><br><dt><code>?:</code><dd>Conditional.
This operator groups right-to-left.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-871"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-872"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-873"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-874"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-875"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-876"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-877"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-878"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-879"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-880"></a><a
name="index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-881"></a><a
name="index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-882"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-883"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-884"></a><br><dt><code>=
+= -= *=</code><dt><code>/= %= ^= **=</code><dd>Assignment. These operators
group right to left.
-</dl>
-
- <p><a
name="index-portability_002c-operators_002c-not-in-POSIX-_0040command_007bawk_007d-885"></a><blockquote>
-<b>NOTE:</b> The `<samp><span class="samp">|&</span></samp>', `<samp><span
class="samp">**</span></samp>', and `<samp><span
class="samp">**=</span></samp>' operators are not specified by POSIX.
-For maximum portability, do not use them.
-</blockquote>
- <!-- ENDOFRANGE prec -->
-<!-- ENDOFRANGE oppr -->
-<!-- ENDOFRANGE exps -->
-
-<div class="node">
-<p><hr>
-<a name="Patterns-and-Actions"></a>Next: <a rel="next" accesskey="n"
href="#Arrays">Arrays</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Expressions">Expressions</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">6 Patterns, Actions, and Variables</h2>
-
-<!-- STARTOFRANGE pat -->
-<p><a name="index-patterns-886"></a>
-As you have already seen, each <samp><span class="command">awk</span></samp>
statement consists of
-a pattern with an associated action. This chapter describes how
-you build patterns and actions, what kinds of things you can do within
-actions, and <samp><span class="command">awk</span></samp>'s built-in
variables.
-
- <p>The pattern-action rules and the statements available for use
-within actions form the core of <samp><span class="command">awk</span></samp>
programming.
-In a sense, everything covered
-up to here has been the foundation
-that programs are built on top of. Now it's time to start
-building something useful.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Pattern-Overview">Pattern Overview</a>:
What goes into a pattern.
-<li><a accesskey="2" href="#Using-Shell-Variables">Using Shell Variables</a>:
How to use shell variables with <samp><span
class="command">awk</span></samp>.
-<li><a accesskey="3" href="#Action-Overview">Action Overview</a>:
What goes into an action.
-<li><a accesskey="4" href="#Statements">Statements</a>:
Describes the various control statements in
- detail.
-<li><a accesskey="5" href="#Built_002din-Variables">Built-in Variables</a>:
Summarizes the built-in variables.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Pattern-Overview"></a>Next: <a rel="next" accesskey="n"
href="#Using-Shell-Variables">Using Shell Variables</a>,
-Up: <a rel="up" accesskey="u" href="#Patterns-and-Actions">Patterns and
Actions</a>
-<br>
-</div>
-
-<h3 class="section">6.1 Pattern Elements</h3>
-
-<ul class="menu">
-<li><a accesskey="1" href="#Regexp-Patterns">Regexp Patterns</a>:
Using regexps as patterns.
-<li><a accesskey="2" href="#Expression-Patterns">Expression Patterns</a>:
Any expression can be used as a pattern.
-<li><a accesskey="3" href="#Ranges">Ranges</a>: Pairs of
patterns specify record ranges.
-<li><a accesskey="4" href="#BEGIN_002fEND">BEGIN/END</a>:
Specifying initialization and cleanup rules.
-<li><a accesskey="5" href="#Empty">Empty</a>: The empty
pattern, which matches every record.
-</ul>
-
-<p><a name="index-patterns_002c-types-of-887"></a>Patterns in <samp><span
class="command">awk</span></samp> control the execution of rules—a rule is
-executed when its pattern matches the current input record.
-The following is a summary of the types of <samp><span
class="command">awk</span></samp> patterns:
-
- <dl>
-<dt><code>/</code><var>regular expression</var><code>/</code><dd>A regular
expression. It matches when the text of the
-input record fits the regular expression.
-(See <a href="#Regexp">Regexp</a>.)
-
- <br><dt><var>expression</var><dd>A single expression. It matches when
its value
-is nonzero (if a number) or non-null (if a string).
-(See <a href="#Expression-Patterns">Expression Patterns</a>.)
-
- <br><dt><var>pat1</var><code>, </code><var>pat2</var><dd>A pair of
patterns separated by a comma, specifying a range of records.
-The range includes both the initial record that matches <var>pat1</var> and
-the final record that matches <var>pat2</var>.
-(See <a href="#Ranges">Ranges</a>.)
-
- <br><dt><code>BEGIN</code><dt><code>END</code><dd>Special patterns for
you to supply startup or cleanup actions for your
-<samp><span class="command">awk</span></samp> program.
-(See <a href="#BEGIN_002fEND">BEGIN/END</a>.)
-
- <br><dt><var>empty</var><dd>The empty pattern matches every input record.
-(See <a href="#Empty">Empty</a>.)
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="Regexp-Patterns"></a>Next: <a rel="next" accesskey="n"
href="#Expression-Patterns">Expression Patterns</a>,
-Up: <a rel="up" accesskey="u" href="#Pattern-Overview">Pattern
Overview</a>
-<br>
-</div>
-
-<h4 class="subsection">6.1.1 Regular Expressions as Patterns</h4>
-
-<p><a name="index-patterns_002c-expressions-as-888"></a><a
name="index-regular-expressions_002c-as-patterns-889"></a>
-Regular expressions are one of the first kinds of patterns presented
-in this book.
-This kind of pattern is simply a regexp constant in the pattern part of
-a rule. Its meaning is `<samp><span class="samp">$0 ~
/</span><var>pattern</var><span class="samp">/</span></samp>'.
-The pattern matches when the input record matches the regexp.
-For example:
-
-<pre class="example"> /foo|bar|baz/ { buzzwords++ }
- END { print buzzwords, "buzzwords seen" }
-</pre>
- <div class="node">
-<p><hr>
-<a name="Expression-Patterns"></a>Next: <a rel="next" accesskey="n"
href="#Ranges">Ranges</a>,
-Previous: <a rel="previous" accesskey="p" href="#Regexp-Patterns">Regexp
Patterns</a>,
-Up: <a rel="up" accesskey="u" href="#Pattern-Overview">Pattern
Overview</a>
-<br>
-</div>
-
-<h4 class="subsection">6.1.2 Expressions as Patterns</h4>
-
-<p><a name="index-expressions_002c-as-patterns-890"></a>
-Any <samp><span class="command">awk</span></samp> expression is valid as an
<samp><span class="command">awk</span></samp> pattern.
-The pattern matches if the expression's value is nonzero (if a
-number) or non-null (if a string).
-The expression is reevaluated each time the rule is tested against a new
-input record. If the expression uses fields such as <code>$1</code>, the
-value depends directly on the new input record's text; otherwise, it
-depends on only what has happened so far in the execution of the
-<samp><span class="command">awk</span></samp> program.
-
- <p><a name="index-comparison-expressions_002c-as-patterns-891"></a><a
name="index-patterns_002c-comparison-expressions-as-892"></a>Comparison
expressions, using the comparison operators described in
-<a href="#Typing-and-Comparison">Typing and Comparison</a>,
-are a very common kind of pattern.
-Regexp matching and nonmatching are also very common expressions.
-The left operand of the `<samp><span class="samp">~</span></samp>' and
`<samp><span class="samp">!~</span></samp>' operators is a string.
-The right operand is either a constant regular expression enclosed in
-slashes (<code>/</code><var>regexp</var><code>/</code>), or any expression
whose string value
-is used as a dynamic regular expression
-(see <a href="#Computed-Regexps">Computed Regexps</a>).
-The following example prints the second field of each input record
-whose first field is precisely `<samp><span class="samp">foo</span></samp>':
-
- <p><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-patterns-and-893"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-patterns-and-894"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-895"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-896"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-897"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-898"></a>
-<pre class="example"> $ awk '$1 == "foo" { print $2 }' BBS-list
-</pre>
- <p class="noindent">(There is no output, because there is no BBS site with
the exact name `<samp><span class="samp">foo</span></samp>'.)
-Contrast this with the following regular expression match, which
-accepts any record with a first field that contains `<samp><span
class="samp">foo</span></samp>':
-
-<pre class="example"> $ awk '$1 ~ /foo/ { print $2 }' BBS-list
- -| 555-1234
- -| 555-6699
- -| 555-6480
- -| 555-2127
-</pre>
- <p><a name="index-regexp-constants_002c-as-patterns-899"></a><a
name="index-patterns_002c-regexp-constants-as-900"></a>A regexp constant as a
pattern is also a special case of an expression
-pattern. The expression <code>/foo/</code> has the value one if `<samp><span
class="samp">foo</span></samp>'
-appears in the current input record. Thus, as a pattern, <code>/foo/</code>
-matches any record containing `<samp><span class="samp">foo</span></samp>'.
-
- <p><a name="index-Boolean-expressions_002c-as-patterns-901"></a>Boolean
expressions are also commonly used as patterns.
-Whether the pattern
-matches an input record depends on whether its subexpressions match.
-For example, the following command prints all the records in
-<samp><span class="file">BBS-list</span></samp> that contain both `<samp><span
class="samp">2400</span></samp>' and `<samp><span
class="samp">foo</span></samp>':
-
-<pre class="example"> $ awk '/2400/ && /foo/' BBS-list
- -| fooey 555-1234 2400/1200/300 B
-</pre>
- <p>The following command prints all records in
-<samp><span class="file">BBS-list</span></samp> that contain <em>either</em>
`<samp><span class="samp">2400</span></samp>' or `<samp><span
class="samp">foo</span></samp>'
-(or both, of course):
-
-<pre class="example"> $ awk '/2400/ || /foo/' BBS-list
- -| alpo-net 555-3412 2400/1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sdace 555-3430 2400/1200/300 A
- -| sabafoo 555-2127 1200/300 C
-</pre>
- <p>The following command prints all records in
-<samp><span class="file">BBS-list</span></samp> that do <em>not</em> contain
the string `<samp><span class="samp">foo</span></samp>':
-
-<pre class="example"> $ awk '! /foo/' BBS-list
- -| aardvark 555-5553 1200/300 B
- -| alpo-net 555-3412 2400/1200/300 A
- -| barfly 555-7685 1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| camelot 555-0542 300 C
- -| core 555-2912 1200/300 C
- -| sdace 555-3430 2400/1200/300 A
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-Boolean-patterns-and-902"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-Boolean-patterns-and-903"></a>The
subexpressions of a Boolean operator in a pattern can be constant regular
-expressions, comparisons, or any other <samp><span
class="command">awk</span></samp> expressions. Range
-patterns are not expressions, so they cannot appear inside Boolean
-patterns. Likewise, the special patterns <code>BEGIN</code> and
<code>END</code>,
-which never match any input record, are not expressions and cannot
-appear inside Boolean patterns.
-
-<div class="node">
-<p><hr>
-<a name="Ranges"></a>Next: <a rel="next" accesskey="n"
href="#BEGIN_002fEND">BEGIN/END</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Expression-Patterns">Expression Patterns</a>,
-Up: <a rel="up" accesskey="u" href="#Pattern-Overview">Pattern
Overview</a>
-<br>
-</div>
-
-<h4 class="subsection">6.1.3 Specifying Record Ranges with Patterns</h4>
-
-<p><a name="index-range-patterns-904"></a><a
name="index-patterns_002c-ranges-in-905"></a><a
name="index-lines_002c-matching-ranges-of-906"></a><a
name="index-_0040code_007b_002c_007d-_0028comma_0029_002c-in-range-patterns-907"></a><a
name="index-comma-_0028_0040code_007b_002c_007d_0029_002c-in-range-patterns-908"></a>A
<dfn>range pattern</dfn> is made of two patterns separated by a comma, in
-the form `<samp><var>begpat</var><span class="samp">,
</span><var>endpat</var></samp>'. It is used to match ranges of
-consecutive input records. The first pattern, <var>begpat</var>, controls
-where the range begins, while <var>endpat</var> controls where
-the pattern ends. For example, the following:
-
-<pre class="example"> awk '$1 == "on", $1 == "off"' myfile
-</pre>
- <p class="noindent">prints every record in <samp><span
class="file">myfile</span></samp> between `<samp><span
class="samp">on</span></samp>'/`<samp><span class="samp">off</span></samp>'
pairs, inclusive.
-
- <p>A range pattern starts out by matching <var>begpat</var> against every
-input record. When a record matches <var>begpat</var>, the range pattern is
-<dfn>turned on</dfn> and the range pattern matches this record as well. As
long as
-the range pattern stays turned on, it automatically matches every input
-record read. The range pattern also matches <var>endpat</var> against every
-input record; when this succeeds, the range pattern is turned off again
-for the following record. Then the range pattern goes back to checking
-<var>begpat</var> against each record.
-
- <p><a
name="index-_0040code_007bif_007d-statement_002c-actions_0040comma_007b_007d-changing-909"></a>The
record that turns on the range pattern and the one that turns it
-off both match the range pattern. If you don't want to operate on
-these records, you can write <code>if</code> statements in the rule's action
-to distinguish them from the records you are interested in.
-
- <p>It is possible for a pattern to be turned on and off by the same
-record. If the record satisfies both conditions, then the action is
-executed for just that record.
-For example, suppose there is text between two identical markers (e.g.,
-the `<samp><span class="samp">%</span></samp>' symbol), each on its own line,
that should be ignored.
-A first attempt would be to
-combine a range pattern that describes the delimited text with the
-<code>next</code> statement
-(not discussed yet, see <a href="#Next-Statement">Next Statement</a>).
-This causes <samp><span class="command">awk</span></samp> to skip any further
processing of the current
-record and start over again with the next input record. Such a program
-looks like this:
-
-<pre class="example"> /^%$/,/^%$/ { next }
- { print }
-</pre>
- <p class="noindent"><a
name="index-lines_002c-skipping-between-markers-910"></a><!-- @cindex flag
variables -->
-This program fails because the range pattern is both turned on and turned off
-by the first line, which just has a `<samp><span class="samp">%</span></samp>'
on it. To accomplish this task,
-write the program in the following manner, using a flag:
-
- <p><a name="index-_0040code_007b_0021_007d-operator-911"></a>
-<pre class="example"> /^%$/ { skip = ! skip; next }
- skip == 1 { next } # skip lines with `skip' set
-</pre>
- <p>In a range pattern, the comma (`<samp><span
class="samp">,</span></samp>') has the lowest precedence of
-all the operators (i.e., it is evaluated last). Thus, the following
-program attempts to combine a range pattern with another, simpler test:
-
-<pre class="example"> echo Yes | awk '/1/,/2/ || /Yes/'
-</pre>
- <p>The intent of this program is `<samp><span class="samp">(/1/,/2/) ||
/Yes/</span></samp>'.
-However, <samp><span class="command">awk</span></samp> interprets this as
`<samp><span class="samp">/1/, (/2/ || /Yes/)</span></samp>'.
-This cannot be changed or worked around; range patterns do not combine
-with other patterns:
-
-<pre class="example"> $ echo Yes | gawk '(/1/,/2/) || /Yes/'
- error--> gawk: cmd. line:1: (/1/,/2/) || /Yes/
- error--> gawk: cmd. line:1: ^ parse error
- error--> gawk: cmd. line:2: (/1/,/2/) || /Yes/
- error--> gawk: cmd. line:2: ^ unexpected newline
-</pre>
- <div class="node">
-<p><hr>
-<a name="BEGIN_002fEND"></a>Next: <a rel="next" accesskey="n"
href="#Empty">Empty</a>,
-Previous: <a rel="previous" accesskey="p" href="#Ranges">Ranges</a>,
-Up: <a rel="up" accesskey="u" href="#Pattern-Overview">Pattern
Overview</a>
-<br>
-</div>
-
-<h4 class="subsection">6.1.4 The <code>BEGIN</code> and <code>END</code>
Special Patterns</h4>
-
-<!-- STARTOFRANGE beg -->
-<p><a name="index-_0040code_007bBEGIN_007d-pattern-912"></a><!-- STARTOFRANGE
end -->
-<a name="index-_0040code_007bEND_007d-pattern-913"></a>All the patterns
described so far are for matching input records.
-The <code>BEGIN</code> and <code>END</code> special patterns are different.
-They supply startup and cleanup actions for <samp><span
class="command">awk</span></samp> programs.
-<code>BEGIN</code> and <code>END</code> rules must have actions; there is no
default
-action for these rules because there is no current record when they run.
-<code>BEGIN</code> and <code>END</code> rules are often referred to as
-“<code>BEGIN</code> and <code>END</code> blocks” by long-time
<samp><span class="command">awk</span></samp>
-programmers.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Using-BEGIN_002fEND">Using BEGIN/END</a>:
How and why to use BEGIN/END rules.
-<li><a accesskey="2" href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a>:
I/O issues in BEGIN/END rules.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Using-BEGIN_002fEND"></a>Next: <a rel="next" accesskey="n"
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a>,
-Up: <a rel="up" accesskey="u" href="#BEGIN_002fEND">BEGIN/END</a>
-<br>
-</div>
-
-<h5 class="subsubsection">6.1.4.1 Startup and Cleanup Actions</h5>
-
-<p>A <code>BEGIN</code> rule is executed once only, before the first input
record
-is read. Likewise, an <code>END</code> rule is executed once only, after all
the
-input is read. For example:
-
-<pre class="example"> $ awk '
- > BEGIN { print "Analysis of \"foo\"" }
- > /foo/ { ++n }
- > END { print "\"foo\" appears", n, "times." }' BBS-list
- -| Analysis of "foo"
- -| "foo" appears 4 times.
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-operators-and-914"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-operators-and-915"></a>This
program finds the number of records in the input file <samp><span
class="file">BBS-list</span></samp>
-that contain the string `<samp><span class="samp">foo</span></samp>'. The
<code>BEGIN</code> rule prints a title
-for the report. There is no need to use the <code>BEGIN</code> rule to
-initialize the counter <code>n</code> to zero, since <samp><span
class="command">awk</span></samp> does this
-automatically (see <a href="#Variables">Variables</a>).
-The second rule increments the variable <code>n</code> every time a
-record containing the pattern `<samp><span class="samp">foo</span></samp>' is
read. The <code>END</code> rule
-prints the value of <code>n</code> at the end of the run.
-
- <p>The special patterns <code>BEGIN</code> and <code>END</code> cannot be
used in ranges
-or with Boolean operators (indeed, they cannot be used with any operators).
-An <samp><span class="command">awk</span></samp> program may have multiple
<code>BEGIN</code> and/or <code>END</code>
-rules. They are executed in the order in which they appear: all the
<code>BEGIN</code>
-rules at startup and all the <code>END</code> rules at termination.
-<code>BEGIN</code> and <code>END</code> rules may be intermixed with other
rules.
-This feature was added in the 1987 version of <samp><span
class="command">awk</span></samp> and is included
-in the POSIX standard.
-The original (1978) version of <samp><span class="command">awk</span></samp>
-required the <code>BEGIN</code> rule to be placed at the beginning of the
-program, the <code>END</code> rule to be placed at the end, and only allowed
one of
-each.
-This is no longer required, but it is a good idea to follow this template
-in terms of program organization and readability.
-
- <p>Multiple <code>BEGIN</code> and <code>END</code> rules are useful for
writing
-library functions, because each library file can have its own
<code>BEGIN</code> and/or
-<code>END</code> rule to do its own initialization and/or cleanup.
-The order in which library functions are named on the command line
-controls the order in which their <code>BEGIN</code> and <code>END</code>
rules are
-executed. Therefore, you have to be careful when writing such rules in
-library files so that the order in which they are executed doesn't matter.
-See <a href="#Options">Options</a>, for more information on
-using library functions.
-See <a href="#Library-Functions">Library Functions</a>,
-for a number of useful library functions.
-
- <p>If an <samp><span class="command">awk</span></samp> program has only a
<code>BEGIN</code> rule and no
-other rules, then the program exits after the <code>BEGIN</code> rule is
-run.<a rel="footnote" href="#fn-26" name="fnd-26"><sup>26</sup></a> However,
if an
-<code>END</code> rule exists, then the input is read, even if there are
-no other rules in the program. This is necessary in case the <code>END</code>
-rule checks the <code>FNR</code> and <code>NR</code> variables.
-
-<div class="node">
-<p><hr>
-<a name="I_002fO-And-BEGIN_002fEND"></a>Previous: <a rel="previous"
accesskey="p" href="#Using-BEGIN_002fEND">Using BEGIN/END</a>,
-Up: <a rel="up" accesskey="u" href="#BEGIN_002fEND">BEGIN/END</a>
-<br>
-</div>
-
-<h5 class="subsubsection">6.1.4.2 Input/Output from <code>BEGIN</code> and
<code>END</code> Rules</h5>
-
-<p><a
name="index-input_002foutput_002c-from-_0040code_007bBEGIN_007d-and-_0040code_007bEND_007d-916"></a>There
are several (sometimes subtle) points to remember when doing I/O
-from a <code>BEGIN</code> or <code>END</code> rule.
-The first has to do with the value of <code>$0</code> in a <code>BEGIN</code>
-rule. Because <code>BEGIN</code> rules are executed before any input is read,
-there simply is no input record, and therefore no fields, when
-executing <code>BEGIN</code> rules. References to <code>$0</code> and the
fields
-yield a null string or zero, depending upon the context. One way
-to give <code>$0</code> a real value is to execute a <code>getline</code>
command
-without a variable (see <a href="#Getline">Getline</a>).
-Another way is simply to assign a value to <code>$0</code>.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-917"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-918"></a><a
name="index-_0040code_007bprint_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-919"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bprint_007d-statement-and-920"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bprint_007d-statement-and-921"></a>The
second point is similar to the first but from the other direction.
-Traditionally, due largely to implementation issues, <code>$0</code> and
-<code>NF</code> were <em>undefined</em> inside an <code>END</code> rule.
-The POSIX standard specifies that <code>NF</code> is available in an
<code>END</code>
-rule. It contains the number of fields from the last input record.
-Most probably due to an oversight, the standard does not say that
<code>$0</code>
-is also preserved, although logically one would think that it should be.
-In fact, <samp><span class="command">gawk</span></samp> does preserve the
value of <code>$0</code> for use in
-<code>END</code> rules. Be aware, however, that Unix <samp><span
class="command">awk</span></samp>, and possibly
-other implementations, do not.
-
- <p>The third point follows from the first two. The meaning of `<samp><span
class="samp">print</span></samp>'
-inside a <code>BEGIN</code> or <code>END</code> rule is the same as always:
-`<samp><span class="samp">print $0</span></samp>'. If <code>$0</code> is the
null string, then this prints an
-empty line. Many long time <samp><span class="command">awk</span></samp>
programmers use an unadorned
-`<samp><span class="samp">print</span></samp>' in <code>BEGIN</code> and
<code>END</code> rules, to mean `<samp><span class="samp">print ""<!-- /@w
--></span></samp>',
-relying on <code>$0</code> being null. Although one might generally get away
with
-this in <code>BEGIN</code> rules, it is a very bad idea in <code>END</code>
rules,
-at least in <samp><span class="command">gawk</span></samp>. It is also poor
style, since if an empty
-line is needed in the output, the program should print one explicitly.
-
- <p><a
name="index-_0040code_007bnext_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-922"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-923"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-924"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-925"></a>Finally,
the <code>next</code> and <code>nextfile</code> statements are not allowed
-in a <code>BEGIN</code> rule, because the implicit
-read-a-record-and-match-against-the-rules loop has not started yet.
Similarly, those statements
-are not valid in an <code>END</code> rule, since all the input has been read.
-(See <a href="#Next-Statement">Next Statement</a>, and see
-<a href="#Nextfile-Statement">Nextfile Statement</a>.)
-<!-- ENDOFRANGE beg -->
-<!-- ENDOFRANGE end -->
-
-<div class="node">
-<p><hr>
-<a name="Empty"></a>Previous: <a rel="previous" accesskey="p"
href="#BEGIN_002fEND">BEGIN/END</a>,
-Up: <a rel="up" accesskey="u" href="#Pattern-Overview">Pattern
Overview</a>
-<br>
-</div>
-
-<h4 class="subsection">6.1.5 The Empty Pattern</h4>
-
-<p><a name="index-empty-pattern-926"></a><a
name="index-patterns_002c-empty-927"></a>An empty (i.e., nonexistent) pattern
is considered to match <em>every</em>
-input record. For example, the program:
-
-<pre class="example"> awk '{ print $1 }' BBS-list
-</pre>
- <p class="noindent">prints the first field of every record.
-<!-- ENDOFRANGE pat -->
-
-<div class="node">
-<p><hr>
-<a name="Using-Shell-Variables"></a>Next: <a rel="next" accesskey="n"
href="#Action-Overview">Action Overview</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Pattern-Overview">Pattern Overview</a>,
-Up: <a rel="up" accesskey="u" href="#Patterns-and-Actions">Patterns and
Actions</a>
-<br>
-</div>
-
-<h3 class="section">6.2 Using Shell Variables in Programs</h3>
-
-<p><a name="index-shells_002c-variables-928"></a><a
name="index-_0040command_007bawk_007d-programs_002c-shell-variables-in-929"></a><!--
@cindex shell and @command{awk} interaction -->
-
- <p><samp><span class="command">awk</span></samp> programs are often used as
components in larger
-programs written in shell.
-For example, it is very common to use a shell variable to
-hold a pattern that the <samp><span class="command">awk</span></samp> program
searches for.
-There are two ways to get the value of the shell variable
-into the body of the <samp><span class="command">awk</span></samp> program.
-
- <p><a name="index-shells_002c-quoting-930"></a>The most common method is to
use shell quoting to substitute
-the variable's value into the program inside the script.
-For example, in the following program:
-
-<pre class="example"> echo -n "Enter search pattern: "
- read pattern
- awk "/$pattern/ "'{ nmatches++ }
- END { print nmatches, "found" }' /path/to/data
-</pre>
- <p class="noindent">the <samp><span class="command">awk</span></samp>
program consists of two pieces of quoted text
-that are concatenated together to form the program.
-The first part is double-quoted, which allows substitution of
-the <code>pattern</code> variable inside the quotes.
-The second part is single-quoted.
-
- <p>Variable substitution via quoting works, but can be potentially
-messy. It requires a good understanding of the shell's quoting rules
-(see <a href="#Quoting">Quoting</a>),
-and it's often difficult to correctly
-match up the quotes when reading the program.
-
- <p>A better method is to use <samp><span
class="command">awk</span></samp>'s variable assignment feature
-(see <a href="#Assignment-Options">Assignment Options</a>)
-to assign the shell variable's value to an <samp><span
class="command">awk</span></samp> variable's
-value. Then use dynamic regexps to match the pattern
-(see <a href="#Computed-Regexps">Computed Regexps</a>).
-The following shows how to redo the
-previous example using this technique:
-
-<pre class="example"> echo -n "Enter search pattern: "
- read pattern
- awk -v pat="$pattern" '$0 ~ pat { nmatches++ }
- END { print nmatches, "found" }' /path/to/data
-</pre>
- <p class="noindent">Now, the <samp><span class="command">awk</span></samp>
program is just one single-quoted string.
-The assignment `<samp><span class="samp">-v pat="$pattern"</span></samp>'
still requires double quotes,
-in case there is whitespace in the value of <code>$pattern</code>.
-The <samp><span class="command">awk</span></samp> variable <code>pat</code>
could be named <code>pattern</code>
-too, but that would be more confusing. Using a variable also
-provides more flexibility, since the variable can be used anywhere inside
-the program—for printing, as an array subscript, or for any other
-use—without requiring the quoting tricks at every point in the program.
-
-<div class="node">
-<p><hr>
-<a name="Action-Overview"></a>Next: <a rel="next" accesskey="n"
href="#Statements">Statements</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Using-Shell-Variables">Using Shell Variables</a>,
-Up: <a rel="up" accesskey="u" href="#Patterns-and-Actions">Patterns and
Actions</a>
-<br>
-</div>
-
-<h3 class="section">6.3 Actions</h3>
-
-<!-- @cindex action, definition of -->
-<!-- @cindex curly braces -->
-<!-- @cindex action, curly braces -->
-<!-- @cindex action, separating statements -->
-<p><a name="index-actions-931"></a>
-An <samp><span class="command">awk</span></samp> program or script consists of
a series of
-rules and function definitions interspersed. (Functions are
-described later. See <a href="#User_002ddefined">User-defined</a>.)
-A rule contains a pattern and an action, either of which (but not
-both) may be omitted. The purpose of the <dfn>action</dfn> is to tell
-<samp><span class="command">awk</span></samp> what to do once a match for the
pattern is found. Thus,
-in outline, an <samp><span class="command">awk</span></samp> program generally
looks like this:
-
-<pre class="example"> <span class="roman">[</span><var>pattern</var><span
class="roman">]</span> <span class="roman">[</span>{ <var>action</var> }<span
class="roman">]</span>
- <span class="roman">[</span><var>pattern</var><span
class="roman">]</span> <span class="roman">[</span>{ <var>action</var> }<span
class="roman">]</span>
- ...
- function <var>name</var>(<var>args</var>) { ... }
- ...
-</pre>
- <p><a
name="index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-actions-and-932"></a><a
name="index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-actions-and-933"></a><a
name="index-separators_002c-for-statements-in-actions-934"></a><a
name="index-newlines_002c-separating-statements-in-actions-935"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-936"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-937"></a>An
action consists of one or more <samp><span class="command">awk</span></samp>
<dfn>statements</dfn>, enclosed
-in curly braces (`<samp><span class="samp">{...}</span></samp>'). Each
statement specifies one
-thing to do. The statements are separated by newlines or semicolons.
-The curly braces around an action must be used even if the action
-contains only one statement, or if it contains no statements at
-all. However, if you omit the action entirely, omit the curly braces as
-well. An omitted action is equivalent to `<samp><span class="samp">{ print $0
}</span></samp>':
-
-<pre class="example"> /foo/ { } <i>match </i><code>foo</code><i>, do
nothing --- empty action</i>
- /foo/ <i>match </i><code>foo</code><i>, print the record ---
omitted action</i>
-</pre>
- <p>The following types of statements are supported in <samp><span
class="command">awk</span></samp>:
-
-
-<a name="index-side-effects_002c-statements-938"></a>
-<dl><dt>Expressions<dd>Call functions or assign values to variables
-(see <a href="#Expressions">Expressions</a>). Executing
-this kind of statement simply computes the value of the expression.
-This is useful when the expression has side effects
-(see <a href="#Assignment-Ops">Assignment Ops</a>).
-
- <br><dt>Control statements<dd>Specify the control flow of <samp><span
class="command">awk</span></samp>
-programs. The <samp><span class="command">awk</span></samp> language gives
you C-like constructs
-(<code>if</code>, <code>for</code>, <code>while</code>, and <code>do</code>)
as well as a few
-special ones (see <a href="#Statements">Statements</a>).
-
- <br><dt>Compound statements<dd>Consist of one or more statements enclosed
in
-curly braces. A compound statement is used in order to put several
-statements together in the body of an <code>if</code>, <code>while</code>,
<code>do</code>,
-or <code>for</code> statement.
-
- <br><dt>Input statements<dd>Use the <code>getline</code> command
-(see <a href="#Getline">Getline</a>).
-Also supplied in <samp><span class="command">awk</span></samp> are the
<code>next</code>
-statement (see <a href="#Next-Statement">Next Statement</a>),
-and the <code>nextfile</code> statement
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-
- <br><dt>Output statements<dd>Such as <code>print</code> and
<code>printf</code>.
-See <a href="#Printing">Printing</a>.
-
- <br><dt>Deletion statements<dd>For deleting array elements.
-See <a href="#Delete">Delete</a>.
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="Statements"></a>Next: <a rel="next" accesskey="n"
href="#Built_002din-Variables">Built-in Variables</a>,
-Previous: <a rel="previous" accesskey="p" href="#Action-Overview">Action
Overview</a>,
-Up: <a rel="up" accesskey="u" href="#Patterns-and-Actions">Patterns and
Actions</a>
-<br>
-</div>
-
-<h3 class="section">6.4 Control Statements in Actions</h3>
-
-<!-- STARTOFRANGE csta -->
-<p><a name="index-control-statements-939"></a><!-- STARTOFRANGE acs -->
-<a name="index-statements_002c-control_002c-in-actions-940"></a><!--
STARTOFRANGE accs -->
-<a name="index-actions_002c-control-statements-in-941"></a>
-<dfn>Control statements</dfn>, such as <code>if</code>, <code>while</code>,
and so on,
-control the flow of execution in <samp><span class="command">awk</span></samp>
programs. Most of the
-control statements in <samp><span class="command">awk</span></samp> are
patterned on similar statements in C.
-
- <p><a
name="index-compound-statements_0040comma_007b_007d-control-statements-and-942"></a><a
name="index-statements_002c-compound_0040comma_007b_007d-control-statements-and-943"></a><a
name="index-body_002c-in-actions-944"></a><a
name="index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-statements_002c-grouping-945"></a><a
name="index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-statements_002c-grouping-946"></a><a
name="index-newlines_002c-separating-statements-in-actions-947"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-948"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-949"></a>All
the control statements start with special keywords, such as <code>if</code>
-and <code>while</code>, to distinguish them from simple expressions.
-Many control statements contain other statements. For example, the
-<code>if</code> statement contains another statement that may or may not be
-executed. The contained statement is called the <dfn>body</dfn>.
-To include more than one statement in the body, group them into a
-single <dfn>compound statement</dfn> with curly braces, separating them with
-newlines or semicolons.
-
-<ul class="menu">
-<li><a accesskey="1" href="#If-Statement">If Statement</a>:
Conditionally execute some <samp><span class="command">awk</span></samp>
- statements.
-<li><a accesskey="2" href="#While-Statement">While Statement</a>:
Loop until some condition is satisfied.
-<li><a accesskey="3" href="#Do-Statement">Do Statement</a>: Do
specified action while looping until some
- condition is satisfied.
-<li><a accesskey="4" href="#For-Statement">For Statement</a>:
Another looping statement, that provides
- initialization and increment clauses.
-<li><a accesskey="5" href="#Switch-Statement">Switch Statement</a>:
Switch/case evaluation for conditional
- execution of statements based on a value.
-<li><a accesskey="6" href="#Break-Statement">Break Statement</a>:
Immediately exit the innermost enclosing loop.
-<li><a accesskey="7" href="#Continue-Statement">Continue Statement</a>:
Skip to the end of the innermost enclosing
- loop.
-<li><a accesskey="8" href="#Next-Statement">Next Statement</a>:
Stop processing the current input record.
-<li><a accesskey="9" href="#Nextfile-Statement">Nextfile Statement</a>:
Stop processing the current file.
-<li><a href="#Exit-Statement">Exit Statement</a>: Stop execution
of <samp><span class="command">awk</span></samp>.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="If-Statement"></a>Next: <a rel="next" accesskey="n"
href="#While-Statement">While Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.1 The <code>if</code>-<code>else</code>
Statement</h4>
-
-<p><a name="index-_0040code_007bif_007d-statement-950"></a>The
<code>if</code>-<code>else</code> statement is <samp><span
class="command">awk</span></samp>'s decision-making
-statement. It looks like this:
-
-<pre class="example"> if (<var>condition</var>) <var>then-body</var> <span
class="roman">[</span>else <var>else-body</var><span class="roman">]</span>
-</pre>
- <p class="noindent">The <var>condition</var> is an expression that controls
what the rest of the
-statement does. If the <var>condition</var> is true, <var>then-body</var> is
-executed; otherwise, <var>else-body</var> is executed.
-The <code>else</code> part of the statement is
-optional. The condition is considered false if its value is zero or
-the null string; otherwise, the condition is true.
-Refer to the following:
-
-<pre class="example"> if (x % 2 == 0)
- print "x is even"
- else
- print "x is odd"
-</pre>
- <p>In this example, if the expression `<samp><span class="samp">x % 2 ==
0</span></samp>' is true (that is,
-if the value of <code>x</code> is evenly divisible by two), then the first
-<code>print</code> statement is executed; otherwise, the second
<code>print</code>
-statement is executed.
-If the <code>else</code> keyword appears on the same line as
<var>then-body</var> and
-<var>then-body</var> is not a compound statement (i.e., not surrounded by
-curly braces), then a semicolon must separate <var>then-body</var> from
-the <code>else</code>.
-To illustrate this, the previous example can be rewritten as:
-
-<pre class="example"> if (x % 2 == 0) print "x is even"; else
- print "x is odd"
-</pre>
- <p class="noindent">If the `<samp><span class="samp">;</span></samp>' is
left out, <samp><span class="command">awk</span></samp> can't interpret the
statement and
-it produces a syntax error. Don't actually write programs this way,
-because a human reader might fail to see the <code>else</code> if it is not
-the first thing on its line.
-
-<div class="node">
-<p><hr>
-<a name="While-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Do-Statement">Do Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#If-Statement">If
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.2 The <code>while</code> Statement</h4>
-
-<p><a name="index-_0040code_007bwhile_007d-statement-951"></a><a
name="index-loops-952"></a><a
name="index-loops_002c-See-Also-_0040code_007bwhile_007d-statement-953"></a>
-In programming, a <dfn>loop</dfn> is a part of a program that can
-be executed two or more times in succession.
-The <code>while</code> statement is the simplest looping statement in
-<samp><span class="command">awk</span></samp>. It repeatedly executes a
statement as long as a condition is
-true. For example:
-
-<pre class="example"> while (<var>condition</var>)
- <var>body</var>
-</pre>
- <p><a name="index-body_002c-in-loops-954"></a><var>body</var> is a
statement called the <dfn>body</dfn> of the loop,
-and <var>condition</var> is an expression that controls how long the loop
-keeps running.
-The first thing the <code>while</code> statement does is test the
<var>condition</var>.
-If the <var>condition</var> is true, it executes the statement
<var>body</var>.
-After <var>body</var> has been executed,
-<var>condition</var> is tested again, and if it is still true, <var>body</var>
is
-executed again. This process repeats until the <var>condition</var> is no
longer
-true. If the <var>condition</var> is initially false, the body of the loop is
-never executed and <samp><span class="command">awk</span></samp> continues
with the statement following
-the loop.
-This example prints the first three fields of each record, one per line:
-
-<pre class="example"> awk '{ i = 1
- while (i <= 3) {
- print $i
- i++
- }
- }' inventory-shipped
-</pre>
- <p class="noindent">The body of this loop is a compound statement enclosed
in braces,
-containing two statements.
-The loop works in the following manner: first, the value of <code>i</code> is
set to one.
-Then, the <code>while</code> statement tests whether <code>i</code> is less
than or equal to
-three. This is true when <code>i</code> equals one, so the <code>i</code>-th
-field is printed. Then the `<samp><span class="samp">i++</span></samp>'
increments the value of <code>i</code>
-and the loop repeats. The loop terminates when <code>i</code> reaches four.
-
- <p>A newline is not required between the condition and the
-body; however using one makes the program clearer unless the body is a
-compound statement or else is very simple. The newline after the open-brace
-that begins the compound statement is not required either, but the
-program is harder to read without it.
-
-<div class="node">
-<p><hr>
-<a name="Do-Statement"></a>Next: <a rel="next" accesskey="n"
href="#For-Statement">For Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#While-Statement">While
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.3 The <code>do</code>-<code>while</code>
Statement</h4>
-
-<p><a
name="index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-955"></a>
-The <code>do</code> loop is a variation of the <code>while</code> looping
statement.
-The <code>do</code> loop executes the <var>body</var> once and then repeats the
-<var>body</var> as long as the <var>condition</var> is true. It looks like
this:
-
-<pre class="example"> do
- <var>body</var>
- while (<var>condition</var>)
-</pre>
- <p>Even if the <var>condition</var> is false at the start, the
<var>body</var> is
-executed at least once (and only once, unless executing <var>body</var>
-makes <var>condition</var> true). Contrast this with the corresponding
-<code>while</code> statement:
-
-<pre class="example"> while (<var>condition</var>)
- <var>body</var>
-</pre>
- <p class="noindent">This statement does not execute <var>body</var> even
once if the <var>condition</var>
-is false to begin with.
-The following is an example of a <code>do</code> statement:
-
-<pre class="example"> { i = 1
- do {
- print $0
- i++
- } while (i <= 10)
- }
-</pre>
- <p class="noindent">This program prints each input record 10 times.
However, it isn't a very
-realistic example, since in this case an ordinary <code>while</code> would do
-just as well. This situation reflects actual experience; only
-occasionally is there a real use for a <code>do</code> statement.
-
-<div class="node">
-<p><hr>
-<a name="For-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Switch-Statement">Switch Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#Do-Statement">Do
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.4 The <code>for</code> Statement</h4>
-
-<p><a name="index-_0040code_007bfor_007d-statement-956"></a>
-The <code>for</code> statement makes it more convenient to count iterations of
a
-loop. The general form of the <code>for</code> statement looks like this:
-
-<pre class="example"> for (<var>initialization</var>;
<var>condition</var>; <var>increment</var>)
- <var>body</var>
-</pre>
- <p class="noindent">The <var>initialization</var>, <var>condition</var>,
and <var>increment</var> parts are
-arbitrary <samp><span class="command">awk</span></samp> expressions, and
<var>body</var> stands for any
-<samp><span class="command">awk</span></samp> statement.
-
- <p>The <code>for</code> statement starts by executing
<var>initialization</var>.
-Then, as long
-as the <var>condition</var> is true, it repeatedly executes <var>body</var>
and then
-<var>increment</var>. Typically, <var>initialization</var> sets a variable to
-either zero or one, <var>increment</var> adds one to it, and
<var>condition</var>
-compares it against the desired number of iterations.
-For example:
-
-<pre class="example"> awk '{ for (i = 1; i <= 3; i++)
- print $i
- }' inventory-shipped
-</pre>
- <p class="noindent">This prints the first three fields of each input
record, with one field per
-line.
-
- <p>It isn't possible to
-set more than one variable in the
-<var>initialization</var> part without using a multiple assignment statement
-such as `<samp><span class="samp">x = y = 0</span></samp>'. This makes sense
only if all the initial values
-are equal. (But it is possible to initialize additional variables by writing
-their assignments as separate statements preceding the <code>for</code> loop.)
-
-<!-- @cindex comma operator, not supported -->
-<p>The same is true of the <var>increment</var> part. Incrementing additional
-variables requires separate statements at the end of the loop.
-The C compound expression, using C's comma operator, is useful in
-this context but it is not supported in <samp><span
class="command">awk</span></samp>.
-
- <p>Most often, <var>increment</var> is an increment expression, as in the
previous
-example. But this is not required; it can be any expression
-whatsoever. For example, the following statement prints all the powers of two
-between 1 and 100:
-
-<pre class="example"> for (i = 1; i <= 100; i *= 2)
- print i
-</pre>
- <p>If there is nothing to be done, any of the three expressions in the
-parentheses following the <code>for</code> keyword may be omitted. Thus,
-`<samp><span
class="samp">for (; x > 0;)</span></samp>'<!-- /@w -->
is equivalent to `<samp><span
class="samp">while (x > 0)</span></samp>'<!-- /@w -->. If the
-<var>condition</var> is omitted, it is treated as true, effectively
-yielding an <dfn>infinite loop</dfn> (i.e., a loop that never terminates).
-
- <p>In most cases, a <code>for</code> loop is an abbreviation for a
<code>while</code>
-loop, as shown here:
-
-<pre class="example"> <var>initialization</var>
- while (<var>condition</var>) {
- <var>body</var>
- <var>increment</var>
- }
-</pre>
- <p><a
name="index-loops_002c-_0040code_007bcontinue_007d-statements-and-957"></a>The
only exception is when the <code>continue</code> statement
-(see <a href="#Continue-Statement">Continue Statement</a>) is used
-inside the loop. Changing a <code>for</code> statement to a <code>while</code>
-statement in this way can change the effect of the <code>continue</code>
-statement inside the loop.
-
- <p>The <samp><span class="command">awk</span></samp> language has a
<code>for</code> statement in addition to a
-<code>while</code> statement because a <code>for</code> loop is often both
less work to
-type and more natural to think of. Counting the number of iterations is
-very common in loops. It can be easier to think of this counting as part
-of looping rather than as something to do inside the loop.
-
-<div class="node">
-<p><hr>
-<a name="Switch-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Break-Statement">Break Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#For-Statement">For
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.5 The <code>switch</code> Statement</h4>
-
-<p><a name="index-_0040code_007bswitch_007d-statement-958"></a><a
name="index-_0040code_007bcase_007d-keyword-959"></a><a
name="index-_0040code_007bdefault_007d-keyword-960"></a>
-<strong>NOTE:</strong> This subsection describes an experimental feature
-added in <samp><span class="command">gawk</span></samp> 3.1.3. It is
<em>not</em> enabled by default. To
-enable it, use the <samp><span class="option">--enable-switch</span></samp>
option to <samp><span class="command">configure</span></samp>
-when <samp><span class="command">gawk</span></samp> is being configured and
built.
-See <a href="#Additional-Configuration-Options">Additional Configuration
Options</a>, for more information.
-
- <p>The <code>switch</code> statement allows the evaluation of an expression
and
-the execution of statements based on a <code>case</code> match. Case statements
-are checked for a match in the order they are defined. If no suitable
-<code>case</code> is found, the <code>default</code> section is executed, if
supplied.
-
- <p>Each <code>case</code> contains a single constant, be it numeric,
string, or
-regexp. The <code>switch</code> expression is evaluated, and then each
-<code>case</code>'s constant is compared against the result in turn. The type
of constant
-determines the comparison: numeric or string do the usual comparisons.
-A regexp constant does a regular expression match against the string
-value of the original expression. The general form of the <code>switch</code>
-statement looks like this:
-
-<pre class="example"> switch (<var>expression</var>) {
- case <var>value or regular expression</var>:
- <var>case-body</var>
- default:
- <var>default-body</var>
- }
-</pre>
- <p>Control flow in
-the <code>switch</code> statement works as it does in C. Once a match to a
given
-case is made, case statement bodies are executed until a <code>break</code>,
-<code>continue</code>, <code>next</code>, <code>nextfile</code> or
<code>exit</code> is encountered,
-or the end of the <code>switch</code> statement itself. For example:
-
-<pre class="example"> switch (NR * 2 + 1) {
- case 3:
- case "11":
- print NR - 1
- break
-
- case /2[[:digit:]]+/:
- print NR
-
- default:
- print NR + 1
-
- case -1:
- print NR * -1
- }
-</pre>
- <p>Note that if none of the statements specified above halt execution
-of a matched <code>case</code> statement, execution falls through to the
-next <code>case</code> until execution halts. In the above example, for
-any case value starting with `<samp><span class="samp">2</span></samp>'
followed by one or more digits,
-the <code>print</code> statement is executed and then falls through into the
-<code>default</code> section, executing its <code>print</code> statement. In
turn,
-the −1 case will also be executed since the <code>default</code> does
-not halt execution.
-
-<div class="node">
-<p><hr>
-<a name="Break-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Continue-Statement">Continue Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#Switch-Statement">Switch
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.6 The <code>break</code> Statement</h4>
-
-<p><a name="index-_0040code_007bbreak_007d-statement-961"></a><a
name="index-loops_002c-exiting-962"></a>
-The <code>break</code> statement jumps out of the innermost <code>for</code>,
-<code>while</code>, or <code>do</code> loop that encloses it. The following
example
-finds the smallest divisor of any integer, and also identifies prime
-numbers:
-
-<pre class="example"> # find smallest divisor of num
- {
- num = $1
- for (div = 2; div*div <= num; div++)
- if (num % div == 0)
- break
- if (num % div == 0)
- printf "Smallest divisor of %d is %d\n", num, div
- else
- printf "%d is prime\n", num
- }
-</pre>
- <p>When the remainder is zero in the first <code>if</code> statement,
<samp><span class="command">awk</span></samp>
-immediately <dfn>breaks out</dfn> of the containing <code>for</code> loop.
This means
-that <samp><span class="command">awk</span></samp> proceeds immediately to the
statement following the loop
-and continues processing. (This is very different from the <code>exit</code>
-statement, which stops the entire <samp><span
class="command">awk</span></samp> program.
-See <a href="#Exit-Statement">Exit Statement</a>.)
-
- <p>Th following program illustrates how the <var>condition</var> of a
<code>for</code>
-or <code>while</code> statement could be replaced with a <code>break</code>
inside
-an <code>if</code>:
-
-<pre class="example"> # find smallest divisor of num
- {
- num = $1
- for (div = 2; ; div++) {
- if (num % div == 0) {
- printf "Smallest divisor of %d is %d\n", num, div
- break
- }
- if (div*div > num) {
- printf "%d is prime\n", num
- break
- }
- }
- }
-</pre>
- <!-- @cindex @code{break}, outside of loops -->
-<!-- @cindex historical features -->
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bbreak_007d-statement-and-963"></a><a
name="index-dark-corner_002c-_0040code_007bbreak_007d-statement-964"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bbreak_007d-statement-in-965"></a>The
<code>break</code> statement has no meaning when
-used outside the body of a loop. However, although it was never documented,
-historical implementations of <samp><span class="command">awk</span></samp>
treated the <code>break</code>
-statement outside of a loop as if it were a <code>next</code> statement
-(see <a href="#Next-Statement">Next Statement</a>).
-Recent versions of Unix <samp><span class="command">awk</span></samp> no
longer allow this usage.
-<samp><span class="command">gawk</span></samp> supports this use of
<code>break</code> only
-if <samp><span class="option">--traditional</span></samp>
-has been specified on the command line
-(see <a href="#Options">Options</a>).
-Otherwise, it is treated as an error, since the POSIX standard
-specifies that <code>break</code> should only be used inside the body of a
-loop.
-(d.c.)
-
-<div class="node">
-<p><hr>
-<a name="Continue-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Next-Statement">Next Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#Break-Statement">Break
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.7 The <code>continue</code> Statement</h4>
-
-<p><a name="index-_0040code_007bcontinue_007d-statement-966"></a>As with
<code>break</code>, the <code>continue</code> statement is used only inside
-<code>for</code>, <code>while</code>, and <code>do</code> loops. It skips
-over the rest of the loop body, causing the next cycle around the loop
-to begin immediately. Contrast this with <code>break</code>, which jumps out
-of the loop altogether.
-
- <p>The <code>continue</code> statement in a <code>for</code> loop directs
<samp><span class="command">awk</span></samp> to
-skip the rest of the body of the loop and resume execution with the
-increment-expression of the <code>for</code> statement. The following program
-illustrates this fact:
-
-<pre class="example"> BEGIN {
- for (x = 0; x <= 20; x++) {
- if (x == 5)
- continue
- printf "%d ", x
- }
- print ""
- }
-</pre>
- <p class="noindent">This program prints all the numbers from 0 to
20—except for 5, for
-which the <code>printf</code> is skipped. Because the increment `<samp><span
class="samp">x++</span></samp>'
-is not skipped, <code>x</code> does not remain stuck at 5. Contrast the
-<code>for</code> loop from the previous example with the following
<code>while</code> loop:
-
-<pre class="example"> BEGIN {
- x = 0
- while (x <= 20) {
- if (x == 5)
- continue
- printf "%d ", x
- x++
- }
- print ""
- }
-</pre>
- <p class="noindent">This program loops forever once <code>x</code> reaches
5.
-
-<!-- @cindex @code{continue}, outside of loops -->
-<!-- @cindex historical features -->
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bcontinue_007d-statement-and-967"></a><a
name="index-dark-corner_002c-_0040code_007bcontinue_007d-statement-968"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bcontinue_007d-statement-in-969"></a>The
<code>continue</code> statement has no meaning when used outside the body of
-a loop. Historical versions of <samp><span class="command">awk</span></samp>
treated a <code>continue</code>
-statement outside a loop the same way they treated a <code>break</code>
-statement outside a loop: as if it were a <code>next</code>
-statement
-(see <a href="#Next-Statement">Next Statement</a>).
-Recent versions of Unix <samp><span class="command">awk</span></samp> no
longer work this way, and
-<samp><span class="command">gawk</span></samp> allows it only if <samp><span
class="option">--traditional</span></samp> is specified on
-the command line (see <a href="#Options">Options</a>). Just like the
-<code>break</code> statement, the POSIX standard specifies that
<code>continue</code>
-should only be used inside the body of a loop.
-(d.c.)
-
-<div class="node">
-<p><hr>
-<a name="Next-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Nextfile-Statement">Nextfile Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Continue-Statement">Continue Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.8 The <code>next</code> Statement</h4>
-
-<p><a name="index-_0040code_007bnext_007d-statement-970"></a>
-The <code>next</code> statement forces <samp><span
class="command">awk</span></samp> to immediately stop processing
-the current record and go on to the next record. This means that no
-further rules are executed for the current record, and the rest of the
-current rule's action isn't executed.
-
- <p>Contrast this with the effect of the <code>getline</code> function
-(see <a href="#Getline">Getline</a>). That also causes
-<samp><span class="command">awk</span></samp> to read the next record
immediately, but it does not alter the
-flow of control in any way (i.e., the rest of the current action executes
-with a new input record).
-
- <p><a
name="index-_0040command_007bawk_007d-programs_002c-execution-of-971"></a>At
the highest level, <samp><span class="command">awk</span></samp> program
execution is a loop that reads
-an input record and then tests each rule's pattern against it. If you
-think of this loop as a <code>for</code> statement whose body contains the
-rules, then the <code>next</code> statement is analogous to a
<code>continue</code>
-statement. It skips to the end of the body of this implicit loop and
-executes the increment (which reads another record).
-
- <p>For example, suppose an <samp><span class="command">awk</span></samp>
program works only on records
-with four fields, and it shouldn't fail when given bad input. To avoid
-complicating the rest of the program, write a “weed out” rule near
-the beginning, in the following manner:
-
-<pre class="example"> NF != 4 {
- err = sprintf("%s:%d: skipped: NF != 4\n", FILENAME, FNR)
- print err > "/dev/stderr"
- next
- }
-</pre>
- <p class="noindent">Because of the <code>next</code> statement,
-the program's subsequent rules won't see the bad record. The error
-message is redirected to the standard error output stream, as error
-messages should be.
-For more detail see
-<a href="#Special-Files">Special Files</a>.
-
-<!-- @cindex @command{awk} language, POSIX version -->
-<!-- @cindex @code{next}, inside a user-defined function -->
-<p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-972"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-973"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-974"></a><a
name="index-_0040code_007bnext_007d-statement_002c-user_002ddefined-functions-and-975"></a><a
name="index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-976"></a>According
to the POSIX standard, the behavior is undefined if
-the <code>next</code> statement is used in a <code>BEGIN</code> or
<code>END</code> rule.
-<samp><span class="command">gawk</span></samp> treats it as a syntax error.
-Although POSIX permits it,
-some other <samp><span class="command">awk</span></samp> implementations don't
allow the <code>next</code>
-statement inside function bodies
-(see <a href="#User_002ddefined">User-defined</a>).
-Just as with any other <code>next</code> statement, a <code>next</code>
statement inside a
-function body reads the next record and starts processing it with the
-first rule in the program.
-If the <code>next</code> statement causes the end of the input to be reached,
-then the code in any <code>END</code> rules is executed.
-See <a href="#BEGIN_002fEND">BEGIN/END</a>.
-
-<div class="node">
-<p><hr>
-<a name="Nextfile-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Exit-Statement">Exit Statement</a>,
-Previous: <a rel="previous" accesskey="p" href="#Next-Statement">Next
Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.9 Using <samp><span
class="command">gawk</span></samp>'s <code>nextfile</code> Statement</h4>
-
-<p><a name="index-_0040code_007bnextfile_007d-statement-977"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-978"></a>
-<samp><span class="command">gawk</span></samp> provides the
<code>nextfile</code> statement,
-which is similar to the <code>next</code> statement.
-However, instead of abandoning processing of the current record, the
-<code>nextfile</code> statement instructs <samp><span
class="command">gawk</span></samp> to stop processing the
-current data file.
-
- <p>The <code>nextfile</code> statement is a <samp><span
class="command">gawk</span></samp> extension.
-In most other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-<code>nextfile</code> is not special.
-
- <p>Upon execution of the <code>nextfile</code> statement,
<code>FILENAME</code> is
-updated to the name of the next data file listed on the command line,
-<code>FNR</code> is reset to one, <code>ARGIND</code> is incremented, and
processing
-starts over with the first rule in the program.
-(<code>ARGIND</code> hasn't been introduced yet. See <a
href="#Built_002din-Variables">Built-in Variables</a>.)
-If the <code>nextfile</code> statement causes the end of the input to be
reached,
-then the code in any <code>END</code> rules is executed.
-See <a href="#BEGIN_002fEND">BEGIN/END</a>.
-
- <p>The <code>nextfile</code> statement is useful when there are many data
files
-to process but it isn't necessary to process every record in every file.
-Normally, in order to move on to the next data file, a program
-has to continue scanning the unwanted records. The <code>nextfile</code>
-statement accomplishes this much more efficiently.
-
- <p>While one might think that `<samp><span
class="samp">close(FILENAME)</span></samp>' would accomplish
-the same as <code>nextfile</code>, this isn't true. <code>close</code> is
-reserved for closing files, pipes, and coprocesses that are
-opened with redirections. It is not related to the main processing that
-<samp><span class="command">awk</span></samp> does with the files listed in
<code>ARGV</code>.
-
- <p>If it's necessary to use an <samp><span
class="command">awk</span></samp> version that doesn't support
-<code>nextfile</code>, see
-<a href="#Nextfile-Function">Nextfile Function</a>,
-for a user-defined function that simulates the <code>nextfile</code>
-statement.
-
- <p><a
name="index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-979"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-user_002ddefined-functions-and-980"></a>The
current version of the Bell Laboratories <samp><span
class="command">awk</span></samp>
-(see <a href="#Other-Versions">Other Versions</a>)
-also supports <code>nextfile</code>. However, it doesn't allow the
<code>nextfile</code>
-statement inside function bodies
-(see <a href="#User_002ddefined">User-defined</a>).
-<samp><span class="command">gawk</span></samp> does; a <code>nextfile</code>
inside a
-function body reads the next record and starts processing it with the
-first rule in the program, just as any other <code>nextfile</code> statement.
-
- <p><a
name="index-_0040code_007bnext-file_007d-statement_002c-in-_0040command_007bgawk_007d-981"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bnext-file_007d-statement-in-982"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-in-_0040command_007bgawk_007d-983"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-984"></a><strong>Caution:</strong>
Versions of <samp><span class="command">gawk</span></samp> prior to 3.0 used
two
-words (`<samp><span class="samp">next file</span></samp>') for the
<code>nextfile</code> statement.
-In version 3.0, this was changed
-to one word, because the treatment of `<samp><span
class="samp">file</span></samp>' was
-inconsistent. When it appeared after <code>next</code>, `<samp><span
class="samp">file</span></samp>' was a keyword;
-otherwise, it was a regular identifier. The old usage is no longer
-accepted; `<samp><span class="samp">next file</span></samp>' generates a
syntax error.
-
-<div class="node">
-<p><hr>
-<a name="Exit-Statement"></a>Previous: <a rel="previous" accesskey="p"
href="#Nextfile-Statement">Nextfile Statement</a>,
-Up: <a rel="up" accesskey="u" href="#Statements">Statements</a>
-<br>
-</div>
-
-<h4 class="subsection">6.4.10 The <code>exit</code> Statement</h4>
-
-<p><a name="index-_0040code_007bexit_007d-statement-985"></a>The
<code>exit</code> statement causes <samp><span
class="command">awk</span></samp> to immediately stop
-executing the current rule and to stop processing input; any remaining input
-is ignored. The <code>exit</code> statement is written as follows:
-
-<pre class="example"> exit <span class="roman">[</span><var>return
code</var><span class="roman">]</span>
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bexit_007d-statement-and-986"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bexit_007d-statement-and-987"></a>When
an <code>exit</code> statement is executed from a <code>BEGIN</code> rule, the
-program stops processing everything immediately. No input records are
-read. However, if an <code>END</code> rule is present,
-as part of executing the <code>exit</code> statement,
-the <code>END</code> rule is executed
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-If <code>exit</code> is used as part of an <code>END</code> rule, it causes
-the program to stop immediately.
-
- <p>An <code>exit</code> statement that is not part of a <code>BEGIN</code>
or <code>END</code>
-rule stops the execution of any further automatic rules for the current
-record, skips reading any remaining input records, and executes the
-<code>END</code> rule if there is one.
-
- <p>In such a case,
-if you don't want the <code>END</code> rule to do its job, set a variable
-to nonzero before the <code>exit</code> statement and check that variable in
-the <code>END</code> rule.
-See <a href="#Assert-Function">Assert Function</a>,
-for an example that does this.
-
- <p><a
name="index-dark-corner_002c-_0040code_007bexit_007d-statement-988"></a>If an
argument is supplied to <code>exit</code>, its value is used as the exit
-status code for the <samp><span class="command">awk</span></samp> process. If
no argument is supplied,
-<code>exit</code> returns status zero (success). In the case where an argument
-is supplied to a first <code>exit</code> statement, and then <code>exit</code>
is
-called a second time from an <code>END</code> rule with no argument,
-<samp><span class="command">awk</span></samp> uses the previously supplied
exit value.
-(d.c.)
-
- <p><a
name="index-programming-conventions_002c-_0040code_007bexit_007d-statement-989"></a>For
example, suppose an error condition occurs that is difficult or
-impossible to handle. Conventionally, programs report this by
-exiting with a nonzero status. An <samp><span
class="command">awk</span></samp> program can do this
-using an <code>exit</code> statement with a nonzero argument, as shown
-in the following example:
-
-<pre class="example"> BEGIN {
- if (("date" | getline date_now) <= 0) {
- print "Can't get system date" > "/dev/stderr"
- exit 1
- }
- print "current date is", date_now
- close("date")
- }
-</pre>
- <!-- ENDOFRANGE csta -->
-<!-- ENDOFRANGE acs -->
-<!-- ENDOFRANGE accs -->
-<div class="node">
-<p><hr>
-<a name="Built_002din-Variables"></a>Previous: <a rel="previous"
accesskey="p" href="#Statements">Statements</a>,
-Up: <a rel="up" accesskey="u" href="#Patterns-and-Actions">Patterns and
Actions</a>
-<br>
-</div>
-
-<h3 class="section">6.5 Built-in Variables</h3>
-
-<!-- STARTOFRANGE bvar -->
-<p><a name="index-built_002din-variables-990"></a><!-- STARTOFRANGE varb -->
-<a name="index-variables_002c-built_002din-991"></a>
-Most <samp><span class="command">awk</span></samp> variables are available to
use for your own
-purposes; they never change unless your program assigns values to
-them, and they never affect anything unless your program examines them.
-However, a few variables in <samp><span class="command">awk</span></samp> have
special built-in meanings.
-<samp><span class="command">awk</span></samp> examines some of these
automatically, so that they enable you
-to tell <samp><span class="command">awk</span></samp> how to do certain
things. Others are set
-automatically by <samp><span class="command">awk</span></samp>, so that they
carry information from the
-internal workings of <samp><span class="command">awk</span></samp> to your
program.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-built_002din-variables-and-992"></a>This
section documents all the built-in variables of
-<samp><span class="command">gawk</span></samp>, most of which are also
documented in the chapters
-describing their areas of activity.
-
-<ul class="menu">
-<li><a accesskey="1" href="#User_002dmodified">User-modified</a>:
Built-in variables that you change to control
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="2" href="#Auto_002dset">Auto-set</a>:
Built-in variables where <samp><span class="command">awk</span></samp> gives
- you information.
-<li><a accesskey="3" href="#ARGC-and-ARGV">ARGC and ARGV</a>:
Ways to use <code>ARGC</code> and <code>ARGV</code>.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="User_002dmodified"></a>Next: <a rel="next" accesskey="n"
href="#Auto_002dset">Auto-set</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din-Variables">Built-in
Variables</a>
-<br>
-</div>
-
-<h4 class="subsection">6.5.1 Built-in Variables That Control <samp><span
class="command">awk</span></samp></h4>
-
-<!-- STARTOFRANGE bvaru -->
-<p><a
name="index-built_002din-variables_002c-user_002dmodifiable-993"></a><!--
STARTOFRANGE nmbv -->
-<a name="index-user_002dmodifiable-variables-994"></a>
-The following is an alphabetical list of variables that you can change to
-control how <samp><span class="command">awk</span></samp> does certain things.
The variables that are
-specific to <samp><span class="command">gawk</span></samp> are marked with a
pound sign (`<samp><span class="samp">#</span></samp>').<!-- /@w -->
-
-
-<a name="index-_0040code_007bBINMODE_007d-variable-995"></a>
-<a name="index-binary-input_002foutput-996"></a>
-<a name="index-input_002foutput_002c-binary-997"></a>
-<dl><dt><code>BINMODE #</code><dd>On non-POSIX systems, this variable
specifies use of binary mode for all I/O.
-Numeric values of one, two, or three specify that input files, output files, or
-all files, respectively, should use binary I/O.
-Alternatively,
-string values of <code>"r"</code> or <code>"w"</code> specify that input files
and
-output files, respectively, should use binary I/O.
-A string value of <code>"rw"</code> or <code>"wr"</code> indicates that all
-files should use binary I/O.
-Any other string value is equivalent to <code>"rw"</code>, but <samp><span
class="command">gawk</span></samp>
-generates a warning message.
-<code>BINMODE</code> is described in more detail in
-<a href="#PC-Using">PC Using</a>.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-998"></a>This
variable is a <samp><span class="command">gawk</span></samp> extension.
-In other <samp><span class="command">awk</span></samp> implementations
-(except <samp><span class="command">mawk</span></samp>,
-see <a href="#Other-Versions">Other Versions</a>),
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-it is not special.
-
- <p><a name="index-_0040code_007bCONVFMT_007d-variable-999"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bCONVFMT_007d-variable-and-1000"></a><a
name="index-numbers_002c-converting_002c-to-strings-1001"></a><a
name="index-strings_002c-converting_002c-numbers-to-1002"></a><br><dt><code>CONVFMT</code><dd>This
string controls conversion of numbers to
-strings (see <a href="#Conversion">Conversion</a>).
-It works by being passed, in effect, as the first argument to the
-<code>sprintf</code> function
-(see <a href="#String-Functions">String Functions</a>).
-Its default value is <code>"%.6g"</code>.
-<code>CONVFMT</code> was introduced by the POSIX standard.
-
- <p><a name="index-_0040code_007bFIELDWIDTHS_007d-variable-1003"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-1004"></a><a
name="index-field-separators_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1005"></a><a
name="index-separators_002c-field_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1006"></a><br><dt><code>FIELDWIDTHS
#</code><dd>This is a space-separated list of columns that tells <samp><span
class="command">gawk</span></samp>
-how to split input with fixed columnar boundaries.
-Assigning a value to <code>FIELDWIDTHS</code>
-overrides the use of <code>FS</code> for field splitting.
-See <a href="#Constant-Size">Constant Size</a>, for more information.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-in-1007"></a>If
<samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>), then <code>FIELDWIDTHS</code>
-has no special meaning, and field-splitting operations occur based
-exclusively on the value of <code>FS</code>.
-
- <p><a name="index-_0040code_007bFS_007d-variable-1008"></a><a
name="index-separators_002c-field-1009"></a><a
name="index-field-separators-1010"></a><br><dt><code>FS</code><dd>This is the
input field separator
-(see <a href="#Field-Separators">Field Separators</a>).
-The value is a single-character string or a multi-character regular
-expression that matches the separations between fields in an input
-record. If the value is the null string (<code>""</code>), then each
-character in the record becomes a separate field.
-(This behavior is a <samp><span class="command">gawk</span></samp> extension.
POSIX <samp><span class="command">awk</span></samp> does not
-specify the behavior when <code>FS</code> is the null string.)
-<!-- NEXT ED: Mark as common extension -->
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bFS_007d-variable-and-1011"></a>The
default value is <code>" "</code><!-- /@w -->, a string consisting of a
single
-space. As a special exception, this value means that any
-sequence of spaces, tabs, and/or newlines is a single separator.<a
rel="footnote" href="#fn-27" name="fnd-27"><sup>27</sup></a> It also causes
-spaces, tabs, and newlines at the beginning and end of a record to be ignored.
-
- <p>You can set the value of <code>FS</code> on the command line using the
-<samp><span class="option">-F</span></samp> option:
-
- <pre class="example"> awk -F, '<var>program</var>'
<var>input-files</var>
- </pre>
- <p><a
name="index-_0040command_007bgawk_007d_002c-field-separators-and-1012"></a>If
<samp><span class="command">gawk</span></samp> is using
<code>FIELDWIDTHS</code> for field splitting,
-assigning a value to <code>FS</code> causes <samp><span
class="command">gawk</span></samp> to return to
-the normal, <code>FS</code>-based field splitting. An easy way to do this
-is to simply say `<samp><span class="samp">FS = FS</span></samp>', perhaps
with an explanatory comment.
-
- <p><a name="index-_0040code_007bIGNORECASE_007d-variable-1013"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-1014"></a><a
name="index-case-sensitivity_002c-string-comparisons-and-1015"></a><a
name="index-case-sensitivity_002c-regexps-and-1016"></a><a
name="index-regular-expressions_002c-case-sensitivity-1017"></a><br><dt><code>IGNORECASE
#</code><dd>If <code>IGNORECASE</code> is nonzero or non-null, then all string
comparisons
-and all regular expression matching are case independent. Thus, regexp
-matching with `<samp><span class="samp">~</span></samp>' and `<samp><span
class="samp">!~</span></samp>', as well as the <code>gensub</code>,
-<code>gsub</code>, <code>index</code>, <code>match</code>, <code>split</code>,
and <code>sub</code>
-functions, record termination with <code>RS</code>, and field splitting with
-<code>FS</code>, all ignore case when doing their particular regexp
operations.
-However, the value of <code>IGNORECASE</code> does <em>not</em> affect array
subscripting
-and it does not affect field splitting when using a single-character
-field separator.
-See <a href="#Case_002dsensitivity">Case-sensitivity</a>.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-in-1018"></a>If
<samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-then <code>IGNORECASE</code> has no special meaning. Thus, string
-and regexp operations are always case-sensitive.
-
- <p><a name="index-_0040code_007bLINT_007d-variable-1019"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-1020"></a><a
name="index-lint-checking-1021"></a><br><dt><code>LINT #</code><dd>When this
variable is true (nonzero or non-null), <samp><span
class="command">gawk</span></samp>
-behaves as if the <samp><span class="option">--lint</span></samp> command-line
option is in effect.
-(see <a href="#Options">Options</a>).
-With a value of <code>"fatal"</code>, lint warnings become fatal errors.
-With a value of <code>"invalid"</code>, only warnings about things that are
-actually invalid are issued. (This is not fully implemented yet.)
-Any other true value prints nonfatal warnings.
-Assigning a false value to <code>LINT</code> turns off the lint warnings.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-in-1022"></a>This
variable is a <samp><span class="command">gawk</span></samp> extension. It is
not special
-in other <samp><span class="command">awk</span></samp> implementations.
Unlike the other special variables,
-changing <code>LINT</code> does affect the production of lint warnings,
-even if <samp><span class="command">gawk</span></samp> is in compatibility
mode. Much as
-the <samp><span class="option">--lint</span></samp> and <samp><span
class="option">--traditional</span></samp> options independently
-control different aspects of <samp><span class="command">gawk</span></samp>'s
behavior, the control
-of lint warnings during program execution is independent of the flavor
-of <samp><span class="command">awk</span></samp> being executed.
-
- <p><a name="index-_0040code_007bOFMT_007d-variable-1023"></a><a
name="index-numbers_002c-converting_002c-to-strings-1024"></a><a
name="index-strings_002c-converting_002c-numbers-to-1025"></a><br><dt><code>OFMT</code><dd>This
string controls conversion of numbers to
-strings (see <a href="#Conversion">Conversion</a>) for
-printing with the <code>print</code> statement. It works by being passed
-as the first argument to the <code>sprintf</code> function
-(see <a href="#String-Functions">String Functions</a>).
-Its default value is <code>"%.6g"</code>. Earlier versions of <samp><span
class="command">awk</span></samp>
-also used <code>OFMT</code> to specify the format for converting numbers to
-strings in general expressions; this is now done by <code>CONVFMT</code>.
-
- <p><a
name="index-_0040code_007bsprintf_007d-function_002c-_0040code_007bOFMT_007d-variable-and-1026"></a><a
name="index-_0040code_007bprint_007d-statement_002c-_0040code_007bOFMT_007d-variable-and-1027"></a><a
name="index-_0040code_007bOFS_007d-variable-1028"></a><a
name="index-separators_002c-field-1029"></a><a
name="index-field-separators-1030"></a><br><dt><code>OFS</code><dd>This is the
output field separator (see <a href="#Output-Separators">Output
Separators</a>). It is
-output between the fields printed by a <code>print</code> statement. Its
-default value is <code>" "</code><!-- /@w -->, a string consisting of a
single space.
-
- <p><a
name="index-_0040code_007bORS_007d-variable-1031"></a><br><dt><code>ORS</code><dd>This
is the output record separator. It is output at the end of every
-<code>print</code> statement. Its default value is <code>"\n"</code>, the
newline
-character. (See <a href="#Output-Separators">Output Separators</a>.)
-
- <p><a name="index-_0040code_007bRS_007d-variable-1032"></a><a
name="index-separators_002c-record-1033"></a><a
name="index-record-separators-1034"></a><br><dt><code>RS</code><dd>This is
<samp><span class="command">awk</span></samp>'s input record separator. Its
default value is a string
-containing a single newline character, which means that an input record
-consists of a single line of text.
-It can also be the null string, in which case records are separated by
-runs of blank lines.
-If it is a regexp, records are separated by
-matches of the regexp in the input text.
-(See <a href="#Records">Records</a>.)
-
- <p>The ability for <code>RS</code> to be a regular expression
-is a <samp><span class="command">gawk</span></samp> extension.
-In most other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-just the first character of <code>RS</code>'s value is used.
-
- <p><a name="index-_0040code_007bSUBSEP_007d-variable-1035"></a><a
name="index-separators_002c-subscript-1036"></a><a
name="index-subscript-separators-1037"></a><br><dt><code>SUBSEP</code><dd>This
is the subscript separator. It has the default value of
-<code>"\034"</code> and is used to separate the parts of the indices of a
-multidimensional array. Thus, the expression <code>foo["A", "B"]<!-- /@w
--></code>
-really accesses <code>foo["A\034B"]</code>
-(see <a href="#Multi_002ddimensional">Multi-dimensional</a>).
-
- <p><a name="index-_0040code_007bTEXTDOMAIN_007d-variable-1038"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bTEXTDOMAIN_007d-variable-1039"></a><a
name="index-internationalization_002c-localization-1040"></a><br><dt><code>TEXTDOMAIN
#</code><dd>This variable is used for internationalization of programs at the
-<samp><span class="command">awk</span></samp> level. It sets the default text
domain for specially
-marked string constants in the source text, as well as for the
-<code>dcgettext</code>, <code>dcngettext</code> and
<code>bindtextdomain</code> functions
-(see <a href="#Internationalization">Internationalization</a>).
-The default value of <code>TEXTDOMAIN</code> is <code>"messages"</code>.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-it is not special.
-</dl>
- <!-- ENDOFRANGE bvar -->
-<!-- ENDOFRANGE varb -->
-<!-- ENDOFRANGE bvaru -->
-<!-- ENDOFRANGE nmbv -->
-
-<div class="node">
-<p><hr>
-<a name="Auto_002dset"></a>Next: <a rel="next" accesskey="n"
href="#ARGC-and-ARGV">ARGC and ARGV</a>,
-Previous: <a rel="previous" accesskey="p"
href="#User_002dmodified">User-modified</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din-Variables">Built-in
Variables</a>
-<br>
-</div>
-
-<h4 class="subsection">6.5.2 Built-in Variables That Convey Information</h4>
-
-<!-- STARTOFRANGE bvconi -->
-<p><a
name="index-built_002din-variables_002c-conveying-information-1041"></a><!--
STARTOFRANGE vbconi -->
-<a
name="index-variables_002c-built_002din_002c-conveying-information-1042"></a>The
following is an alphabetical list of variables that <samp><span
class="command">awk</span></samp>
-sets automatically on certain occasions in order to provide
-information to your program. The variables that are specific to
-<samp><span class="command">gawk</span></samp> are marked with a pound
sign (`<samp><span class="samp">#</span></samp>').<!-- /@w -->
-
-
-<a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1043"></a>
-<a name="index-arguments_002c-command_002dline-1044"></a>
-<a name="index-command-line_002c-arguments-1045"></a>
-<dl><dt><code>ARGC</code><span class="roman">,</span><code> ARGV</code><dd>The
command-line arguments available to <samp><span
class="command">awk</span></samp> programs are stored in
-an array called <code>ARGV</code>. <code>ARGC</code> is the number of
command-line
-arguments present. See <a href="#Other-Arguments">Other Arguments</a>.
-Unlike most <samp><span class="command">awk</span></samp> arrays,
-<code>ARGV</code> is indexed from 0 to <code>ARGC</code> − 1.
-In the following example:
-
- <pre class="example"> $ awk 'BEGIN {
- > for (i = 0; i < ARGC; i++)
- > print ARGV[i]
- > }' inventory-shipped BBS-list
- -| awk
- -| inventory-shipped
- -| BBS-list
- </pre>
- <p class="noindent"><code>ARGV[0]</code> contains <code>"awk"</code>,
<code>ARGV[1]</code>
-contains <code>"inventory-shipped"</code>, and <code>ARGV[2]</code> contains
-<code>"BBS-list"</code>. The value of <code>ARGC</code> is three, one more
than the
-index of the last element in <code>ARGV</code>, because the elements are
numbered
-from zero.
-
- <p><a
name="index-programming-conventions_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1046"></a>The
names <code>ARGC</code> and <code>ARGV</code>, as well as the convention of
indexing
-the array from 0 to <code>ARGC</code> − 1, are derived from the C
language's
-method of accessing command-line arguments.
-
- <p>The value of <code>ARGV[0]</code> can vary from system to system.
-Also, you should note that the program text is <em>not</em> included in
-<code>ARGV</code>, nor are any of <samp><span
class="command">awk</span></samp>'s command-line options.
-See <a href="#ARGC-and-ARGV">ARGC and ARGV</a>, for information
-about how <samp><span class="command">awk</span></samp> uses these variables.
-
- <p><a name="index-_0040code_007bARGIND_007d-variable-1047"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGIND_007d-variable-1048"></a><br><dt><code>ARGIND
#</code><dd>The index in <code>ARGV</code> of the current file being
processed.
-Every time <samp><span class="command">gawk</span></samp> opens a new data
file for processing, it sets
-<code>ARGIND</code> to the index in <code>ARGV</code> of the file name.
-When <samp><span class="command">gawk</span></samp> is processing the input
files,
-`<samp><span class="samp">FILENAME == ARGV[ARGIND]</span></samp>' is always
true.
-
- <p><a
name="index-files_002c-processing_0040comma_007b_007d-_0040code_007bARGIND_007d-variable-and-1049"></a>This
variable is useful in file processing; it allows you to tell how far
-along you are in the list of data files as well as to distinguish between
-successive instances of the same file name on the command line.
-
- <p><a
name="index-_0040value_007bFN_007ds_002c-distinguishing-1050"></a>While you can
change the value of <code>ARGIND</code> within your <samp><span
class="command">awk</span></samp>
-program, <samp><span class="command">gawk</span></samp> automatically sets it
to a new value when the
-next file is opened.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-it is not special.
-
- <p><a name="index-_0040code_007bENVIRON_007d-variable-1051"></a><a
name="index-environment-variables-1052"></a><br><dt><code>ENVIRON</code><dd>An
associative array that contains the values of the environment. The array
-indices are the environment variable names; the elements are the values of
-the particular environment variables. For example,
-<code>ENVIRON["HOME"]</code> might be <samp><span
class="file">/home/arnold</span></samp>. Changing this array
-does not affect the environment passed on to any programs that
-<samp><span class="command">awk</span></samp> may spawn via redirection or the
<code>system</code> function.
-<!-- (In a future version of @command{gawk}, it may do so.) -->
-
- <p>Some operating systems may not have environment variables.
-On such systems, the <code>ENVIRON</code> array is empty (except for
-<code>ENVIRON["AWKPATH"]</code><!-- /@w -->,
-see <a href="#AWKPATH-Variable">AWKPATH Variable</a>).
-
- <p><a name="index-_0040code_007bERRNO_007d-variable-1053"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bERRNO_007d-variable-1054"></a><a
name="index-error-handling_002c-_0040code_007bERRNO_007d-variable-and-1055"></a><br><dt><code>ERRNO
#</code><dd>If a system error occurs during a redirection for
<code>getline</code>,
-during a read for <code>getline</code>, or during a <code>close</code>
operation,
-then <code>ERRNO</code> contains a string describing the error.
-
- <p><code>ERRNO</code> works similarly to the C variable
<code>errno</code>.
-In particular <samp><span class="command">gawk</span></samp> <em>never</em>
clears it (sets it
-to zero or <code>""</code>). Thus, you should only expect its value
-to be meaningful when an I/O operation returns a failure
-value, such as <code>getline</code> returning −1.
-You are, of course, free to clear it yourself before doing an
-I/O operation.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-it is not special.
-
- <p><a name="index-_0040code_007bFILENAME_007d-variable-1056"></a><a
name="index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-1057"></a><br><dt><code>FILENAME</code><dd>The
name of the file that <samp><span class="command">awk</span></samp> is
currently reading.
-When no data files are listed on the command line, <samp><span
class="command">awk</span></samp> reads
-from the standard input and <code>FILENAME</code> is set to <code>"-"</code>.
-<code>FILENAME</code> is changed each time a new file is read
-(see <a href="#Reading-Files">Reading Files</a>).
-Inside a <code>BEGIN</code> rule, the value of <code>FILENAME</code> is
-<code>""</code>, since there are no input files being processed
-yet.<a rel="footnote" href="#fn-28" name="fnd-28"><sup>28</sup></a>
-(d.c.)
-Note, though, that using <code>getline</code>
-(see <a href="#Getline">Getline</a>)
-inside a <code>BEGIN</code> rule can give
-<code>FILENAME</code> a value.
-
- <p><a
name="index-_0040code_007bFNR_007d-variable-1058"></a><br><dt><code>FNR</code><dd>The
current record number in the current file. <code>FNR</code> is
-incremented each time a new record is read
-(see <a href="#Getline">Getline</a>). It is reinitialized
-to zero each time a new input file is started.
-
- <p><a
name="index-_0040code_007bNF_007d-variable-1059"></a><br><dt><code>NF</code><dd>The
number of fields in the current input record.
-<code>NF</code> is set each time a new record is read, when a new field is
-created or when <code>$0</code> changes (see <a href="#Fields">Fields</a>).
-
- <p>Unlike most of the variables described in this
-section,
-assigning a value to <code>NF</code> has the potential to affect
-<samp><span class="command">awk</span></samp>'s internal workings. In
particular, assignments
-to <code>NF</code> can be used to create or remove fields from the
-current record: See <a href="#Changing-Fields">Changing Fields</a>.
-
- <p><a
name="index-_0040code_007bNR_007d-variable-1060"></a><br><dt><code>NR</code><dd>The
number of input records <samp><span class="command">awk</span></samp> has
processed since
-the beginning of the program's execution
-(see <a href="#Records">Records</a>).
-<code>NR</code> is incremented each time a new record is read.
-
- <p><a name="index-_0040code_007bPROCINFO_007d-array-1061"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bPROCINFO_007d-array-1062"></a><br><dt><code>PROCINFO
#</code><dd>The elements of this array provide access to information about the
-running <samp><span class="command">awk</span></samp> program.
-The following elements (listed alphabetically)
-are guaranteed to be available:
-
- <dl>
-<dt><code>PROCINFO["egid"]</code><dd>The value of the <code>getegid</code>
system call.
-
- <br><dt><code>PROCINFO["euid"]</code><dd>The value of the
<code>geteuid</code> system call.
-
- <br><dt><code>PROCINFO["FS"]</code><dd>This is
-<code>"FS"</code> if field splitting with <code>FS</code> is in effect, or it
is
-<code>"FIELDWIDTHS"</code> if field splitting with <code>FIELDWIDTHS</code> is
in effect.
-
- <br><dt><code>PROCINFO["gid"]</code><dd>The value of the
<code>getgid</code> system call.
-
- <br><dt><code>PROCINFO["pgrpid"]</code><dd>The process group ID of
the current process.
-
- <br><dt><code>PROCINFO["pid"]</code><dd>The process ID of the
current process.
-
- <br><dt><code>PROCINFO["ppid"]</code><dd>The parent process ID of
the current process.
-
- <br><dt><code>PROCINFO["uid"]</code><dd>The value of the
<code>getuid</code> system call.
-
- <br><dt><code>PROCINFO["version"]</code><dd>The version of
<samp><span class="command">gawk</span></samp>. This is available from
-version 3.1.4 and later.
-</dl>
-
- <p>On some systems, there may be elements in the array,
<code>"group1"</code>
-through <code>"group</code><var>N</var><code>"</code> for some <var>N</var>.
<var>N</var> is the number of
-supplementary groups that the process has. Use the <code>in</code> operator
-to test for these elements
-(see <a href="#Reference-to-Elements">Reference to Elements</a>).
-
- <p>This array is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-it is not special.
-
- <p><a
name="index-_0040code_007bRLENGTH_007d-variable-1063"></a><br><dt><code>RLENGTH</code><dd>The
length of the substring matched by the
-<code>match</code> function
-(see <a href="#String-Functions">String Functions</a>).
-<code>RLENGTH</code> is set by invoking the <code>match</code> function. Its
value
-is the length of the matched string, or −1 if no match is found.
-
- <p><a
name="index-_0040code_007bRSTART_007d-variable-1064"></a><br><dt><code>RSTART</code><dd>The
start-index in characters of the substring that is matched by the
-<code>match</code> function
-(see <a href="#String-Functions">String Functions</a>).
-<code>RSTART</code> is set by invoking the <code>match</code> function. Its
value
-is the position of the string where the matched substring starts, or zero
-if no match was found.
-
- <p><a name="index-_0040code_007bRT_007d-variable-1065"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRT_007d-variable-1066"></a><br><dt><code>RT
#</code><dd>This is set each time a record is read. It contains the input text
-that matched the text denoted by <code>RS</code>, the record separator.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="#Options">Options</a>),
-it is not special.
-</dl>
- <!-- ENDOFRANGE bvconi -->
-<!-- ENDOFRANGE vbconi -->
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Changing <code>NR</code> and
<code>FNR</code></h4>
-
-<p><a name="index-_0040code_007bNR_007d-variable_002c-changing-1067"></a><a
name="index-_0040code_007bFNR_007d-variable_002c-changing-1068"></a><a
name="index-advanced-features_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1069"></a><a
name="index-dark-corner_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1070"></a><samp><span
class="command">awk</span></samp> increments <code>NR</code> and
<code>FNR</code>
-each time it reads a record, instead of setting them to the absolute
-value of the number of records read. This means that a program can
-change these variables and their new values are incremented for
-each record.
-(d.c.)
-This is demonstrated in the following example:
-
-<pre class="example"> $ echo '1
- > 2
- > 3
- > 4' | awk 'NR == 2 { NR = 17 }
- > { print NR }'
- -| 1
- -| 17
- -| 18
- -| 19
-</pre>
- <p class="noindent">Before <code>FNR</code> was added to the <samp><span
class="command">awk</span></samp> language
-(see <a href="#V7_002fSVR3_002e1">V7/SVR3.1</a>),
-many <samp><span class="command">awk</span></samp> programs used this feature
to track the number of
-records in a file by resetting <code>NR</code> to zero when
<code>FILENAME</code>
-changed.
-
-<div class="node">
-<p><hr>
-<a name="ARGC-and-ARGV"></a>Previous: <a rel="previous" accesskey="p"
href="#Auto_002dset">Auto-set</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din-Variables">Built-in
Variables</a>
-<br>
-</div>
-
-<h4 class="subsection">6.5.3 Using <code>ARGC</code> and <code>ARGV</code></h4>
-
-<p><a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1071"></a><a
name="index-arguments_002c-command_002dline-1072"></a><a
name="index-command-line_002c-arguments-1073"></a>
-<a href="#Auto_002dset">Auto-set</a>,
-presented the following program describing the information contained in
<code>ARGC</code>
-and <code>ARGV</code>:
-
-<pre class="example"> $ awk 'BEGIN {
- > for (i = 0; i < ARGC; i++)
- > print ARGV[i]
- > }' inventory-shipped BBS-list
- -| awk
- -| inventory-shipped
- -| BBS-list
-</pre>
- <p class="noindent">In this example, <code>ARGV[0]</code> contains
`<samp><span class="samp">awk</span></samp>', <code>ARGV[1]</code>
-contains `<samp><span class="samp">inventory-shipped</span></samp>', and
<code>ARGV[2]</code> contains
-`<samp><span class="samp">BBS-list</span></samp>'.
-Notice that the <samp><span class="command">awk</span></samp> program is not
entered in <code>ARGV</code>. The
-other special command-line options, with their arguments, are also not
-entered. This includes variable assignments done with the <samp><span
class="option">-v</span></samp>
-option (see <a href="#Options">Options</a>).
-Normal variable assignments on the command line <em>are</em>
-treated as arguments and do show up in the <code>ARGV</code> array:
-
-<pre class="example"> $ cat showargs.awk
- -| BEGIN {
- -| printf "A=%d, B=%d\n", A, B
- -| for (i = 0; i < ARGC; i++)
- -| printf "\tARGV[%d] = %s\n", i, ARGV[i]
- -| }
- -| END { printf "A=%d, B=%d\n", A, B }
- $ awk -v A=1 -f showargs.awk B=2 /dev/null
- -| A=1, B=0
- -| ARGV[0] = awk
- -| ARGV[1] = B=2
- -| ARGV[2] = /dev/null
- -| A=1, B=2
-</pre>
- <p>A program can alter <code>ARGC</code> and the elements of
<code>ARGV</code>.
-Each time <samp><span class="command">awk</span></samp> reaches the end of an
input file, it uses the next
-element of <code>ARGV</code> as the name of the next input file. By storing a
-different string there, a program can change which files are read.
-Use <code>"-"</code> to represent the standard input. Storing
-additional elements and incrementing <code>ARGC</code> causes
-additional files to be read.
-
- <p>If the value of <code>ARGC</code> is decreased, that eliminates input
files
-from the end of the list. By recording the old value of <code>ARGC</code>
-elsewhere, a program can treat the eliminated arguments as
-something other than file names.
-
- <p>To eliminate a file from the middle of the list, store the null string
-(<code>""</code>) into <code>ARGV</code> in place of the file's name. As a
-special feature, <samp><span class="command">awk</span></samp> ignores file
names that have been
-replaced with the null string.
-Another option is to
-use the <code>delete</code> statement to remove elements from
-<code>ARGV</code> (see <a href="#Delete">Delete</a>).
-
- <p>All of these actions are typically done in the <code>BEGIN</code> rule,
-before actual processing of the input begins.
-See <a href="#Split-Program">Split Program</a>, and see
-<a href="#Tee-Program">Tee Program</a>, for examples
-of each way of removing elements from <code>ARGV</code>.
-The following fragment processes <code>ARGV</code> in order to examine, and
-then remove, command-line options:
-<!-- NEXT ED: Add xref to rewind() function -->
-
-<pre class="example"> BEGIN {
- for (i = 1; i < ARGC; i++) {
- if (ARGV[i] == "-v")
- verbose = 1
- else if (ARGV[i] == "-d")
- debug = 1
- else if (ARGV[i] ~ /^-?/) {
- e = sprintf("%s: unrecognized option -- %c",
- ARGV[0], substr(ARGV[i], 1, ,1))
- print e > "/dev/stderr"
- } else
- break
- delete ARGV[i]
- }
- }
-</pre>
- <p>To actually get the options into the <samp><span
class="command">awk</span></samp> program,
-end the <samp><span class="command">awk</span></samp> options with <samp><span
class="option">--</span></samp> and then supply
-the <samp><span class="command">awk</span></samp> program's options, in the
following manner:
-
-<pre class="example"> awk -f myprog -- -v -d file1 file2 ...
-</pre>
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1074"></a>This
is not necessary in <samp><span class="command">gawk</span></samp>. Unless
<samp><span class="option">--posix</span></samp> has
-been specified, <samp><span class="command">gawk</span></samp> silently puts
any unrecognized options
-into <code>ARGV</code> for the <samp><span class="command">awk</span></samp>
program to deal with. As soon
-as it sees an unknown option, <samp><span class="command">gawk</span></samp>
stops looking for other
-options that it might otherwise recognize. The previous example with
-<samp><span class="command">gawk</span></samp> would be:
-
-<pre class="example"> gawk -f myprog -d -v file1 file2 ...
-</pre>
- <p class="noindent">Because <samp><span class="option">-d</span></samp> is
not a valid <samp><span class="command">gawk</span></samp> option,
-it and the following <samp><span class="option">-v</span></samp>
-are passed on to the <samp><span class="command">awk</span></samp> program.
-
-<div class="node">
-<p><hr>
-<a name="Arrays"></a>Next: <a rel="next" accesskey="n"
href="#Functions">Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Patterns-and-Actions">Patterns and Actions</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">7 Arrays in <samp><span
class="command">awk</span></samp></h2>
-
-<!-- STARTOFRANGE arrs -->
-<p><a name="index-arrays-1075"></a>
-An <dfn>array</dfn> is a table of values called <dfn>elements</dfn>. The
-elements of an array are distinguished by their indices. <dfn>Indices</dfn>
-may be either numbers or strings.
-
- <p>This chapter describes how arrays work in <samp><span
class="command">awk</span></samp>,
-how to use array elements, how to scan through every element in an array,
-and how to remove array elements.
-It also describes how <samp><span class="command">awk</span></samp> simulates
multidimensional
-arrays, as well as some of the less obvious points about array usage.
-The chapter finishes with a discussion of <samp><span
class="command">gawk</span></samp>'s facility
-for sorting an array based on its indices.
-
- <p><a name="index-variables_002c-names-of-1076"></a><a
name="index-functions_002c-names-of-1077"></a><a
name="index-arrays_002c-names-of-1078"></a><a
name="index-names_002c-arrays_002fvariables-1079"></a><a
name="index-namespace-issues-1080"></a><samp><span
class="command">awk</span></samp> maintains a single set
-of names that may be used for naming variables, arrays, and functions
-(see <a href="#User_002ddefined">User-defined</a>).
-Thus, you cannot have a variable and an array with the same name in the
-same <samp><span class="command">awk</span></samp> program.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Array-Intro">Array Intro</a>:
Introduction to Arrays
-<li><a accesskey="2" href="#Reference-to-Elements">Reference to Elements</a>:
How to examine one element of an array.
-<li><a accesskey="3" href="#Assigning-Elements">Assigning Elements</a>:
How to change an element of an array.
-<li><a accesskey="4" href="#Array-Example">Array Example</a>:
Basic Example of an Array
-<li><a accesskey="5" href="#Scanning-an-Array">Scanning an Array</a>:
A variation of the <code>for</code> statement. It
- loops through the indices of an array's
- existing elements.
-<li><a accesskey="6" href="#Delete">Delete</a>: The
<code>delete</code> statement removes an element
- from an array.
-<li><a accesskey="7" href="#Numeric-Array-Subscripts">Numeric Array
Subscripts</a>: How to use numbers as subscripts in
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="8" href="#Uninitialized-Subscripts">Uninitialized
Subscripts</a>: Using Uninitialized variables as subscripts.
-<li><a accesskey="9" href="#Multi_002ddimensional">Multi-dimensional</a>:
Emulating multidimensional arrays in
- <samp><span class="command">awk</span></samp>.
-<li><a href="#Multi_002dscanning">Multi-scanning</a>: Scanning
multidimensional arrays.
-<li><a href="#Array-Sorting">Array Sorting</a>: Sorting array
values and indices.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Array-Intro"></a>Next: <a rel="next" accesskey="n"
href="#Reference-to-Elements">Reference to Elements</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.1 Introduction to Arrays</h3>
-
-<p>The <samp><span class="command">awk</span></samp> language provides
one-dimensional arrays
-for storing groups of related strings or numbers.
-Every <samp><span class="command">awk</span></samp> array must have a name.
Array names have the same
-syntax as variable names; any valid variable name would also be a valid
-array name. But one name cannot be used in both ways (as an array and
-as a variable) in the same <samp><span class="command">awk</span></samp>
program.
-
- <p>Arrays in <samp><span class="command">awk</span></samp> superficially
resemble arrays in other programming
-languages, but there are fundamental differences. In <samp><span
class="command">awk</span></samp>, it
-isn't necessary to specify the size of an array before starting to use it.
-Additionally, any number or string in <samp><span
class="command">awk</span></samp>, not just consecutive integers,
-may be used as an array index.
-
- <p>In most other languages, arrays must be <dfn>declared</dfn> before use,
-including a specification of
-how many elements or components they contain. In such languages, the
-declaration causes a contiguous block of memory to be allocated for that
-many elements. Usually, an index in the array must be a positive integer.
-For example, the index zero specifies the first element in the array, which is
-actually stored at the beginning of the block of memory. Index one
-specifies the second element, which is stored in memory right after the
-first element, and so on. It is impossible to add more elements to the
-array, because it has room only for as many elements as given in
-the declaration.
-(Some languages allow arbitrary starting and ending
-indices—e.g., `<samp><span class="samp">15 ..
27</span></samp>'—but the size of the array is still fixed when
-the array is declared.)
-
- <p>A contiguous array of four elements might look like the following
example,
-conceptually, if the element values are 8, <code>"foo"</code>,
-<code>""</code>, and 30:
-
-<!-- NEXT ED: Use real images here -->
-<p class="noindent">Only the values are stored; the indices are implicit from
the order of
-the values. Here, 8 is the value at index zero, because 8 appears in the
-position with zero elements before it.
-
-<!-- STARTOFRANGE arrin -->
-<p><a name="index-arrays_002c-indexing-1081"></a><!-- STARTOFRANGE inarr -->
-<a name="index-indexing-arrays-1082"></a><a
name="index-associative-arrays-1083"></a><a
name="index-arrays_002c-associative-1084"></a>Arrays in <samp><span
class="command">awk</span></samp> are different—they are
<dfn>associative</dfn>. This means
-that each array is a collection of pairs: an index and its corresponding
-array element value:
-
-<pre class="example"> <span class="roman">Element</span> 3 <span
class="roman">Value</span> 30
- <span class="roman">Element</span> 1 <span class="roman">Value</span>
"foo"
- <span class="roman">Element</span> 0 <span class="roman">Value</span>
8
- <span class="roman">Element</span> 2 <span class="roman">Value</span>
""
-</pre>
- <p class="noindent">The pairs are shown in jumbled order because their
order is irrelevant.
-
- <p>One advantage of associative arrays is that new pairs can be added
-at any time. For example, suppose a tenth element is added to the array
-whose value is <code>"number ten"</code><!-- /@w -->. The result is:
-
-<pre class="example"> <span class="roman">Element</span> 10 <span
class="roman">Value</span> "number ten"
- <span class="roman">Element</span> 3 <span class="roman">Value</span>
30
- <span class="roman">Element</span> 1 <span class="roman">Value</span>
"foo"
- <span class="roman">Element</span> 0 <span class="roman">Value</span>
8
- <span class="roman">Element</span> 2 <span class="roman">Value</span>
""
-</pre>
- <p class="noindent"><a name="index-sparse-arrays-1085"></a><a
name="index-arrays_002c-sparse-1086"></a>Now the array is <dfn>sparse</dfn>,
which just means some indices are missing.
-It has elements 0–3 and 10, but doesn't have elements 4, 5, 6, 7, 8, or
9.
-
- <p>Another consequence of associative arrays is that the indices don't
-have to be positive integers. Any number, or even a string, can be
-an index. For example, the following is an array that translates words from
-English to French:
-
-<pre class="example"> <span class="roman">Element</span> "dog" <span
class="roman">Value</span> "chien"
- <span class="roman">Element</span> "cat" <span class="roman">Value</span>
"chat"
- <span class="roman">Element</span> "one" <span class="roman">Value</span>
"un"
- <span class="roman">Element</span> 1 <span class="roman">Value</span>
"un"
-</pre>
- <p class="noindent">Here we decided to translate the number one in both
spelled-out and
-numeric form—thus illustrating that a single array can have both
-numbers and strings as indices.
-In fact, array subscripts are always strings; this is discussed
-in more detail in
-<a href="#Numeric-Array-Subscripts">Numeric Array Subscripts</a>.
-Here, the number <code>1</code> isn't double-quoted, since <samp><span
class="command">awk</span></samp>
-automatically converts it to a string.
-
- <p><a name="index-case-sensitivity_002c-array-indices-and-1087"></a><a
name="index-arrays_002c-_0040code_007bIGNORECASE_007d-variable-and-1088"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable_002c-array-subscripts-and-1089"></a>The
value of <code>IGNORECASE</code> has no effect upon array subscripting.
-The identical string value used to store an array element must be used
-to retrieve it.
-When <samp><span class="command">awk</span></samp> creates an array (e.g.,
with the <code>split</code>
-built-in function),
-that array's indices are consecutive integers starting at one.
-(See <a href="#String-Functions">String Functions</a>.)
-
- <p><samp><span class="command">awk</span></samp>'s arrays are
efficient—the time to access an element
-is independent of the number of elements in the array.
-<!-- ENDOFRANGE arrin -->
-<!-- ENDOFRANGE inarr -->
-
-<div class="node">
-<p><hr>
-<a name="Reference-to-Elements"></a>Next: <a rel="next" accesskey="n"
href="#Assigning-Elements">Assigning Elements</a>,
-Previous: <a rel="previous" accesskey="p" href="#Array-Intro">Array
Intro</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.2 Referring to an Array Element</h3>
-
-<p><a name="index-arrays_002c-elements_002c-referencing-1090"></a><a
name="index-elements-in-arrays-1091"></a>
-The principal way to use an array is to refer to one of its elements.
-An array reference is an expression as follows:
-
-<pre class="example"> <var>array</var>[<var>index</var>]
-</pre>
- <p class="noindent">Here, <var>array</var> is the name of an array. The
expression <var>index</var> is
-the index of the desired element of the array.
-
- <p>The value of the array reference is the current value of that array
-element. For example, <code>foo[4.3]</code> is an expression for the element
-of array <code>foo</code> at index `<samp><span
class="samp">4.3</span></samp>'.
-
- <p>A reference to an array element that has no recorded value yields a
value of
-<code>""</code>, the null string. This includes elements
-that have not been assigned any value as well as elements that have been
-deleted (see <a href="#Delete">Delete</a>). Such a reference
-automatically creates that array element, with the null string as its value.
-(In some cases, this is unfortunate, because it might waste memory inside
-<samp><span class="command">awk</span></samp>.)
-
-<!-- @cindex arrays, @code{in} operator and -->
-<p><a name="index-_0040code_007bin_007d-operator_002c-arrays-and-1092"></a>To
determine whether an element exists in an array at a certain index, use
-the following expression:
-
-<pre class="example"> <var>index</var> in <var>array</var>
-</pre>
- <p><a name="index-side-effects_002c-array-indexing-1093"></a>This
expression tests whether the particular index exists,
-without the side effect of creating that element if it is not present.
-The expression has the value one (true) if
<var>array</var><code>[</code><var>index</var><code>]</code>
-exists and zero (false) if it does not exist.
-For example, this statement tests whether the array <code>frequencies</code>
-contains the index `<samp><span class="samp">2</span></samp>':
-
-<pre class="example"> if (2 in frequencies)
- print "Subscript 2 is present."
-</pre>
- <p>Note that this is <em>not</em> a test of whether the array
-<code>frequencies</code> contains an element whose <em>value</em> is two.
-There is no way to do that except to scan all the elements. Also, this
-<em>does not</em> create <code>frequencies[2]</code>, while the following
-(incorrect) alternative does:
-
-<pre class="example"> if (frequencies[2] != "")
- print "Subscript 2 is present."
-</pre>
- <div class="node">
-<p><hr>
-<a name="Assigning-Elements"></a>Next: <a rel="next" accesskey="n"
href="#Array-Example">Array Example</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Reference-to-Elements">Reference to Elements</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.3 Assigning Array Elements</h3>
-
-<p><a name="index-arrays_002c-elements_002c-assigning-1094"></a><a
name="index-elements-in-arrays_002c-assigning-1095"></a>
-Array elements can be assigned values just like
-<samp><span class="command">awk</span></samp> variables:
-
-<pre class="example"> <var>array</var>[<var>subscript</var>] =
<var>value</var>
-</pre>
- <p class="noindent"><var>array</var> is the name of an array. The
expression
-<var>subscript</var> is the index of the element of the array that is
-assigned a value. The expression <var>value</var> is the value to
-assign to that element of the array.
-
-<div class="node">
-<p><hr>
-<a name="Array-Example"></a>Next: <a rel="next" accesskey="n"
href="#Scanning-an-Array">Scanning an Array</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Assigning-Elements">Assigning Elements</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.4 Basic Array Example</h3>
-
-<p>The following program takes a list of lines, each beginning with a line
-number, and prints them out in order of line number. The line numbers
-are not in order when they are first read—instead they
-are scrambled. This program sorts the lines by making an array using
-the line numbers as subscripts. The program then prints out the lines
-in sorted order of their numbers. It is a very simple program and gets
-confused upon encountering repeated numbers, gaps, or lines that don't
-begin with a number:
-
-<pre class="example"> <!-- file eg/misc/arraymax.awk -->
- {
- if ($1 > max)
- max = $1
- arr[$1] = $0
- }
-
- END {
- for (x = 1; x <= max; x++)
- print arr[x]
- }
- <!-- endfile -->
-</pre>
- <p>The first rule keeps track of the largest line number seen so far;
-it also stores each line into the array <code>arr</code>, at an index that
-is the line's number.
-The second rule runs after all the input has been read, to print out
-all the lines.
-When this program is run with the following input:
-
-<pre class="example"> <!-- file eg/misc/arraymax.data -->
- 5 I am the Five man
- 2 Who are you? The new number two!
- 4 . . . And four on the floor
- 1 Who is number one?
- 3 I three you.
- <!-- endfile -->
-</pre>
- <p class="noindent">Its output is:
-
-<pre class="example"> 1 Who is number one?
- 2 Who are you? The new number two!
- 3 I three you.
- 4 . . . And four on the floor
- 5 I am the Five man
-</pre>
- <p>If a line number is repeated, the last line with a given number overrides
-the others.
-Gaps in the line numbers can be handled with an easy improvement to the
-program's <code>END</code> rule, as follows:
-
-<pre class="example"> END {
- for (x = 1; x <= max; x++)
- if (x in arr)
- print arr[x]
- }
-</pre>
- <div class="node">
-<p><hr>
-<a name="Scanning-an-Array"></a>Next: <a rel="next" accesskey="n"
href="#Delete">Delete</a>,
-Previous: <a rel="previous" accesskey="p" href="#Array-Example">Array
Example</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.5 Scanning All Elements of an Array</h3>
-
-<p><a name="index-elements-in-arrays_002c-scanning-1096"></a><a
name="index-arrays_002c-scanning-1097"></a>
-In programs that use arrays, it is often necessary to use a loop that
-executes once for each element of an array. In other languages, where
-arrays are contiguous and indices are limited to positive integers,
-this is easy: all the valid indices can be found by counting from
-the lowest index up to the highest. This technique won't do the job
-in <samp><span class="command">awk</span></samp>, because any number or string
can be an array index.
-So <samp><span class="command">awk</span></samp> has a special kind of
<code>for</code> statement for scanning
-an array:
-
-<pre class="example"> for (<var>var</var> in <var>array</var>)
- <var>body</var>
-</pre>
- <p class="noindent"><a
name="index-_0040code_007bin_007d-operator_002c-arrays-and-1098"></a>This loop
executes <var>body</var> once for each index in <var>array</var> that the
-program has previously used, with the variable <var>var</var> set to that
index.
-
- <p><a
name="index-arrays_002c-_0040code_007bfor_007d-statement-and-1099"></a><a
name="index-_0040code_007bfor_007d-statement_002c-in-arrays-1100"></a>The
following program uses this form of the <code>for</code> statement. The
-first rule scans the input records and notes which words appear (at
-least once) in the input, by storing a one into the array <code>used</code>
with
-the word as index. The second rule scans the elements of <code>used</code> to
-find all the distinct words that appear in the input. It prints each
-word that is more than 10 characters long and also prints the number of
-such words.
-See <a href="#String-Functions">String Functions</a>,
-for more information on the built-in function <code>length</code>.
-
-<pre class="example"> # Record a 1 for each word that is used at least once
- {
- for (i = 1; i <= NF; i++)
- used[$i] = 1
- }
-
- # Find number of distinct words more than 10 characters long
- END {
- for (x in used)
- if (length(x) > 10) {
- ++num_long_words
- print x
- }
- print num_long_words, "words longer than 10 characters"
- }
-</pre>
- <p class="noindent">See <a href="#Word-Sorting">Word Sorting</a>,
-for a more detailed example of this type.
-
- <p><a name="index-arrays_002c-elements_002c-order-of-1101"></a><a
name="index-elements-in-arrays_002c-order-of-1102"></a>The order in which
elements of the array are accessed by this statement
-is determined by the internal arrangement of the array elements within
-<samp><span class="command">awk</span></samp> and cannot be controlled or
changed. This can lead to
-problems if new elements are added to <var>array</var> by statements in
-the loop body; it is not predictable whether the <code>for</code> loop will
-reach them. Similarly, changing <var>var</var> inside the loop may produce
-strange results. It is best to avoid such things.
-
-<div class="node">
-<p><hr>
-<a name="Delete"></a>Next: <a rel="next" accesskey="n"
href="#Numeric-Array-Subscripts">Numeric Array Subscripts</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Scanning-an-Array">Scanning an Array</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.6 The <code>delete</code> Statement</h3>
-
-<p><a name="index-_0040code_007bdelete_007d-statement-1103"></a><a
name="index-deleting-elements-in-arrays-1104"></a><a
name="index-arrays_002c-elements_002c-deleting-1105"></a><a
name="index-elements-in-arrays_002c-deleting-1106"></a>
-To remove an individual element of an array, use the <code>delete</code>
-statement:
-
-<pre class="example"> delete <var>array</var>[<var>index</var>]
-</pre>
- <p>Once an array element has been deleted, any value the element once
-had is no longer available. It is as if the element had never
-been referred to or had been given a value.
-The following is an example of deleting elements in an array:
-
-<pre class="example"> for (i in frequencies)
- delete frequencies[i]
-</pre>
- <p class="noindent">This example removes all the elements from the array
<code>frequencies</code>.
-Once an element is deleted, a subsequent <code>for</code> statement to scan
the array
-does not report that element and the <code>in</code> operator to check for
-the presence of that element returns zero (i.e., false):
-
-<pre class="example"> delete foo[4]
- if (4 in foo)
- print "This will never be printed"
-</pre>
- <p><a name="index-null-strings_002c-array-elements-and-1107"></a>It is
important to note that deleting an element is <em>not</em> the
-same as assigning it a null value (the empty string, <code>""</code>).
-For example:
-
-<pre class="example"> foo[4] = ""
- if (4 in foo)
- print "This is printed, even though foo[4] is empty"
-</pre>
- <p><a name="index-lint-checking_002c-array-elements-1108"></a>It is not an
error to delete an element that does not exist.
-If <samp><span class="option">--lint</span></samp> is provided on the command
line
-(see <a href="#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> issues a warning message when
an element that
-is not in the array is deleted.
-
- <p><a name="index-arrays_002c-deleting-entire-contents-1109"></a><a
name="index-deleting-entire-arrays-1110"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-array-elements_002c-deleting-1111"></a>All
the elements of an array may be deleted with a single statement
-by leaving off the subscript in the <code>delete</code> statement,
-as follows:
-
-<pre class="example"> delete <var>array</var>
-</pre>
- <p>This ability is a <samp><span class="command">gawk</span></samp>
extension; it is not available in
-compatibility mode (see <a href="#Options">Options</a>).
-
- <p>Using this version of the <code>delete</code> statement is about three
times
-more efficient than the equivalent loop that deletes each element one
-at a time.
-
- <p><a name="index-portability_002c-deleting-array-elements-1112"></a><a
name="index-Brennan_002c-Michael-1113"></a>The following statement provides a
portable but nonobvious way to clear
-out an array:<a rel="footnote" href="#fn-29" name="fnd-29"><sup>29</sup></a>
-
-<pre class="example"> split("", array)
-</pre>
- <p><a
name="index-_0040code_007bsplit_007d-function_002c-array-elements_0040comma_007b_007d-deleting-1114"></a>The
<code>split</code> function
-(see <a href="#String-Functions">String Functions</a>)
-clears out the target array first. This call asks it to split
-apart the null string. Because there is no data to split out, the
-function simply clears the array and then returns.
-
- <p><strong>Caution:</strong> Deleting an array does not change its type;
you cannot
-delete an array and then use the array's name as a scalar
-(i.e., a regular variable). For example, the following does not work:
-
-<pre class="example"> a[1] = 3; delete a; a = 3
-</pre>
- <div class="node">
-<p><hr>
-<a name="Numeric-Array-Subscripts"></a>Next: <a rel="next" accesskey="n"
href="#Uninitialized-Subscripts">Uninitialized Subscripts</a>,
-Previous: <a rel="previous" accesskey="p" href="#Delete">Delete</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.7 Using Numbers to Subscript Arrays</h3>
-
-<p><a name="index-numbers_002c-as-array-subscripts-1115"></a><a
name="index-arrays_002c-subscripts-1116"></a><a
name="index-subscripts-in-arrays_002c-numbers-as-1117"></a><a
name="index-_0040code_007bCONVFMT_007d-variable_002c-array-subscripts-and-1118"></a>An
important aspect about arrays to remember is that <em>array subscripts
-are always strings</em>. When a numeric value is used as a subscript,
-it is converted to a string value before being used for subscripting
-(see <a href="#Conversion">Conversion</a>).
-This means that the value of the built-in variable <code>CONVFMT</code> can
-affect how your program accesses elements of an array. For example:
-
-<pre class="example"> xyz = 12.153
- data[xyz] = 1
- CONVFMT = "%2.2f"
- if (xyz in data)
- printf "%s is in data\n", xyz
- else
- printf "%s is not in data\n", xyz
-</pre>
- <p class="noindent">This prints `<samp><span class="samp">12.15 is not in
data</span></samp>'. The first statement gives
-<code>xyz</code> a numeric value. Assigning to
-<code>data[xyz]</code> subscripts <code>data</code> with the string value
<code>"12.153"</code>
-(using the default conversion value of <code>CONVFMT</code>,
<code>"%.6g"</code>).
-Thus, the array element <code>data["12.153"]</code> is assigned the value one.
-The program then changes
-the value of <code>CONVFMT</code>. The test `<samp><span class="samp">(xyz in
data)</span></samp>' generates a new
-string value from <code>xyz</code>—this time
<code>"12.15"</code>—because the value of
-<code>CONVFMT</code> only allows two significant digits. This test fails,
-since <code>"12.15"</code> is a different string from <code>"12.153"</code>.
-
- <p><a name="index-converting_002c-during-subscripting-1119"></a>According
to the rules for conversions
-(see <a href="#Conversion">Conversion</a>), integer
-values are always converted to strings as integers, no matter what the
-value of <code>CONVFMT</code> may happen to be. So the usual case of
-the following works:
-
-<pre class="example"> for (i = 1; i <= maxsub; i++)
- <i>do something with</i> array[i]
-</pre>
- <p>The “integer values always convert to strings as integers”
rule
-has an additional consequence for array indexing.
-Octal and hexadecimal constants
-(see <a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>)
-are converted internally into numbers, and their original form
-is forgotten.
-This means, for example, that
-<code>array[17]</code>,
-<code>array[021]</code>,
-and
-<code>array[0x11]</code>
-all refer to the same element!
-
- <p>As with many things in <samp><span class="command">awk</span></samp>,
the majority of the time
-things work as one would expect them to. But it is useful to have a precise
-knowledge of the actual rules which sometimes can have a subtle
-effect on your programs.
-
-<div class="node">
-<p><hr>
-<a name="Uninitialized-Subscripts"></a>Next: <a rel="next" accesskey="n"
href="#Multi_002ddimensional">Multi-dimensional</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Numeric-Array-Subscripts">Numeric Array Subscripts</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.8 Using Uninitialized Variables as Subscripts</h3>
-
-<p><a
name="index-variables_002c-uninitialized_0040comma_007b_007d-as-array-subscripts-1120"></a><a
name="index-uninitialized-variables_002c-as-array-subscripts-1121"></a><a
name="index-subscripts-in-arrays_002c-uninitialized-variables-as-1122"></a><a
name="index-arrays_002c-subscripts_002c-uninitialized-variables-as-1123"></a>Suppose
it's necessary to write a program
-to print the input data in reverse order.
-A reasonable attempt to do so (with some test
-data) might look like this:
-
-<pre class="example"> $ echo 'line 1
- > line 2
- > line 3' | awk '{ l[lines] = $0; ++lines }
- > END {
- > for (i = lines-1; i >= 0; --i)
- > print l[i]
- > }'
- -| line 3
- -| line 2
-</pre>
- <p>Unfortunately, the very first line of input data did not come out in the
-output!
-
- <p>At first glance, this program should have worked. The variable
<code>lines</code>
-is uninitialized, and uninitialized variables have the numeric value zero.
-So, <samp><span class="command">awk</span></samp> should have printed the
value of <code>l[0]</code>.
-
- <p>The issue here is that subscripts for <samp><span
class="command">awk</span></samp> arrays are <em>always</em>
-strings. Uninitialized variables, when used as strings, have the
-value <code>""</code>, not zero. Thus, `<samp><span class="samp">line
1</span></samp>' ends up stored in
-<code>l[""]</code>.
-The following version of the program works correctly:
-
-<pre class="example"> { l[lines++] = $0 }
- END {
- for (i = lines - 1; i >= 0; --i)
- print l[i]
- }
-</pre>
- <p>Here, the `<samp><span class="samp">++</span></samp>' forces
<code>lines</code> to be numeric, thus making
-the “old value” numeric zero. This is then converted to
<code>"0"</code>
-as the array subscript.
-
- <p><a name="index-null-strings_002c-as-array-subscripts-1124"></a><a
name="index-dark-corner_002c-array-subscripts-1125"></a><a
name="index-lint-checking_002c-array-subscripts-1126"></a>Even though it is
somewhat unusual, the null string
-(<code>""</code>) is a valid array subscript.
-(d.c.)
-<samp><span class="command">gawk</span></samp> warns about the use of the null
string as a subscript
-if <samp><span class="option">--lint</span></samp> is provided
-on the command line (see <a href="#Options">Options</a>).
-
-<div class="node">
-<p><hr>
-<a name="Multi_002ddimensional"></a>Next: <a rel="next" accesskey="n"
href="#Multi_002dscanning">Multi-scanning</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Uninitialized-Subscripts">Uninitialized Subscripts</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.9 Multidimensional Arrays</h3>
-
-<p><a name="index-subscripts-in-arrays_002c-multidimensional-1127"></a><a
name="index-arrays_002c-multidimensional-1128"></a>A multidimensional array is
an array in which an element is identified
-by a sequence of indices instead of a single index. For example, a
-two-dimensional array requires two indices. The usual way (in most
-languages, including <samp><span class="command">awk</span></samp>) to refer
to an element of a
-two-dimensional array named <code>grid</code> is with
-<code>grid[</code><var>x</var><code>,</code><var>y</var><code>]</code>.
-
- <p><a
name="index-_0040code_007bSUBSEP_007d-variable_002c-multidimensional-arrays-1129"></a>Multidimensional
arrays are supported in <samp><span class="command">awk</span></samp> through
-concatenation of indices into one string.
-<samp><span class="command">awk</span></samp> converts the indices into strings
-(see <a href="#Conversion">Conversion</a>) and
-concatenates them together, with a separator between them. This creates
-a single string that describes the values of the separate indices. The
-combined string is used as a single index into an ordinary,
-one-dimensional array. The separator used is the value of the built-in
-variable <code>SUBSEP</code>.
-
- <p>For example, suppose we evaluate the expression `<samp><span
class="samp">foo[5,12] = "value"</span></samp>'
-when the value of <code>SUBSEP</code> is <code>"@"</code>. The numbers 5 and
12 are
-converted to strings and
-concatenated with an `<samp><span class="samp">@</span></samp>' between them,
yielding <code>"address@hidden"</code>; thus,
-the array element <code>foo["address@hidden"]</code> is set to
<code>"value"</code>.
-
- <p>Once the element's value is stored, <samp><span
class="command">awk</span></samp> has no record of whether
-it was stored with a single index or a sequence of indices. The two
-expressions `<samp><span class="samp">foo[5,12]</span></samp>' and
`<samp><span class="samp">foo[5 SUBSEP 12]</span></samp>'<!-- /@w -->
are always
-equivalent.
-
- <p>The default value of <code>SUBSEP</code> is the string
<code>"\034"</code>,
-which contains a nonprinting character that is unlikely to appear in an
-<samp><span class="command">awk</span></samp> program or in most input data.
-The usefulness of choosing an unlikely character comes from the fact
-that index values that contain a string matching <code>SUBSEP</code> can lead
to
-combined strings that are ambiguous. Suppose that <code>SUBSEP</code> is
-<code>"@"</code>; then `<samp><span
class="samp">foo["address@hidden", "c"]</span></samp>'<!-- /@w --> and
`<samp><span class="samp">foo["a", "address@hidden"]</span></samp>'<!--
/@w --> are indistinguishable because both are actually
-stored as `<samp><span class="samp">foo["address@hidden@c"]</span></samp>'.
-
- <p>To test whether a particular index sequence exists in a
-multidimensional array, use the same operator (`<samp><span
class="samp">in</span></samp>') that is
-used for single dimensional arrays. Write the whole sequence of indices
-in parentheses, separated by commas, as the left operand:
-
-<pre class="example"> (<var>subscript1</var>, <var>subscript2</var>, ...)
in <var>array</var>
-</pre>
- <p>The following example treats its input as a two-dimensional array of
-fields; it rotates this array 90 degrees clockwise and prints the
-result. It assumes that all lines have the same number of
-elements:
-
-<pre class="example"> {
- if (max_nf < NF)
- max_nf = NF
- max_nr = NR
- for (x = 1; x <= NF; x++)
- vector[x, NR] = $x
- }
-
- END {
- for (x = 1; x <= max_nf; x++) {
- for (y = max_nr; y >= 1; --y)
- printf("%s ", vector[x, y])
- printf("\n")
- }
- }
-</pre>
- <p class="noindent">When given the input:
-
-<pre class="example"> 1 2 3 4 5 6
- 2 3 4 5 6 1
- 3 4 5 6 1 2
- 4 5 6 1 2 3
-</pre>
- <p class="noindent">the program produces the following output:
-
-<pre class="example"> 4 3 2 1
- 5 4 3 2
- 6 5 4 3
- 1 6 5 4
- 2 1 6 5
- 3 2 1 6
-</pre>
- <div class="node">
-<p><hr>
-<a name="Multi_002dscanning"></a>Next: <a rel="next" accesskey="n"
href="#Array-Sorting">Array Sorting</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Multi_002ddimensional">Multi-dimensional</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.10 Scanning Multidimensional Arrays</h3>
-
-<p>There is no special <code>for</code> statement for scanning a
-“multidimensional” array. There cannot be one, because, in truth,
there
-are no multidimensional arrays or elements—there is only a
-multidimensional <em>way of accessing</em> an array.
-
- <p><a
name="index-subscripts-in-arrays_002c-multidimensional_002c-scanning-1130"></a><a
name="index-arrays_002c-multidimensional_002c-scanning-1131"></a>However, if
your program has an array that is always accessed as
-multidimensional, you can get the effect of scanning it by combining
-the scanning <code>for</code> statement
-(see <a href="#Scanning-an-Array">Scanning an Array</a>) with the
-built-in <code>split</code> function
-(see <a href="#String-Functions">String Functions</a>).
-It works in the following manner:
-
-<pre class="example"> for (combined in array) {
- split(combined, separate, SUBSEP)
- ...
- }
-</pre>
- <p class="noindent">This sets the variable <code>combined</code> to
-each concatenated combined index in the array, and splits it
-into the individual indices by breaking it apart where the value of
-<code>SUBSEP</code> appears. The individual indices then become the elements
of
-the array <code>separate</code>.
-
- <p>Thus, if a value is previously stored in <code>array[1, "foo"]</code>;
then
-an element with index <code>"1\034foo"</code> exists in <code>array</code>.
(Recall
-that the default value of <code>SUBSEP</code> is the character with code 034.)
-Sooner or later, the <code>for</code> statement finds that index and does an
-iteration with the variable <code>combined</code> set to
<code>"1\034foo"</code>.
-Then the <code>split</code> function is called as follows:
-
-<pre class="example"> split("1\034foo", separate, "\034")
-</pre>
- <p class="noindent">The result is to set <code>separate[1]</code> to
<code>"1"</code> and
-<code>separate[2]</code> to <code>"foo"</code>. Presto! The original sequence
of
-separate indices is recovered.
-
-<div class="node">
-<p><hr>
-<a name="Array-Sorting"></a>Previous: <a rel="previous" accesskey="p"
href="#Multi_002dscanning">Multi-scanning</a>,
-Up: <a rel="up" accesskey="u" href="#Arrays">Arrays</a>
-<br>
-</div>
-
-<h3 class="section">7.11 Sorting Array Values and Indices with <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-arrays_002c-sorting-1132"></a><a
name="index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1133"></a><a
name="index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029_002c-arrays_0040comma_007b_007d-sorting-1134"></a><a
name="index-sort-function_002c-arrays_002c-sorting-1135"></a>The order in
which an array is scanned with a `<samp><span class="samp">for (i in
array)</span></samp>'
-loop is essentially arbitrary.
-In most <samp><span class="command">awk</span></samp> implementations, sorting
an array requires
-writing a <code>sort</code> function.
-While this can be educational for exploring different sorting algorithms,
-usually that's not the point of the program.
-<samp><span class="command">gawk</span></samp> provides the built-in
<code>asort</code>
-and <code>asorti</code> functions
-(see <a href="#String-Functions">String Functions</a>)
-for sorting arrays. For example:
-
-<pre class="example"> <var>populate the array</var> data
- n = asort(data)
- for (i = 1; i <= n; i++)
- <var>do something with</var> data[i]
-</pre>
- <p>After the call to <code>asort</code>, the array <code>data</code> is
indexed from 1
-to some number <var>n</var>, the total number of elements in
<code>data</code>.
-(This count is <code>asort</code>'s return value.)
-<code>data[1]</code> <= <code>data[2]</code> <= <code>data[3]</code>,
and so on.
-The comparison of array elements is done
-using <samp><span class="command">gawk</span></samp>'s usual comparison rules
-(see <a href="#Typing-and-Comparison">Typing and Comparison</a>).
-
- <p><a
name="index-side-effects_002c-_0040code_007basort_007d-function-1136"></a>An
important side effect of calling <code>asort</code> is that
-<em>the array's original indices are irrevocably lost</em>.
-As this isn't always desirable, <code>asort</code> accepts a
-second argument:
-
-<pre class="example"> <var>populate the array</var> source
- n = asort(source, dest)
- for (i = 1; i <= n; i++)
- <var>do something with</var> dest[i]
-</pre>
- <p>In this case, <samp><span class="command">gawk</span></samp> copies the
<code>source</code> array into the
-<code>dest</code> array and then sorts <code>dest</code>, destroying its
indices.
-However, the <code>source</code> array is not affected.
-
- <p>Often, what's needed is to sort on the values of the <em>indices</em>
-instead of the values of the elements.
-To do that, starting with <samp><span class="command">gawk</span></samp>
3.1.2, use the
-<code>asorti</code> function. The interface is identical to that of
-<code>asort</code>, except that the index values are used for sorting, and
-become the values of the result array:
-
-<pre class="example"> { source[$0] = some_func($0) }
-
- END {
- n = asorti(source, dest)
- for (i = 1; i <= n; i++) {
- <var>do something with</var> dest[i] <i>Work with
sorted indices directly</i>
- ...
- <var>do something with</var> source[dest[i]] <i>Access
original array via sorted indices</i>
- }
- }
-</pre>
- <p>If your version of <samp><span class="command">gawk</span></samp> is
3.1.0 or 3.1.1, you don't
-have <code>asorti</code>. Instead, use a helper array
-to hold the sorted index values, and then access the original array's
-elements. It works in the following way:
-
-<pre class="example"> <var>populate the array</var> data
- # copy indices
- j = 1
- for (i in data) {
- ind[j] = i # index value becomes element value
- j++
- }
- n = asort(ind) # index values are now sorted
- for (i = 1; i <= n; i++) {
- <var>do something with</var> ind[i] <i>Work with sorted
indices directly</i>
- ...
- <var>do something with</var> data[ind[i]] <i>Access original
array via sorted indices</i>
- }
-</pre>
- <p>Sorting the array by replacing the indices provides maximal flexibility.
-To traverse the elements in decreasing order, use a loop that goes from
-<var>n</var> down to 1, either over the elements or over the indices.
-
- <p><a name="index-reference-counting_002c-sorting-arrays-1137"></a>Copying
array indices and elements isn't expensive in terms of memory.
-Internally, <samp><span class="command">gawk</span></samp> maintains
<dfn>reference counts</dfn> to data.
-For example, when <code>asort</code> copies the first array to the second one,
-there is only one copy of the original array elements' data, even though
-both arrays use the values. Similarly, when copying the indices from
-<code>data</code> to <code>ind</code>, there is only one copy of the actual
index
-strings.
-
-<!-- Document It And Call It A Feature. Sigh. -->
-<p><a
name="index-arrays_002c-sorting_002c-_0040code_007bIGNORECASE_007d-variable-and-1138"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable_002c-array-sorting-and-1139"></a>We
said previously that comparisons are done using <samp><span
class="command">gawk</span></samp>'s
-“usual comparison rules.” Because <code>IGNORECASE</code> affects
-string comparisons, the value of <code>IGNORECASE</code> also
-affects sorting for both <code>asort</code> and <code>asorti</code>.
-Caveat Emptor.
-<!-- ENDOFRANGE arrs -->
-
-<div class="node">
-<p><hr>
-<a name="Functions"></a>Next: <a rel="next" accesskey="n"
href="#Internationalization">Internationalization</a>,
-Previous: <a rel="previous" accesskey="p" href="#Arrays">Arrays</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">8 Functions</h2>
-
-<!-- STARTOFRANGE funcbi -->
-<p><a name="index-functions_002c-built_002din-1140"></a><!-- STARTOFRANGE
bifunc -->
-<a name="index-built_002din-functions-1141"></a>This chapter describes
<samp><span class="command">awk</span></samp>'s built-in functions,
-which fall into three categories: numeric, string, and I/O.
-<samp><span class="command">gawk</span></samp> provides additional groups of
functions
-to work with values that represent time, do
-bit manipulation, and internationalize and localize programs.
-
- <p>Besides the built-in functions, <samp><span
class="command">awk</span></samp> has provisions for
-writing new functions that the rest of a program can use.
-The second half of this chapter describes these
-<dfn>user-defined</dfn> functions.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Built_002din">Built-in</a>:
Summarizes the built-in functions.
-<li><a accesskey="2" href="#User_002ddefined">User-defined</a>:
Describes User-defined functions in detail.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Built_002din"></a>Next: <a rel="next" accesskey="n"
href="#User_002ddefined">User-defined</a>,
-Up: <a rel="up" accesskey="u" href="#Functions">Functions</a>
-<br>
-</div>
-
-<h3 class="section">8.1 Built-in Functions</h3>
-
-<!-- 2e: USE TEXINFO-2 FUNCTION DEFINITION STUFF!!!!!!!!!!!!! -->
-<p><dfn>Built-in</dfn> functions are always available for
-your <samp><span class="command">awk</span></samp> program to call. This
section defines all
-the built-in
-functions in <samp><span class="command">awk</span></samp>; some of these are
mentioned in other sections
-but are summarized here for your convenience.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Calling-Built_002din">Calling Built-in</a>:
How to call built-in functions.
-<li><a accesskey="2" href="#Numeric-Functions">Numeric Functions</a>:
Functions that work with numbers, including
- <code>int</code>, <code>sin</code> and
<code>rand</code>.
-<li><a accesskey="3" href="#String-Functions">String Functions</a>:
Functions for string manipulation, such as
- <code>split</code>, <code>match</code> and
<code>sprintf</code>.
-<li><a accesskey="4" href="#I_002fO-Functions">I/O Functions</a>:
Functions for files and shell commands.
-<li><a accesskey="5" href="#Time-Functions">Time Functions</a>:
Functions for dealing with timestamps.
-<li><a accesskey="6" href="#Bitwise-Functions">Bitwise Functions</a>:
Functions for bitwise operations.
-<li><a accesskey="7" href="#I18N-Functions">I18N Functions</a>:
Functions for string translation.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Calling-Built_002din"></a>Next: <a rel="next" accesskey="n"
href="#Numeric-Functions">Numeric Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.1 Calling Built-in Functions</h4>
-
-<p>To call one of <samp><span class="command">awk</span></samp>'s built-in
functions, write the name of
-the function followed
-by arguments in parentheses. For example, `<samp><span class="samp">atan2(y +
z, 1)</span></samp>'
-is a call to the function <code>atan2</code> and has two arguments.
-
- <p><a
name="index-programming-conventions_002c-functions_002c-calling-1142"></a><a
name="index-whitespace_002c-functions_0040comma_007b_007d-calling-1143"></a>Whitespace
is ignored between the built-in function name and the
-open parenthesis, and it is good practice to avoid using whitespace
-there. User-defined functions do not permit whitespace in this way, and
-it is easier to avoid mistakes by following a simple
-convention that always works—no whitespace after a function name.
-
- <p><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d_002c-fatal-errors_0040comma_007b_007d-function-arguments-1144"></a><a
name="index-_0040command_007bgawk_007d_002c-function-arguments-and-1145"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-function-arguments-_0028_0040command_007bgawk_007d_0029-1146"></a>Each
built-in function accepts a certain number of arguments.
-In some cases, arguments can be omitted. The defaults for omitted
-arguments vary from function to function and are described under the
-individual functions. In some <samp><span class="command">awk</span></samp>
implementations, extra
-arguments given to built-in functions are ignored. However, in <samp><span
class="command">gawk</span></samp>,
-it is a fatal error to give extra arguments to a built-in function.
-
- <p>When a function is called, expressions that create the function's actual
-parameters are evaluated completely before the call is performed.
-For example, in the following code fragment:
-
-<pre class="example"> i = 4
- j = sqrt(i++)
-</pre>
- <p><a name="index-evaluation-order_002c-functions-1147"></a><a
name="index-functions_002c-built_002din_002c-evaluation-order-1148"></a><a
name="index-built_002din-functions_002c-evaluation-order-1149"></a>the variable
<code>i</code> is incremented to the value five before <code>sqrt</code>
-is called with a value of four for its actual parameter.
-The order of evaluation of the expressions used for the function's
-parameters is undefined. Thus, avoid writing programs that
-assume that parameters are evaluated from left to right or from
-right to left. For example:
-
-<pre class="example"> i = 5
- j = atan2(i++, i *= 2)
-</pre>
- <p>If the order of evaluation is left to right, then <code>i</code> first
becomes
-6, and then 12, and <code>atan2</code> is called with the two arguments 6
-and 12. But if the order of evaluation is right to left, <code>i</code>
-first becomes 10, then 11, and <code>atan2</code> is called with the
-two arguments 11 and 10.
-
-<div class="node">
-<p><hr>
-<a name="Numeric-Functions"></a>Next: <a rel="next" accesskey="n"
href="#String-Functions">String Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Calling-Built_002din">Calling Built-in</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.2 Numeric Functions</h4>
-
-<p>The following list describes all of
-the built-in functions that work with numbers.
-Optional parameters are enclosed in square brackets ([ ]):<!-- /@w
-->
-
- <dl>
-<dt><code>int(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bint_007d-function-1150"></a>This returns the nearest
integer to <var>x</var>, located between <var>x</var> and zero and
-truncated toward zero.
-
- <p>For example, <code>int(3)</code> is 3, <code>int(3.9)</code> is 3,
<code>int(-3.9)</code>
-is −3, and <code>int(-3)</code> is −3 as well.
-
- <br><dt><code>sqrt(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bsqrt_007d-function-1151"></a>This returns the
positive square root of <var>x</var>.
-<samp><span class="command">gawk</span></samp> reports an error
-if <var>x</var> is negative. Thus, <code>sqrt(4)</code> is 2.
-
- <br><dt><code>exp(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bexp_007d-function-1152"></a>This returns the
exponential of <var>x</var> (<code>e ^ </code><var>x</var>) or reports
-an error if <var>x</var> is out of range. The range of values <var>x</var>
can have
-depends on your machine's floating-point representation.
-
- <br><dt><code>log(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007blog_007d-function-1153"></a>This returns the natural
logarithm of <var>x</var>, if <var>x</var> is positive;
-otherwise, it reports an error.
-
- <br><dt><code>sin(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bsin_007d-function-1154"></a>This returns the sine of
<var>x</var>, with <var>x</var> in radians.
-
- <br><dt><code>cos(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bcos_007d-function-1155"></a>This returns the cosine
of <var>x</var>, with <var>x</var> in radians.
-
- <br><dt><code>atan2(</code><var>y</var><code>,
</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007batan2_007d-function-1156"></a>This returns the
arctangent of <var>y</var><code> / </code><var>x</var> in radians.
-
- <br><dt><code>rand()</code><dd><a
name="index-_0040code_007brand_007d-function-1157"></a><a
name="index-random-numbers_002c-_0040code_007brand_007d_002f_0040code_007bsrand_007d-functions-1158"></a>This
returns a random number. The values of <code>rand</code> are
-uniformly distributed between zero and one.
-The value could be zero but is never one.<a rel="footnote" href="#fn-30"
name="fnd-30"><sup>30</sup></a>
-
- <p>Often random integers are needed instead. Following is a user-defined
function
-that can be used to obtain a random non-negative integer less than
<var>n</var>:
-
- <pre class="example"> function randint(n) {
- return int(n * rand())
- }
- </pre>
- <p class="noindent">The multiplication produces a random number greater
than zero and less
-than <code>n</code>. Using <code>int</code>, this result is made into
-an integer between zero and <code>n</code> − 1, inclusive.
-
- <p>The following example uses a similar function to produce random
integers
-between one and <var>n</var>. This program prints a new random number for
-each input record:
-
- <pre class="example"> # Function to roll a simulated die.
- function roll(n) { return 1 + int(rand() * n) }
-
- # Roll 3 six-sided dice and
- # print total number of points.
- {
- printf("%d points\n",
- roll(6)+roll(6)+roll(6))
- }
- </pre>
- <p><a name="index-numbers_002c-random-1159"></a><a
name="index-random-numbers_002c-seed-of-1160"></a><!-- MAWK uses a different
seed each time. -->
-<strong>Caution:</strong> In most <samp><span
class="command">awk</span></samp> implementations, including <samp><span
class="command">gawk</span></samp>,
-<code>rand</code> starts generating numbers from the same
-starting number, or <dfn>seed</dfn>, each time you run <samp><span
class="command">awk</span></samp>. Thus,
-a program generates the same results each time you run it.
-The numbers are random within one <samp><span
class="command">awk</span></samp> run but predictable
-from run to run. This is convenient for debugging, but if you want
-a program to do different things each time it is used, you must change
-the seed to a value that is different in each run. To do this,
-use <code>srand</code>.
-
- <br><dt><code>srand(</code><span class="roman">[</span><var>x</var><span
class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsrand_007d-function-1161"></a>The function
<code>srand</code> sets the starting point, or seed,
-for generating random numbers to the value <var>x</var>.
-
- <p>Each seed value leads to a particular sequence of random
-numbers.<a rel="footnote" href="#fn-31" name="fnd-31"><sup>31</sup></a>
-Thus, if the seed is set to the same value a second time,
-the same sequence of random numbers is produced again.
-
- <p>Different <samp><span class="command">awk</span></samp>
implementations use different random-number
-generators internally. Don't expect the same <samp><span
class="command">awk</span></samp> program
-to produce the same series of random numbers when executed by
-different versions of <samp><span class="command">awk</span></samp>.
-
- <p>If the argument <var>x</var> is omitted, as in `<samp><span
class="samp">srand()</span></samp>', then the current
-date and time of day are used for a seed. This is the way to get random
-numbers that are truly unpredictable.
-
- <p>The return value of <code>srand</code> is the previous seed. This
makes it
-easy to keep track of the seeds in case you need to consistently reproduce
-sequences of random numbers.
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="String-Functions"></a>Next: <a rel="next" accesskey="n"
href="#I_002fO-Functions">I/O Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Numeric-Functions">Numeric Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.3 String-Manipulation Functions</h4>
-
-<p>The functions in this section look at or change the text of one or more
-strings.
-Optional parameters are enclosed in square brackets ([ ]).<!-- /@w
-->
-Those functions that are
-specific to <samp><span class="command">gawk</span></samp> are marked with a
pound sign (`<samp><span class="samp">#</span></samp>'):<!-- /@w -->
-
-<ul class="menu">
-<li><a accesskey="1" href="#Gory-Details">Gory Details</a>:
More than you want to know about `<samp><span class="samp">\</span></samp>' and
- `<samp><span class="samp">&</span></samp>'
with <code>sub</code>, <code>gsub</code>, and
- <code>gensub</code>.
-</ul>
-
- <dl>
-<dt><code>asort(</code><var>source</var> <span class="roman">[</span><code>,
</code><var>dest</var><span class="roman">]</span><code>) #</code><dd><a
name="index-arrays_002c-elements_002c-retrieving-number-of-1162"></a><a
name="index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1163"></a><code>asort</code>
is a <samp><span class="command">gawk</span></samp>-specific extension,
returning the number of
-elements in the array <var>source</var>. The contents of <var>source</var> are
-sorted using <samp><span class="command">gawk</span></samp>'s normal rules for
comparing values
-(in particular, <code>IGNORECASE</code> affects the sorting)
-and the indices
-of the sorted values of <var>source</var> are replaced with sequential
-integers starting with one. If the optional array <var>dest</var> is specified,
-then <var>source</var> is duplicated into <var>dest</var>. <var>dest</var> is
then
-sorted, leaving the indices of <var>source</var> unchanged.
-For example, if the contents of <code>a</code> are as follows:
-
- <pre class="example"> a["last"] = "de"
- a["first"] = "sac"
- a["middle"] = "cul"
- </pre>
- <p class="noindent">A call to <code>asort</code>:
-
- <pre class="example"> asort(a)
- </pre>
- <p class="noindent">results in the following contents of <code>a</code>:
-
- <pre class="example"> a[1] = "cul"
- a[2] = "de"
- a[3] = "sac"
- </pre>
- <p>The <code>asort</code> function is described in more detail in
-<a href="#Array-Sorting">Array Sorting</a>.
-<code>asort</code> is a <samp><span class="command">gawk</span></samp>
extension; it is not available
-in compatibility mode (see <a href="#Options">Options</a>).
-
- <br><dt><code>asorti(</code><var>source</var> <span
class="roman">[</span><code>, </code><var>dest</var><span
class="roman">]</span><code>) #</code><dd><a
name="index-_0040code_007basorti_007d-function-_0028_0040command_007bgawk_007d_0029-1164"></a><code>asorti</code>
is a <samp><span class="command">gawk</span></samp>-specific extension,
returning the number of
-elements in the array <var>source</var>.
-It works similarly to <code>asort</code>, however, the <em>indices</em>
-are sorted, instead of the values. As array indices are always strings,
-the comparison performed is always a string comparison. (Here too,
-<code>IGNORECASE</code> affects the sorting.)
-
- <p>The <code>asorti</code> function is described in more detail in
-<a href="#Array-Sorting">Array Sorting</a>.
-It was added in <samp><span class="command">gawk</span></samp> 3.1.2.
-<code>asorti</code> is a <samp><span class="command">gawk</span></samp>
extension; it is not available
-in compatibility mode (see <a href="#Options">Options</a>).
-
- <br><dt><code>index(</code><var>in</var><code>,
</code><var>find</var><code>)</code><dd><a
name="index-_0040code_007bindex_007d-function-1165"></a><a
name="index-searching-1166"></a>This searches the string <var>in</var> for the
first occurrence of the string
-<var>find</var>, and returns the position in characters where that occurrence
-begins in the string <var>in</var>. Consider the following example:
-
- <pre class="example"> $ awk 'BEGIN { print index("peanut", "an")
}'
- -| 3
- </pre>
- <p class="noindent">If <var>find</var> is not found, <code>index</code>
returns zero.
-(Remember that string indices in <samp><span class="command">awk</span></samp>
start at one.)
-
- <br><dt><code>length(</code><span
class="roman">[</span><var>string</var><span
class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007blength_007d-function-1167"></a>This returns the
number of characters in <var>string</var>. If
-<var>string</var> is a number, the length of the digit string representing
-that number is returned. For example, <code>length("abcde")</code> is 5. By
-contrast, <code>length(15 * 35)</code> works out to 3. In this example, 15 *
35 =
-525, and 525 is then converted to the string <code>"525"</code>, which has
-three characters.
-
- <p>If no argument is supplied, <code>length</code> returns the length of
<code>$0</code>.
-
- <!-- @cindex historical features -->
-<p><a
name="index-portability_002c-_0040code_007blength_007d-function-1168"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007blength_007d-1169"></a><blockquote>
-<b>NOTE:</b> In older versions of <samp><span
class="command">awk</span></samp>, the <code>length</code> function could
-be called
-without any parentheses. Doing so is marked as “deprecated” in the
-POSIX standard. This means that while a program can do this,
-it is a feature that can eventually be removed from a future
-version of the standard. Therefore, for programs to be maximally portable,
-always supply the parentheses.
-</blockquote>
-
- <br><dt><code>match(</code><var>string</var><code>,
</code><var>regexp</var> <span class="roman">[</span><code>,
</code><var>array</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bmatch_007d-function-1170"></a>The <code>match</code>
function searches <var>string</var> for the
-longest, leftmost substring matched by the regular expression,
-<var>regexp</var>. It returns the character position, or <dfn>index</dfn>,
-at which that substring begins (one, if it starts at the beginning of
-<var>string</var>). If no match is found, it returns zero.
-
- <p>The <var>regexp</var> argument may be either a regexp constant
-(`<samp><span class="samp">/.../</span></samp>') or a string constant
(<var>"<small class="dots">...</small>"</var>).
-In the latter case, the string is treated as a regexp to be matched.
-<a href="#Computed-Regexps">Computed Regexps</a>, for a
-discussion of the difference between the two forms, and the
-implications for writing your program correctly.
-
- <p>The order of the first two arguments is backwards from most other
string
-functions that work with regular expressions, such as
-<code>sub</code> and <code>gsub</code>. It might help to remember that
-for <code>match</code>, the order is the same as for the `<samp><span
class="samp">~</span></samp>' operator:
-`<samp><var>string</var><span class="samp"> ~ </span><var>regexp</var></samp>'.
-
- <p><a
name="index-_0040code_007bRSTART_007d-variable_002c-_0040code_007bmatch_007d-function-and-1171"></a><a
name="index-_0040code_007bRLENGTH_007d-variable_002c-_0040code_007bmatch_007d-function-and-1172"></a><a
name="index-_0040code_007bmatch_007d-function_002c-_0040code_007bRSTART_007d_002f_0040code_007bRLENGTH_007d-variables-1173"></a>The
<code>match</code> function sets the built-in variable <code>RSTART</code> to
-the index. It also sets the built-in variable <code>RLENGTH</code> to the
-length in characters of the matched substring. If no match is found,
-<code>RSTART</code> is set to zero, and <code>RLENGTH</code> to −1.
-
- <p>For example:
-
- <pre class="example"> <!-- file eg/misc/findpat.awk -->
- {
- if ($1 == "FIND")
- regex = $2
- else {
- where = match($0, regex)
- if (where != 0)
- print "Match of", regex, "found at",
- where, "in", $0
- }
- }
- <!-- endfile -->
- </pre>
- <p class="noindent">This program looks for lines that match the regular
expression stored in
-the variable <code>regex</code>. This regular expression can be changed. If
the
-first word on a line is `<samp><span class="samp">FIND</span></samp>',
<code>regex</code> is changed to be the
-second word on that line. Therefore, if given:
-
- <pre class="example"> <!-- file eg/misc/findpat.data -->
- FIND ru+n
- My program runs
- but not very quickly
- FIND Melvin
- JF+KM
- This line is property of Reality Engineering Co.
- Melvin was here.
- <!-- endfile -->
- </pre>
- <p class="noindent"><samp><span class="command">awk</span></samp> prints:
-
- <pre class="example"> Match of ru+n found at 12 in My program
runs
- Match of Melvin found at 1 in Melvin was here.
- </pre>
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bmatch_007d-function-1174"></a>If
<var>array</var> is present, it is cleared, and then the 0th element
-of <var>array</var> is set to the entire portion of <var>string</var>
-matched by <var>regexp</var>. If <var>regexp</var> contains parentheses,
-the integer-indexed elements of <var>array</var> are set to contain the
-portion of <var>string</var> matching the corresponding parenthesized
-subexpression.
-For example:
-
- <pre class="example"> $ echo foooobazbarrrrr |
- > gawk '{ match($0, /(fo+).+(bar*)/, arr)
- > print arr[1], arr[2] }'
- -| foooo barrrrr
- </pre>
- <p>In addition,
-beginning with <samp><span class="command">gawk</span></samp> 3.1.2,
-multidimensional subscripts are available providing
-the start index and length of each matched subexpression:
-
- <pre class="example"> $ echo foooobazbarrrrr |
- > gawk '{ match($0, /(fo+).+(bar*)/, arr)
- > print arr[1], arr[2]
- > print arr[1, "start"], arr[1, "length"]
- > print arr[2, "start"], arr[2, "length"]
- > }'
- -| foooo barrrrr
- -| 1 5
- -| 9 7
- </pre>
- <p>There may not be subscripts for the start and index for every
parenthesized
-subexpressions, since they may not all have matched text; thus they
-should be tested for with the <code>in</code> operator
-(see <a href="#Reference-to-Elements">Reference to Elements</a>).
-
- <p><a
name="index-troubleshooting_002c-_0040code_007bmatch_007d-function-1175"></a>The
<var>array</var> argument to <code>match</code> is a
-<samp><span class="command">gawk</span></samp> extension. In compatibility
mode
-(see <a href="#Options">Options</a>),
-using a third argument is a fatal error.
-
- <br><dt><code>split(</code><var>string</var><code>,
</code><var>array</var> <span class="roman">[</span><code>,
</code><var>fieldsep</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsplit_007d-function-1176"></a>This function divides
<var>string</var> into pieces separated by <var>fieldsep</var>
-and stores the pieces in <var>array</var>. The first piece is stored in
-<var>array</var><code>[1]</code>, the second piece in
<var>array</var><code>[2]</code>, and so
-forth. The string value of the third argument, <var>fieldsep</var>, is
-a regexp describing where to split <var>string</var> (much as <code>FS</code>
can
-be a regexp describing where to split input records). If
-<var>fieldsep</var> is omitted, the value of <code>FS</code> is used.
-<code>split</code> returns the number of elements created.
-
- <p>The <code>split</code> function splits strings into pieces in a
-manner similar to the way input lines are split into fields. For example:
-
- <pre class="example"> split("cul-de-sac", a, "-")
- </pre>
- <p class="noindent"><a
name="index-strings_002c-splitting-1177"></a>splits the string `<samp><span
class="samp">cul-de-sac</span></samp>' into three fields using `<samp><span
class="samp">-</span></samp>' as the
-separator. It sets the contents of the array <code>a</code> as follows:
-
- <pre class="example"> a[1] = "cul"
- a[2] = "de"
- a[3] = "sac"
- </pre>
- <p class="noindent">The value returned by this call to <code>split</code>
is three.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bsplit_007d-function-1178"></a>As
with input field-splitting, when the value of <var>fieldsep</var> is
-<code>" "</code><!-- /@w -->, leading and trailing whitespace is ignored,
and the elements
-are separated by runs of whitespace.
-Also as with input field-splitting, if <var>fieldsep</var> is the null string,
each
-individual character in the string is split into its own array element.
-(This is a <samp><span class="command">gawk</span></samp>-specific extension.)
-
- <p>Note, however, that <code>RS</code> has no effect on the way
<code>split</code>
-works. Even though `<samp><span class="samp">RS = ""</span></samp>' causes
newline to also be an input
-field separator, this does not affect how <code>split</code> splits strings.
-
- <p><a
name="index-dark-corner_002c-_0040code_007bsplit_007d-function-1179"></a>Modern
implementations of <samp><span class="command">awk</span></samp>, including
<samp><span class="command">gawk</span></samp>, allow
-the third argument to be a regexp constant (<code>/abc/</code>) as well as a
-string.
-(d.c.)
-The POSIX standard allows this as well.
-<a href="#Computed-Regexps">Computed Regexps</a>, for a
-discussion of the difference between using a string constant or a regexp
constant,
-and the implications for writing your program correctly.
-
- <p>Before splitting the string, <code>split</code> deletes any previously
existing
-elements in the array <var>array</var>.
-
- <p>If <var>string</var> is null, the array has no elements. (So this is a
portable
-way to delete an entire array with one statement.
-See <a href="#Delete">Delete</a>.)
-
- <p>If <var>string</var> does not match <var>fieldsep</var> at all (but is
not null),
-<var>array</var> has one element only. The value of that element is the
original
-<var>string</var>.
-
- <br><dt><code>sprintf(</code><var>format</var><code>,
</code><var>expression1</var><code>, ...)</code><dd><a
name="index-_0040code_007bsprintf_007d-function-1180"></a>This returns (without
printing) the string that <code>printf</code> would
-have printed out with the same arguments
-(see <a href="#Printf">Printf</a>).
-For example:
-
- <pre class="example"> pival = sprintf("pi = %.2f (approx.)",
22/7)
- </pre>
- <p class="noindent">assigns the string
<code>"pi = 3.14 (approx.)"</code><!-- /@w --> to the variable
<code>pival</code>.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1181"></a><a
name="index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1182"></a><br><dt><code>strtonum(</code><var>str</var><code>)
#</code><dd>Examines <var>str</var> and returns its numeric value. If
<var>str</var>
-begins with a leading `<samp><span class="samp">0</span></samp>',
<code>strtonum</code> assumes that <var>str</var>
-is an octal number. If <var>str</var> begins with a leading `<samp><span
class="samp">0x</span></samp>' or
-`<samp><span class="samp">0X</span></samp>', <code>strtonum</code> assumes
that <var>str</var> is a hexadecimal number.
-For example:
-
- <pre class="example"> $ echo 0x11 |
- > gawk '{ printf "%d\n", strtonum($1) }'
- -| 17
- </pre>
- <p>Using the <code>strtonum</code> function is <em>not</em> the same as
adding zero
-to a string value; the automatic coercion of strings to numbers
-works only for decimal data, not for octal or hexadecimal.<a rel="footnote"
href="#fn-32" name="fnd-32"><sup>32</sup></a>
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1183"></a><code>strtonum</code>
is a <samp><span class="command">gawk</span></samp> extension; it is not
available
-in compatibility mode (see <a href="#Options">Options</a>).
-
- <br><dt><code>sub(</code><var>regexp</var><code>,
</code><var>replacement</var> <span class="roman">[</span><code>,
</code><var>target</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsub_007d-function-1184"></a>The <code>sub</code>
function alters the value of <var>target</var>.
-It searches this value, which is treated as a string, for the
-leftmost, longest substring matched by the regular expression
<var>regexp</var>.
-Then the entire string is
-changed by replacing the matched text with <var>replacement</var>.
-The modified string becomes the new value of <var>target</var>.
-
- <p>The <var>regexp</var> argument may be either a regexp constant
-(`<samp><span class="samp">/.../</span></samp>') or a string constant
(<var>"<small class="dots">...</small>"</var>).
-In the latter case, the string is treated as a regexp to be matched.
-<a href="#Computed-Regexps">Computed Regexps</a>, for a
-discussion of the difference between the two forms, and the
-implications for writing your program correctly.
-
- <p>This function is peculiar because <var>target</var> is not simply
-used to compute a value, and not just any expression will do—it
-must be a variable, field, or array element so that <code>sub</code> can
-store a modified value there. If this argument is omitted, then the
-default is to use and alter <code>$0</code>.<a rel="footnote" href="#fn-33"
name="fnd-33"><sup>33</sup></a>
-For example:
-
- <pre class="example"> str = "water, water, everywhere"
- sub(/at/, "ith", str)
- </pre>
- <p class="noindent">sets <code>str</code> to
<code>"wither, water, everywhere"</code><!-- /@w -->, by replacing the
-leftmost longest occurrence of `<samp><span class="samp">at</span></samp>'
with `<samp><span class="samp">ith</span></samp>'.
-
- <p>The <code>sub</code> function returns the number of substitutions made
(either
-one or zero).
-
- <p>If the special character `<samp><span
class="samp">&</span></samp>' appears in <var>replacement</var>, it
-stands for the precise substring that was matched by <var>regexp</var>. (If
-the regexp can match more than one string, then this precise substring
-may vary.) For example:
-
- <pre class="example"> { sub(/candidate/, "& and his wife");
print }
- </pre>
- <p class="noindent">changes the first occurrence of `<samp><span
class="samp">candidate</span></samp>' to `<samp><span class="samp">candidate
-and his wife</span></samp>' on each input line.
-Here is another example:
-
- <pre class="example"> $ awk 'BEGIN {
- > str = "daabaaa"
- > sub(/a+/, "C&C", str)
- > print str
- > }'
- -| dCaaCbaaa
- </pre>
- <p class="noindent">This shows how `<samp><span
class="samp">&</span></samp>' can represent a nonconstant string and also
-illustrates the “leftmost, longest” rule in regexp matching
-(see <a href="#Leftmost-Longest">Leftmost Longest</a>).
-
- <p>The effect of this special character (`<samp><span
class="samp">&</span></samp>') can be turned off by putting a
-backslash before it in the string. As usual, to insert one backslash in
-the string, you must write two backslashes. Therefore, write `<samp><span
class="samp">\\&</span></samp>'
-in a string constant to include a literal `<samp><span
class="samp">&</span></samp>' in the replacement.
-For example, the following shows how to replace the first `<samp><span
class="samp">|</span></samp>' on each line with
-an `<samp><span class="samp">&</span></samp>':
-
- <pre class="example"> { sub(/\|/, "\\&"); print }
- </pre>
- <p><a
name="index-_0040code_007bsub_007d-function_002c-arguments-of-1185"></a><a
name="index-_0040code_007bgsub_007d-function_002c-arguments-of-1186"></a>As
mentioned, the third argument to <code>sub</code> must
-be a variable, field or array reference.
-Some versions of <samp><span class="command">awk</span></samp> allow the third
argument to
-be an expression that is not an lvalue. In such a case, <code>sub</code>
-still searches for the pattern and returns zero or one, but the result of
-the substitution (if any) is thrown away because there is no place
-to put it. Such versions of <samp><span class="command">awk</span></samp>
accept expressions
-such as the following:
-
- <pre class="example"> sub(/USA/, "United States", "the USA and
Canada")
- </pre>
- <p class="noindent"><a
name="index-troubleshooting_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-functions-1187"></a>For
historical compatibility, <samp><span class="command">gawk</span></samp>
accepts erroneous code,
-such as in the previous example. However, using any other nonchangeable
-object as the third parameter causes a fatal error and your program
-will not run.
-
- <p>Finally, if the <var>regexp</var> is not a regexp constant, it is
converted into a
-string, and then the value of that string is treated as the regexp to match.
-
- <br><dt><code>gsub(</code><var>regexp</var><code>,
</code><var>replacement</var> <span class="roman">[</span><code>,
</code><var>target</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bgsub_007d-function-1188"></a>This is similar to the
<code>sub</code> function, except <code>gsub</code> replaces
-<em>all</em> of the longest, leftmost, <em>nonoverlapping</em> matching
-substrings it can find. The `<samp><span class="samp">g</span></samp>' in
<code>gsub</code> stands for
-“global,” which means replace everywhere. For example:
-
- <pre class="example"> { gsub(/Britain/, "United Kingdom"); print
}
- </pre>
- <p class="noindent">replaces all occurrences of the string `<samp><span
class="samp">Britain</span></samp>' with `<samp><span class="samp">United
-Kingdom</span></samp>' for all input records.
-
- <p>The <code>gsub</code> function returns the number of substitutions
made. If
-the variable to search and alter (<var>target</var>) is
-omitted, then the entire input record (<code>$0</code>) is used.
-As in <code>sub</code>, the characters `<samp><span
class="samp">&</span></samp>' and `<samp><span
class="samp">\</span></samp>' are special,
-and the third argument must be assignable.
-
- <br><dt><code>gensub(</code><var>regexp</var><code>,
</code><var>replacement</var><code>, </code><var>how</var> <span
class="roman">[</span><code>, </code><var>target</var><span
class="roman">]</span><code>) #</code><dd><a
name="index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-1189"></a><code>gensub</code>
is a general substitution function. Like <code>sub</code> and
-<code>gsub</code>, it searches the target string <var>target</var> for matches
of
-the regular expression <var>regexp</var>. Unlike <code>sub</code> and
<code>gsub</code>,
-the modified string is returned as the result of the function and the
-original target string is <em>not</em> changed. If <var>how</var> is a string
-beginning with `<samp><span class="samp">g</span></samp>' or `<samp><span
class="samp">G</span></samp>', then it replaces all matches of
-<var>regexp</var> with <var>replacement</var>. Otherwise, <var>how</var> is
treated
-as a number that indicates which match of <var>regexp</var> to replace. If
-no <var>target</var> is supplied, <code>$0</code> is used.
-
- <p><code>gensub</code> provides an additional feature that is not
available
-in <code>sub</code> or <code>gsub</code>: the ability to specify components of
a
-regexp in the replacement text. This is done by using parentheses in
-the regexp to mark the components and then specifying `<samp><span
class="samp">\</span><var>N</var></samp>'
-in the replacement text, where <var>N</var> is a digit from 1 to 9.
-For example:
-
- <pre class="example"> $ gawk '
- > BEGIN {
- > a = "abc def"
- > b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a)
- > print b
- > }'
- -| def abc
- </pre>
- <p class="noindent">As with <code>sub</code>, you must type two
backslashes in order
-to get one into the string.
-In the replacement text, the sequence `<samp><span
class="samp">\0</span></samp>' represents the entire
-matched text, as does the character `<samp><span
class="samp">&</span></samp>'.
-
- <p>The following example shows how you can use the third argument to
control
-which match of the regexp should be changed:
-
- <pre class="example"> $ echo a b c a b c |
- > gawk '{ print gensub(/a/, "AA", 2) }'
- -| a b c AA b c
- </pre>
- <p>In this case, <code>$0</code> is used as the default target string.
-<code>gensub</code> returns the new string as its result, which is
-passed directly to <code>print</code> for printing.
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p>If the <var>how</var> argument is a string that does not begin with
`<samp><span class="samp">g</span></samp>' or
-`<samp><span class="samp">G</span></samp>', or if it is a number that is less
than or equal to zero, only one
-substitution is performed. If <var>how</var> is zero, <samp><span
class="command">gawk</span></samp> issues
-a warning message.
-
- <p>If <var>regexp</var> does not match <var>target</var>,
<code>gensub</code>'s return value
-is the original unchanged value of <var>target</var>.
-
- <p><code>gensub</code> is a <samp><span
class="command">gawk</span></samp> extension; it is not available
-in compatibility mode (see <a href="#Options">Options</a>).
-
- <br><dt><code>substr(</code><var>string</var><code>,
</code><var>start</var> <span class="roman">[</span><code>,
</code><var>length</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsubstr_007d-function-1190"></a>This returns a
<var>length</var>-character-long substring of <var>string</var>,
-starting at character number <var>start</var>. The first character of a
-string is character number one.<a rel="footnote" href="#fn-34"
name="fnd-34"><sup>34</sup></a>
-For example, <code>substr("washington", 5, 3)</code> returns
<code>"ing"</code>.
-
- <p>If <var>length</var> is not present, this function returns the whole
suffix of
-<var>string</var> that begins at character number <var>start</var>. For
example,
-<code>substr("washington", 5)</code> returns <code>"ington"</code>. The whole
-suffix is also returned
-if <var>length</var> is greater than the number of characters remaining
-in the string, counting from character <var>start</var>.
-
- <p>If <var>start</var> is less than one, <code>substr</code> treats it as
-if it was one. (POSIX doesn't specify what to do in this case:
-Unix <samp><span class="command">awk</span></samp> acts this way, and
therefore <samp><span class="command">gawk</span></samp>
-does too.)
-If <var>start</var> is greater than the number of characters
-in the string, <code>substr</code> returns the null string.
-Similarly, if <var>length</var> is present but less than or equal to zero,
-the null string is returned.
-
- <p><a
name="index-troubleshooting_002c-_0040code_007bsubstr_007d-function-1191"></a>The
string returned by <code>substr</code> <em>cannot</em> be
-assigned. Thus, it is a mistake to attempt to change a portion of
-a string, as shown in the following example:
-
- <pre class="example"> string = "abcdef"
- # try to get "abCDEf", won't work
- substr(string, 3, 3) = "CDE"
- </pre>
- <p class="noindent">It is also a mistake to use <code>substr</code> as
the third argument
-of <code>sub</code> or <code>gsub</code>:
-
- <pre class="example"> gsub(/xyz/, "pdq", substr($0, 5, 20)) #
WRONG
- </pre>
- <p><a
name="index-portability_002c-_0040code_007bsubstr_007d-function-1192"></a>(Some
commercial versions of <samp><span class="command">awk</span></samp> do in fact
let you use
-<code>substr</code> this way, but doing so is not portable.)
-
- <p>If you need to replace bits and pieces of a string, combine
<code>substr</code>
-with string concatenation, in the following manner:
-
- <pre class="example"> string = "abcdef"
- ...
- string = substr(string, 1, 2) "CDE" substr(string, 6)
- </pre>
- <p><a name="index-case-sensitivity_002c-converting-case-1193"></a><a
name="index-converting_002c-case-1194"></a><br><dt><code>tolower(</code><var>string</var><code>)</code><dd><a
name="index-_0040code_007btolower_007d-function-1195"></a>This returns a copy
of <var>string</var>, with each uppercase character
-in the string replaced with its corresponding lowercase character.
-Nonalphabetic characters are left unchanged. For example,
-<code>tolower("MiXeD cAsE 123")</code> returns <code>"mixed case 123"</code>.
-
- <br><dt><code>toupper(</code><var>string</var><code>)</code><dd><a
name="index-_0040code_007btoupper_007d-function-1196"></a>This returns a copy
of <var>string</var>, with each lowercase character
-in the string replaced with its corresponding uppercase character.
-Nonalphabetic characters are left unchanged. For example,
-<code>toupper("MiXeD cAsE 123")</code> returns <code>"MIXED CASE 123"</code>.
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="Gory-Details"></a>Up: <a rel="up" accesskey="u"
href="#String-Functions">String Functions</a>
-<br>
-</div>
-
-<h5 class="subsubsection">8.1.3.1 More About `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' with <code>sub</code>, <code>gsub</code>, and
<code>gensub</code></h5>
-
-<p><a
name="index-escape-processing_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-1197"></a><a
name="index-_0040code_007bsub_007d-function_002c-escape-processing-1198"></a><a
name="index-_0040code_007bgsub_007d-function_002c-escape-processing-1199"></a><a
name="index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029_002c-escape-processing-1200"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1201"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1202"></a><a
name="index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1203"></a><a
name="index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1204"></a>When
using <code>sub</code>, <code>gsub</code>, or <code>gensub</code>, and trying
to get literal
-backslashes and ampersands into the replacement text, you need to remember
-that there are several levels of <dfn>escape processing</dfn> going on.
-
- <p>First, there is the <dfn>lexical</dfn> level, which is when <samp><span
class="command">awk</span></samp> reads
-your program
-and builds an internal copy of it that can be executed.
-Then there is the runtime level, which is when <samp><span
class="command">awk</span></samp> actually scans the
-replacement string to determine what to generate.
-
- <p>At both levels, <samp><span class="command">awk</span></samp> looks for
a defined set of characters that
-can come after a backslash. At the lexical level, it looks for the
-escape sequences listed in <a href="#Escape-Sequences">Escape Sequences</a>.
-Thus, for every `<samp><span class="samp">\</span></samp>' that <samp><span
class="command">awk</span></samp> processes at the runtime
-level, type two backslashes at the lexical level.
-When a character that is not valid for an escape sequence follows the
-`<samp><span class="samp">\</span></samp>', Unix <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp> both simply remove the initial
-`<samp><span class="samp">\</span></samp>' and put the next character into the
string. Thus, for
-example, <code>"a\qb"</code> is treated as <code>"aqb"</code>.
-
- <p>At the runtime level, the various functions handle sequences of
-`<samp><span class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' differently. The situation is (sadly)
somewhat complex.
-Historically, the <code>sub</code> and <code>gsub</code> functions treated the
two
-character sequence `<samp><span class="samp">\&</span></samp>' specially;
this sequence was replaced in
-the generated text with a single `<samp><span
class="samp">&</span></samp>'. Any other `<samp><span
class="samp">\</span></samp>' within
-the <var>replacement</var> string that did not precede an `<samp><span
class="samp">&</span></samp>' was passed
-through unchanged. This is illustrated in <a
href="#table_002dsub_002descapes">table-sub-escapes</a>.
-
-<!-- Thank to Karl Berry for help with the TeX stuff. -->
-<div class="float">
-<a name="table_002dsub_002descapes"></a>
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>\&</code> <code>&</code> the
matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\\&</span></samp>'
- <code>\\q</code> <code>\q</code> a literal
`<samp><span class="samp">\q</span></samp>'
-</pre>
- <p><strong class="float-caption">Table 8.1: Historical Escape Sequence
Processing for sub and gsub</strong></p></div>
-
-<p class="noindent">This table shows both the lexical-level processing, where
-an odd number of backslashes becomes an even number at the runtime level,
-as well as the runtime processing done by <code>sub</code>.
-(For the sake of simplicity, the rest of the following tables only show the
-case of even numbers of backslashes entered at the lexical level.)
-
- <p>The problem with the historical approach is that there is no way to get
-a literal `<samp><span class="samp">\</span></samp>' followed by the matched
text.
-
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-1205"></a>The
1992 POSIX standard attempted to fix this problem. That standard
-says that <code>sub</code> and <code>gsub</code> look for either a
`<samp><span class="samp">\</span></samp>' or an `<samp><span
class="samp">&</span></samp>'
-after the `<samp><span class="samp">\</span></samp>'. If either one follows a
`<samp><span class="samp">\</span></samp>', that character is
-output literally. The interpretation of `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' then becomes
-as shown in <a href="#table_002dsub_002dposix_002d92">table-sub-posix-92</a>.
-
- <div class="float">
-<a name="table_002dsub_002dposix_002d92"></a>
-<!-- thanks to Karl Berry for formatting this table -->
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>&</code> <code>&</code> the
matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\</span></samp>', then the matched text
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
-</pre>
- <p><strong class="float-caption">Table 8.2: 1992 POSIX Rules for sub and
gsub Escape Sequence Processing</strong></p></div>
-
-<p class="noindent">This appears to solve the problem.
-Unfortunately, the phrasing of the standard is unusual. It
-says, in effect, that `<samp><span class="samp">\</span></samp>' turns off the
special meaning of any
-following character, but for anything other than `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>',
-such special meaning is undefined. This wording leads to two problems:
-
- <ul>
-<li>Backslashes must now be doubled in the <var>replacement</var> string,
breaking
-historical <samp><span class="command">awk</span></samp> programs.
-
- <li>To make sure that an <samp><span class="command">awk</span></samp>
program is portable, <em>every</em> character
-in the <var>replacement</var> string must be preceded with a
-backslash.<a rel="footnote" href="#fn-35" name="fnd-35"><sup>35</sup></a>
-<!-- I can say that, 'cause I was involved in making this change -->
-</ul>
-
- <p>Because of the problems just listed,
-in 1996, the <samp><span class="command">gawk</span></samp> maintainer
submitted
-proposed text for a revised standard that
-reverts to rules that correspond more closely to the original existing
-practice. The proposed rules have special cases that make it possible
-to produce a `<samp><span class="samp">\</span></samp>' preceding the matched
text. This is shown in
-<a href="#table_002dsub_002dproposed">table-sub-proposed</a>.
-
- <div class="float">
-<a name="table_002dsub_002dproposed"></a>
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\</span></samp>', followed by the matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\q</code> <code>\q</code> a literal
`<samp><span class="samp">\q</span></samp>'
- <code>\\\\</code> <code>\\</code>
<code>\\</code>
-</pre>
- <p><strong class="float-caption">Table 8.3: Propsosed rules for sub and
backslash</strong></p></div>
-
- <p>In a nutshell, at the runtime level, there are now three special
sequences
-of characters (`<samp><span class="samp">\\\&</span></samp>', `<samp><span
class="samp">\\&</span></samp>' and `<samp><span
class="samp">\&</span></samp>') whereas historically
-there was only one. However, as in the historical case, any `<samp><span
class="samp">\</span></samp>' that
-is not part of one of these three sequences is not special and appears
-in the output literally.
-
- <p><samp><span class="command">gawk</span></samp> 3.0 and 3.1 follow these
proposed POSIX rules for <code>sub</code> and
-<code>gsub</code>.
-<!-- As much as we think it's a lousy idea. You win some, you lose some. Sigh.
-->
-The POSIX standard took much longer to be revised than was expected in 1996.
-The 2001 standard does not follow the above rules. Instead, the rules
-there are somewhat simpler. The results are similar except for one case.
-
- <p>The 2001 POSIX rules state that `<samp><span
class="samp">\&</span></samp>' in the replacement string produces
-a literal `<samp><span class="samp">&</span></samp>', `<samp><span
class="samp">\\</span></samp>' produces a literal `<samp><span
class="samp">\</span></samp>', and `<samp><span class="samp">\</span></samp>'
followed
-by anything else is not special; the `<samp><span
class="samp">\</span></samp>' is placed straight into the output.
-These rules are presented in <a
href="#table_002dposix_002d2001_002dsub">table-posix-2001-sub</a>.
-
- <div class="float">
-<a name="table_002dposix_002d2001_002dsub"></a>
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\</span></samp>', followed by the matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\q</code> <code>\q</code> a literal
`<samp><span class="samp">\q</span></samp>'
- <code>\\\\</code> <code>\\</code> <code>\</code>
-</pre>
- <p><strong class="float-caption">Table 8.4: POSIX 2001 rules for
sub</strong></p></div>
-
- <p>The only case where the difference is noticeable is the last one:
`<samp><span class="samp">\\\\</span></samp>'
-is seen as `<samp><span class="samp">\\</span></samp>' and produces
`<samp><span class="samp">\</span></samp>' instead of `<samp><span
class="samp">\\</span></samp>'.
-
- <p>Starting with version 3.1.4, <samp><span
class="command">gawk</span></samp> follows the POSIX rules
-when <samp><span class="option">--posix</span></samp> is specified (see <a
href="#Options">Options</a>). Otherwise,
-it continues to follow the 1996 proposed rules, since, as of this
-writing, that has been its behavior for over seven years.
-
- <blockquote>
-<b>NOTE:</b> At the next major release, <samp><span
class="command">gawk</span></samp> will switch to using
-the POSIX 2001 rules by default.
-</blockquote>
-
- <p>The rules for <code>gensub</code> are considerably simpler. At the
runtime
-level, whenever <samp><span class="command">gawk</span></samp> sees a
`<samp><span class="samp">\</span></samp>', if the following character
-is a digit, then the text that matched the corresponding parenthesized
-subexpression is placed in the generated output. Otherwise,
-no matter what character follows the `<samp><span
class="samp">\</span></samp>', it
-appears in the generated text and the `<samp><span
class="samp">\</span></samp>' does not,
-as shown in <a href="#table_002dgensub_002descapes">table-gensub-escapes</a>.
-
- <div class="float">
-<a name="table_002dgensub_002descapes"></a>
-<pre class="display"> You type <code>gensub</code> sees
<code>gensub</code> generates
- ———–
——————
————————–
- <code>&</code> <code>&</code>
the matched text
- <code>\\&</code> <code>\&</code>
a literal `<samp><span class="samp">&</span></samp>'
- <code>\\\\</code> <code>\\</code> a
literal `<samp><span class="samp">\</span></samp>'
- <code>\\\\&</code> <code>\\&</code>
a literal `<samp><span class="samp">\</span></samp>', then the matched text
- <code>\\\\\\&</code> <code>\\\&</code>
a literal `<samp><span class="samp">\&</span></samp>'
- <code>\\q</code> <code>\q</code> a
literal `<samp><span class="samp">q</span></samp>'
-</pre>
- <p><strong class="float-caption">Table 8.5: Escape Sequence Processing for
gensub</strong></p></div>
-
- <p>Because of the complexity of the lexical and runtime level processing
-and the special cases for <code>sub</code> and <code>gsub</code>,
-we recommend the use of <samp><span class="command">gawk</span></samp> and
<code>gensub</code> when you have
-to do substitutions.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Matching the Null String</h4>
-
-<p><a
name="index-advanced-features_002c-null-strings_0040comma_007b_007d-matching-1206"></a><a
name="index-matching_002c-null-strings-1207"></a><a
name="index-null-strings_002c-matching-1208"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1209"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1210"></a>
-In <samp><span class="command">awk</span></samp>, the `<samp><span
class="samp">*</span></samp>' operator can match the null string.
-This is particularly important for the <code>sub</code>, <code>gsub</code>,
-and <code>gensub</code> functions. For example:
-
-<pre class="example"> $ echo abc | awk '{ gsub(/m*/, "X"); print }'
- -| XaXbXcX
-</pre>
- <p class="noindent">Although this makes a certain amount of sense, it can
be surprising.
-
-<div class="node">
-<p><hr>
-<a name="I_002fO-Functions"></a>Next: <a rel="next" accesskey="n"
href="#Time-Functions">Time Functions</a>,
-Previous: <a rel="previous" accesskey="p" href="#String-Functions">String
Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.4 Input/Output Functions</h4>
-
-<p>The following functions relate to input/output (I/O).
-Optional parameters are enclosed in square brackets ([ ]):
-
- <dl>
-<dt><code>close(</code><var>filename</var> <span class="roman">[</span><code>,
</code><var>how</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bclose_007d-function-1211"></a><a
name="index-files_002c-closing-1212"></a>Close the file <var>filename</var> for
input or output. Alternatively, the
-argument may be a shell command that was used for creating a coprocess, or
-for redirecting to or from a pipe; then the coprocess or pipe is closed.
-See <a href="#Close-Files-And-Pipes">Close Files And Pipes</a>,
-for more information.
-
- <p>When closing a coprocess, it is occasionally useful to first close
-one end of the two-way pipe and then to close the other. This is done
-by providing a second argument to <code>close</code>. This second argument
-should be one of the two string values <code>"to"</code> or
<code>"from"</code>,
-indicating which end of the pipe to close. Case in the string does
-not matter.
-See <a href="#Two_002dway-I_002fO">Two-way I/O</a>,
-which discusses this feature in more detail and gives an example.
-
- <br><dt><code>fflush(</code><span
class="roman">[</span><var>filename</var><span
class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bfflush_007d-function-1213"></a>Flush any buffered
output associated with <var>filename</var>, which is either a
-file opened for writing or a shell command for redirecting output to
-a pipe or coprocess.
-
- <p><a
name="index-portability_002c-_0040code_007bfflush_007d-function-and-1214"></a><a
name="index-buffers_002c-flushing-1215"></a><a
name="index-output_002c-buffering-1216"></a>Many utility programs
<dfn>buffer</dfn> their output; i.e., they save information
-to write to a disk file or terminal in memory until there is enough
-for it to be worthwhile to send the data to the output device.
-This is often more efficient than writing
-every little bit of information as soon as it is ready. However, sometimes
-it is necessary to force a program to <dfn>flush</dfn> its buffers; that is,
-write the information to its destination, even if a buffer is not full.
-This is the purpose of the <code>fflush</code> function—<samp><span
class="command">gawk</span></samp> also
-buffers its output and the <code>fflush</code> function forces
-<samp><span class="command">gawk</span></samp> to flush its buffers.
-
- <p><code>fflush</code> was added to the Bell Laboratories research
-version of <samp><span class="command">awk</span></samp> in 1994; it is not
part of the POSIX standard and is
-not available if <samp><span class="option">--posix</span></samp> has been
specified on the
-command line (see <a href="#Options">Options</a>).
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bfflush_007d-function-in-1217"></a><samp><span
class="command">gawk</span></samp> extends the <code>fflush</code> function in
two ways. The first
-is to allow no argument at all. In this case, the buffer for the
-standard output is flushed. The second is to allow the null string
-(<code>""</code><!-- /@w -->) as the argument. In this case, the buffers for
-<em>all</em> open output files and pipes are flushed.
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a
name="index-troubleshooting_002c-_0040code_007bfflush_007d-function-1218"></a><code>fflush</code>
returns zero if the buffer is successfully flushed;
-otherwise, it returns −1.
-In the case where all buffers are flushed, the return value is zero
-only if all buffers were flushed successfully. Otherwise, it is
-−1, and <samp><span class="command">gawk</span></samp> warns about the
problem <var>filename</var>.
-
- <p><samp><span class="command">gawk</span></samp> also issues a warning
message if you attempt to flush
-a file or pipe that was opened for reading (such as with <code>getline</code>),
-or if <var>filename</var> is not an open file, pipe, or coprocess.
-In such a case, <code>fflush</code> returns −1, as well.
-
- <br><dt><code>system(</code><var>command</var><code>)</code><dd><a
name="index-_0040code_007bsystem_007d-function-1219"></a><a
name="index-interacting-with-other-programs-1220"></a>Executes operating-system
-commands and then returns to the <samp><span class="command">awk</span></samp>
program. The <code>system</code>
-function executes the command given by the string <var>command</var>.
-It returns the status returned by the command that was executed as
-its value.
-
- <p>For example, if the following fragment of code is put in your
<samp><span class="command">awk</span></samp>
-program:
-
- <pre class="example"> END {
- system("date | mail -s 'awk run done' root")
- }
- </pre>
- <p class="noindent">the system administrator is sent mail when the
<samp><span class="command">awk</span></samp> program
-finishes processing input and begins its end-of-input processing.
-
- <p>Note that redirecting <code>print</code> or <code>printf</code> into a
pipe is often
-enough to accomplish your task. If you need to run many commands, it
-is more efficient to simply print them down a pipeline to the shell:
-
- <pre class="example"> while (<var>more stuff to do</var>)
- print <var>command</var> | "/bin/sh"
- close("/bin/sh")
- </pre>
- <p class="noindent"><a
name="index-troubleshooting_002c-_0040code_007bsystem_007d-function-1221"></a>However,
if your <samp><span class="command">awk</span></samp>
-program is interactive, <code>system</code> is useful for cranking up large
-self-contained programs, such as a shell or an editor.
-Some operating systems cannot implement the <code>system</code> function.
-<code>system</code> causes a fatal error if it is not supported.
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Interactive Versus Noninteractive
Buffering</h4>
-
-<p><a name="index-advanced-features_002c-buffering-1222"></a><a
name="index-buffering_002c-interactive-vs_002e-noninteractive-1223"></a>
-As a side point, buffering issues can be even more confusing, depending
-upon whether your program is <dfn>interactive</dfn>, i.e., communicating
-with a user sitting at a keyboard.<a rel="footnote" href="#fn-36"
name="fnd-36"><sup>36</sup></a>
-
-<!-- Thanks to address@hidden for this example, and for -->
-<!-- motivating me to write this section. -->
-<p>Interactive programs generally <dfn>line buffer</dfn> their output; i.e.,
they
-write out every line. Noninteractive programs wait until they have
-a full buffer, which may be many lines of output.
-Here is an example of the difference:
-
-<pre class="example"> $ awk '{ print $1 + $2 }'
- 1 1
- -| 2
- 2 3
- -| 5
- <kbd>Ctrl-d</kbd>
-</pre>
- <p class="noindent">Each line of output is printed immediately. Compare
that behavior
-with this example:
-
-<pre class="example"> $ awk '{ print $1 + $2 }' | cat
- 1 1
- 2 3
- <kbd>Ctrl-d</kbd>
- -| 2
- -| 5
-</pre>
- <p class="noindent">Here, no output is printed until after the
<kbd>Ctrl-d</kbd> is typed, because
-it is all buffered and sent down the pipe to <samp><span
class="command">cat</span></samp> in one shot.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Controlling Output Buffering with
<code>system</code></h4>
-
-<p><a name="index-advanced-features_002c-buffering-1224"></a><a
name="index-buffers_002c-flushing-1225"></a><a
name="index-buffering_002c-input_002foutput-1226"></a><a
name="index-output_002c-buffering-1227"></a>
-The <code>fflush</code> function provides explicit control over output
buffering for
-individual files and pipes. However, its use is not portable to many other
-<samp><span class="command">awk</span></samp> implementations. An alternative
method to flush output
-buffers is to call <code>system</code> with a null string as its argument:
-
-<pre class="example"> system("") # flush output
-</pre>
- <p class="noindent"><samp><span class="command">gawk</span></samp> treats
this use of the <code>system</code> function as a special
-case and is smart enough not to run a shell (or other command
-interpreter) with the empty command. Therefore, with <samp><span
class="command">gawk</span></samp>, this
-idiom is not only useful, it is also efficient. While this method should work
-with other <samp><span class="command">awk</span></samp> implementations, it
does not necessarily avoid
-starting an unnecessary shell. (Other implementations may only
-flush the buffer associated with the standard output and not necessarily
-all buffered output.)
-
- <p>If you think about what a programmer expects, it makes sense that
-<code>system</code> should flush any pending output. The following program:
-
-<pre class="example"> BEGIN {
- print "first print"
- system("echo system echo")
- print "second print"
- }
-</pre>
- <p class="noindent">must print:
-
-<pre class="example"> first print
- system echo
- second print
-</pre>
- <p class="noindent">and not:
-
-<pre class="example"> system echo
- first print
- second print
-</pre>
- <p>If <samp><span class="command">awk</span></samp> did not flush its
buffers before calling <code>system</code>,
-you would see the latter (undesirable) output.
-
-<div class="node">
-<p><hr>
-<a name="Time-Functions"></a>Next: <a rel="next" accesskey="n"
href="#Bitwise-Functions">Bitwise Functions</a>,
-Previous: <a rel="previous" accesskey="p" href="#I_002fO-Functions">I/O
Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.5 Using <samp><span
class="command">gawk</span></samp>'s Timestamp Functions</h4>
-
-<!-- STARTOFRANGE tst -->
-<p><a name="index-timestamps-1228"></a><!-- STARTOFRANGE logftst -->
-<a name="index-log-files_002c-timestamps-in-1229"></a><!-- STARTOFRANGE
filogtst -->
-<a name="index-files_002c-log_0040comma_007b_007d-timestamps-in-1230"></a><!--
STARTOFRANGE gawtst -->
-<a name="index-_0040command_007bgawk_007d_002c-timestamps-1231"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-timestamps-and-1232"></a><code>awk</code>
programs are commonly used to process log files
-containing timestamp information, indicating when a
-particular log record was written. Many programs log their timestamp
-in the form returned by the <code>time</code> system call, which is the
-number of seconds since a particular epoch. On POSIX-compliant systems,
-it is the number of seconds since
-1970-01-01 00:00:00 UTC, not counting leap seconds.<a rel="footnote"
href="#fn-37" name="fnd-37"><sup>37</sup></a>
-All known POSIX-compliant systems support timestamps from 0 through
-2^31 - 1, which is sufficient to represent times through
-2038-01-19 03:14:07 UTC. Many systems support a wider range of timestamps,
-including negative timestamps that represent times before the
-epoch.
-
- <p><a name="index-_0040command_007bdate_007d-utility_002c-GNU-1233"></a><a
name="index-time_002c-retrieving-1234"></a>In order to make it easier to
process such log files and to produce
-useful reports, <samp><span class="command">gawk</span></samp> provides the
following functions for
-working with timestamps. They are <samp><span
class="command">gawk</span></samp> extensions; they are
-not specified in the POSIX standard, nor are they in any other known
-version of <samp><span class="command">awk</span></samp>.<a rel="footnote"
href="#fn-38" name="fnd-38"><sup>38</sup></a>
-Optional parameters are enclosed in square brackets ([ ]):
-
- <dl>
-<dt><code>systime()</code><dd><a
name="index-_0040code_007bsystime_007d-function-_0028_0040command_007bgawk_007d_0029-1235"></a><a
name="index-timestamps-1236"></a>This function returns the current time as the
number of seconds since
-the system epoch. On POSIX systems, this is the number of seconds
-since 1970-01-01 00:00:00 UTC, not counting leap seconds.
-It may be a different number on
-other systems.
-
- <br><dt><code>mktime(</code><var>datespec</var><code>)</code><dd><a
name="index-_0040code_007bmktime_007d-function-_0028_0040command_007bgawk_007d_0029-1237"></a>This
function turns <var>datespec</var> into a timestamp in the same form
-as is returned by <code>systime</code>. It is similar to the function of the
-same name in ISO C. The argument, <var>datespec</var>, is a string of the form
-<code>"</code><var>YYYY</var><code> </code><var>MM</var><code> </code><var>DD</var><code> </code><var>HH</var><code> </code><var>MM</var><code> </code><var>SS</var><code> [</code><var>DST</var><code>]"</code><!--
/@w -->.
-The string consists of six or seven numbers representing, respectively,
-the full year including century, the month from 1 to 12, the day of the month
-from 1 to 31, the hour of the day from 0 to 23, the minute from 0 to
-59, the second from 0 to 60,<a rel="footnote" href="#fn-39"
name="fnd-39"><sup>39</sup></a>
-and an optional daylight-savings flag.
-
- <p>The values of these numbers need not be within the ranges specified;
-for example, an hour of −1 means 1 hour before midnight.
-The origin-zero Gregorian calendar is assumed, with year 0 preceding
-year 1 and year −1 preceding year 0.
-The time is assumed to be in the local timezone.
-If the daylight-savings flag is positive, the time is assumed to be
-daylight savings time; if zero, the time is assumed to be standard
-time; and if negative (the default), <code>mktime</code> attempts to determine
-whether daylight savings time is in effect for the specified time.
-
- <p>If <var>datespec</var> does not contain enough elements or if the
resulting time
-is out of range, <code>mktime</code> returns −1.
-
- <br><dt><code>strftime(</code><span
class="roman">[</span><var>format</var> <span class="roman">[</span><code>,
</code><var>timestamp</var><span class="roman">]]</span><code>)</code><dd><!--
STARTOFRANGE strf -->
-<a
name="index-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1238"></a>This
function returns a string. It is similar to the function of the
-same name in ISO C. The time specified by <var>timestamp</var> is used to
-produce a string, based on the contents of the <var>format</var> string.
-The <var>timestamp</var> is in the same format as the value returned by the
-<code>systime</code> function. If no <var>timestamp</var> argument is
supplied,
-<samp><span class="command">gawk</span></samp> uses the current time of day as
the timestamp.
-If no <var>format</var> argument is supplied, <code>strftime</code> uses
-<code>"%a %b %d %H:%M:%S %Z %Y"<!-- /@w --></code>.
This format string produces
-output that is (almost) equivalent to that of the <samp><span
class="command">date</span></samp> utility.
-(Versions of <samp><span class="command">gawk</span></samp> prior to 3.0
require the <var>format</var> argument.)
-</dl>
-
- <p>The <code>systime</code> function allows you to compare a timestamp from
a
-log file with the current time of day. In particular, it is easy to
-determine how long ago a particular record was logged. It also allows
-you to produce log records using the “seconds since the epoch”
format.
-
- <p><a name="index-converting_002c-dates-to-timestamps-1239"></a><a
name="index-dates_002c-converting-to-timestamps-1240"></a><a
name="index-timestamps_002c-converting-dates-to-1241"></a>The
<code>mktime</code> function allows you to convert a textual representation
-of a date and time into a timestamp. This makes it easy to do before/after
-comparisons of dates and times, particularly when dealing with date and
-time data coming from an external source, such as a log file.
-
- <p>The <code>strftime</code> function allows you to easily turn a timestamp
-into human-readable information. It is similar in nature to the
<code>sprintf</code>
-function
-(see <a href="#String-Functions">String Functions</a>),
-in that it copies nonformat specification characters verbatim to the
-returned string, while substituting date and time values for format
-specifications in the <var>format</var> string.
-
- <p><a
name="index-format-specifiers_002c-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1242"></a><code>strftime</code>
is guaranteed by the 1999 ISO C standard<a rel="footnote" href="#fn-40"
name="fnd-40"><sup>40</sup></a>
-to support the following date format specifications:
-
- <dl>
-<dt><code>%a</code><dd>The locale's abbreviated weekday name.
-
- <br><dt><code>%A</code><dd>The locale's full weekday name.
-
- <br><dt><code>%b</code><dd>The locale's abbreviated month name.
-
- <br><dt><code>%B</code><dd>The locale's full month name.
-
- <br><dt><code>%c</code><dd>The locale's “appropriate” date
and time representation.
-(This is `<samp><span class="samp">%A %B %d %T %Y</span></samp>' in the
<code>"C"</code> locale.)
-
- <br><dt><code>%C</code><dd>The century. This is the year divided by 100
and truncated to the next
-lower integer.
-
- <br><dt><code>%d</code><dd>The day of the month as a decimal number
(01–31).
-
- <br><dt><code>%D</code><dd>Equivalent to specifying `<samp><span
class="samp">%m/%d/%y</span></samp>'.
-
- <br><dt><code>%e</code><dd>The day of the month, padded with a space if
it is only one digit.
-
- <br><dt><code>%F</code><dd>Equivalent to specifying `<samp><span
class="samp">%Y-%m-%d</span></samp>'.
-This is the ISO 8601 date format.
-
- <br><dt><code>%g</code><dd>The year modulo 100 of the ISO week number, as
a decimal number (00–99).
-For example, January 1, 1993 is in week 53 of 1992. Thus, the year
-of its ISO week number is 1992, even though its year is 1993.
-Similarly, December 31, 1973 is in week 1 of 1974. Thus, the year
-of its ISO week number is 1974, even though its year is 1973.
-
- <br><dt><code>%G</code><dd>The full year of the ISO week number, as a
decimal number.
-
- <br><dt><code>%h</code><dd>Equivalent to `<samp><span
class="samp">%b</span></samp>'.
-
- <br><dt><code>%H</code><dd>The hour (24-hour clock) as a decimal number
(00–23).
-
- <br><dt><code>%I</code><dd>The hour (12-hour clock) as a decimal number
(01–12).
-
- <br><dt><code>%j</code><dd>The day of the year as a decimal number
(001–366).
-
- <br><dt><code>%m</code><dd>The month as a decimal number (01–12).
-
- <br><dt><code>%M</code><dd>The minute as a decimal number (00–59).
-
- <br><dt><code>%n</code><dd>A newline character (ASCII LF).
-
- <br><dt><code>%p</code><dd>The locale's equivalent of the AM/PM
designations associated
-with a 12-hour clock.
-
- <br><dt><code>%r</code><dd>The locale's 12-hour clock time.
-(This is `<samp><span class="samp">%I:%M:%S %p</span></samp>' in the
<code>"C"</code> locale.)
-
- <br><dt><code>%R</code><dd>Equivalent to specifying `<samp><span
class="samp">%H:%M</span></samp>'.
-
- <br><dt><code>%S</code><dd>The second as a decimal number (00–60).
-
- <br><dt><code>%t</code><dd>A TAB character.
-
- <br><dt><code>%T</code><dd>Equivalent to specifying `<samp><span
class="samp">%H:%M:%S</span></samp>'.
-
- <br><dt><code>%u</code><dd>The weekday as a decimal number (1–7).
Monday is day one.
-
- <br><dt><code>%U</code><dd>The week number of the year (the first Sunday
as the first day of week one)
-as a decimal number (00–53).
-
- <!-- @cindex ISO 8601 -->
-<br><dt><code>%V</code><dd>The week number of the year (the first Monday as
the first
-day of week one) as a decimal number (01–53).
-The method for determining the week number is as specified by ISO 8601.
-(To wit: if the week containing January 1 has four or more days in the
-new year, then it is week one; otherwise it is week 53 of the previous year
-and the next week is week one.)
-
- <br><dt><code>%w</code><dd>The weekday as a decimal number (0–6).
Sunday is day zero.
-
- <br><dt><code>%W</code><dd>The week number of the year (the first Monday
as the first day of week one)
-as a decimal number (00–53).
-
- <br><dt><code>%x</code><dd>The locale's “appropriate” date
representation.
-(This is `<samp><span class="samp">%A %B %d %Y</span></samp>' in the
<code>"C"</code> locale.)
-
- <br><dt><code>%X</code><dd>The locale's “appropriate” time
representation.
-(This is `<samp><span class="samp">%T</span></samp>' in the <code>"C"</code>
locale.)
-
- <br><dt><code>%y</code><dd>The year modulo 100 as a decimal number
(00–99).
-
- <br><dt><code>%Y</code><dd>The full year as a decimal number (e.g., 1995).
-
- <!-- @cindex RFC 822 -->
-<!-- @cindex RFC 1036 -->
-<br><dt><code>%z</code><dd>The timezone offset in a +HHMM format (e.g., the
format necessary to
-produce RFC 822/RFC 1036 date headers).
-
- <br><dt><code>%Z</code><dd>The time zone name or abbreviation; no
characters if
-no time zone is determinable.
-
- <br><dt><code>%Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH</code><dt><code>%OI %Om
%OM %OS %Ou %OU %OV %Ow %OW %Oy</code><dd>“Alternate
representations” for the specifications
-that use only the second letter (`<samp><span class="samp">%c</span></samp>',
`<samp><span class="samp">%C</span></samp>',
-and so on).<a rel="footnote" href="#fn-41" name="fnd-41"><sup>41</sup></a>
-(These facilitate compliance with the POSIX <samp><span
class="command">date</span></samp> utility.)
-
- <br><dt><code>%%</code><dd>A literal `<samp><span
class="samp">%</span></samp>'.
-</dl>
-
- <p>If a conversion specifier is not one of the above, the behavior is
-undefined.<a rel="footnote" href="#fn-42" name="fnd-42"><sup>42</sup></a>
-
-<!-- @cindex locale, definition of -->
-<p>Informally, a <dfn>locale</dfn> is the geographic place in which a program
-is meant to run. For example, a common way to abbreviate the date
-September 4, 1991 in the United States is “9/4/91.”
-In many countries in Europe, however, it is abbreviated “4.9.91.”
-Thus, the `<samp><span class="samp">%x</span></samp>' specification in a
<code>"US"</code> locale might produce
-`<samp><span class="samp">9/4/91</span></samp>', while in a
<code>"EUROPE"</code> locale, it might produce
-`<samp><span class="samp">4.9.91</span></samp>'. The ISO C standard defines a
default <code>"C"</code>
-locale, which is an environment that is typical of what most C programmers
-are used to.
-
- <p>A public-domain C version of <code>strftime</code> is supplied with
<samp><span class="command">gawk</span></samp>
-for systems that are not yet fully standards-compliant.
-It supports all of the just listed format specifications.
-If that version is
-used to compile <samp><span class="command">gawk</span></samp> (see <a
href="#Installation">Installation</a>),
-then the following additional format specifications are available:
-
- <dl>
-<dt><code>%k</code><dd>The hour (24-hour clock) as a decimal number
(0–23).
-Single-digit numbers are padded with a space.
-
- <br><dt><code>%l</code><dd>The hour (12-hour clock) as a decimal number
(1–12).
-Single-digit numbers are padded with a space.
-
- <br><dt><code>%N</code><dd>The “Emperor/Era” name.
-Equivalent to <code>%C</code>.
-
- <br><dt><code>%o</code><dd>The “Emperor/Era” year.
-Equivalent to <code>%y</code>.
-
- <br><dt><code>%s</code><dd>The time as a decimal timestamp in seconds
since the epoch.
-
- <br><dt><code>%v</code><dd>The date in VMS format (e.g., `<samp><span
class="samp">20-JUN-1991</span></samp>').
-</dl>
- <!-- ENDOFRANGE strf -->
-
- <p>Additionally, the alternate representations are recognized but their
-normal representations are used.
-
- <p><a name="index-_0040code_007bdate_007d-utility_002c-POSIX-1243"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bdate_007d-utility-and-1244"></a>This
example is an <samp><span class="command">awk</span></samp> implementation of
the POSIX
-<samp><span class="command">date</span></samp> utility. Normally, the
<samp><span class="command">date</span></samp> utility prints the
-current date and time of day in a well-known format. However, if you
-provide an argument to it that begins with a `<samp><span
class="samp">+</span></samp>', <samp><span class="command">date</span></samp>
-copies nonformat specifier characters to the standard output and
-interprets the current time according to the format specifiers in
-the string. For example:
-
-<pre class="example"> $ date '+Today is %A, %B %d, %Y.'
- -| Today is Thursday, September 14, 2000.
-</pre>
- <p>Here is the <samp><span class="command">gawk</span></samp> version of
the <samp><span class="command">date</span></samp> utility.
-It has a shell “wrapper” to handle the <samp><span
class="option">-u</span></samp> option,
-which requires that <samp><span class="command">date</span></samp> run as if
the time zone
-is set to UTC:
-
-<pre class="example"> #! /bin/sh
- #
- # date --- approximate the P1003.2 'date' command
-
- case $1 in
- -u) TZ=UTC0 # use UTC
- export TZ
- shift ;;
- esac
-
- <!-- FIXME: One day, change %d to %e, when C 99 is common. -->
- gawk 'BEGIN {
- format = "%a %b %d %H:%M:%S %Z %Y"
- exitval = 0
-
- if (ARGC > 2)
- exitval = 1
- else if (ARGC == 2) {
- format = ARGV[1]
- if (format ~ /^\+/)
- format = substr(format, 2) # remove leading +
- }
- print strftime(format)
- exit exitval
- }' "$@"
-</pre>
- <!-- ENDOFRANGE tst -->
-<!-- ENDOFRANGE logftst -->
-<!-- ENDOFRANGE filogtst -->
-<!-- ENDOFRANGE gawtst -->
-<div class="node">
-<p><hr>
-<a name="Bitwise-Functions"></a>Next: <a rel="next" accesskey="n"
href="#I18N-Functions">I18N Functions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Time-Functions">Time
Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.6 Bit-Manipulation Functions of <samp><span
class="command">gawk</span></samp></h4>
-
-<!-- STARTOFRANGE bit -->
-<p><a name="index-bitwise_002c-operations-1245"></a><!-- STARTOFRANGE and -->
-<a name="index-AND-bitwise-operation-1246"></a><!-- STARTOFRANGE oro -->
-<a name="index-OR-bitwise-operation-1247"></a><!-- STARTOFRANGE xor -->
-<a name="index-XOR-bitwise-operation-1248"></a><!-- STARTOFRANGE opbit -->
-<a name="index-operations_002c-bitwise-1249"></a><blockquote>
-<i>I can explain it for you, but I can't understand it for you.</i><br>
-Anonymous
-</blockquote>
-
- <p>Many languages provide the ability to perform <dfn>bitwise</dfn>
operations
-on two integer numbers. In other words, the operation is performed on
-each successive pair of bits in the operands.
-Three common operations are bitwise AND, OR, and XOR.
-The operations are described in <a
href="#table_002dbitwise_002dops">table-bitwise-ops</a>.
-
- <div class="float">
-<a name="table_002dbitwise_002dops"></a>
-<pre class="display"> Bit Operator
- | AND | OR | XOR
- |—+—+—+—+—+—
- Operands | 0 | 1 | 0 | 1 | 0 | 1
-
————–+—+—+—+—+—+—
- 0 | 0 0 | 0 1 | 0 1
- 1 | 0 1 | 1 1 | 1 0
-</pre>
- <p><strong class="float-caption">Table 8.6: Bitwise
Operations</strong></p></div>
-
- <p><a name="index-bitwise_002c-complement-1250"></a><a
name="index-complement_002c-bitwise-1251"></a>As you can see, the result of an
AND operation is 1 only when <em>both</em>
-bits are 1.
-The result of an OR operation is 1 if <em>either</em> bit is 1.
-The result of an XOR operation is 1 if either bit is 1,
-but not both.
-The next operation is the <dfn>complement</dfn>; the complement of 1 is 0 and
-the complement of 0 is 1. Thus, this operation “flips” all the bits
-of a given value.
-
- <p><a name="index-bitwise_002c-shift-1252"></a><a
name="index-left-shift_002c-bitwise-1253"></a><a
name="index-right-shift_002c-bitwise-1254"></a><a
name="index-shift_002c-bitwise-1255"></a>Finally, two other common operations
are to shift the bits left or right.
-For example, if you have a bit string `<samp><span
class="samp">10111001</span></samp>' and you shift it
-right by three bits, you end up with `<samp><span
class="samp">00010111</span></samp>'.<a rel="footnote" href="#fn-43"
name="fnd-43"><sup>43</sup></a>
-<!-- Purposely decided to use 0's and 1's here. 2/2001. -->
-If you start over
-again with `<samp><span class="samp">10111001</span></samp>' and shift it left
by three bits, you end up
-with `<samp><span class="samp">11001000</span></samp>'.
-<samp><span class="command">gawk</span></samp> provides built-in functions
that implement the
-bitwise operations just described. They are:
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-bitwise-operations-in-1256"></a>
- <p><table summary=""><a
name="index-_0040code_007band_007d-function-_0028_0040command_007bgawk_007d_0029-1257"></a><tr
align="left"><td valign="top"><code>and(</code><var>v1</var><code>,
</code><var>v2</var><code>)</code>
-</td><td valign="top">Returns the bitwise AND of the values provided by
<var>v1</var> and <var>v2</var>.
-
-<p><a
name="index-_0040code_007bor_007d-function-_0028_0040command_007bgawk_007d_0029-1258"></a><br></td></tr><tr
align="left"><td valign="top"><code>or(</code><var>v1</var><code>,
</code><var>v2</var><code>)</code>
-</td><td valign="top">Returns the bitwise OR of the values provided by
<var>v1</var> and <var>v2</var>.
-
-<p><a
name="index-_0040code_007bxor_007d-function-_0028_0040command_007bgawk_007d_0029-1259"></a><br></td></tr><tr
align="left"><td valign="top"><code>xor(</code><var>v1</var><code>,
</code><var>v2</var><code>)</code>
-</td><td valign="top">Returns the bitwise XOR of the values provided by
<var>v1</var> and <var>v2</var>.
-
-<p><a
name="index-_0040code_007bcompl_007d-function-_0028_0040command_007bgawk_007d_0029-1260"></a><br></td></tr><tr
align="left"><td valign="top"><code>compl(</code><var>val</var><code>)</code>
-</td><td valign="top">Returns the bitwise complement of <var>val</var>.
-
-<p><a
name="index-_0040code_007blshift_007d-function-_0028_0040command_007bgawk_007d_0029-1261"></a><br></td></tr><tr
align="left"><td valign="top"><code>lshift(</code><var>val</var><code>,
</code><var>count</var><code>)</code>
-</td><td valign="top">Returns the value of <var>val</var>, shifted left by
<var>count</var> bits.
-
-<p><a
name="index-_0040code_007brshift_007d-function-_0028_0040command_007bgawk_007d_0029-1262"></a><br></td></tr><tr
align="left"><td valign="top"><code>rshift(</code><var>val</var><code>,
</code><var>count</var><code>)</code>
-</td><td valign="top">Returns the value of <var>val</var>, shifted right by
<var>count</var> bits.
- <br></td></tr></table>
-
- <p>For all of these functions, first the double-precision floating-point
value is
-converted to the widest C unsigned integer type, then the bitwise operation is
-performed. If the result cannot be represented exactly as a C
<code>double</code>,
-leading nonzero bits are removed one by one until it can be represented
-exactly. The result is then converted back into a C <code>double</code>. (If
-you don't understand this paragraph, don't worry about it.)
-
- <p>Here is a user-defined function
-(see <a href="#User_002ddefined">User-defined</a>)
-that illustrates the use of these functions:
-
- <p><a
name="index-_0040code_007bbits2str_007d-user_002ddefined-function-1263"></a><a
name="index-_0040code_007btestbits_002eawk_007d-program-1264"></a>
-<pre class="smallexample"> <!-- file eg/lib/bits2str.awk -->
- # bits2str --- turn a byte into readable 1's and 0's
-
- function bits2str(bits, data, mask)
- {
- if (bits == 0)
- return "0"
-
- mask = 1
- for (; bits != 0; bits = rshift(bits, 1))
- data = (and(bits, mask) ? "1" : "0") data
-
- while ((length(data) % 8) != 0)
- data = "0" data
-
- return data
- }
- <!-- endfile -->
-
- <!-- this is a hack to make testbits.awk self-contained -->
- <!-- file eg/prog/testbits.awk -->
- BEGIN {
- printf "123 = %s\n", bits2str(123)
- printf "0123 = %s\n", bits2str(0123)
- printf "0x99 = %s\n", bits2str(0x99)
- comp = compl(0x99)
- printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp)
- shift = lshift(0x99, 2)
- printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
- shift = rshift(0x99, 2)
- printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">This program produces the following output when run:
-
-<pre class="smallexample"> $ gawk -f testbits.awk
- -| 123 = 01111011
- -| 0123 = 01010011
- -| 0x99 = 10011001
- -| compl(0x99) = 0xffffff66 = 11111111111111111111111101100110
- -| lshift(0x99, 2) = 0x264 = 0000001001100100
- -| rshift(0x99, 2) = 0x26 = 00100110
-</pre>
- <p><a name="index-numbers_002c-converting_002c-to-strings-1265"></a><a
name="index-strings_002c-converting_002c-numbers-to-1266"></a><a
name="index-converting_002c-numbers_002c-to-strings-1267"></a>The
<code>bits2str</code> function turns a binary number into a string.
-The number <code>1</code> represents a binary value where the rightmost bit
-is set to 1. Using this mask,
-the function repeatedly checks the rightmost bit.
-ANDing the mask with the value indicates whether the
-rightmost bit is 1 or not. If so, a <code>"1"</code> is concatenated onto the
front
-of the string.
-Otherwise, a <code>"0"</code> is added.
-The value is then shifted right by one bit and the loop continues
-until there are no more 1 bits.
-
- <p>If the initial value is zero it returns a simple <code>"0"</code>.
-Otherwise, at the end, it pads the value with zeros to represent multiples
-of 8-bit quantities. This is typical in modern computers.
-
- <p>The main code in the <code>BEGIN</code> rule shows the difference
between the
-decimal and octal values for the same numbers
-(see <a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>),
-and then demonstrates the
-results of the <code>compl</code>, <code>lshift</code>, and
<code>rshift</code> functions.
-<!-- ENDOFRANGE bit -->
-<!-- ENDOFRANGE and -->
-<!-- ENDOFRANGE oro -->
-<!-- ENDOFRANGE xor -->
-<!-- ENDOFRANGE opbit -->
-
-<div class="node">
-<p><hr>
-<a name="I18N-Functions"></a>Previous: <a rel="previous" accesskey="p"
href="#Bitwise-Functions">Bitwise Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Built_002din">Built-in</a>
-<br>
-</div>
-
-<h4 class="subsection">8.1.7 Using <samp><span
class="command">gawk</span></samp>'s String-Translation Functions</h4>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-string_002dtranslation-functions-1268"></a><a
name="index-functions_002c-string_002dtranslation-1269"></a><a
name="index-internationalization-1270"></a><a
name="index-_0040command_007bawk_007d-programs_002c-internationalizing-1271"></a>
-<samp><span class="command">gawk</span></samp> provides facilities for
internationalizing <samp><span class="command">awk</span></samp> programs.
-These include the functions described in the following list.
-The descriptions here are purposely brief.
-See <a href="#Internationalization">Internationalization</a>,
-for the full story.
-Optional parameters are enclosed in square brackets ([ ]):
-
-
-<a
name="index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1272"></a>
-<dl><dt><code>dcgettext(</code><var>string</var> <span
class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This function returns the translation
of <var>string</var> in
-text domain <var>domain</var> for locale category <var>category</var>.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p><a
name="index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1273"></a><br><dt><code>dcngettext(</code><var>string1</var><code>,
</code><var>string2</var><code>, </code><var>number</var> <span
class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This function returns the plural form
used for <var>number</var> of the
-translation of <var>string1</var> and <var>string2</var> in text domain
-<var>domain</var> for locale category <var>category</var>. <var>string1</var>
is the
-English singular variant of a message, and <var>string2</var> the English
plural
-variant of the same message.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1274"></a><br><dt><code>bindtextdomain(</code><var>directory</var>
<span class="roman">[</span><code>, </code><var>domain</var><span
class="roman">]</span><code>)</code><dd>This function allows you to specify the
directory in which
-<samp><span class="command">gawk</span></samp> will look for message
translation files, in case they
-will not or cannot be placed in the “standard” locations
-(e.g., during testing).
-It returns the directory in which <var>domain</var> is “bound.”
-
- <p>The default <var>domain</var> is the value of <code>TEXTDOMAIN</code>.
-If <var>directory</var> is the null string (<code>""</code>), then
-<code>bindtextdomain</code> returns the current binding for the
-given <var>domain</var>.
-</dl>
- <!-- ENDOFRANGE funcbi -->
-<!-- ENDOFRANGE bifunc -->
-
-<div class="node">
-<p><hr>
-<a name="User_002ddefined"></a>Previous: <a rel="previous" accesskey="p"
href="#Built_002din">Built-in</a>,
-Up: <a rel="up" accesskey="u" href="#Functions">Functions</a>
-<br>
-</div>
-
-<h3 class="section">8.2 User-Defined Functions</h3>
-
-<!-- STARTOFRANGE udfunc -->
-<p><a name="index-user_002ddefined_002c-functions-1275"></a><!-- STARTOFRANGE
funcud -->
-<a name="index-functions_002c-user_002ddefined-1276"></a>Complicated
<samp><span class="command">awk</span></samp> programs can often be simplified
by defining
-your own functions. User-defined functions can be called just like
-built-in ones (see <a href="#Function-Calls">Function Calls</a>), but it is up
to you to define
-them, i.e., to tell <samp><span class="command">awk</span></samp> what they
should do.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Definition-Syntax">Definition Syntax</a>:
How to write definitions and what they mean.
-<li><a accesskey="2" href="#Function-Example">Function Example</a>:
An example function definition and what it
- does.
-<li><a accesskey="3" href="#Function-Caveats">Function Caveats</a>:
Things to watch out for.
-<li><a accesskey="4" href="#Return-Statement">Return Statement</a>:
Specifying the value a function returns.
-<li><a accesskey="5" href="#Dynamic-Typing">Dynamic Typing</a>:
How variable types can change at runtime.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Definition-Syntax"></a>Next: <a rel="next" accesskey="n"
href="#Function-Example">Function Example</a>,
-Up: <a rel="up" accesskey="u" href="#User_002ddefined">User-defined</a>
-<br>
-</div>
-
-<h4 class="subsection">8.2.1 Function Definition Syntax</h4>
-
-<!-- STARTOFRANGE fdef -->
-<p><a name="index-functions_002c-defining-1277"></a>Definitions of functions
can appear anywhere between the rules of an
-<samp><span class="command">awk</span></samp> program. Thus, the general form
of an <samp><span class="command">awk</span></samp> program is
-extended to include sequences of rules <em>and</em> user-defined function
-definitions.
-There is no need to put the definition of a function
-before all uses of the function. This is because <samp><span
class="command">awk</span></samp> reads the
-entire program before starting to execute any of it.
-
- <p>The definition of a function named <var>name</var> looks like this:
-<!-- NEXT ED: put [ ] around parameter list -->
-
-<pre class="example"> function <var>name</var>(<var>parameter-list</var>)
- {
- <var>body-of-function</var>
- }
-</pre>
- <p><a name="index-names_002c-functions-1278"></a><a
name="index-functions_002c-names-of-1279"></a><a
name="index-namespace-issues_002c-functions-1280"></a><var>name</var> is the
name of the function to define. A valid function
-name is like a valid variable name: a sequence of letters, digits, and
-underscores that doesn't start with a digit.
-Within a single <samp><span class="command">awk</span></samp> program, any
particular name can only be
-used as a variable, array, or function.
-
-<!-- NEXT ED: parameter-list is an OPTIONAL list of ... -->
-<p><var>parameter-list</var> is a list of the function's arguments and local
-variable names, separated by commas. When the function is called,
-the argument names are used to hold the argument values given in
-the call. The local variables are initialized to the empty string.
-A function cannot have two parameters with the same name, nor may it
-have a parameter with the same name as the function itself.
-
- <p>The <var>body-of-function</var> consists of <samp><span
class="command">awk</span></samp> statements. It is the
-most important part of the definition, because it says what the function
-should actually <em>do</em>. The argument names exist to give the body a
-way to talk about the arguments; local variables exist to give the body
-places to keep temporary values.
-
- <p>Argument names are not distinguished syntactically from local variable
-names. Instead, the number of arguments supplied when the function is
-called determines how many argument variables there are. Thus, if three
-argument values are given, the first three names in <var>parameter-list</var>
-are arguments and the rest are local variables.
-
- <p>It follows that if the number of arguments is not the same in all calls
-to the function, some of the names in <var>parameter-list</var> may be
-arguments on some occasions and local variables on others. Another
-way to think of this is that omitted arguments default to the
-null string.
-
- <p><a
name="index-programming-conventions_002c-functions_002c-writing-1281"></a>Usually
when you write a function, you know how many names you intend to
-use for arguments and how many you intend to use as local variables. It is
-conventional to place some extra space between the arguments and
-the local variables, in order to document how your function is supposed to be
used.
-
- <p><a name="index-variables_002c-shadowing-1282"></a>During execution of
the function body, the arguments and local variable
-values hide, or <dfn>shadow</dfn>, any variables of the same names used in the
-rest of the program. The shadowed variables are not accessible in the
-function definition, because there is no way to name them while their
-names have been taken away for the local variables. All other variables
-used in the <samp><span class="command">awk</span></samp> program can be
referenced or set normally in the
-function's body.
-
- <p>The arguments and local variables last only as long as the function body
-is executing. Once the body finishes, you can once again access the
-variables that were shadowed while the function was running.
-
- <p><a name="index-recursive-functions-1283"></a><a
name="index-functions_002c-recursive-1284"></a>The function body can contain
expressions that call functions. They
-can even call this function, either directly or by way of another
-function. When this happens, we say the function is <dfn>recursive</dfn>.
-The act of a function calling itself is called <dfn>recursion</dfn>.
-
-<!-- @cindex @command{awk} language, POSIX version -->
-<!-- @cindex POSIX @command{awk} -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bfunction_007d-keyword-in-1285"></a>In
many <samp><span class="command">awk</span></samp> implementations, including
<samp><span class="command">gawk</span></samp>,
-the keyword <code>function</code> may be
-abbreviated <code>func</code>. However, POSIX only specifies the use of
-the keyword <code>function</code>. This actually has some practical
implications.
-If <samp><span class="command">gawk</span></samp> is in POSIX-compatibility
mode
-(see <a href="#Options">Options</a>), then the following
-statement does <em>not</em> define a function:
-
-<pre class="example"> func foo() { a = sqrt($1) ; print a }
-</pre>
- <p class="noindent">Instead it defines a rule that, for each record,
concatenates the value
-of the variable `<samp><span class="samp">func</span></samp>' with the return
value of the function `<samp><span class="samp">foo</span></samp>'.
-If the resulting string is non-null, the action is executed.
-This is probably not what is desired. (<samp><span
class="command">awk</span></samp> accepts this input as
-syntactically valid, because functions may be used before they are defined
-in <samp><span class="command">awk</span></samp> programs.)
-<!-- NEXT ED: This won't actually run, since foo() is undefined ... -->
-
- <p><a
name="index-portability_002c-functions_0040comma_007b_007d-defining-1286"></a>To
ensure that your <samp><span class="command">awk</span></samp> programs are
portable, always use the
-keyword <code>function</code> when defining a function.
-
-<div class="node">
-<p><hr>
-<a name="Function-Example"></a>Next: <a rel="next" accesskey="n"
href="#Function-Caveats">Function Caveats</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Definition-Syntax">Definition Syntax</a>,
-Up: <a rel="up" accesskey="u" href="#User_002ddefined">User-defined</a>
-<br>
-</div>
-
-<h4 class="subsection">8.2.2 Function Definition Examples</h4>
-
-<p>Here is an example of a user-defined function, called <code>myprint</code>,
that
-takes a number and prints it in a specific format:
-
-<pre class="example"> function myprint(num)
- {
- printf "%6.3g\n", num
- }
-</pre>
- <p class="noindent">To illustrate, here is an <samp><span
class="command">awk</span></samp> rule that uses our <code>myprint</code>
-function:
-
-<pre class="example"> $3 > 0 { myprint($3) }
-</pre>
- <p class="noindent">This program prints, in our special format, all the
third fields that
-contain a positive number in our input. Therefore, when given the following:
-
-<pre class="example"> 1.2 3.4 5.6 7.8
- 9.10 11.12 -13.14 15.16
- 17.18 19.20 21.22 23.24
-</pre>
- <p class="noindent">this program, using our function to format the results,
prints:
-
-<pre class="example"> 5.6
- 21.2
-</pre>
- <p>This function deletes all the elements in an array:
-
-<pre class="example"> function delarray(a, i)
- {
- for (i in a)
- delete a[i]
- }
-</pre>
- <p>When working with arrays, it is often necessary to delete all the
elements
-in an array and start over with a new list of elements
-(see <a href="#Delete">Delete</a>).
-Instead of having
-to repeat this loop everywhere that you need to clear out
-an array, your program can just call <code>delarray</code>.
-(This guarantees portability. The use of `<samp><span class="samp">delete
</span><var>array</var></samp>' to delete
-the contents of an entire array is a nonstandard extension.)
-
- <p>The following is an example of a recursive function. It takes a string
-as an input parameter and returns the string in backwards order.
-Recursive functions must always have a test that stops the recursion.
-In this case, the recursion terminates when the starting position
-is zero, i.e., when there are no more characters left in the string.
-
- <p><a
name="index-_0040code_007brev_007d-user_002ddefined-function-1287"></a>
-<pre class="example"> function rev(str, start)
- {
- if (start == 0)
- return ""
-
- return (substr(str, start, 1) rev(str, start - 1))
- }
-</pre>
- <p>If this function is in a file named <samp><span
class="file">rev.awk</span></samp>, it can be tested
-this way:
-
-<pre class="example"> $ echo "Don't Panic!" |
- > gawk --source '{ print rev($0, length($0)) }' -f rev.awk
- -| !cinaP t'noD
-</pre>
- <p>The C <code>ctime</code> function takes a timestamp and returns it in a
string,
-formatted in a well-known fashion.
-The following example uses the built-in <code>strftime</code> function
-(see <a href="#Time-Functions">Time Functions</a>)
-to create an <samp><span class="command">awk</span></samp> version of
<code>ctime</code>:
-
- <p><a
name="index-_0040code_007bctime_007d-user_002ddefined-function-1288"></a><!--
FIXME: One day, change %d to %e, when C 99 is common. -->
-<pre class="example"> <!-- file eg/lib/ctime.awk -->
- # ctime.awk
- #
- # awk version of C ctime(3) function
-
- function ctime(ts, format)
- {
- format = "%a %b %d %H:%M:%S %Z %Y"
- if (ts == 0)
- ts = systime() # use current time as default
- return strftime(format, ts)
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE fdef -->
-<div class="node">
-<p><hr>
-<a name="Function-Caveats"></a>Next: <a rel="next" accesskey="n"
href="#Return-Statement">Return Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Function-Example">Function Example</a>,
-Up: <a rel="up" accesskey="u" href="#User_002ddefined">User-defined</a>
-<br>
-</div>
-
-<h4 class="subsection">8.2.3 Calling User-Defined Functions</h4>
-
-<!-- STARTOFRANGE fudc -->
-<p><a
name="index-functions_002c-user_002ddefined_002c-calling-1289"></a><dfn>Calling
a function</dfn> means causing the function to run and do its job.
-A function call is an expression and its value is the value returned by
-the function.
-
- <p>A function call consists of the function name followed by the arguments
-in parentheses. <samp><span class="command">awk</span></samp> expressions are
what you write in the
-call for the arguments. Each time the call is executed, these
-expressions are evaluated, and the values are the actual arguments. For
-example, here is a call to <code>foo</code> with three arguments (the first
-being a string concatenation):
-
-<pre class="example"> foo(x y, "lose", 4 * z)
-</pre>
- <p><strong>Caution:</strong> Whitespace characters (spaces and tabs) are
not allowed
-between the function name and the open-parenthesis of the argument list.
-If you write whitespace by mistake, <samp><span
class="command">awk</span></samp> might think that you mean
-to concatenate a variable with an expression in parentheses. However, it
-notices that you used a function name and not a variable name, and reports
-an error.
-
- <p><a name="index-call-by-value-1290"></a>When a function is called, it is
given a <em>copy</em> of the values of
-its arguments. This is known as <dfn>call by value</dfn>. The caller may use
-a variable as the expression for the argument, but the called function
-does not know this—it only knows what value the argument had. For
-example, if you write the following code:
-
-<pre class="example"> foo = "bar"
- z = myfunc(foo)
-</pre>
- <p class="noindent">then you should not think of the argument to
<code>myfunc</code> as being
-“the variable <code>foo</code>.” Instead, think of the argument
as the
-string value <code>"bar"</code>.
-If the function <code>myfunc</code> alters the values of its local variables,
-this has no effect on any other variables. Thus, if <code>myfunc</code>
-does this:
-
-<pre class="example"> function myfunc(str)
- {
- print str
- str = "zzz"
- print str
- }
-</pre>
- <p class="noindent">to change its first argument variable <code>str</code>,
it does <em>not</em>
-change the value of <code>foo</code> in the caller. The role of
<code>foo</code> in
-calling <code>myfunc</code> ended when its value (<code>"bar"</code>) was
computed.
-If <code>str</code> also exists outside of <code>myfunc</code>, the function
body
-cannot alter this outer value, because it is shadowed during the
-execution of <code>myfunc</code> and cannot be seen or changed from there.
-
- <p><a name="index-call-by-reference-1291"></a><a
name="index-arrays_002c-as-parameters-to-functions-1292"></a><a
name="index-functions_002c-arrays-as-parameters-to-1293"></a>However, when
arrays are the parameters to functions, they are <em>not</em>
-copied. Instead, the array itself is made available for direct manipulation
-by the function. This is usually called <dfn>call by reference</dfn>.
-Changes made to an array parameter inside the body of a function <em>are</em>
-visible outside that function.
-
- <blockquote>
-<b>NOTE:</b> Changing an array parameter inside a function
-can be very dangerous if you do not watch what you are doing.
-For example:
-
- <pre class="example"> function changeit(array, ind, nvalue)
- {
- array[ind] = nvalue
- }
-
- BEGIN {
- a[1] = 1; a[2] = 2; a[3] = 3
- changeit(a, 2, "two")
- printf "a[1] = %s, a[2] = %s, a[3] = %s\n",
- a[1], a[2], a[3]
- }
- </pre>
- <p class="noindent">prints `<samp><span class="samp">a[1] = 1, a[2] =
two, a[3] = 3</span></samp>', because
-<code>changeit</code> stores <code>"two"</code> in the second element of
<code>a</code>.
-</blockquote>
-
- <p><a name="index-undefined-functions-1294"></a><a
name="index-functions_002c-undefined-1295"></a>Some <samp><span
class="command">awk</span></samp> implementations allow you to call a function
that
-has not been defined. They only report a problem at runtime when the
-program actually tries to call the function. For example:
-
-<pre class="example"> BEGIN {
- if (0)
- foo()
- else
- bar()
- }
- function bar() { ... }
- # note that `foo' is not defined
-</pre>
- <p class="noindent">Because the `<samp><span class="samp">if</span></samp>'
statement will never be true, it is not really a
-problem that <code>foo</code> has not been defined. Usually, though, it is a
-problem if a program calls an undefined function.
-
- <p><a name="index-lint-checking_002c-undefined-functions-1296"></a>If
<samp><span class="option">--lint</span></samp> is specified
-(see <a href="#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> reports calls to undefined
functions.
-
- <p><a
name="index-portability_002c-_0040code_007bnext_007d-statement-in-user_002ddefined-functions-1297"></a>Some
<samp><span class="command">awk</span></samp> implementations generate a
runtime
-error if you use the <code>next</code> statement
-(see <a href="#Next-Statement">Next Statement</a>)
-inside a user-defined function.
-<samp><span class="command">gawk</span></samp> does not have this limitation.
-<!-- ENDOFRANGE fudc -->
-
-<div class="node">
-<p><hr>
-<a name="Return-Statement"></a>Next: <a rel="next" accesskey="n"
href="#Dynamic-Typing">Dynamic Typing</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Function-Caveats">Function Caveats</a>,
-Up: <a rel="up" accesskey="u" href="#User_002ddefined">User-defined</a>
-<br>
-</div>
-
-<h4 class="subsection">8.2.4 The <code>return</code> Statement</h4>
-
-<p><a
name="index-_0040code_007breturn_007d-statement_0040comma_007b_007d-user_002ddefined-functions-1298"></a>
-The body of a user-defined function can contain a <code>return</code>
statement.
-This statement returns control to the calling part of the <samp><span
class="command">awk</span></samp> program. It
-can also be used to return a value for use in the rest of the <samp><span
class="command">awk</span></samp>
-program. It looks like this:
-
-<pre class="example"> return <span
class="roman">[</span><var>expression</var><span class="roman">]</span>
-</pre>
- <p>The <var>expression</var> part is optional. If it is omitted, then the
returned
-value is undefined, and therefore, unpredictable.
-
- <p>A <code>return</code> statement with no value expression is assumed at
the end of
-every function definition. So if control reaches the end of the function
-body, then the function returns an unpredictable value. <samp><span
class="command">awk</span></samp>
-does <em>not</em> warn you if you use the return value of such a function.
-
- <p>Sometimes, you want to write a function for what it does, not for
-what it returns. Such a function corresponds to a <code>void</code> function
-in C or to a <code>procedure</code> in Pascal. Thus, it may be appropriate to
not
-return any value; simply bear in mind that if you use the return
-value of such a function, you do so at your own risk.
-
- <p>The following is an example of a user-defined function that returns a
value
-for the largest number among the elements of an array:
-
-<pre class="example"> function maxelt(vec, i, ret)
- {
- for (i in vec) {
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- }
- return ret
- }
-</pre>
- <p><a
name="index-programming-conventions_002c-function-parameters-1299"></a>You call
<code>maxelt</code> with one argument, which is an array name. The local
-variables <code>i</code> and <code>ret</code> are not intended to be arguments;
-while there is nothing to stop you from passing more than one argument
-to <code>maxelt</code>, the results would be strange. The extra space before
-<code>i</code> in the function parameter list indicates that <code>i</code> and
-<code>ret</code> are not supposed to be arguments.
-You should follow this convention when defining functions.
-
- <p>The following program uses the <code>maxelt</code> function. It loads an
-array, calls <code>maxelt</code>, and then reports the maximum number in that
-array:
-
-<pre class="example"> function maxelt(vec, i, ret)
- {
- for (i in vec) {
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- }
- return ret
- }
-
- # Load all fields of each record into nums.
- {
- for(i = 1; i <= NF; i++)
- nums[NR, i] = $i
- }
-
- END {
- print maxelt(nums)
- }
-</pre>
- <p>Given the following input:
-
-<pre class="example"> 1 5 23 8 16
- 44 3 5 2 8 26
- 256 291 1396 2962 100
- -6 467 998 1101
- 99385 11 0 225
-</pre>
- <p class="noindent">the program reports (predictably) that
<code>99385</code> is the largest number
-in the array.
-
-<div class="node">
-<p><hr>
-<a name="Dynamic-Typing"></a>Previous: <a rel="previous" accesskey="p"
href="#Return-Statement">Return Statement</a>,
-Up: <a rel="up" accesskey="u" href="#User_002ddefined">User-defined</a>
-<br>
-</div>
-
-<h4 class="subsection">8.2.5 Functions and Their Effects on Variable
Typing</h4>
-
-<p><samp><span class="command">awk</span></samp> is a very fluid language.
-It is possible that <samp><span class="command">awk</span></samp> can't tell
if an identifier
-represents a regular variable or an array until runtime.
-Here is an annotated sample program:
-
-<pre class="example"> function foo(a)
- {
- a[1] = 1 # parameter is an array
- }
-
- BEGIN {
- b = 1
- foo(b) # invalid: fatal type mismatch
-
- foo(x) # x uninitialized, becomes an array dynamically
- x = 1 # now not allowed, runtime error
- }
-</pre>
- <p>Usually, such things aren't a big issue, but it's worth
-being aware of them.
-<!-- ENDOFRANGE udfunc -->
-<!-- ENDOFRANGE funcud -->
-
-<div class="node">
-<p><hr>
-<a name="Internationalization"></a>Next: <a rel="next" accesskey="n"
href="#Advanced-Features">Advanced Features</a>,
-Previous: <a rel="previous" accesskey="p" href="#Functions">Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">9 Internationalization with <samp><span
class="command">gawk</span></samp></h2>
-
-<p>Once upon a time, computer makers
-wrote software that worked only in English.
-Eventually, hardware and software vendors noticed that if their
-systems worked in the native languages of non-English-speaking
-countries, they were able to sell more systems.
-As a result, internationalization and localization
-of programs and software systems became a common practice.
-
-<!-- STARTOFRANGE inloc -->
-<p><a name="index-internationalization_002c-localization-1300"></a><a
name="index-_0040command_007bgawk_007d_002c-internationalization-and_002c-See-internationalization-1301"></a><a
name="index-internationalization_002c-localization_002c-_0040command_007bgawk_007d-and-1302"></a>Until
recently, the ability to provide internationalization
-was largely restricted to programs written in C and C++.
-This chapter describes the underlying library <samp><span
class="command">gawk</span></samp>
-uses for internationalization, as well as how
-<samp><span class="command">gawk</span></samp> makes internationalization
-features available at the <samp><span class="command">awk</span></samp>
program level.
-Having internationalization available at the <samp><span
class="command">awk</span></samp> level
-gives software developers additional flexibility—they are no
-longer required to write in C when internationalization is
-a requirement.
-
-<ul class="menu">
-<li><a accesskey="1" href="#I18N-and-L10N">I18N and L10N</a>:
Internationalization and Localization.
-<li><a accesskey="2" href="#Explaining-gettext">Explaining gettext</a>:
How GNU <code>gettext</code> works.
-<li><a accesskey="3" href="#Programmer-i18n">Programmer i18n</a>:
Features for the programmer.
-<li><a accesskey="4" href="#Translator-i18n">Translator i18n</a>:
Features for the translator.
-<li><a accesskey="5" href="#I18N-Example">I18N Example</a>: A
simple i18n example.
-<li><a accesskey="6" href="#Gawk-I18N">Gawk I18N</a>:
<samp><span class="command">gawk</span></samp> is also internationalized.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="I18N-and-L10N"></a>Next: <a rel="next" accesskey="n"
href="#Explaining-gettext">Explaining gettext</a>,
-Up: <a rel="up" accesskey="u"
href="#Internationalization">Internationalization</a>
-<br>
-</div>
-
-<h3 class="section">9.1 Internationalization and Localization</h3>
-
-<p><a name="index-internationalization-1303"></a><a
name="index-localization_002c-See-internationalization_0040comma_007b_007d-localization-1304"></a><a
name="index-localization-1305"></a><dfn>Internationalization</dfn> means
writing (or modifying) a program once,
-in such a way that it can use multiple languages without requiring
-further source-code changes.
-<dfn>Localization</dfn> means providing the data necessary for an
-internationalized program to work in a particular language.
-Most typically, these terms refer to features such as the language
-used for printing error messages, the language used to read
-responses, and information related to how numerical and
-monetary values are printed and read.
-
-<div class="node">
-<p><hr>
-<a name="Explaining-gettext"></a>Next: <a rel="next" accesskey="n"
href="#Programmer-i18n">Programmer i18n</a>,
-Previous: <a rel="previous" accesskey="p" href="#I18N-and-L10N">I18N and
L10N</a>,
-Up: <a rel="up" accesskey="u"
href="#Internationalization">Internationalization</a>
-<br>
-</div>
-
-<h3 class="section">9.2 GNU <code>gettext</code></h3>
-
-<p><a name="index-internationalizing-a-program-1306"></a><!-- STARTOFRANGE
gettex -->
-<a name="index-_0040code_007bgettext_007d-library-1307"></a>The facilities in
GNU <code>gettext</code> focus on messages; strings printed
-by a program, either directly or via formatting with <code>printf</code> or
-<code>sprintf</code>.<a rel="footnote" href="#fn-44"
name="fnd-44"><sup>44</sup></a>
-
- <p><a
name="index-portability_002c-_0040code_007bgettext_007d-library-and-1308"></a>When
using GNU <code>gettext</code>, each application has its own
-<dfn>text domain</dfn>. This is a unique name, such as `<samp><span
class="samp">kpilot</span></samp>' or `<samp><span
class="samp">gawk</span></samp>',
-that identifies the application.
-A complete application may have multiple components—programs written
-in C or C++, as well as scripts written in <samp><span
class="command">sh</span></samp> or <samp><span
class="command">awk</span></samp>.
-All of the components use the same text domain.
-
- <p>To make the discussion concrete, assume we're writing an application
-named <samp><span class="command">guide</span></samp>. Internationalization
consists of the
-following steps, in this order:
-
- <ol type=1 start=1>
-<li>The programmer goes
-through the source for all of <samp><span
class="command">guide</span></samp>'s components
-and marks each string that is a candidate for translation.
-For example, <code>"`-F': option required"</code> is a good candidate for
translation.
-A table with strings of option names is not (e.g., <samp><span
class="command">gawk</span></samp>'s
-<samp><span class="option">--profile</span></samp> option should remain the
same, no matter what the local
-language).
-
- <p><a
name="index-_0040code_007btextdomain_007d-function-_0028C-library_0029-1309"></a><li>The
programmer indicates the application's text domain
-(<code>"guide"</code>) to the <code>gettext</code> library,
-by calling the <code>textdomain</code> function.
-
- <li>Messages from the application are extracted from the source code and
-collected into a portable object file (<samp><span
class="file">guide.po</span></samp>),
-which lists the strings and their translations.
-The translations are initially empty.
-The original (usually English) messages serve as the key for
-lookup of the translations.
-
- <p><a name="index-_0040code_007b_002epo_007d-files-1310"></a><a
name="index-files_002c-_0040code_007b_002epo_007d-1311"></a><a
name="index-portable-object-files-1312"></a><a
name="index-files_002c-portable-object-1313"></a><li>For each language with a
translator, <samp><span class="file">guide.po</span></samp>
-is copied and translations are created and shipped with the application.
-
- <p><a name="index-_0040code_007b_002emo_007d-files-1314"></a><a
name="index-files_002c-_0040code_007b_002emo_007d-1315"></a><a
name="index-message-object-files-1316"></a><a
name="index-files_002c-message-object-1317"></a><li>Each language's <samp><span
class="file">.po</span></samp> file is converted into a binary
-message object (<samp><span class="file">.mo</span></samp>) file.
-A message object file contains the original messages and their
-translations in a binary format that allows fast lookup of translations
-at runtime.
-
- <li>When <samp><span class="command">guide</span></samp> is built and
installed, the binary translation files
-are installed in a standard place.
-
- <p><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028C-library_0029-1318"></a><li>For
testing and development, it is possible to tell <code>gettext</code>
-to use <samp><span class="file">.mo</span></samp> files in a different
directory than the standard
-one by using the <code>bindtextdomain</code> function.
-
- <p><a
name="index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1319"></a><a
name="index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1320"></a><a
name="index-message-object-files_002c-specifying-directory-of-1321"></a><a
name="index-files_002c-message-object_002c-specifying-directory-of-1322"></a><li>At
runtime, <samp><span class="command">guide</span></samp> looks up each string
via a call
-to <code>gettext</code>. The returned string is the translated string
-if available, or the original string if not.
-
- <li>If necessary, it is possible to access messages from a different
-text domain than the one belonging to the application, without
-having to switch the application's default text domain back
-and forth.
- </ol>
-
- <p><a
name="index-_0040code_007bgettext_007d-function-_0028C-library_0029-1323"></a>In
C (or C++), the string marking and dynamic translation lookup
-are accomplished by wrapping each string in a call to <code>gettext</code>:
-
-<pre class="example"> printf(gettext("Don't Panic!\n"));
-</pre>
- <p>The tools that extract messages from source code pull out all
-strings enclosed in calls to <code>gettext</code>.
-
- <p><a
name="index-_0040code_007b_005f_007d-_0028underscore_0029_002c-_0040code_007b_005f_007d-C-macro-1324"></a><a
name="index-underscore-_0028_0040code_007b_005f_007d_0029_002c-_0040code_007b_005f_007d-C-macro-1325"></a>The
GNU <code>gettext</code> developers, recognizing that typing
-`<samp><span class="samp">gettext</span></samp>' over and over again is both
painful and ugly to look
-at, use the macro `<samp><span class="samp">_</span></samp>' (an underscore)
to make things easier:
-
-<pre class="example"> /* In the standard header file: */
- #define _(str) gettext(str)
-
- /* In the program text: */
- printf(_("Don't Panic!\n"));
-</pre>
- <p><a
name="index-internationalization_002c-localization_002c-locale-categories-1326"></a><a
name="index-_0040code_007bgettext_007d-library_002c-locale-categories-1327"></a><a
name="index-locale-categories-1328"></a>This reduces the typing overhead to
just three extra characters per string
-and is considerably easier to read as well.
-There are locale <dfn>categories</dfn>
-for different types of locale-related information.
-The defined locale categories that <code>gettext</code> knows about are:
-
-
-<a name="index-_0040code_007bLC_005fMESSAGES_007d-locale-category-1329"></a>
-<dl><dt><code>LC_MESSAGES</code><dd>Text messages. This is the default
category for <code>gettext</code>
-operations, but it is possible to supply a different one explicitly,
-if necessary. (It is almost never necessary to supply a different category.)
-
- <p><a name="index-sorting-characters-in-different-languages-1330"></a><a
name="index-_0040code_007bLC_005fCOLLATE_007d-locale-category-1331"></a><br><dt><code>LC_COLLATE</code><dd>Text-collation
information; i.e., how different characters
-and/or groups of characters sort in a given language.
-
- <p><a
name="index-_0040code_007bLC_005fCTYPE_007d-locale-category-1332"></a><br><dt><code>LC_CTYPE</code><dd>Character-type
information (alphabetic, digit, upper- or lowercase, and
-so on).
-This information is accessed via the
-POSIX character classes in regular expressions,
-such as <code>/[[:alnum:]]/</code>
-(see <a href="#Regexp-Operators">Regexp Operators</a>).
-
- <p><a name="index-monetary-information_002c-localization-1333"></a><a
name="index-currency-symbols_002c-localization-1334"></a><a
name="index-_0040code_007bLC_005fMONETARY_007d-locale-category-1335"></a><br><dt><code>LC_MONETARY</code><dd>Monetary
information, such as the currency symbol, and whether the
-symbol goes before or after a number.
-
- <p><a
name="index-_0040code_007bLC_005fNUMERIC_007d-locale-category-1336"></a><br><dt><code>LC_NUMERIC</code><dd>Numeric
information, such as which characters to use for the decimal
-point and the thousands separator.<a rel="footnote" href="#fn-45"
name="fnd-45"><sup>45</sup></a>
-
- <p><a
name="index-_0040code_007bLC_005fRESPONSE_007d-locale-category-1337"></a><br><dt><code>LC_RESPONSE</code><dd>Response
information, such as how “yes” and “no” appear in the
-local language, and possibly other information as well.
-
- <p><a name="index-time_002c-localization-and-1338"></a><a
name="index-dates_002c-information-related-to_0040comma_007b_007d-localization-1339"></a><a
name="index-_0040code_007bLC_005fTIME_007d-locale-category-1340"></a><br><dt><code>LC_TIME</code><dd>Time-
and date-related information, such as 12- or 24-hour clock, month printed
-before or after day in a date, local month abbreviations, and so on.
-
- <p><a
name="index-_0040code_007bLC_005fALL_007d-locale-category-1341"></a><br><dt><code>LC_ALL</code><dd>All
of the above. (Not too useful in the context of <code>gettext</code>.)
-</dl>
- <!-- ENDOFRANGE gettex -->
-
-<div class="node">
-<p><hr>
-<a name="Programmer-i18n"></a>Next: <a rel="next" accesskey="n"
href="#Translator-i18n">Translator i18n</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Explaining-gettext">Explaining gettext</a>,
-Up: <a rel="up" accesskey="u"
href="#Internationalization">Internationalization</a>
-<br>
-</div>
-
-<h3 class="section">9.3 Internationalizing <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<!-- STARTOFRANGE inap -->
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-internationalizing-1342"></a>
-<samp><span class="command">gawk</span></samp> provides the following
variables and functions for
-internationalization:
-
-
-<a name="index-_0040code_007bTEXTDOMAIN_007d-variable-1343"></a>
-<dl><dt><code>TEXTDOMAIN</code><dd>This variable indicates the application's
text domain.
-For compatibility with GNU <code>gettext</code>, the default
-value is <code>"messages"</code>.
-
- <p><a
name="index-internationalization_002c-localization_002c-marked-strings-1344"></a><a
name="index-strings_002c-for-localization-1345"></a><br><dt><code>_"your
message here"</code><dd>String constants marked with a leading underscore
-are candidates for translation at runtime.
-String constants without a leading underscore are not translated.
-
- <p><a
name="index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1346"></a><br><dt><code>dcgettext(</code><var>string</var>
<span class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This built-in function returns the
translation of <var>string</var> in
-text domain <var>domain</var> for locale category <var>category</var>.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p>If you supply a value for <var>category</var>, it must be a string
equal to
-one of the known locale categories described in
-the previous section.
-You must also supply a text domain. Use <code>TEXTDOMAIN</code> if
-you want to use the current domain.
-
- <p><strong>Caution:</strong> The order of arguments to the <samp><span
class="command">awk</span></samp> version
-of the <code>dcgettext</code> function is purposely different from the order
for
-the C version. The <samp><span class="command">awk</span></samp> version's
order was
-chosen to be simple and to allow for reasonable <samp><span
class="command">awk</span></samp>-style
-default arguments.
-
- <p><a
name="index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1347"></a><br><dt><code>dcngettext(</code><var>string1</var><code>,
</code><var>string2</var><code>, </code><var>number</var> <span
class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This built-in function returns the
plural form used for <var>number</var> of the
-translation of <var>string1</var> and <var>string2</var> in text domain
-<var>domain</var> for locale category <var>category</var>. <var>string1</var>
is the
-English singular variant of a message, and <var>string2</var> the English
plural
-variant of the same message.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p>The same remarks as for the <code>dcgettext</code> function apply.
-
- <p><a
name="index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1348"></a><a
name="index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1349"></a><a
name="index-message-object-files_002c-specifying-directory-of-1350"></a><a
name="index-files_002c-message-object_002c-specifying-directory-of-1351"></a><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1352"></a><br><dt><code>bindtextdomain(</code><var>directory</var>
<span class="roman">[</span><code>, </code><var>domain</var><span
class="roman">]</span><code>)</code><dd>This built-in function allows you to
specify the directory in which
-<code>gettext</code> looks for <samp><span class="file">.mo</span></samp>
files, in case they
-will not or cannot be placed in the standard locations
-(e.g., during testing).
-It returns the directory in which <var>domain</var> is “bound.”
-
- <p>The default <var>domain</var> is the value of <code>TEXTDOMAIN</code>.
-If <var>directory</var> is the null string (<code>""</code>), then
-<code>bindtextdomain</code> returns the current binding for the
-given <var>domain</var>.
-</dl>
-
- <p>To use these facilities in your <samp><span
class="command">awk</span></samp> program, follow the steps
-outlined in
-the previous section,
-like so:
-
- <ol type=1 start=1>
-<a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bTEXTDOMAIN_007d-variable-and-1353"></a><a
name="index-_0040code_007bTEXTDOMAIN_007d-variable_002c-_0040code_007bBEGIN_007d-pattern-and-1354"></a><li>Set
the variable <code>TEXTDOMAIN</code> to the text domain of
-your program. This is best done in a <code>BEGIN</code> rule
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>),
-or it can also be done via the <samp><span class="option">-v</span></samp>
command-line
-option (see <a href="#Options">Options</a>):
-
- <pre class="example"> BEGIN {
- TEXTDOMAIN = "guide"
- ...
- }
- </pre>
- <p><a
name="index-_0040code_007b_005f_007d-_0028underscore_0029_002c-translatable-string-1355"></a><a
name="index-underscore-_0028_0040code_007b_005f_007d_0029_002c-translatable-string-1356"></a><li>Mark
all translatable strings with a leading underscore (`<samp><span
class="samp">_</span></samp>')
-character. It <em>must</em> be adjacent to the opening
-quote of the string. For example:
-
- <pre class="example"> print _"hello, world"
- x = _"you goofed"
- printf(_"Number of users is %d\n", nusers)
- </pre>
- <li>If you are creating strings dynamically, you can
-still translate them, using the <code>dcgettext</code>
-built-in function:
-
- <pre class="example"> message = nusers " users logged in"
- message = dcgettext(message, "adminprog")
- print message
- </pre>
- <p>Here, the call to <code>dcgettext</code> supplies a different
-text domain (<code>"adminprog"</code>) in which to find the
-message, but it uses the default <code>"LC_MESSAGES"</code> category.
-
- <p><a
name="index-_0040code_007bLC_005fMESSAGES_007d-locale-category_002c-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1357"></a><li>During
development, you might want to put the <samp><span
class="file">.mo</span></samp>
-file in a private directory for testing. This is done
-with the <code>bindtextdomain</code> built-in function:
-
- <pre class="example"> BEGIN {
- TEXTDOMAIN = "guide" # our text domain
- if (Testing) {
- # where to find our files
- bindtextdomain("testdir")
- # joe is in charge of adminprog
- bindtextdomain("../joe/testdir", "adminprog")
- }
- ...
- }
- </pre>
- </ol>
-
- <p>See <a href="#I18N-Example">I18N Example</a>,
-for an example program showing the steps to create
-and use translations from <samp><span class="command">awk</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="Translator-i18n"></a>Next: <a rel="next" accesskey="n"
href="#I18N-Example">I18N Example</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Programmer-i18n">Programmer i18n</a>,
-Up: <a rel="up" accesskey="u"
href="#Internationalization">Internationalization</a>
-<br>
-</div>
-
-<h3 class="section">9.4 Translating <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<p><a name="index-_0040code_007b_002epo_007d-files-1358"></a><a
name="index-files_002c-_0040code_007b_002epo_007d-1359"></a><a
name="index-portable-object-files-1360"></a><a
name="index-files_002c-portable-object-1361"></a>Once a program's translatable
strings have been marked, they must
-be extracted to create the initial <samp><span class="file">.po</span></samp>
file.
-As part of translation, it is often helpful to rearrange the order
-in which arguments to <code>printf</code> are output.
-
- <p><samp><span class="command">gawk</span></samp>'s <samp><span
class="option">--gen-po</span></samp> command-line option extracts
-the messages and is discussed next.
-After that, <code>printf</code>'s ability to
-rearrange the order for <code>printf</code> arguments at runtime
-is covered.
-
-<ul class="menu">
-<li><a accesskey="1" href="#String-Extraction">String Extraction</a>:
Extracting marked strings.
-<li><a accesskey="2" href="#Printf-Ordering">Printf Ordering</a>:
Rearranging <code>printf</code> arguments.
-<li><a accesskey="3" href="#I18N-Portability">I18N Portability</a>:
<samp><span class="command">awk</span></samp>-level portability issues.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="String-Extraction"></a>Next: <a rel="next" accesskey="n"
href="#Printf-Ordering">Printf Ordering</a>,
-Up: <a rel="up" accesskey="u" href="#Translator-i18n">Translator i18n</a>
-<br>
-</div>
-
-<h4 class="subsection">9.4.1 Extracting Marked Strings</h4>
-
-<p><a name="index-strings_002c-extracting-1362"></a><a
name="index-marked-strings_0040comma_007b_007d-extracting-1363"></a><a
name="index-_0040code_007b_002d_002dgen_002dpo_007d-option-1364"></a><a
name="index-command_002dline-options_002c-string-extraction-1365"></a><a
name="index-string-extraction-_0028internationalization_0029-1366"></a><a
name="index-marked-string-extraction-_0028internationalization_0029-1367"></a><a
name="index-extraction_002c-of-marked-strings-_0028internationalization_0029-1368"></a>
-<a name="index-_0040code_007b_002d_002dgen_002dpo_007d-option-1369"></a>Once
your <samp><span class="command">awk</span></samp> program is working, and all
the strings have
-been marked and you've set (and perhaps bound) the text domain,
-it is time to produce translations.
-First, use the <samp><span class="option">--gen-po</span></samp> command-line
option to create
-the initial <samp><span class="file">.po</span></samp> file:
-
-<pre class="example"> $ gawk --gen-po -f guide.awk > guide.po
-</pre>
- <p><a name="index-_0040code_007bxgettext_007d-utility-1370"></a>When run
with <samp><span class="option">--gen-po</span></samp>, <samp><span
class="command">gawk</span></samp> does not execute your
-program. Instead, it parses it as usual and prints all marked strings
-to standard output in the format of a GNU <code>gettext</code> Portable Object
-file. Also included in the output are any constant strings that
-appear as the first argument to <code>dcgettext</code> or as the first and
-second argument to <code>dcngettext</code>.<a rel="footnote" href="#fn-46"
name="fnd-46"><sup>46</sup></a>
-See <a href="#I18N-Example">I18N Example</a>,
-for the full list of steps to go through to create and test
-translations for <samp><span class="command">guide</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="Printf-Ordering"></a>Next: <a rel="next" accesskey="n"
href="#I18N-Portability">I18N Portability</a>,
-Previous: <a rel="previous" accesskey="p"
href="#String-Extraction">String Extraction</a>,
-Up: <a rel="up" accesskey="u" href="#Translator-i18n">Translator i18n</a>
-<br>
-</div>
-
-<h4 class="subsection">9.4.2 Rearranging <code>printf</code> Arguments</h4>
-
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-1371"></a><a
name="index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement-1372"></a>Format
strings for <code>printf</code> and <code>sprintf</code>
-(see <a href="#Printf">Printf</a>)
-present a special problem for translation.
-Consider the following:<a rel="footnote" href="#fn-47"
name="fnd-47"><sup>47</sup></a>
-
-<!-- line broken here only for smallbook format -->
-<pre class="example"> printf(_"String `%s' has %d characters\n",
- string, length(string)))
-</pre>
- <p>A possible German translation for this might be:
-
-<pre class="example"> "%d Zeichen lang ist die Zeichenkette `%s'\n"
-</pre>
- <p>The problem should be obvious: the order of the format
-specifications is different from the original!
-Even though <code>gettext</code> can return the translated string
-at runtime,
-it cannot change the argument order in the call to <code>printf</code>.
-
- <p>To solve this problem, <code>printf</code> format specificiers may have
-an additional optional element, which we call a <dfn>positional
specifier</dfn>.
-For example:
-
-<pre class="example"> "%2$d Zeichen lang ist die Zeichenkette `%1$s'\n"
-</pre>
- <p>Here, the positional specifier consists of an integer count, which
indicates which
-argument to use, and a `<samp><span class="samp">$</span></samp>'. Counts are
one-based, and the
-format string itself is <em>not</em> included. Thus, in the following
-example, `<samp><span class="samp">string</span></samp>' is the first argument
and `<samp><span class="samp">length(string)</span></samp>' is the second:
-
-<pre class="example"> $ gawk 'BEGIN {
- > string = "Dont Panic"
- > printf _"%2$d characters live in \"%1$s\"\n",
- > string, length(string)
- > }'
- -| 10 characters live in "Dont Panic"
-</pre>
- <p>If present, positional specifiers come first in the format specification,
-before the flags, the field width, and/or the precision.
-
- <p>Positional specifiers can be used with the dynamic field width and
-precision capability:
-
-<pre class="example"> $ gawk 'BEGIN {
- > printf("%*.*s\n", 10, 20, "hello")
- > printf("%3$*2$.*1$s\n", 20, 10, "hello")
- > }'
- -| hello
- -| hello
-</pre>
- <blockquote>
-<b>NOTE:</b> When using `<samp><span class="samp">*</span></samp>' with a
positional specifier, the `<samp><span class="samp">*</span></samp>'
-comes first, then the integer position, and then the `<samp><span
class="samp">$</span></samp>'.
-This is somewhat counterintutive.
-</blockquote>
-
- <p><a
name="index-_0040code_007bprintf_007d-statement_002c-positional-specifiers_002c-mixing-with-regular-formats-1373"></a><a
name="index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement_002c-mixing-with-regular-formats-1374"></a><a
name="index-format-specifiers_002c-mixing-regular-with-positional-specifiers-1375"></a><samp><span
class="command">gawk</span></samp> does not allow you to mix regular format
specifiers
-and those with positional specifiers in the same string:
-
-<pre class="smallexample"> $ gawk 'BEGIN { printf _"%d %3$s\n", 1, 2, "hi"
}'
- error--> gawk: cmd. line:1: fatal: must use `count$' on all formats or
none
-</pre>
- <blockquote>
-<b>NOTE:</b> There are some pathological cases that <samp><span
class="command">gawk</span></samp> may fail to
-diagnose. In such cases, the output may not be what you expect.
-It's still a bad idea to try mixing them, even if <samp><span
class="command">gawk</span></samp>
-doesn't detect it.
-</blockquote>
-
- <p>Although positional specifiers can be used directly in <samp><span
class="command">awk</span></samp> programs,
-their primary purpose is to help in producing correct translations of
-format strings into languages different from the one in which the program
-is first written.
-
-<div class="node">
-<p><hr>
-<a name="I18N-Portability"></a>Previous: <a rel="previous" accesskey="p"
href="#Printf-Ordering">Printf Ordering</a>,
-Up: <a rel="up" accesskey="u" href="#Translator-i18n">Translator i18n</a>
-<br>
-</div>
-
-<h4 class="subsection">9.4.3 <samp><span class="command">awk</span></samp>
Portability Issues</h4>
-
-<p><a name="index-portability_002c-internationalization-and-1376"></a><a
name="index-internationalization_002c-localization_002c-portability-and-1377"></a><samp><span
class="command">gawk</span></samp>'s internationalization features were
purposely chosen to
-have as little impact as possible on the portability of <samp><span
class="command">awk</span></samp>
-programs that use them to other versions of <samp><span
class="command">awk</span></samp>.
-Consider this program:
-
-<pre class="example"> BEGIN {
- TEXTDOMAIN = "guide"
- if (Test_Guide) # set with -v
- bindtextdomain("/test/guide/messages")
- print _"don't panic!"
- }
-</pre>
- <p class="noindent">As written, it won't work on other versions of
<samp><span class="command">awk</span></samp>.
-However, it is actually almost portable, requiring very little
-change:
-
-
-<a
name="index-_0040code_007bTEXTDOMAIN_007d-variable_002c-portability-and-1378"></a>
-<ul><li>Assignments to <code>TEXTDOMAIN</code> won't have any effect,
-since <code>TEXTDOMAIN</code> is not special in other <samp><span
class="command">awk</span></samp> implementations.
-
- <li>Non-GNU versions of <samp><span class="command">awk</span></samp>
treat marked strings
-as the concatenation of a variable named <code>_</code> with the string
-following it.<a rel="footnote" href="#fn-48" name="fnd-48"><sup>48</sup></a>
Typically, the variable <code>_</code> has
-the null string (<code>""</code>) as its value, leaving the original string
constant as
-the result.
-
- <li>By defining “dummy” functions to replace
<code>dcgettext</code>, <code>dcngettext</code>
-and <code>bindtextdomain</code>, the <samp><span
class="command">awk</span></samp> program can be made to run, but
-all the messages are output in the original language.
-For example:
-
- <p><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1379"></a><a
name="index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1380"></a><a
name="index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1381"></a>
- <pre class="example"> <!-- file eg/lib/libintl.awk -->
- function bindtextdomain(dir, domain)
- {
- return dir
- }
-
- function dcgettext(string, domain, category)
- {
- return string
- }
-
- function dcngettext(string1, string2, number, domain, category)
- {
- return (number == 1 ? string1 : string2)
- }
- <!-- endfile -->
- </pre>
- <li>The use of positional specifications in <code>printf</code> or
-<code>sprintf</code> is <em>not</em> portable.
-To support <code>gettext</code> at the C level, many systems' C versions of
-<code>sprintf</code> do support positional specifiers. But it works only if
-enough arguments are supplied in the function call. Many versions of
-<samp><span class="command">awk</span></samp> pass <code>printf</code> formats
and arguments unchanged to the
-underlying C library version of <code>sprintf</code>, but only one format and
-argument at a time. What happens if a positional specification is
-used is anybody's guess.
-However, since the positional specifications are primarily for use in
-<em>translated</em> format strings, and since non-GNU <samp><span
class="command">awk</span></samp>s never
-retrieve the translated string, this should not be a problem in practice.
-</ul>
- <!-- ENDOFRANGE inap -->
-
-<div class="node">
-<p><hr>
-<a name="I18N-Example"></a>Next: <a rel="next" accesskey="n"
href="#Gawk-I18N">Gawk I18N</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Translator-i18n">Translator i18n</a>,
-Up: <a rel="up" accesskey="u"
href="#Internationalization">Internationalization</a>
-<br>
-</div>
-
-<h3 class="section">9.5 A Simple Internationalization Example</h3>
-
-<p>Now let's look at a step-by-step example of how to internationalize and
-localize a simple <samp><span class="command">awk</span></samp> program, using
<samp><span class="file">guide.awk</span></samp> as our
-original source:
-
-<pre class="example"> <!-- file eg/prog/guide.awk -->
- BEGIN {
- TEXTDOMAIN = "guide"
- bindtextdomain(".") # for testing
- print _"Don't Panic"
- print _"The Answer Is", 42
- print "Pardon me, Zaphod who?"
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">Run `<samp><span class="samp">gawk
--gen-po</span></samp>' to create the <samp><span
class="file">.po</span></samp> file:
-
-<pre class="example"> $ gawk --gen-po -f guide.awk > guide.po
-</pre>
- <p class="noindent">This produces:
-
-<pre class="example"> <!-- file eg/data/guide.po -->
- #: guide.awk:4
- msgid "Don't Panic"
- msgstr ""
-
- #: guide.awk:5
- msgid "The Answer Is"
- msgstr ""
-
- <!-- endfile -->
-</pre>
- <p>This original portable object file is saved and reused for each language
-into which the application is translated. The <code>msgid</code>
-is the original string and the <code>msgstr</code> is the translation.
-
- <blockquote>
-<b>NOTE:</b> Strings not marked with a leading underscore do not
-appear in the <samp><span class="file">guide.po</span></samp> file.
-</blockquote>
-
- <p>Next, the messages must be translated.
-Here is a translation to a hypothetical dialect of English,
-called “Mellow”:<a rel="footnote" href="#fn-49"
name="fnd-49"><sup>49</sup></a>
-
-<pre class="example"> $ cp guide.po guide-mellow.po
- <var>Add translations to</var> guide-mellow.po ...
-</pre>
- <p class="noindent">Following are the translations:
-
-<pre class="example"> <!-- file eg/data/guide-mellow.po -->
- #: guide.awk:4
- msgid "Don't Panic"
- msgstr "Hey man, relax!"
-
- #: guide.awk:5
- msgid "The Answer Is"
- msgstr "Like, the scoop is"
-
- <!-- endfile -->
-</pre>
- <p><a name="index-Linux-1382"></a><a
name="index-GNU_002fLinux-1383"></a>The next step is to make the directory to
hold the binary message object
-file and then to create the <samp><span class="file">guide.mo</span></samp>
file.
-The directory layout shown here is standard for GNU <code>gettext</code> on
-GNU/Linux systems. Other versions of <code>gettext</code> may use a different
-layout:
-
-<pre class="example"> $ mkdir en_US en_US/LC_MESSAGES
-</pre>
- <p><a
name="index-_0040code_007b_002epo_007d-files_002c-converting-to-_0040code_007b_002emo_007d-1384"></a><a
name="index-files_002c-_0040code_007b_002epo_007d_002c-converting-to-_0040code_007b_002emo_007d-1385"></a><a
name="index-_0040code_007b_002emo_007d-files_002c-converting-from-_0040code_007b_002epo_007d-1386"></a><a
name="index-files_002c-_0040code_007b_002emo_007d_002c-converting-from-_0040code_007b_002epo_007d-1387"></a><a
name="index-portable-object-files_002c-converting-to-message-object-files-1388"></a><a
name="index-files_002c-portable-object_002c-converting-to-message-object-files-1389"></a><a
name="index-message-object-files_002c-converting-from-portable-object-files-1390"></a><a
name="index-files_002c-message-object_002c-converting-from-portable-object-files-1391"></a><a
name="index-_0040command_007bmsgfmt_007d-utility-1392"></a>The <samp><span
class="command">msgfmt</span></samp> utility does the conversion from
human-readable
-<samp><span class="file">.po</span></samp> file to machine-readable
<samp><span class="file">.mo</span></samp> file.
-By default, <samp><span class="command">msgfmt</span></samp> creates a file
named <samp><span class="file">messages</span></samp>.
-This file must be renamed and placed in the proper directory so that
-<samp><span class="command">gawk</span></samp> can find it:
-
-<pre class="example"> $ msgfmt guide-mellow.po
- $ mv messages en_US/LC_MESSAGES/guide.mo
-</pre>
- <p>Finally, we run the program to test it:
-
-<pre class="example"> $ gawk -f guide.awk
- -| Hey man, relax!
- -| Like, the scoop is 42
- -| Pardon me, Zaphod who?
-</pre>
- <p>If the three replacement functions for <code>dcgettext</code>,
<code>dcngettext</code>
-and <code>bindtextdomain</code>
-(see <a href="#I18N-Portability">I18N Portability</a>)
-are in a file named <samp><span class="file">libintl.awk</span></samp>,
-then we can run <samp><span class="file">guide.awk</span></samp> unchanged as
follows:
-
-<pre class="example"> $ gawk --posix -f guide.awk -f libintl.awk
- -| Don't Panic
- -| The Answer Is 42
- -| Pardon me, Zaphod who?
-</pre>
- <div class="node">
-<p><hr>
-<a name="Gawk-I18N"></a>Previous: <a rel="previous" accesskey="p"
href="#I18N-Example">I18N Example</a>,
-Up: <a rel="up" accesskey="u"
href="#Internationalization">Internationalization</a>
-<br>
-</div>
-
-<h3 class="section">9.6 <samp><span class="command">gawk</span></samp> Can
Speak Your Language</h3>
-
-<p>As of version 3.1, <samp><span class="command">gawk</span></samp> itself
has been internationalized
-using the GNU <code>gettext</code> package.
-(GNU <code>gettext</code> is described in
-complete detail in
-<cite>GNU gettext tools</cite>.)
-As of this writing, the latest version of GNU <code>gettext</code> is
-<a href="ftp://ftp.gnu.org/gnu/gettext/gettext-0.11.5.tar.gz">version
0.11.5</a>.
-
- <p>If a translation of <samp><span class="command">gawk</span></samp>'s
messages exists,
-then <samp><span class="command">gawk</span></samp> produces usage messages,
warnings,
-and fatal errors in the local language.
-
- <p><a
name="index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1393"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1394"></a>On
systems that do not use version 2 (or later) of the GNU C library, you should
-configure <samp><span class="command">gawk</span></samp> with the <samp><span
class="option">--with-included-gettext</span></samp> option
-before compiling and installing it.
-See <a href="#Additional-Configuration-Options">Additional Configuration
Options</a>,
-for more information.
-<!-- ENDOFRANGE inloc -->
-
-<div class="node">
-<p><hr>
-<a name="Advanced-Features"></a>Next: <a rel="next" accesskey="n"
href="#Invoking-Gawk">Invoking Gawk</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Internationalization">Internationalization</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">10 Advanced Features of <samp><span
class="command">gawk</span></samp></h2>
-
-<p><a
name="index-advanced-features_002c-network-connections_002c-See-Also-networks_002c-connections-1395"></a><!--
STARTOFRANGE gawadv -->
-<a
name="index-_0040command_007bgawk_007d_002c-features_002c-advanced-1396"></a><!--
STARTOFRANGE advgaw -->
-<a
name="index-advanced-features_002c-_0040command_007bgawk_007d-1397"></a><blockquote>
-<i>Write documentation as if whoever reads it is
-a violent psychopath who knows where you live.</i><br>
-Steve English, as quoted by Peter Langston
-</blockquote>
-
- <p>This chapter discusses advanced features in <samp><span
class="command">gawk</span></samp>.
-It's a bit of a “grab bag” of items that are otherwise unrelated
-to each other.
-First, a command-line option allows <samp><span
class="command">gawk</span></samp> to recognize
-nondecimal numbers in input data, not just in <samp><span
class="command">awk</span></samp>
-programs. Next, two-way I/O, discussed briefly in earlier parts of this
-Web page, is described in full detail, along with the basics
-of TCP/IP networking and BSD portal files. Finally, <samp><span
class="command">gawk</span></samp>
-can <dfn>profile</dfn> an <samp><span class="command">awk</span></samp>
program, making it possible to tune
-it for performance.
-
- <p><a href="#Dynamic-Extensions">Dynamic Extensions</a>,
-discusses the ability to dynamically add new built-in functions to
-<samp><span class="command">gawk</span></samp>. As this feature is still
immature and likely to change,
-its description is relegated to an appendix.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Nondecimal-Data">Nondecimal Data</a>:
Allowing nondecimal input data.
-<li><a accesskey="2" href="#Two_002dway-I_002fO">Two-way I/O</a>:
Two-way communications with another process.
-<li><a accesskey="3" href="#TCP_002fIP-Networking">TCP/IP Networking</a>:
Using <samp><span class="command">gawk</span></samp> for network
programming.
-<li><a accesskey="4" href="#Portal-Files">Portal Files</a>:
Using <samp><span class="command">gawk</span></samp> with BSD portals.
-<li><a accesskey="5" href="#Profiling">Profiling</a>:
Profiling your <samp><span class="command">awk</span></samp> programs.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Nondecimal-Data"></a>Next: <a rel="next" accesskey="n"
href="#Two_002dway-I_002fO">Two-way I/O</a>,
-Up: <a rel="up" accesskey="u" href="#Advanced-Features">Advanced
Features</a>
-<br>
-</div>
-
-<h3 class="section">10.1 Allowing Nondecimal Input Data</h3>
-
-<p><a
name="index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1398"></a><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-nondecimal-input-data-1399"></a><a
name="index-input_002c-data_0040comma_007b_007d-nondecimal-1400"></a><a
name="index-constants_002c-nondecimal-1401"></a>
-If you run <samp><span class="command">gawk</span></samp> with the <samp><span
class="option">--non-decimal-data</span></samp> option,
-you can have nondecimal constants in your input data:
-
-<!-- line break here for small book format -->
-<pre class="example"> $ echo 0123 123 0x123 |
- > gawk --non-decimal-data '{ printf "%d, %d, %d\n",
- > $1, $2, $3 }'
- -| 83, 123, 291
-</pre>
- <p>For this feature to work, write your program so that
-<samp><span class="command">gawk</span></samp> treats your data as numeric:
-
-<pre class="example"> $ echo 0123 123 0x123 | gawk '{ print $1, $2, $3 }'
- -| 0123 123 0x123
-</pre>
- <p class="noindent">The <code>print</code> statement treats its expressions
as strings.
-Although the fields can act as numbers when necessary,
-they are still strings, so <code>print</code> does not try to treat them
-numerically. You may need to add zero to a field to force it to
-be treated as a number. For example:
-
-<pre class="example"> $ echo 0123 123 0x123 | gawk --non-decimal-data '
- > { print $1, $2, $3
- > print $1 + 0, $2 + 0, $3 + 0 }'
- -| 0123 123 0x123
- -| 83 123 291
-</pre>
- <p>Because it is common to have decimal data with leading zeros, and because
-using it could lead to surprising results, the default is to leave this
-facility disabled. If you want it, you must explicitly request it.
-
- <p><a
name="index-programming-conventions_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1402"></a><a
name="index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option_002c-_0040code_007bstrtonum_007d-function-and-1403"></a><a
name="index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-and-1404"></a><strong>Caution:</strong>
-<em>Use of this option is not recommended.</em>
-It can break old programs very badly.
-Instead, use the <code>strtonum</code> function to convert your data
-(see <a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>).
-This makes your programs easier to write and easier to read, and
-leads to less surprising results.
-
-<div class="node">
-<p><hr>
-<a name="Two_002dway-I_002fO"></a>Next: <a rel="next" accesskey="n"
href="#TCP_002fIP-Networking">TCP/IP Networking</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Nondecimal-Data">Nondecimal Data</a>,
-Up: <a rel="up" accesskey="u" href="#Advanced-Features">Advanced
Features</a>
-<br>
-</div>
-
-<h3 class="section">10.2 Two-Way Communications with Another Process</h3>
-
-<p><a name="index-Brennan_002c-Michael-1405"></a><a
name="index-programmers_002c-attractiveness-of-1406"></a>
-<pre class="smallexample"> <!-- Path:
cssun.mathcs.emory.edu!gatech!newsxfer3.itd.umich.edu!news-peer.sprintlink.net!news-sea-19.sprintlink.net!news-in-west.sprintlink.net!news.sprintlink.net!Sprint!204.94.52.5!news.whidbey.com!brennan
-->
- From: address@hidden (Mike Brennan)
- Newsgroups: comp.lang.awk
- Subject: Re: Learn the SECRET to Attract Women Easily
- Date: 4 Aug 1997 17:34:46 GMT
- <!-- Organization: WhidbeyNet -->
- <!-- Lines: 12 -->
- Message-ID: <address@hidden>
- <!-- References: <address@hidden> -->
- <!-- Reply-To: address@hidden -->
- <!-- NNTP-Posting-Host: asn202.whidbey.com -->
- <!-- X-Newsreader: slrn (0.9.4.1 Unix) -->
- <!-- Xref: cssun.mathcs.emory.edu comp.lang.awk:5403 -->
-
- On 3 Aug 1997 13:17:43 GMT, Want More Dates???
- <address@hidden> wrote:
- >Learn the SECRET to Attract Women Easily
- >
- >The SCENT(tm) Pheromone Sex Attractant For Men to Attract Women
-
- The scent of awk programmers is a lot more attractive to women than
- the scent of perl programmers.
- --
- Mike Brennan
- <!-- brennan@@whidbey.com -->
-</pre>
- <p><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-processes_0040comma_007b_007d-communicating-with-1407"></a><a
name="index-processes_002c-two_002dway-communications-with-1408"></a>It is
often useful to be able to
-send data to a separate program for
-processing and then read the result. This can always be
-done with temporary files:
-
-<pre class="example"> # write the data for processing
- tempfile = ("mydata." PROCINFO["pid"])
- while (<var>not done with data</var>)
- print <var>data</var> | ("subprogram > " tempfile)
- close("subprogram > " tempfile)
-
- # read the results, remove tempfile when done
- while ((getline newdata < tempfile) > 0)
- <var>process</var> newdata <var>appropriately</var>
- close(tempfile)
- system("rm " tempfile)
-</pre>
- <p class="noindent">This works, but not elegantly. Among other things, it
requires that
-the program be run in a directory that cannot be shared among users;
-for example, <samp><span class="file">/tmp</span></samp> will not do, as
another user might happen
-to be using a temporary file with the same name.
-
- <p><a name="index-coprocesses-1409"></a><a
name="index-input_002foutput_002c-two_002dway-1410"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-1411"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-I_002fO-operator-_0028I_002fO_0029-1412"></a><a
name="index-_0040command_007bcsh_007d-utility_002c-_0040code_007b_007c_0026_007d-operator_002c-comparison-with-1413"></a>Starting
with version 3.1 of <samp><span class="command">gawk</span></samp>, it is
possible to
-open a <em>two-way</em> pipe to another process. The second process is
-termed a <dfn>coprocess</dfn>, since it runs in parallel with <samp><span
class="command">gawk</span></samp>.
-The two-way connection is created using the new `<samp><span
class="samp">|&</span></samp>' operator
-(borrowed from the Korn shell, <samp><span
class="command">ksh</span></samp>):<a rel="footnote" href="#fn-50"
name="fnd-50"><sup>50</sup></a>
-
-<pre class="example"> do {
- print <var>data</var> |& "subprogram"
- "subprogram" |& getline results
- } while (<var>data left to process</var>)
- close("subprogram")
-</pre>
- <p>The first time an I/O operation is executed using the `<samp><span
class="samp">|&</span></samp>'
-operator, <samp><span class="command">gawk</span></samp> creates a two-way
pipeline to a child process
-that runs the other program. Output created with <code>print</code>
-or <code>printf</code> is written to the program's standard input, and
-output from the program's standard output can be read by the <samp><span
class="command">gawk</span></samp>
-program using <code>getline</code>.
-As is the case with processes started by `<samp><span
class="samp">|</span></samp>', the subprogram
-can be any program, or pipeline of programs, that can be started by
-the shell.
-
- <p>There are some cautionary items to be aware of:
-
- <ul>
-<li>As the code inside <samp><span class="command">gawk</span></samp>
currently stands, the coprocess's
-standard error goes to the same place that the parent <samp><span
class="command">gawk</span></samp>'s
-standard error goes. It is not possible to read the child's
-standard error separately.
-
- <p><a name="index-deadlocks-1414"></a><a
name="index-buffering_002c-input_002foutput-1415"></a><a
name="index-_0040code_007bgetline_007d-command_002c-deadlock-and-1416"></a><li>I/O
buffering may be a problem. <samp><span class="command">gawk</span></samp>
automatically
-flushes all output down the pipe to the child process.
-However, if the coprocess does not flush its output,
-<samp><span class="command">gawk</span></samp> may hang when doing a
<code>getline</code> in order to read
-the coprocess's results. This could lead to a situation
-known as <dfn>deadlock</dfn>, where each process is waiting for the
-other one to do something.
-</ul>
-
- <p><a
name="index-_0040code_007bclose_007d-function_002c-two_002dway-pipes-and-1417"></a>It
is possible to close just one end of the two-way pipe to
-a coprocess, by supplying a second argument to the <code>close</code>
-function of either <code>"to"</code> or <code>"from"</code>
-(see <a href="#Close-Files-And-Pipes">Close Files And Pipes</a>).
-These strings tell <samp><span class="command">gawk</span></samp> to close the
end of the pipe
-that sends data to the process or the end that reads from it,
-respectively.
-
- <p><a
name="index-_0040command_007bsort_007d-utility_002c-coprocesses-and-1418"></a>This
is particularly necessary in order to use
-the system <samp><span class="command">sort</span></samp> utility as part of a
coprocess;
-<samp><span class="command">sort</span></samp> must read <em>all</em> of its
input
-data before it can produce any output.
-The <samp><span class="command">sort</span></samp> program does not receive an
end-of-file indication
-until <samp><span class="command">gawk</span></samp> closes the write end of
the pipe.
-
- <p>When you have finished writing data to the <samp><span
class="command">sort</span></samp>
-utility, you can close the <code>"to"</code> end of the pipe, and
-then start reading sorted data via <code>getline</code>.
-For example:
-
-<pre class="example"> BEGIN {
- command = "LC_ALL=C sort"
- n = split("abcdefghijklmnopqrstuvwxyz", a, "")
-
- for (i = n; i > 0; i--)
- print a[i] |& command
- close(command, "to")
-
- while ((command |& getline line) > 0)
- print "got", line
- close(command)
- }
-</pre>
- <p>This program writes the letters of the alphabet in reverse order, one
-per line, down the two-way pipe to <samp><span
class="command">sort</span></samp>. It then closes the
-write end of the pipe, so that <samp><span class="command">sort</span></samp>
receives an end-of-file
-indication. This causes <samp><span class="command">sort</span></samp> to
sort the data and write the
-sorted data back to the <samp><span class="command">gawk</span></samp>
program. Once all of the data
-has been read, <samp><span class="command">gawk</span></samp> terminates the
coprocess and exits.
-
- <p>As a side note, the assignment `<samp><span
class="samp">LC_ALL=C</span></samp>' in the <samp><span
class="command">sort</span></samp>
-command ensures traditional Unix (ASCII) sorting from <samp><span
class="command">sort</span></samp>.
-
- <p>Beginning with <samp><span class="command">gawk</span></samp> 3.1.2, you
may use Pseudo-ttys (ptys) for
-two-way communication instead of pipes, if your system supports them.
-This is done on a per-command basis, by setting a special element
-in the <code>PROCINFO</code> array
-(see <a href="#Auto_002dset">Auto-set</a>),
-like so:
-
-<pre class="example"> command = "sort -nr" # command, saved in
variable for convenience
- PROCINFO[command, "pty"] = 1 # update PROCINFO
- print ... |& command # start two-way pipe
- ...
-</pre>
- <p class="noindent">Using ptys avoids the buffer deadlock issues described
earlier, at some
-loss in performance. If your system does not have ptys, or if all the
-system's ptys are in use, <samp><span class="command">gawk</span></samp>
automatically falls back to
-using regular pipes.
-
-<div class="node">
-<p><hr>
-<a name="TCP_002fIP-Networking"></a>Next: <a rel="next" accesskey="n"
href="#Portal-Files">Portal Files</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Two_002dway-I_002fO">Two-way I/O</a>,
-Up: <a rel="up" accesskey="u" href="#Advanced-Features">Advanced
Features</a>
-<br>
-</div>
-
-<h3 class="section">10.3 Using <samp><span class="command">gawk</span></samp>
for Network Programming</h3>
-
-<p><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-network-programming-1419"></a><a
name="index-networks_002c-programming-1420"></a><!-- STARTOFRANGE tcpip -->
-<a name="index-TCP_002fIP-1421"></a><a
name="index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-1422"></a><a
name="index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-1423"></a><a
name="index-_0040code_007bEMISTERED_007d-1424"></a><blockquote>
-<code>EMISTERED</code>: <i>A host is a host from coast to coast,<br>
-and no-one can talk to host that's close,<br>
-unless the host that isn't close<br>
-is busy hung or dead.</i>
-</blockquote>
-
- <p>In addition to being able to open a two-way pipeline to a coprocess
-on the same system
-(see <a href="#Two_002dway-I_002fO">Two-way I/O</a>),
-it is possible to make a two-way connection to
-another process on another system across an IP networking connection.
-
- <p>You can think of this as just a <em>very long</em> two-way pipeline to
-a coprocess.
-The way <samp><span class="command">gawk</span></samp> decides that you want
to use TCP/IP networking is
-by recognizing special file names that begin with `<samp><span
class="samp">/inet/</span></samp>'.
-
- <p>The full syntax of the special file name is
-<samp><span class="file">/inet/</span><var>protocol</var><span
class="file">/</span><var>local-port</var><span
class="file">/</span><var>remote-host</var><span
class="file">/</span><var>remote-port</var></samp>.
-The components are:
-
- <dl>
-<dt><var>protocol</var><dd>The protocol to use over IP. This must be either
`<samp><span class="samp">tcp</span></samp>',
-`<samp><span class="samp">udp</span></samp>', or `<samp><span
class="samp">raw</span></samp>', for a TCP, UDP, or raw IP connection,
-respectively. The use of TCP is recommended for most applications.
-
- <p><a name="index-raw-sockets-1425"></a><a
name="index-sockets-1426"></a><strong>Caution:</strong> The use of raw sockets
is not currently supported
-in version 3.1 of <samp><span class="command">gawk</span></samp>.
-
- <br><dt><var>local-port</var><dd><a
name="index-_0040code_007bgetservbyname_007d-function-_0028C-library_0029-1427"></a>The
local TCP or UDP port number to use. Use a port number of `<samp><span
class="samp">0</span></samp>'
-when you want the system to pick a port. This is what you should do
-when writing a TCP or UDP client.
-You may also use a well-known service name, such as `<samp><span
class="samp">smtp</span></samp>'
-or `<samp><span class="samp">http</span></samp>', in which case <samp><span
class="command">gawk</span></samp> attempts to determine
-the predefined port number using the C <code>getservbyname</code> function.
-
- <br><dt><var>remote-host</var><dd>The IP address or fully-qualified
domain name of the Internet
-host to which you want to connect.
-
- <br><dt><var>remote-port</var><dd>The TCP or UDP port number to use on
the given <var>remote-host</var>.
-Again, use `<samp><span class="samp">0</span></samp>' if you don't care, or
else a well-known
-service name.
-</dl>
-
- <p>Consider the following very simple example:
-
-<pre class="example"> BEGIN {
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
- }
-</pre>
- <p>This program reads the current date and time from the local system's
-TCP `<samp><span class="samp">daytime</span></samp>' server.
-It then prints the results and closes the connection.
-
- <p>Because this topic is extensive, the use of <samp><span
class="command">gawk</span></samp> for
-TCP/IP programming is documented separately.
-See <cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>,
-which comes as part of the <samp><span class="command">gawk</span></samp>
distribution,
-for a much more complete introduction and discussion, as well as
-extensive examples.
-
-<div class="node">
-<p><hr>
-<a name="Portal-Files"></a>Next: <a rel="next" accesskey="n"
href="#Profiling">Profiling</a>,
-Previous: <a rel="previous" accesskey="p"
href="#TCP_002fIP-Networking">TCP/IP Networking</a>,
-Up: <a rel="up" accesskey="u" href="#Advanced-Features">Advanced
Features</a>
-<br>
-</div>
-
-<h3 class="section">10.4 Using <samp><span class="command">gawk</span></samp>
with BSD Portals</h3>
-
-<p><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-BSD-portals-1428"></a><a
name="index-portal-files-1429"></a><a
name="index-files_002c-portal-1430"></a><a name="index-BSD-portals-1431"></a><a
name="index-_0040code_007b_002fp_007d-files-_0028_0040command_007bgawk_007d_0029-1432"></a><a
name="index-files_002c-_0040code_007b_002fp_007d-_0028_0040command_007bgawk_007d_0029-1433"></a><a
name="index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1434"></a><a
name="index-operating-systems_002c-BSD_002dbased-1435"></a>
-Similar to the <samp><span class="file">/inet</span></samp> special files, if
<samp><span class="command">gawk</span></samp>
-is configured with the <samp><span
class="option">--enable-portals</span></samp> option
-(see <a href="#Quick-Installation">Quick Installation</a>),
-then <samp><span class="command">gawk</span></samp> treats
-files whose pathnames begin with <code>/p</code> as 4.4 BSD-style portals.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1436"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1437"></a>When
used with the `<samp><span class="samp">|&</span></samp>' operator,
<samp><span class="command">gawk</span></samp> opens the file
-for two-way communications. The operating system's portal mechanism
-then manages creating the process associated with the portal and
-the corresponding communications with the portal's process.
-<!-- ENDOFRANGE tcpip -->
-
-<div class="node">
-<p><hr>
-<a name="Profiling"></a>Previous: <a rel="previous" accesskey="p"
href="#Portal-Files">Portal Files</a>,
-Up: <a rel="up" accesskey="u" href="#Advanced-Features">Advanced
Features</a>
-<br>
-</div>
-
-<h3 class="section">10.5 Profiling Your <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<!-- STARTOFRANGE awkp -->
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-profiling-1438"></a><!--
STARTOFRANGE proawk -->
-<a name="index-profiling-_0040command_007bawk_007d-programs-1439"></a><!--
STARTOFRANGE pgawk -->
-<a name="index-_0040command_007bpgawk_007d-program-1440"></a><a
name="index-profiling-_0040command_007bgawk_007d_002c-See-_0040command_007bpgawk_007d-program-1441"></a>
-Beginning with version 3.1 of <samp><span class="command">gawk</span></samp>,
you may produce execution
-traces of your <samp><span class="command">awk</span></samp> programs.
-This is done with a specially compiled version of <samp><span
class="command">gawk</span></samp>,
-called <samp><span class="command">pgawk</span></samp> (“profiling
<samp><span class="command">gawk</span></samp>”).
-
- <p><a name="index-_0040code_007bawkprof_002eout_007d-file-1442"></a><a
name="index-files_002c-_0040code_007bawkprof_002eout_007d-1443"></a><a
name="index-_0040command_007bpgawk_007d-program_002c-_0040code_007bawkprof_002eout_007d-file-1444"></a><samp><span
class="command">pgawk</span></samp> is identical in every way to <samp><span
class="command">gawk</span></samp>, except that when
-it has finished running, it creates a profile of your program in a file
-named <samp><span class="file">awkprof.out</span></samp>.
-Because it is profiling, it also executes up to 45% slower than
-<samp><span class="command">gawk</span></samp> normally does.
-
- <p><a name="index-_0040code_007b_002d_002dprofile_007d-option-1445"></a>As
shown in the following example,
-the <samp><span class="option">--profile</span></samp> option can be used to
change the name of the file
-where <samp><span class="command">pgawk</span></samp> will write the profile:
-
-<pre class="example"> $ pgawk --profile=myprog.prof -f myprog.awk data1
data2
-</pre>
- <p class="noindent">In the above example, <samp><span
class="command">pgawk</span></samp> places the profile in
-<samp><span class="file">myprog.prof</span></samp> instead of in <samp><span
class="file">awkprof.out</span></samp>.
-
- <p>Regular <samp><span class="command">gawk</span></samp> also accepts this
option. When called with just
-<samp><span class="option">--profile</span></samp>, <samp><span
class="command">gawk</span></samp> “pretty prints” the program into
-<samp><span class="file">awkprof.out</span></samp>, without any execution
counts. You may supply an
-option to <samp><span class="option">--profile</span></samp> to change the
file name. Here is a sample
-session showing a simple <samp><span class="command">awk</span></samp>
program, its input data, and the
-results from running <samp><span class="command">pgawk</span></samp>. First,
the <samp><span class="command">awk</span></samp> program:
-
-<pre class="example"> BEGIN { print "First BEGIN rule" }
-
- END { print "First END rule" }
-
- /foo/ {
- print "matched /foo/, gosh"
- for (i = 1; i <= 3; i++)
- sing()
- }
-
- {
- if (/foo/)
- print "if is true"
- else
- print "else is true"
- }
-
- BEGIN { print "Second BEGIN rule" }
-
- END { print "Second END rule" }
-
- function sing( dummy)
- {
- print "I gotta be me!"
- }
-</pre>
- <p>Following is the input data:
-
-<pre class="example"> foo
- bar
- baz
- foo
- junk
-</pre>
- <p>Here is the <samp><span class="file">awkprof.out</span></samp> that
results from running <samp><span class="command">pgawk</span></samp>
-on this program and data (this example also illustrates that <samp><span
class="command">awk</span></samp>
-programmers sometimes have to work late):
-
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040command_007bpgawk_007d-program-1446"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040command_007bpgawk_007d-program-1447"></a>
-<pre class="example"> # gawk profile, created Sun Aug 13 00:00:15
2000
-
- # BEGIN block(s)
-
- BEGIN {
- 1 print "First BEGIN rule"
- 1 print "Second BEGIN rule"
- }
-
- # Rule(s)
-
- 5 /foo/ { # 2
- 2 print "matched /foo/, gosh"
- 6 for (i = 1; i <= 3; i++) {
- 6 sing()
- }
- }
-
- 5 {
- 5 if (/foo/) { # 2
- 2 print "if is true"
- 3 } else {
- 3 print "else is true"
- }
- }
-
- # END block(s)
-
- END {
- 1 print "First END rule"
- 1 print "Second END rule"
- }
-
- # Functions, listed alphabetically
-
- 6 function sing(dummy)
- {
- 6 print "I gotta be me!"
- }
-</pre>
- <p>This example illustrates many of the basic rules for profiling output.
-The rules are as follows:
-
- <ul>
-<li>The program is printed in the order <code>BEGIN</code> rule,
-pattern/action rules, <code>END</code> rule and functions, listed
-alphabetically.
-Multiple <code>BEGIN</code> and <code>END</code> rules are merged together.
-
- <p><a name="index-patterns_002c-counts-1448"></a><li>Pattern-action rules
have two counts.
-The first count, to the left of the rule, shows how many times
-the rule's pattern was <em>tested</em>.
-The second count, to the right of the rule's opening left brace
-in a comment,
-shows how many times the rule's action was <em>executed</em>.
-The difference between the two indicates how many times the rule's
-pattern evaluated to false.
-
- <li>Similarly,
-the count for an <code>if</code>-<code>else</code> statement shows how many
times
-the condition was tested.
-To the right of the opening left brace for the <code>if</code>'s body
-is a count showing how many times the condition was true.
-The count for the <code>else</code>
-indicates how many times the test failed.
-
- <p><a name="index-loops_002c-count-for-header-1449"></a><li>The count for
a loop header (such as <code>for</code>
-or <code>while</code>) shows how many times the loop test was executed.
-(Because of this, you can't just look at the count on the first
-statement in a rule to determine how many times the rule was executed.
-If the first statement is a loop, the count is misleading.)
-
- <p><a
name="index-functions_002c-user_002ddefined_002c-counts-1450"></a><a
name="index-user_002ddefined_002c-functions_002c-counts-1451"></a><li>For
user-defined functions, the count next to the <code>function</code>
-keyword indicates how many times the function was called.
-The counts next to the statements in the body show how many times
-those statements were executed.
-
- <p><a
name="index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-_0040command_007bpgawk_007d-program-1452"></a><a
name="index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-_0040command_007bpgawk_007d-program-1453"></a><li>The
layout uses “K&R” style with tabs.
-Braces are used everywhere, even when
-the body of an <code>if</code>, <code>else</code>, or loop is only a single
statement.
-
- <p><a
name="index-_0040code_007b_0028_0029_007d-_0028parentheses_0029_002c-_0040command_007bpgawk_007d-program-1454"></a><a
name="index-parentheses-_0040code_007b_0028_0029_007d_002c-_0040command_007bpgawk_007d-program-1455"></a><li>Parentheses
are used only where needed, as indicated by the structure
-of the program and the precedence rules.
-<!-- extra verbiage here satisfies the copyeditor. ugh. -->
-For example, `<samp><span class="samp">(3 + 5) * 4</span></samp>' means add
three plus five, then multiply
-the total by four. However, `<samp><span class="samp">3 + 5 *
4</span></samp>' has no parentheses, and
-means `<samp><span class="samp">3 + (5 * 4)</span></samp>'.
-
- <li>All string concatenations are parenthesized too.
-(This could be made a bit smarter.)
-
- <li>Parentheses are used around the arguments to <code>print</code>
-and <code>printf</code> only when
-the <code>print</code> or <code>printf</code> statement is followed by a
redirection.
-Similarly, if
-the target of a redirection isn't a scalar, it gets parenthesized.
-
- <li><samp><span class="command">pgawk</span></samp> supplies leading
comments in
-front of the <code>BEGIN</code> and <code>END</code> rules,
-the pattern/action rules, and the functions.
-
- </ul>
-
- <p>The profiled version of your program may not look exactly like what you
-typed when you wrote it. This is because <samp><span
class="command">pgawk</span></samp> creates the
-profiled version by “pretty printing” its internal representation
of
-the program. The advantage to this is that <samp><span
class="command">pgawk</span></samp> can produce
-a standard representation. The disadvantage is that all source-code
-comments are lost, as are the distinctions among multiple <code>BEGIN</code>
-and <code>END</code> rules. Also, things such as:
-
-<pre class="example"> /foo/
-</pre>
- <p class="noindent">come out as:
-
-<pre class="example"> /foo/ {
- print $0
- }
-</pre>
- <p class="noindent">which is correct, but possibly surprising.
-
- <p><a
name="index-profiling-_0040command_007bawk_007d-programs_002c-dynamically-1456"></a><a
name="index-_0040command_007bpgawk_007d-program_002c-dynamic-profiling-1457"></a>Besides
creating profiles when a program has completed,
-<samp><span class="command">pgawk</span></samp> can produce a profile while it
is running.
-This is useful if your <samp><span class="command">awk</span></samp> program
goes into an
-infinite loop and you want to see what has been executed.
-To use this feature, run <samp><span class="command">pgawk</span></samp> in
the background:
-
-<pre class="example"> $ pgawk -f myprog &
- [1] 13992
-</pre>
- <p><a
name="index-_0040command_007bkill_007d-command_0040comma_007b_007d-dynamic-profiling-1458"></a><a
name="index-_0040code_007bUSR1_007d-signal-1459"></a><a
name="index-signals_002c-_0040code_007bUSR1_007d_002f_0040code_007bSIGUSR1_007d-1460"></a>The
shell prints a job number and process ID number; in this case, 13992.
-Use the <samp><span class="command">kill</span></samp> command to send the
<code>USR1</code> signal
-to <samp><span class="command">pgawk</span></samp>:
-
-<pre class="example"> $ kill -USR1 13992
-</pre>
- <p class="noindent">As usual, the profiled version of the program is
written to
-<samp><span class="file">awkprof.out</span></samp>, or to a different file if
you use the <samp><span class="option">--profile</span></samp>
-option.
-
- <p>Along with the regular profile, as shown earlier, the profile
-includes a trace of any active functions:
-
-<pre class="example"> # Function Call Stack:
-
- # 3. baz
- # 2. bar
- # 1. foo
- # -- main --
-</pre>
- <p>You may send <samp><span class="command">pgawk</span></samp> the
<code>USR1</code> signal as many times as you like.
-Each time, the profile and function call trace are appended to the output
-profile file.
-
- <p><a name="index-_0040code_007bHUP_007d-signal-1461"></a><a
name="index-signals_002c-_0040code_007bHUP_007d_002f_0040code_007bSIGHUP_007d-1462"></a>If
you use the <code>HUP</code> signal instead of the <code>USR1</code> signal,
-<samp><span class="command">pgawk</span></samp> produces the profile and the
function call trace and then exits.
-
- <p><a
name="index-_0040code_007bINT_007d-signal-_0028MS_002dDOS_0029-1463"></a><a
name="index-signals_002c-_0040code_007bINT_007d_002f_0040code_007bSIGINT_007d-_0028MS_002dDOS_0029-1464"></a><a
name="index-_0040code_007bQUIT_007d-signal-_0028MS_002dDOS_0029-1465"></a><a
name="index-signals_002c-_0040code_007bQUIT_007d_002f_0040code_007bSIGQUIT_007d-_0028MS_002dDOS_0029-1466"></a>When
<samp><span class="command">pgawk</span></samp> runs on MS-DOS or MS-Windows,
it uses the
-<code>INT</code> and <code>QUIT</code> signals for producing the profile and,
in
-the case of the <code>INT</code> signal, <samp><span
class="command">pgawk</span></samp> exits. This is
-because these systems don't support the <samp><span
class="command">kill</span></samp> command, so the
-only signals you can deliver to a program are those generated by the
-keyboard. The <code>INT</code> signal is generated by the
-<kbd>Ctrl-<C></kbd> or <kbd>Ctrl-<BREAK></kbd> key, while the
-<code>QUIT</code> signal is generated by the <kbd>Ctrl-<\></kbd> key.
-<!-- ENDOFRANGE advgaw -->
-<!-- ENDOFRANGE gawadv -->
-<!-- ENDOFRANGE pgawk -->
-<!-- ENDOFRANGE awkp -->
-<!-- ENDOFRANGE proawk -->
-
-<div class="node">
-<p><hr>
-<a name="Invoking-Gawk"></a>Next: <a rel="next" accesskey="n"
href="#Library-Functions">Library Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Advanced-Features">Advanced Features</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">11 Running <samp><span class="command">awk</span></samp>
and <samp><span class="command">gawk</span></samp></h2>
-
-<p>This chapter covers how to run awk, both POSIX-standard
-and <samp><span class="command">gawk</span></samp>-specific command-line
options, and what
-<samp><span class="command">awk</span></samp> and
-<samp><span class="command">gawk</span></samp> do with non-option arguments.
-It then proceeds to cover how <samp><span class="command">gawk</span></samp>
searches for source files,
-obsolete options and/or features, and known bugs in <samp><span
class="command">gawk</span></samp>.
-This chapter rounds out the discussion of <samp><span
class="command">awk</span></samp>
-as a program and as a language.
-
- <p>While a number of the options and features described here were
-discussed in passing earlier in the book, this chapter provides the
-full details.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Command-Line">Command Line</a>:
How to run <samp><span class="command">awk</span></samp>.
-<li><a accesskey="2" href="#Options">Options</a>:
Command-line options and their meanings.
-<li><a accesskey="3" href="#Other-Arguments">Other Arguments</a>:
Input file names and variable assignments.
-<li><a accesskey="4" href="#AWKPATH-Variable">AWKPATH Variable</a>:
Searching directories for <samp><span class="command">awk</span></samp>
- programs.
-<li><a accesskey="5" href="#Obsolete">Obsolete</a>:
Obsolete Options and/or features.
-<li><a accesskey="6" href="#Undocumented">Undocumented</a>:
Undocumented Options and Features.
-<li><a accesskey="7" href="#Known-Bugs">Known Bugs</a>:
Known Bugs in <samp><span class="command">gawk</span></samp>.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Command-Line"></a>Next: <a rel="next" accesskey="n"
href="#Options">Options</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.1 Invoking <samp><span
class="command">awk</span></samp></h3>
-
-<p><a
name="index-command-line_002c-invoking-_0040command_007bawk_007d-from-1467"></a><a
name="index-_0040command_007bawk_007d_002c-invoking-1468"></a><a
name="index-arguments_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1469"></a><a
name="index-options_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1470"></a>
-There are two ways to run <samp><span
class="command">awk</span></samp>—with an explicit program or with
-one or more program files. Here are templates for both of them; items
-enclosed in [<small class="dots">...</small>] in these templates are optional:
-
-<pre class="example"> awk <span
class="roman">[</span><var>options</var><span class="roman">]</span> -f
progfile <span class="roman">[</span><code>--</code><span
class="roman">]</span> <var>file</var> ...
- awk <span class="roman">[</span><var>options</var><span
class="roman">]</span> <span class="roman">[</span><code>--</code><span
class="roman">]</span> '<var>program</var>' <var>file</var> ...
-</pre>
- <p><a name="index-GNU-long-options-1471"></a><a
name="index-long-options-1472"></a><a
name="index-options_002c-long-1473"></a>Besides traditional one-letter
POSIX-style options, <samp><span class="command">gawk</span></samp> also
-supports GNU long options.
-
- <p><a
name="index-dark-corner_002c-invoking-_0040command_007bawk_007d-1474"></a><a
name="index-lint-checking_002c-empty-programs-1475"></a>It is possible to
invoke <samp><span class="command">awk</span></samp> with an empty program:
-
-<pre class="example"> awk '' datafile1 datafile2
-</pre>
- <p><a name="index-_0040code_007b_002d_002dlint_007d-option-1476"></a>Doing
so makes little sense, though; <samp><span class="command">awk</span></samp>
exits
-silently when given an empty program.
-(d.c.)
-If <samp><span class="option">--lint</span></samp> has
-been specified on the command line, <samp><span
class="command">gawk</span></samp> issues a
-warning that the program is empty.
-
-<div class="node">
-<p><hr>
-<a name="Options"></a>Next: <a rel="next" accesskey="n"
href="#Other-Arguments">Other Arguments</a>,
-Previous: <a rel="previous" accesskey="p" href="#Command-Line">Command
Line</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.2 Command-Line Options</h3>
-
-<!-- STARTOFRANGE ocl -->
-<p><a name="index-options_002c-command_002dline-1477"></a><!-- STARTOFRANGE
clo -->
-<a name="index-command-line_002c-options-1478"></a><!-- STARTOFRANGE gnulo -->
-<a name="index-GNU-long-options-1479"></a><!-- STARTOFRANGE longo -->
-<a name="index-options_002c-long-1480"></a>
-Options begin with a dash and consist of a single character.
-GNU-style long options consist of two dashes and a keyword.
-The keyword can be abbreviated, as long as the abbreviation allows the option
-to be uniquely identified. If the option takes an argument, then the
-keyword is either immediately followed by an equals sign (`<samp><span
class="samp">=</span></samp>') and the
-argument's value, or the keyword and the argument's value are separated
-by whitespace.
-If a particular option with a value is given more than once, it is the
-last value that counts.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-GNU-long-options-and-1481"></a>Each
long option for <samp><span class="command">gawk</span></samp> has a
corresponding
-POSIX-style option.
-The long and short options are
-interchangeable in all contexts.
-The options and their meanings are as follows:
-
- <dl>
-<dt><code>-F </code><var>fs</var><dt><code>--field-separator
</code><var>fs</var><dd><a
name="index-_0040code_007b_002dF_007d-option-1482"></a><a
name="index-_0040code_007b_002d_002dfield_002dseparator_007d-option-1483"></a><a
name="index-_0040code_007bFS_007d-variable_002c-_0040code_007b_002d_002dfield_002dseparator_007d-option-and-1484"></a>Sets
the <code>FS</code> variable to <var>fs</var>
-(see <a href="#Field-Separators">Field Separators</a>).
-
- <br><dt><code>-f </code><var>source-file</var><dt><code>--file
</code><var>source-file</var><dd><a
name="index-_0040code_007b_002df_007d-option-1485"></a><a
name="index-_0040code_007b_002d_002dfile_007d-option-1486"></a><a
name="index-_0040command_007bawk_007d-programs_002c-location-of-1487"></a>Indicates
that the <samp><span class="command">awk</span></samp> program is to be found
in <var>source-file</var>
-instead of in the first non-option argument.
-
- <br><dt><code>-v
</code><var>var</var><code>=</code><var>val</var><dt><code>--assign
</code><var>var</var><code>=</code><var>val</var><dd><a
name="index-_0040code_007b_002dv_007d-option-1488"></a><a
name="index-_0040code_007b_002d_002dassign_007d-option-1489"></a><a
name="index-variables_002c-setting-1490"></a>Sets the variable <var>var</var>
to the value <var>val</var> <em>before</em>
-execution of the program begins. Such variable values are available
-inside the <code>BEGIN</code> rule
-(see <a href="#Other-Arguments">Other Arguments</a>).
-
- <p>The <samp><span class="option">-v</span></samp> option can only set
one variable, but it can be used
-more than once, setting another variable each time, like this:
-`<samp><span class="samp">awk -v foo=1<!-- /@w --> -v bar=2<!-- /@w
--> ...</span></samp>'.
-
- <p><a
name="index-built_002din-variables_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1491"></a><a
name="index-variables_002c-built_002din_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1492"></a><strong>Caution:</strong>
Using <samp><span class="option">-v</span></samp> to set the values of the
built-in
-variables may lead to surprising results. <samp><span
class="command">awk</span></samp> will reset the
-values of those variables as it needs to, possibly ignoring any
-predefined value you may have given.
-
- <br><dt><code>-mf </code><var>N</var><dt><code>-mr
</code><var>N</var><dd><a
name="index-_0040code_007b_002dmf_007d_002f_0040code_007b_002dmr_007d-options-1493"></a><a
name="index-memory_002c-setting-limits-1494"></a>Sets various memory limits to
the value <var>N</var>. The `<samp><span class="samp">f</span></samp>' flag
sets
-the maximum number of fields and the `<samp><span
class="samp">r</span></samp>' flag sets the maximum
-record size. These two flags and the <samp><span
class="option">-m</span></samp> option are from the
-Bell Laboratories research version of Unix <samp><span
class="command">awk</span></samp>. They are provided
-for compatibility but otherwise ignored by
-<samp><span class="command">gawk</span></samp>, since <samp><span
class="command">gawk</span></samp> has no predefined limits.
-(The Bell Laboratories <samp><span class="command">awk</span></samp> no longer
needs these options;
-it continues to accept them to avoid breaking old programs.)
-
- <br><dt><code>-W </code><var>gawk-opt</var><dd><a
name="index-_0040code_007b_002dW_007d-option-1495"></a>Following the POSIX
standard, implementation-specific
-options are supplied as arguments to the <samp><span
class="option">-W</span></samp> option. These options
-also have corresponding GNU-style long options.
-Note that the long options may be abbreviated, as long as
-the abbreviations remain unique.
-The full list of <samp><span class="command">gawk</span></samp>-specific
options is provided next.
-
- <br><dt><code>--</code><dd><a
name="index-command-line_002c-options_002c-end-of-1496"></a><a
name="index-options_002c-command_002dline_002c-end-of-1497"></a>Signals the end
of the command-line options. The following arguments
-are not treated as options even if they begin with `<samp><span
class="samp">-</span></samp>'. This
-interpretation of <samp><span class="option">--</span></samp> follows the
POSIX argument parsing
-conventions.
-
- <p><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-filenames-beginning-with-1498"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-filenames-beginning-with-1499"></a>This
is useful if you have file names that start with `<samp><span
class="samp">-</span></samp>',
-or in shell scripts, if you have file names that will be specified
-by the user that could start with `<samp><span class="samp">-</span></samp>'.
-</dl>
- <!-- ENDOFRANGE gnulo -->
-<!-- ENDOFRANGE longo -->
-
- <p>The previous list described options mandated by the POSIX standard,
-as well as options available in the Bell Laboratories version of <samp><span
class="command">awk</span></samp>.
-The following list describes <samp><span
class="command">gawk</span></samp>-specific options:
-
- <dl>
-<dt><code>-W compat</code><dt><code>-W
traditional</code><dt><code>--compat</code><dt><code>--traditional</code><dd><a
name="index-_0040code_007b_002d_002dcompat_007d-option-1500"></a><a
name="index-_0040code_007b_002d_002dtraditional_007d-option-1501"></a><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-specifying-1502"></a>Specifies
<dfn>compatibility mode</dfn>, in which the GNU extensions to
-the <samp><span class="command">awk</span></samp> language are disabled, so
that <samp><span class="command">gawk</span></samp> behaves just
-like the Bell Laboratories research version of Unix <samp><span
class="command">awk</span></samp>.
-<samp><span class="option">--traditional</span></samp> is the preferred form
of this option.
-See <a href="#POSIX_002fGNU">POSIX/GNU</a>,
-which summarizes the extensions. Also see
-<a href="#Compatibility-Mode">Compatibility Mode</a>.
-
- <br><dt><code>-W copyright</code><dt><code>--copyright</code><dd><a
name="index-_0040code_007b_002d_002dcopyright_007d-option-1503"></a><a
name="index-GPL-_0028General-Public-License_0029_002c-printing-1504"></a>Print
the short version of the General Public License and then exit.
-
- <br><dt><code>-W copyleft</code><dt><code>--copyleft</code><dd><a
name="index-_0040code_007b_002d_002dcopyleft_007d-option-1505"></a>Just like
<samp><span class="option">--copyright</span></samp>.
-This option may disappear in a future version of <samp><span
class="command">gawk</span></samp>.
-
- <p><a
name="index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1506"></a><a
name="index-_0040code_007bawkvars_002eout_007d-file-1507"></a><a
name="index-files_002c-_0040code_007bawkvars_002eout_007d-1508"></a><a
name="index-variables_002c-global_002c-printing-list-of-1509"></a><br><dt><code>-W
dump-variables</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dt><code>--dump-variables</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dd>Prints a sorted list of global variables, their
types, and final values
-to <var>file</var>. If no <var>file</var> is provided, <samp><span
class="command">gawk</span></samp> prints this
-list to the file named <samp><span class="file">awkvars.out</span></samp> in
the current directory.
-
- <p><a
name="index-troubleshooting_002c-typographical-errors_0040comma_007b_007d-global-variables-1510"></a>Having
a list of all global variables is a good way to look for
-typographical errors in your programs.
-You would also use this option if you have a large program with a lot of
-functions, and you want to be sure that your functions don't
-inadvertently use global variables that you meant to be local.
-(This is a particularly easy mistake to make with simple variable
-names like <code>i</code>, <code>j</code>, etc.)
-
- <br><dt><code>-W gen-po</code><dt><code>--gen-po</code><dd><a
name="index-_0040code_007b_002d_002dgen_002dpo_007d-option-1511"></a><a
name="index-portable-object-files_002c-generating-1512"></a><a
name="index-files_002c-portable-object_002c-generating-1513"></a>Analyzes the
source program and
-generates a GNU <code>gettext</code> Portable Object file on standard
-output for all string constants that have been marked for translation.
-See <a href="#Internationalization">Internationalization</a>,
-for information about this option.
-
- <br><dt><code>-W help</code><dt><code>-W
usage</code><dt><code>--help</code><dt><code>--usage</code><dd><a
name="index-_0040code_007b_002d_002dhelp_007d-option-1514"></a><a
name="index-_0040code_007b_002d_002dusage_007d-option-1515"></a><a
name="index-GNU-long-options_002c-printing-list-of-1516"></a><a
name="index-options_002c-printing-list-of-1517"></a><a
name="index-printing_002c-list-of-options-1518"></a>Prints a
“usage” message summarizing the short and long style options
-that <samp><span class="command">gawk</span></samp> accepts and then exit.
-
- <br><dt><code>-W lint</code><span
class="roman">[</span><code>=fatal</code><span
class="roman">]</span><dt><code>--lint</code><span
class="roman">[</span><code>=fatal</code><span class="roman">]</span><dd><a
name="index-_0040code_007b_002d_002dlint_007d-option-1519"></a><a
name="index-lint-checking_002c-issuing-warnings-1520"></a><a
name="index-warnings_002c-issuing-1521"></a>Warns about constructs that are
dubious or nonportable to
-other <samp><span class="command">awk</span></samp> implementations.
-Some warnings are issued when <samp><span class="command">gawk</span></samp>
first reads your program. Others
-are issued at runtime, as your program executes.
-With an optional argument of `<samp><span class="samp">fatal</span></samp>',
-lint warnings become fatal errors.
-This may be drastic, but its use will certainly encourage the
-development of cleaner <samp><span class="command">awk</span></samp> programs.
-With an optional argument of `<samp><span class="samp">invalid</span></samp>',
only warnings about things that are
-actually invalid are issued. (This is not fully implemented yet.)
-
- <br><dt><code>-W lint-old</code><dt><code>--lint-old</code><dd><a
name="index-_0040code_007b_002d_002dlint_002dold_007d-option-1522"></a>Warns
about constructs that are not available in the original version of
-<samp><span class="command">awk</span></samp> from Version 7 Unix
-(see <a href="#V7_002fSVR3_002e1">V7/SVR3.1</a>).
-
- <br><dt><code>-W
non-decimal-data</code><dt><code>--non-decimal-data</code><dd><a
name="index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1523"></a><a
name="index-hexadecimal-values_0040comma_007b_007d-enabling-interpretation-of-1524"></a><a
name="index-octal-values_0040comma_007b_007d-enabling-interpretation-of-1525"></a>Enable
automatic interpretation of octal and hexadecimal
-values in input data
-(see <a href="#Nondecimal-Data">Nondecimal Data</a>).
-
- <p><a
name="index-troubleshooting_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1526"></a><strong>Caution:</strong>
This option can severely break old programs.
-Use with care.
-
- <br><dt><code>-W posix</code><dt><code>--posix</code><dd><a
name="index-_0040code_007b_002d_002dposix_007d-option-1527"></a><a
name="index-POSIX-mode-1528"></a><a
name="index-_0040command_007bgawk_007d_002c-extensions_0040comma_007b_007d-disabling-1529"></a>Operates
in strict POSIX mode. This disables all <samp><span
class="command">gawk</span></samp>
-extensions (just like <samp><span class="option">--traditional</span></samp>)
and adds the following additional
-restrictions:
-
- <!-- IMPORTANT! Keep this list in sync with the one in node POSIX -->
-
-<a name="index-escape-sequences_002c-unrecognized-1530"></a>
-<ul><li><code>\x</code> escape sequences are not recognized
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-
- <p><a name="index-newlines-1531"></a><a
name="index-whitespace_002c-newlines-as-1532"></a><li>Newlines do not act as
whitespace to separate fields when <code>FS</code> is
-equal to a single space
-(see <a href="#Fields">Fields</a>).
-
- <li>Newlines are not allowed after `<samp><span
class="samp">?</span></samp>' or `<samp><span class="samp">:</span></samp>'
-(see <a href="#Conditional-Exp">Conditional Exp</a>).
-
- <li>The synonym <code>func</code> for the keyword
<code>function</code> is not
-recognized (see <a href="#Definition-Syntax">Definition Syntax</a>).
-
- <p><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-1533"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-1534"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1535"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1536"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-1537"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-1538"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-1539"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-1540"></a><li>The
`<samp><span class="samp">**</span></samp>' and `<samp><span
class="samp">**=</span></samp>' operators cannot be used in
-place of `<samp><span class="samp">^</span></samp>' and `<samp><span
class="samp">^=</span></samp>' (see <a href="#Arithmetic-Ops">Arithmetic
Ops</a>,
-and also see <a href="#Assignment-Ops">Assignment Ops</a>).
-
- <p><a
name="index-_0040code_007bFS_007d-variable_002c-as-TAB-character-1541"></a><li>Specifying
`<samp><span class="samp">-Ft</span></samp>' on the command-line does not set
the value
-of <code>FS</code> to be a single TAB character
-(see <a href="#Field-Separators">Field Separators</a>).
-
- <p><a
name="index-_0040code_007bfflush_007d-function_0040comma_007b_007d-unsupported-1542"></a><li>The
<code>fflush</code> built-in function is not supported
-(see <a href="#I_002fO-Functions">I/O Functions</a>).
-</ul>
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a
name="index-_0040code_007b_002d_002dtraditional_007d-option_002c-_0040code_007b_002d_002dposix_007d-option-and-1543"></a><a
name="index-_0040code_007b_002d_002dposix_007d-option_002c-_0040code_007b_002d_002dtraditional_007d-option-and-1544"></a>If
you supply both <samp><span class="option">--traditional</span></samp> and
<samp><span class="option">--posix</span></samp> on the
-command line, <samp><span class="option">--posix</span></samp> takes
precedence. <samp><span class="command">gawk</span></samp>
-also issues a warning if both options are supplied.
-
- <br><dt><code>-W profile</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dt><code>--profile</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dd><a
name="index-_0040code_007b_002d_002dprofile_007d-option-1545"></a><a
name="index-_0040command_007bawk_007d-programs_002c-profiling_002c-enabling-1546"></a>Enable
profiling of <samp><span class="command">awk</span></samp> programs
-(see <a href="#Profiling">Profiling</a>).
-By default, profiles are created in a file named <samp><span
class="file">awkprof.out</span></samp>.
-The optional <var>file</var> argument allows you to specify a different
-file name for the profile file.
-
- <p>When run with <samp><span class="command">gawk</span></samp>, the
profile is just a “pretty printed” version
-of the program. When run with <samp><span
class="command">pgawk</span></samp>, the profile contains execution
-counts for each statement in the program in the left margin, and function
-call counts for each function.
-
- <br><dt><code>-W re-interval</code><dt><code>--re-interval</code><dd><a
name="index-_0040code_007b_002d_002dre_002dinterval_007d-option-1547"></a><a
name="index-regular-expressions_002c-interval-expressions-and-1548"></a>Allows
interval expressions
-(see <a href="#Regexp-Operators">Regexp Operators</a>)
-in regexps.
-Because interval expressions were traditionally not available in <samp><span
class="command">awk</span></samp>,
-<samp><span class="command">gawk</span></samp> does not provide them by
default. This prevents old <samp><span class="command">awk</span></samp>
-programs from breaking.
-
- <br><dt><code>-W source </code><var>program-text</var><dt><code>--source
</code><var>program-text</var><dd><a
name="index-_0040code_007b_002d_002dsource_007d-option-1549"></a><a
name="index-source-code_002c-mixing-1550"></a>Allows you to mix source code in
files with source
-code that you enter on the command line.
-Program source code is taken from the <var>program-text</var>.
-This is particularly useful
-when you have library functions that you want to use from your command-line
-programs (see <a href="#AWKPATH-Variable">AWKPATH Variable</a>).
-
- <br><dt><code>-W version</code><dt><code>--version</code><dd><a
name="index-_0040code_007b_002d_002dversion_007d-option-1551"></a><a
name="index-_0040command_007bgawk_007d_002c-versions-of_002c-information-about_0040comma_007b_007d-printing-1552"></a>Prints
version information for this particular copy of <samp><span
class="command">gawk</span></samp>.
-This allows you to determine if your copy of <samp><span
class="command">gawk</span></samp> is up to date
-with respect to whatever the Free Software Foundation is currently
-distributing.
-It is also useful for bug reports
-(see <a href="#Bugs">Bugs</a>).
-</dl>
-
- <p>As long as program text has been supplied,
-any other options are flagged as invalid with a warning message but
-are otherwise ignored.
-
- <p><a
name="index-_0040code_007b_002dF_007d-option_002c-_0040code_007b_002dFt_007d-sets-_0040code_007bFS_007d-to-TAB-1553"></a>In
compatibility mode, as a special case, if the value of <var>fs</var> supplied
-to the <samp><span class="option">-F</span></samp> option is `<samp><span
class="samp">t</span></samp>', then <code>FS</code> is set to the TAB
-character (<code>"\t"</code>). This is true only for <samp><span
class="option">--traditional</span></samp> and not
-for <samp><span class="option">--posix</span></samp>
-(see <a href="#Field-Separators">Field Separators</a>).
-
- <p><a
name="index-_0040code_007b_002df_007d-option_002c-on-command-line-1554"></a>The
<samp><span class="option">-f</span></samp> option may be used more than once
on the command line.
-If it is, <samp><span class="command">awk</span></samp> reads its program
source from all of the named files, as
-if they had been concatenated together into one big file. This is
-useful for creating libraries of <samp><span class="command">awk</span></samp>
functions. These functions
-can be written once and then retrieved from a standard place, instead
-of having to be included into each individual program.
-(As mentioned in
-<a href="#Definition-Syntax">Definition Syntax</a>,
-function names must be unique.)
-
- <p>Library functions can still be used, even if the program is entered at
the terminal,
-by specifying `<samp><span class="samp">-f /dev/tty</span></samp>'. After
typing your program,
-type <kbd>Ctrl-d</kbd> (the end-of-file character) to terminate it.
-(You may also use `<samp><span class="samp">-f -</span></samp>' to read
program source from the standard
-input but then you will not be able to also use the standard input as a
-source of data.)
-
- <p>Because it is clumsy using the standard <samp><span
class="command">awk</span></samp> mechanisms to mix source
-file and command-line <samp><span class="command">awk</span></samp> programs,
<samp><span class="command">gawk</span></samp> provides the
-<samp><span class="option">--source</span></samp> option. This does not
require you to pre-empt the standard
-input for your source code; it allows you to easily mix command-line
-and library source code
-(see <a href="#AWKPATH-Variable">AWKPATH Variable</a>).
-
- <p><a name="index-_0040code_007b_002d_002dsource_007d-option-1555"></a>If
no <samp><span class="option">-f</span></samp> or <samp><span
class="option">--source</span></samp> option is specified, then <samp><span
class="command">gawk</span></samp>
-uses the first non-option command-line argument as the text of the
-program source code.
-
- <p><a
name="index-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1556"></a><a
name="index-lint-checking_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1557"></a><a
name="index-POSIX-mode-1558"></a>If the environment variable <samp><span
class="env">POSIXLY_CORRECT</span></samp> exists,
-then <samp><span class="command">gawk</span></samp> behaves in strict POSIX
mode, exactly as if
-you had supplied the <samp><span class="option">--posix</span></samp>
command-line option.
-Many GNU programs look for this environment variable to turn on
-strict POSIX mode. If <samp><span class="option">--lint</span></samp> is
supplied on the command line
-and <samp><span class="command">gawk</span></samp> turns on POSIX mode because
of <samp><span class="env">POSIXLY_CORRECT</span></samp>,
-then it issues a warning message indicating that POSIX
-mode is in effect.
-You would typically set this variable in your shell's startup file.
-For a Bourne-compatible shell (such as <samp><span
class="command">bash</span></samp>), you would add these
-lines to the <samp><span class="file">.profile</span></samp> file in your home
directory:
-
-<pre class="example"> POSIXLY_CORRECT=true
- export POSIXLY_CORRECT
-</pre>
- <p><a
name="index-_0040command_007bcsh_007d-utility_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1559"></a>For
a <samp><span class="command">csh</span></samp>-compatible
-shell,<a rel="footnote" href="#fn-51" name="fnd-51"><sup>51</sup></a>
-you would add this line to the <samp><span class="file">.login</span></samp>
file in your home directory:
-
-<pre class="example"> setenv POSIXLY_CORRECT true
-</pre>
- <p><a
name="index-portability_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1560"></a>Having
<samp><span class="env">POSIXLY_CORRECT</span></samp> set is not recommended
for daily use,
-but it is good for testing the portability of your programs to other
-environments.
-<!-- ENDOFRANGE ocl -->
-<!-- ENDOFRANGE clo -->
-
-<div class="node">
-<p><hr>
-<a name="Other-Arguments"></a>Next: <a rel="next" accesskey="n"
href="#AWKPATH-Variable">AWKPATH Variable</a>,
-Previous: <a rel="previous" accesskey="p" href="#Options">Options</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.3 Other Command-Line Arguments</h3>
-
-<p><a name="index-command-line_002c-arguments-1561"></a><a
name="index-arguments_002c-command_002dline-1562"></a>
-Any additional arguments on the command line are normally treated as
-input files to be processed in the order specified. However, an
-argument that has the form <var>var</var><code>=</code><var>value</var>,
assigns
-the value <var>value</var> to the variable <var>var</var>—it does not
specify a
-file at all.
-(This was discussed earlier in
-<a href="#Assignment-Options">Assignment Options</a>.)
-
- <p><a
name="index-_0040code_007bARGIND_007d-variable_002c-command_002dline-arguments-1563"></a><a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-command_002dline-arguments-1564"></a>All
these arguments are made available to your <samp><span
class="command">awk</span></samp> program in the
-<code>ARGV</code> array (see <a href="#Built_002din-Variables">Built-in
Variables</a>). Command-line options
-and the program text (if present) are omitted from <code>ARGV</code>.
-All other arguments, including variable assignments, are
-included. As each element of <code>ARGV</code> is processed, <samp><span
class="command">gawk</span></samp>
-sets the variable <code>ARGIND</code> to the index in <code>ARGV</code> of the
-current element.
-
- <p><a name="index-input-files_002c-variable-assignments-and-1565"></a>The
distinction between file name arguments and variable-assignment
-arguments is made when <samp><span class="command">awk</span></samp> is about
to open the next input file.
-At that point in execution, it checks the file name to see whether
-it is really a variable assignment; if so, <samp><span
class="command">awk</span></samp> sets the variable
-instead of reading a file.
-
- <p>Therefore, the variables actually receive the given values after all
-previously specified files have been read. In particular, the values of
-variables assigned in this fashion are <em>not</em> available inside a
-<code>BEGIN</code> rule
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>),
-because such rules are run before <samp><span
class="command">awk</span></samp> begins scanning the argument list.
-
- <p><a name="index-dark-corner_002c-escape-sequences-1566"></a>The variable
values given on the command line are processed for escape
-sequences (see <a href="#Escape-Sequences">Escape Sequences</a>).
-(d.c.)
-
- <p>In some earlier implementations of <samp><span
class="command">awk</span></samp>, when a variable assignment
-occurred before any file names, the assignment would happen <em>before</em>
-the <code>BEGIN</code> rule was executed. <samp><span
class="command">awk</span></samp>'s behavior was thus
-inconsistent; some command-line assignments were available inside the
-<code>BEGIN</code> rule, while others were not. Unfortunately,
-some applications came to depend
-upon this “feature.” When <samp><span
class="command">awk</span></samp> was changed to be more consistent,
-the <samp><span class="option">-v</span></samp> option was added to
accommodate applications that depended
-upon the old behavior.
-
- <p>The variable assignment feature is most useful for assigning to variables
-such as <code>RS</code>, <code>OFS</code>, and <code>ORS</code>, which control
input and
-output formats before scanning the data files. It is also useful for
-controlling state if multiple passes are needed over a data file. For
-example:
-
- <p><a name="index-files_002c-multiple-passes-over-1567"></a>
-<pre class="example"> awk 'pass == 1 { <var>pass 1 stuff</var> }
- pass == 2 { <var>pass 2 stuff</var> }' pass=1 mydata pass=2 mydata
-</pre>
- <p>Given the variable assignment feature, the <samp><span
class="option">-F</span></samp> option for setting
-the value of <code>FS</code> is not
-strictly necessary. It remains for historical compatibility.
-
-<div class="node">
-<p><hr>
-<a name="AWKPATH-Variable"></a>Next: <a rel="next" accesskey="n"
href="#Obsolete">Obsolete</a>,
-Previous: <a rel="previous" accesskey="p" href="#Other-Arguments">Other
Arguments</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.4 The <samp><span class="env">AWKPATH</span></samp>
Environment Variable</h3>
-
-<p><a name="index-_0040env_007bAWKPATH_007d-environment-variable-1568"></a><a
name="index-directories_002c-searching-1569"></a><a
name="index-search-paths_002c-for-source-files-1570"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bAWKPATH_007d-environment-variable-1571"></a>In
most <samp><span class="command">awk</span></samp>
-implementations, you must supply a precise path name for each program
-file, unless the file is in the current directory.
-But in <samp><span class="command">gawk</span></samp>, if the file name
supplied to the <samp><span class="option">-f</span></samp> option
-does not contain a `<samp><span class="samp">/</span></samp>', then
<samp><span class="command">gawk</span></samp> searches a list of
-directories (called the <dfn>search path</dfn>), one by one, looking for a
-file with the specified name.
-
- <p>The search path is a string consisting of directory names
-separated by colons. <samp><span class="command">gawk</span></samp> gets its
search path from the
-<samp><span class="env">AWKPATH</span></samp> environment variable. If that
variable does not exist,
-<samp><span class="command">gawk</span></samp> uses a default path,
-`<samp><span class="samp">.:/usr/local/share/awk</span></samp>'.<a
rel="footnote" href="#fn-52" name="fnd-52"><sup>52</sup></a> (Programs written
for use by
-system administrators should use an <samp><span
class="env">AWKPATH</span></samp> variable that
-does not include the current directory, <samp><span
class="file">.</span></samp>.)
-
- <p>The search path feature is particularly useful for building libraries
-of useful <samp><span class="command">awk</span></samp> functions. The
library files can be placed in a
-standard directory in the default path and then specified on
-the command line with a short file name. Otherwise, the full file name
-would have to be typed for each file.
-
- <p>By using both the <samp><span class="option">--source</span></samp> and
<samp><span class="option">-f</span></samp> options, your command-line
-<samp><span class="command">awk</span></samp> programs can use facilities in
<samp><span class="command">awk</span></samp> library files
-(see <a href="#Library-Functions">Library Functions</a>).
-Path searching is not done if <samp><span class="command">gawk</span></samp>
is in compatibility mode.
-This is true for both <samp><span class="option">--traditional</span></samp>
and <samp><span class="option">--posix</span></samp>.
-See <a href="#Options">Options</a>.
-
- <blockquote>
-<b>NOTE:</b> If you want files in the current directory to be found,
-you must include the current directory in the path, either by including
-<samp><span class="file">.</span></samp> explicitly in the path or by writing
a null entry in the
-path. (A null entry is indicated by starting or ending the path with a
-colon or by placing two colons next to each other (`<samp><span
class="samp">::</span></samp>').) If the
-current directory is not included in the path, then files cannot be
-found in the current directory. This path search mechanism is identical
-to the shell's.
-<!-- someday, @cite{The Bourne Again Shell}.... -->
-</blockquote>
-
- <p>Starting with version 3.0, if <samp><span
class="env">AWKPATH</span></samp> is not defined in the
-environment, <samp><span class="command">gawk</span></samp> places its default
search path into
-<code>ENVIRON["AWKPATH"]</code>. This makes it easy to determine
-the actual search path that <samp><span class="command">gawk</span></samp>
will use
-from within an <samp><span class="command">awk</span></samp> program.
-
- <p>While you can change <code>ENVIRON["AWKPATH"]</code> within your
<samp><span class="command">awk</span></samp>
-program, this has no effect on the running program's behavior. This makes
-sense: the <samp><span class="env">AWKPATH</span></samp> environment variable
is used to find the program
-source files. Once your program is running, all the files have been
-found, and <samp><span class="command">gawk</span></samp> no longer needs to
use <samp><span class="env">AWKPATH</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="Obsolete"></a>Next: <a rel="next" accesskey="n"
href="#Undocumented">Undocumented</a>,
-Previous: <a rel="previous" accesskey="p"
href="#AWKPATH-Variable">AWKPATH Variable</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.5 Obsolete Options and/or Features</h3>
-
-<p><a
name="index-features_002c-advanced_002c-See-advanced-features-1572"></a><a
name="index-options_002c-deprecated-1573"></a><a
name="index-features_002c-deprecated-1574"></a><a
name="index-obsolete-features-1575"></a>This section describes features and/or
command-line options from
-previous releases of <samp><span class="command">gawk</span></samp> that are
either not available in the
-current version or that are still supported but deprecated (meaning that
-they will <em>not</em> be in the next release).
-
-<!-- update this section for each release! -->
-<p><a
name="index-_0040code_007bnext-file_007d-statement_002c-deprecated-1576"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bnext-file_007d-statement-and-1577"></a>For
version 3.1 of <samp><span class="command">gawk</span></samp>, there are no
-deprecated command-line options
-<!-- or other deprecated features -->
-from the previous version of <samp><span class="command">gawk</span></samp>.
-The use of `<samp><span class="samp">next file</span></samp>' (two words) for
<code>nextfile</code> was deprecated
-in <samp><span class="command">gawk</span></samp> 3.0 but still worked.
Starting with version 3.1, the
-two-word usage is no longer accepted.
-
- <p>The process-related special files described in
-<a href="#Special-Process">Special Process</a>,
-work as described, but
-are now considered deprecated.
-<samp><span class="command">gawk</span></samp> prints a warning message every
time they are used.
-(Use <code>PROCINFO</code> instead; see
-<a href="#Auto_002dset">Auto-set</a>.)
-They will be removed from the next release of <samp><span
class="command">gawk</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="Undocumented"></a>Next: <a rel="next" accesskey="n"
href="#Known-Bugs">Known Bugs</a>,
-Previous: <a rel="previous" accesskey="p" href="#Obsolete">Obsolete</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.6 Undocumented Options and Features</h3>
-
-<p><a name="index-undocumented-features-1578"></a><a
name="index-features_002c-undocumented-1579"></a><a
name="index-Skywalker_002c-Luke-1580"></a><a
name="index-Kenobi_002c-Obi_002dWan-1581"></a><a
name="index-Jedi-knights-1582"></a><a
name="index-Knights_002c-jedi-1583"></a><blockquote>
-<i>Use the Source, Luke!</i><br>
-Obi-Wan
-</blockquote>
-
- <p>This section intentionally left
-blank.
-
-<div class="node">
-<p><hr>
-<a name="Known-Bugs"></a>Previous: <a rel="previous" accesskey="p"
href="#Undocumented">Undocumented</a>,
-Up: <a rel="up" accesskey="u" href="#Invoking-Gawk">Invoking Gawk</a>
-<br>
-</div>
-
-<h3 class="section">11.7 Known Bugs in <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-_0040command_007bgawk_007d_002c-debugging-1584"></a><a
name="index-debugging-_0040command_007bgawk_007d-1585"></a><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d-1586"></a>
-
-<a name="index-troubleshooting_002c-_0040code_007b_002dF_007d-option-1587"></a>
-<a name="index-_0040code_007b_002dF_007d-option_002c-troubleshooting-1588"></a>
-<a name="index-_0040code_007bFS_007d-variable_002c-changing-value-of-1589"></a>
-<ul><li>The <samp><span class="option">-F</span></samp> option for changing
the value of <code>FS</code>
-(see <a href="#Options">Options</a>)
-is not necessary given the command-line variable
-assignment feature; it remains only for backward compatibility.
-
- <li>Syntactically invalid single-character programs tend to overflow
-the parse stack, generating a rather unhelpful message. Such programs
-are surprisingly difficult to diagnose in the completely general case,
-and the effort to do so really is not worth it.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Library-Functions"></a>Next: <a rel="next" accesskey="n"
href="#Sample-Programs">Sample Programs</a>,
-Previous: <a rel="previous" accesskey="p" href="#Invoking-Gawk">Invoking
Gawk</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">12 A Library of <samp><span
class="command">awk</span></samp> Functions</h2>
-
-<!-- STARTOFRANGE libf -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions-1590"></a><!--
STARTOFRANGE flib -->
-<a name="index-functions_002c-library-1591"></a><!-- STARTOFRANGE fudlib -->
-<a name="index-functions_002c-user_002ddefined_002c-library-of-1592"></a>
-<a href="#User_002ddefined">User-defined</a>, describes how to write
-your own <samp><span class="command">awk</span></samp> functions. Writing
functions is important, because
-it allows you to encapsulate algorithms and program tasks in a single
-place. It simplifies programming, making program development more
-manageable, and making programs more readable.
-
- <p>One valuable way to learn a new programming language is to <em>read</em>
-programs in that language. To that end, this chapter
-and <a href="#Sample-Programs">Sample Programs</a>,
-provide a good-sized body of code for you to read,
-and hopefully, to learn from.
-
-<!-- 2e: USE TEXINFO-2 FUNCTION DEFINITION STUFF!!!!!!!!!!!!! -->
-<p>This chapter presents a library of useful <samp><span
class="command">awk</span></samp> functions.
-Many of the sample programs presented later in this Web page
-use these functions.
-The functions are presented here in a progression from simple to complex.
-
- <p><a name="index-Texinfo-1593"></a><a href="#Extract-Program">Extract
Program</a>,
-presents a program that you can use to extract the source code for
-these example library functions and programs from the Texinfo source
-for this Web page.
-(This has already been done as part of the <samp><span
class="command">gawk</span></samp> distribution.)
-
- <p>If you have written one or more useful, general-purpose <samp><span
class="command">awk</span></samp> functions
-and would like to contribute them to the author's collection of <samp><span
class="command">awk</span></samp>
-programs, see
-<a href="#How-To-Contribute">How To Contribute</a>, for more information.
-
- <p><a name="index-portability_002c-example-programs-1594"></a>The programs
in this chapter and in
-<a href="#Sample-Programs">Sample Programs</a>,
-freely use features that are <samp><span
class="command">gawk</span></samp>-specific.
-Rewriting these programs for different implementations of awk is pretty
straightforward.
-
- <p>Diagnostic error messages are sent to <samp><span
class="file">/dev/stderr</span></samp>.
-Use `<samp><span class="samp">| "cat 1>&2"</span></samp>' instead of
`<samp><span class="samp">> "/dev/stderr"</span></samp>' if your system
-does not have a <samp><span class="file">/dev/stderr</span></samp>, or if you
cannot use <samp><span class="command">gawk</span></samp>.
-
- <p>A number of programs use <code>nextfile</code>
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>)
-to skip any remaining input in the input file.
-<a href="#Nextfile-Function">Nextfile Function</a>,
-shows you how to write a function that does the same thing.
-
-<!-- 12/2000: Thanks to Nelson Beebe for pointing out the output issue. -->
-<p><a name="index-case-sensitivity_002c-example-programs-1595"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable_002c-in-example-programs-1596"></a>Finally,
some of the programs choose to ignore upper- and lowercase
-distinctions in their input. They do so by assigning one to
<code>IGNORECASE</code>.
-You can achieve almost the same effect<a rel="footnote" href="#fn-53"
name="fnd-53"><sup>53</sup></a> by adding the following rule to the
-beginning of the program:
-
-<pre class="example"> # ignore case
- { $0 = tolower($0) }
-</pre>
- <p class="noindent">Also, verify that all regexp and string constants used
in
-comparisons use only lowercase letters.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Library-Names">Library Names</a>:
How to best name private global variables in
- library functions.
-<li><a accesskey="2" href="#General-Functions">General Functions</a>:
Functions that are of general use.
-<li><a accesskey="3" href="#Data-File-Management">Data File Management</a>:
Functions for managing command-line data
- files.
-<li><a accesskey="4" href="#Getopt-Function">Getopt Function</a>:
A function for processing command-line
- arguments.
-<li><a accesskey="5" href="#Passwd-Functions">Passwd Functions</a>:
Functions for getting user information.
-<li><a accesskey="6" href="#Group-Functions">Group Functions</a>:
Functions for getting group information.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Library-Names"></a>Next: <a rel="next" accesskey="n"
href="#General-Functions">General Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Library-Functions">Library
Functions</a>
-<br>
-</div>
-
-<h3 class="section">12.1 Naming Library Function Global Variables</h3>
-
-<p><a name="index-names_002c-arrays_002fvariables-1597"></a><a
name="index-names_002c-functions-1598"></a><a
name="index-namespace-issues-1599"></a><a
name="index-_0040command_007bawk_007d-programs_002c-documenting-1600"></a><a
name="index-documentation_002c-of-_0040command_007bawk_007d-programs-1601"></a>Due
to the way the <samp><span class="command">awk</span></samp> language evolved,
variables are either
-<dfn>global</dfn> (usable by the entire program) or <dfn>local</dfn> (usable
just by
-a specific function). There is no intermediate state analogous to
-<code>static</code> variables in C.
-
- <p><a
name="index-variables_002c-global_002c-for-library-functions-1602"></a><a
name="index-private-variables-1603"></a><a
name="index-variables_002c-private-1604"></a>Library functions often need to
have global variables that they can use to
-preserve state information between calls to the function—for example,
-<code>getopt</code>'s variable <code>_opti</code>
-(see <a href="#Getopt-Function">Getopt Function</a>).
-Such variables are called <dfn>private</dfn>, since the only functions that
need to
-use them are the ones in the library.
-
- <p>When writing a library function, you should try to choose names for your
-private variables that will not conflict with any variables used by
-either another library function or a user's main program. For example, a
-name like `<samp><span class="samp">i</span></samp>' or `<samp><span
class="samp">j</span></samp>' is not a good choice, because user programs
-often use variable names like these for their own purposes.
-
- <p><a
name="index-programming-conventions_002c-private-variable-names-1605"></a>The
example programs shown in this chapter all start the names of their
-private variables with an underscore (`<samp><span
class="samp">_</span></samp>'). Users generally don't use
-leading underscores in their variable names, so this convention immediately
-decreases the chances that the variable name will be accidentally shared
-with the user's program.
-
- <p><a
name="index-_0040code_007b_005f_007d-_0028underscore_0029_002c-in-names-of-private-variables-1606"></a><a
name="index-underscore-_0028_0040code_007b_005f_007d_0029_002c-in-names-of-private-variables-1607"></a>In
addition, several of the library functions use a prefix that helps
-indicate what function or set of functions use the variables—for example,
-<code>_pw_byname</code> in the user database routines
-(see <a href="#Passwd-Functions">Passwd Functions</a>).
-This convention is recommended, since it even further decreases the
-chance of inadvertent conflict among variable names. Note that this
-convention is used equally well for variable names and for private
-function names as well.<a rel="footnote" href="#fn-54"
name="fnd-54"><sup>54</sup></a>
-
- <p>As a final note on variable naming, if a function makes global variables
-available for use by a main program, it is a good convention to start that
-variable's name with a capital letter—for
-example, <code>getopt</code>'s <code>Opterr</code> and <code>Optind</code>
variables
-(see <a href="#Getopt-Function">Getopt Function</a>).
-The leading capital letter indicates that it is global, while the fact that
-the variable name is not all capital letters indicates that the variable is
-not one of <samp><span class="command">awk</span></samp>'s built-in variables,
such as <code>FS</code>.
-
- <p><a
name="index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1608"></a>It
is also important that <em>all</em> variables in library
-functions that do not need to save state are, in fact, declared
-local.<a rel="footnote" href="#fn-55" name="fnd-55"><sup>55</sup></a> If this
is not done, the variable
-could accidentally be used in the user's program, leading to bugs that
-are very difficult to track down:
-
-<pre class="example"> function lib_func(x, y, l1, l2)
- {
- ...
- <var>use variable</var> some_var # some_var should be local
- ... # but is not by oversight
- }
-</pre>
- <p><a
name="index-arrays_002c-associative_002c-library-functions-and-1609"></a><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-associative-arrays-and-1610"></a><a
name="index-functions_002c-library_002c-associative-arrays-and-1611"></a><a
name="index-Tcl-1612"></a>A different convention, common in the Tcl community,
is to use a single
-associative array to hold the values needed by the library function(s), or
-“package.” This significantly decreases the number of actual
global names
-in use. For example, the functions described in
-<a href="#Passwd-Functions">Passwd Functions</a>,
-might have used array elements <code>PW_data["inited"]<!-- /@w --></code>,
<code>PW_data["total"]<!-- /@w --></code>,
-<code>PW_data["count"]<!-- /@w --></code>, and <code>PW_data["awklib"]<!-- /@w
--></code>, instead of
-<code>_pw_inited<!-- /@w --></code>, <code>_pw_awklib<!-- /@w --></code>,
<code>_pw_total<!-- /@w --></code>,
-and <code>_pw_count<!-- /@w --></code>.
-
- <p>The conventions presented in this section are exactly
-that: conventions. You are not required to write your programs this
-way—we merely recommend that you do so.
-
-<div class="node">
-<p><hr>
-<a name="General-Functions"></a>Next: <a rel="next" accesskey="n"
href="#Data-File-Management">Data File Management</a>,
-Previous: <a rel="previous" accesskey="p" href="#Library-Names">Library
Names</a>,
-Up: <a rel="up" accesskey="u" href="#Library-Functions">Library
Functions</a>
-<br>
-</div>
-
-<h3 class="section">12.2 General Programming</h3>
-
-<p>This section presents a number of functions that are of general
-programming use.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Nextfile-Function">Nextfile Function</a>:
Two implementations of a <code>nextfile</code>
- function.
-<li><a accesskey="2" href="#Strtonum-Function">Strtonum Function</a>:
A replacement for the built-in <code>strtonum</code>
- function.
-<li><a accesskey="3" href="#Assert-Function">Assert Function</a>:
A function for assertions in <samp><span class="command">awk</span></samp>
- programs.
-<li><a accesskey="4" href="#Round-Function">Round Function</a>:
A function for rounding if <code>sprintf</code> does
- not do it correctly.
-<li><a accesskey="5" href="#Cliff-Random-Function">Cliff Random Function</a>:
The Cliff Random Number Generator.
-<li><a accesskey="6" href="#Ordinal-Functions">Ordinal Functions</a>:
Functions for using characters as numbers and
- vice versa.
-<li><a accesskey="7" href="#Join-Function">Join Function</a>: A
function to join an array into a string.
-<li><a accesskey="8" href="#Gettimeofday-Function">Gettimeofday Function</a>:
A function to get formatted times.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Nextfile-Function"></a>Next: <a rel="next" accesskey="n"
href="#Strtonum-Function">Strtonum Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.1 Implementing <code>nextfile</code> as a
Function</h4>
-
-<p><a name="index-input-files_002c-skipping-1613"></a><!-- STARTOFRANGE
libfnex -->
-<a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-_0040code_007bnextfile_007d-statement-1614"></a><!--
STARTOFRANGE flibnex -->
-<a
name="index-functions_002c-library_002c-_0040code_007bnextfile_007d-statement-1615"></a><!--
STARTOFRANGE nexim -->
-<a
name="index-_0040code_007bnextfile_007d-statement_002c-implementing-1616"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-1617"></a>The
<code>nextfile</code> statement, presented in
-<a href="#Nextfile-Statement">Nextfile Statement</a>,
-is a <samp><span class="command">gawk</span></samp>-specific
extension—it is not available in most other
-implementations of <samp><span class="command">awk</span></samp>. This
section shows two versions of a
-<code>nextfile</code> function that you can use to simulate <samp><span
class="command">gawk</span></samp>'s
-<code>nextfile</code> statement if you cannot use <samp><span
class="command">gawk</span></samp>.
-
- <p>A first attempt at writing a <code>nextfile</code> function is as
follows:
-
-<pre class="example"> # nextfile --- skip remaining records in current file
- # this should be read in before the "main" awk program
-
- function nextfile() { _abandon_ = FILENAME; next }
- _abandon_ == FILENAME { next }
-</pre>
- <p><a
name="index-programming-conventions_002c-_0040code_007bnextfile_007d-statement-1618"></a>Because
it supplies a rule that must be executed first, this file should
-be included before the main program. This rule compares the current
-data file's name (which is always in the <code>FILENAME</code> variable) to
-a private variable named <code>_abandon_</code>. If the file name matches,
-then the action part of the rule executes a <code>next</code> statement to
-go on to the next record. (The use of `<samp><span
class="samp">_</span></samp>' in the variable name is
-a convention. It is discussed more fully in
-<a href="#Library-Names">Library Names</a>.)
-
- <p>The use of the <code>next</code> statement effectively creates a loop
that reads
-all the records from the current data file.
-The end of the file is eventually reached and
-a new data file is opened, changing the value of <code>FILENAME</code>.
-Once this happens, the comparison of <code>_abandon_</code> to
<code>FILENAME</code>
-fails, and execution continues with the first rule of the “real”
program.
-
- <p>The <code>nextfile</code> function itself simply sets the value of
<code>_abandon_</code>
-and then executes a <code>next</code> statement to start the
-loop.
-
- <p><a
name="index-_0040code_007bnextfile_007d-user_002ddefined-function-1619"></a>This
initial version has a subtle problem.
-If the same data file is listed <em>twice</em> on the commandline,
-one right after the other
-or even with just a variable assignment between them,
-this code skips right through the file a second time, even though
-it should stop when it gets to the end of the first occurrence.
-A second version of <code>nextfile</code> that remedies this problem
-is shown here:
-
-<pre class="example"> <!-- file eg/lib/nextfile.awk -->
- # nextfile --- skip remaining records in current file
- # correctly handle successive occurrences of the same file
- <!-- endfile -->
- <!-- file eg/lib/nextfile.awk -->
- # this should be read in before the "main" awk program
-
- function nextfile() { _abandon_ = FILENAME; next }
-
- _abandon_ == FILENAME {
- if (FNR == 1)
- _abandon_ = ""
- else
- next
- }
- <!-- endfile -->
-</pre>
- <p>The <code>nextfile</code> function has not changed. It makes
<code>_abandon_</code>
-equal to the current file name and then executes a <code>next</code>
statement.
-The <code>next</code> statement reads the next record and increments
<code>FNR</code>
-so that <code>FNR</code> is guaranteed to have a value of at least two.
-However, if <code>nextfile</code> is called for the last record in the file,
-then <samp><span class="command">awk</span></samp> closes the current data
file and moves on to the next
-one. Upon doing so, <code>FILENAME</code> is set to the name of the new file
-and <code>FNR</code> is reset to one. If this next file is the same as
-the previous one, <code>_abandon_</code> is still equal to
<code>FILENAME</code>.
-However, <code>FNR</code> is equal to one, telling us that this is a new
-occurrence of the file and not the one we were reading when the
-<code>nextfile</code> function was executed. In that case,
<code>_abandon_</code>
-is reset to the empty string, so that further executions of this rule
-fail (until the next time that <code>nextfile</code> is called).
-
- <p>If <code>FNR</code> is not one, then we are still in the original data
file
-and the program executes a <code>next</code> statement to skip through it.
-
- <p>An important question to ask at this point is: given that the
-functionality of <code>nextfile</code> can be provided with a library file,
-why is it built into <samp><span class="command">gawk</span></samp>? Adding
-features for little reason leads to larger, slower programs that are
-harder to maintain.
-The answer is that building <code>nextfile</code> into <samp><span
class="command">gawk</span></samp> provides
-significant gains in efficiency. If the <code>nextfile</code> function is
executed
-at the beginning of a large data file, <samp><span
class="command">awk</span></samp> still has to scan the entire
-file, splitting it up into records,
-<!-- at least conceptually -->
-just to skip over it. The built-in
-<code>nextfile</code> can simply close the file immediately and proceed to the
-next one, which saves a lot of time. This is particularly important in
-<samp><span class="command">awk</span></samp>, because <samp><span
class="command">awk</span></samp> programs are generally I/O-bound (i.e.,
-they spend most of their time doing input and output, instead of performing
-computations).
-<!-- ENDOFRANGE libfnex -->
-<!-- ENDOFRANGE flibnex -->
-<!-- ENDOFRANGE nexim -->
-
-<div class="node">
-<p><hr>
-<a name="Strtonum-Function"></a>Next: <a rel="next" accesskey="n"
href="#Assert-Function">Assert Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Nextfile-Function">Nextfile Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.2 Converting Strings To Numbers</h4>
-
-<p>The <code>strtonum</code> function (see <a href="#String-Functions">String
Functions</a>)
-is a <samp><span class="command">gawk</span></samp> extension. The following
function
-provides an implementation for other versions of <samp><span
class="command">awk</span></samp>:
-
-<pre class="example"> <!-- file eg/lib/strtonum.awk -->
- # strtonum --- convert string to number
- <!-- endfile -->
- <!-- file eg/lib/strtonum.awk -->
- function mystrtonum(str, ret, chars, n, i, k, c)
- {
- if (str ~ /^0[0-7]*$/) {
- # octal
- n = length(str)
- ret = 0
- for (i = 1; i <= n; i++) {
- c = substr(str, i, 1)
- if ((k = index("01234567", c)) > 0)
- k-- # adjust for 1-basing in awk
-
- ret = ret * 8 + k
- }
- } else if (str ~ /^0[xX][0-9a-fA-f]+/) {
- # hexadecimal
- str = substr(str, 3) # lop off leading 0x
- n = length(str)
- ret = 0
- for (i = 1; i <= n; i++) {
- c = substr(str, i, 1)
- c = tolower(c)
- if ((k = index("0123456789", c)) > 0)
- k-- # adjust for 1-basing in awk
- else if ((k = index("abcdef", c)) > 0)
- k += 9
-
- ret = ret * 16 + k
- }
- } else if (str ~
/^[-+]?([0-9]+([.][0-9]*([Ee][0-9]+)?)?|([.][0-9]+([Ee][-+]?[0-9]+)?))$/) {
- # decimal number, possibly floating point
- ret = str + 0
- } else
- ret = "NOT-A-NUMBER"
-
- return ret
- }
-
- # BEGIN { # gawk test harness
- # a[1] = "25"
- # a[2] = ".31"
- # a[3] = "0123"
- # a[4] = "0xdeadBEEF"
- # a[5] = "123.45"
- # a[6] = "1.e3"
- # a[7] = "1.32"
- # a[7] = "1.32E2"
- #
- # for (i = 1; i in a; i++)
- # print a[i], strtonum(a[i]), mystrtonum(a[i])
- # }
- <!-- endfile -->
-</pre>
- <p>The function first looks for C-style octal numbers (base 8).
-If the input string matches a regular expression describing octal
-numbers, then <code>mystrtonum</code> loops through each character in the
-string. It sets <code>k</code> to the index in <code>"01234567"</code> of the
current
-octal digit. Since the return value is one-based, the `<samp><span
class="samp">k--</span></samp>'
-adjusts <code>k</code> so it can be used in computing the return value.
-
- <p>Similar logic applies to the code that checks for and converts a
-hexadecimal value, which starts with `<samp><span
class="samp">0x</span></samp>' or `<samp><span class="samp">0X</span></samp>'.
-The use of <code>tolower</code> simplifies the computation for finding
-the correct numeric value for each hexadecimal digit.
-
- <p>Finally, if the string matches the (rather complicated) regex for a
-regular decimal integer or floating-point numer, the computation
-`<samp><span class="samp">ret = str + 0</span></samp>' lets <samp><span
class="command">awk</span></samp> convert the value to a
-number.
-
- <p>A commented-out test program is included, so that the function can
-be tested with <samp><span class="command">gawk</span></samp> and the results
compared to the built-in
-<code>strtonum</code> function.
-
-<div class="node">
-<p><hr>
-<a name="Assert-Function"></a>Next: <a rel="next" accesskey="n"
href="#Round-Function">Round Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Strtonum-Function">Strtonum Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.3 Assertions</h4>
-
-<!-- STARTOFRANGE asse -->
-<p><a name="index-assertions-1620"></a><!-- STARTOFRANGE assef -->
-<a
name="index-_0040code_007bassert_007d-function-_0028C-library_0029-1621"></a><!--
STARTOFRANGE libfass -->
-<a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-assertions-1622"></a><!--
STARTOFRANGE flibass -->
-<a name="index-functions_002c-library_002c-assertions-1623"></a><a
name="index-_0040command_007bawk_007d-programs_002c-lengthy_002c-assertions-1624"></a>When
writing large programs, it is often useful to know
-that a condition or set of conditions is true. Before proceeding with a
-particular computation, you make a statement about what you believe to be
-the case. Such a statement is known as an
-<dfn>assertion</dfn>. The C language provides an
<code><assert.h></code> header file
-and corresponding <code>assert</code> macro that the programmer can use to make
-assertions. If an assertion fails, the <code>assert</code> macro arranges to
-print a diagnostic message describing the condition that should have
-been true but was not, and then it kills the program. In C, using
-<code>assert</code> looks this:
-
-<pre class="example"> #include <assert.h>
-
- int myfunc(int a, double b)
- {
- assert(a <= 5 && b >= 17.1);
- ...
- }
-</pre>
- <p>If the assertion fails, the program prints a message similar to this:
-
-<pre class="example"> prog.c:5: assertion failed: a <= 5 && b
>= 17.1
-</pre>
- <p><a
name="index-_0040code_007bassert_007d-user_002ddefined-function-1625"></a>The C
language makes it possible to turn the condition into a string for use
-in printing the diagnostic message. This is not possible in <samp><span
class="command">awk</span></samp>, so
-this <code>assert</code> function also requires a string version of the
condition
-that is being tested.
-Following is the function:
-
-<pre class="example"> <!-- file eg/lib/assert.awk -->
- # assert --- assert that a condition is true. Otherwise exit.
- <!-- endfile -->
- <!-- file eg/lib/assert.awk -->
- function assert(condition, string)
- {
- if (! condition) {
- printf("%s:%d: assertion failed: %s\n",
- FILENAME, FNR, string) > "/dev/stderr"
- _assert_exit = 1
- exit 1
- }
- }
-
- END {
- if (_assert_exit)
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p>The <code>assert</code> function tests the <code>condition</code>
parameter. If it
-is false, it prints a message to standard error, using the <code>string</code>
-parameter to describe the failed condition. It then sets the variable
-<code>_assert_exit</code> to one and executes the <code>exit</code> statement.
-The <code>exit</code> statement jumps to the <code>END</code> rule. If the
<code>END</code>
-rules finds <code>_assert_exit</code> to be true, it exits immediately.
-
- <p>The purpose of the test in the <code>END</code> rule is to
-keep any other <code>END</code> rules from running. When an assertion fails,
the
-program should exit immediately.
-If no assertions fail, then <code>_assert_exit</code> is still
-false when the <code>END</code> rule is run normally, and the rest of the
-program's <code>END</code> rules execute.
-For all of this to work correctly, <samp><span
class="file">assert.awk</span></samp> must be the
-first source file read by <samp><span class="command">awk</span></samp>.
-The function can be used in a program in the following way:
-
-<pre class="example"> function myfunc(a, b)
- {
- assert(a <= 5 && b >= 17.1, "a <= 5 && b
>= 17.1")
- ...
- }
-</pre>
- <p class="noindent">If the assertion fails, you see a message similar to
the following:
-
-<pre class="example"> mydata:1357: assertion failed: a <= 5 &&
b >= 17.1
-</pre>
- <p><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1626"></a>There
is a small problem with this version of <code>assert</code>.
-An <code>END</code> rule is automatically added
-to the program calling <code>assert</code>. Normally, if a program consists
-of just a <code>BEGIN</code> rule, the input files and/or standard input are
-not read. However, now that the program has an <code>END</code> rule,
<samp><span class="command">awk</span></samp>
-attempts to read the input data files or standard input
-(see <a href="#Using-BEGIN_002fEND">Using BEGIN/END</a>),
-most likely causing the program to hang as it waits for input.
-
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1627"></a>There
is a simple workaround to this:
-make sure the <code>BEGIN</code> rule always ends
-with an <code>exit</code> statement.
-<!-- ENDOFRANGE asse -->
-<!-- ENDOFRANGE assef -->
-<!-- ENDOFRANGE flibass -->
-<!-- ENDOFRANGE libfass -->
-
-<div class="node">
-<p><hr>
-<a name="Round-Function"></a>Next: <a rel="next" accesskey="n"
href="#Cliff-Random-Function">Cliff Random Function</a>,
-Previous: <a rel="previous" accesskey="p" href="#Assert-Function">Assert
Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.4 Rounding Numbers</h4>
-
-<p><a name="index-rounding-1628"></a><a
name="index-rounding-numbers-1629"></a><a
name="index-numbers_002c-rounding-1630"></a><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-rounding-numbers-1631"></a><a
name="index-functions_002c-library_002c-rounding-numbers-1632"></a><a
name="index-_0040code_007bprint_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1633"></a><a
name="index-_0040code_007bprintf_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1634"></a><a
name="index-_0040code_007bsprintf_007d-function_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-and-1635"></a>The
way <code>printf</code> and <code>sprintf</code>
-(see <a href="#Printf">Printf</a>)
-perform rounding often depends upon the system's C <code>sprintf</code>
-subroutine. On many machines, <code>sprintf</code> rounding is
“unbiased,”
-which means it doesn't always round a trailing `<samp><span
class="samp">.5</span></samp>' up, contrary
-to naive expectations. In unbiased rounding, `<samp><span
class="samp">.5</span></samp>' rounds to even,
-rather than always up, so 1.5 rounds to 2 but 4.5 rounds to 4. This means
-that if you are using a format that does rounding (e.g., <code>"%.0f"</code>),
-you should check what your system does. The following function does
-traditional rounding; it might be useful if your awk's <code>printf</code>
-does unbiased rounding:
-
- <p><a
name="index-_0040code_007bround_007d-user_002ddefined-function-1636"></a>
-<pre class="example"> <!-- file eg/lib/round.awk -->
- # round.awk --- do normal rounding
- <!-- endfile -->
- <!-- file eg/lib/round.awk -->
- function round(x, ival, aval, fraction)
- {
- ival = int(x) # integer part, int() truncates
-
- # see if fractional part
- if (ival == x) # no fraction
- return x
-
- if (x < 0) {
- aval = -x # absolute value
- ival = int(aval)
- fraction = aval - ival
- if (fraction >= .5)
- return int(x) - 1 # -2.5 --> -3
- else
- return int(x) # -2.3 --> -2
- } else {
- fraction = x - ival
- if (fraction >= .5)
- return ival + 1
- else
- return ival
- }
- }
-
- # test harness
- { print $0, round($0) }
- <!-- endfile -->
-</pre>
- <div class="node">
-<p><hr>
-<a name="Cliff-Random-Function"></a>Next: <a rel="next" accesskey="n"
href="#Ordinal-Functions">Ordinal Functions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Round-Function">Round
Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.5 The Cliff Random Number Generator</h4>
-
-<p><a name="index-random-numbers_002c-Cliff-1637"></a><a
name="index-Cliff-random-numbers-1638"></a><a
name="index-numbers_002c-Cliff-random-1639"></a><a
name="index-functions_002c-library_002c-Cliff-random-numbers-1640"></a>
-The Cliff random number
-generator<a rel="footnote" href="#fn-56" name="fnd-56"><sup>56</sup></a>
-is a very simple random number generator that “passes the noise sphere
test
-for randomness by showing no structure.”
-It is easily programmed, in less than 10 lines of <samp><span
class="command">awk</span></samp> code:
-
- <p><a
name="index-_0040code_007bcliff_005frand_007d-user_002ddefined-function-1641"></a>
-<pre class="example"> <!-- file eg/lib/cliff_rand.awk -->
- # cliff_rand.awk --- generate Cliff random numbers
- <!-- endfile -->
- <!-- file eg/lib/cliff_rand.awk -->
- BEGIN { _cliff_seed = 0.1 }
-
- function cliff_rand()
- {
- _cliff_seed = (100 * log(_cliff_seed)) % 1
- if (_cliff_seed < 0)
- _cliff_seed = - _cliff_seed
- return _cliff_seed
- }
- <!-- endfile -->
-</pre>
- <p>This algorithm requires an initial “seed” of 0.1. Each new
value
-uses the current seed as input for the calculation.
-If the built-in <code>rand</code> function
-(see <a href="#Numeric-Functions">Numeric Functions</a>)
-isn't random enough, you might try using this function instead.
-
-<div class="node">
-<p><hr>
-<a name="Ordinal-Functions"></a>Next: <a rel="next" accesskey="n"
href="#Join-Function">Join Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Cliff-Random-Function">Cliff Random Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.6 Translating Between Characters and Numbers</h4>
-
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-character-values-as-numbers-1642"></a><a
name="index-functions_002c-library_002c-character-values-as-numbers-1643"></a><a
name="index-characters_002c-values-of-as-numbers-1644"></a><a
name="index-numbers_002c-as-values-of-characters-1645"></a>One commercial
implementation of <samp><span class="command">awk</span></samp> supplies a
built-in function,
-<code>ord</code>, which takes a character and returns the numeric value for
that
-character in the machine's character set. If the string passed to
-<code>ord</code> has more than one character, only the first one is used.
-
- <p>The inverse of this function is <code>chr</code> (from the function of
the same
-name in Pascal), which takes a number and returns the corresponding character.
-Both functions are written very nicely in <samp><span
class="command">awk</span></samp>; there is no real
-reason to build them into the <samp><span class="command">awk</span></samp>
interpreter:
-
- <p><a
name="index-_0040code_007bord_007d-user_002ddefined-function-1646"></a><a
name="index-_0040code_007bchr_007d-user_002ddefined-function-1647"></a>
-<pre class="example"> <!-- file eg/lib/ord.awk -->
- # ord.awk --- do ord and chr
-
- # Global identifiers:
- # _ord_: numerical values indexed by characters
- # _ord_init: function to initialize _ord_
- <!-- endfile -->
- <!-- file eg/lib/ord.awk -->
- BEGIN { _ord_init() }
-
- function _ord_init( low, high, i, t)
- {
- low = sprintf("%c", 7) # BEL is ascii 7
- if (low == "\a") { # regular ascii
- low = 0
- high = 127
- } else if (sprintf("%c", 128 + 7) == "\a") {
- # ascii, mark parity
- low = 128
- high = 255
- } else { # ebcdic(!)
- low = 0
- high = 255
- }
-
- for (i = low; i <= high; i++) {
- t = sprintf("%c", i)
- _ord_[t] = i
- }
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-character-sets-1648"></a><a
name="index-character-encodings-1649"></a><a name="index-ASCII-1650"></a><a
name="index-EBCDIC-1651"></a><a name="index-mark-parity-1652"></a>Some
explanation of the numbers used by <code>chr</code> is worthwhile.
-The most prominent character set in use today is ASCII. Although an
-8-bit byte can hold 256 distinct values (from 0 to 255), ASCII only
-defines characters that use the values from 0 to 127.<a rel="footnote"
href="#fn-57" name="fnd-57"><sup>57</sup></a>
-In the now distant past,
-at least one minicomputer manufacturer
-<!-- Pr1me, blech -->
-used ASCII, but with mark parity, meaning that the leftmost bit in the byte
-is always 1. This means that on those systems, characters
-have numeric values from 128 to 255.
-Finally, large mainframe systems use the EBCDIC character set, which
-uses all 256 values.
-While there are other character sets in use on some older systems,
-they are not really worth worrying about:
-
-<pre class="example"> <!-- file eg/lib/ord.awk -->
- function ord(str, c)
- {
- # only first character is of interest
- c = substr(str, 1, 1)
- return _ord_[c]
- }
-
- function chr(c)
- {
- # force c to be numeric by adding 0
- return sprintf("%c", c + 0)
- }
- <!-- endfile -->
-
- #### test code ####
- # BEGIN \
- # {
- # for (;;) {
- # printf("enter a character: ")
- # if (getline var <= 0)
- # break
- # printf("ord(%s) = %d\n", var, ord(var))
- # }
- # }
- <!-- endfile -->
-</pre>
- <p>An obvious improvement to these functions is to move the code for the
-<code>_ord_init<!-- /@w --></code> function into the body of the
<code>BEGIN</code> rule. It was
-written this way initially for ease of development.
-There is a “test program” in a <code>BEGIN</code> rule, to test the
-function. It is commented out for production use.
-
-<div class="node">
-<p><hr>
-<a name="Join-Function"></a>Next: <a rel="next" accesskey="n"
href="#Gettimeofday-Function">Gettimeofday Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Ordinal-Functions">Ordinal Functions</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.7 Merging an Array into a String</h4>
-
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-merging-arrays-into-strings-1653"></a><a
name="index-functions_002c-library_002c-merging-arrays-into-strings-1654"></a><a
name="index-strings_002c-merging-arrays-into-1655"></a><a
name="index-arrays_002c-merging-into-strings-1656"></a>When doing string
processing, it is often useful to be able to join
-all the strings in an array into one long string. The following function,
-<code>join</code>, accomplishes this task. It is used later in several of
-the application programs
-(see <a href="#Sample-Programs">Sample Programs</a>).
-
- <p>Good function design is important; this function needs to be general but
it
-should also have a reasonable default behavior. It is called with an array
-as well as the beginning and ending indices of the elements in the array to be
-merged. This assumes that the array indices are numeric—a reasonable
-assumption since the array was likely created with <code>split</code>
-(see <a href="#String-Functions">String Functions</a>):
-
- <p><a
name="index-_0040code_007bjoin_007d-user_002ddefined-function-1657"></a>
-<pre class="example"> <!-- file eg/lib/join.awk -->
- # join.awk --- join an array into a string
- <!-- endfile -->
- <!-- file eg/lib/join.awk -->
- function join(array, start, end, sep, result, i)
- {
- if (sep == "")
- sep = " "
- else if (sep == SUBSEP) # magic value
- sep = ""
- result = array[start]
- for (i = start + 1; i <= end; i++)
- result = result sep array[i]
- return result
- }
- <!-- endfile -->
-</pre>
- <p>An optional additional argument is the separator to use when joining the
-strings back together. If the caller supplies a nonempty value,
-<code>join</code> uses it; if it is not supplied, it has a null
-value. In this case, <code>join</code> uses a single blank as a default
-separator for the strings. If the value is equal to <code>SUBSEP</code>,
-then <code>join</code> joins the strings with no separator between them.
-<code>SUBSEP</code> serves as a “magic” value to indicate that
there should
-be no separation between the component strings.<a rel="footnote" href="#fn-58"
name="fnd-58"><sup>58</sup></a>
-
-<div class="node">
-<p><hr>
-<a name="Gettimeofday-Function"></a>Previous: <a rel="previous"
accesskey="p" href="#Join-Function">Join Function</a>,
-Up: <a rel="up" accesskey="u" href="#General-Functions">General
Functions</a>
-<br>
-</div>
-
-<h4 class="subsection">12.2.8 Managing the Time of Day</h4>
-
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-time-1658"></a><a
name="index-functions_002c-library_002c-managing-time-1659"></a><a
name="index-timestamps_002c-formatted-1660"></a><a
name="index-time_002c-managing-1661"></a>The <code>systime</code> and
<code>strftime</code> functions described in
-<a href="#Time-Functions">Time Functions</a>,
-provide the minimum functionality necessary for dealing with the time of day
-in human readable form. While <code>strftime</code> is extensive, the control
-formats are not necessarily easy to remember or intuitively obvious when
-reading a program.
-
- <p>The following function, <code>gettimeofday</code>, populates a
user-supplied array
-with preformatted time information. It returns a string with the current
-time formatted in the same way as the <samp><span
class="command">date</span></samp> utility:
-
- <p><a
name="index-_0040code_007bgettimeofday_007d-user_002ddefined-function-1662"></a>
-<pre class="example"> <!-- file eg/lib/gettime.awk -->
- # gettimeofday.awk --- get the time of day in a usable format
- <!-- endfile -->
- <!-- file eg/lib/gettime.awk -->
-
- # Returns a string in the format of output of date(1)
- # Populates the array argument time with individual values:
- # time["second"] -- seconds (0 - 59)
- # time["minute"] -- minutes (0 - 59)
- # time["hour"] -- hours (0 - 23)
- # time["althour"] -- hours (0 - 12)
- # time["monthday"] -- day of month (1 - 31)
- # time["month"] -- month of year (1 - 12)
- # time["monthname"] -- name of the month
- # time["shortmonth"] -- short name of the month
- # time["year"] -- year modulo 100 (0 - 99)
- # time["fullyear"] -- full year
- # time["weekday"] -- day of week (Sunday = 0)
- # time["altweekday"] -- day of week (Monday = 0)
- # time["dayname"] -- name of weekday
- # time["shortdayname"] -- short name of weekday
- # time["yearday"] -- day of year (0 - 365)
- # time["timezone"] -- abbreviation of timezone name
- # time["ampm"] -- AM or PM designation
- # time["weeknum"] -- week number, Sunday first day
- # time["altweeknum"] -- week number, Monday first day
-
- function gettimeofday(time, ret, now, i)
- {
- # get time once, avoids unnecessary system calls
- now = systime()
-
- # return date(1)-style output
- ret = strftime("%a %b %d %H:%M:%S %Z %Y", now)
-
- # clear out target array
- delete time
-
- # fill in values, force numeric values to be
- # numeric by adding 0
- time["second"] = strftime("%S", now) + 0
- time["minute"] = strftime("%M", now) + 0
- time["hour"] = strftime("%H", now) + 0
- time["althour"] = strftime("%I", now) + 0
- time["monthday"] = strftime("%d", now) + 0
- time["month"] = strftime("%m", now) + 0
- time["monthname"] = strftime("%B", now)
- time["shortmonth"] = strftime("%b", now)
- time["year"] = strftime("%y", now) + 0
- time["fullyear"] = strftime("%Y", now) + 0
- time["weekday"] = strftime("%w", now) + 0
- time["altweekday"] = strftime("%u", now) + 0
- time["dayname"] = strftime("%A", now)
- time["shortdayname"] = strftime("%a", now)
- time["yearday"] = strftime("%j", now) + 0
- time["timezone"] = strftime("%Z", now)
- time["ampm"] = strftime("%p", now)
- time["weeknum"] = strftime("%U", now) + 0
- time["altweeknum"] = strftime("%W", now) + 0
-
- return ret
- }
- <!-- endfile -->
-</pre>
- <p>The string indices are easier to use and read than the various formats
-required by <code>strftime</code>. The <code>alarm</code> program presented in
-<a href="#Alarm-Program">Alarm Program</a>,
-uses this function.
-A more general design for the <code>gettimeofday</code> function would have
-allowed the user to supply an optional timestamp value to use instead
-of the current time.
-
-<div class="node">
-<p><hr>
-<a name="Data-File-Management"></a>Next: <a rel="next" accesskey="n"
href="#Getopt-Function">Getopt Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="#General-Functions">General Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Library-Functions">Library
Functions</a>
-<br>
-</div>
-
-<h3 class="section">12.3 Data File Management</h3>
-
-<!-- STARTOFRANGE dataf -->
-<p><a name="index-files_002c-managing-1663"></a><!-- STARTOFRANGE libfdataf -->
-<a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-_0040value_007bDF_007ds-1664"></a><!--
STARTOFRANGE flibdataf -->
-<a
name="index-functions_002c-library_002c-managing-_0040value_007bDF_007ds-1665"></a>This
section presents functions that are useful for managing
-command-line data files.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Filetrans-Function">Filetrans Function</a>:
A function for handling data file transitions.
-<li><a accesskey="2" href="#Rewind-Function">Rewind Function</a>:
A function for rereading the current file.
-<li><a accesskey="3" href="#File-Checking">File Checking</a>:
Checking that data files are readable.
-<li><a accesskey="4" href="#Empty-Files">Empty Files</a>:
Checking for zero-length files.
-<li><a accesskey="5" href="#Ignoring-Assigns">Ignoring Assigns</a>:
Treating assignments as file names.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Filetrans-Function"></a>Next: <a rel="next" accesskey="n"
href="#Rewind-Function">Rewind Function</a>,
-Up: <a rel="up" accesskey="u" href="#Data-File-Management">Data File
Management</a>
-<br>
-</div>
-
-<h4 class="subsection">12.3.1 Noting Data File Boundaries</h4>
-
-<p><a
name="index-files_002c-managing_002c-_0040value_007bDF_007d-boundaries-1666"></a><a
name="index-files_002c-initialization-and-cleanup-1667"></a>The
<code>BEGIN</code> and <code>END</code> rules are each executed exactly once at
-the beginning and end of your <samp><span class="command">awk</span></samp>
program, respectively
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-We (the <samp><span class="command">gawk</span></samp> authors) once had a
user who mistakenly thought that the
-<code>BEGIN</code> rule is executed at the beginning of each data file and the
-<code>END</code> rule is executed at the end of each data file. When informed
-that this was not the case, the user requested that we add new special
-patterns to <samp><span class="command">gawk</span></samp>, named
<code>BEGIN_FILE</code> and <code>END_FILE</code>, that
-would have the desired behavior. He even supplied us the code to do so.
-
- <p>Adding these special patterns to <samp><span
class="command">gawk</span></samp> wasn't necessary;
-the job can be done cleanly in <samp><span class="command">awk</span></samp>
itself, as illustrated
-by the following library program.
-It arranges to call two user-supplied functions, <code>beginfile</code> and
-<code>endfile</code>, at the beginning and end of each data file.
-Besides solving the problem in only nine(!) lines of code, it does so
-<em>portably</em>; this works with any implementation of <samp><span
class="command">awk</span></samp>:
-
-<pre class="example"> # transfile.awk
- #
- # Give the user a hook for filename transitions
- #
- # The user must supply functions beginfile() and endfile()
- # that each take the name of the file being started or
- # finished, respectively.
- <!-- # -->
- <!-- # Arnold Robbins, arnold@@gnu.org, Public Domain -->
- <!-- # January 1992 -->
-
- FILENAME != _oldfilename \
- {
- if (_oldfilename != "")
- endfile(_oldfilename)
- _oldfilename = FILENAME
- beginfile(FILENAME)
- }
-
- END { endfile(FILENAME) }
-</pre>
- <p>This file must be loaded before the user's “main” program,
so that the
-rule it supplies is executed first.
-
- <p>This rule relies on <samp><span class="command">awk</span></samp>'s
<code>FILENAME</code> variable that
-automatically changes for each new data file. The current file name is
-saved in a private variable, <code>_oldfilename</code>. If
<code>FILENAME</code> does
-not equal <code>_oldfilename</code>, then a new data file is being processed
and
-it is necessary to call <code>endfile</code> for the old file. Because
-<code>endfile</code> should only be called if a file has been processed, the
-program first checks to make sure that <code>_oldfilename</code> is not the
null
-string. The program then assigns the current file name to
-<code>_oldfilename</code> and calls <code>beginfile</code> for the file.
-Because, like all <samp><span class="command">awk</span></samp> variables,
<code>_oldfilename</code> is
-initialized to the null string, this rule executes correctly even for the
-first data file.
-
- <p>The program also supplies an <code>END</code> rule to do the final
processing for
-the last file. Because this <code>END</code> rule comes before any
<code>END</code> rules
-supplied in the “main” program, <code>endfile</code> is called
first. Once
-again the value of multiple <code>BEGIN</code> and <code>END</code> rules
should be clear.
-
- <p><a
name="index-_0040code_007bbeginfile_007d-user_002ddefined-function-1668"></a><a
name="index-_0040code_007bendfile_007d-user_002ddefined-function-1669"></a>This
version has same problem as the first version of <code>nextfile</code>
-(see <a href="#Nextfile-Function">Nextfile Function</a>).
-If the same data file occurs twice in a row on the command line, then
-<code>endfile</code> and <code>beginfile</code> are not executed at the end of
the
-first pass and at the beginning of the second pass.
-The following version solves the problem:
-
-<pre class="example"> <!-- file eg/lib/ftrans.awk -->
- # ftrans.awk --- handle data file transitions
- #
- # user supplies beginfile() and endfile() functions
- <!-- endfile -->
- <!-- file eg/lib/ftrans.awk -->
- FNR == 1 {
- if (_filename_ != "")
- endfile(_filename_)
- _filename_ = FILENAME
- beginfile(FILENAME)
- }
-
- END { endfile(_filename_) }
- <!-- endfile -->
-</pre>
- <p><a href="#Wc-Program">Wc Program</a>,
-shows how this library function can be used and
-how it simplifies writing the main program.
-
-<div class="node">
-<p><hr>
-<a name="Rewind-Function"></a>Next: <a rel="next" accesskey="n"
href="#File-Checking">File Checking</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Filetrans-Function">Filetrans Function</a>,
-Up: <a rel="up" accesskey="u" href="#Data-File-Management">Data File
Management</a>
-<br>
-</div>
-
-<h4 class="subsection">12.3.2 Rereading the Current File</h4>
-
-<p><a name="index-files_002c-reading-1670"></a>Another request for a new
built-in function was for a <code>rewind</code>
-function that would make it possible to reread the current file.
-The requesting user didn't want to have to use <code>getline</code>
-(see <a href="#Getline">Getline</a>)
-inside a loop.
-
- <p>However, as long as you are not in the <code>END</code> rule, it is
-quite easy to arrange to immediately close the current input file
-and then start over with it from the top.
-For lack of a better name, we'll call it <code>rewind</code>:
-
- <p><a
name="index-_0040code_007brewind_007d-user_002ddefined-function-1671"></a>
-<pre class="example"> <!-- file eg/lib/rewind.awk -->
- # rewind.awk --- rewind the current file and start over
- <!-- endfile -->
- <!-- file eg/lib/rewind.awk -->
- function rewind( i)
- {
- # shift remaining arguments up
- for (i = ARGC; i > ARGIND; i--)
- ARGV[i] = ARGV[i-1]
-
- # make sure gawk knows to keep going
- ARGC++
-
- # make current file next to get done
- ARGV[ARGIND+1] = FILENAME
-
- # do it
- nextfile
- }
- <!-- endfile -->
-</pre>
- <p>This code relies on the <code>ARGIND</code> variable
-(see <a href="#Auto_002dset">Auto-set</a>),
-which is specific to <samp><span class="command">gawk</span></samp>.
-If you are not using
-<samp><span class="command">gawk</span></samp>, you can use ideas presented in
-the previous section
-to either update <code>ARGIND</code> on your own
-or modify this code as appropriate.
-
- <p>The <code>rewind</code> function also relies on the
<code>nextfile</code> keyword
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-See <a href="#Nextfile-Function">Nextfile Function</a>,
-for a function version of <code>nextfile</code>.
-
-<div class="node">
-<p><hr>
-<a name="File-Checking"></a>Next: <a rel="next" accesskey="n"
href="#Empty-Files">Empty Files</a>,
-Previous: <a rel="previous" accesskey="p" href="#Rewind-Function">Rewind
Function</a>,
-Up: <a rel="up" accesskey="u" href="#Data-File-Management">Data File
Management</a>
-<br>
-</div>
-
-<h4 class="subsection">12.3.3 Checking for Readable Data Files</h4>
-
-<p><a
name="index-troubleshooting_002c-readable-_0040value_007bDF_007ds-1672"></a><a
name="index-readable-_0040value_007bDF_007ds_0040comma_007b_007d-checking-1673"></a><a
name="index-files_002c-skipping-1674"></a>Normally, if you give <samp><span
class="command">awk</span></samp> a data file that isn't readable,
-it stops with a fatal error. There are times when you
-might want to just ignore such files and keep going. You can
-do this by prepending the following program to your <samp><span
class="command">awk</span></samp>
-program:
-
- <p><a name="index-_0040code_007breadable_002eawk_007d-program-1675"></a>
-<pre class="example"> <!-- file eg/lib/readable.awk -->
- # readable.awk --- library file to skip over unreadable files
- <!-- endfile -->
- <!-- file eg/lib/readable.awk -->
- BEGIN {
- for (i = 1; i < ARGC; i++) {
- if (ARGV[i] ~ /^[A-Za-z_][A-Za-z0-9_]*=.*/ \
- || ARGV[i] == "-")
- continue # assignment or standard input
- else if ((getline junk < ARGV[i]) < 0) # unreadable
- delete ARGV[i]
- else
- close(ARGV[i])
- }
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-troubleshooting_002c-_0040code_007bgetline_007d-function-1676"></a>In
<samp><span class="command">gawk</span></samp>, the <code>getline</code> won't
be fatal (unless
-<samp><span class="option">--posix</span></samp> is in force).
-Removing the element from <code>ARGV</code> with <code>delete</code>
-skips the file (since it's no longer in the list).
-
-<!-- This doesn't handle /dev/stdin etc. Not worth the hassle to mention or
fix. -->
-<div class="node">
-<p><hr>
-<a name="Empty-Files"></a>Next: <a rel="next" accesskey="n"
href="#Ignoring-Assigns">Ignoring Assigns</a>,
-Previous: <a rel="previous" accesskey="p" href="#File-Checking">File
Checking</a>,
-Up: <a rel="up" accesskey="u" href="#Data-File-Management">Data File
Management</a>
-<br>
-</div>
-
-<h4 class="subsection">12.3.4 Checking For Zero-length Files</h4>
-
-<p>All known <samp><span class="command">awk</span></samp> implementations
silently skip over zero-length files.
-This is a by-product of <samp><span class="command">awk</span></samp>'s
implicit
-read-a-record-and-match-against-the-rules loop: when <samp><span
class="command">awk</span></samp>
-tries to read a record from an empty file, it immediately receives an
-end of file indication, closes the file, and proceeds on to the next
-command-line data file, <em>without</em> executing any user-level
-<samp><span class="command">awk</span></samp> program code.
-
- <p>Using <samp><span class="command">gawk</span></samp>'s
<code>ARGIND</code> variable
-(see <a href="#Built_002din-Variables">Built-in Variables</a>), it is possible
to detect when an empty
-data file has been skipped. Similar to the library file presented
-in <a href="#Filetrans-Function">Filetrans Function</a>, the following library
file calls a function named
-<code>zerofile</code> that the user must provide. The arguments passed are
-the file name and the position in <code>ARGV</code> where it was found:
-
- <p><a name="index-_0040code_007bzerofile_002eawk_007d-program-1677"></a>
-<pre class="example"> <!-- file eg/lib/zerofile.awk -->
- # zerofile.awk --- library file to process empty input files
- <!-- endfile -->
- <!-- file eg/lib/zerofile.awk -->
- BEGIN { Argind = 0 }
-
- ARGIND > Argind + 1 {
- for (Argind++; Argind < ARGIND; Argind++)
- zerofile(ARGV[Argind], Argind)
- }
-
- ARGIND != Argind { Argind = ARGIND }
-
- END {
- if (ARGIND > Argind)
- for (Argind++; Argind <= ARGIND; Argind++)
- zerofile(ARGV[Argind], Argind)
- }
- <!-- endfile -->
-</pre>
- <p>The user-level variable <code>Argind</code> allows the <samp><span
class="command">awk</span></samp> program
-to track its progress through <code>ARGV</code>. Whenever the program detects
-that <code>ARGIND</code> is greater than `<samp><span class="samp">Argind +
1</span></samp>', it means that one or
-more empty files were skipped. The action then calls <code>zerofile</code> for
-each such file, incrementing <code>Argind</code> along the way.
-
- <p>The `<samp><span class="samp">Argind != ARGIND</span></samp>' rule
simply keeps <code>Argind</code> up to date
-in the normal case.
-
- <p>Finally, the <code>END</code> rule catches the case of any empty files at
-the end of the command-line arguments. Note that the test in the
-condition of the <code>for</code> loop uses the `<samp><span
class="samp"><=</span></samp>' operator,
-not <code><</code>.
-
- <p>As an exercise, you might consider whether this same problem can
-be solved without relying on <samp><span class="command">gawk</span></samp>'s
<code>ARGIND</code> variable.
-
- <p>As a second exercise, revise this code to handle the case where
-an intervening value in <code>ARGV</code> is a variable assignment.
-
-<div class="node">
-<p><hr>
-<a name="Ignoring-Assigns"></a>Previous: <a rel="previous" accesskey="p"
href="#Empty-Files">Empty Files</a>,
-Up: <a rel="up" accesskey="u" href="#Data-File-Management">Data File
Management</a>
-<br>
-</div>
-
-<h4 class="subsection">12.3.5 Treating Assignments as File Names</h4>
-
-<p><a name="index-assignments-as-filenames-1678"></a><a
name="index-filenames_002c-assignments-as-1679"></a>Occasionally, you might not
want <samp><span class="command">awk</span></samp> to process command-line
-variable assignments
-(see <a href="#Assignment-Options">Assignment Options</a>).
-In particular, if you have file names that contain an `<samp><span
class="samp">=</span></samp>' character,
-<samp><span class="command">awk</span></samp> treats the file name as an
assignment, and does not process it.
-
- <p>Some users have suggested an additional command-line option for
<samp><span class="command">gawk</span></samp>
-to disable command-line assignments. However, some simple programming with
-a library file does the trick:
-
- <p><a name="index-_0040code_007bnoassign_002eawk_007d-program-1680"></a>
-<pre class="example"> <!-- file eg/lib/noassign.awk -->
- # noassign.awk --- library file to avoid the need for a
- # special option that disables command-line assignments
- <!-- endfile -->
- <!-- file eg/lib/noassign.awk -->
- function disable_assigns(argc, argv, i)
- {
- for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[A-Za-z_][A-Za-z_0-9]*=.*/)
- argv[i] = ("./" argv[i])
- }
-
- BEGIN {
- if (No_command_assign)
- disable_assigns(ARGC, ARGV)
- }
- <!-- endfile -->
-</pre>
- <p>You then run your program this way:
-
-<pre class="example"> awk -v No_command_assign=1 -f noassign.awk -f
yourprog.awk *
-</pre>
- <p>The function works by looping through the arguments.
-It prepends `<samp><span class="samp">./</span></samp>' to
-any argument that matches the form
-of a variable assignment, turning that argument into a file name.
-
- <p>The use of <code>No_command_assign</code> allows you to disable
command-line
-assignments at invocation time, by giving the variable a true value.
-When not set, it is initially zero (i.e., false), so the command-line arguments
-are left alone.
-<!-- ENDOFRANGE dataf -->
-<!-- ENDOFRANGE flibdataf -->
-<!-- ENDOFRANGE libfdataf -->
-
-<div class="node">
-<p><hr>
-<a name="Getopt-Function"></a>Next: <a rel="next" accesskey="n"
href="#Passwd-Functions">Passwd Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Data-File-Management">Data File Management</a>,
-Up: <a rel="up" accesskey="u" href="#Library-Functions">Library
Functions</a>
-<br>
-</div>
-
-<h3 class="section">12.4 Processing Command-Line Options</h3>
-
-<!-- STARTOFRANGE libfclo -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-command_002dline-options-1681"></a><!--
STARTOFRANGE flibclo -->
-<a
name="index-functions_002c-library_002c-command_002dline-options-1682"></a><!--
STARTOFRANGE clop -->
-<a name="index-command_002dline-options_002c-processing-1683"></a><!--
STARTOFRANGE oclp -->
-<a name="index-options_002c-command_002dline_002c-processing-1684"></a><!--
STARTOFRANGE clibf -->
-<a name="index-functions_002c-library_002c-C-library-1685"></a><a
name="index-arguments_002c-processing-1686"></a>Most utilities on POSIX
compatible systems take options, or “switches,” on
-the command line that can be used to change the way a program behaves.
-<samp><span class="command">awk</span></samp> is an example of such a program
-(see <a href="#Options">Options</a>).
-Often, options take <dfn>arguments</dfn>; i.e., data that the program needs to
-correctly obey the command-line option. For example, <samp><span
class="command">awk</span></samp>'s
-<samp><span class="option">-F</span></samp> option requires a string to use as
the field separator.
-The first occurrence on the command line of either <samp><span
class="option">--</span></samp> or a
-string that does not begin with `<samp><span class="samp">-</span></samp>'
ends the options.
-
- <p><a
name="index-_0040code_007bgetopt_007d-function-_0028C-library_0029-1687"></a>Modern
Unix systems provide a C function named <code>getopt</code> for processing
-command-line arguments. The programmer provides a string describing the
-one-letter options. If an option requires an argument, it is followed in the
-string with a colon. <code>getopt</code> is also passed the
-count and values of the command-line arguments and is called in a loop.
-<code>getopt</code> processes the command-line arguments for option letters.
-Each time around the loop, it returns a single character representing the
-next option letter that it finds, or `<samp><span
class="samp">?</span></samp>' if it finds an invalid option.
-When it returns −1, there are no options left on the command line.
-
- <p>When using <code>getopt</code>, options that do not take arguments can be
-grouped together. Furthermore, options that take arguments require that the
-argument is present. The argument can immediately follow the option letter,
-or it can be a separate command-line argument.
-
- <p>Given a hypothetical program that takes
-three command-line options, <samp><span class="option">-a</span></samp>,
<samp><span class="option">-b</span></samp>, and <samp><span
class="option">-c</span></samp>, where
-<samp><span class="option">-b</span></samp> requires an argument, all of the
following are valid ways of
-invoking the program:
-
-<pre class="example"> prog -a -b foo -c data1 data2 data3
- prog -ac -bfoo -- data1 data2 data3
- prog -acbfoo data1 data2 data3
-</pre>
- <p>Notice that when the argument is grouped with its option, the rest of
-the argument is considered to be the option's argument.
-In this example, <samp><span class="option">-acbfoo</span></samp> indicates
that all of the
-<samp><span class="option">-a</span></samp>, <samp><span
class="option">-b</span></samp>, and <samp><span
class="option">-c</span></samp> options were supplied,
-and that `<samp><span class="samp">foo</span></samp>' is the argument to the
<samp><span class="option">-b</span></samp> option.
-
- <p><code>getopt</code> provides four external variables that the programmer
can use:
-
- <dl>
-<dt><code>optind</code><dd>The index in the argument value array
(<code>argv</code>) where the first
-nonoption command-line argument can be found.
-
- <br><dt><code>optarg</code><dd>The string value of the argument to an
option.
-
- <br><dt><code>opterr</code><dd>Usually <code>getopt</code> prints an
error message when it finds an invalid
-option. Setting <code>opterr</code> to zero disables this feature. (An
-application might want to print its own error message.)
-
- <br><dt><code>optopt</code><dd>The letter representing the command-line
option.
-<!-- While not usually documented, most versions supply this variable. -->
-</dl>
-
- <p>The following C fragment shows how <code>getopt</code> might process
command-line
-arguments for <samp><span class="command">awk</span></samp>:
-
-<pre class="example"> int
- main(int argc, char *argv[])
- {
- ...
- /* print our own message */
- opterr = 0;
- while ((c = getopt(argc, argv, "v:f:F:W:")) != -1) {
- switch (c) {
- case 'f': /* file */
- ...
- break;
- case 'F': /* field separator */
- ...
- break;
- case 'v': /* variable assignment */
- ...
- break;
- case 'W': /* extension */
- ...
- break;
- case '?':
- default:
- usage();
- break;
- }
- }
- ...
- }
-</pre>
- <p>As a side point, <samp><span class="command">gawk</span></samp> actually
uses the GNU <code>getopt_long</code>
-function to process both normal and GNU-style long options
-(see <a href="#Options">Options</a>).
-
- <p>The abstraction provided by <code>getopt</code> is very useful and is
quite
-handy in <samp><span class="command">awk</span></samp> programs as well.
Following is an <samp><span class="command">awk</span></samp>
-version of <code>getopt</code>. This function highlights one of the
-greatest weaknesses in <samp><span class="command">awk</span></samp>, which is
that it is very poor at
-manipulating single characters. Repeated calls to <code>substr</code> are
-necessary for accessing individual characters
-(see <a href="#String-Functions">String Functions</a>).<a rel="footnote"
href="#fn-59" name="fnd-59"><sup>59</sup></a>
-
- <p>The discussion that follows walks through the code a bit at a time:
-
- <p><a
name="index-_0040code_007bgetopt_007d-user_002ddefined-function-1688"></a>
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- # getopt.awk --- do C library getopt(3) function in awk
- <!-- endfile -->
- <!-- file eg/lib/getopt.awk -->
- # External variables:
- # Optind -- index in ARGV of first nonoption argument
- # Optarg -- string value of argument to current option
- # Opterr -- if nonzero, print our own diagnostic
- # Optopt -- current option letter
-
- # Returns:
- # -1 at end of options
- # ? for unrecognized option
- # <c> a character representing the current option
-
- # Private Data:
- # _opti -- index in multi-flag option, e.g., -abc
- <!-- endfile -->
-</pre>
- <p>The function starts out with
-a list of the global variables it uses,
-what the return values are, what they mean, and any global variables that
-are “private” to this library function. Such documentation is
essential
-for any program, and particularly for library functions.
-
- <p>The <code>getopt</code> function first checks that it was indeed called
with a string of options
-(the <code>options</code> parameter). If <code>options</code> has a zero
length,
-<code>getopt</code> immediately returns −1:
-
- <p><a
name="index-_0040code_007bgetopt_007d-user_002ddefined-function-1689"></a>
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- function getopt(argc, argv, options, thisopt, i)
- {
- if (length(options) == 0) # no options given
- return -1
-
- if (argv[Optind] == "--") { # all done
- Optind++
- _opti = 0
- return -1
- } else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) {
- _opti = 0
- return -1
- }
- <!-- endfile -->
-</pre>
- <p>The next thing to check for is the end of the options. A <samp><span
class="option">--</span></samp>
-ends the command-line options, as does any command-line argument that
-does not begin with a `<samp><span class="samp">-</span></samp>'.
<code>Optind</code> is used to step through
-the array of command-line arguments; it retains its value across calls
-to <code>getopt</code>, because it is a global variable.
-
- <p>The regular expression that is used,
<code>/^-[^: \t\n\f\r\v\b]/<!-- /@w --></code>, is
-perhaps a bit of overkill; it checks for a `<samp><span
class="samp">-</span></samp>' followed by anything
-that is not whitespace and not a colon.
-If the current command-line argument does not match this pattern,
-it is not an option, and it ends option processing:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- if (_opti == 0)
- _opti = 2
- thisopt = substr(argv[Optind], _opti, 1)
- Optopt = thisopt
- i = index(options, thisopt)
- if (i == 0) {
- if (Opterr)
- printf("%c -- invalid option\n",
- thisopt) > "/dev/stderr"
- if (_opti >= length(argv[Optind])) {
- Optind++
- _opti = 0
- } else
- _opti++
- return "?"
- }
- <!-- endfile -->
-</pre>
- <p>The <code>_opti</code> variable tracks the position in the current
command-line
-argument (<code>argv[Optind]</code>). If multiple options are
-grouped together with one `<samp><span class="samp">-</span></samp>' (e.g.,
<samp><span class="option">-abx</span></samp>), it is necessary
-to return them to the user one at a time.
-
- <p>If <code>_opti</code> is equal to zero, it is set to two, which is the
index in
-the string of the next character to look at (we skip the `<samp><span
class="samp">-</span></samp>', which
-is at position one). The variable <code>thisopt</code> holds the character,
-obtained with <code>substr</code>. It is saved in <code>Optopt</code> for the
main
-program to use.
-
- <p>If <code>thisopt</code> is not in the <code>options</code> string, then
it is an
-invalid option. If <code>Opterr</code> is nonzero, <code>getopt</code> prints
an error
-message on the standard error that is similar to the message from the C
-version of <code>getopt</code>.
-
- <p>Because the option is invalid, it is necessary to skip it and move on to
the
-next option character. If <code>_opti</code> is greater than or equal to the
-length of the current command-line argument, it is necessary to move on
-to the next argument, so <code>Optind</code> is incremented and
<code>_opti</code> is reset
-to zero. Otherwise, <code>Optind</code> is left alone and <code>_opti</code>
is merely
-incremented.
-
- <p>In any case, because the option is invalid, <code>getopt</code> returns
`<samp><span class="samp">?</span></samp>'.
-The main program can examine <code>Optopt</code> if it needs to know what the
-invalid option letter actually is. Continuing on:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- if (substr(options, i + 1, 1) == ":") {
- # get option argument
- if (length(substr(argv[Optind], _opti + 1)) > 0)
- Optarg = substr(argv[Optind], _opti + 1)
- else
- Optarg = argv[++Optind]
- _opti = 0
- } else
- Optarg = ""
- <!-- endfile -->
-</pre>
- <p>If the option requires an argument, the option letter is followed by a
colon
-in the <code>options</code> string. If there are remaining characters in the
-current command-line argument (<code>argv[Optind]</code>), then the rest of
that
-string is assigned to <code>Optarg</code>. Otherwise, the next command-line
-argument is used (`<samp><span class="samp">-xFOO</span></samp>' versus
`<samp><span class="samp">-x FOO<!-- /@w --></span></samp>'). In either
case,
-<code>_opti</code> is reset to zero, because there are no more characters left
to
-examine in the current command-line argument. Continuing:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- if (_opti == 0 || _opti >= length(argv[Optind])) {
- Optind++
- _opti = 0
- } else
- _opti++
- return thisopt
- }
- <!-- endfile -->
-</pre>
- <p>Finally, if <code>_opti</code> is either zero or greater than the length
of the
-current command-line argument, it means this element in <code>argv</code> is
-through being processed, so <code>Optind</code> is incremented to point to the
-next element in <code>argv</code>. If neither condition is true, then only
-<code>_opti</code> is incremented, so that the next option letter can be
processed
-on the next call to <code>getopt</code>.
-
- <p>The <code>BEGIN</code> rule initializes both <code>Opterr</code> and
<code>Optind</code> to one.
-<code>Opterr</code> is set to one, since the default behavior is for
<code>getopt</code>
-to print a diagnostic message upon seeing an invalid option.
<code>Optind</code>
-is set to one, since there's no reason to look at the program name, which is
-in <code>ARGV[0]</code>:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- BEGIN {
- Opterr = 1 # default is to diagnose
- Optind = 1 # skip ARGV[0]
-
- # test program
- if (_getopt_test) {
- while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1)
- printf("c = <%c>, optarg = <%s>\n",
- _go_c, Optarg)
- printf("non-option arguments:\n")
- for (; Optind < ARGC; Optind++)
- printf("\tARGV[%d] = <%s>\n",
- Optind, ARGV[Optind])
- }
- }
- <!-- endfile -->
-</pre>
- <p>The rest of the <code>BEGIN</code> rule is a simple test program. Here
is the
-result of two sample runs of the test program:
-
-<pre class="example"> $ awk -f getopt.awk -v _getopt_test=1 -- -a -cbARG
bax -x
- -| c = <a>, optarg = <>
- -| c = <c>, optarg = <>
- -| c = <b>, optarg = <ARG>
- -| non-option arguments:
- -| ARGV[3] = <bax>
- -| ARGV[4] = <-x>
-
- $ awk -f getopt.awk -v _getopt_test=1 -- -a -x -- xyz abc
- -| c = <a>, optarg = <>
- error--> x -- invalid option
- -| c = <?>, optarg = <>
- -| non-option arguments:
- -| ARGV[4] = <xyz>
- -| ARGV[5] = <abc>
-</pre>
- <p>In both runs,
-the first <samp><span class="option">--</span></samp> terminates the arguments
to <samp><span class="command">awk</span></samp>, so that it does
-not try to interpret the <samp><span class="option">-a</span></samp>, etc., as
its own options.
-Several of the sample programs presented in
-<a href="#Sample-Programs">Sample Programs</a>,
-use <code>getopt</code> to process their arguments.
-<!-- ENDOFRANGE libfclo -->
-<!-- ENDOFRANGE flibclo -->
-<!-- ENDOFRANGE clop -->
-<!-- ENDOFRANGE oclp -->
-
-<div class="node">
-<p><hr>
-<a name="Passwd-Functions"></a>Next: <a rel="next" accesskey="n"
href="#Group-Functions">Group Functions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Getopt-Function">Getopt
Function</a>,
-Up: <a rel="up" accesskey="u" href="#Library-Functions">Library
Functions</a>
-<br>
-</div>
-
-<h3 class="section">12.5 Reading the User Database</h3>
-
-<!-- STARTOFRANGE libfudata -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-user-database_002c-reading-1690"></a><!--
STARTOFRANGE flibudata -->
-<a
name="index-functions_002c-library_002c-user-database_002c-reading-1691"></a><!--
STARTOFRANGE udatar -->
-<a name="index-user-database_0040comma_007b_007d-reading-1692"></a><!--
STARTOFRANGE dataur -->
-<a name="index-database_002c-users_0040comma_007b_007d-reading-1693"></a><a
name="index-_0040code_007bPROCINFO_007d-array-1694"></a>The
<code>PROCINFO</code> array
-(see <a href="#Built_002din-Variables">Built-in Variables</a>)
-provides access to the current user's real and effective user and group ID
-numbers, and if available, the user's supplementary group set.
-However, because these are numbers, they do not provide very useful
-information to the average user. There needs to be some way to find the
-user information associated with the user and group ID numbers. This
-section presents a suite of functions for retrieving information from the
-user database. See <a href="#Group-Functions">Group Functions</a>,
-for a similar suite that retrieves information from the group database.
-
- <p><a
name="index-_0040code_007bgetpwent_007d-function-_0028C-library_0029-1695"></a><a
name="index-_0040code_007bgetpwent_007d-user_002ddefined-function-1696"></a><a
name="index-users_002c-information-about_002c-retrieving-1697"></a><a
name="index-login-information-1698"></a><a
name="index-account-information-1699"></a><a
name="index-password-file-1700"></a><a
name="index-files_002c-password-1701"></a>The POSIX standard does not define
the file where user information is
-kept. Instead, it provides the <code><pwd.h></code> header file
-and several C language subroutines for obtaining user information.
-The primary function is <code>getpwent</code>, for “get password
entry.”
-The “password” comes from the original user database file,
-<samp><span class="file">/etc/passwd</span></samp>, which stores user
information, along with the
-encrypted passwords (hence the name).
-
- <p><a name="index-_0040command_007bpwcat_007d-program-1702"></a>While an
<samp><span class="command">awk</span></samp> program could simply read
<samp><span class="file">/etc/passwd</span></samp>
-directly, this file may not contain complete information about the
-system's set of users.<a rel="footnote" href="#fn-60"
name="fnd-60"><sup>60</sup></a> To be sure you are able to
-produce a readable and complete version of the user database, it is necessary
-to write a small C program that calls <code>getpwent</code>.
<code>getpwent</code>
-is defined as returning a pointer to a <code>struct passwd</code>. Each time
it
-is called, it returns the next entry in the database. When there are
-no more entries, it returns <code>NULL</code>, the null pointer. When this
-happens, the C program should call <code>endpwent</code> to close the
database.
-Following is <samp><span class="command">pwcat</span></samp>, a C program that
“cats” the password database:
-
-<!-- Use old style function header for portability to old systems (SunOS,
HP/UX). -->
-<pre class="example"> <!-- file eg/lib/pwcat.c -->
- /*
- * pwcat.c
- *
- * Generate a printable version of the password database
- */
- <!-- endfile -->
- <!-- file eg/lib/pwcat.c -->
- #include <stdio.h>
- #include <pwd.h>
-
- <!-- endfile -->
- <!-- file eg/lib/pwcat.c -->
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct passwd *p;
-
- while ((p = getpwent()) != NULL)
- printf("%s:%s:%ld:%ld:%s:%s:%s\n",
- p->pw_name, p->pw_passwd, (long) p->pw_uid,
- (long) p->pw_gid, p->pw_gecos, p->pw_dir,
p->pw_shell);
-
- endpwent();
- return 0;
- }
- <!-- endfile -->
-</pre>
- <p>If you don't understand C, don't worry about it.
-The output from <samp><span class="command">pwcat</span></samp> is the user
database, in the traditional
-<samp><span class="file">/etc/passwd</span></samp> format of colon-separated
fields. The fields are:
-
- <p><table summary=""><tr align="left"><td valign="top">Login name </td><td
valign="top">The user's login name.
-
-<p><br></td></tr><tr align="left"><td valign="top">Encrypted password </td><td
valign="top">The user's encrypted password. This may not be available on some
systems.
-
-<p><br></td></tr><tr align="left"><td valign="top">User-ID </td><td
valign="top">The user's numeric user ID number.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group-ID </td><td
valign="top">The user's numeric group ID number.
-
-<p><br></td></tr><tr align="left"><td valign="top">Full name </td><td
valign="top">The user's full name, and perhaps other information associated
with the
-user.
-
-<p><br></td></tr><tr align="left"><td valign="top">Home directory </td><td
valign="top">The user's login (or “home”) directory (familiar to
shell programmers as
-<code>$HOME</code>).
-
-<p><br></td></tr><tr align="left"><td valign="top">Login shell </td><td
valign="top">The program that is run when the user logs in. This is usually a
-shell, such as <samp><span class="command">bash</span></samp>.
- <br></td></tr></table>
-
- <p>A few lines representative of <samp><span
class="command">pwcat</span></samp>'s output are as follows:
-
- <p><a name="index-Jacobs_002c-Andrew-1703"></a><a
name="index-Robbins_002c-Arnold-1704"></a><a
name="index-Robbins_002c-Miriam-1705"></a>
-<pre class="example"> $ pwcat
- -| root:3Ov02d5VaUPB6:0:1:Operator:/:/bin/sh
- -| nobody:*:65534:65534::/:
- -| daemon:*:1:1::/:
- -| sys:*:2:2::/:/bin/csh
- -| bin:*:3:3::/bin:
- -| arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/sh
- -| miriam:yxaay:112:10:Miriam Robbins:/home/miriam:/bin/sh
- -| andy:abcca2:113:10:Andy Jacobs:/home/andy:/bin/sh
- ...
-</pre>
- <p>With that introduction, following is a group of functions for getting
user
-information. There are several functions here, corresponding to the C
-functions of the same names:
-
-<!-- Exercise: simplify all these functions that return values. -->
-<!-- Answer: return foo[key] returns "" if key not there, no need to check
with `in'. -->
-<p><a
name="index-_0040code_007b_005fpw_005finit_007d-user_002ddefined-function-1706"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- # passwd.awk --- access password file information
- <!-- endfile -->
- <!-- file eg/lib/passwdawk.in -->
- BEGIN {
- # tailor this to suit your system
- _pw_awklib = "/usr/local/libexec/awk/"
- }
-
- function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw)
- {
- if (_pw_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
- FS = ":"
- RS = "\n"
-
- pwcat = _pw_awklib "pwcat"
- while ((pwcat | getline) > 0) {
- _pw_byname[$1] = $0
- _pw_byuid[$3] = $0
- _pw_bycount[++_pw_total] = $0
- }
- close(pwcat)
- _pw_count = 0
- _pw_inited = 1
- FS = oldfs
- if (using_fw)
- FIELDWIDTHS = FIELDWIDTHS
- RS = oldrs
- $0 = olddol0
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bpwcat_007d-program-1707"></a>The
<code>BEGIN</code> rule sets a private variable to the directory where
-<samp><span class="command">pwcat</span></samp> is stored. Because it is used
to help out an <samp><span class="command">awk</span></samp> library
-routine, we have chosen to put it in <samp><span
class="file">/usr/local/libexec/awk</span></samp>;
-however, you might want it to be in a different directory on your system.
-
- <p>The function <code>_pw_init</code> keeps three copies of the user
information
-in three associative arrays. The arrays are indexed by username
-(<code>_pw_byname</code>), by user ID number (<code>_pw_byuid</code>), and by
order of
-occurrence (<code>_pw_bycount</code>).
-The variable <code>_pw_inited</code> is used for efficiency;
<code>_pw_init</code>
-needs only to be called once.
-
- <p><a
name="index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fpw_005finit_007d-function-1708"></a>Because
this function uses <code>getline</code> to read information from
-<samp><span class="command">pwcat</span></samp>, it first saves the values of
<code>FS</code>, <code>RS</code>, and <code>$0</code>.
-It notes in the variable <code>using_fw</code> whether field splitting
-with <code>FIELDWIDTHS</code> is in effect or not.
-Doing so is necessary, since these functions could be called
-from anywhere within a user's program, and the user may have his
-or her
-own way of splitting records and fields.
-
- <p>The <code>using_fw</code> variable checks <code>PROCINFO["FS"]</code>,
which
-is <code>"FIELDWIDTHS"</code> if field splitting is being done with
-<code>FIELDWIDTHS</code>. This makes it possible to restore the correct
-field-splitting mechanism later. The test can only be true for
-<samp><span class="command">gawk</span></samp>. It is false if using
<code>FS</code> or on some other
-<samp><span class="command">awk</span></samp> implementation.
-
- <p>The main part of the function uses a loop to read database lines, split
-the line into fields, and then store the line into each array as necessary.
-When the loop is done, <code>_pw_init<!-- /@w --></code> cleans up by closing
the pipeline,
-setting <code>_pw_inited<!-- /@w --></code> to one, and restoring
<code>FS</code> (and <code>FIELDWIDTHS</code>
-if necessary), <code>RS</code>, and <code>$0</code>.
-The use of <code>_pw_count<!-- /@w --></code> is explained shortly.
-
-<!-- NEXT ED: All of these functions don't need the ... in ... test. Just -->
-<!-- return the array element, which will be "" if not already there. Duh. -->
-<p><a
name="index-_0040code_007bgetpwnam_007d-function-_0028C-library_0029-1709"></a>The
<code>getpwnam</code> function takes a username as a string argument. If that
-user is in the database, it returns the appropriate line. Otherwise, it
-returns the null string:
-
- <p><a
name="index-_0040code_007bgetpwnam_007d-user_002ddefined-function-1710"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function getpwnam(name)
- {
- _pw_init()
- if (name in _pw_byname)
- return _pw_byname[name]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetpwuid_007d-function-_0028C-library_0029-1711"></a>Similarly,
-the <code>getpwuid</code> function takes a user ID number argument. If that
-user number is in the database, it returns the appropriate line. Otherwise, it
-returns the null string:
-
- <p><a
name="index-_0040code_007bgetpwuid_007d-user_002ddefined-function-1712"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function getpwuid(uid)
- {
- _pw_init()
- if (uid in _pw_byuid)
- return _pw_byuid[uid]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetpwent_007d-function-_0028C-library_0029-1713"></a>The
<code>getpwent</code> function simply steps through the database, one entry at
-a time. It uses <code>_pw_count</code> to track its current position in the
-<code>_pw_bycount</code> array:
-
- <p><a
name="index-_0040code_007bgetpwent_007d-user_002ddefined-function-1714"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function getpwent()
- {
- _pw_init()
- if (_pw_count < _pw_total)
- return _pw_bycount[++_pw_count]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bendpwent_007d-function-_0028C-library_0029-1715"></a>The
<code>endpwent<!-- /@w --></code> function resets <code>_pw_count<!-- /@w
--></code> to zero, so that
-subsequent calls to <code>getpwent</code> start over again:
-
- <p><a
name="index-_0040code_007bendpwent_007d-user_002ddefined-function-1716"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function endpwent()
- {
- _pw_count = 0
- }
- <!-- endfile -->
-</pre>
- <p>A conscious design decision in this suite was made that each subroutine
calls
-<code>_pw_init<!-- /@w --></code> to initialize the database arrays. The
overhead of running
-a separate process to generate the user database, and the I/O to scan it,
-are only incurred if the user's main program actually calls one of these
-functions. If this library file is loaded along with a user's program, but
-none of the routines are ever called, then there is no extra runtime overhead.
-(The alternative is move the body of <code>_pw_init<!-- /@w --></code> into a
-<code>BEGIN</code> rule, which always runs <samp><span
class="command">pwcat</span></samp>. This simplifies the
-code but runs an extra process that may never be needed.)
-
- <p>In turn, calling <code>_pw_init</code> is not too expensive, because the
-<code>_pw_inited</code> variable keeps the program from reading the data more
than
-once. If you are worried about squeezing every last cycle out of your
-<samp><span class="command">awk</span></samp> program, the check of
<code>_pw_inited</code> could be moved out of
-<code>_pw_init</code> and duplicated in all the other functions. In practice,
-this is not necessary, since most <samp><span
class="command">awk</span></samp> programs are I/O-bound, and it
-clutters up the code.
-
- <p>The <samp><span class="command">id</span></samp> program in <a
href="#Id-Program">Id Program</a>,
-uses these functions.
-<!-- ENDOFRANGE libfudata -->
-<!-- ENDOFRANGE flibudata -->
-<!-- ENDOFRANGE udatar -->
-<!-- ENDOFRANGE dataur -->
-
-<div class="node">
-<p><hr>
-<a name="Group-Functions"></a>Previous: <a rel="previous" accesskey="p"
href="#Passwd-Functions">Passwd Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Library-Functions">Library
Functions</a>
-<br>
-</div>
-
-<h3 class="section">12.6 Reading the Group Database</h3>
-
-<!-- STARTOFRANGE libfgdata -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-group-database_002c-reading-1717"></a><!--
STARTOFRANGE flibgdata -->
-<a
name="index-functions_002c-library_002c-group-database_002c-reading-1718"></a><!--
STARTOFRANGE gdatar -->
-<a name="index-group-database_002c-reading-1719"></a><!-- STARTOFRANGE datagr
-->
-<a name="index-database_002c-group_002c-reading-1720"></a><a
name="index-_0040code_007bPROCINFO_007d-array-1721"></a><a
name="index-_0040code_007bgetgrent_007d-function-_0028C-library_0029-1722"></a><a
name="index-_0040code_007bgetgrent_007d-user_002ddefined-function-1723"></a><a
name="index-groups_0040comma_007b_007d-information-about-1724"></a><a
name="index-account-information-1725"></a><a
name="index-group-file-1726"></a><a name="index-files_002c-group-1727"></a>Much
of the discussion presented in
-<a href="#Passwd-Functions">Passwd Functions</a>,
-applies to the group database as well. Although there has traditionally
-been a well-known file (<samp><span class="file">/etc/group</span></samp>) in
a well-known format, the POSIX
-standard only provides a set of C library routines
-(<code><grp.h></code> and <code>getgrent</code>)
-for accessing the information.
-Even though this file may exist, it likely does not have
-complete information. Therefore, as with the user database, it is necessary
-to have a small C program that generates the group database as its output.
-
- <p><a name="index-_0040command_007bgrcat_007d-program-1728"></a><samp><span
class="command">grcat</span></samp>, a C program that “cats” the
group database,
-is as follows:
-
-<pre class="example"> <!-- file eg/lib/grcat.c -->
- /*
- * grcat.c
- *
- * Generate a printable version of the group database
- */
- <!-- endfile -->
- <!-- file eg/lib/grcat.c -->
- #include <stdio.h>
- #include <grp.h>
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct group *g;
- int i;
-
- while ((g = getgrent()) != NULL) {
- printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
- (long) g->gr_gid);
- for (i = 0; g->gr_mem[i] != NULL; i++) {
- printf("%s", g->gr_mem[i]);
- if (g->gr_mem[i+1] != NULL)
- putchar(',');
- }
- putchar('\n');
- }
- endgrent();
- return 0;
- }
- <!-- endfile -->
-</pre>
- <p>Each line in the group database represents one group. The fields are
-separated with colons and represent the following information:
-
- <p><table summary=""><tr align="left"><td valign="top">Group name </td><td
valign="top">The group's name.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group password </td><td
valign="top">The group's encrypted password. In practice, this field is never
used;
-it is usually empty or set to `<samp><span class="samp">*</span></samp>'.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group-ID </td><td
valign="top">
-The group's numeric group ID number; this number should be unique within the
file.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group member list </td><td
valign="top">
-A comma-separated list of usernames. These users are members of the group.
-Modern Unix systems allow users to be members of several groups
-simultaneously. If your system does, then there are elements
-<code>"group1"</code> through <code>"group</code><var>N</var><code>"</code> in
<code>PROCINFO</code>
-for those group ID numbers.
-(Note that <code>PROCINFO</code> is a <samp><span
class="command">gawk</span></samp> extension;
-see <a href="#Built_002din-Variables">Built-in Variables</a>.)
- <br></td></tr></table>
-
- <p>Here is what running <samp><span class="command">grcat</span></samp>
might produce:
-
-<pre class="example"> $ grcat
- -| wheel:*:0:arnold
- -| nogroup:*:65534:
- -| daemon:*:1:
- -| kmem:*:2:
- -| staff:*:10:arnold,miriam,andy
- -| other:*:20:
- ...
-</pre>
- <p>Here are the functions for obtaining information from the group
database.
-There are several, modeled after the C library functions of the same names:
-
- <p><a
name="index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1729"></a><a
name="index-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1730"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- # group.awk --- functions for dealing with the group file
- <!-- endfile -->
- <!-- line break on _gr_init for smallbook -->
- <!-- file eg/lib/groupawk.in -->
- BEGIN \
- {
- # Change to suit your system
- _gr_awklib = "/usr/local/libexec/awk/"
- }
-
- function _gr_init( oldfs, oldrs, olddol0, grcat,
- using_fw, n, a, i)
- {
- if (_gr_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
- FS = ":"
- RS = "\n"
-
- grcat = _gr_awklib "grcat"
- while ((grcat | getline) > 0) {
- if ($1 in _gr_byname)
- _gr_byname[$1] = _gr_byname[$1] "," $4
- else
- _gr_byname[$1] = $0
- if ($3 in _gr_bygid)
- _gr_bygid[$3] = _gr_bygid[$3] "," $4
- else
- _gr_bygid[$3] = $0
-
- n = split($4, a, "[ \t]*,[ \t]*")
- for (i = 1; i <= n; i++)
- if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
- else
- _gr_groupsbyuser[a[i]] = $1
-
- _gr_bycount[++_gr_count] = $0
- }
- close(grcat)
- _gr_count = 0
- _gr_inited++
- FS = oldfs
- if (using_fw)
- FIELDWIDTHS = FIELDWIDTHS
- RS = oldrs
- $0 = olddol0
- }
- <!-- endfile -->
-</pre>
- <p>The <code>BEGIN</code> rule sets a private variable to the directory
where
-<samp><span class="command">grcat</span></samp> is stored. Because it is used
to help out an <samp><span class="command">awk</span></samp> library
-routine, we have chosen to put it in <samp><span
class="file">/usr/local/libexec/awk</span></samp>. You might
-want it to be in a different directory on your system.
-
- <p>These routines follow the same general outline as the user database
routines
-(see <a href="#Passwd-Functions">Passwd Functions</a>).
-The <code>_gr_inited<!-- /@w --></code> variable is used to
-ensure that the database is scanned no more than once.
-The <code>_gr_init<!-- /@w --></code> function first saves <code>FS</code>,
<code>FIELDWIDTHS</code>, <code>RS</code>, and
-<code>$0</code>, and then sets <code>FS</code> and <code>RS</code> to the
correct values for
-scanning the group information.
-
- <p>The group information is stored is several associative arrays.
-The arrays are indexed by group name (<code>_gr_byname<!-- /@w --></code>), by
group ID number
-(<code>_gr_bygid<!-- /@w --></code>), and by position in the database
(<code>_gr_bycount<!-- /@w --></code>).
-There is an additional array indexed by username (<code>_gr_groupsbyuser<!--
/@w --></code>),
-which is a space-separated list of groups to which each user belongs.
-
- <p>Unlike the user database, it is possible to have multiple records in the
-database for the same group. This is common when a group has a large number
-of members. A pair of such entries might look like the following:
-
-<pre class="example"> tvpeople:*:101:johnny,jay,arsenio
- tvpeople:*:101:david,conan,tom,joan
-</pre>
- <p>For this reason, <code>_gr_init</code> looks to see if a group name or
-group ID number is already seen. If it is, then the usernames are
-simply concatenated onto the previous list of users. (There is actually a
-subtle problem with the code just presented. Suppose that
-the first time there were no names. This code adds the names with
-a leading comma. It also doesn't check that there is a <code>$4</code>.)
-
- <p>Finally, <code>_gr_init</code> closes the pipeline to <samp><span
class="command">grcat</span></samp>, restores
-<code>FS</code> (and <code>FIELDWIDTHS</code> if necessary), <code>RS</code>,
and <code>$0</code>,
-initializes <code>_gr_count</code> to zero
-(it is used later), and makes <code>_gr_inited</code> nonzero.
-
- <p><a
name="index-_0040code_007bgetgrnam_007d-function-_0028C-library_0029-1731"></a>The
<code>getgrnam</code> function takes a group name as its argument, and if that
-group exists, it is returned. Otherwise, <code>getgrnam</code> returns the null
-string:
-
- <p><a
name="index-_0040code_007bgetgrnam_007d-user_002ddefined-function-1732"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgrnam(group)
- {
- _gr_init()
- if (group in _gr_byname)
- return _gr_byname[group]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetgrgid_007d-function-_0028C-library_0029-1733"></a>The
<code>getgrgid</code> function is similar, it takes a numeric group ID and
-looks up the information associated with that group ID:
-
- <p><a
name="index-_0040code_007bgetgrgid_007d-user_002ddefined-function-1734"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgrgid(gid)
- {
- _gr_init()
- if (gid in _gr_bygid)
- return _gr_bygid[gid]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetgruser_007d-function-_0028C-library_0029-1735"></a>The
<code>getgruser</code> function does not have a C counterpart. It takes a
-username and returns the list of groups that have the user as a member:
-
- <p><a
name="index-_0040code_007bgetgruser_007d-function_002c-user_002ddefined-1736"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgruser(user)
- {
- _gr_init()
- if (user in _gr_groupsbyuser)
- return _gr_groupsbyuser[user]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetgrent_007d-function-_0028C-library_0029-1737"></a>The
<code>getgrent</code> function steps through the database one entry at a time.
-It uses <code>_gr_count</code> to track its position in the list:
-
- <p><a
name="index-_0040code_007bgetgrent_007d-user_002ddefined-function-1738"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgrent()
- {
- _gr_init()
- if (++_gr_count in _gr_bycount)
- return _gr_bycount[_gr_count]
- return ""
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE clibf -->
-<p><a
name="index-_0040code_007bendgrent_007d-function-_0028C-library_0029-1739"></a>The
<code>endgrent</code> function resets <code>_gr_count</code> to zero so that
<code>getgrent</code> can
-start over again:
-
- <p><a
name="index-_0040code_007bendgrent_007d-user_002ddefined-function-1740"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function endgrent()
- {
- _gr_count = 0
- }
- <!-- endfile -->
-</pre>
- <p>As with the user database routines, each function calls
<code>_gr_init</code> to
-initialize the arrays. Doing so only incurs the extra overhead of running
-<samp><span class="command">grcat</span></samp> if these functions are used
(as opposed to moving the body of
-<code>_gr_init</code> into a <code>BEGIN</code> rule).
-
- <p>Most of the work is in scanning the database and building the various
-associative arrays. The functions that the user calls are themselves very
-simple, relying on <samp><span class="command">awk</span></samp>'s associative
arrays to do work.
-
- <p>The <samp><span class="command">id</span></samp> program in <a
href="#Id-Program">Id Program</a>,
-uses these functions.
-<!-- ENDOFRANGE libfgdata -->
-<!-- ENDOFRANGE flibgdata -->
-<!-- ENDOFRANGE gdatar -->
-<!-- ENDOFRANGE libf -->
-<!-- ENDOFRANGE flib -->
-<!-- ENDOFRANGE fudlib -->
-<!-- ENDOFRANGE datagr -->
-
-<div class="node">
-<p><hr>
-<a name="Sample-Programs"></a>Next: <a rel="next" accesskey="n"
href="#Language-History">Language History</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Library-Functions">Library Functions</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">13 Practical <samp><span class="command">awk</span></samp>
Programs</h2>
-
-<!-- STARTOFRANGE awkpex -->
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-examples-of-1741"></a>
-<a href="#Library-Functions">Library Functions</a>,
-presents the idea that reading programs in a language contributes to
-learning that language. This chapter continues that theme,
-presenting a potpourri of <samp><span class="command">awk</span></samp>
programs for your reading
-enjoyment.
-There are three sections.
-The first describes how to run the programs presented
-in this chapter.
-
- <p>The second presents <samp><span class="command">awk</span></samp>
-versions of several common POSIX utilities.
-These are programs that you are hopefully already familiar with,
-and therefore, whose problems are understood.
-By reimplementing these programs in <samp><span
class="command">awk</span></samp>,
-you can focus on the <samp><span class="command">awk</span></samp>-related
aspects of solving
-the programming problem.
-
- <p>The third is a grab bag of interesting programs.
-These solve a number of different data-manipulation and management
-problems. Many of the programs are short, which emphasizes <samp><span
class="command">awk</span></samp>'s
-ability to do a lot in just a few lines of code.
-
- <p>Many of these programs use the library functions presented in
-<a href="#Library-Functions">Library Functions</a>.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Running-Examples">Running Examples</a>:
How to run these examples.
-<li><a accesskey="2" href="#Clones">Clones</a>: Clones
of common utilities.
-<li><a accesskey="3" href="#Miscellaneous-Programs">Miscellaneous
Programs</a>: Some interesting <samp><span
class="command">awk</span></samp> programs.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Running-Examples"></a>Next: <a rel="next" accesskey="n"
href="#Clones">Clones</a>,
-Up: <a rel="up" accesskey="u" href="#Sample-Programs">Sample Programs</a>
-<br>
-</div>
-
-<h3 class="section">13.1 Running the Example Programs</h3>
-
-<p>To run a given program, you would typically do something like this:
-
-<pre class="example"> awk -f <var>program</var> -- <var>options</var>
<var>files</var>
-</pre>
- <p class="noindent">Here, <var>program</var> is the name of the <samp><span
class="command">awk</span></samp> program (such as
-<samp><span class="file">cut.awk</span></samp>), <var>options</var> are any
command-line options for the
-program that start with a `<samp><span class="samp">-</span></samp>', and
<var>files</var> are the actual data files.
-
- <p>If your system supports the `<samp><span class="samp">#!</span></samp>'
executable interpreter mechanism
-(see <a href="#Executable-Scripts">Executable Scripts</a>),
-you can instead run your program directly:
-
-<pre class="example"> cut.awk -c1-8 myfiles > results
-</pre>
- <p>If your <samp><span class="command">awk</span></samp> is not <samp><span
class="command">gawk</span></samp>, you may instead need to use this:
-
-<pre class="example"> cut.awk -- -c1-8 myfiles > results
-</pre>
- <div class="node">
-<p><hr>
-<a name="Clones"></a>Next: <a rel="next" accesskey="n"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Running-Examples">Running Examples</a>,
-Up: <a rel="up" accesskey="u" href="#Sample-Programs">Sample Programs</a>
-<br>
-</div>
-
-<h3 class="section">13.2 Reinventing Wheels for Fun and Profit</h3>
-
-<!-- STARTOFRANGE posimawk -->
-<p><a
name="index-POSIX_002c-programs_0040comma_007b_007d-implementing-in-_0040command_007bawk_007d-1742"></a>
-This section presents a number of POSIX utilities that are implemented in
-<samp><span class="command">awk</span></samp>. Reinventing these programs in
<samp><span class="command">awk</span></samp> is often enjoyable,
-because the algorithms can be very clearly expressed, and the code is usually
-very concise and simple. This is true because <samp><span
class="command">awk</span></samp> does so much for you.
-
- <p>It should be noted that these programs are not necessarily intended to
-replace the installed versions on your system. Instead, their
-purpose is to illustrate <samp><span class="command">awk</span></samp>
language programming for “real world”
-tasks.
-
- <p>The programs are presented in alphabetical order.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Cut-Program">Cut Program</a>: The
<samp><span class="command">cut</span></samp> utility.
-<li><a accesskey="2" href="#Egrep-Program">Egrep Program</a>:
The <samp><span class="command">egrep</span></samp> utility.
-<li><a accesskey="3" href="#Id-Program">Id Program</a>: The
<samp><span class="command">id</span></samp> utility.
-<li><a accesskey="4" href="#Split-Program">Split Program</a>:
The <samp><span class="command">split</span></samp> utility.
-<li><a accesskey="5" href="#Tee-Program">Tee Program</a>: The
<samp><span class="command">tee</span></samp> utility.
-<li><a accesskey="6" href="#Uniq-Program">Uniq Program</a>:
The <samp><span class="command">uniq</span></samp> utility.
-<li><a accesskey="7" href="#Wc-Program">Wc Program</a>: The
<samp><span class="command">wc</span></samp> utility.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Cut-Program"></a>Next: <a rel="next" accesskey="n"
href="#Egrep-Program">Egrep Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.1 Cutting out Fields and Columns</h4>
-
-<p><a name="index-_0040command_007bcut_007d-utility-1743"></a><!--
STARTOFRANGE cut -->
-<a name="index-_0040command_007bcut_007d-utility-1744"></a><!-- STARTOFRANGE
ficut -->
-<a name="index-fields_002c-cutting-1745"></a><!-- STARTOFRANGE colcut -->
-<a name="index-columns_002c-cutting-1746"></a>The <samp><span
class="command">cut</span></samp> utility selects, or “cuts,”
characters or fields
-from its standard input and sends them to its standard output.
-Fields are separated by tabs by default,
-but you may supply a command-line option to change the field
-<dfn>delimiter</dfn> (i.e., the field-separator character). <samp><span
class="command">cut</span></samp>'s
-definition of fields is less general than <samp><span
class="command">awk</span></samp>'s.
-
- <p>A common use of <samp><span class="command">cut</span></samp> might be
to pull out just the login name of
-logged-on users from the output of <samp><span
class="command">who</span></samp>. For example, the following
-pipeline generates a sorted, unique list of the logged-on users:
-
-<pre class="example"> who | cut -c1-8 | sort | uniq
-</pre>
- <p>The options for <samp><span class="command">cut</span></samp> are:
-
- <dl>
-<dt><code>-c </code><var>list</var><dd>Use <var>list</var> as the list of
characters to cut out. Items within the list
-may be separated by commas, and ranges of characters can be separated with
-dashes. The list `<samp><span class="samp">1-8,15,22-35</span></samp>'
specifies characters 1 through
-8, 15, and 22 through 35.
-
- <br><dt><code>-f </code><var>list</var><dd>Use <var>list</var> as the
list of fields to cut out.
-
- <br><dt><code>-d </code><var>delim</var><dd>Use <var>delim</var> as the
field-separator character instead of the tab
-character.
-
- <br><dt><code>-s</code><dd>Suppress printing of lines that do not contain
the field delimiter.
-</dl>
-
- <p>The <samp><span class="command">awk</span></samp> implementation of
<samp><span class="command">cut</span></samp> uses the <code>getopt</code>
library
-function (see <a href="#Getopt-Function">Getopt Function</a>)
-and the <code>join</code> library function
-(see <a href="#Join-Function">Join Function</a>).
-
- <p>The program begins with a comment describing the options, the library
-functions needed, and a <code>usage</code> function that prints out a usage
-message and exits. <code>usage</code> is called if invalid arguments are
-supplied:
-
- <p><a name="index-_0040code_007bcut_002eawk_007d-program-1747"></a>
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- # cut.awk --- implement cut in awk
- <!-- endfile -->
- <!-- file eg/prog/cut.awk -->
- # Options:
- # -f list Cut fields
- # -d c Field delimiter character
- # -c list Cut characters
- #
- # -s Suppress lines without the delimiter
- #
- # Requires getopt and join library functions
-
- function usage( e1, e2)
- {
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">The variables <code>e1</code> and <code>e2</code> are
used so that the function
-fits nicely on the
-page.
-screen.
-
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-running-_0040command_007bawk_007d-programs-and-1748"></a><a
name="index-_0040code_007bFS_007d-variable_002c-running-_0040command_007bawk_007d-programs-and-1749"></a>Next
comes a <code>BEGIN</code> rule that parses the command-line options.
-It sets <code>FS</code> to a single TAB character, because that is <samp><span
class="command">cut</span></samp>'s
-default field separator. The output field separator is also set to be the
-same as the input field separator. Then <code>getopt</code> is used to step
-through the command-line options. Exactly one of the variables
-<code>by_fields</code> or <code>by_chars</code> is set to true, to indicate
that
-processing should be done by fields or by characters, respectively.
-When cutting by characters, the output field separator is set to the null
-string:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- BEGIN \
- {
- FS = "\t" # default
- OFS = FS
- while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) {
- if (c == "f") {
- by_fields = 1
- fieldlist = Optarg
- } else if (c == "c") {
- by_chars = 1
- fieldlist = Optarg
- OFS = ""
- } else if (c == "d") {
- if (length(Optarg) > 1) {
- printf("Using first character of %s" \
- " for delimiter\n", Optarg) > "/dev/stderr"
- Optarg = substr(Optarg, 1, 1)
- }
- FS = Optarg
- OFS = FS
- if (FS == " ") # defeat awk semantics
- FS = "[ ]"
- } else if (c == "s")
- suppress++
- else
- usage()
- }
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
- <!-- endfile -->
-</pre>
- <p><a name="index-field-separators_002c-spaces-as-1750"></a>Special care is
taken when the field delimiter is a space. Using
-a single space (<code>" "<!-- /@w --></code>) for the value of
<code>FS</code> is
-incorrect—<samp><span class="command">awk</span></samp> would separate
fields with runs of spaces,
-tabs, and/or newlines, and we want them to be separated with individual
-spaces. Also, note that after <code>getopt</code> is through, we have to
-clear out all the elements of <code>ARGV</code> from 1 to <code>Optind</code>,
-so that <samp><span class="command">awk</span></samp> does not try to process
the command-line options
-as file names.
-
- <p>After dealing with the command-line options, the program verifies that
the
-options make sense. Only one or the other of <samp><span
class="option">-c</span></samp> and <samp><span class="option">-f</span></samp>
-should be used, and both require a field list. Then the program calls
-either <code>set_fieldlist</code> or <code>set_charlist</code> to pull apart
the
-list of fields or characters:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- if (by_fields && by_chars)
- usage()
-
- if (by_fields == 0 && by_chars == 0)
- by_fields = 1 # default
-
- if (fieldlist == "") {
- print "cut: needs list for -c or -f" > "/dev/stderr"
- exit 1
- }
-
- if (by_fields)
- set_fieldlist()
- else
- set_charlist()
- }
- <!-- endfile -->
-</pre>
- <p><code>set_fieldlist</code> is used to split the field list apart at the
commas
-and into an array. Then, for each element of the array, it looks to
-see if it is actually a range, and if so, splits it apart. The range
-is verified to make sure the first number is smaller than the second.
-Each number in the list is added to the <code>flist</code> array, which
-simply lists the fields that will be printed. Normal field splitting
-is used. The program lets <samp><span class="command">awk</span></samp>
handle the job of doing the
-field splitting:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- function set_fieldlist( n, m, i, j, k, f, g)
- {
- n = split(fieldlist, f, ",")
- j = 1 # index in flist
- for (i = 1; i <= n; i++) {
- if (index(f[i], "-") != 0) { # a range
- m = split(f[i], g, "-")
- if (m != 2 || g[1] >= g[2]) {
- printf("bad field list: %s\n",
- f[i]) > "/dev/stderr"
- exit 1
- }
- for (k = g[1]; k <= g[2]; k++)
- flist[j++] = k
- } else
- flist[j++] = f[i]
- }
- nfields = j - 1
- }
- <!-- endfile -->
-</pre>
- <p>The <code>set_charlist</code> function is more complicated than
<code>set_fieldlist</code>.
-The idea here is to use <samp><span class="command">gawk</span></samp>'s
<code>FIELDWIDTHS</code> variable
-(see <a href="#Constant-Size">Constant Size</a>),
-which describes constant-width input. When using a character list, that is
-exactly what we have.
-
- <p>Setting up <code>FIELDWIDTHS</code> is more complicated than simply
listing the
-fields that need to be printed. We have to keep track of the fields to
-print and also the intervening characters that have to be skipped.
-For example, suppose you wanted characters 1 through 8, 15, and
-22 through 35. You would use `<samp><span class="samp">-c
1-8,15,22-35</span></samp>'. The necessary value
-for <code>FIELDWIDTHS</code> is <code>"8 6 1 6 14"<!-- /@w
--></code>. This yields five
-fields, and the fields to print
-are <code>$1</code>, <code>$3</code>, and <code>$5</code>.
-The intermediate fields are <dfn>filler</dfn>,
-which is stuff in between the desired data.
-<code>flist</code> lists the fields to print, and <code>t</code> tracks the
-complete field list, including filler fields:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- function set_charlist( field, i, j, f, g, t,
- filler, last, len)
- {
- field = 1 # count total fields
- n = split(fieldlist, f, ",")
- j = 1 # index in flist
- for (i = 1; i <= n; i++) {
- if (index(f[i], "-") != 0) { # range
- m = split(f[i], g, "-")
- if (m != 2 || g[1] >= g[2]) {
- printf("bad character list: %s\n",
- f[i]) > "/dev/stderr"
- exit 1
- }
- len = g[2] - g[1] + 1
- if (g[1] > 1) # compute length of filler
- filler = g[1] - last - 1
- else
- filler = 0
- if (filler)
- t[field++] = filler
- t[field++] = len # length of field
- last = g[2]
- flist[j++] = field - 1
- } else {
- if (f[i] > 1)
- filler = f[i] - last - 1
- else
- filler = 0
- if (filler)
- t[field++] = filler
- t[field++] = 1
- last = f[i]
- flist[j++] = field - 1
- }
- }
- FIELDWIDTHS = join(t, 1, field - 1)
- nfields = j - 1
- }
- <!-- endfile -->
-</pre>
- <p>Next is the rule that actually processes the data. If the <samp><span
class="option">-s</span></samp> option
-is given, then <code>suppress</code> is true. The first <code>if</code>
statement
-makes sure that the input record does have the field separator. If
-<samp><span class="command">cut</span></samp> is processing fields,
<code>suppress</code> is true, and the field
-separator character is not in the record, then the record is skipped.
-
- <p>If the record is valid, then <samp><span
class="command">gawk</span></samp> has split the data
-into fields, either using the character in <code>FS</code> or using
fixed-length
-fields and <code>FIELDWIDTHS</code>. The loop goes through the list of fields
-that should be printed. The corresponding field is printed if it contains
data.
-If the next field also has data, then the separator character is
-written out between the fields:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- {
- if (by_fields && suppress && index($0, FS) != 0)
- next
-
- for (i = 1; i <= nfields; i++) {
- if ($flist[i] != "") {
- printf "%s", $flist[i]
- if (i < nfields && $flist[i+1] != "")
- printf "%s", OFS
- }
- }
- print ""
- }
- <!-- endfile -->
-</pre>
- <p>This version of <samp><span class="command">cut</span></samp> relies on
<samp><span class="command">gawk</span></samp>'s <code>FIELDWIDTHS</code>
-variable to do the character-based cutting. While it is possible in
-other <samp><span class="command">awk</span></samp> implementations to use
<code>substr</code>
-(see <a href="#String-Functions">String Functions</a>),
-it is also extremely painful.
-The <code>FIELDWIDTHS</code> variable supplies an elegant solution to the
problem
-of picking the input line apart by characters.
-<!-- ENDOFRANGE cut -->
-<!-- ENDOFRANGE ficut -->
-<!-- ENDOFRANGE colcut -->
-
-<!-- Exercise: Rewrite using split with "". -->
-<div class="node">
-<p><hr>
-<a name="Egrep-Program"></a>Next: <a rel="next" accesskey="n"
href="#Id-Program">Id Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Cut-Program">Cut
Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.2 Searching for Regular Expressions in Files</h4>
-
-<!-- STARTOFRANGE regexps -->
-<p><a name="index-regular-expressions_002c-searching-for-1751"></a><!--
STARTOFRANGE sfregexp -->
-<a name="index-searching_002c-files-for-regular-expressions-1752"></a><!--
STARTOFRANGE fsregexp -->
-<a name="index-files_002c-searching-for-regular-expressions-1753"></a><a
name="index-_0040command_007begrep_007d-utility-1754"></a>The <samp><span
class="command">egrep</span></samp> utility searches files for patterns. It
uses regular
-expressions that are almost identical to those available in <samp><span
class="command">awk</span></samp>
-(see <a href="#Regexp">Regexp</a>).
-It is used in the following manner:
-
-<pre class="example"> egrep <span class="roman">[</span>
<var>options</var> <span class="roman">]</span> '<var>pattern</var>'
<var>files</var> ...
-</pre>
- <p>The <var>pattern</var> is a regular expression. In typical usage, the
regular
-expression is quoted to prevent the shell from expanding any of the
-special characters as file name wildcards. Normally, <samp><span
class="command">egrep</span></samp>
-prints the lines that matched. If multiple file names are provided on
-the command line, each output line is preceded by the name of the file
-and a colon.
-
- <p>The options to <samp><span class="command">egrep</span></samp> are as
follows:
-
- <dl>
-<dt><code>-c</code><dd>Print out a count of the lines that matched the
pattern, instead of the
-lines themselves.
-
- <br><dt><code>-s</code><dd>Be silent. No output is produced and the exit
value indicates whether
-the pattern was matched.
-
- <br><dt><code>-v</code><dd>Invert the sense of the test. <samp><span
class="command">egrep</span></samp> prints the lines that do
-<em>not</em> match the pattern and exits successfully if the pattern is not
-matched.
-
- <br><dt><code>-i</code><dd>Ignore case distinctions in both the pattern
and the input data.
-
- <br><dt><code>-l</code><dd>Only print (list) the names of the files that
matched, not the lines that matched.
-
- <br><dt><code>-e </code><var>pattern</var><dd>Use <var>pattern</var> as
the regexp to match. The purpose of the <samp><span
class="option">-e</span></samp>
-option is to allow patterns that start with a `<samp><span
class="samp">-</span></samp>'.
-</dl>
-
- <p>This version uses the <code>getopt</code> library function
-(see <a href="#Getopt-Function">Getopt Function</a>)
-and the file transition library program
-(see <a href="#Filetrans-Function">Filetrans Function</a>).
-
- <p>The program begins with a descriptive comment and then a
<code>BEGIN</code> rule
-that processes the command-line arguments with <code>getopt</code>. The
<samp><span class="option">-i</span></samp>
-(ignore case) option is particularly easy with <samp><span
class="command">gawk</span></samp>; we just use the
-<code>IGNORECASE</code> built-in variable
-(see <a href="#Built_002din-Variables">Built-in Variables</a>):
-
- <p><a name="index-_0040code_007begrep_002eawk_007d-program-1755"></a>
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- # egrep.awk --- simulate egrep in awk
- <!-- endfile -->
- <!-- file eg/prog/egrep.awk -->
- # Options:
- # -c count of lines
- # -s silent - use exit value
- # -v invert test, success if no match
- # -i ignore case
- # -l print filenames only
- # -e argument is pattern
- #
- # Requires getopt and file transition library functions
-
- BEGIN {
- while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) {
- if (c == "c")
- count_only++
- else if (c == "s")
- no_print++
- else if (c == "v")
- invert++
- else if (c == "i")
- IGNORECASE = 1
- else if (c == "l")
- filenames_only++
- else if (c == "e")
- pattern = Optarg
- else
- usage()
- }
- <!-- endfile -->
-</pre>
- <p>Next comes the code that handles the <samp><span
class="command">egrep</span></samp>-specific behavior. If no
-pattern is supplied with <samp><span class="option">-e</span></samp>, the
first nonoption on the
-command line is used. The <samp><span class="command">awk</span></samp>
command-line arguments up to <code>ARGV[Optind]</code>
-are cleared, so that <samp><span class="command">awk</span></samp> won't try
to process them as files. If no
-files are specified, the standard input is used, and if multiple files are
-specified, we make sure to note this so that the file names can precede the
-matched lines in the output:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- if (pattern == "")
- pattern = ARGV[Optind++]
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
- if (Optind >= ARGC) {
- ARGV[1] = "-"
- ARGC = 2
- } else if (ARGC - Optind > 1)
- do_filenames++
-
- # if (IGNORECASE)
- # pattern = tolower(pattern)
- }
- <!-- endfile -->
-</pre>
- <p>The last two lines are commented out, since they are not needed in
-<samp><span class="command">gawk</span></samp>. They should be uncommented if
you have to use another version
-of <samp><span class="command">awk</span></samp>.
-
- <p>The next set of lines should be uncommented if you are not using
-<samp><span class="command">gawk</span></samp>. This rule translates all the
characters in the input line
-into lowercase if the <samp><span class="option">-i</span></samp> option is
specified.<a rel="footnote" href="#fn-61" name="fnd-61"><sup>61</sup></a>
-The rule is
-commented out since it is not necessary with <samp><span
class="command">gawk</span></samp>:
-
-<!-- Exercise: Fix this, w/array and new line as key to original line -->
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- #{
- # if (IGNORECASE)
- # $0 = tolower($0)
- #}
- <!-- endfile -->
-</pre>
- <p>The <code>beginfile</code> function is called by the rule in <samp><span
class="file">ftrans.awk</span></samp>
-when each new file is processed. In this case, it is very simple; all it
-does is initialize a variable <code>fcount</code> to zero. <code>fcount</code>
tracks
-how many lines in the current file matched the pattern
-(naming the parameter <code>junk</code> shows we know that
<code>beginfile</code>
-is called with a parameter, but that we're not interested in its value):
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- function beginfile(junk)
- {
- fcount = 0
- }
- <!-- endfile -->
-</pre>
- <p>The <code>endfile</code> function is called after each file has been
processed.
-It affects the output only when the user wants a count of the number of lines
that
-matched. <code>no_print</code> is true only if the exit status is desired.
-<code>count_only</code> is true if line counts are desired. <samp><span
class="command">egrep</span></samp>
-therefore only prints line counts if printing and counting are enabled.
-The output format must be adjusted depending upon the number of files to
-process. Finally, <code>fcount</code> is added to <code>total</code>, so that
we
-know the total number of lines that matched the pattern:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- function endfile(file)
- {
- if (! no_print && count_only)
- if (do_filenames)
- print file ":" fcount
- else
- print fcount
-
- total += fcount
- }
- <!-- endfile -->
-</pre>
- <p>The following rule does most of the work of matching lines. The variable
-<code>matches</code> is true if the line matched the pattern. If the user
-wants lines that did not match, the sense of <code>matches</code> is inverted
-using the `<samp><span class="samp">!</span></samp>' operator.
<code>fcount</code> is incremented with the value of
-<code>matches</code>, which is either one or zero, depending upon a
-successful or unsuccessful match. If the line does not match, the
-<code>next</code> statement just moves on to the next record.
-
- <p><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-1756"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-1757"></a>A
number of additional tests are made, but they are only done if we
-are not counting lines. First, if the user only wants exit status
-(<code>no_print</code> is true), then it is enough to know that <em>one</em>
-line in this file matched, and we can skip on to the next file with
-<code>nextfile</code>. Similarly, if we are only printing file names, we can
-print the file name, and then skip to the next file with
<code>nextfile</code>.
-Finally, each line is printed, with a leading file name and colon
-if necessary:
-
- <p><a name="index-_0040code_007b_0021_007d-operator-1758"></a>
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- {
- matches = ($0 ~ pattern)
- if (invert)
- matches = ! matches
-
- fcount += matches # 1 or 0
-
- if (! matches)
- next
-
- if (! count_only) {
- if (no_print)
- nextfile
-
- if (filenames_only) {
- print FILENAME
- nextfile
- }
-
- if (do_filenames)
- print FILENAME ":" $0
- else
- print
- }
- }
- <!-- endfile -->
-</pre>
- <p>The <code>END</code> rule takes care of producing the correct exit
status. If
-there are no matches, the exit status is one; otherwise it is zero:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- END \
- {
- if (total == 0)
- exit 1
- exit 0
- }
- <!-- endfile -->
-</pre>
- <p>The <code>usage</code> function prints a usage message in case of
invalid options,
-and then exits:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- function usage( e)
- {
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p>The variable <code>e</code> is used so that the function fits nicely
-on the printed page.
-
- <p><a
name="index-_0040code_007bEND_007d-pattern_002c-backslash-continuation-and-1759"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-1760"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-1761"></a>Just
a note on programming style: you may have noticed that the <code>END</code>
-rule uses backslash continuation, with the open brace on a line by
-itself. This is so that it more closely resembles the way functions
-are written. Many of the examples
-in this chapter
-use this style. You can decide for yourself if you like writing
-your <code>BEGIN</code> and <code>END</code> rules this way
-or not.
-<!-- ENDOFRANGE regexps -->
-<!-- ENDOFRANGE sfregexp -->
-<!-- ENDOFRANGE fsregexp -->
-
-<div class="node">
-<p><hr>
-<a name="Id-Program"></a>Next: <a rel="next" accesskey="n"
href="#Split-Program">Split Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Egrep-Program">Egrep
Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.3 Printing out User Information</h4>
-
-<p><a name="index-printing_002c-user-information-1762"></a><a
name="index-users_002c-information-about_002c-printing-1763"></a><a
name="index-_0040command_007bid_007d-utility-1764"></a>The <samp><span
class="command">id</span></samp> utility lists a user's real and effective user
ID numbers,
-real and effective group ID numbers, and the user's group set, if any.
-<samp><span class="command">id</span></samp> only prints the effective user ID
and group ID if they are
-different from the real ones. If possible, <samp><span
class="command">id</span></samp> also supplies the
-corresponding user and group names. The output might look like this:
-
-<pre class="example"> $ id
- -| uid=2076(arnold) gid=10(staff) groups=10(staff),4(tty)
-</pre>
- <p>This information is part of what is provided by <samp><span
class="command">gawk</span></samp>'s
-<code>PROCINFO</code> array (see <a href="#Built_002din-Variables">Built-in
Variables</a>).
-However, the <samp><span class="command">id</span></samp> utility provides a
more palatable output than just
-individual numbers.
-
- <p>Here is a simple version of <samp><span class="command">id</span></samp>
written in <samp><span class="command">awk</span></samp>.
-It uses the user database library functions
-(see <a href="#Passwd-Functions">Passwd Functions</a>)
-and the group database library functions
-(see <a href="#Group-Functions">Group Functions</a>):
-
- <p>The program is fairly straightforward. All the work is done in the
-<code>BEGIN</code> rule. The user and group ID numbers are obtained from
-<code>PROCINFO</code>.
-The code is repetitive. The entry in the user database for the real user ID
-number is split into parts at the `<samp><span class="samp">:</span></samp>'.
The name is the first field.
-Similar code is used for the effective user ID number and the group
-numbers:
-
- <p><a name="index-_0040code_007bid_002eawk_007d-program-1765"></a>
-<pre class="example"> <!-- file eg/prog/id.awk -->
- # id.awk --- implement id in awk
- #
- # Requires user and group library functions
- <!-- endfile -->
- <!-- file eg/prog/id.awk -->
- # output is:
- # uid=12(foo) euid=34(bar) gid=3(baz) \
- # egid=5(blat) groups=9(nine),2(two),1(one)
-
- BEGIN \
- {
- uid = PROCINFO["uid"]
- euid = PROCINFO["euid"]
- gid = PROCINFO["gid"]
- egid = PROCINFO["egid"]
-
- printf("uid=%d", uid)
- pw = getpwuid(uid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
-
- if (euid != uid) {
- printf(" euid=%d", euid)
- pw = getpwuid(euid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- }
-
- printf(" gid=%d", gid)
- pw = getgrgid(gid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
-
- if (egid != gid) {
- printf(" egid=%d", egid)
- pw = getgrgid(egid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- }
-
- for (i = 1; ("group" i) in PROCINFO; i++) {
- if (i == 1)
- printf(" groups=")
- group = PROCINFO["group" i]
- printf("%d", group)
- pw = getgrgid(group)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- if (("group" (i+1)) in PROCINFO)
- printf(",")
- }
-
- print ""
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-_0040code_007bin_007d-operator-1766"></a>The test in the
<code>for</code> loop is worth noting.
-Any supplementary groups in the <code>PROCINFO</code> array have the
-indices <code>"group1"</code> through
<code>"group</code><var>N</var><code>"</code> for some
-<var>N</var>, i.e., the total number of supplementary groups.
-However, we don't know in advance how many of these groups
-there are.
-
- <p>This loop works by starting at one, concatenating the value with
-<code>"group"</code>, and then using <code>in</code> to see if that value is
-in the array. Eventually, <code>i</code> is incremented past
-the last group in the array and the loop exits.
-
- <p>The loop is also correct if there are <em>no</em> supplementary
-groups; then the condition is false the first time it's
-tested, and the loop body never executes.
-
-<!-- exercise!!! -->
-<div class="node">
-<p><hr>
-<a name="Split-Program"></a>Next: <a rel="next" accesskey="n"
href="#Tee-Program">Tee Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Id-Program">Id
Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.4 Splitting a Large File into Pieces</h4>
-
-<!-- STARTOFRANGE filspl -->
-<p><a name="index-files_002c-splitting-1767"></a><a
name="index-_0040code_007bsplit_007d-utility-1768"></a>The <code>split</code>
program splits large text files into smaller pieces.
-Usage is as follows:
-
-<pre class="example"> split <span
class="roman">[</span>-<var>count</var><span class="roman">]</span> file <span
class="roman">[</span> <var>prefix</var> <span class="roman">]</span>
-</pre>
- <p>By default,
-the output files are named <samp><span class="file">xaa</span></samp>,
<samp><span class="file">xab</span></samp>, and so on. Each file has
-1000 lines in it, with the likely exception of the last file. To change the
-number of lines in each file, supply a number on the command line
-preceded with a minus; e.g., `<samp><span class="samp">-500</span></samp>' for
files with 500 lines in them
-instead of 1000. To change the name of the output files to something like
-<samp><span class="file">myfileaa</span></samp>, <samp><span
class="file">myfileab</span></samp>, and so on, supply an additional
-argument that specifies the file name prefix.
-
- <p>Here is a version of <code>split</code> in <samp><span
class="command">awk</span></samp>. It uses the <code>ord</code> and
-<code>chr</code> functions presented in
-<a href="#Ordinal-Functions">Ordinal Functions</a>.
-
- <p>The program first sets its defaults, and then tests to make sure there
are
-not too many arguments. It then looks at each argument in turn. The
-first argument could be a minus sign followed by a number. If it is, this
happens
-to look like a negative number, so it is made positive, and that is the
-count of lines. The data file name is skipped over and the final argument
-is used as the prefix for the output file names:
-
- <p><a name="index-_0040code_007bsplit_002eawk_007d-program-1769"></a>
-<pre class="example"> <!-- file eg/prog/split.awk -->
- # split.awk --- do split in awk
- #
- # Requires ord and chr library functions
- <!-- endfile -->
- <!-- file eg/prog/split.awk -->
- # usage: split [-num] [file] [outname]
-
- BEGIN {
- outfile = "x" # default
- count = 1000
- if (ARGC > 4)
- usage()
-
- i = 1
- if (ARGV[i] ~ /^-[0-9]+$/) {
- count = -ARGV[i]
- ARGV[i] = ""
- i++
- }
- # test argv in case reading from stdin instead of file
- if (i in ARGV)
- i++ # skip data file name
- if (i in ARGV) {
- outfile = ARGV[i]
- ARGV[i] = ""
- }
-
- s1 = s2 = "a"
- out = (outfile s1 s2)
- }
- <!-- endfile -->
-</pre>
- <p>The next rule does most of the work. <code>tcount</code> (temporary
count) tracks
-how many lines have been printed to the output file so far. If it is greater
-than <code>count</code>, it is time to close the current file and start a new
one.
-<code>s1</code> and <code>s2</code> track the current suffixes for the file
name. If
-they are both `<samp><span class="samp">z</span></samp>', the file is just too
big. Otherwise, <code>s1</code>
-moves to the next letter in the alphabet and <code>s2</code> starts over again
at
-`<samp><span class="samp">a</span></samp>':
-
-<!-- else on separate line here for page breaking -->
-<pre class="example"> <!-- file eg/prog/split.awk -->
- {
- if (++tcount > count) {
- close(out)
- if (s2 == "z") {
- if (s1 == "z") {
- printf("split: %s is too large to split\n",
- FILENAME) > "/dev/stderr"
- exit 1
- }
- s1 = chr(ord(s1) + 1)
- s2 = "a"
- }
- else
- s2 = chr(ord(s2) + 1)
- out = (outfile s1 s2)
- tcount = 1
- }
- print > out
- }
- <!-- endfile -->
-</pre>
- <!-- Exercise: do this with just awk builtin functions, index("abc..."),
substr, etc. -->
-<p class="noindent">The <code>usage</code> function simply prints an error
message and exits:
-
-<pre class="example"> <!-- file eg/prog/split.awk -->
- function usage( e)
- {
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">The variable <code>e</code> is used so that the function
-fits nicely on the
-page.
-
- <p>This program is a bit sloppy; it relies on <samp><span
class="command">awk</span></samp> to automatically close the last file
-instead of doing it in an <code>END</code> rule.
-It also assumes that letters are contiguous in the character set,
-which isn't true for EBCDIC systems.
-<!-- BFD... -->
-<!-- ENDOFRANGE filspl -->
-
-<div class="node">
-<p><hr>
-<a name="Tee-Program"></a>Next: <a rel="next" accesskey="n"
href="#Uniq-Program">Uniq Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Split-Program">Split
Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.5 Duplicating Output into Multiple Files</h4>
-
-<p><a
name="index-files_002c-multiple_0040comma_007b_007d-duplicating-output-into-1770"></a><a
name="index-output_002c-duplicating-into-files-1771"></a><a
name="index-_0040code_007btee_007d-utility-1772"></a>The <code>tee</code>
program is known as a “pipe fitting.” <code>tee</code> copies
-its standard input to its standard output and also duplicates it to the
-files named on the command line. Its usage is as follows:
-
-<pre class="example"> tee <span class="roman">[</span>-a<span
class="roman">]</span> file ...
-</pre>
- <p>The <samp><span class="option">-a</span></samp> option tells
<code>tee</code> to append to the named files, instead of
-truncating them and starting over.
-
- <p>The <code>BEGIN</code> rule first makes a copy of all the command-line
arguments
-into an array named <code>copy</code>.
-<code>ARGV[0]</code> is not copied, since it is not needed.
-<code>tee</code> cannot use <code>ARGV</code> directly, since <samp><span
class="command">awk</span></samp> attempts to
-process each file name in <code>ARGV</code> as input data.
-
- <p><a name="index-flag-variables-1773"></a>If the first argument is
<samp><span class="option">-a</span></samp>, then the flag variable
-<code>append</code> is set to true, and both <code>ARGV[1]</code> and
-<code>copy[1]</code> are deleted. If <code>ARGC</code> is less than two, then
no
-file names were supplied and <code>tee</code> prints a usage message and
exits.
-Finally, <samp><span class="command">awk</span></samp> is forced to read the
standard input by setting
-<code>ARGV[1]</code> to <code>"-"</code> and <code>ARGC</code> to two:
-
-<!-- NEXT ED: Add more leading commentary in this program -->
-<p><a name="index-_0040code_007btee_002eawk_007d-program-1774"></a>
-<pre class="example"> <!-- file eg/prog/tee.awk -->
- # tee.awk --- tee in awk
- <!-- endfile -->
- <!-- file eg/prog/tee.awk -->
- BEGIN \
- {
- for (i = 1; i < ARGC; i++)
- copy[i] = ARGV[i]
-
- if (ARGV[1] == "-a") {
- append = 1
- delete ARGV[1]
- delete copy[1]
- ARGC--
- }
- if (ARGC < 2) {
- print "usage: tee [-a] file ..." > "/dev/stderr"
- exit 1
- }
- ARGV[1] = "-"
- ARGC = 2
- }
- <!-- endfile -->
-</pre>
- <p>The single rule does all the work. Since there is no pattern, it is
-executed for each line of input. The body of the rule simply prints the
-line into each file on the command line, and then to the standard output:
-
-<pre class="example"> <!-- file eg/prog/tee.awk -->
- {
- # moving the if outside the loop makes it run faster
- if (append)
- for (i in copy)
- print >> copy[i]
- else
- for (i in copy)
- print > copy[i]
- print
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">It is also possible to write the loop this way:
-
-<pre class="example"> for (i in copy)
- if (append)
- print >> copy[i]
- else
- print > copy[i]
-</pre>
- <p class="noindent">This is more concise but it is also less efficient.
The `<samp><span class="samp">if</span></samp>' is
-tested for each record and for each output file. By duplicating the loop
-body, the `<samp><span class="samp">if</span></samp>' is only tested once for
each input record. If there are
-<var>N</var> input records and <var>M</var> output files, the first method only
-executes <var>N</var> `<samp><span class="samp">if</span></samp>' statements,
while the second executes
-<var>N</var><code>*</code><var>M</var> `<samp><span
class="samp">if</span></samp>' statements.
-
- <p>Finally, the <code>END</code> rule cleans up by closing all the output
files:
-
-<pre class="example"> <!-- file eg/prog/tee.awk -->
- END \
- {
- for (i in copy)
- close(copy[i])
- }
- <!-- endfile -->
-</pre>
- <div class="node">
-<p><hr>
-<a name="Uniq-Program"></a>Next: <a rel="next" accesskey="n"
href="#Wc-Program">Wc Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Tee-Program">Tee
Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.6 Printing Nonduplicated Lines of Text</h4>
-
-<!-- STARTOFRANGE prunt -->
-<p><a name="index-printing_002c-unduplicated-lines-of-text-1775"></a><!--
STARTOFRANGE tpul -->
-<a
name="index-text_0040comma_007b_007d-printing_002c-unduplicated-lines-of-1776"></a><a
name="index-_0040command_007buniq_007d-utility-1777"></a>The <samp><span
class="command">uniq</span></samp> utility reads sorted lines of data on its
standard
-input, and by default removes duplicate lines. In other words, it only
-prints unique lines—hence the name. <samp><span
class="command">uniq</span></samp> has a number of
-options. The usage is as follows:
-
-<pre class="example"> uniq <span class="roman">[</span>-udc <span
class="roman">[</span>-<var>n</var><span class="roman">]]</span> <span
class="roman">[</span>+<var>n</var><span class="roman">]</span> <span
class="roman">[</span> <var>input file</var> <span class="roman">[</span>
<var>output file</var> <span class="roman">]]</span>
-</pre>
- <p>The options for <samp><span class="command">uniq</span></samp> are:
-
- <dl>
-<dt><code>-d</code><dd>Pnly print only repeated lines.
-
- <br><dt><code>-u</code><dd>Print only nonrepeated lines.
-
- <br><dt><code>-c</code><dd>Count lines. This option overrides <samp><span
class="option">-d</span></samp> and <samp><span
class="option">-u</span></samp>. Both repeated
-and nonrepeated lines are counted.
-
- <br><dt><code>-</code><var>n</var><dd>Skip <var>n</var> fields before
comparing lines. The definition of fields
-is similar to <samp><span class="command">awk</span></samp>'s default:
nonwhitespace characters separated
-by runs of spaces and/or tabs.
-
- <br><dt><code>+</code><var>n</var><dd>Skip <var>n</var> characters before
comparing lines. Any fields specified with
-`<samp><span class="samp">-</span><var>n</var></samp>' are skipped first.
-
- <br><dt><var>input file</var><dd>Data is read from the input file named
on the command line, instead of from
-the standard input.
-
- <br><dt><var>output file</var><dd>The generated output is sent to the
named output file, instead of to the
-standard output.
-</dl>
-
- <p>Normally <samp><span class="command">uniq</span></samp> behaves as if
both the <samp><span class="option">-d</span></samp> and
-<samp><span class="option">-u</span></samp> options are provided.
-
- <p><samp><span class="command">uniq</span></samp> uses the
-<code>getopt</code> library function
-(see <a href="#Getopt-Function">Getopt Function</a>)
-and the <code>join</code> library function
-(see <a href="#Join-Function">Join Function</a>).
-
- <p>The program begins with a <code>usage</code> function and then a brief
outline of
-the options and their meanings in a comment.
-The <code>BEGIN</code> rule deals with the command-line arguments and options.
It
-uses a trick to get <code>getopt</code> to handle options of the form
`<samp><span class="samp">-25</span></samp>',
-treating such an option as the option letter `<samp><span
class="samp">2</span></samp>' with an argument of
-`<samp><span class="samp">5</span></samp>'. If indeed two or more digits are
supplied (<code>Optarg</code> looks
-like a number), <code>Optarg</code> is
-concatenated with the option digit and then the result is added to zero to make
-it into a number. If there is only one digit in the option, then
-<code>Optarg</code> is not needed. In this case, <code>Optind</code> must be
decremented so that
-<code>getopt</code> processes it next time. This code is admittedly a bit
-tricky.
-
- <p>If no options are supplied, then the default is taken, to print both
-repeated and nonrepeated lines. The output file, if provided, is assigned
-to <code>outputfile</code>. Early on, <code>outputfile</code> is initialized
to the
-standard output, <samp><span class="file">/dev/stdout</span></samp>:
-
- <p><a name="index-_0040code_007buniq_002eawk_007d-program-1778"></a>
-<pre class="example"> <!-- file eg/prog/uniq.awk -->
- # uniq.awk --- do uniq in awk
- #
- # Requires getopt and join library functions
- <!-- endfile -->
- <!-- file eg/prog/uniq.awk -->
- function usage( e)
- {
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
- exit 1
- }
-
- # -c count lines. overrides -d and -u
- # -d only repeated lines
- # -u only non-repeated lines
- # -n skip n fields
- # +n skip n characters, skip fields first
-
- BEGIN \
- {
- count = 1
- outputfile = "/dev/stdout"
- opts = "udc0:1:2:3:4:5:6:7:8:9:"
- while ((c = getopt(ARGC, ARGV, opts)) != -1) {
- if (c == "u")
- non_repeated_only++
- else if (c == "d")
- repeated_only++
- else if (c == "c")
- do_count++
- else if (index("0123456789", c) != 0) {
- # getopt requires args to options
- # this messes us up for things like -5
- if (Optarg ~ /^[0-9]+$/)
- fcount = (c Optarg) + 0
- else {
- fcount = c + 0
- Optind--
- }
- } else
- usage()
- }
-
- if (ARGV[Optind] ~ /^\+[0-9]+$/) {
- charcount = substr(ARGV[Optind], 2) + 0
- Optind++
- }
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- if (repeated_only == 0 && non_repeated_only == 0)
- repeated_only = non_repeated_only = 1
-
- if (ARGC - Optind == 2) {
- outputfile = ARGV[ARGC - 1]
- ARGV[ARGC - 1] = ""
- }
- }
- <!-- endfile -->
-</pre>
- <p>The following function, <code>are_equal</code>, compares the current
line,
-<code>$0</code>, to the
-previous line, <code>last</code>. It handles skipping fields and characters.
-If no field count and no character count are specified, <code>are_equal</code>
-simply returns one or zero depending upon the result of a simple string
-comparison of <code>last</code> and <code>$0</code>. Otherwise, things get
more
-complicated.
-If fields have to be skipped, each line is broken into an array using
-<code>split</code>
-(see <a href="#String-Functions">String Functions</a>);
-the desired fields are then joined back into a line using <code>join</code>.
-The joined lines are stored in <code>clast</code> and <code>cline</code>.
-If no fields are skipped, <code>clast</code> and <code>cline</code> are set to
-<code>last</code> and <code>$0</code>, respectively.
-Finally, if characters are skipped, <code>substr</code> is used to strip off
the
-leading <code>charcount</code> characters in <code>clast</code> and
<code>cline</code>. The
-two strings are then compared and <code>are_equal</code> returns the result:
-
-<pre class="example"> <!-- file eg/prog/uniq.awk -->
- function are_equal( n, m, clast, cline, alast, aline)
- {
- if (fcount == 0 && charcount == 0)
- return (last == $0)
-
- if (fcount > 0) {
- n = split(last, alast)
- m = split($0, aline)
- clast = join(alast, fcount+1, n)
- cline = join(aline, fcount+1, m)
- } else {
- clast = last
- cline = $0
- }
- if (charcount) {
- clast = substr(clast, charcount + 1)
- cline = substr(cline, charcount + 1)
- }
-
- return (clast == cline)
- }
- <!-- endfile -->
-</pre>
- <p>The following two rules are the body of the program. The first one is
-executed only for the very first line of data. It sets <code>last</code>
equal to
-<code>$0</code>, so that subsequent lines of text have something to be
compared to.
-
- <p>The second rule does the work. The variable <code>equal</code> is one or
zero,
-depending upon the results of <code>are_equal</code>'s comparison. If
<samp><span class="command">uniq</span></samp>
-is counting repeated lines, and the lines are equal, then it increments the
<code>count</code> variable.
-Otherwise, it prints the line and resets <code>count</code>,
-since the two lines are not equal.
-
- <p>If <samp><span class="command">uniq</span></samp> is not counting, and
if the lines are equal, <code>count</code> is incremented.
-Nothing is printed, since the point is to remove duplicates.
-Otherwise, if <samp><span class="command">uniq</span></samp> is counting
repeated lines and more than
-one line is seen, or if <samp><span class="command">uniq</span></samp> is
counting nonrepeated lines
-and only one line is seen, then the line is printed, and <code>count</code>
-is reset.
-
- <p>Finally, similar logic is used in the <code>END</code> rule to print the
final
-line of input data:
-
-<pre class="example"> <!-- file eg/prog/uniq.awk -->
- NR == 1 {
- last = $0
- next
- }
-
- {
- equal = are_equal()
-
- if (do_count) { # overrides -d and -u
- if (equal)
- count++
- else {
- printf("%4d %s\n", count, last) > outputfile
- last = $0
- count = 1 # reset
- }
- next
- }
-
- if (equal)
- count++
- else {
- if ((repeated_only && count > 1) ||
- (non_repeated_only && count == 1))
- print last > outputfile
- last = $0
- count = 1
- }
- }
-
- END {
- if (do_count)
- printf("%4d %s\n", count, last) > outputfile
- else if ((repeated_only && count > 1) ||
- (non_repeated_only && count == 1))
- print last > outputfile
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE prunt -->
-<!-- ENDOFRANGE tpul -->
-<div class="node">
-<p><hr>
-<a name="Wc-Program"></a>Previous: <a rel="previous" accesskey="p"
href="#Uniq-Program">Uniq Program</a>,
-Up: <a rel="up" accesskey="u" href="#Clones">Clones</a>
-<br>
-</div>
-
-<h4 class="subsection">13.2.7 Counting Things</h4>
-
-<!-- STARTOFRANGE count -->
-<p><a name="index-counting-1779"></a><!-- STARTOFRANGE infco -->
-<a name="index-input-files_002c-counting-elements-in-1780"></a><!--
STARTOFRANGE woco -->
-<a name="index-words_002c-counting-1781"></a><!-- STARTOFRANGE chco -->
-<a name="index-characters_002c-counting-1782"></a><!-- STARTOFRANGE lico -->
-<a name="index-lines_002c-counting-1783"></a><a
name="index-_0040command_007bwc_007d-utility-1784"></a>The <samp><span
class="command">wc</span></samp> (word count) utility counts lines, words, and
characters in
-one or more input files. Its usage is as follows:
-
-<pre class="example"> wc <span class="roman">[</span>-lwc<span
class="roman">]</span> <span class="roman">[</span> <var>files</var> ... <span
class="roman">]</span>
-</pre>
- <p>If no files are specified on the command line, <samp><span
class="command">wc</span></samp> reads its standard
-input. If there are multiple files, it also prints total counts for all
-the files. The options and their meanings are shown in the following list:
-
- <dl>
-<dt><code>-l</code><dd>Count only lines.
-
- <br><dt><code>-w</code><dd>Count only words.
-A “word” is a contiguous sequence of nonwhitespace characters,
separated
-by spaces and/or tabs. Luckily, this is the normal way <samp><span
class="command">awk</span></samp> separates
-fields in its input data.
-
- <br><dt><code>-c</code><dd>Count only characters.
-</dl>
-
- <p>Implementing <samp><span class="command">wc</span></samp> in <samp><span
class="command">awk</span></samp> is particularly elegant,
-since <samp><span class="command">awk</span></samp> does a lot of the work for
us; it splits lines into
-words (i.e., fields) and counts them, it counts lines (i.e., records),
-and it can easily tell us how long a line is.
-
- <p>This uses the <code>getopt</code> library function
-(see <a href="#Getopt-Function">Getopt Function</a>)
-and the file-transition functions
-(see <a href="#Filetrans-Function">Filetrans Function</a>).
-
- <p>This version has one notable difference from traditional versions of
-<samp><span class="command">wc</span></samp>: it always prints the counts in
the order lines, words,
-and characters. Traditional versions note the order of the <samp><span
class="option">-l</span></samp>,
-<samp><span class="option">-w</span></samp>, and <samp><span
class="option">-c</span></samp> options on the command line, and print the
-counts in that order.
-
- <p>The <code>BEGIN</code> rule does the argument processing. The variable
-<code>print_total</code> is true if more than one file is named on the
-command line:
-
- <p><a name="index-_0040code_007bwc_002eawk_007d-program-1785"></a>
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- # wc.awk --- count lines, words, characters
- <!-- endfile -->
- <!-- file eg/prog/wc.awk -->
-
- # Options:
- # -l only count lines
- # -w only count words
- # -c only count characters
- #
- # Default is to count lines, words, characters
- #
- # Requires getopt and file transition library functions
-
- BEGIN {
- # let getopt print a message about
- # invalid options. we ignore them
- while ((c = getopt(ARGC, ARGV, "lwc")) != -1) {
- if (c == "l")
- do_lines = 1
- else if (c == "w")
- do_words = 1
- else if (c == "c")
- do_chars = 1
- }
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- # if no options, do all
- if (! do_lines && ! do_words && ! do_chars)
- do_lines = do_words = do_chars = 1
-
- print_total = (ARGC - i > 2)
- }
- <!-- endfile -->
-</pre>
- <p>The <code>beginfile</code> function is simple; it just resets the counts
of lines,
-words, and characters to zero, and saves the current file name in
-<code>fname</code>:
-
-<!-- NEXT ED: make it lines = words = chars = 0 -->
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- function beginfile(file)
- {
- chars = lines = words = 0
- fname = FILENAME
- }
- <!-- endfile -->
-</pre>
- <p>The <code>endfile</code> function adds the current file's numbers to the
running
-totals of lines, words, and characters.<a rel="footnote" href="#fn-62"
name="fnd-62"><sup>62</sup></a> It then prints out those numbers
-for the file that was just read. It relies on <code>beginfile</code> to reset
the
-numbers for the following data file:
-<!-- ONE DAY: make the above footnote an exercise, instead of giving away the
answer. -->
-
-<!-- NEXT ED: make order for += be lines, words, chars -->
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- function endfile(file)
- {
- tchars += chars
- tlines += lines
- twords += words
- if (do_lines)
- printf "\t%d", lines
- if (do_words)
- printf "\t%d", words
- if (do_chars)
- printf "\t%d", chars
- printf "\t%s\n", fname
- }
- <!-- endfile -->
-</pre>
- <p>There is one rule that is executed for each line. It adds the length of
-the record, plus one, to <code>chars</code>. Adding one plus the record length
-is needed because the newline character separating records (the value
-of <code>RS</code>) is not part of the record itself, and thus not included
-in its length. Next, <code>lines</code> is incremented for each line read,
-and <code>words</code> is incremented by the value of <code>NF</code>, which
is the
-number of “words” on this line:
-
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- # do per line
- {
- chars += length($0) + 1 # get newline
- lines++
- words += NF
- }
- <!-- endfile -->
-</pre>
- <p>Finally, the <code>END</code> rule simply prints the totals for all the
files:
-
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- END {
- if (print_total) {
- if (do_lines)
- printf "\t%d", tlines
- if (do_words)
- printf "\t%d", twords
- if (do_chars)
- printf "\t%d", tchars
- print "\ttotal"
- }
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE count -->
-<!-- ENDOFRANGE infco -->
-<!-- ENDOFRANGE lico -->
-<!-- ENDOFRANGE woco -->
-<!-- ENDOFRANGE chco -->
-<!-- ENDOFRANGE posimawk -->
-<div class="node">
-<p><hr>
-<a name="Miscellaneous-Programs"></a>Previous: <a rel="previous"
accesskey="p" href="#Clones">Clones</a>,
-Up: <a rel="up" accesskey="u" href="#Sample-Programs">Sample Programs</a>
-<br>
-</div>
-
-<h3 class="section">13.3 A Grab Bag of <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<p>This section is a large “grab bag” of miscellaneous programs.
-We hope you find them both interesting and enjoyable.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Dupword-Program">Dupword Program</a>:
Finding duplicated words in a document.
-<li><a accesskey="2" href="#Alarm-Program">Alarm Program</a>:
An alarm clock.
-<li><a accesskey="3" href="#Translate-Program">Translate Program</a>:
A program similar to the <samp><span class="command">tr</span></samp>
utility.
-<li><a accesskey="4" href="#Labels-Program">Labels Program</a>:
Printing mailing labels.
-<li><a accesskey="5" href="#Word-Sorting">Word Sorting</a>: A
program to produce a word usage count.
-<li><a accesskey="6" href="#History-Sorting">History Sorting</a>:
Eliminating duplicate entries from a history
- file.
-<li><a accesskey="7" href="#Extract-Program">Extract Program</a>:
Pulling out programs from Texinfo source
- files.
-<li><a accesskey="8" href="#Simple-Sed">Simple Sed</a>: A
Simple Stream Editor.
-<li><a accesskey="9" href="#Igawk-Program">Igawk Program</a>: A
wrapper for <samp><span class="command">awk</span></samp> that includes
- files.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Dupword-Program"></a>Next: <a rel="next" accesskey="n"
href="#Alarm-Program">Alarm Program</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.1 Finding Duplicated Words in a Document</h4>
-
-<p><a
name="index-words_002c-duplicate_0040comma_007b_007d-searching-for-1786"></a><a
name="index-searching_002c-for-words-1787"></a><a
name="index-documents_0040comma_007b_007d-searching-1788"></a>A common error
when writing large amounts of prose is to accidentally
-duplicate words. Typically you will see this in text as something like
“the
-the program does the following<small class="dots">...</small>” When the
text is online, often
-the duplicated words occur at the end of one line and the beginning of
-another, making them very difficult to spot.
-<!-- as here! -->
-
- <p>This program, <samp><span class="file">dupword.awk</span></samp>, scans
through a file one line at a time
-and looks for adjacent occurrences of the same word. It also saves the last
-word on a line (in the variable <code>prev</code>) for comparison with the
first
-word on the next line.
-
- <p><a name="index-Texinfo-1789"></a>The first two statements make sure that
the line is all lowercase,
-so that, for example, “The” and “the” compare equal to
each other.
-The next statement replaces nonalphanumeric and nonwhitespace characters
-with spaces, so that punctuation does not affect the comparison either.
-The characters are replaced with spaces so that formatting controls
-don't create nonsense words (e.g., the Texinfo `<samp><span
class="samp">@code{NF}</span></samp>'
-becomes `<samp><span class="samp">codeNF</span></samp>' if punctuation is
simply deleted). The record is
-then resplit into fields, yielding just the actual words on the line,
-and ensuring that there are no empty fields.
-
- <p>If there are no fields left after removing all the punctuation, the
-current record is skipped. Otherwise, the program loops through each
-word, comparing it to the previous one:
-
- <p><a name="index-_0040code_007bdupword_002eawk_007d-program-1790"></a>
-<pre class="example"> <!-- file eg/prog/dupword.awk -->
- # dupword.awk --- find duplicate words in text
- <!-- endfile -->
- <!-- file eg/prog/dupword.awk -->
- {
- $0 = tolower($0)
- gsub(/[^[:alnum:][:blank:]]/, " ");
- $0 = $0 # re-split
- if (NF == 0)
- next
- if ($1 == prev)
- printf("%s:%d: duplicate %s\n",
- FILENAME, FNR, $1)
- for (i = 2; i <= NF; i++)
- if ($i == $(i-1))
- printf("%s:%d: duplicate %s\n",
- FILENAME, FNR, $i)
- prev = $NF
- }
- <!-- endfile -->
-</pre>
- <div class="node">
-<p><hr>
-<a name="Alarm-Program"></a>Next: <a rel="next" accesskey="n"
href="#Translate-Program">Translate Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Dupword-Program">Dupword
Program</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.2 An Alarm Clock Program</h4>
-
-<p><a name="index-insomnia_002c-cure-for-1791"></a><a
name="index-Robbins_002c-Arnold-1792"></a><blockquote>
-<i>Nothing cures insomnia like a ringing alarm clock.</i><br>
-Arnold Robbins
-</blockquote>
-
-<!-- STARTOFRANGE tialarm -->
-<p><a name="index-time_002c-alarm-clock-example-program-1793"></a><!--
STARTOFRANGE alaex -->
-<a name="index-alarm-clock-example-program-1794"></a>The following program is
a simple “alarm clock” program.
-You give it a time of day and an optional message. At the specified time,
-it prints the message on the standard output. In addition, you can give it
-the number of times to repeat the message as well as a delay between
-repetitions.
-
- <p>This program uses the <code>gettimeofday</code> function from
-<a href="#Gettimeofday-Function">Gettimeofday Function</a>.
-
- <p>All the work is done in the <code>BEGIN</code> rule. The first part is
argument
-checking and setting of defaults: the delay, the count, and the message to
-print. If the user supplied a message without the ASCII BEL
-character (known as the “alert” character, <code>"\a"</code>),
then it is added to
-the message. (On many systems, printing the ASCII BEL generates an
-audible alert. Thus when the alarm goes off, the system calls attention
-to itself in case the user is not looking at the computer or terminal.)
-Here is the program:
-
- <p><a name="index-_0040code_007balarm_002eawk_007d-program-1795"></a>
-<pre class="example"> <!-- file eg/prog/alarm.awk -->
- # alarm.awk --- set an alarm
- #
- # Requires gettimeofday library function
- <!-- endfile -->
- <!-- file eg/prog/alarm.awk -->
- # usage: alarm time [ "message" [ count [ delay ] ] ]
-
- BEGIN \
- {
- # Initial argument sanity checking
- usage1 = "usage: alarm time ['message' [count [delay]]]"
- usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1])
-
- if (ARGC < 2) {
- print usage1 > "/dev/stderr"
- print usage2 > "/dev/stderr"
- exit 1
- } else if (ARGC == 5) {
- delay = ARGV[4] + 0
- count = ARGV[3] + 0
- message = ARGV[2]
- } else if (ARGC == 4) {
- count = ARGV[3] + 0
- message = ARGV[2]
- } else if (ARGC == 3) {
- message = ARGV[2]
- } else if (ARGV[1] !~ /[0-9]?[0-9]:[0-9][0-9]/) {
- print usage1 > "/dev/stderr"
- print usage2 > "/dev/stderr"
- exit 1
- }
-
- # set defaults for once we reach the desired time
- if (delay == 0)
- delay = 180 # 3 minutes
- if (count == 0)
- count = 5
- if (message == "")
- message = sprintf("\aIt is now %s!\a", ARGV[1])
- else if (index(message, "\a") == 0)
- message = "\a" message "\a"
- <!-- endfile -->
-</pre>
- <p>The next section of code turns the alarm time into hours and minutes,
-converts it (if necessary) to a 24-hour clock, and then turns that
-time into a count of the seconds since midnight. Next it turns the current
-time into a count of seconds since midnight. The difference between the two
-is how long to wait before setting off the alarm:
-
-<pre class="example"> <!-- file eg/prog/alarm.awk -->
- # split up alarm time
- split(ARGV[1], atime, ":")
- hour = atime[1] + 0 # force numeric
- minute = atime[2] + 0 # force numeric
-
- # get current broken down time
- gettimeofday(now)
-
- # if time given is 12-hour hours and it's after that
- # hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m.,
- # then add 12 to real hour
- if (hour < 12 && now["hour"] > hour)
- hour += 12
-
- # set target time in seconds since midnight
- target = (hour * 60 * 60) + (minute * 60)
-
- # get current time in seconds since midnight
- current = (now["hour"] * 60 * 60) + \
- (now["minute"] * 60) + now["second"]
-
- # how long to sleep for
- naptime = target - current
- if (naptime <= 0) {
- print "time is in the past!" > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-_0040command_007bsleep_007d-utility-1796"></a>Finally,
the program uses the <code>system</code> function
-(see <a href="#I_002fO-Functions">I/O Functions</a>)
-to call the <samp><span class="command">sleep</span></samp> utility. The
<samp><span class="command">sleep</span></samp> utility simply pauses
-for the given number of seconds. If the exit status is not zero,
-the program assumes that <samp><span class="command">sleep</span></samp> was
interrupted and exits. If
-<samp><span class="command">sleep</span></samp> exited with an OK status
(zero), then the program prints the
-message in a loop, again using <samp><span class="command">sleep</span></samp>
to delay for however many
-seconds are necessary:
-
-<pre class="example"> <!-- file eg/prog/alarm.awk -->
- # zzzzzz..... go away if interrupted
- if (system(sprintf("sleep %d", naptime)) != 0)
- exit 1
-
- # time to notify!
- command = sprintf("sleep %d", delay)
- for (i = 1; i <= count; i++) {
- print message
- # if sleep command interrupted, go away
- if (system(command) != 0)
- break
- }
-
- exit 0
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE tialarm -->
-<!-- ENDOFRANGE alaex -->
-<div class="node">
-<p><hr>
-<a name="Translate-Program"></a>Next: <a rel="next" accesskey="n"
href="#Labels-Program">Labels Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Alarm-Program">Alarm
Program</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.3 Transliterating Characters</h4>
-
-<!-- STARTOFRANGE chtra -->
-<p><a name="index-characters_002c-transliterating-1797"></a><a
name="index-_0040command_007btr_007d-utility-1798"></a>The system <samp><span
class="command">tr</span></samp> utility transliterates characters. For
example, it is
-often used to map uppercase letters into lowercase for further processing:
-
-<pre class="example"> <var>generate data</var> | tr 'A-Z' 'a-z' |
<var>process data</var> ...
-</pre>
- <p><samp><span class="command">tr</span></samp> requires two lists of
characters.<a rel="footnote" href="#fn-63" name="fnd-63"><sup>63</sup></a>
When processing the input, the first character in the
-first list is replaced with the first character in the second list,
-the second character in the first list is replaced with the second
-character in the second list, and so on. If there are more characters
-in the “from” list than in the “to” list, the last
character of the
-“to” list is used for the remaining characters in the
“from” list.
-
- <p>Some time ago,
-<!-- early or mid-1989! -->
-a user proposed that a transliteration function should
-be added to <samp><span class="command">gawk</span></samp>.
-<!-- Wishing to avoid gratuitous new features, -->
-<!-- at least theoretically -->
-The following program was written to
-prove that character transliteration could be done with a user-level
-function. This program is not as complete as the system <samp><span
class="command">tr</span></samp> utility
-but it does most of the job.
-
- <p>The <samp><span class="command">translate</span></samp> program
demonstrates one of the few weaknesses
-of standard <samp><span class="command">awk</span></samp>: dealing with
individual characters is very
-painful, requiring repeated use of the <code>substr</code>, <code>index</code>,
-and <code>gsub</code> built-in functions
-(see <a href="#String-Functions">String Functions</a>).<a rel="footnote"
href="#fn-64" name="fnd-64"><sup>64</sup></a>
-<!-- Exercise: How might you use this new feature to simplify the program? -->
-There are two functions. The first, <code>stranslate</code>, takes three
-arguments:
-
- <dl>
-<dt><code>from</code><dd>A list of characters from which to translate.
-
- <br><dt><code>to</code><dd>A list of characters to which to translate.
-
- <br><dt><code>target</code><dd>The string on which to do the translation.
-</dl>
-
- <p>Associative arrays make the translation part fairly easy.
<code>t_ar</code> holds
-the “to” characters, indexed by the “from” characters.
Then a simple
-loop goes through <code>from</code>, one character at a time. For each
character
-in <code>from</code>, if the character appears in <code>target</code>,
<code>gsub</code>
-is used to change it to the corresponding <code>to</code> character.
-
- <p>The <code>translate</code> function simply calls <code>stranslate</code>
using <code>$0</code>
-as the target. The main program sets two global variables, <code>FROM</code>
and
-<code>TO</code>, from the command line, and then changes <code>ARGV</code> so
that
-<samp><span class="command">awk</span></samp> reads from the standard input.
-
- <p>Finally, the processing rule simply calls <code>translate</code> for
each record:
-
- <p><a name="index-_0040code_007btranslate_002eawk_007d-program-1799"></a>
-<pre class="example"> <!-- file eg/prog/translate.awk -->
- # translate.awk --- do tr-like stuff
- <!-- endfile -->
- <!-- file eg/prog/translate.awk -->
- # Bugs: does not handle things like: tr A-Z a-z, it has
- # to be spelled out. However, if `to' is shorter than `from',
- # the last character in `to' is used for the rest of `from'.
-
- function stranslate(from, to, target, lf, lt, t_ar, i, c)
- {
- lf = length(from)
- lt = length(to)
- for (i = 1; i <= lt; i++)
- t_ar[substr(from, i, 1)] = substr(to, i, 1)
- if (lt < lf)
- for (; i <= lf; i++)
- t_ar[substr(from, i, 1)] = substr(to, lt, 1)
- for (i = 1; i <= lf; i++) {
- c = substr(from, i, 1)
- if (index(target, c) > 0)
- gsub(c, t_ar[c], target)
- }
- return target
- }
-
- function translate(from, to)
- {
- return $0 = stranslate(from, to, $0)
- }
-
- # main program
- BEGIN {
- if (ARGC < 3) {
- print "usage: translate from to" > "/dev/stderr"
- exit
- }
- FROM = ARGV[1]
- TO = ARGV[2]
- ARGC = 2
- ARGV[1] = "-"
- }
-
- {
- translate(FROM, TO)
- print
- }
- <!-- endfile -->
-</pre>
- <p>While it is possible to do character transliteration in a user-level
-function, it is not necessarily efficient, and we (the <samp><span
class="command">gawk</span></samp>
-authors) started to consider adding a built-in function. However,
-shortly after writing this program, we learned that the System V Release 4
-<samp><span class="command">awk</span></samp> had added the
<code>toupper</code> and <code>tolower</code> functions
-(see <a href="#String-Functions">String Functions</a>).
-These functions handle the vast majority of the
-cases where character transliteration is necessary, and so we chose to
-simply add those functions to <samp><span class="command">gawk</span></samp>
as well and then leave well
-enough alone.
-
- <p>An obvious improvement to this program would be to set up the
-<code>t_ar</code> array only once, in a <code>BEGIN</code> rule. However, this
-assumes that the “from” and “to” lists
-will never change throughout the lifetime of the program.
-<!-- ENDOFRANGE chtra -->
-
-<div class="node">
-<p><hr>
-<a name="Labels-Program"></a>Next: <a rel="next" accesskey="n"
href="#Word-Sorting">Word Sorting</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Translate-Program">Translate Program</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.4 Printing Mailing Labels</h4>
-
-<!-- STARTOFRANGE prml -->
-<p><a name="index-printing_002c-mailing-labels-1800"></a><!-- STARTOFRANGE
mlprint -->
-<a name="index-mailing-labels_0040comma_007b_007d-printing-1801"></a>Here is a
“real world”<a rel="footnote" href="#fn-65"
name="fnd-65"><sup>65</sup></a>
-program. This
-script reads lists of names and
-addresses and generates mailing labels. Each page of labels has 20 labels
-on it, 2 across and 10 down. The addresses are guaranteed to be no more
-than 5 lines of data. Each address is separated from the next by a blank
-line.
-
- <p>The basic idea is to read 20 labels worth of data. Each line of each
label
-is stored in the <code>line</code> array. The single rule takes care of
filling
-the <code>line</code> array and printing the page when 20 labels have been
read.
-
- <p>The <code>BEGIN</code> rule simply sets <code>RS</code> to the empty
string, so that
-<samp><span class="command">awk</span></samp> splits records at blank lines
-(see <a href="#Records">Records</a>).
-It sets <code>MAXLINES</code> to 100, since 100 is the maximum number
-of lines on the page (20 * 5 = 100).
-
- <p>Most of the work is done in the <code>printpage</code> function.
-The label lines are stored sequentially in the <code>line</code> array. But
they
-have to print horizontally; <code>line[1]</code> next to <code>line[6]</code>,
-<code>line[2]</code> next to <code>line[7]</code>, and so on. Two loops are
used to
-accomplish this. The outer loop, controlled by <code>i</code>, steps through
-every 10 lines of data; this is each row of labels. The inner loop,
-controlled by <code>j</code>, goes through the lines within the row.
-As <code>j</code> goes from 0 to 4, `<samp><span
class="samp">i+j</span></samp>' is the <code>j</code>-th line in
-the row, and `<samp><span class="samp">i+j+5</span></samp>' is the entry next
to it. The output ends up
-looking something like this:
-
-<pre class="example"> line 1 line 6
- line 2 line 7
- line 3 line 8
- line 4 line 9
- line 5 line 10
- ...
-</pre>
- <p>As a final note, an extra blank line is printed at lines 21 and 61, to
keep
-the output lined up on the labels. This is dependent on the particular
-brand of labels in use when the program was written. You will also note
-that there are 2 blank lines at the top and 2 blank lines at the bottom.
-
- <p>The <code>END</code> rule arranges to flush the final page of labels;
there may
-not have been an even multiple of 20 labels in the data:
-
- <p><a name="index-_0040code_007blabels_002eawk_007d-program-1802"></a>
-<pre class="example"> <!-- file eg/prog/labels.awk -->
- # labels.awk --- print mailing labels
- <!-- endfile -->
- <!-- file eg/prog/labels.awk -->
-
- # Each label is 5 lines of data that may have blank lines.
- # The label sheets have 2 blank lines at the top and 2 at
- # the bottom.
-
- BEGIN { RS = "" ; MAXLINES = 100 }
-
- function printpage( i, j)
- {
- if (Nlines <= 0)
- return
-
- printf "\n\n" # header
-
- for (i = 1; i <= Nlines; i += 10) {
- if (i == 21 || i == 61)
- print ""
- for (j = 0; j < 5; j++) {
- if (i + j > MAXLINES)
- break
- printf " %-41s %s\n", line[i+j], line[i+j+5]
- }
- print ""
- }
-
- printf "\n\n" # footer
-
- for (i in line)
- line[i] = ""
- }
-
- # main rule
- {
- if (Count >= 20) {
- printpage()
- Count = 0
- Nlines = 0
- }
- n = split($0, a, "\n")
- for (i = 1; i <= n; i++)
- line[++Nlines] = a[i]
- for (; i <= 5; i++)
- line[++Nlines] = ""
- Count++
- }
-
- END \
- {
- printpage()
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE prml -->
-<!-- ENDOFRANGE mlprint -->
-<div class="node">
-<p><hr>
-<a name="Word-Sorting"></a>Next: <a rel="next" accesskey="n"
href="#History-Sorting">History Sorting</a>,
-Previous: <a rel="previous" accesskey="p" href="#Labels-Program">Labels
Program</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.5 Generating Word-Usage Counts</h4>
-
-<!-- STARTOFRANGE worus -->
-<p><a
name="index-words_002c-usage-counts_0040comma_007b_007d-generating-1803"></a><!--
NEXT ED: Rewrite this whole section and example -->
-The following <samp><span class="command">awk</span></samp> program prints
-the number of occurrences of each word in its input. It illustrates the
-associative nature of <samp><span class="command">awk</span></samp> arrays by
using strings as subscripts. It
-also demonstrates the `<samp><span class="samp">for
</span><var>index</var><span class="samp"> in </span><var>array</var></samp>'
mechanism.
-Finally, it shows how <samp><span class="command">awk</span></samp> is used in
conjunction with other
-utility programs to do a useful task of some complexity with a minimum of
-effort. Some explanations follow the program listing:
-
-<pre class="example"> # Print list of word frequencies
- {
- for (i = 1; i <= NF; i++)
- freq[$i]++
- }
-
- END {
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
- }
-</pre>
- <!-- Exercise: Use asort() here -->
-<p>This program has two rules. The
-first rule, because it has an empty pattern, is executed for every input line.
-It uses <samp><span class="command">awk</span></samp>'s field-accessing
mechanism
-(see <a href="#Fields">Fields</a>) to pick out the individual words from
-the line, and the built-in variable <code>NF</code> (see <a
href="#Built_002din-Variables">Built-in Variables</a>)
-to know how many fields are available.
-For each input word, it increments an element of the array <code>freq</code> to
-reflect that the word has been seen an additional time.
-
- <p>The second rule, because it has the pattern <code>END</code>, is not
executed
-until the input has been exhausted. It prints out the contents of the
-<code>freq</code> table that has been built up inside the first action.
-This program has several problems that would prevent it from being
-useful by itself on real text files:
-
- <ul>
-<li>Words are detected using the <samp><span class="command">awk</span></samp>
convention that fields are
-separated just by whitespace. Other characters in the input (except
-newlines) don't have any special meaning to <samp><span
class="command">awk</span></samp>. This means that
-punctuation characters count as part of words.
-
- <li>The <samp><span class="command">awk</span></samp> language considers
upper- and lowercase characters to be
-distinct. Therefore, “bartender” and “Bartender” are
not treated
-as the same word. This is undesirable, since in normal text, words
-are capitalized if they begin sentences, and a frequency analyzer should not
-be sensitive to capitalization.
-
- <li>The output does not come out in any useful order. You're more likely
to be
-interested in which words occur most frequently or in having an alphabetized
-table of how frequently each word occurs.
-</ul>
-
- <p><a name="index-_0040command_007bsort_007d-utility-1804"></a>The way to
solve these problems is to use some of <samp><span
class="command">awk</span></samp>'s more advanced
-features. First, we use <code>tolower</code> to remove
-case distinctions. Next, we use <code>gsub</code> to remove punctuation
-characters. Finally, we use the system <samp><span
class="command">sort</span></samp> utility to process the
-output of the <samp><span class="command">awk</span></samp> script. Here is
the new version of
-the program:
-
- <p><a name="index-_0040code_007bwordfreq_002eawk_007d-program-1805"></a>
-<pre class="example"> <!-- file eg/prog/wordfreq.awk -->
- # wordfreq.awk --- print list of word frequencies
-
- {
- $0 = tolower($0) # remove case distinctions
- # remove punctuation
- gsub(/[^[:alnum:]_[:blank:]]/, "", $0)
- for (i = 1; i <= NF; i++)
- freq[$i]++
- }
-
- END {
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
- }
- <!-- endfile -->
-</pre>
- <p>Assuming we have saved this program in a file named <samp><span
class="file">wordfreq.awk</span></samp>,
-and that the data is in <samp><span class="file">file1</span></samp>, the
following pipeline:
-
-<pre class="example"> awk -f wordfreq.awk file1 | sort -k 2nr
-</pre>
- <p class="noindent">produces a table of the words appearing in <samp><span
class="file">file1</span></samp> in order of
-decreasing frequency. The <samp><span class="command">awk</span></samp>
program suitably massages the
-data and produces a word frequency table, which is not ordered.
-
- <p>The <samp><span class="command">awk</span></samp> script's output is
then sorted by the <samp><span class="command">sort</span></samp>
-utility and printed on the terminal. The options given to <samp><span
class="command">sort</span></samp>
-specify a sort that uses the second field of each input line (skipping
-one field), that the sort keys should be treated as numeric quantities
-(otherwise `<samp><span class="samp">15</span></samp>' would come before
`<samp><span class="samp">5</span></samp>'), and that the sorting
-should be done in descending (reverse) order.
-
- <p>The <samp><span class="command">sort</span></samp> could even be done
from within the program, by changing
-the <code>END</code> action to:
-
-<pre class="example"> <!-- file eg/prog/wordfreq.awk -->
- END {
- sort = "sort -k 2nr"
- for (word in freq)
- printf "%s\t%d\n", word, freq[word] | sort
- close(sort)
- }
- <!-- endfile -->
-</pre>
- <p>This way of sorting must be used on systems that do not
-have true pipes at the command-line (or batch-file) level.
-See the general operating system documentation for more information on how
-to use the <samp><span class="command">sort</span></samp> program.
-<!-- ENDOFRANGE worus -->
-
-<div class="node">
-<p><hr>
-<a name="History-Sorting"></a>Next: <a rel="next" accesskey="n"
href="#Extract-Program">Extract Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Word-Sorting">Word
Sorting</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.6 Removing Duplicates from Unsorted Text</h4>
-
-<!-- STARTOFRANGE lidu -->
-<p><a
name="index-lines_002c-duplicate_0040comma_007b_007d-removing-1806"></a>The
<samp><span class="command">uniq</span></samp> program
-(see <a href="#Uniq-Program">Uniq Program</a>),
-removes duplicate lines from <em>sorted</em> data.
-
- <p>Suppose, however, you need to remove duplicate lines from a data file but
-that you want to preserve the order the lines are in. A good example of
-this might be a shell history file. The history file keeps a copy of all
-the commands you have entered, and it is not unusual to repeat a command
-several times in a row. Occasionally you might want to compact the history
-by removing duplicate entries. Yet it is desirable to maintain the order
-of the original commands.
-
- <p>This simple program does the job. It uses two arrays. The
<code>data</code>
-array is indexed by the text of each line.
-For each line, <code>data[$0]</code> is incremented.
-If a particular line has not
-been seen before, then <code>data[$0]</code> is zero.
-In this case, the text of the line is stored in <code>lines[count]</code>.
-Each element of <code>lines</code> is a unique command, and the indices of
-<code>lines</code> indicate the order in which those lines are encountered.
-The <code>END</code> rule simply prints out the lines, in order:
-
- <p><a name="index-Rakitzis_002c-Byron-1807"></a><a
name="index-_0040code_007bhistsort_002eawk_007d-program-1808"></a>
-<pre class="example"> <!-- file eg/prog/histsort.awk -->
- # histsort.awk --- compact a shell history file
- # Thanks to Byron Rakitzis for the general idea
- <!-- endfile -->
- <!-- file eg/prog/histsort.awk -->
- {
- if (data[$0]++ == 0)
- lines[++count] = $0
- }
-
- END {
- for (i = 1; i <= count; i++)
- print lines[i]
- }
- <!-- endfile -->
-</pre>
- <p>This program also provides a foundation for generating other useful
-information. For example, using the following <code>print</code> statement in
the
-<code>END</code> rule indicates how often a particular command is used:
-
-<pre class="example"> print data[lines[i]], lines[i]
-</pre>
- <p>This works because <code>data[$0]</code> is incremented each time a line
is
-seen.
-<!-- ENDOFRANGE lidu -->
-
-<div class="node">
-<p><hr>
-<a name="Extract-Program"></a>Next: <a rel="next" accesskey="n"
href="#Simple-Sed">Simple Sed</a>,
-Previous: <a rel="previous" accesskey="p" href="#History-Sorting">History
Sorting</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.7 Extracting Programs from Texinfo Source
Files</h4>
-
-<!-- STARTOFRANGE texse -->
-<p><a
name="index-Texinfo_002c-extracting-programs-from-source-files-1809"></a><!--
STARTOFRANGE fitex -->
-<a
name="index-files_002c-Texinfo_0040comma_007b_007d-extracting-programs-from-1810"></a>Both
this chapter and the previous chapter
-(<a href="#Library-Functions">Library Functions</a>)
-present a large number of <samp><span class="command">awk</span></samp>
programs.
-If you want to experiment with these programs, it is tedious to have to type
-them in by hand. Here we present a program that can extract parts of a
-Texinfo input file into separate files.
-
- <p><a name="index-Texinfo-1811"></a>This Web page is written in Texinfo,
the GNU project's document
-formatting
-language.
-A single Texinfo source file can be used to produce both
-printed and online documentation.
-Texinfo is fully documented in the book
-<cite>Texinfo—The GNU Documentation Format</cite>,
-available from the Free Software Foundation.
-
- <p>For our purposes, it is enough to know three things about Texinfo input
-files:
-
- <ul>
-<li>The “at” symbol (`<samp><span class="samp">@</span></samp>')
is special in Texinfo, much as
-the backslash (`<samp><span class="samp">\</span></samp>') is in C
-or <samp><span class="command">awk</span></samp>. Literal `<samp><span
class="samp">@</span></samp>' symbols are represented in Texinfo source
-files as `<samp><span class="samp">@@</span></samp>'.
-
- <li>Comments start with either `<samp><span
class="samp">@c</span></samp>' or `<samp><span
class="samp">@comment</span></samp>'.
-The file-extraction program works by using special comments that start
-at the beginning of a line.
-
- <li>Lines containing `<samp><span class="samp">@group</span></samp>' and
`<samp><span class="samp">@end group</span></samp>' commands bracket
-example text that should not be split across a page boundary.
-(Unfortunately, TeX isn't always smart enough to do things exactly right,
-and we have to give it some help.)
-</ul>
-
- <p>The following program, <samp><span
class="file">extract.awk</span></samp>, reads through a Texinfo source
-file and does two things, based on the special comments.
-Upon seeing `<samp><span class="samp">@c system ...<!-- /@w
--></span></samp>',
-it runs a command, by extracting the command text from the
-control line and passing it on to the <code>system</code> function
-(see <a href="#I_002fO-Functions">I/O Functions</a>).
-Upon seeing `<samp><span class="samp">@c file
</span><var>filename</var></samp>', each subsequent line is sent to
-the file <var>filename</var>, until `<samp><span class="samp">@c
endfile</span></samp>' is encountered.
-The rules in <samp><span class="file">extract.awk</span></samp> match either
`<samp><span class="samp">@c</span></samp>' or
-`<samp><span class="samp">@comment</span></samp>' by letting the `<samp><span
class="samp">omment</span></samp>' part be optional.
-Lines containing `<samp><span class="samp">@group</span></samp>' and
`<samp><span class="samp">@end group</span></samp>' are simply removed.
-<samp><span class="file">extract.awk</span></samp> uses the <code>join</code>
library function
-(see <a href="#Join-Function">Join Function</a>).
-
- <p>The example programs in the online Texinfo source for <cite>GAWK:
Effective AWK Programming</cite>
-(<samp><span class="file">gawk.texi</span></samp>) have all been bracketed
inside `<samp><span class="samp">file</span></samp>' and
-`<samp><span class="samp">endfile</span></samp>' lines. The <samp><span
class="command">gawk</span></samp> distribution uses a copy of
-<samp><span class="file">extract.awk</span></samp> to extract the sample
programs and install many
-of them in a standard directory where <samp><span
class="command">gawk</span></samp> can find them.
-The Texinfo file looks something like this:
-
-<pre class="example"> ...
- This program has a @code{BEGIN} rule,
- that prints a nice message:
-
- @example
- @c file examples/messages.awk
- BEGIN @{ print "Don't panic!" @}
- @c end file
- @end example
-
- It also prints some final advice:
-
- @example
- @c file examples/messages.awk
- END @{ print "Always avoid bored archeologists!" @}
- @c end file
- @end example
- ...
-</pre>
- <p><samp><span class="file">extract.awk</span></samp> begins by setting
<code>IGNORECASE</code> to one, so that
-mixed upper- and lowercase letters in the directives won't matter.
-
- <p>The first rule handles calling <code>system</code>, checking that a
command is
-given (<code>NF</code> is at least three) and also checking that the command
-exits with a zero exit status, signifying OK:
-
- <p><a name="index-_0040code_007bextract_002eawk_007d-program-1812"></a>
-<pre class="example"> <!-- file eg/prog/extract.awk -->
- # extract.awk --- extract files and run programs
- # from texinfo files
- <!-- endfile -->
- <!-- file eg/prog/extract.awk -->
- BEGIN { IGNORECASE = 1 }
-
- /address@hidden(omment)?[ \t]+system/ \
- {
- if (NF < 3) {
- e = (FILENAME ":" FNR)
- e = (e ": badly formed `system' line")
- print e > "/dev/stderr"
- next
- }
- $1 = ""
- $2 = ""
- stat = system($0)
- if (stat != 0) {
- e = (FILENAME ":" FNR)
- e = (e ": warning: system returned " stat)
- print e > "/dev/stderr"
- }
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">The variable <code>e</code> is used so that the function
-fits nicely on the
-page.
-screen.
-
- <p>The second rule handles moving data into files. It verifies that a
-file name is given in the directive. If the file named is not the
-current file, then the current file is closed. Keeping the current file
-open until a new file is encountered allows the use of the `<samp><span
class="samp">></span></samp>'
-redirection for printing the contents, keeping open file management
-simple.
-
- <p>The `<samp><span class="samp">for</span></samp>' loop does the work. It
reads lines using <code>getline</code>
-(see <a href="#Getline">Getline</a>).
-For an unexpected end of file, it calls the <code>unexpected_eof<!-- /@w
--></code>
-function. If the line is an “endfile” line, then it breaks out of
-the loop.
-If the line is an `<samp><span class="samp">@group</span></samp>' or
`<samp><span class="samp">@end group</span></samp>' line, then it
-ignores it and goes on to the next line.
-Similarly, comments within examples are also ignored.
-
- <p>Most of the work is in the following few lines. If the line has no
`<samp><span class="samp">@</span></samp>'
-symbols, the program can print it directly.
-Otherwise, each leading `<samp><span class="samp">@</span></samp>' must be
stripped off.
-To remove the `<samp><span class="samp">@</span></samp>' symbols, the line is
split into separate elements of
-the array <code>a</code>, using the <code>split</code> function
-(see <a href="#String-Functions">String Functions</a>).
-The `<samp><span class="samp">@</span></samp>' symbol is used as the separator
character.
-Each element of <code>a</code> that is empty indicates two successive
`<samp><span class="samp">@</span></samp>'
-symbols in the original line. For each two empty elements (`<samp><span
class="samp">@@</span></samp>' in
-the original file), we have to add a single `<samp><span
class="samp">@</span></samp>' symbol back in.
-
- <p>When the processing of the array is finished, <code>join</code> is
called with the
-value of <code>SUBSEP</code>, to rejoin the pieces back into a single
-line. That line is then printed to the output file:
-
-<pre class="example"> <!-- file eg/prog/extract.awk -->
- /address@hidden(omment)?[ \t]+file/ \
- {
- if (NF != 3) {
- e = (FILENAME ":" FNR ": badly formed `file' line")
- print e > "/dev/stderr"
- next
- }
- if ($3 != curfile) {
- if (curfile != "")
- close(curfile)
- curfile = $3
- }
-
- for (;;) {
- if ((getline line) <= 0)
- unexpected_eof()
- if (line ~ /address@hidden(omment)?[ \t]+endfile/)
- break
- else if (line ~ /^@(end[ \t]+)?group/)
- continue
- else if (line ~ /address@hidden(omment+)?[ \t]+/)
- continue
- if (index(line, "@") == 0) {
- print line > curfile
- continue
- }
- n = split(line, a, "@")
- # if a[1] == "", means leading @,
- # don't add one back in.
- for (i = 2; i <= n; i++) {
- if (a[i] == "") { # was an @@
- a[i] = "@"
- if (a[i+1] == "")
- i++
- }
- }
- print join(a, 1, n, SUBSEP) > curfile
- }
- }
- <!-- endfile -->
-</pre>
- <p>An important thing to note is the use of the `<samp><span
class="samp">></span></samp>' redirection.
-Output done with `<samp><span class="samp">></span></samp>' only opens the
file once; it stays open and
-subsequent output is appended to the file
-(see <a href="#Redirection">Redirection</a>).
-This makes it easy to mix program text and explanatory prose for the same
-sample source file (as has been done here!) without any hassle. The file is
-only closed when a new data file name is encountered or at the end of the
-input file.
-
- <p>Finally, the function <code>unexpected_eof<!-- /@w --></code> prints an
appropriate
-error message and then exits.
-The <code>END</code> rule handles the final cleanup, closing the open file:
-
-<!-- function lb put on same line for page breaking. sigh -->
-<pre class="example"> <!-- file eg/prog/extract.awk -->
- function unexpected_eof() {
- printf("%s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
- exit 1
- }
-
- END {
- if (curfile)
- close(curfile)
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE texse -->
-<!-- ENDOFRANGE fitex -->
-<div class="node">
-<p><hr>
-<a name="Simple-Sed"></a>Next: <a rel="next" accesskey="n"
href="#Igawk-Program">Igawk Program</a>,
-Previous: <a rel="previous" accesskey="p" href="#Extract-Program">Extract
Program</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.8 A Simple Stream Editor</h4>
-
-<p><a name="index-_0040command_007bsed_007d-utility-1813"></a><a
name="index-stream-editors-1814"></a>The <samp><span
class="command">sed</span></samp> utility is a stream editor, a program that
reads a
-stream of data, makes changes to it, and passes it on.
-It is often used to make global changes to a large file or to a stream
-of data generated by a pipeline of commands.
-While <samp><span class="command">sed</span></samp> is a complicated program
in its own right, its most common
-use is to perform global substitutions in the middle of a pipeline:
-
-<pre class="example"> command1 < orig.data | sed 's/old/new/g' |
command2 > result
-</pre>
- <p>Here, `<samp><span class="samp">s/old/new/g</span></samp>' tells
<samp><span class="command">sed</span></samp> to look for the regexp
-`<samp><span class="samp">old</span></samp>' on each input line and globally
replace it with the text
-`<samp><span class="samp">new</span></samp>', i.e., all the occurrences on a
line. This is similar to
-<samp><span class="command">awk</span></samp>'s <code>gsub</code> function
-(see <a href="#String-Functions">String Functions</a>).
-
- <p>The following program, <samp><span
class="file">awksed.awk</span></samp>, accepts at least two command-line
-arguments: the pattern to look for and the text to replace it with. Any
-additional arguments are treated as data file names to process. If none
-are provided, the standard input is used:
-
- <p><a name="index-Brennan_002c-Michael-1815"></a><a
name="index-_0040command_007bawksed_002eawk_007d-program-1816"></a><!-- @cindex
simple stream editor -->
-<!-- @cindex stream editor, simple -->
-<pre class="example"> <!-- file eg/prog/awksed.awk -->
- # awksed.awk --- do s/foo/bar/g using just print
- # Thanks to Michael Brennan for the idea
- <!-- endfile -->
- <!-- file eg/prog/awksed.awk -->
- function usage()
- {
- print "usage: awksed pat repl [files...]" > "/dev/stderr"
- exit 1
- }
-
- BEGIN {
- # validate arguments
- if (ARGC < 3)
- usage()
-
- RS = ARGV[1]
- ORS = ARGV[2]
-
- # don't use arguments as files
- ARGV[1] = ARGV[2] = ""
- }
-
- # look ma, no hands!
- {
- if (RT == "")
- printf "%s", $0
- else
- print
- }
- <!-- endfile -->
-</pre>
- <p>The program relies on <samp><span class="command">gawk</span></samp>'s
ability to have <code>RS</code> be a regexp,
-as well as on the setting of <code>RT</code> to the actual text that
terminates the
-record (see <a href="#Records">Records</a>).
-
- <p>The idea is to have <code>RS</code> be the pattern to look for.
<samp><span class="command">gawk</span></samp>
-automatically sets <code>$0</code> to the text between matches of the pattern.
-This is text that we want to keep, unmodified. Then, by setting
<code>ORS</code>
-to the replacement text, a simple <code>print</code> statement outputs the
-text we want to keep, followed by the replacement text.
-
- <p>There is one wrinkle to this scheme, which is what to do if the last
record
-doesn't end with text that matches <code>RS</code>. Using a <code>print</code>
-statement unconditionally prints the replacement text, which is not correct.
-However, if the file did not end in text that matches <code>RS</code>,
<code>RT</code>
-is set to the null string. In this case, we can print <code>$0</code> using
-<code>printf</code>
-(see <a href="#Printf">Printf</a>).
-
- <p>The <code>BEGIN</code> rule handles the setup, checking for the right
number
-of arguments and calling <code>usage</code> if there is a problem. Then it sets
-<code>RS</code> and <code>ORS</code> from the command-line arguments and sets
-<code>ARGV[1]</code> and <code>ARGV[2]</code> to the null string, so that they
are
-not treated as file names
-(see <a href="#ARGC-and-ARGV">ARGC and ARGV</a>).
-
- <p>The <code>usage</code> function prints an error message and exits.
-Finally, the single rule handles the printing scheme outlined above,
-using <code>print</code> or <code>printf</code> as appropriate, depending upon
the
-value of <code>RT</code>.
-
-<div class="node">
-<p><hr>
-<a name="Igawk-Program"></a>Previous: <a rel="previous" accesskey="p"
href="#Simple-Sed">Simple Sed</a>,
-Up: <a rel="up" accesskey="u"
href="#Miscellaneous-Programs">Miscellaneous Programs</a>
-<br>
-</div>
-
-<h4 class="subsection">13.3.9 An Easy Way to Use Library Functions</h4>
-
-<!-- STARTOFRANGE libfex -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-example-program-for-using-1817"></a><!--
STARTOFRANGE flibex -->
-<a
name="index-functions_002c-library_002c-example-program-for-using-1818"></a>Using
library functions in <samp><span class="command">awk</span></samp> can be very
beneficial. It
-encourages code reuse and the writing of general functions. Programs are
-smaller and therefore clearer.
-However, using library functions is only easy when writing <samp><span
class="command">awk</span></samp>
-programs; it is painful when running them, requiring multiple <samp><span
class="option">-f</span></samp>
-options. If <samp><span class="command">gawk</span></samp> is unavailable,
then so too is the <samp><span class="env">AWKPATH</span></samp>
-environment variable and the ability to put <samp><span
class="command">awk</span></samp> functions into a
-library directory (see <a href="#Options">Options</a>).
-It would be nice to be able to write programs in the following manner:
-
-<pre class="example"> # library functions
- @include getopt.awk
- @include join.awk
- ...
-
- # main program
- BEGIN {
- while ((c = getopt(ARGC, ARGV, "a:b:cde")) != -1)
- ...
- ...
- }
-</pre>
- <p>The following program, <samp><span class="file">igawk.sh</span></samp>,
provides this service.
-It simulates <samp><span class="command">gawk</span></samp>'s searching of the
<samp><span class="env">AWKPATH</span></samp> variable
-and also allows <dfn>nested</dfn> includes; i.e., a file that is included
-with `<samp><span class="samp">@include</span></samp>' can contain further
`<samp><span class="samp">@include</span></samp>' statements.
-<samp><span class="command">igawk</span></samp> makes an effort to only
include files once, so that nested
-includes don't accidentally include a library function twice.
-
- <p><samp><span class="command">igawk</span></samp> should behave just like
<samp><span class="command">gawk</span></samp> externally. This
-means it should accept all of <samp><span class="command">gawk</span></samp>'s
command-line arguments,
-including the ability to have multiple source files specified via
-<samp><span class="option">-f</span></samp>, and the ability to mix
command-line and library source files.
-
- <p>The program is written using the POSIX Shell (<samp><span
class="command">sh</span></samp>) command
-language.<a rel="footnote" href="#fn-66" name="fnd-66"><sup>66</sup></a> It
works as follows:
-
- <ol type=1 start=1>
-<li>Loop through the arguments, saving anything that doesn't represent
-<samp><span class="command">awk</span></samp> source code for later, when the
expanded program is run.
-
- <li>For any arguments that do represent <samp><span
class="command">awk</span></samp> text, put the arguments into
-a shell variable that will be expanded. There are two cases:
-
- <ol type=a start=1>
-<li>Literal text, provided with <samp><span
class="option">--source</span></samp> or <samp><span
class="option">--source=</span></samp>. This
-text is just appended directly.
-
- <li>Source file names, provided with <samp><span
class="option">-f</span></samp>. We use a neat trick and append
-`<samp><span class="samp">@include </span><var>filename</var></samp>' to the
shell variable's contents. Since the file-inclusion
-program works the way <samp><span class="command">gawk</span></samp> does,
this gets the text
-of the file included into the program at the correct point.
- </ol>
-
- <li>Run an <samp><span class="command">awk</span></samp> program
(naturally) over the shell variable's contents to expand
-`<samp><span class="samp">@include</span></samp>' statements. The expanded
program is placed in a second
-shell variable.
-
- <li>Run the expanded program with <samp><span
class="command">gawk</span></samp> and any other original command-line
-arguments that the user supplied (such as the data file names).
- </ol>
-
- <p>This program uses shell variables extensively; for storing command line
arguments,
-the text of the <samp><span class="command">awk</span></samp> program that
will expand the user's program, for the
-user's original program, and for the expanded program. Doing so removes some
-potential problems that might arise were we to use temporary files instead,
-at the cost of making the script somewhat more complicated.
-
- <p>The initial part of the program turns on shell tracing if the first
-argument is `<samp><span class="samp">debug</span></samp>'.
-
- <p>The next part loops through all the command-line arguments.
-There are several cases of interest:
-
- <dl>
-<dt><code>--</code><dd>This ends the arguments to <samp><span
class="command">igawk</span></samp>. Anything else should be passed on
-to the user's <samp><span class="command">awk</span></samp> program without
being evaluated.
-
- <br><dt><code>-W</code><dd>This indicates that the next option is
specific to <samp><span class="command">gawk</span></samp>. To make
-argument processing easier, the <samp><span class="option">-W</span></samp> is
appended to the front of the
-remaining arguments and the loop continues. (This is an <samp><span
class="command">sh</span></samp>
-programming trick. Don't worry about it if you are not familiar with
-<samp><span class="command">sh</span></samp>.)
-
- <br><dt><code>-v</code><span class="roman">,</span><code>
-F</code><dd>These are saved and passed on to <samp><span
class="command">gawk</span></samp>.
-
- <br><dt><code>-f</code><span class="roman">,</span><code>
--file</code><span class="roman">,</span><code> --file=</code><span
class="roman">,</span><code> -Wfile=</code><dd>The file name is appended to the
shell variable <code>program</code> with an
-`<samp><span class="samp">@include</span></samp>' statement.
-The <samp><span class="command">expr</span></samp> utility is used to remove
the leading option part of the
-argument (e.g., `<samp><span class="samp">--file=</span></samp>').
-(Typical <samp><span class="command">sh</span></samp> usage would be to use
the <samp><span class="command">echo</span></samp> and <samp><span
class="command">sed</span></samp>
-utilities to do this work. Unfortunately, some versions of <samp><span
class="command">echo</span></samp> evaluate
-escape sequences in their arguments, possibly mangling the program text.
-Using <samp><span class="command">expr</span></samp> avoids this problem.)
-
- <br><dt><code>--source</code><span class="roman">,</span><code>
--source=</code><span class="roman">,</span><code> -Wsource=</code><dd>The
source text is appended to <code>program</code>.
-
- <br><dt><code>--version</code><span class="roman">,</span><code>
-Wversion</code><dd><samp><span class="command">igawk</span></samp> prints its
version number, runs `<samp><span class="samp">gawk --version</span></samp>'
-to get the <samp><span class="command">gawk</span></samp> version information,
and then exits.
-</dl>
-
- <p>If none of the <samp><span class="option">-f</span></samp>, <samp><span
class="option">--file</span></samp>, <samp><span
class="option">-Wfile</span></samp>, <samp><span
class="option">--source</span></samp>,
-or <samp><span class="option">-Wsource</span></samp> arguments are supplied,
then the first nonoption argument
-should be the <samp><span class="command">awk</span></samp> program. If there
are no command-line
-arguments left, <samp><span class="command">igawk</span></samp> prints an
error message and exits.
-Otherwise, the first argument is appended to <code>program</code>.
-In any case, after the arguments have been processed,
-<code>program</code> contains the complete text of the original <samp><span
class="command">awk</span></samp>
-program.
-
- <p>The program is as follows:
-
- <p><a name="index-_0040code_007bigawk_002esh_007d-program-1819"></a>
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- #! /bin/sh
- # igawk --- like gawk but do @include processing
- <!-- endfile -->
- <!-- file eg/prog/igawk.sh -->
- if [ "$1" = debug ]
- then
- set -x
- shift
- fi
-
- # A literal newline, so that program text is formmatted correctly
- n='
- '
-
- # Initialize variables to empty
- program=
- opts=
-
- while [ $# -ne 0 ] # loop over arguments
- do
- case $1 in
- --) shift; break;;
-
- -W) shift
- # The ${x?'message here'} construct prints a
- # diagnostic if $x is the null string
- set -- -W"address@hidden'missing operand'}"
- continue;;
-
- -[vF]) opts="$opts $1 '${2?'missing operand'}'"
- shift;;
-
- -[vF]*) opts="$opts '$1'" ;;
-
- -f) program="address@hidden ${2?'missing operand'}"
- shift;;
-
- -f*) f=`expr "$1" : '-f\(.*\)'`
- program="address@hidden $f";;
-
- -[W-]file=*)
- f=`expr "$1" : '-.file=\(.*\)'`
- program="address@hidden $f";;
-
- -[W-]file)
- program="address@hidden ${2?'missing operand'}"
- shift;;
-
- -[W-]source=*)
- t=`expr "$1" : '-.source=\(.*\)'`
- program="$program$n$t";;
-
- -[W-]source)
- program="$program$n${2?'missing operand'}"
- shift;;
-
- -[W-]version)
- echo igawk: version 2.0 1>&2
- gawk --version
- exit 0 ;;
-
- -[W-]*) opts="$opts '$1'" ;;
-
- *) break;;
- esac
- shift
- done
-
- if [ -z "$program" ]
- then
- program=${1?'missing program'}
- shift
- fi
-
- # At this point, `program' has the program.
- <!-- endfile -->
-</pre>
- <p>The <samp><span class="command">awk</span></samp> program to process
`<samp><span class="samp">@include</span></samp>' directives
-is stored in the shell variable <code>expand_prog</code>. Doing this keeps
-the shell script readable. The <samp><span class="command">awk</span></samp>
program
-reads through the user's program, one line at a time, using
<code>getline</code>
-(see <a href="#Getline">Getline</a>). The input
-file names and `<samp><span class="samp">@include</span></samp>' statements
are managed using a stack.
-As each `<samp><span class="samp">@include</span></samp>' is encountered, the
current file name is
-“pushed” onto the stack and the file named in the `<samp><span
class="samp">@include</span></samp>'
-directive becomes the current file name. As each file is finished,
-the stack is “popped,” and the previous input file becomes the
current
-input file again. The process is started by making the original file
-the first one on the stack.
-
- <p>The <code>pathto</code> function does the work of finding the full path
to
-a file. It simulates <samp><span class="command">gawk</span></samp>'s
behavior when searching the
-<samp><span class="env">AWKPATH</span></samp> environment variable
-(see <a href="#AWKPATH-Variable">AWKPATH Variable</a>).
-If a file name has a `<samp><span class="samp">/</span></samp>' in it, no path
search is done. Otherwise,
-the file name is concatenated with the name of each directory in
-the path, and an attempt is made to open the generated file name.
-The only way to test if a file can be read in <samp><span
class="command">awk</span></samp> is to go
-ahead and try to read it with <code>getline</code>; this is what
<code>pathto</code>
-does.<a rel="footnote" href="#fn-67" name="fnd-67"><sup>67</sup></a> If the
file can be read, it is closed and the file name
-is returned:
-
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- expand_prog='
-
- function pathto(file, i, t, junk)
- {
- if (index(file, "/") != 0)
- return file
-
- for (i = 1; i <= ndirs; i++) {
- t = (pathlist[i] "/" file)
- if ((getline junk < t) > 0) {
- # found it
- close(t)
- return t
- }
- }
- return ""
- }
- <!-- endfile -->
-</pre>
- <p>The main program is contained inside one <code>BEGIN</code> rule. The
first thing it
-does is set up the <code>pathlist</code> array that <code>pathto</code> uses.
After
-splitting the path on `<samp><span class="samp">:</span></samp>', null
elements are replaced with <code>"."</code>,
-which represents the current directory:
-
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- BEGIN {
- path = ENVIRON["AWKPATH"]
- ndirs = split(path, pathlist, ":")
- for (i = 1; i <= ndirs; i++) {
- if (pathlist[i] == "")
- pathlist[i] = "."
- }
- <!-- endfile -->
-</pre>
- <p>The stack is initialized with <code>ARGV[1]</code>, which will be
<samp><span class="file">/dev/stdin</span></samp>.
-The main loop comes next. Input lines are read in succession. Lines that
-do not start with `<samp><span class="samp">@include</span></samp>' are
printed verbatim.
-If the line does start with `<samp><span class="samp">@include</span></samp>',
the file name is in <code>$2</code>.
-<code>pathto</code> is called to generate the full path. If it cannot, then we
-print an error message and continue.
-
- <p>The next thing to check is if the file is included already. The
-<code>processed</code> array is indexed by the full file name of each included
-file and it tracks this information for us. If the file is
-seen again, a warning message is printed. Otherwise, the new file name is
-pushed onto the stack and processing continues.
-
- <p>Finally, when <code>getline</code> encounters the end of the input file,
the file
-is closed and the stack is popped. When <code>stackptr</code> is less than
zero,
-the program is done:
-
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- stackptr = 0
- input[stackptr] = ARGV[1] # ARGV[1] is first file
-
- for (; stackptr >= 0; stackptr--) {
- while ((getline < input[stackptr]) > 0) {
- if (tolower($1) != "@include") {
- print
- continue
- }
- fpath = pathto($2)
- if (fpath == "") {
- printf("igawk:%s:%d: cannot find %s\n",
- input[stackptr], FNR, $2) > "/dev/stderr"
- continue
- }
- if (! (fpath in processed)) {
- processed[fpath] = input[stackptr]
- input[++stackptr] = fpath # push onto stack
- } else
- print $2, "included in", input[stackptr],
- "already included in",
- processed[fpath] > "/dev/stderr"
- }
- close(input[stackptr])
- }
- }' # close quote ends `expand_prog' variable
-
- processed_program=`gawk -- "$expand_prog" /dev/stdin <<EOF
- $program
- EOF
- `
- <!-- endfile -->
-</pre>
- <p>The shell construct `<samp><var>command</var><span class="samp">
<< </span><var>marker</var></samp>' is called a <dfn>here document</dfn>.
-Everything in the shell script up to the <var>marker</var> is fed to
<var>command</var> as input.
-The shell processes the contents of the here document for variable and command
substitution
-(and possibly other things as well, depending upon the shell).
-
- <p>The shell construct `<samp><span class="samp">`...`</span></samp>' is
called <dfn>command substitution</dfn>.
-The output of the command between the two backquotes (grave accents) is
substituted
-into the command line. It is saved as a single string, even if the results
-contain whitespace.
-
- <p>The expanded program is saved in the variable
<code>processed_program</code>.
-It's done in these steps:
-
- <ol type=1 start=1>
-<li>Run <samp><span class="command">gawk</span></samp> with the `<samp><span
class="samp">@include</span></samp>'-processing program (the
-value of the <code>expand_prog</code> shell variable) on standard input.
-
- <li>Standard input is the contents of the user's program, from the shell
variable <code>program</code>.
-Its contents are fed to <samp><span class="command">gawk</span></samp> via a
here document.
-
- <li>The results of this processing are saved in the shell variable
<code>processed_program</code> by using command substitution.
- </ol>
-
- <p>The last step is to call <samp><span class="command">gawk</span></samp>
with the expanded program,
-along with the original
-options and command-line arguments that the user supplied.
-
-<!-- this causes more problems than it solves, so leave it out. -->
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- eval gawk $opts -- '"$processed_program"' '"$@"'
- <!-- endfile -->
-</pre>
- <p>The <samp><span class="command">eval</span></samp> command is a shell
construct that reruns the shell's parsing
-process. This keeps things properly quoted.
-
- <p>This version of <samp><span class="command">igawk</span></samp>
represents my fourth attempt at this program.
-There are four key simplifications that make the program work better:
-
- <ul>
-<li>Using `<samp><span class="samp">@include</span></samp>' even for the files
named with <samp><span class="option">-f</span></samp> makes building
-the initial collected <samp><span class="command">awk</span></samp> program
much simpler; all the
-`<samp><span class="samp">@include</span></samp>' processing can be done once.
-
- <li>Not trying to save the line read with <code>getline</code>
-in the <code>pathto</code> function when testing for the
-file's accessibility for use with the main program simplifies things
-considerably.
-<!-- what problem does this engender though - exercise -->
-<!-- answer, reading from "-" or /dev/stdin -->
-
- <li>Using a <code>getline</code> loop in the <code>BEGIN</code> rule does
it all in one
-place. It is not necessary to call out to a separate loop for processing
-nested `<samp><span class="samp">@include</span></samp>' statements.
-
- <li>Instead of saving the expanded program in a temporary file, putting
it in a shell variable
-avoids some potential security problems.
-This has the disadvantage that the script relies upon more features
-of the <samp><span class="command">sh</span></samp> language, making it harder
to follow for those who
-aren't familiar with <samp><span class="command">sh</span></samp>.
-</ul>
-
- <p>Also, this program illustrates that it is often worthwhile to combine
-<samp><span class="command">sh</span></samp> and <samp><span
class="command">awk</span></samp> programming together. You can usually
-accomplish quite a lot, without having to resort to low-level programming
-in C or C++, and it is frequently easier to do certain kinds of string
-and argument manipulation using the shell than it is in <samp><span
class="command">awk</span></samp>.
-
- <p>Finally, <samp><span class="command">igawk</span></samp> shows that it
is not always necessary to add new
-features to a program; they can often be layered on top. With <samp><span
class="command">igawk</span></samp>,
-there is no real reason to build `<samp><span
class="samp">@include</span></samp>' processing into
-<samp><span class="command">gawk</span></samp> itself.
-
- <p><a name="index-search-paths_002c-for-source-files-1820"></a><a
name="index-source-files_0040comma_007b_007d-search-path-for-1821"></a><a
name="index-files_002c-source_0040comma_007b_007d-search-path-for-1822"></a><a
name="index-directories_002c-searching-1823"></a>As an additional example of
this, consider the idea of having two
-files in a directory in the search path:
-
- <dl>
-<dt><samp><span class="file">default.awk</span></samp><dd>This file contains a
set of default library functions, such
-as <code>getopt</code> and <code>assert</code>.
-
- <br><dt><samp><span class="file">site.awk</span></samp><dd>This file
contains library functions that are specific to a site or
-installation; i.e., locally developed functions.
-Having a separate file allows <samp><span
class="file">default.awk</span></samp> to change with
-new <samp><span class="command">gawk</span></samp> releases, without requiring
the system administrator to
-update it each time by adding the local functions.
-</dl>
-
- <p>One user
-<!-- Karl Berry, address@hidden, 10/95 -->
-suggested that <samp><span class="command">gawk</span></samp> be modified to
automatically read these files
-upon startup. Instead, it would be very simple to modify <samp><span
class="command">igawk</span></samp>
-to do this. Since <samp><span class="command">igawk</span></samp> can process
nested `<samp><span class="samp">@include</span></samp>'
-directives, <samp><span class="file">default.awk</span></samp> could simply
contain `<samp><span class="samp">@include</span></samp>'
-statements for the desired library functions.
-<!-- ENDOFRANGE libfex -->
-<!-- ENDOFRANGE flibex -->
-<!-- ENDOFRANGE awkpex -->
-
-<!-- Exercise: make this change -->
-<div class="node">
-<p><hr>
-<a name="Language-History"></a>Next: <a rel="next" accesskey="n"
href="#Installation">Installation</a>,
-Previous: <a rel="previous" accesskey="p" href="#Sample-Programs">Sample
Programs</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="appendix">Appendix A The Evolution of the <samp><span
class="command">awk</span></samp> Language</h2>
-
-<p>This Web page describes the GNU implementation of <samp><span
class="command">awk</span></samp>, which follows
-the POSIX specification.
-Many long-time <samp><span class="command">awk</span></samp> users learned
<samp><span class="command">awk</span></samp> programming
-with the original <samp><span class="command">awk</span></samp> implementation
in Version 7 Unix.
-(This implementation was the basis for <samp><span
class="command">awk</span></samp> in Berkeley Unix,
-through 4.3-Reno. Subsequent versions of Berkeley Unix, and systems
-derived from 4.4BSD-Lite, use various versions of <samp><span
class="command">gawk</span></samp>
-for their <samp><span class="command">awk</span></samp>.)
-This chapter briefly describes the
-evolution of the <samp><span class="command">awk</span></samp> language, with
cross-references to other parts
-of the Web page where you can find more information.
-
-<ul class="menu">
-<li><a accesskey="1" href="#V7_002fSVR3_002e1">V7/SVR3.1</a>:
The major changes between V7 and System V
- Release 3.1.
-<li><a accesskey="2" href="#SVR4">SVR4</a>: Minor
changes between System V Releases 3.1
- and 4.
-<li><a accesskey="3" href="#POSIX">POSIX</a>: New
features from the POSIX standard.
-<li><a accesskey="4" href="#BTL">BTL</a>: New
features from the Bell Laboratories
- version of <samp><span
class="command">awk</span></samp>.
-<li><a accesskey="5" href="#POSIX_002fGNU">POSIX/GNU</a>:
The extensions in <samp><span class="command">gawk</span></samp> not in POSIX
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="6" href="#Contributors">Contributors</a>:
The major contributors to <samp><span class="command">gawk</span></samp>.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="V7_002fSVR3_002e1"></a>Next: <a rel="next" accesskey="n"
href="#SVR4">SVR4</a>,
-Up: <a rel="up" accesskey="u" href="#Language-History">Language
History</a>
-<br>
-</div>
-
-<h3 class="appendixsec">A.1 Major Changes Between V7 and SVR3.1</h3>
-
-<!-- STARTOFRANGE gawkv -->
-<p><a name="index-_0040command_007bawk_007d_002c-versions-of-1824"></a><!--
STARTOFRANGE gawkv1 -->
-<a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-V7-and-SVR3_002e1-1825"></a>
-The <samp><span class="command">awk</span></samp> language evolved
considerably between the release of
-Version 7 Unix (1978) and the new version that was first made generally
available in
-System V Release 3.1 (1987). This section summarizes the changes, with
-cross-references to further details:
-
- <ul>
-<li>The requirement for `<samp><span class="samp">;</span></samp>' to separate
rules on a line
-(see <a href="#Statements_002fLines">Statements/Lines</a>).
-
- <li>User-defined functions and the <code>return</code> statement
-(see <a href="#User_002ddefined">User-defined</a>).
-
- <li>The <code>delete</code> statement (see <a href="#Delete">Delete</a>).
-
- <li>The <code>do</code>-<code>while</code> statement
-(see <a href="#Do-Statement">Do Statement</a>).
-
- <li>The built-in functions <code>atan2</code>, <code>cos</code>,
<code>sin</code>, <code>rand</code>, and
-<code>srand</code> (see <a href="#Numeric-Functions">Numeric Functions</a>).
-
- <li>The built-in functions <code>gsub</code>, <code>sub</code>, and
<code>match</code>
-(see <a href="#String-Functions">String Functions</a>).
-
- <li>The built-in functions <code>close</code> and <code>system</code>
-(see <a href="#I_002fO-Functions">I/O Functions</a>).
-
- <li>The <code>ARGC</code>, <code>ARGV</code>, <code>FNR</code>,
<code>RLENGTH</code>, <code>RSTART</code>,
-and <code>SUBSEP</code> built-in variables (see <a
href="#Built_002din-Variables">Built-in Variables</a>).
-
- <li>The conditional expression using the ternary operator `<samp><span
class="samp">?:</span></samp>'
-(see <a href="#Conditional-Exp">Conditional Exp</a>).
-
- <li>The exponentiation operator `<samp><span class="samp">^</span></samp>'
-(see <a href="#Arithmetic-Ops">Arithmetic Ops</a>) and its assignment operator
-form `<samp><span class="samp">^=</span></samp>' (see <a
href="#Assignment-Ops">Assignment Ops</a>).
-
- <li>C-compatible operator precedence, which breaks some old <samp><span
class="command">awk</span></samp>
-programs (see <a href="#Precedence">Precedence</a>).
-
- <li>Regexps as the value of <code>FS</code>
-(see <a href="#Field-Separators">Field Separators</a>) and as the
-third argument to the <code>split</code> function
-(see <a href="#String-Functions">String Functions</a>).
-
- <li>Dynamic regexps as operands of the `<samp><span
class="samp">~</span></samp>' and `<samp><span class="samp">!~</span></samp>'
operators
-(see <a href="#Regexp-Usage">Regexp Usage</a>).
-
- <li>The escape sequences `<samp><span class="samp">\b</span></samp>',
`<samp><span class="samp">\f</span></samp>', and `<samp><span
class="samp">\r</span></samp>'
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-(Some vendors have updated their old versions of <samp><span
class="command">awk</span></samp> to
-recognize `<samp><span class="samp">\b</span></samp>', `<samp><span
class="samp">\f</span></samp>', and `<samp><span
class="samp">\r</span></samp>', but this is not
-something you can rely on.)
-
- <li>Redirection of input for the <code>getline</code> function
-(see <a href="#Getline">Getline</a>).
-
- <li>Multiple <code>BEGIN</code> and <code>END</code> rules
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-
- <li>Multidimensional arrays
-(see <a href="#Multi_002ddimensional">Multi-dimensional</a>).
-</ul>
- <!-- ENDOFRANGE gawkv1 -->
-
-<div class="node">
-<p><hr>
-<a name="SVR4"></a>Next: <a rel="next" accesskey="n"
href="#POSIX">POSIX</a>,
-Previous: <a rel="previous" accesskey="p"
href="#V7_002fSVR3_002e1">V7/SVR3.1</a>,
-Up: <a rel="up" accesskey="u" href="#Language-History">Language
History</a>
-<br>
-</div>
-
-<h3 class="appendixsec">A.2 Changes Between SVR3.1 and SVR4</h3>
-
-<p><a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR3_002e1-and-SVR4-1826"></a>The
System V Release 4 (1989) version of Unix <samp><span
class="command">awk</span></samp> added these features
-(some of which originated in <samp><span class="command">gawk</span></samp>):
-
- <ul>
-<li>The <code>ENVIRON</code> variable (see <a
href="#Built_002din-Variables">Built-in Variables</a>).
-<!-- gawk and MKS awk -->
-
- <li>Multiple <samp><span class="option">-f</span></samp> options on the
command line
-(see <a href="#Options">Options</a>).
-<!-- MKS awk -->
-
- <li>The <samp><span class="option">-v</span></samp> option for assigning
variables before program execution begins
-(see <a href="#Options">Options</a>).
-<!-- GNU, Bell Laboratories & MKS together -->
-
- <li>The <samp><span class="option">--</span></samp> option for
terminating command-line options.
-
- <li>The `<samp><span class="samp">\a</span></samp>', `<samp><span
class="samp">\v</span></samp>', and `<samp><span class="samp">\x</span></samp>'
escape sequences
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-<!-- GNU, for ANSI C compat -->
-
- <li>A defined return value for the <code>srand</code> built-in function
-(see <a href="#Numeric-Functions">Numeric Functions</a>).
-
- <li>The <code>toupper</code> and <code>tolower</code> built-in string
functions
-for case translation
-(see <a href="#String-Functions">String Functions</a>).
-
- <li>A cleaner specification for the `<samp><span
class="samp">%c</span></samp>' format-control letter in the
-<code>printf</code> function
-(see <a href="#Control-Letters">Control Letters</a>).
-
- <li>The ability to dynamically pass the field width and precision
(<code>"%*.*d"</code>)
-in the argument list of the <code>printf</code> function
-(see <a href="#Control-Letters">Control Letters</a>).
-
- <li>The use of regexp constants, such as <code>/foo/</code>, as
expressions, where
-they are equivalent to using the matching operator, as in `<samp><span
class="samp">$0 ~ /foo/</span></samp>'
-(see <a href="#Using-Constant-Regexps">Using Constant Regexps</a>).
-
- <li>Processing of escape sequences inside command-line variable
assignments
-(see <a href="#Assignment-Options">Assignment Options</a>).
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="POSIX"></a>Next: <a rel="next" accesskey="n" href="#BTL">BTL</a>,
-Previous: <a rel="previous" accesskey="p" href="#SVR4">SVR4</a>,
-Up: <a rel="up" accesskey="u" href="#Language-History">Language
History</a>
-<br>
-</div>
-
-<h3 class="appendixsec">A.3 Changes Between SVR4 and POSIX <samp><span
class="command">awk</span></samp></h3>
-
-<p><a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR4-and-POSIX-_0040command_007bawk_007d-1827"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-changes-in-_0040command_007bawk_007d-versions-1828"></a>
-The POSIX Command Language and Utilities standard for <samp><span
class="command">awk</span></samp> (1992)
-introduced the following changes into the language:
-
- <ul>
-<li>The use of <samp><span class="option">-W</span></samp> for
implementation-specific options
-(see <a href="#Options">Options</a>).
-
- <li>The use of <code>CONVFMT</code> for controlling the conversion of
numbers
-to strings (see <a href="#Conversion">Conversion</a>).
-
- <li>The concept of a numeric string and tighter comparison rules to go
-with it (see <a href="#Typing-and-Comparison">Typing and Comparison</a>).
-
- <li>More complete documentation of many of the previously undocumented
-features of the language.
-</ul>
-
- <p>The following common extensions are not permitted by the POSIX
-standard:
-
-<!-- IMPORTANT! Keep this list in sync with the one in node Options -->
-<ul>
-<li><code>\x</code> escape sequences are not recognized
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-
- <li>Newlines do not act as whitespace to separate fields when
<code>FS</code> is
-equal to a single space
-(see <a href="#Fields">Fields</a>).
-
- <li>Newlines are not allowed after `<samp><span
class="samp">?</span></samp>' or `<samp><span class="samp">:</span></samp>'
-(see <a href="#Conditional-Exp">Conditional Exp</a>).
-
- <li>The synonym <code>func</code> for the keyword <code>function</code>
is not
-recognized (see <a href="#Definition-Syntax">Definition Syntax</a>).
-
- <li>The operators `<samp><span class="samp">**</span></samp>' and
`<samp><span class="samp">**=</span></samp>' cannot be used in
-place of `<samp><span class="samp">^</span></samp>' and `<samp><span
class="samp">^=</span></samp>' (see <a href="#Arithmetic-Ops">Arithmetic
Ops</a>,
-and <a href="#Assignment-Ops">Assignment Ops</a>).
-
- <li>Specifying `<samp><span class="samp">-Ft</span></samp>' on the
command line does not set the value
-of <code>FS</code> to be a single TAB character
-(see <a href="#Field-Separators">Field Separators</a>).
-
- <li>The <code>fflush</code> built-in function is not supported
-(see <a href="#I_002fO-Functions">I/O Functions</a>).
-</ul>
- <!-- ENDOFRANGE gawkv -->
-
-<div class="node">
-<p><hr>
-<a name="BTL"></a>Next: <a rel="next" accesskey="n"
href="#POSIX_002fGNU">POSIX/GNU</a>,
-Previous: <a rel="previous" accesskey="p" href="#POSIX">POSIX</a>,
-Up: <a rel="up" accesskey="u" href="#Language-History">Language
History</a>
-<br>
-</div>
-
-<h3 class="appendixsec">A.4 Extensions in the Bell Laboratories <samp><span
class="command">awk</span></samp></h3>
-
-<p><a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-See-Also-Bell-Laboratories-_0040command_007bawk_007d-1829"></a><a
name="index-extensions_002c-Bell-Laboratories-_0040command_007bawk_007d-1830"></a><a
name="index-Bell-Laboratories-_0040command_007bawk_007d-extensions-1831"></a><a
name="index-Kernighan_002c-Brian-1832"></a>Brian Kernighan, one of the original
designers of Unix <samp><span class="command">awk</span></samp>,
-has made his version available via his home page
-(see <a href="#Other-Versions">Other Versions</a>).
-This section describes extensions in his version of <samp><span
class="command">awk</span></samp> that are
-not in POSIX <samp><span class="command">awk</span></samp>:
-
- <ul>
-<li>The `<samp><span class="samp">-mf </span><var>N</var></samp>' and
`<samp><span class="samp">-mr </span><var>N</var></samp>' command-line options
-to set the maximum number of fields and the maximum
-record size, respectively
-(see <a href="#Options">Options</a>).
-As a side note, his <samp><span class="command">awk</span></samp> no longer
needs these options;
-it continues to accept them to avoid breaking old programs.
-
- <li>The <code>fflush</code> built-in function for flushing buffered output
-(see <a href="#I_002fO-Functions">I/O Functions</a>).
-
- <li>The `<samp><span class="samp">**</span></samp>' and `<samp><span
class="samp">**=</span></samp>' operators
-(see <a href="#Arithmetic-Ops">Arithmetic Ops</a>
-and
-<a href="#Assignment-Ops">Assignment Ops</a>).
-
- <li>The use of <code>func</code> as an abbreviation for
<code>function</code>
-(see <a href="#Definition-Syntax">Definition Syntax</a>).
-
- </ul>
-
- <p>The Bell Laboratories <samp><span class="command">awk</span></samp> also
incorporates the following extensions,
-originally developed for <samp><span class="command">gawk</span></samp>:
-
- <ul>
-<li>The `<samp><span class="samp">\x</span></samp>' escape sequence
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-
- <li>The <samp><span class="file">/dev/stdin</span></samp>, <samp><span
class="file">/dev/stdout</span></samp>, and <samp><span
class="file">/dev/stderr</span></samp>
-special files
-(see <a href="#Special-Files">Special Files</a>).
-
- <li>The ability for <code>FS</code> and for the third
-argument to <code>split</code> to be null strings
-(see <a href="#Single-Character-Fields">Single Character Fields</a>).
-
- <li>The <code>nextfile</code> statement
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-
- <li>The ability to delete all of an array at once with `<samp><span
class="samp">delete </span><var>array</var></samp>'
-(see <a href="#Delete">Delete</a>).
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="POSIX_002fGNU"></a>Next: <a rel="next" accesskey="n"
href="#Contributors">Contributors</a>,
-Previous: <a rel="previous" accesskey="p" href="#BTL">BTL</a>,
-Up: <a rel="up" accesskey="u" href="#Language-History">Language
History</a>
-<br>
-</div>
-
-<h3 class="appendixsec">A.5 Extensions in <samp><span
class="command">gawk</span></samp> Not in POSIX <samp><span
class="command">awk</span></samp></h3>
-
-<!-- STARTOFRANGE fripls -->
-<p><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-extensions-1833"></a><!--
STARTOFRANGE exgnot -->
-<a
name="index-extensions_002c-in-_0040command_007bgawk_007d_002c-not-in-POSIX-_0040command_007bawk_007d-1834"></a><!--
STARTOFRANGE posnot -->
-<a
name="index-POSIX_002c-_0040command_007bgawk_007d-extensions-not-included-in-1835"></a>The
GNU implementation, <samp><span class="command">gawk</span></samp>, adds a
large number of features.
-This section lists them in the order they were added to <samp><span
class="command">gawk</span></samp>.
-They can all be disabled with either the <samp><span
class="option">--traditional</span></samp> or
-<samp><span class="option">--posix</span></samp> options
-(see <a href="#Options">Options</a>).
-
- <p>Version 2.10 of <samp><span class="command">gawk</span></samp>
introduced the following features:
-
- <ul>
-<li>The <samp><span class="env">AWKPATH</span></samp> environment variable for
specifying a path search for
-the <samp><span class="option">-f</span></samp> command-line option
-(see <a href="#Options">Options</a>).
-
- <li>The <code>IGNORECASE</code> variable and its effects
-(see <a href="#Case_002dsensitivity">Case-sensitivity</a>).
-
- <li>The <samp><span class="file">/dev/stdin</span></samp>, <samp><span
class="file">/dev/stdout</span></samp>, <samp><span
class="file">/dev/stderr</span></samp> and
-<samp><span class="file">/dev/fd/</span><var>N</var></samp> special file names
-(see <a href="#Special-Files">Special Files</a>).
-</ul>
-
- <p>Version 2.13 of <samp><span class="command">gawk</span></samp>
introduced the following features:
-
- <ul>
-<li>The <code>FIELDWIDTHS</code> variable and its effects
-(see <a href="#Constant-Size">Constant Size</a>).
-
- <li>The <code>systime</code> and <code>strftime</code> built-in functions
for obtaining
-and printing timestamps
-(see <a href="#Time-Functions">Time Functions</a>).
-
- <li>The <samp><span class="option">-W lint</span></samp> option to
provide error and portability checking
-for both the source code and at runtime
-(see <a href="#Options">Options</a>).
-
- <li>The <samp><span class="option">-W compat</span></samp> option to turn
off the GNU extensions
-(see <a href="#Options">Options</a>).
-
- <li>The <samp><span class="option">-W posix</span></samp> option for full
POSIX compliance
-(see <a href="#Options">Options</a>).
-</ul>
-
- <p>Version 2.14 of <samp><span class="command">gawk</span></samp>
introduced the following feature:
-
- <ul>
-<li>The <code>next file</code> statement for skipping to the next data file
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-</ul>
-
- <p>Version 2.15 of <samp><span class="command">gawk</span></samp>
introduced the following features:
-
- <ul>
-<li>The <code>ARGIND</code> variable, which tracks the movement of
<code>FILENAME</code>
-through <code>ARGV</code> (see <a href="#Built_002din-Variables">Built-in
Variables</a>).
-
- <li>The <code>ERRNO</code> variable, which contains the system error
message when
-<code>getline</code> returns −1 or <code>close</code> fails
-(see <a href="#Built_002din-Variables">Built-in Variables</a>).
-
- <li>The <samp><span class="file">/dev/pid</span></samp>, <samp><span
class="file">/dev/ppid</span></samp>, <samp><span
class="file">/dev/pgrpid</span></samp>, and
-<samp><span class="file">/dev/user</span></samp> file name interpretation
-(see <a href="#Special-Files">Special Files</a>).
-
- <li>The ability to delete all of an array at once with `<samp><span
class="samp">delete </span><var>array</var></samp>'
-(see <a href="#Delete">Delete</a>).
-
- <li>The ability to use GNU-style long-named options that start with
<samp><span class="option">--</span></samp>
-(see <a href="#Options">Options</a>).
-
- <li>The <samp><span class="option">--source</span></samp> option for
mixing command-line and library-file
-source code
-(see <a href="#Options">Options</a>).
-</ul>
-
- <p>Version 3.0 of <samp><span class="command">gawk</span></samp> introduced
the following features:
-
- <ul>
-<li><code>IGNORECASE</code> changed, now applying to string comparison as well
-as regexp operations
-(see <a href="#Case_002dsensitivity">Case-sensitivity</a>).
-
- <li>The <code>RT</code> variable that contains the input text that
-matched <code>RS</code>
-(see <a href="#Records">Records</a>).
-
- <li>Full support for both POSIX and GNU regexps
-(see <a href="#Regexp">Regexp</a>).
-
- <li>The <code>gensub</code> function for more powerful text manipulation
-(see <a href="#String-Functions">String Functions</a>).
-
- <li>The <code>strftime</code> function acquired a default time format,
-allowing it to be called with no arguments
-(see <a href="#Time-Functions">Time Functions</a>).
-
- <li>The ability for <code>FS</code> and for the third
-argument to <code>split</code> to be null strings
-(see <a href="#Single-Character-Fields">Single Character Fields</a>).
-
- <li>The ability for <code>RS</code> to be a regexp
-(see <a href="#Records">Records</a>).
-
- <li>The <code>next file</code> statement became <code>nextfile</code>
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-
- <li>The <samp><span class="option">--lint-old</span></samp> option to
-warn about constructs that are not available in
-the original Version 7 Unix version of <samp><span
class="command">awk</span></samp>
-(see <a href="#V7_002fSVR3_002e1">V7/SVR3.1</a>).
-
- <li>The <samp><span class="option">-m</span></samp> option and the
<code>fflush</code> function from the
-Bell Laboratories research version of <samp><span
class="command">awk</span></samp>
-(see <a href="#Options">Options</a>; also
-see <a href="#I_002fO-Functions">I/O Functions</a>).
-
- <li>The <samp><span class="option">--re-interval</span></samp> option to
provide interval expressions in regexps
-(see <a href="#Regexp-Operators">Regexp Operators</a>).
-
- <li>The <samp><span class="option">--traditional</span></samp> option was
added as a better name for
-<samp><span class="option">--compat</span></samp> (see <a
href="#Options">Options</a>).
-
- <li>The use of GNU Autoconf to control the configuration process
-(see <a href="#Quick-Installation">Quick Installation</a>).
-
- <li>Amiga support
-(see <a href="#Amiga-Installation">Amiga Installation</a>).
-
- </ul>
-
- <p>Version 3.1 of <samp><span class="command">gawk</span></samp> introduced
the following features:
-
- <ul>
-<li>The <code>BINMODE</code> special variable for non-POSIX systems,
-which allows binary I/O for input and/or output files
-(see <a href="#PC-Using">PC Using</a>).
-
- <li>The <code>LINT</code> special variable, which dynamically controls
lint warnings
-(see <a href="#Built_002din-Variables">Built-in Variables</a>).
-
- <li>The <code>PROCINFO</code> array for providing process-related
information
-(see <a href="#Built_002din-Variables">Built-in Variables</a>).
-
- <li>The <code>TEXTDOMAIN</code> special variable for setting an
application's
-internationalization text domain
-(see <a href="#Built_002din-Variables">Built-in Variables</a>,
-and
-<a href="#Internationalization">Internationalization</a>).
-
- <li>The ability to use octal and hexadecimal constants in <samp><span
class="command">awk</span></samp>
-program source code
-(see <a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>).
-
- <li>The `<samp><span class="samp">|&</span></samp>' operator for
two-way I/O to a coprocess
-(see <a href="#Two_002dway-I_002fO">Two-way I/O</a>).
-
- <li>The <samp><span class="file">/inet</span></samp> special files for
TCP/IP networking using `<samp><span class="samp">|&</span></samp>'
-(see <a href="#TCP_002fIP-Networking">TCP/IP Networking</a>).
-
- <li>The optional second argument to <code>close</code> that allows
closing one end
-of a two-way pipe to a coprocess
-(see <a href="#Two_002dway-I_002fO">Two-way I/O</a>).
-
- <li>The optional third argument to the <code>match</code> function
-for capturing text-matching subexpressions within a regexp
-(see <a href="#String-Functions">String Functions</a>).
-
- <li>Positional specifiers in <code>printf</code> formats for
-making translations easier
-(see <a href="#Printf-Ordering">Printf Ordering</a>).
-
- <li>The <code>asort</code> and <code>asorti</code> functions for sorting
arrays
-(see <a href="#Array-Sorting">Array Sorting</a>).
-
- <li>The <code>bindtextdomain</code>, <code>dcgettext</code> and
<code>dcngettext</code> functions
-for internationalization
-(see <a href="#Programmer-i18n">Programmer i18n</a>).
-
- <li>The <code>extension</code> built-in function and the ability to add
-new built-in functions dynamically
-(see <a href="#Dynamic-Extensions">Dynamic Extensions</a>).
-
- <li>The <code>mktime</code> built-in function for creating timestamps
-(see <a href="#Time-Functions">Time Functions</a>).
-
- <li>The
-<code>and</code>,
-<code>or</code>,
-<code>xor</code>,
-<code>compl</code>,
-<code>lshift</code>,
-<code>rshift</code>,
-and
-<code>strtonum</code> built-in
-functions
-(see <a href="#Bitwise-Functions">Bitwise Functions</a>).
-
- <li><a name="index-_0040code_007bnext-file_007d-statement-1836"></a>The
support for `<samp><span class="samp">next file</span></samp>' as two words was
removed completely
-(see <a href="#Nextfile-Statement">Nextfile Statement</a>).
-
- <li>The <samp><span class="option">--dump-variables</span></samp> option
to print a list of all global variables
-(see <a href="#Options">Options</a>).
-
- <li>The <samp><span class="option">--gen-po</span></samp> command-line
option and the use of a leading
-underscore to mark strings that should be translated
-(see <a href="#String-Extraction">String Extraction</a>).
-
- <li>The <samp><span class="option">--non-decimal-data</span></samp>
option to allow non-decimal
-input data
-(see <a href="#Nondecimal-Data">Nondecimal Data</a>).
-
- <li>The <samp><span class="option">--profile</span></samp> option and
<samp><span class="command">pgawk</span></samp>, the
-profiling version of <samp><span class="command">gawk</span></samp>, for
producing execution
-profiles of <samp><span class="command">awk</span></samp> programs
-(see <a href="#Profiling">Profiling</a>).
-
- <li>The <samp><span class="option">--enable-portals</span></samp>
configuration option to enable special treatment of
-pathnames that begin with <samp><span class="file">/p</span></samp> as BSD
portals
-(see <a href="#Portal-Files">Portal Files</a>).
-
- <li>The use of GNU Automake to help in standardizing the configuration
process
-(see <a href="#Quick-Installation">Quick Installation</a>).
-
- <li>The use of GNU <code>gettext</code> for <samp><span
class="command">gawk</span></samp>'s own message output
-(see <a href="#Gawk-I18N">Gawk I18N</a>).
-
- <li>BeOS support
-(see <a href="#BeOS-Installation">BeOS Installation</a>).
-
- <li>Tandem support
-(see <a href="#Tandem-Installation">Tandem Installation</a>).
-
- <li>The Atari port became officially unsupported
-(see <a href="#Atari-Installation">Atari Installation</a>).
-
- <li>The source code now uses new-style function definitions, with
-<samp><span class="command">ansi2knr</span></samp> to convert the code on
systems with old compilers.
-
- <li>The <samp><span class="option">--disable-lint</span></samp>
configuration option to disable lint checking
-at compile time
-(see <a href="#Additional-Configuration-Options">Additional Configuration
Options</a>).
-
- <li>POSIX compliance for <code>sub</code> and <code>gsub</code>
-(see <a href="#Gory-Details">Gory Details</a>).
-
- </ul>
-
-<!-- XXX ADD MORE STUFF HERE -->
-<!-- ENDOFRANGE fripls -->
-<!-- ENDOFRANGE exgnot -->
-<!-- ENDOFRANGE posnot -->
-<div class="node">
-<p><hr>
-<a name="Contributors"></a>Previous: <a rel="previous" accesskey="p"
href="#POSIX_002fGNU">POSIX/GNU</a>,
-Up: <a rel="up" accesskey="u" href="#Language-History">Language
History</a>
-<br>
-</div>
-
-<h3 class="appendixsec">A.6 Major Contributors to <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-list-of-contributors-to-1837"></a><blockquote>
-<i>Always give credit where credit is due.</i><br>
-Anonymous
-</blockquote>
-
- <p>This section names the major contributors to <samp><span
class="command">gawk</span></samp>
-and/or this Web page, in approximate chronological order:
-
- <ul>
-<li><a name="index-Aho_002c-Alfred-1838"></a><a
name="index-Weinberger_002c-Peter-1839"></a><a
name="index-Kernighan_002c-Brian-1840"></a>Dr. Alfred V. Aho,
-Dr. Peter J. Weinberger, and
-Dr. Brian W. Kernighan, all of Bell Laboratories,
-designed and implemented Unix <samp><span class="command">awk</span></samp>,
-from which <samp><span class="command">gawk</span></samp> gets the majority of
its feature set.
-
- <li><a name="index-Rubin_002c-Paul-1841"></a>Paul Rubin
-did the initial design and implementation in 1986, and wrote
-the first draft (around 40 pages) of this Web page.
-
- <li><a name="index-Fenlason_002c-Jay-1842"></a>Jay Fenlason
-finished the initial implementation.
-
- <li><a name="index-Close_002c-Diane-1843"></a>Diane Close
-revised the first draft of this Web page, bringing it
-to around 90 pages.
-
- <li><a name="index-Stallman_002c-Richard-1844"></a>Richard Stallman
-helped finish the implementation and the initial draft of this
-Web page.
-He is also the founder of the FSF and the GNU project.
-
- <li><a name="index-Woods_002c-John-1845"></a>John Woods
-contributed parts of the code (mostly fixes) in
-the initial version of <samp><span class="command">gawk</span></samp>.
-
- <li><a name="index-Trueman_002c-David-1846"></a>In 1988,
-David Trueman
-took over primary maintenance of <samp><span
class="command">gawk</span></samp>,
-making it compatible with “new” <samp><span
class="command">awk</span></samp>, and
-greatly improving its performance.
-
- <li><a name="index-Rankin_002c-Pat-1847"></a>Pat Rankin
-provided the VMS port and its documentation.
-
- <li><a name="index-Kwok_002c-Conrad-1848"></a><a
name="index-Garfinkle_002c-Scott-1849"></a><a
name="index-Williams_002c-Kent-1850"></a>Conrad Kwok,
-Scott Garfinkle,
-and
-Kent Williams
-did the initial ports to MS-DOS with various versions of MSC.
-
- <li><a name="index-Peterson_002c-Hal-1851"></a>Hal Peterson
-provided help in porting <samp><span class="command">gawk</span></samp> to
Cray systems.
-
- <li><a name="index-Rommel_002c-Kai-Uwe-1852"></a>Kai Uwe Rommel
-provided the initial port to OS/2 and its documentation.
-
- <li><a name="index-Jaegermann_002c-Michal-1853"></a>Michal Jaegermann
-provided the port to Atari systems and its documentation.
-He continues to provide portability checking with DEC Alpha
-systems, and has done a lot of work to make sure <samp><span
class="command">gawk</span></samp>
-works on non-32-bit systems.
-
- <li><a name="index-Fish_002c-Fred-1854"></a>Fred Fish
-provided the port to Amiga systems and its documentation.
-
- <li><a name="index-Deifik_002c-Scott-1855"></a>Scott Deifik
-currently maintains the MS-DOS port.
-
- <li><a name="index-Grigera_002c-Juan-1856"></a>Juan Grigera
-maintains the port to Windows32 systems.
-
- <li><a name="index-Hankerson_002c-Darrel-1857"></a>Dr. Darrel Hankerson
-acts as coordinator for the various ports to different PC platforms
-and creates binary distributions for various PC operating systems.
-He is also instrumental in keeping the documentation up to date for
-the various PC platforms.
-
- <li><a name="index-Zoulas_002c-Christos-1858"></a>Christos Zoulas
-provided the <code>extension</code>
-built-in function for dynamically adding new modules.
-
- <li><a name="index-Kahrs_002c-J_0040_0022urgen-1859"></a>Jürgen Kahrs
-contributed the initial version of the TCP/IP networking
-code and documentation, and motivated the inclusion of the `<samp><span
class="samp">|&</span></samp>' operator.
-
- <li><a name="index-Davies_002c-Stephen-1860"></a>Stephen Davies
-provided the port to Tandem systems and its documentation.
-
- <li><a name="index-Brown_002c-Martin-1861"></a>Martin Brown
-provided the port to BeOS and its documentation.
-
- <li><a name="index-Peters_002c-Arno-1862"></a>Arno Peters
-did the initial work to convert <samp><span class="command">gawk</span></samp>
to use
-GNU Automake and <code>gettext</code>.
-
- <li><a name="index-Broder_002c-Alan-J_002e_0040_003a-1863"></a>Alan J.
Broder
-provided the initial version of the <code>asort</code> function
-as well as the code for the new optional third argument to the
<code>match</code> function.
-
- <li><a name="index-Buening_002c-Andreas-1864"></a>Andreas Buening
-updated the <samp><span class="command">gawk</span></samp> port for OS/2.
-
- <p><a name="index-Hasegawa_002c-Isamu-1865"></a>Isamu Hasegawa,
-of IBM in Japan, contributed support for multibyte characters.
-
- <p><a name="index-Benzinger_002c-Michael-1866"></a>Michael Benzinger
contributed the initial code for <code>switch</code> statements.
-
- <p><a name="index-McPhee_002c-Patrick-1867"></a>Patrick T.J. McPhee
contributed the code for dynamic loading in Windows32
-environments.
-
- <li><a name="index-Robbins_002c-Arnold-1868"></a>Arnold Robbins
-has been working on <samp><span class="command">gawk</span></samp> since 1988,
at first
-helping David Trueman, and as the primary maintainer since around 1994.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Installation"></a>Next: <a rel="next" accesskey="n"
href="#Notes">Notes</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Language-History">Language History</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="appendix">Appendix B Installing <samp><span
class="command">gawk</span></samp></h2>
-
-<!-- last two commas are part of see also -->
-<p><a
name="index-operating-systems_002c-See-Also-GNU_002fLinux_002c-PC-operating-systems_002c-Unix-1869"></a><!--
STARTOFRANGE gligawk -->
-<a name="index-_0040command_007bgawk_007d_002c-installing-1870"></a><!--
STARTOFRANGE ingawk -->
-<a name="index-installing-_0040command_007bgawk_007d-1871"></a>This appendix
provides instructions for installing <samp><span
class="command">gawk</span></samp> on the
-various platforms that are supported by the developers. The primary
-developer supports GNU/Linux (and Unix), whereas the other ports are
-contributed.
-See <a href="#Bugs">Bugs</a>,
-for the electronic mail addresses of the people who did
-the respective ports.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Gawk-Distribution">Gawk Distribution</a>:
What is in the <samp><span class="command">gawk</span></samp> distribution.
-<li><a accesskey="2" href="#Unix-Installation">Unix Installation</a>:
Installing <samp><span class="command">gawk</span></samp> under various
- versions of Unix.
-<li><a accesskey="3" href="#Non_002dUnix-Installation">Non-Unix
Installation</a>: Installation on Other Operating Systems.
-<li><a accesskey="4" href="#Unsupported">Unsupported</a>:
Systems whose ports are no longer supported.
-<li><a accesskey="5" href="#Bugs">Bugs</a>: Reporting
Problems and Bugs.
-<li><a accesskey="6" href="#Other-Versions">Other Versions</a>:
Other freely available <samp><span class="command">awk</span></samp>
- implementations.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Gawk-Distribution"></a>Next: <a rel="next" accesskey="n"
href="#Unix-Installation">Unix Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Installation">Installation</a>
-<br>
-</div>
-
-<h3 class="appendixsec">B.1 The <samp><span class="command">gawk</span></samp>
Distribution</h3>
-
-<p><a name="index-source-code_002c-_0040command_007bgawk_007d-1872"></a>
-This section describes how to get the <samp><span
class="command">gawk</span></samp>
-distribution, how to extract it, and then what is in the various files and
-subdirectories.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Getting">Getting</a>: How to
get the distribution.
-<li><a accesskey="2" href="#Extracting">Extracting</a>: How
to extract the distribution.
-<li><a accesskey="3" href="#Distribution-contents">Distribution contents</a>:
What is in the distribution.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Getting"></a>Next: <a rel="next" accesskey="n"
href="#Extracting">Extracting</a>,
-Up: <a rel="up" accesskey="u" href="#Gawk-Distribution">Gawk
Distribution</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.1.1 Getting the <samp><span
class="command">gawk</span></samp> Distribution</h4>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-source-code_0040comma_007b_007d-obtaining-1873"></a>There
are three ways to get GNU software:
-
- <ul>
-<li>Copy it from someone else who already has it.
-
- <p><a name="index-FSF-_0028Free-Software-Foundation_0029-1874"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-1875"></a><li>Order
<samp><span class="command">gawk</span></samp> directly from the Free Software
Foundation.
-Software distributions are available for
-Gnu/Linux, Unix, and MS-Windows, in several CD packages.
-Their address is:
-
- <pre class="display"> Free Software Foundation
- 51 Franklin Street, Fifth Floor
- Boston, MA 02110-1301 USA
- Phone: +1-617-542-5942
- Fax (including Japan): +1-617-542-2652
- Email: <a href="mailto:address@hidden">address@hidden</a>
- URL: <a href="http://www.gnu.org">http://www.gnu.org</a>
- </pre>
- <p class="noindent">Ordering from the FSF directly contributes to the
support of the foundation
-and to the production of more free software.
-
- <li>Retrieve <samp><span class="command">gawk</span></samp> by using
anonymous <samp><span class="command">ftp</span></samp> to the Internet host
-<code>ftp.gnu.org</code>, in the directory <samp><span
class="file">/gnu/gawk</span></samp>.
-</ul>
-
- <p>The GNU software archive is mirrored around the world.
-The up-to-date list of mirror sites is available from
-<a href="http://www.gnu.org/order/ftp.html">the main FSF web site</a>.
-Try to use one of the mirrors; they
-will be less busy, and you can usually find one closer to your site.
-
-<div class="node">
-<p><hr>
-<a name="Extracting"></a>Next: <a rel="next" accesskey="n"
href="#Distribution-contents">Distribution contents</a>,
-Previous: <a rel="previous" accesskey="p" href="#Getting">Getting</a>,
-Up: <a rel="up" accesskey="u" href="#Gawk-Distribution">Gawk
Distribution</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.1.2 Extracting the Distribution</h4>
-
-<p><samp><span class="command">gawk</span></samp> is distributed as a
<code>tar</code> file compressed with the
-GNU Zip program, <code>gzip</code>.
-
- <p>Once you have the distribution (for example,
-<samp><span class="file">gawk-3.1.4.tar.gz</span></samp>),
-use <code>gzip</code> to expand the
-file and then use <code>tar</code> to extract it. You can use the following
-pipeline to produce the <samp><span class="command">gawk</span></samp>
distribution:
-
-<pre class="example"> # Under System V, add 'o' to the tar options
- gzip -d -c gawk-3.1.4.tar.gz | tar -xvpf -
-</pre>
- <p class="noindent">This creates a directory named <samp><span
class="file">gawk-3.1.4</span></samp>
-in the current directory.
-
- <p>The distribution file name is of the form
-<samp><span class="file">gawk-</span><var>V</var><span
class="file">.</span><var>R</var><span class="file">.</span><var>P</var><span
class="file">.tar.gz</span></samp>.
-The <var>V</var> represents the major version of <samp><span
class="command">gawk</span></samp>,
-the <var>R</var> represents the current release of version <var>V</var>, and
-the <var>P</var> represents a <dfn>patch level</dfn>, meaning that minor bugs
have
-been fixed in the release. The current patch level is 4,
-but when retrieving distributions, you should get the version with the highest
-version, release, and patch level. (Note, however, that patch levels greater
than
-or equal to 80 denote “beta” or nonproduction software; you might
not want
-to retrieve such a version unless you don't mind experimenting.)
-If you are not on a Unix system, you need to make other arrangements
-for getting and extracting the <samp><span class="command">gawk</span></samp>
distribution. You should consult
-a local expert.
-
-<div class="node">
-<p><hr>
-<a name="Distribution-contents"></a>Previous: <a rel="previous"
accesskey="p" href="#Extracting">Extracting</a>,
-Up: <a rel="up" accesskey="u" href="#Gawk-Distribution">Gawk
Distribution</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.1.3 Contents of the <samp><span
class="command">gawk</span></samp> Distribution</h4>
-
-<!-- STARTOFRANGE gawdis -->
-<p><a name="index-_0040command_007bgawk_007d_002c-distribution-1876"></a>
-The <samp><span class="command">gawk</span></samp> distribution has a number
of C source files,
-documentation files,
-subdirectories, and files related to the configuration process
-(see <a href="#Unix-Installation">Unix Installation</a>),
-as well as several subdirectories related to different non-Unix
-operating systems:
-
- <dl>
-<dt>Various `<samp><span class="samp">.c</span></samp>', `<samp><span
class="samp">.y</span></samp>', and `<samp><span class="samp">.h</span></samp>'
files<dd>The actual <samp><span class="command">gawk</span></samp> source code.
-</dl>
-
- <dl>
-<dt><samp><span class="file">README</span></samp><dt><samp><span
class="file">README_d/README.*</span></samp><dd>Descriptive files: <samp><span
class="file">README</span></samp> for <samp><span
class="command">gawk</span></samp> under Unix and the
-rest for the various hardware and software combinations.
-
- <br><dt><samp><span class="file">INSTALL</span></samp><dd>A file
providing an overview of the configuration and installation process.
-
- <br><dt><samp><span class="file">ChangeLog</span></samp><dd>A detailed
list of source code changes as bugs are fixed or improvements made.
-
- <br><dt><samp><span class="file">NEWS</span></samp><dd>A list of changes
to <samp><span class="command">gawk</span></samp> since the last release or
patch.
-
- <br><dt><samp><span class="file">COPYING</span></samp><dd>The GNU General
Public License.
-
- <br><dt><samp><span class="file">FUTURES</span></samp><dd>A brief list of
features and changes being contemplated for future
-releases, with some indication of the time frame for the feature, based
-on its difficulty.
-
- <br><dt><samp><span class="file">LIMITATIONS</span></samp><dd>A list of
those factors that limit <samp><span class="command">gawk</span></samp>'s
performance.
-Most of these depend on the hardware or operating system software and
-are not limits in <samp><span class="command">gawk</span></samp> itself.
-
- <br><dt><samp><span class="file">POSIX.STD</span></samp><dd>A description
of one area in which the POSIX standard for <samp><span
class="command">awk</span></samp> is
-incorrect as well as how <samp><span class="command">gawk</span></samp>
handles the problem.
-
- <p><a
name="index-artificial-intelligence_0040comma_007b_007d-_0040command_007bgawk_007d-and-1877"></a><br><dt><samp><span
class="file">doc/awkforai.txt</span></samp><dd>A short article describing why
<samp><span class="command">gawk</span></samp> is a good language for
-AI (Artificial Intelligence) programming.
-
- <br><dt><samp><span
class="file">doc/README.card</span></samp><dt><samp><span
class="file">doc/ad.block</span></samp><dt><samp><span
class="file">doc/awkcard.in</span></samp><dt><samp><span
class="file">doc/cardfonts</span></samp><dt><samp><span
class="file">doc/colors</span></samp><dt><samp><span
class="file">doc/macros</span></samp><dt><samp><span
class="file">doc/no.colors</span></samp><dt><samp><span
class="file">doc/setter.outline</span></samp><dd>The <samp><span
class="command">troff</span></samp> source for a five-color <samp><span
class="command">awk</span></samp> reference card.
-A modern version of <samp><span class="command">troff</span></samp> such as
GNU <samp><span class="command">troff</span></samp> (<samp><span
class="command">groff</span></samp>) is
-needed to produce the color version. See the file <samp><span
class="file">README.card</span></samp>
-for instructions if you have an older <samp><span
class="command">troff</span></samp>.
-
- <br><dt><samp><span class="file">doc/gawk.1</span></samp><dd>The
<samp><span class="command">troff</span></samp> source for a manual page
describing <samp><span class="command">gawk</span></samp>.
-This is distributed for the convenience of Unix users.
-
- <p><a name="index-Texinfo-1878"></a><br><dt><samp><span
class="file">doc/gawk.texi</span></samp><dd>The Texinfo source file for this
Web page.
-It should be processed with TeX to produce a printed document, and
-with <samp><span class="command">makeinfo</span></samp> to produce an Info or
HTML file.
-
- <br><dt><samp><span class="file">doc/gawk.info</span></samp><dd>The
generated Info file for this Web page.
-
- <br><dt><samp><span class="file">doc/gawkinet.texi</span></samp><dd>The
Texinfo source file for
-<cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>.
-It should be processed with TeX to produce a printed document and
-with <samp><span class="command">makeinfo</span></samp> to produce an Info or
HTML file.
-
- <br><dt><samp><span class="file">doc/gawkinet.info</span></samp><dd>The
generated Info file for
-<cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>.
-
- <br><dt><samp><span class="file">doc/igawk.1</span></samp><dd>The
<samp><span class="command">troff</span></samp> source for a manual page
describing the <samp><span class="command">igawk</span></samp>
-program presented in
-<a href="#Igawk-Program">Igawk Program</a>.
-
- <br><dt><samp><span class="file">doc/Makefile.in</span></samp><dd>The
input file used during the configuration process to generate the
-actual <samp><span class="file">Makefile</span></samp> for creating the
documentation.
-
- <br><dt><samp><span class="file">Makefile.am</span></samp><dt><samp><span
class="file">*/Makefile.am</span></samp><dd>Files used by the GNU <samp><span
class="command">automake</span></samp> software for generating
-the <samp><span class="file">Makefile.in</span></samp> files used by
<samp><span class="command">autoconf</span></samp> and
-<samp><span class="command">configure</span></samp>.
-
- <br><dt><samp><span class="file">Makefile.in</span></samp><dt><samp><span
class="file">acconfig.h</span></samp><dt><samp><span
class="file">acinclude.m4</span></samp><dt><samp><span
class="file">aclocal.m4</span></samp><dt><samp><span
class="file">configh.in</span></samp><dt><samp><span
class="file">configure.in</span></samp><dt><samp><span
class="file">configure</span></samp><dt><samp><span
class="file">custom.h</span></samp><dt><samp><span
class="file">missing_d/*</span></samp><dt><samp><span
class="file">m4/*</span></samp><dd>These files and subdirectories are used when
configuring <samp><span class="command">gawk</span></samp>
-for various Unix systems. They are explained in
-<a href="#Unix-Installation">Unix Installation</a>.
-
- <br><dt><samp><span class="file">intl/*</span></samp><dt><samp><span
class="file">po/*</span></samp><dd>The <samp><span
class="file">intl</span></samp> directory provides the GNU <code>gettext</code>
library, which implements
-<samp><span class="command">gawk</span></samp>'s internationalization
features, while the <samp><span class="file">po</span></samp> library
-contains message translations.
-
- <br><dt><samp><span
class="file">awklib/extract.awk</span></samp><dt><samp><span
class="file">awklib/Makefile.am</span></samp><dt><samp><span
class="file">awklib/Makefile.in</span></samp><dt><samp><span
class="file">awklib/eg/*</span></samp><dd>The <samp><span
class="file">awklib</span></samp> directory contains a copy of <samp><span
class="file">extract.awk</span></samp>
-(see <a href="#Extract-Program">Extract Program</a>),
-which can be used to extract the sample programs from the Texinfo
-source file for this Web page. It also contains a <samp><span
class="file">Makefile.in</span></samp> file, which
-<samp><span class="command">configure</span></samp> uses to generate a
<samp><span class="file">Makefile</span></samp>.
-<samp><span class="file">Makefile.am</span></samp> is used by GNU Automake to
create <samp><span class="file">Makefile.in</span></samp>.
-The library functions from
-<a href="#Library-Functions">Library Functions</a>,
-and the <samp><span class="command">igawk</span></samp> program from
-<a href="#Igawk-Program">Igawk Program</a>,
-are included as ready-to-use files in the <samp><span
class="command">gawk</span></samp> distribution.
-They are installed as part of the installation process.
-The rest of the programs in this Web page are available in appropriate
-subdirectories of <samp><span class="file">awklib/eg</span></samp>.
-
- <br><dt><samp><span
class="file">unsupported/atari/*</span></samp><dd>Files needed for building
<samp><span class="command">gawk</span></samp> on an Atari ST
-(see <a href="#Atari-Installation">Atari Installation</a>, for details).
-
- <br><dt><samp><span
class="file">unsupported/tandem/*</span></samp><dd>Files needed for building
<samp><span class="command">gawk</span></samp> on a Tandem
-(see <a href="#Tandem-Installation">Tandem Installation</a>, for details).
-
- <br><dt><samp><span class="file">posix/*</span></samp><dd>Files needed
for building <samp><span class="command">gawk</span></samp> on POSIX-compliant
systems.
-
- <br><dt><samp><span class="file">pc/*</span></samp><dd>Files needed for
building <samp><span class="command">gawk</span></samp> under MS-DOS, MS
Windows and OS/2
-(see <a href="#PC-Installation">PC Installation</a>, for details).
-
- <br><dt><samp><span class="file">vms/*</span></samp><dd>Files needed for
building <samp><span class="command">gawk</span></samp> under VMS
-(see <a href="#VMS-Installation">VMS Installation</a>, for details).
-
- <br><dt><samp><span class="file">test/*</span></samp><dd>A test suite for
-<samp><span class="command">gawk</span></samp>. You can use `<samp><span
class="samp">make check</span></samp>' from the top-level <samp><span
class="command">gawk</span></samp>
-directory to run your version of <samp><span
class="command">gawk</span></samp> against the test suite.
-If <samp><span class="command">gawk</span></samp> successfully passes
`<samp><span class="samp">make check</span></samp>', then you can
-be confident of a successful port.
-</dl>
- <!-- ENDOFRANGE gawdis -->
-
-<div class="node">
-<p><hr>
-<a name="Unix-Installation"></a>Next: <a rel="next" accesskey="n"
href="#Non_002dUnix-Installation">Non-Unix Installation</a>,
-Previous: <a rel="previous" accesskey="p" href="#Gawk-Distribution">Gawk
Distribution</a>,
-Up: <a rel="up" accesskey="u" href="#Installation">Installation</a>
-<br>
-</div>
-
-<h3 class="appendixsec">B.2 Compiling and Installing <samp><span
class="command">gawk</span></samp> on Unix</h3>
-
-<p>Usually, you can compile and install <samp><span
class="command">gawk</span></samp> by typing only two
-commands. However, if you use an unusual system, you may need
-to configure <samp><span class="command">gawk</span></samp> for your system
yourself.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Quick-Installation">Quick Installation</a>:
Compiling <samp><span class="command">gawk</span></samp> under Unix.
-<li><a accesskey="2" href="#Additional-Configuration-Options">Additional
Configuration Options</a>: Other compile-time options.
-<li><a accesskey="3" href="#Configuration-Philosophy">Configuration
Philosophy</a>: How it's all supposed to work.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Quick-Installation"></a>Next: <a rel="next" accesskey="n"
href="#Additional-Configuration-Options">Additional Configuration Options</a>,
-Up: <a rel="up" accesskey="u" href="#Unix-Installation">Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.2.1 Compiling <samp><span
class="command">gawk</span></samp> for Unix</h4>
-
-<!-- @cindex installation, unix -->
-<p>After you have extracted the <samp><span class="command">gawk</span></samp>
distribution, <samp><span class="command">cd</span></samp>
-to <samp><span class="file">gawk-3.1.4</span></samp>. Like most GNU software,
-<samp><span class="command">gawk</span></samp> is configured
-automatically for your Unix system by running the <samp><span
class="command">configure</span></samp> program.
-This program is a Bourne shell script that is generated automatically using
-GNU <samp><span class="command">autoconf</span></samp>.
-(The <samp><span class="command">autoconf</span></samp> software is
-described fully in
-<cite>Autoconf—Generating Automatic Configuration Scripts</cite>,
-which is available from the Free Software Foundation.)
-
- <p>To configure <samp><span class="command">gawk</span></samp>, simply run
<samp><span class="command">configure</span></samp>:
-
-<pre class="example"> sh ./configure
-</pre>
- <p>This produces a <samp><span class="file">Makefile</span></samp> and
<samp><span class="file">config.h</span></samp> tailored to your system.
-The <samp><span class="file">config.h</span></samp> file describes various
facts about your system.
-You might want to edit the <samp><span class="file">Makefile</span></samp> to
-change the <code>CFLAGS</code> variable, which controls
-the command-line options that are passed to the C compiler (such as
-optimization levels or compiling for debugging).
-
- <p>Alternatively, you can add your own values for most <samp><span
class="command">make</span></samp>
-variables on the command line, such as <code>CC</code> and
<code>CFLAGS</code>, when
-running <samp><span class="command">configure</span></samp>:
-
-<pre class="example"> CC=cc CFLAGS=-g sh ./configure
-</pre>
- <p class="noindent">See the file <samp><span
class="file">INSTALL</span></samp> in the <samp><span
class="command">gawk</span></samp> distribution for
-all the details.
-
- <p>After you have run <samp><span class="command">configure</span></samp>
and possibly edited the <samp><span class="file">Makefile</span></samp>,
-type:
-
-<pre class="example"> make
-</pre>
- <p class="noindent">Shortly thereafter, you should have an executable
version of <samp><span class="command">gawk</span></samp>.
-That's all there is to it!
-To verify that <samp><span class="command">gawk</span></samp> is working
properly,
-run `<samp><span class="samp">make check</span></samp>'. All of the tests
should succeed.
-If these steps do not work, or if any of the tests fail,
-check the files in the <samp><span class="file">README_d</span></samp>
directory to see if you've
-found a known problem. If the failure is not described there,
-please send in a bug report
-(see <a href="#Bugs">Bugs</a>.)
-
-<div class="node">
-<p><hr>
-<a name="Additional-Configuration-Options"></a>Next: <a rel="next"
accesskey="n" href="#Configuration-Philosophy">Configuration Philosophy</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Quick-Installation">Quick Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Unix-Installation">Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.2.2 Additional Configuration Options</h4>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-configuring_002c-options-1879"></a><a
name="index-configuration-options_0040comma_007b_007d-_0040command_007bgawk_007d-1880"></a>
-There are several additional options you may use on the <samp><span
class="command">configure</span></samp>
-command line when compiling <samp><span class="command">gawk</span></samp>
from scratch, including:
-
-
-<a
name="index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1881"></a>
-<a
name="index-configuration-option_002c-_0040code_007b_002d_002denable_002dportals_007d-1882"></a>
-<dl><dt><code>--enable-portals</code><dd>Treat pathnames that begin
-with <samp><span class="file">/p</span></samp> as BSD portal files when doing
two-way I/O with
-the `<samp><span class="samp">|&</span></samp>' operator
-(see <a href="#Portal-Files">Portal Files</a>).
-
- <p><a
name="index-_0040code_007b_002d_002denable_002dswitch_007d-configuration-option-1883"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002denable_002dswitch_007d-1884"></a><br><dt><code>--enable-switch</code><dd>Enable
the recognition and execution of C-style <code>switch</code> statements
-in <samp><span class="command">awk</span></samp> programs
-(see <a href="#Switch-Statement">Switch Statement</a>.)
-
- <p><a name="index-Linux-1885"></a><a
name="index-GNU_002fLinux-1886"></a><a
name="index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1887"></a><a
name="index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option_002c-configuring-_0040command_007bgawk_007d-with-1888"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1889"></a><br><dt><code>--with-included-gettext</code><dd>Use
the version of the <code>gettext</code> library that comes with <samp><span
class="command">gawk</span></samp>.
-This option should be used on systems that do <em>not</em> use version 2 (or
later)
-of the GNU C library.
-All known modern GNU/Linux systems use Glibc 2. Use this option on any other
system.
-
- <p><a
name="index-_0040code_007b_002d_002ddisable_002dlint_007d-configuration-option-1890"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dlint_007d-1891"></a><br><dt><code>--disable-lint</code><dd>This
option disables all lint checking within <code>gawk</code>. The
-<samp><span class="option">--lint</span></samp> and <samp><span
class="option">--lint-old</span></samp> options
-(see <a href="#Options">Options</a>)
-are accepted, but silently do nothing.
-Similarly, setting the <code>LINT</code> variable
-(see <a href="#User_002dmodified">User-modified</a>)
-has no effect on the running <samp><span class="command">awk</span></samp>
program.
-
- <p>When used with GCC's automatic dead-code-elimination, this option
-cuts almost 200K bytes off the size of the <samp><span
class="command">gawk</span></samp>
-executable on GNU/Linux x86 systems. Results on other systems and
-with other compilers are likely to vary.
-Using this option may bring you some slight performance improvement.
-
- <p>Using this option will cause some of the tests in the test suite
-to fail. This option may be removed at a later date.
-
- <p><a
name="index-_0040code_007b_002d_002ddisable_002dnls_007d-configuration-option-1892"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dnls_007d-1893"></a><br><dt><code>--disable-nls</code><dd>Disable
all message-translation facilities.
-This is usually not desirable, but it may bring you some slight performance
-improvement.
-You should also use this option if <samp><span
class="option">--with-included-gettext</span></samp>
-doesn't work on your system.
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="Configuration-Philosophy"></a>Previous: <a rel="previous"
accesskey="p" href="#Additional-Configuration-Options">Additional Configuration
Options</a>,
-Up: <a rel="up" accesskey="u" href="#Unix-Installation">Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.2.3 The Configuration Process</h4>
-
-<p><a name="index-_0040command_007bgawk_007d_002c-configuring-1894"></a>This
section is of interest only if you know something about using the
-C language and the Unix operating system.
-
- <p>The source code for <samp><span class="command">gawk</span></samp>
generally attempts to adhere to formal
-standards wherever possible. This means that <samp><span
class="command">gawk</span></samp> uses library
-routines that are specified by the ISO C standard and by the POSIX
-operating system interface standard. When using an ISO C compiler,
-function prototypes are used to help improve the compile-time checking.
-
- <p>Many Unix systems do not support all of either the ISO or the
-POSIX standards. The <samp><span class="file">missing_d</span></samp>
subdirectory in the <samp><span class="command">gawk</span></samp>
-distribution contains replacement versions of those functions that are
-most likely to be missing.
-
- <p>The <samp><span class="file">config.h</span></samp> file that
<samp><span class="command">configure</span></samp> creates contains
-definitions that describe features of the particular operating system
-where you are attempting to compile <samp><span
class="command">gawk</span></samp>. The three things
-described by this file are: what header files are available, so that
-they can be correctly included, what (supposedly) standard functions
-are actually available in your C libraries, and various miscellaneous
-facts about your variant of Unix. For example, there may not be an
-<code>st_blksize</code> element in the <code>stat</code> structure. In this
case,
-`<samp><span class="samp">HAVE_ST_BLKSIZE</span></samp>' is undefined.
-
- <p><a name="index-_0040code_007bcustom_002eh_007d-file-1895"></a>It is
possible for your C compiler to lie to <samp><span
class="command">configure</span></samp>. It may
-do so by not exiting with an error when a library function is not
-available. To get around this, edit the file <samp><span
class="file">custom.h</span></samp>.
-Use an `<samp><span class="samp">#ifdef</span></samp>' that is appropriate for
your system, and either
-<code>#define</code> any constants that <samp><span
class="command">configure</span></samp> should have defined but
-didn't, or <code>#undef</code> any constants that <samp><span
class="command">configure</span></samp> defined and
-should not have. <samp><span class="file">custom.h</span></samp> is
automatically included by
-<samp><span class="file">config.h</span></samp>.
-
- <p>It is also possible that the <samp><span
class="command">configure</span></samp> program generated by
-<samp><span class="command">autoconf</span></samp> will not work on your
system in some other fashion.
-If you do have a problem, the file <samp><span
class="file">configure.in</span></samp> is the input for
-<samp><span class="command">autoconf</span></samp>. You may be able to change
this file and generate a
-new version of <samp><span class="command">configure</span></samp> that works
on your system
-(see <a href="#Bugs">Bugs</a>,
-for information on how to report problems in configuring <samp><span
class="command">gawk</span></samp>).
-The same mechanism may be used to send in updates to <samp><span
class="file">configure.in</span></samp>
-and/or <samp><span class="file">custom.h</span></samp>.
-
-<div class="node">
-<p><hr>
-<a name="Non_002dUnix-Installation"></a>Next: <a rel="next" accesskey="n"
href="#Unsupported">Unsupported</a>,
-Previous: <a rel="previous" accesskey="p" href="#Unix-Installation">Unix
Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Installation">Installation</a>
-<br>
-</div>
-
-<h3 class="appendixsec">B.3 Installation on Other Operating Systems</h3>
-
-<p>This section describes how to install <samp><span
class="command">gawk</span></samp> on
-various non-Unix systems.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Amiga-Installation">Amiga Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on an Amiga.
-<li><a accesskey="2" href="#BeOS-Installation">BeOS Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on BeOS.
-<li><a accesskey="3" href="#PC-Installation">PC Installation</a>:
Installing and Compiling <samp><span class="command">gawk</span></samp> on
- MS-DOS and OS/2.
-<li><a accesskey="4" href="#VMS-Installation">VMS Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on VMS.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Amiga-Installation"></a>Next: <a rel="next" accesskey="n"
href="#BeOS-Installation">BeOS Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.3.1 Installing <samp><span
class="command">gawk</span></samp> on an Amiga</h4>
-
-<p><a name="index-amiga-1896"></a><a
name="index-installation_002c-amiga-1897"></a>You can install <samp><span
class="command">gawk</span></samp> on an Amiga system using a Unix emulation
-environment, available via anonymous <samp><span
class="command">ftp</span></samp> from
-<code>ftp.ninemoons.com</code> in the directory <samp><span
class="file">pub/ade/current</span></samp>.
-This includes a shell based on <samp><span
class="command">pdksh</span></samp>. The primary component of
-this environment is a Unix emulation library, <samp><span
class="file">ixemul.lib</span></samp>.
-<!-- could really use more background here, who wrote this, etc. -->
-
- <p>A more complete distribution for the Amiga is available on
-the Geek Gadgets CD-ROM, available from:
-
-<pre class="display"> CRONUS
- 1840 E. Warner Road #105-265
- Tempe, AZ 85284 USA
- US Toll Free: (800) 804-0833
- Phone: +1-602-491-0442
- FAX: +1-602-491-0048
- Email: <a href="mailto:address@hidden">address@hidden</a>
- WWW: <a href="http://www.ninemoons.com">http://www.ninemoons.com</a>
- Anonymous <samp><span class="command">ftp</span></samp> site:
<code>ftp.ninemoons.com</code>
-</pre>
- <p>Once you have the distribution, you can configure <samp><span
class="command">gawk</span></samp> simply by
-running <samp><span class="command">configure</span></samp>:
-
-<pre class="example"> configure -v m68k-amigaos
-</pre>
- <p>Then run <samp><span class="command">make</span></samp> and you should
be all set!
-If these steps do not work, please send in a bug report
-(see <a href="#Bugs">Bugs</a>).
-
-<div class="node">
-<p><hr>
-<a name="BeOS-Installation"></a>Next: <a rel="next" accesskey="n"
href="#PC-Installation">PC Installation</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Amiga-Installation">Amiga Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.3.2 Installing <samp><span
class="command">gawk</span></samp> on BeOS</h4>
-
-<p><a name="index-BeOS-1898"></a><a
name="index-installation_002c-beos-1899"></a>
-<!-- From email contributed by Martin Brown, address@hidden -->
-Since BeOS DR9, all the tools that you should need to build <code>gawk</code>
are
-included with BeOS. The process is basically identical to the Unix process
-of running <samp><span class="command">configure</span></samp> and then
<samp><span class="command">make</span></samp>. Full instructions are given
below.
-
- <p>You can compile <samp><span class="command">gawk</span></samp> under
BeOS by extracting the standard sources
-and running <samp><span class="command">configure</span></samp>. You
<em>must</em> specify the location
-prefix for the installation directory. For BeOS DR9 and beyond, the best
directory to
-use is <samp><span class="file">/boot/home/config</span></samp>, so the
<samp><span class="command">configure</span></samp> command is:
-
-<pre class="example"> configure --prefix=/boot/home/config
-</pre>
- <p>This installs the compiled application into <samp><span
class="file">/boot/home/config/bin</span></samp>,
-which is already specified in the standard <samp><span
class="env">PATH</span></samp>.
-
- <p>Once the configuration process is completed, you can run <samp><span
class="command">make</span></samp>,
-and then `<samp><span class="samp">make install</span></samp>':
-
-<pre class="example"> $ make
- ...
- $ make install
-</pre>
- <p>BeOS uses <samp><span class="command">bash</span></samp> as its shell;
thus, you use <samp><span class="command">gawk</span></samp> the same way you
would
-under Unix.
-If these steps do not work, please send in a bug report
-(see <a href="#Bugs">Bugs</a>).
-
-<!-- Rewritten by Scott Deifik <address@hidden> -->
-<!-- and Darrel Hankerson <address@hidden> -->
-<div class="node">
-<p><hr>
-<a name="PC-Installation"></a>Next: <a rel="next" accesskey="n"
href="#VMS-Installation">VMS Installation</a>,
-Previous: <a rel="previous" accesskey="p" href="#BeOS-Installation">BeOS
Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.3.3 Installation on PC Operating Systems</h4>
-
-<p><a
name="index-PC-operating-systems_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1900"></a><a
name="index-operating-systems_002c-PC_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1901"></a>This
section covers installation and usage of <samp><span
class="command">gawk</span></samp> on x86 machines
-running DOS, any version of Windows, or OS/2.
-In this section, the term “Windows32”
-refers to any of Windows-95/98/ME/NT/2000.
-
- <p>The limitations of DOS (and DOS shells under Windows or OS/2) has meant
-that various “DOS extenders” are often used with programs such as
-<samp><span class="command">gawk</span></samp>. The varying capabilities of
Microsoft Windows 3.1
-and Windows32 can add to the confusion. For an overview of the
-considerations, please refer to <samp><span
class="file">README_d/README.pc</span></samp> in the
-distribution.
-
-<ul class="menu">
-<li><a accesskey="1" href="#PC-Binary-Installation">PC Binary
Installation</a>: Installing a prepared distribution.
-<li><a accesskey="2" href="#PC-Compiling">PC Compiling</a>:
Compiling <samp><span class="command">gawk</span></samp> for MS-DOS, Windows32,
- and OS/2.
-<li><a accesskey="3" href="#PC-Dynamic">PC Dynamic</a>:
Compiling <samp><span class="command">gawk</span></samp> for dynamic libraries.
-<li><a accesskey="4" href="#PC-Using">PC Using</a>:
Running <samp><span class="command">gawk</span></samp> on MS-DOS, Windows32 and
- OS/2.
-<li><a accesskey="5" href="#Cygwin">Cygwin</a>: Building
and running <samp><span class="command">gawk</span></samp> for
- Cygwin.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="PC-Binary-Installation"></a>Next: <a rel="next" accesskey="n"
href="#PC-Compiling">PC Compiling</a>,
-Up: <a rel="up" accesskey="u" href="#PC-Installation">PC Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.1 Installing a Prepared Distribution for
PC Systems</h5>
-
-<p>If you have received a binary distribution prepared by the DOS
-maintainers, then <samp><span class="command">gawk</span></samp> and the
necessary support files appear
-under the <samp><span class="file">gnu</span></samp> directory, with
executables in <samp><span class="file">gnu/bin</span></samp>,
-libraries in <samp><span class="file">gnu/lib/awk</span></samp>, and manual
pages under <samp><span class="file">gnu/man</span></samp>.
-This is designed for easy installation to a <samp><span
class="file">/gnu</span></samp> directory on your
-drive—however, the files can be installed anywhere provided <samp><span
class="env">AWKPATH</span></samp> is
-set properly. Regardless of the installation directory, the first line of
-<samp><span class="file">igawk.cmd</span></samp> and <samp><span
class="file">igawk.bat</span></samp> (in <samp><span
class="file">gnu/bin</span></samp>) may need to be
-edited.
-
- <p>The binary distribution contains a separate file describing the
-contents. In particular, it may include more than one version of the
-<samp><span class="command">gawk</span></samp> executable.
-
- <p>OS/2 (32 bit, EMX) binary distributions are prepared for the <samp><span
class="file">/usr</span></samp>
-directory of your preferred drive. Set <samp><span
class="env">UnixROOT</span></samp> to your installation
-drive (e.g., `<samp><span class="samp">e:</span></samp>') if you want to
install <samp><span class="command">gawk</span></samp> onto another drive
-than the hardcoded default `<samp><span class="samp">c:</span></samp>'.
Executables appear in <samp><span class="file">/usr/bin</span></samp>,
-libraries under <samp><span class="file">/usr/share/awk</span></samp>, manual
pages under <samp><span class="file">/usr/man</span></samp>,
-Texinfo documentation under <samp><span class="file">/usr/info</span></samp>
and NLS files under <samp><span class="file">/usr/share/locale</span></samp>.
-If you already have a file <samp><span
class="file">/usr/info/dir</span></samp> from another package
-<em>do not overwrite it!</em> Instead enter the following commands at your
prompt
-(replace `<samp><span class="samp">x:</span></samp>' by your installation
drive):
-
-<pre class="example"> install-info --info-dir=x:/usr/info
x:/usr/info/gawk.info
- install-info --info-dir=x:/usr/info x:/usr/info/gawkinet.info
-</pre>
- <p>However, the files can be installed anywhere provided <samp><span
class="env">AWKPATH</span></samp> is
-set properly.
-
- <p>The binary distribution may contain a separate file containing additional
-or more detailed installation instructions.
-
-<div class="node">
-<p><hr>
-<a name="PC-Compiling"></a>Next: <a rel="next" accesskey="n"
href="#PC-Dynamic">PC Dynamic</a>,
-Previous: <a rel="previous" accesskey="p"
href="#PC-Binary-Installation">PC Binary Installation</a>,
-Up: <a rel="up" accesskey="u" href="#PC-Installation">PC Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.2 Compiling <samp><span
class="command">gawk</span></samp> for PC Operating Systems</h5>
-
-<p><samp><span class="command">gawk</span></samp> can be compiled for MS-DOS,
Windows32, and OS/2 using the GNU
-development tools from DJ Delorie (DJGPP; MS-DOS only) or Eberhard
-Mattes (EMX; MS-DOS, Windows32 and OS/2). Microsoft Visual C/C++ can be used
-to build a Windows32 version, and Microsoft C/C++ can be
-used to build 16-bit versions for MS-DOS and OS/2.
-<!-- FIXME: -->
-(As of <samp><span class="command">gawk</span></samp> 3.1.2, the MSC version
doesn't work. However,
-the maintainer is working on fixing it.)
-The file
-<samp><span class="file">README_d/README.pc</span></samp> in the <samp><span
class="command">gawk</span></samp> distribution contains
-additional notes, and <samp><span class="file">pc/Makefile</span></samp>
contains important information on
-compilation options.
-
- <p>To build <samp><span class="command">gawk</span></samp> for MS-DOS,
Windows32, and OS/2 (16 bit only; for 32 bit
-(EMX) you can use the <samp><span class="command">configure</span></samp>
script and skip the following paragraphs;
-for details see below), copy the files in the <samp><span
class="file">pc</span></samp> directory (<em>except</em>
-for <samp><span class="file">ChangeLog</span></samp>) to the directory with
the rest of the <samp><span class="command">gawk</span></samp>
-sources. The <samp><span class="file">Makefile</span></samp> contains a
configuration section with comments and
-may need to be edited in order to work with your <samp><span
class="command">make</span></samp> utility.
-
- <p>The <samp><span class="file">Makefile</span></samp> contains a number of
targets for building various MS-DOS,
-Windows32, and OS/2 versions. A list of targets is printed if the <samp><span
class="command">make</span></samp>
-command is given without a target. As an example, to build <samp><span
class="command">gawk</span></samp>
-using the DJGPP tools, enter `<samp><span class="samp">make
djgpp</span></samp>'.
-(The DJGPP tools may be found at
-<a
href="ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/">ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/</a>.)
-
- <p>Using <samp><span class="command">make</span></samp> to run the standard
tests and to install <samp><span class="command">gawk</span></samp>
-requires additional Unix-like tools, including <samp><span
class="command">sh</span></samp>, <samp><span
class="command">sed</span></samp>, and
-<samp><span class="command">cp</span></samp>. In order to run the tests, the
<samp><span class="file">test/*.ok</span></samp> files may need to
-be converted so that they have the usual DOS-style end-of-line markers. Most
-of the tests work properly with Stewartson's shell along with the
-companion utilities or appropriate GNU utilities. However, some editing of
-<samp><span class="file">test/Makefile</span></samp> is required. It is
recommended that you copy the file
-<samp><span class="file">pc/Makefile.tst</span></samp> over the file
<samp><span class="file">test/Makefile</span></samp> as a
-replacement. Details can be found in <samp><span
class="file">README_d/README.pc</span></samp>
-and in the file <samp><span class="file">pc/Makefile.tst</span></samp>.
-
- <p>The 32 bit EMX version of <samp><span class="command">gawk</span></samp>
works “out of the box” under OS/2.
-In principle, it is possible to compile <samp><span
class="command">gawk</span></samp> the following way:
-
-<pre class="example"> $ ./configure
- $ make
-</pre>
- <p>This is not recommended, though. To get an OMF executable you should
-use the following commands at your <samp><span
class="command">sh</span></samp> prompt:
-
-<pre class="example"> $ CPPFLAGS="-D__ST_MT_ERRNO__"
- $ export CPPFLAGS
- $ CFLAGS="-O2 -Zomf -Zmt"
- $ export CFLAGS
- $ LDFLAGS="-s -Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack
0x8000"
- $ export LDFLAGS
- $ RANLIB="echo"
- $ export RANLIB
- $ ./configure --prefix=c:/usr --without-included-gettext
- $ make AR=emxomfar
-</pre>
- <p>These are just suggestions. You may use any other set of
(self-consistent)
-environment variables and compiler flags.
-
- <p>To get an FHS-compliant file hierarchy it is recommended to use the
additional
-<samp><span class="command">configure</span></samp> options <samp><span
class="option">--infodir=c:/usr/share/info</span></samp>, <samp><span
class="option">--mandir=c:/usr/share/man</span></samp>
-and <samp><span class="option">--libexecdir=c:/usr/lib</span></samp>.
-
- <p>The internal <code>gettext</code> library tends to be problematic. It is
therefore recommended
-to use either an external one (<samp><span
class="option">--without-included-gettext</span></samp>) or to disable
-NLS entirely (<samp><span class="option">--disable-nls</span></samp>).
-
- <p>If you use GCC 2.95 or newer it is recommended to use also:
-
-<pre class="example"> $ LIBS="-lgcc"
- $ export LIBS
-</pre>
- <p>You can also get an <code>a.out</code> executable if you prefer:
-
-<pre class="example"> $ CPPFLAGS="-D__ST_MT_ERRNO__"
- $ export CPPFLAGS
- $ CFLAGS="-O2 -Zmt"
- $ export CFLAGS
- $ LDFLAGS="-s -Zstack 0x8000"
- $ LIBS="-lgcc"
- $ unset RANLIB
- $ ./configure --prefix=c:/usr --without-included-gettext
- $ make
-</pre>
- <blockquote>
-<b>NOTE:</b> Even if the compiled <samp><span
class="command">gawk.exe</span></samp> (<code>a.out</code>) executable
-contains a DOS header, it does <em>not</em> work under DOS. To compile an
executable
-that runs under DOS, <code>"-DPIPES_SIMULATED"</code> must be added to
<samp><span class="env">CPPFLAGS</span></samp>.
-But then some nonstandard extensions of <samp><span
class="command">gawk</span></samp> (e.g., `<samp><span
class="samp">|&</span></samp>') do not work!
-</blockquote>
-
- <p>After compilation the internal tests can be performed. Enter
-`<samp><span class="samp">make check CMP="diff -a"</span></samp>' at your
command prompt. All tests
-but the <code>pid</code> test are expected to work properly. The
<code>pid</code>
-test fails because child processes are not started by <code>fork()</code>.
-
- <p>`<samp><span class="samp">make install</span></samp>' works as expected.
-
- <blockquote>
-<b>NOTE:</b> Most OS/2 ports of GNU <samp><span
class="command">make</span></samp> are not able to handle
-the Makefiles of this package. If you encounter any problems with <samp><span
class="command">make</span></samp>
-try GNU Make 3.79.1 or later versions. You should find the latest
-version on <a
href="http://www.unixos2.org/sw/pub/binary/make/">http://www.unixos2.org/sw/pub/binary/make/</a>
or on
-<a href="ftp://hobbes.nmsu.edu/pub/os2/">ftp://hobbes.nmsu.edu/pub/os2/</a>.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="PC-Dynamic"></a>Next: <a rel="next" accesskey="n"
href="#PC-Using">PC Using</a>,
-Previous: <a rel="previous" accesskey="p" href="#PC-Compiling">PC
Compiling</a>,
-Up: <a rel="up" accesskey="u" href="#PC-Installation">PC Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.3 Compiling <samp><span
class="command">gawk</span></samp> For Dynamic Libraries</h5>
-
-<!-- From README_d/README.pcdynamic -->
-<!-- 11 June 2003 -->
-<p>To compile <samp><span class="command">gawk</span></samp> with dynamic
extension support,
-uncomment the definitions of <code>DYN_FLAGS</code>, <code>DYN_EXP</code>,
-<code>DYN_OBJ</code>, and <code>DYN_MAKEXP</code> in the configuration section
of
-the <samp><span class="file">Makefile</span></samp>. There are two definitions
for <code>DYN_MAKEXP</code>:
-pick the one that matches your target.
-
- <p>To build some of the example extension libraries, <samp><span
class="command">cd</span></samp> to the
-extension directory and copy <samp><span
class="file">Makefile.pc</span></samp> to <samp><span
class="file">Makefile</span></samp>. You
-can then build using the same two targets. To run the example
-<samp><span class="command">awk</span></samp> scripts, you'll need to either
change the call to
-the <code>extension</code> function to match the name of the library (for
-instance, change <code>"./ordchr.so"</code> to <code>"ordchr.dll"</code> or
simply
-<code>"ordchr"</code>), or rename the library to match the call (for instance,
-rename <samp><span class="file">ordchr.dll</span></samp> to <samp><span
class="file">ordchr.so</span></samp>).
-
- <p>If you build <samp><span class="command">gawk.exe</span></samp> with one
compiler but want to build
-an extension library with the other, you need to copy the import
-library. Visual C uses a library called <samp><span
class="file">gawk.lib</span></samp>, while MinGW uses
-a library called <samp><span class="file">libgawk.a</span></samp>. These files
are equivalent and will
-interoperate if you give them the correct name. The resulting shared
-libraries are also interoperable.
-
- <p>To create your own extension library, you can use the examples as models,
-but you're essentially on your own. Post to <code>comp.lang.awk</code> or
-send electronic mail to <a href="mailto:address@hidden">address@hidden</a> if
you have problems getting
-started. If you need to access functions or variables which are not
-exported by <samp><span class="command">gawk.exe</span></samp>, add them to
<samp><span class="file">gawkw32.def</span></samp> and
-rebuild. You should also add <code>ATTRIBUTE_EXPORTED</code> to the declaration
-in <samp><span class="file">awk.h</span></samp> of any variables you add to
<samp><span class="file">gawkw32.def</span></samp>.
-
- <p>Note that extension libraries have the name of the <samp><span
class="command">awk</span></samp>
-executable embedded in them at link time, so they will work only
-with <samp><span class="command">gawk.exe</span></samp>. In particular, they
won't work if you
-rename <samp><span class="command">gawk.exe</span></samp> to <samp><span
class="command">awk.exe</span></samp> or if you try to use
-<samp><span class="command">pgawk.exe</span></samp>. You can perform profiling
by temporarily renaming
-<samp><span class="command">pgawk.exe</span></samp> to <samp><span
class="command">gawk.exe</span></samp>. You can resolve this problem
-by changing the program name in the definition of <code>DYN_MAKEXP</code>
-for your compiler.
-
- <p>On Windows32, libraries are sought first in the current directory, then
in
-the directory containing <samp><span class="command">gawk.exe</span></samp>,
and finally through the
-<samp><span class="env">PATH</span></samp> environment variable.
-
-<div class="node">
-<p><hr>
-<a name="PC-Using"></a>Next: <a rel="next" accesskey="n"
href="#Cygwin">Cygwin</a>,
-Previous: <a rel="previous" accesskey="p" href="#PC-Dynamic">PC
Dynamic</a>,
-Up: <a rel="up" accesskey="u" href="#PC-Installation">PC Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.4 Using <samp><span
class="command">gawk</span></samp> on PC Operating Systems</h5>
-
-<!-- STARTOFRANGE opgawx -->
-<p><a
name="index-operating-systems_002c-PC_002c-_0040command_007bgawk_007d-on-1902"></a><!--
STARTOFRANGE pcgawon -->
-<a
name="index-PC-operating-systems_002c-_0040command_007bgawk_007d-on-1903"></a>
-With the exception of the Cygwin environment,
-the `<samp><span class="samp">|&</span></samp>' operator and TCP/IP
networking
-(see <a href="#TCP_002fIP-Networking">TCP/IP Networking</a>)
-are not supported for MS-DOS or MS-Windows. EMX (OS/2 only) does support
-at least the `<samp><span class="samp">|&</span></samp>' operator.
-
- <p><a name="index-search-paths-1904"></a><a
name="index-_0040command_007bgawk_007d_002c-OS_002f2-version-of-1905"></a><a
name="index-_0040command_007bgawk_007d_002c-MS_002dDOS-version-of-1906"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1907"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1908"></a><a
name="index-_0040code_007bAWKPATH_007d-environment-variable-1909"></a>The OS/2
and MS-DOS versions of <samp><span class="command">gawk</span></samp> search
for program files as
-described in <a href="#AWKPATH-Variable">AWKPATH Variable</a>.
-However, semicolons (rather than colons) separate elements
-in the <samp><span class="env">AWKPATH</span></samp> variable. If <samp><span
class="env">AWKPATH</span></samp> is not set or is empty,
-then the default search path for OS/2 (16 bit) and MS-DOS versions is
-<code>".;c:/lib/awk;c:/gnu/lib/awk"<!-- /@w --></code>.
-
- <p>The search path for OS/2 (32 bit, EMX) is determined by the prefix
directory
-(most likely <samp><span class="file">/usr</span></samp> or <samp><span
class="file">c:/usr</span></samp>) that has been specified as an option of
-the <samp><span class="command">configure</span></samp> script like it is the
case for the Unix versions.
-If <samp><span class="file">c:/usr</span></samp> is the prefix directory then
the default search path contains <samp><span class="file">.</span></samp>
-and <samp><span class="file">c:/usr/share/awk</span></samp>.
-Additionally, to support binary distributions of <samp><span
class="command">gawk</span></samp> for OS/2
-systems whose drive `<samp><span class="samp">c:</span></samp>' might not
support long file names or might not exist
-at all, there is a special environment variable. If <samp><span
class="env">UnixROOT</span></samp> specifies
-a drive then this specific drive is also searched for program files.
-E.g., if <samp><span class="env">UnixROOT</span></samp> is set to <samp><span
class="file">e:</span></samp> the complete default search path is
-<code>".;c:/usr/share/awk;e:/usr/share/awk"<!-- /@w --></code>.
-
- <p>An <samp><span class="command">sh</span></samp>-like shell (as opposed
to <samp><span class="command">command.com</span></samp> under MS-DOS
-or <samp><span class="command">cmd.exe</span></samp> under OS/2) may be useful
for <samp><span class="command">awk</span></samp> programming.
-Ian Stewartson has written an excellent shell for MS-DOS and OS/2,
-Daisuke Aoyama has ported GNU <samp><span class="command">bash</span></samp>
to MS-DOS using the DJGPP tools,
-and several shells are available for OS/2, including <samp><span
class="command">ksh</span></samp>. The file
-<samp><span class="file">README_d/README.pc</span></samp> in the <samp><span
class="command">gawk</span></samp> distribution contains
-information on these shells. Users of Stewartson's shell on DOS should
-examine its documentation for handling command lines; in particular,
-the setting for <samp><span class="command">gawk</span></samp> in the shell
configuration may need to be
-changed and the <code>ignoretype</code> option may also be of interest.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-1910"></a><a
name="index-_0040code_007bBINMODE_007d-variable-1911"></a>Under OS/2 and DOS,
<samp><span class="command">gawk</span></samp> (and many other text programs)
silently
-translate end-of-line <code>"\r\n"</code> to <code>"\n"</code> on input and
<code>"\n"</code>
-to <code>"\r\n"</code> on output. A special <code>BINMODE</code> variable
allows
-control over these translations and is interpreted as follows:
-
- <ul>
-<li>If <code>BINMODE</code> is `<samp><span class="samp">"r"</span></samp>', or
-<code>(BINMODE & 1)</code> is nonzero, then
-binary mode is set on read (i.e., no translations on reads).
-
- <li>If <code>BINMODE</code> is <code>"w"</code>, or
-<code>(BINMODE & 2)</code> is nonzero, then
-binary mode is set on write (i.e., no translations on writes).
-
- <li>If <code>BINMODE</code> is <code>"rw"</code> or <code>"wr"</code>,
-binary mode is set for both read and write
-(same as <code>(BINMODE & 3)</code>).
-
- <li><code>BINMODE=</code><var>non-null-string</var> is
-the same as `<samp><span class="samp">BINMODE=3</span></samp>' (i.e., no
translations on
-reads or writes). However, <samp><span class="command">gawk</span></samp>
issues a warning
-message if the string is not one of <code>"rw"</code> or <code>"wr"</code>.
-</ul>
-
-<p class="noindent">The modes for standard input and standard output are set
one time
-only (after the
-command line is read, but before processing any of the <samp><span
class="command">awk</span></samp> program).
-Setting <code>BINMODE</code> for standard input or
-standard output is accomplished by using an
-appropriate `<samp><span class="samp">-v BINMODE=</span><var>N</var></samp>'
option on the command line.
-<code>BINMODE</code> is set at the time a file or pipe is opened and cannot be
-changed mid-stream.
-
- <p>The name <code>BINMODE</code> was chosen to match <samp><span
class="command">mawk</span></samp>
-(see <a href="#Other-Versions">Other Versions</a>).
-Both <samp><span class="command">mawk</span></samp> and <samp><span
class="command">gawk</span></samp> handle <code>BINMODE</code> similarly;
however,
-<samp><span class="command">mawk</span></samp> adds a `<samp><span
class="samp">-W BINMODE=</span><var>N</var></samp>' option and an environment
-variable that can set <code>BINMODE</code>, <code>RS</code>, and
<code>ORS</code>. The
-files <samp><span class="file">binmode[1-3].awk</span></samp> (under
<samp><span class="file">gnu/lib/awk</span></samp> in some of the
-prepared distributions) have been chosen to match <samp><span
class="command">mawk</span></samp>'s `<samp><span class="samp">-W
-BINMODE=</span><var>N</var></samp>' option. These can be changed or
discarded; in particular,
-the setting of <code>RS</code> giving the fewest “surprises” is
open to debate.
-<samp><span class="command">mawk</span></samp> uses `<samp><span
class="samp">RS = "\r\n"</span></samp>' if binary mode is set on read, which is
-appropriate for files with the DOS-style end-of-line.
-
- <p>To illustrate, the following examples set binary mode on writes for
standard
-output and other files, and set <code>ORS</code> as the “usual”
DOS-style
-end-of-line:
-
-<pre class="example"> gawk -v BINMODE=2 -v ORS="\r\n" ...
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> gawk -v BINMODE=w -f binmode2.awk ...
-</pre>
- <p class="noindent">These give the same result as the `<samp><span
class="samp">-W BINMODE=2</span></samp>' option in
-<samp><span class="command">mawk</span></samp>.
-The following changes the record separator to <code>"\r\n"</code> and sets
binary
-mode on reads, but does not affect the mode on standard input:
-
-<pre class="example"> gawk -v RS="\r\n" --source "BEGIN { BINMODE = 1 }"
...
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> gawk -f binmode1.awk ...
-</pre>
- <p class="noindent">With proper quoting, in the first example the setting
of <code>RS</code> can be
-moved into the <code>BEGIN</code> rule.
-
-<div class="node">
-<p><hr>
-<a name="Cygwin"></a>Previous: <a rel="previous" accesskey="p"
href="#PC-Using">PC Using</a>,
-Up: <a rel="up" accesskey="u" href="#PC-Installation">PC Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.5 Using <samp><span
class="command">gawk</span></samp> In The Cygwin Environment</h5>
-
-<p><samp><span class="command">gawk</span></samp> can be used “out of
the box” under Windows if you are
-using the Cygwin environment.<a rel="footnote" href="#fn-68"
name="fnd-68"><sup>68</sup></a>
-This environment provides an excellent simulation of Unix, using the
-GNU tools, such as <samp><span class="command">bash</span></samp>, the GNU
Compiler Collection (GCC),
-GNU Make, and other GNU tools. Compilation and installation for Cygwin
-is the same as for a Unix system:
-
-<pre class="example"> tar -xvpzf gawk-3.1.4.tar.gz
- cd gawk-3.1.4
- ./configure
- make
-</pre>
- <p>When compared to GNU/Linux on the same system, the `<samp><span
class="samp">configure</span></samp>'
-step on Cygwin takes considerably longer. However, it does finish,
-and then the `<samp><span class="samp">make</span></samp>' proceeds as usual.
-
- <blockquote>
-<b>NOTE:</b> The `<samp><span class="samp">|&</span></samp>' operator and
TCP/IP networking
-(see <a href="#TCP_002fIP-Networking">TCP/IP Networking</a>)
-are fully supported in the Cygwin environment. This is not true
-for any other environment for MS-DOS or MS-Windows.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="VMS-Installation"></a>Previous: <a rel="previous" accesskey="p"
href="#PC-Installation">PC Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.3.4 How to Compile and Install <samp><span
class="command">gawk</span></samp> on VMS</h4>
-
-<!-- based on material from Pat Rankin <address@hidden> -->
-<!-- now address@hidden -->
-<p><a name="index-installation_002c-vms-1912"></a>This subsection describes
how to compile and install <samp><span class="command">gawk</span></samp> under
VMS.
-
-<ul class="menu">
-<li><a accesskey="1" href="#VMS-Compilation">VMS Compilation</a>:
How to compile <samp><span class="command">gawk</span></samp> under VMS.
-<li><a accesskey="2" href="#VMS-Installation-Details">VMS Installation
Details</a>: How to install <samp><span class="command">gawk</span></samp>
under VMS.
-<li><a accesskey="3" href="#VMS-Running">VMS Running</a>: How
to run <samp><span class="command">gawk</span></samp> under VMS.
-<li><a accesskey="4" href="#VMS-POSIX">VMS POSIX</a>:
Alternate instructions for VMS POSIX.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="VMS-Compilation"></a>Next: <a rel="next" accesskey="n"
href="#VMS-Installation-Details">VMS Installation Details</a>,
-Up: <a rel="up" accesskey="u" href="#VMS-Installation">VMS
Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.1 Compiling <samp><span
class="command">gawk</span></samp> on VMS</h5>
-
-<p>To compile <samp><span class="command">gawk</span></samp> under VMS, there
is a <code>DCL</code> command procedure that
-issues all the necessary <code>CC</code> and <code>LINK</code> commands. There
is
-also a <samp><span class="file">Makefile</span></samp> for use with the
<code>MMS</code> utility. From the source
-directory, use either:
-
-<pre class="example"> $ @[.VMS]VMSBUILD.COM
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> $ MMS/DESCRIPTION=[.VMS]DESCRIP.MMS GAWK
-</pre>
- <p>Depending upon which C compiler you are using, follow one of the sets
-of instructions in this table:
-
- <dl>
-<dt>VAX C V3.x<dd>Use either <samp><span
class="file">vmsbuild.com</span></samp> or <samp><span
class="file">descrip.mms</span></samp> as is. These use
-<code>CC/OPTIMIZE=NOLINE</code>, which is essential for Version 3.0.
-
- <br><dt>VAX C V2.x<dd>You must have Version 2.3 or 2.4; older ones won't
work. Edit either
-<samp><span class="file">vmsbuild.com</span></samp> or <samp><span
class="file">descrip.mms</span></samp> according to the comments in them.
-For <samp><span class="file">vmsbuild.com</span></samp>, this just entails
removing two `<samp><span class="samp">!</span></samp>' delimiters.
-Also edit <samp><span class="file">config.h</span></samp> (which is a copy of
file <samp><span class="file">[.config]vms-conf.h</span></samp>)
-and comment out or delete the two lines `<samp><span class="samp">#define
__STDC__ 0</span></samp>' and
-`<samp><span class="samp">#define VAXC_BUILTINS</span></samp>' near the end.
-
- <br><dt>GNU C<dd>Edit <samp><span class="file">vmsbuild.com</span></samp>
or <samp><span class="file">descrip.mms</span></samp>; the changes are different
-from those for VAX C V2.x but equally straightforward. No changes to
-<samp><span class="file">config.h</span></samp> are needed.
-
- <br><dt>DEC C<dd>Edit <samp><span class="file">vmsbuild.com</span></samp>
or <samp><span class="file">descrip.mms</span></samp> according to their
comments.
-No changes to <samp><span class="file">config.h</span></samp> are needed.
-</dl>
-
- <p><samp><span class="command">gawk</span></samp> has been tested under
VAX/VMS 5.5-1 using VAX C V3.2, and
-GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up.
-
-<div class="node">
-<p><hr>
-<a name="VMS-Installation-Details"></a>Next: <a rel="next" accesskey="n"
href="#VMS-Running">VMS Running</a>,
-Previous: <a rel="previous" accesskey="p" href="#VMS-Compilation">VMS
Compilation</a>,
-Up: <a rel="up" accesskey="u" href="#VMS-Installation">VMS
Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.2 Installing <samp><span
class="command">gawk</span></samp> on VMS</h5>
-
-<p>To install <samp><span class="command">gawk</span></samp>, all you need is
a “foreign” command, which is
-a <code>DCL</code> symbol whose value begins with a dollar sign. For example:
-
-<pre class="example"> $ GAWK :== $disk1:[gnubin]GAWK
-</pre>
- <p class="noindent">Substitute the actual location of <samp><span
class="command">gawk.exe</span></samp> for
-`<samp><span class="samp">$disk1:[gnubin]</span></samp>'. The symbol should be
placed in the
-<samp><span class="file">login.com</span></samp> of any user who wants to run
<samp><span class="command">gawk</span></samp>,
-so that it is defined every time the user logs on.
-Alternatively, the symbol may be placed in the system-wide
-<samp><span class="file">sylogin.com</span></samp> procedure, which allows all
users
-to run <samp><span class="command">gawk</span></samp>.
-
- <p>Optionally, the help entry can be loaded into a VMS help library:
-
-<pre class="example"> $ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP
-</pre>
- <p class="noindent">(You may want to substitute a site-specific help
library rather than
-the standard VMS library `<samp><span class="samp">HELPLIB</span></samp>'.)
After loading the help text,
-the command:
-
-<pre class="example"> $ HELP GAWK
-</pre>
- <p class="noindent">provides information about both the <samp><span
class="command">gawk</span></samp> implementation and the
-<samp><span class="command">awk</span></samp> programming language.
-
- <p>The logical name `<samp><span class="samp">AWK_LIBRARY</span></samp>'
can designate a default location
-for <samp><span class="command">awk</span></samp> program files. For the
<samp><span class="option">-f</span></samp> option, if the specified
-file name has no device or directory path information in it, <samp><span
class="command">gawk</span></samp>
-looks in the current directory first, then in the directory specified
-by the translation of `<samp><span class="samp">AWK_LIBRARY</span></samp>' if
the file is not found.
-If, after searching in both directories, the file still is not found,
-<samp><span class="command">gawk</span></samp> appends the suffix `<samp><span
class="samp">.awk</span></samp>' to the filename and retries
-the file search. If `<samp><span class="samp">AWK_LIBRARY</span></samp>' is
not defined, that
-portion of the file search fails benignly.
-
-<div class="node">
-<p><hr>
-<a name="VMS-Running"></a>Next: <a rel="next" accesskey="n"
href="#VMS-POSIX">VMS POSIX</a>,
-Previous: <a rel="previous" accesskey="p"
href="#VMS-Installation-Details">VMS Installation Details</a>,
-Up: <a rel="up" accesskey="u" href="#VMS-Installation">VMS
Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.3 Running <samp><span
class="command">gawk</span></samp> on VMS</h5>
-
-<p>Command-line parsing and quoting conventions are significantly different
-on VMS, so examples in this Web page or from other sources often need minor
-changes. They <em>are</em> minor though, and all <samp><span
class="command">awk</span></samp> programs
-should run correctly.
-
- <p>Here are a couple of trivial tests:
-
-<pre class="example"> $ gawk -- "BEGIN {print ""Hello, World!""}"
- $ gawk -"W" version
- ! could also be -"W version" or "-W version"
-</pre>
- <p class="noindent">Note that uppercase and mixed-case text must be quoted.
-
- <p>The VMS port of <samp><span class="command">gawk</span></samp> includes
a <code>DCL</code>-style interface in addition
-to the original shell-style interface (see the help entry for details).
-One side effect of dual command-line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
-becomes ambiguous. To work around this, the normally optional <samp><span
class="option">--</span></samp>
-flag is required to force Unix style rather than <code>DCL</code> parsing. If
any
-other dash-type options (or multiple parameters such as data files to
-process) are present, there is no ambiguity and <samp><span
class="option">--</span></samp> can be omitted.
-
-<!-- @cindex directory search -->
-<!-- @cindex path, search -->
-<p><a name="index-search-paths-1913"></a><a
name="index-search-paths_002c-for-source-files-1914"></a>The default search
path, when looking for <samp><span class="command">awk</span></samp> program
files specified
-by the <samp><span class="option">-f</span></samp> option, is
<code>"SYS$DISK:[],AWK_LIBRARY:"</code>. The logical
-name `<samp><span class="samp">AWKPATH</span></samp>' can be used to override
this default. The format
-of `<samp><span class="samp">AWKPATH</span></samp>' is a comma-separated list
of directory specifications.
-When defining it, the value should be quoted so that it retains a single
-translation and not a multitranslation <code>RMS</code> searchlist.
-
-<div class="node">
-<p><hr>
-<a name="VMS-POSIX"></a>Previous: <a rel="previous" accesskey="p"
href="#VMS-Running">VMS Running</a>,
-Up: <a rel="up" accesskey="u" href="#VMS-Installation">VMS
Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.4 Building and Using <samp><span
class="command">gawk</span></samp> on VMS POSIX</h5>
-
-<p>Ignore the instructions above, although <samp><span
class="file">vms/gawk.hlp</span></samp> should still
-be made available in a help library. The source tree should be unpacked
-into a container file subsystem rather than into the ordinary VMS filesystem.
-Make sure that the two scripts, <samp><span
class="file">configure</span></samp> and
-<samp><span class="file">vms/posix-cc.sh</span></samp>, are executable; use
`<samp><span class="samp">chmod +x</span></samp>' on them if
-necessary. Then execute the following two commands:
-
-<pre class="example"> psx> CC=vms/posix-cc.sh configure
- psx> make CC=c89 gawk
-</pre>
- <p class="noindent">The first command constructs files <samp><span
class="file">config.h</span></samp> and <samp><span
class="file">Makefile</span></samp> out
-of templates, using a script to make the C compiler fit <samp><span
class="command">configure</span></samp>'s
-expectations. The second command compiles and links <samp><span
class="command">gawk</span></samp> using
-the C compiler directly; ignore any warnings from <samp><span
class="command">make</span></samp> about being
-unable to redefine <code>CC</code>. <samp><span
class="command">configure</span></samp> takes a very long
-time to execute, but at least it provides incremental feedback as it runs.
-
- <p>This has been tested with VAX/VMS V6.2, VMS POSIX V2.0, and DEC C V5.2.
-
- <p>Once built, <samp><span class="command">gawk</span></samp> works like
any other shell utility. Unlike
-the normal VMS port of <samp><span class="command">gawk</span></samp>, no
special command-line manipulation is
-needed in the VMS POSIX environment.
-
-<div class="node">
-<p><hr>
-<a name="Unsupported"></a>Next: <a rel="next" accesskey="n"
href="#Bugs">Bugs</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Non_002dUnix-Installation">Non-Unix Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Installation">Installation</a>
-<br>
-</div>
-
-<h3 class="appendixsec">B.4 Unsupported Operating System Ports</h3>
-
-<p>This sections describes systems for which
-the <samp><span class="command">gawk</span></samp> port is no longer supported.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Atari-Installation">Atari Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on the Atari ST.
-<li><a accesskey="2" href="#Tandem-Installation">Tandem Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on a Tandem.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Atari-Installation"></a>Next: <a rel="next" accesskey="n"
href="#Tandem-Installation">Tandem Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Unsupported">Unsupported</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.4.1 Installing <samp><span
class="command">gawk</span></samp> on the Atari ST</h4>
-
-<p>The Atari port is no longer supported. It is
-included for those who might want to use it but it is no longer being
-actively maintained.
-
-<!-- based on material from Michal Jaegermann <address@hidden> -->
-<p><a name="index-atari-1915"></a><a
name="index-installation_002c-atari-1916"></a>There are no substantial
differences when installing <samp><span class="command">gawk</span></samp> on
-various Atari models. Compiled <samp><span class="command">gawk</span></samp>
executables do not require
-a large amount of memory with most <samp><span
class="command">awk</span></samp> programs, and should run on all
-Motorola processor-based models (called further ST, even if that is not
-exactly right).
-
- <p>In order to use <samp><span class="command">gawk</span></samp>, you need
to have a shell, either text or
-graphics, that does not map all the characters of a command line to
-uppercase. Maintaining case distinction in option flags is very
-important (see <a href="#Options">Options</a>).
-These days this is the default and it may only be a problem for some
-very old machines. If your system does not preserve the case of option
-flags, you need to upgrade your tools. Support for I/O
-redirection is necessary to make it easy to import <samp><span
class="command">awk</span></samp> programs
-from other environments. Pipes are nice to have but not vital.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Atari-Compiling">Atari Compiling</a>:
Compiling <samp><span class="command">gawk</span></samp> on Atari.
-<li><a accesskey="2" href="#Atari-Using">Atari Using</a>:
Running <samp><span class="command">gawk</span></samp> on Atari.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Atari-Compiling"></a>Next: <a rel="next" accesskey="n"
href="#Atari-Using">Atari Using</a>,
-Up: <a rel="up" accesskey="u" href="#Atari-Installation">Atari
Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.4.1.1 Compiling <samp><span
class="command">gawk</span></samp> on the Atari ST</h5>
-
-<p>A proper compilation of <samp><span class="command">gawk</span></samp>
sources when <code>sizeof(int)</code>
-differs from <code>sizeof(void *)</code> requires an ISO C compiler. An initial
-port was done with <samp><span class="command">gcc</span></samp>. You may
actually prefer executables
-where <code>int</code>s are four bytes wide but the other variant works as
well.
-
- <p>You may need quite a bit of memory when trying to recompile the
<samp><span class="command">gawk</span></samp>
-sources, as some source files (<samp><span class="file">regex.c</span></samp>
in particular) are quite
-big. If you run out of memory compiling such a file, try reducing the
-optimization level for this particular file, which may help.
-
- <p><a name="index-Linux-1917"></a><a
name="index-GNU_002fLinux-1918"></a>With a reasonable shell (<samp><span
class="command">bash</span></samp> will do), you have a pretty good chance
-that the <samp><span class="command">configure</span></samp> utility will
succeed, and in particular if
-you run GNU/Linux, MiNT or a similar operating system. Otherwise
-sample versions of <samp><span class="file">config.h</span></samp> and
<samp><span class="file">Makefile.st</span></samp> are given in the
-<samp><span class="file">atari</span></samp> subdirectory and can be edited
and copied to the
-corresponding files in the main source directory. Even if
-<samp><span class="command">configure</span></samp> produces something, it
might be advisable to compare
-its results with the sample versions and possibly make adjustments.
-
- <p>Some <samp><span class="command">gawk</span></samp> source code
fragments depend on a preprocessor define
-`<samp><span class="samp">atarist</span></samp>'. This basically assumes the
TOS environment with <samp><span class="command">gcc</span></samp>.
-Modify these sections as appropriate if they are not right for your
-environment. Also see the remarks about <samp><span
class="env">AWKPATH</span></samp> and <code>envsep</code> in
-<a href="#Atari-Using">Atari Using</a>.
-
- <p>As shipped, the sample <samp><span class="file">config.h</span></samp>
claims that the <code>system</code>
-function is missing from the libraries, which is not true, and an
-alternative implementation of this function is provided in
-<samp><span class="file">unsupported/atari/system.c</span></samp>.
-Depending upon your particular combination of
-shell and operating system, you might want to change the file to indicate
-that <code>system</code> is available.
-
-<div class="node">
-<p><hr>
-<a name="Atari-Using"></a>Previous: <a rel="previous" accesskey="p"
href="#Atari-Compiling">Atari Compiling</a>,
-Up: <a rel="up" accesskey="u" href="#Atari-Installation">Atari
Installation</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">B.4.1.2 Running <samp><span
class="command">gawk</span></samp> on the Atari ST</h5>
-
-<p>An executable version of <samp><span class="command">gawk</span></samp>
should be placed, as usual,
-anywhere in your <samp><span class="env">PATH</span></samp> where your shell
can find it.
-
- <p>While executing, the Atari version of <samp><span
class="command">gawk</span></samp> creates a number of temporary files. When
-using <samp><span class="command">gcc</span></samp> libraries for TOS,
<samp><span class="command">gawk</span></samp> looks for either of
-the environment variables, <samp><span class="env">TEMP</span></samp> or
<samp><span class="env">TMPDIR</span></samp>, in that order.
-If either one is found, its value is assumed to be a directory for
-temporary files. This directory must exist, and if you can spare the
-memory, it is a good idea to put it on a RAM drive. If neither
-<samp><span class="env">TEMP</span></samp> nor <samp><span
class="env">TMPDIR</span></samp> are found, then <samp><span
class="command">gawk</span></samp> uses the
-current directory for its temporary files.
-
- <p>The ST version of <samp><span class="command">gawk</span></samp>
searches for its program files, as described in
-<a href="#AWKPATH-Variable">AWKPATH Variable</a>.
-The default value for the <samp><span class="env">AWKPATH</span></samp>
variable is taken from
-<code>DEFPATH</code> defined in <samp><span
class="file">Makefile</span></samp>. The sample <samp><span
class="command">gcc</span></samp>/TOS
-<samp><span class="file">Makefile</span></samp> for the ST in the distribution
sets <code>DEFPATH</code> to
-<code>".,c:\lib\awk,c:\gnu\lib\awk"<!-- /@w --></code>. The search path can be
-modified by explicitly setting <samp><span class="env">AWKPATH</span></samp>
to whatever you want.
-Note that colons cannot be used on the ST to separate elements in the
-<samp><span class="env">AWKPATH</span></samp> variable, since they have
another reserved meaning.
-Instead, you must use a comma to separate elements in the path. When
-recompiling, the separating character can be modified by initializing
-the <code>envsep</code> variable in <samp><span
class="file">unsupported/atari/gawkmisc.atr</span></samp> to another
-value.
-
- <p>Although <samp><span class="command">awk</span></samp> allows great
flexibility in doing I/O redirections
-from within a program, this facility should be used with care on the ST
-running under TOS. In some circumstances, the OS routines for file-handle
-pool processing lose track of certain events, causing the
-computer to crash and requiring a reboot. Often a warm reboot is
-sufficient. Fortunately, this happens infrequently and in rather
-esoteric situations. In particular, avoid having one part of an
-<samp><span class="command">awk</span></samp> program using <code>print</code>
statements explicitly redirected
-to <samp><span class="file">/dev/stdout</span></samp>, while other
<code>print</code> statements use the
-default standard output, and a calling shell has redirected standard
-output to a file.
-<!-- 10/2000: Is this still true, now that gawk does /dev/stdout internally?
-->
-
- <p>When <samp><span class="command">gawk</span></samp> is compiled with the
ST version of <samp><span class="command">gcc</span></samp> and its
-usual libraries, it accepts both `<samp><span class="samp">/</span></samp>'
and `<samp><span class="samp">\</span></samp>' as path separators.
-While this is convenient, it should be remembered that this removes one
-technically valid character (`<samp><span class="samp">/</span></samp>') from
your file name.
-It may also create problems for external programs called via the
<code>system</code>
-function, which may not support this convention. Whenever it is possible
-that a file created by <samp><span class="command">gawk</span></samp> will be
used by some other program,
-use only backslashes. Also remember that in <samp><span
class="command">awk</span></samp>, backslashes in
-strings have to be doubled in order to get literal backslashes
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-
-<div class="node">
-<p><hr>
-<a name="Tandem-Installation"></a>Previous: <a rel="previous"
accesskey="p" href="#Atari-Installation">Atari Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Unsupported">Unsupported</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">B.4.2 Installing <samp><span
class="command">gawk</span></samp> on a Tandem</h4>
-
-<p><a name="index-tandem-1919"></a><a
name="index-installation_002c-tandem-1920"></a>
-The Tandem port is only minimally supported.
-The port's contributor no longer has access to a Tandem system.
-
-<!-- This section based on README.Tandem by Stephen Davies (address@hidden) -->
-<p>The Tandem port was done on a Cyclone machine running D20.
-The port is pretty clean and all facilities seem to work except for
-the I/O piping facilities
-(see <a href="#Getline_002fPipe">Getline/Pipe</a>,
-<a href="#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>,
-and
-<a href="#Redirection">Redirection</a>),
-which is just too foreign a concept for Tandem.
-
- <p>To build a Tandem executable from source, download all of the files so
-that the file names on the Tandem box conform to the restrictions of D20.
-For example, <samp><span class="file">array.c</span></samp> becomes
<samp><span class="file">ARRAYC</span></samp>, and <samp><span
class="file">awk.h</span></samp>
-becomes <samp><span class="file">AWKH</span></samp>. The totally
Tandem-specific files are in the
-<samp><span class="file">tandem</span></samp> “subvolume”
(<samp><span class="file">unsupported/tandem</span></samp> in the <samp><span
class="command">gawk</span></samp>
-distribution) and should be copied to the main source directory before
-building <samp><span class="command">gawk</span></samp>.
-
- <p>The file <samp><span class="file">compit</span></samp> can then be used
to compile and bind an executable.
-Alas, there is no <samp><span class="command">configure</span></samp> or
<samp><span class="command">make</span></samp>.
-
- <p>Usage is the same as for Unix, except that D20 requires all `<samp><span
class="samp">{</span></samp>' and
-`<samp><span class="samp">}</span></samp>' characters to be escaped with
`<samp><span class="samp">~</span></samp>' on the command line
-(but <em>not</em> in script files). Also, the standard Tandem syntax for
-`<samp><span class="samp">/in filename,out filename/</span></samp>' must be
used instead of the usual
-Unix `<samp><span class="samp"><</span></samp>' and `<samp><span
class="samp">></span></samp>' for file redirection. (Redirection options
-on <code>getline</code>, <code>print</code> etc., are supported.)
-
- <p>The `<samp><span class="samp">-mr </span><var>val</var></samp>' option
-(see <a href="#Options">Options</a>)
-has been “stolen” to enable Tandem users to process fixed-length
-records with no “end-of-line” character. That is, `<samp><span
class="samp">-mr 74</span></samp>' tells
-<samp><span class="command">gawk</span></samp> to read the input file as fixed
74-byte records.
-<!-- ENDOFRANGE opgawx -->
-<!-- ENDOFRANGE pcgawon -->
-
-<div class="node">
-<p><hr>
-<a name="Bugs"></a>Next: <a rel="next" accesskey="n"
href="#Other-Versions">Other Versions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Unsupported">Unsupported</a>,
-Up: <a rel="up" accesskey="u" href="#Installation">Installation</a>
-<br>
-</div>
-
-<h3 class="appendixsec">B.5 Reporting Problems and Bugs</h3>
-
-<p><a name="index-archeologists-1921"></a><blockquote>
-<i>There is nothing more dangerous than a bored archeologist.</i><br>
-The Hitchhiker's Guide to the Galaxy
-</blockquote>
- <!-- the radio show, not the book. :-) -->
-
-<!-- STARTOFRANGE dbugg -->
-<p><a
name="index-debugging-_0040command_007bgawk_007d_002c-bug-reports-1922"></a><!--
STARTOFRANGE tblgawb -->
-<a
name="index-troubleshooting_002c-_0040command_007bgawk_007d_002c-bug-reports-1923"></a>If
you have problems with <samp><span class="command">gawk</span></samp> or think
that you have found a bug,
-please report it to the developers; we cannot promise to do anything
-but we might well want to fix it.
-
- <p>Before reporting a bug, make sure you have actually found a real bug.
-Carefully reread the documentation and see if it really says you can do
-what you're trying to do. If it's not clear whether you should be able
-to do something or not, report that too; it's a bug in the documentation!
-
- <p>Before reporting a bug or trying to fix it yourself, try to isolate it
-to the smallest possible <samp><span class="command">awk</span></samp> program
and input data file that
-reproduces the problem. Then send us the program and data file,
-some idea of what kind of Unix system you're using,
-the compiler you used to compile <samp><span
class="command">gawk</span></samp>, and the exact results
-<samp><span class="command">gawk</span></samp> gave you. Also say what you
expected to occur; this helps
-us decide whether the problem is really in the documentation.
-
- <p><a
name="index-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-bug-reporting-address-1924"></a><a
name="index-email-address-for-bug-reports_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1925"></a><a
name="index-bug-reports_002c-email-address_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1926"></a>Once
you have a precise problem, send email to <a
href="mailto:address@hidden">address@hidden</a>.
-
- <p><a name="index-Robbins_002c-Arnold-1927"></a>Please include the version
number of <samp><span class="command">gawk</span></samp> you are using.
-You can get this information with the command `<samp><span class="samp">gawk
--version</span></samp>'.
-Using this address automatically sends a carbon copy of your
-mail to me. If necessary, I can be reached directly at
-<a href="mailto:address@hidden">address@hidden</a>. The bug reporting address
is preferred since the
-email list is archived at the GNU Project.
-<em>All email should be in English, since that is my native language.</em>
-
- <p><a
name="index-_0040code_007bcomp_002elang_002eawk_007d-newsgroup-1928"></a><strong>Caution:</strong>
Do <em>not</em> try to report bugs in <samp><span
class="command">gawk</span></samp> by
-posting to the Usenet/Internet newsgroup <code>comp.lang.awk</code>.
-While the <samp><span class="command">gawk</span></samp> developers do
occasionally read this newsgroup,
-there is no guarantee that we will see your posting. The steps described
-above are the official recognized ways for reporting bugs.
-
- <p>Non-bug suggestions are always welcome as well. If you have questions
-about things that are unclear in the documentation or are just obscure
-features, ask me; I will try to help you out, although I
-may not have the time to fix the problem. You can send me electronic
-mail at the Internet address noted previously.
-
- <p>If you find bugs in one of the non-Unix ports of <samp><span
class="command">gawk</span></samp>, please send
-an electronic mail message to the person who maintains that port. They
-are named in the following list, as well as in the <samp><span
class="file">README</span></samp> file in the <samp><span
class="command">gawk</span></samp>
-distribution. Information in the <samp><span
class="file">README</span></samp> file should be considered
-authoritative if it conflicts with this Web page.
-
- <p>The people maintaining the non-Unix ports of <samp><span
class="command">gawk</span></samp> are
-as follows:
-
- <p><table summary=""><a name="index-Fish_002c-Fred-1929"></a><tr
align="left"><td valign="top">Amiga </td><td valign="top">Fred Fish, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Brown_002c-Martin-1930"></a><br></td></tr><tr
align="left"><td valign="top">BeOS </td><td valign="top">Martin Brown, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Deifik_002c-Scott-1931"></a><a
name="index-Hankerson_002c-Darrel-1932"></a><br></td></tr><tr align="left"><td
valign="top">MS-DOS </td><td valign="top">Scott Deifik, <a
href="mailto:address@hidden">address@hidden</a> and
-Darrel Hankerson, <a href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Grigera_002c-Juan-1933"></a><br></td></tr><tr
align="left"><td valign="top">MS-Windows </td><td valign="top">Juan Grigera, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><br></td></tr><tr align="left"><td valign="top">OS/2 </td><td
valign="top">The Unix for OS/2 team, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Davies_002c-Stephen-1934"></a><br></td></tr><tr
align="left"><td valign="top">Tandem </td><td valign="top">Stephen Davies, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Rankin_002c-Pat-1935"></a><br></td></tr><tr align="left"><td
valign="top">VMS </td><td valign="top">Pat Rankin, <a
href="mailto:address@hidden">address@hidden</a>.
- <br></td></tr></table>
-
- <p>If your bug is also reproducible under Unix, please send a copy of your
-report to the <a href="mailto:address@hidden">address@hidden</a> email list as
well.
-<!-- ENDOFRANGE dbugg -->
-<!-- ENDOFRANGE tblgawb -->
-
-<div class="node">
-<p><hr>
-<a name="Other-Versions"></a>Previous: <a rel="previous" accesskey="p"
href="#Bugs">Bugs</a>,
-Up: <a rel="up" accesskey="u" href="#Installation">Installation</a>
-<br>
-</div>
-
-<h3 class="appendixsec">B.6 Other Freely Available <samp><span
class="command">awk</span></samp> Implementations</h3>
-
-<!-- STARTOFRANGE awkim -->
-<p><a name="index-_0040command_007bawk_007d_002c-implementations-1936"></a><a
name="index-Brennan_002c-Michael-1937"></a><blockquote>
-<i>It's kind of fun to put comments like this in your awk code.</i><br>
- <code>// Do C++ comments work? answer: yes! of course</code><br>
-Michael Brennan
-</blockquote>
-
- <p>There are three other freely available <samp><span
class="command">awk</span></samp> implementations.
-This section briefly describes where to get them:
-
-
-<a name="index-Kernighan_002c-Brian-1938"></a>
-<a
name="index-source-code_002c-Bell-Laboratories-_0040command_007bawk_007d-1939"></a>
-<dl><dt>Unix <samp><span class="command">awk</span></samp><dd>Brian Kernighan
has made his implementation of
-<samp><span class="command">awk</span></samp> freely available.
-You can retrieve this version via the World Wide Web from
-his home page.<a rel="footnote" href="#fn-69" name="fnd-69"><sup>69</sup></a>
-It is available in several archive formats:
-
- <dl>
-<dt>Shell archive<dd><a
href="http://cm.bell-labs.com/who/bwk/awk.shar">http://cm.bell-labs.com/who/bwk/awk.shar</a>
-
- <br><dt>Compressed <samp><span class="command">tar</span></samp>
file<dd><a
href="http://cm.bell-labs.com/who/bwk/awk.tar.gz">http://cm.bell-labs.com/who/bwk/awk.tar.gz</a>
-
- <br><dt>Zip file<dd><a
href="http://cm.bell-labs.com/who/bwk/awk.zip">http://cm.bell-labs.com/who/bwk/awk.zip</a>
-</dl>
-
- <p>This version requires an ISO C (1990 standard) compiler;
-the C compiler from
-GCC (the GNU Compiler Collection)
-works quite nicely.
-
- <p>See <a href="#BTL">BTL</a>,
-for a list of extensions in this <samp><span class="command">awk</span></samp>
that are not in POSIX <samp><span class="command">awk</span></samp>.
-
- <p><a name="index-Brennan_002c-Michael-1940"></a><a
name="index-_0040command_007bmawk_007d-program-1941"></a><a
name="index-source-code_002c-_0040command_007bmawk_007d-1942"></a><br><dt><samp><span
class="command">mawk</span></samp><dd>Michael Brennan has written an
independent implementation of <samp><span class="command">awk</span></samp>,
-called <samp><span class="command">mawk</span></samp>. It is available under
the GPL
-(see <a href="#Copying">Copying</a>),
-just as <samp><span class="command">gawk</span></samp> is.
-
- <p>You can get it via anonymous <samp><span
class="command">ftp</span></samp> to the host
-<code>ftp.whidbey.net<!-- /@w --></code>. Change directory to <samp><span
class="file">/pub/brennan</span></samp>.
-Use “binary” or “image” mode, and retrieve <samp><span
class="file">mawk1.3.3.tar.gz</span></samp>
-(or the latest version that is there).
-
- <p><samp><span class="command">gunzip</span></samp> may be used to
decompress this file. Installation
-is similar to <samp><span class="command">gawk</span></samp>'s
-(see <a href="#Unix-Installation">Unix Installation</a>).
-
- <p><a
name="index-extensions_002c-_0040command_007bmawk_007d-1943"></a><samp><span
class="command">mawk</span></samp> has the following extensions that are not in
POSIX <samp><span class="command">awk</span></samp>:
-
- <ul>
-<li>The <code>fflush</code> built-in function for flushing buffered output
-(see <a href="#I_002fO-Functions">I/O Functions</a>).
-
- <li>The `<samp><span class="samp">**</span></samp>' and `<samp><span
class="samp">**=</span></samp>' operators
-(see <a href="#Arithmetic-Ops">Arithmetic Ops</a>
-and also see
-<a href="#Assignment-Ops">Assignment Ops</a>).
-
- <li>The use of <code>func</code> as an abbreviation for
<code>function</code>
-(see <a href="#Definition-Syntax">Definition Syntax</a>).
-
- <li>The `<samp><span class="samp">\x</span></samp>' escape sequence
-(see <a href="#Escape-Sequences">Escape Sequences</a>).
-
- <li>The <samp><span class="file">/dev/stdout</span></samp>, and
<samp><span class="file">/dev/stderr</span></samp>
-special files
-(see <a href="#Special-Files">Special Files</a>).
-Use <code>"-"</code> instead of <code>"/dev/stdin"</code> with <samp><span
class="command">mawk</span></samp>.
-
- <li>The ability for <code>FS</code> and for the third
-argument to <code>split</code> to be null strings
-(see <a href="#Single-Character-Fields">Single Character Fields</a>).
-
- <li>The ability to delete all of an array at once with `<samp><span
class="samp">delete </span><var>array</var></samp>'
-(see <a href="#Delete">Delete</a>).
-
- <li>The ability for <code>RS</code> to be a regexp
-(see <a href="#Records">Records</a>).
-
- <li>The <code>BINMODE</code> special variable for non-Unix operating
systems
-(see <a href="#PC-Using">PC Using</a>).
-</ul>
-
- <p>The next version of <samp><span class="command">mawk</span></samp>
will support <code>nextfile</code>.
-
- <p><a name="index-Sumner_002c-Andrew-1944"></a><a
name="index-_0040command_007bawka_007d-compiler-for-_0040command_007bawk_007d-1945"></a><a
name="index-source-code_002c-_0040command_007bawka_007d-1946"></a><br><dt><samp><span
class="command">awka</span></samp><dd>Written by Andrew Sumner,
-<samp><span class="command">awka</span></samp> translates <samp><span
class="command">awk</span></samp> programs into C, compiles them,
-and links them with a library of functions that provides the core
-<samp><span class="command">awk</span></samp> functionality.
-It also has a number of extensions.
-
- <p>The <samp><span class="command">awk</span></samp> translator is
released under the GPL, and the library
-is under the LGPL.
-
- <p>To get <samp><span class="command">awka</span></samp>, go to <a
href="http://awka.sourceforge.net">http://awka.sourceforge.net</a>.
-You can reach Andrew Sumner at <a
href="mailto:address@hidden">address@hidden</a>.
-
- <p><a name="index-Beebe_002c-Nelson-H_002eF_002e_0040_003a-1947"></a><a
name="index-_0040command_007bpawk_007d-profiling-Bell-Labs-_0040command_007bawk_007d-1948"></a><br><dt><samp><span
class="command">pawk</span></samp><dd>Nelson H.F. Beebe at the University of
Utah has modified
-the Bell Labs <samp><span class="command">awk</span></samp> to provide timing
and profiling information.
-It is different from <samp><span class="command">pgawk</span></samp>
-(see <a href="#Profiling">Profiling</a>),
-in that it uses CPU-based profiling, not line-count
-profiling. You may find it at either
-<a
href="ftp://ftp.math.utah.edu/pub/pawk/pawk-20020210.tar.gz">ftp://ftp.math.utah.edu/pub/pawk/pawk-20020210.tar.gz</a>
-or
-<a
href="http://www.math.utah.edu/pub/pawk/pawk-20020210.tar.gz">http://www.math.utah.edu/pub/pawk/pawk-20020210.tar.gz</a>.
-
- </dl>
- <!-- ENDOFRANGE gligawk -->
-<!-- ENDOFRANGE ingawk -->
-<!-- ENDOFRANGE awkim -->
-
-<div class="node">
-<p><hr>
-<a name="Notes"></a>Next: <a rel="next" accesskey="n"
href="#Basic-Concepts">Basic Concepts</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Installation">Installation</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="appendix">Appendix C Implementation Notes</h2>
-
-<!-- STARTOFRANGE gawii -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues-1949"></a><!--
STARTOFRANGE impis -->
-<a name="index-implementation-issues_002c-_0040command_007bgawk_007d-1950"></a>
-This appendix contains information mainly of interest to implementors and
-maintainers of <samp><span class="command">gawk</span></samp>. Everything in
it applies specifically to
-<samp><span class="command">gawk</span></samp> and not to other
implementations.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Compatibility-Mode">Compatibility Mode</a>:
How to disable certain <samp><span class="command">gawk</span></samp>
- extensions.
-<li><a accesskey="2" href="#Additions">Additions</a>:
Making Additions To <samp><span class="command">gawk</span></samp>.
-<li><a accesskey="3" href="#Dynamic-Extensions">Dynamic Extensions</a>:
Adding new built-in functions to
- <samp><span
class="command">gawk</span></samp>.
-<li><a accesskey="4" href="#Future-Extensions">Future Extensions</a>:
New features that may be implemented one day.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Compatibility-Mode"></a>Next: <a rel="next" accesskey="n"
href="#Additions">Additions</a>,
-Up: <a rel="up" accesskey="u" href="#Notes">Notes</a>
-<br>
-</div>
-
-<h3 class="appendixsec">C.1 Downward Compatibility and Debugging</h3>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-downward-compatibility-1951"></a><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-debugging-1952"></a><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d-1953"></a><a
name="index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-debugging-1954"></a>
-See <a href="#POSIX_002fGNU">POSIX/GNU</a>,
-for a summary of the GNU extensions to the <samp><span
class="command">awk</span></samp> language and program.
-All of these features can be turned off by invoking <samp><span
class="command">gawk</span></samp> with the
-<samp><span class="option">--traditional</span></samp> option or with the
<samp><span class="option">--posix</span></samp> option.
-
- <p>If <samp><span class="command">gawk</span></samp> is compiled for
debugging with `<samp><span class="samp">-DDEBUG</span></samp>', then there
-is one more option available on the command line:
-
- <dl>
-<dt><code>-W parsedebug</code><dt><code>--parsedebug</code><dd>Prints out the
parse stack information as the program is being parsed.
-</dl>
-
- <p>This option is intended only for serious <samp><span
class="command">gawk</span></samp> developers
-and not for the casual user. It probably has not even been compiled into
-your version of <samp><span class="command">gawk</span></samp>, since it slows
down execution.
-
-<div class="node">
-<p><hr>
-<a name="Additions"></a>Next: <a rel="next" accesskey="n"
href="#Dynamic-Extensions">Dynamic Extensions</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Compatibility-Mode">Compatibility Mode</a>,
-Up: <a rel="up" accesskey="u" href="#Notes">Notes</a>
-<br>
-</div>
-
-<h3 class="appendixsec">C.2 Making Additions to <samp><span
class="command">gawk</span></samp></h3>
-
-<p>If you find that you want to enhance <samp><span
class="command">gawk</span></samp> in a significant
-fashion, you are perfectly free to do so. That is the point of having
-free software; the source code is available and you are free to change
-it as you want (see <a href="#Copying">Copying</a>).
-
- <p>This section discusses the ways you might want to change <samp><span
class="command">gawk</span></samp>
-as well as any considerations you should bear in mind.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Adding-Code">Adding Code</a>:
Adding code to the main body of
- <samp><span
class="command">gawk</span></samp>.
-<li><a accesskey="2" href="#New-Ports">New Ports</a>:
Porting <samp><span class="command">gawk</span></samp> to a new operating
- system.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Adding-Code"></a>Next: <a rel="next" accesskey="n"
href="#New-Ports">New Ports</a>,
-Up: <a rel="up" accesskey="u" href="#Additions">Additions</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">C.2.1 Adding New Features</h4>
-
-<!-- STARTOFRANGE adfgaw -->
-<p><a
name="index-adding_002c-features-to-_0040command_007bgawk_007d-1955"></a><!--
STARTOFRANGE fadgaw -->
-<a
name="index-features_002c-adding-to-_0040command_007bgawk_007d-1956"></a><!--
STARTOFRANGE gawadf -->
-<a
name="index-_0040command_007bgawk_007d_002c-features_002c-adding-1957"></a>You
are free to add any new features you like to <samp><span
class="command">gawk</span></samp>.
-However, if you want your changes to be incorporated into the <samp><span
class="command">gawk</span></samp>
-distribution, there are several steps that you need to take in order to
-make it possible for me to include your changes:
-
- <ol type=1 start=1>
-<li>Before building the new feature into <samp><span
class="command">gawk</span></samp> itself,
-consider writing it as an extension module
-(see <a href="#Dynamic-Extensions">Dynamic Extensions</a>).
-If that's not possible, continue with the rest of the steps in this list.
-
- <li>Get the latest version.
-It is much easier for me to integrate changes if they are relative to
-the most recent distributed version of <samp><span
class="command">gawk</span></samp>. If your version of
-<samp><span class="command">gawk</span></samp> is very old, I may not be able
to integrate them at all.
-(See <a href="#Getting">Getting</a>,
-for information on getting the latest version of <samp><span
class="command">gawk</span></samp>.)
-
- <li>Follow the <cite>GNU Coding Standards</cite>.
-This document describes how GNU software should be written. If you haven't
-read it, please do so, preferably <em>before</em> starting to modify
<samp><span class="command">gawk</span></samp>.
-(The <cite>GNU Coding Standards</cite> are available from
-the GNU Project's
-<samp><span class="command">ftp</span></samp>
-site, at
-<a
href="ftp://ftp.gnu.org/gnu/GNUinfo/standards.text">ftp://ftp.gnu.org/gnu/GNUinfo/standards.text</a>.
-An HTML version, suitable for reading with a WWW browser, is
-available at
-<a
href="http://www.gnu.org/prep/standards_toc.html">http://www.gnu.org/prep/standards_toc.html</a>.
-Texinfo, Info, and DVI versions are also available.)
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-coding-style-in-1958"></a><li>Use
the <samp><span class="command">gawk</span></samp> coding style.
-The C code for <samp><span class="command">gawk</span></samp> follows the
instructions in the
-<cite>GNU Coding Standards</cite>, with minor exceptions. The code is
formatted
-using the traditional “K&R” style, particularly as regards to
the placement
-of braces and the use of tabs. In brief, the coding rules for <samp><span
class="command">gawk</span></samp>
-are as follows:
-
- <ul>
-<li>Use ANSI/ISO style (prototype) function headers when defining functions.
-
- <li>Put the name of the function at the beginning of its own line.
-
- <li>Put the return type of the function, even if it is
<code>int</code>, on the
-line above the line with the name and arguments of the function.
-
- <li>Put spaces around parentheses used in control structures
-(<code>if</code>, <code>while</code>, <code>for</code>, <code>do</code>,
<code>switch</code>,
-and <code>return</code>).
-
- <li>Do not put spaces in front of parentheses used in function calls.
-
- <li>Put spaces around all C operators and after commas in function
calls.
-
- <li>Do not use the comma operator to produce multiple side effects,
except
-in <code>for</code> loop initialization and increment parts, and in macro
bodies.
-
- <li>Use real tabs for indenting, not spaces.
-
- <li>Use the “K&R” brace layout style.
-
- <li>Use comparisons against <code>NULL</code> and <code>'\0'</code>
in the conditions of
-<code>if</code>, <code>while</code>, and <code>for</code> statements, as well
as in the <code>case</code>s
-of <code>switch</code> statements, instead of just the
-plain pointer or character value.
-
- <li>Use the <code>TRUE</code>, <code>FALSE</code> and
<code>NULL</code> symbolic constants
-and the character constant <code>'\0'</code> where appropriate, instead of
<code>1</code>
-and <code>0</code>.
-
- <li>Use the <code>ISALPHA</code>, <code>ISDIGIT</code>, etc. macros,
instead of the
-traditional lowercase versions; these macros are better behaved for
-non-ASCII character sets.
-
- <li>Provide one-line descriptive comments for each function.
-
- <li>Do not use `<samp><span class="samp">#elif</span></samp>'. Many
older Unix C compilers cannot handle it.
-
- <li>Do not use the <code>alloca</code> function for allocating
memory off the stack.
-Its use causes more portability trouble than is worth the minor benefit of not
having
-to free the storage. Instead, use <code>malloc</code> and <code>free</code>.
-</ul>
-
- <blockquote>
-<b>NOTE:</b> If I have to reformat your code to follow the coding style used in
-<samp><span class="command">gawk</span></samp>, I may not bother to integrate
your changes at all.
-</blockquote>
-
- <li>Be prepared to sign the appropriate paperwork.
-In order for the FSF to distribute your changes, you must either place
-those changes in the public domain and submit a signed statement to that
-effect, or assign the copyright in your changes to the FSF.
-Both of these actions are easy to do and <em>many</em> people have done so
-already. If you have questions, please contact me
-(see <a href="#Bugs">Bugs</a>),
-or <a href="mailto:address@hidden">address@hidden</a>.
-
- <p><a name="index-Texinfo-1959"></a><li>Update the documentation.
-Along with your new code, please supply new sections and/or chapters
-for this Web page. If at all possible, please use real
-Texinfo, instead of just supplying unformatted ASCII text (although
-even that is better than no documentation at all).
-Conventions to be followed in <cite>GAWK: Effective AWK Programming</cite> are
provided
-after the `<samp><span class="samp">@bye</span></samp>' at the end of the
Texinfo source file.
-If possible, please update the <samp><span class="command">man</span></samp>
page as well.
-
- <p>You will also have to sign paperwork for your documentation changes.
-
- <li>Submit changes as context diffs or unified diffs.
-Use `<samp><span class="samp">diff -c -r -N</span></samp>' or `<samp><span
class="samp">diff -u -r -N</span></samp>' to compare
-the original <samp><span class="command">gawk</span></samp> source tree with
your version.
-(I find context diffs to be more readable but unified diffs are
-more compact.)
-I recommend using the GNU version of <samp><span
class="command">diff</span></samp>.
-Send the output produced by either run of <samp><span
class="command">diff</span></samp> to me when you
-submit your changes.
-(See <a href="#Bugs">Bugs</a>, for the electronic mail
-information.)
-
- <p>Using this format makes it easy for me to apply your changes to the
-master version of the <samp><span class="command">gawk</span></samp> source
code (using <code>patch</code>).
-If I have to apply the changes manually, using a text editor, I may
-not do so, particularly if there are lots of changes.
-
- <li>Include an entry for the <samp><span
class="file">ChangeLog</span></samp> file with your submission.
-This helps further minimize the amount of work I have to do,
-making it easier for me to accept patches.
- </ol>
-
- <p>Although this sounds like a lot of work, please remember that while you
-may write the new code, I have to maintain it and support it. If it
-isn't possible for me to do that with a minimum of extra work, then I
-probably will not.
-<!-- ENDOFRANGE adfgaw -->
-<!-- ENDOFRANGE gawadf -->
-<!-- ENDOFRANGE fadgaw -->
-
-<div class="node">
-<p><hr>
-<a name="New-Ports"></a>Previous: <a rel="previous" accesskey="p"
href="#Adding-Code">Adding Code</a>,
-Up: <a rel="up" accesskey="u" href="#Additions">Additions</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">C.2.2 Porting <samp><span
class="command">gawk</span></samp> to a New Operating System</h4>
-
-<p><a name="index-portability_002c-_0040command_007bgawk_007d-1960"></a><a
name="index-operating-systems_002c-porting-_0040command_007bgawk_007d-to-1961"></a>
-<a name="index-porting-_0040command_007bgawk_007d-1962"></a>If you want to
port <samp><span class="command">gawk</span></samp> to a new operating system,
there are
-several steps:
-
- <ol type=1 start=1>
-<li>Follow the guidelines in
-the previous section
-concerning coding style, submission of diffs, and so on.
-
- <li>When doing a port, bear in mind that your code must coexist peacefully
-with the rest of <samp><span class="command">gawk</span></samp> and the other
ports. Avoid gratuitous
-changes to the system-independent parts of the code. If at all possible,
-avoid sprinkling `<samp><span class="samp">#ifdef</span></samp>'s just for
your port throughout the
-code.
-
- <p>If the changes needed for a particular system affect too much of the
-code, I probably will not accept them. In such a case, you can, of course,
-distribute your changes on your own, as long as you comply
-with the GPL
-(see <a href="#Copying">Copying</a>).
-
- <li>A number of the files that come with <samp><span
class="command">gawk</span></samp> are maintained by other
-people at the Free Software Foundation. Thus, you should not change them
-unless it is for a very good reason; i.e., changes are not out of the
-question, but changes to these files are scrutinized extra carefully.
-The files are <samp><span class="file">getopt.h</span></samp>, <samp><span
class="file">getopt.c</span></samp>,
-<samp><span class="file">getopt1.c</span></samp>, <samp><span
class="file">regex.h</span></samp>, <samp><span
class="file">regex.c</span></samp>, <samp><span
class="file">dfa.h</span></samp>,
-<samp><span class="file">dfa.c</span></samp>, <samp><span
class="file">install-sh</span></samp>, and <samp><span
class="file">mkinstalldirs</span></samp>.
-
- <li>Be willing to continue to maintain the port.
-Non-Unix operating systems are supported by volunteers who maintain
-the code needed to compile and run <samp><span
class="command">gawk</span></samp> on their systems. If noone
-volunteers to maintain a port, it becomes unsupported and it may
-be necessary to remove it from the distribution.
-
- <li>Supply an appropriate <samp><span
class="file">gawkmisc.???</span></samp> file.
-Each port has its own <samp><span class="file">gawkmisc.???</span></samp> that
implements certain
-operating system specific functions. This is cleaner than a plethora of
-`<samp><span class="samp">#ifdef</span></samp>'s scattered throughout the
code. The <samp><span class="file">gawkmisc.c</span></samp> in
-the main source directory includes the appropriate
-<samp><span class="file">gawkmisc.???</span></samp> file from each
subdirectory.
-Be sure to update it as well.
-
- <p>Each port's <samp><span class="file">gawkmisc.???</span></samp> file
has a suffix reminiscent of the machine
-or operating system for the port—for example, <samp><span
class="file">pc/gawkmisc.pc</span></samp> and
-<samp><span class="file">vms/gawkmisc.vms</span></samp>. The use of separate
suffixes, instead of plain
-<samp><span class="file">gawkmisc.c</span></samp>, makes it possible to move
files from a port's subdirectory
-into the main subdirectory, without accidentally destroying the real
-<samp><span class="file">gawkmisc.c</span></samp> file. (Currently, this is
only an issue for the
-PC operating system ports.)
-
- <li>Supply a <samp><span class="file">Makefile</span></samp> as well as
any other C source and header files that are
-necessary for your operating system. All your code should be in a
-separate subdirectory, with a name that is the same as, or reminiscent
-of, either your operating system or the computer system. If possible,
-try to structure things so that it is not necessary to move files out
-of the subdirectory into the main source directory. If that is not
-possible, then be sure to avoid using names for your files that
-duplicate the names of files in the main source directory.
-
- <li>Update the documentation.
-Please write a section (or sections) for this Web page describing the
-installation and compilation steps needed to compile and/or install
-<samp><span class="command">gawk</span></samp> for your system.
-
- <li>Be prepared to sign the appropriate paperwork.
-In order for the FSF to distribute your code, you must either place
-your code in the public domain and submit a signed statement to that
-effect, or assign the copyright in your code to the FSF.
- </ol>
-
- <p>Following these steps makes it much easier to integrate your changes
-into <samp><span class="command">gawk</span></samp> and have them coexist
happily with other
-operating systems' code that is already there.
-
- <p>In the code that you supply and maintain, feel free to use a
-coding style and brace layout that suits your taste.
-
-<div class="node">
-<p><hr>
-<a name="Dynamic-Extensions"></a>Next: <a rel="next" accesskey="n"
href="#Future-Extensions">Future Extensions</a>,
-Previous: <a rel="previous" accesskey="p" href="#Additions">Additions</a>,
-Up: <a rel="up" accesskey="u" href="#Notes">Notes</a>
-<br>
-</div>
-
-<h3 class="appendixsec">C.3 Adding New Built-in Functions to <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-Robinson_002c-Will-1963"></a><a
name="index-robot_002c-the-1964"></a><a
name="index-Lost-In-Space-1965"></a><blockquote>
-<i>Danger Will Robinson! Danger!!<br>
-Warning! Warning!</i><br>
-The Robot
-</blockquote>
-
-<!-- STARTOFRANGE gladfgaw -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-functions_002c-adding-1966"></a><!--
STARTOFRANGE adfugaw -->
-<a
name="index-adding_002c-functions-to-_0040command_007bgawk_007d-1967"></a><!--
STARTOFRANGE fubadgaw -->
-<a
name="index-functions_002c-built_002din_002c-adding-to-_0040command_007bgawk_007d-1968"></a>Beginning
with <samp><span class="command">gawk</span></samp> 3.1, it is possible to add
new built-in
-functions to <samp><span class="command">gawk</span></samp> using dynamically
loaded libraries. This
-facility is available on systems (such as GNU/Linux) that support
-the <code>dlopen</code> and <code>dlsym</code> functions.
-This section describes how to write and use dynamically
-loaded extensions for <samp><span class="command">gawk</span></samp>.
-Experience with programming in
-C or C++ is necessary when reading this section.
-
- <p><strong>Caution:</strong> The facilities described in this section
-are very much subject to change in a future <samp><span
class="command">gawk</span></samp> release.
-Be aware that you may have to re-do everything, perhaps from scratch,
-at some future time.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Internals">Internals</a>: A
brief look at some <samp><span class="command">gawk</span></samp> internals.
-<li><a accesskey="2" href="#Sample-Library">Sample Library</a>:
A example of new functions.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Internals"></a>Next: <a rel="next" accesskey="n"
href="#Sample-Library">Sample Library</a>,
-Up: <a rel="up" accesskey="u" href="#Dynamic-Extensions">Dynamic
Extensions</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">C.3.1 A Minimal Introduction to <samp><span
class="command">gawk</span></samp> Internals</h4>
-
-<!-- STARTOFRANGE gawint -->
-<p><a name="index-_0040command_007bgawk_007d_002c-internals-1969"></a>
-The truth is that <samp><span class="command">gawk</span></samp> was not
designed for simple extensibility.
-The facilities for adding functions using shared libraries work, but
-are something of a “bag on the side.” Thus, this tour is
-brief and simplistic; would-be <samp><span class="command">gawk</span></samp>
hackers are encouraged to
-spend some time reading the source code before trying to write
-extensions based on the material presented here. Of particular note
-are the files <samp><span class="file">awk.h</span></samp>, <samp><span
class="file">builtin.c</span></samp>, and <samp><span
class="file">eval.c</span></samp>.
-Reading <samp><span class="file">awk.y</span></samp> in order to see how the
parse tree is built
-would also be of use.
-
- <p><a
name="index-_0040code_007bawk_002eh_007d-file-_0028internal_0029-1970"></a>With
the disclaimers out of the way, the following types, structure
-members, functions, and macros are declared in <samp><span
class="file">awk.h</span></samp> and are of
-use when writing extensions. The next section
-shows how they are used:
-
-
-<a
name="index-floating_002dpoint_002c-numbers_002c-_0040code_007bAWKNUM_007d-internal-type-1971"></a>
-<a
name="index-numbers_002c-floating_002dpoint_002c-_0040code_007bAWKNUM_007d-internal-type-1972"></a>
-<a name="index-_0040code_007bAWKNUM_007d-internal-type-1973"></a>
-<dl><dt><code>AWKNUM</code><dd>An <code>AWKNUM</code> is the internal type of
<samp><span class="command">awk</span></samp>
-floating-point numbers. Typically, it is a C <code>double</code>.
-
- <p><a name="index-_0040code_007bNODE_007d-internal-type-1974"></a><a
name="index-strings_002c-_0040code_007bNODE_007d-internal-type-1975"></a><a
name="index-numbers_002c-_0040code_007bNODE_007d-internal-type-1976"></a><br><dt><code>NODE</code><dd>Just
about everything is done using objects of type <code>NODE</code>.
-These contain both strings and numbers, as well as variables and arrays.
-
- <p><a
name="index-_0040code_007bforce_005fnumber_007d-internal-function-1977"></a><a
name="index-numeric_002c-values-1978"></a><br><dt><code>AWKNUM
force_number(NODE *n)</code><dd>This macro forces a value to be numeric. It
returns the actual
-numeric value contained in the node.
-It may end up calling an internal <samp><span
class="command">gawk</span></samp> function.
-
- <p><a
name="index-_0040code_007bforce_005fstring_007d-internal-function-1979"></a><br><dt><code>void
force_string(NODE *n)</code><dd>This macro guarantees that a
<code>NODE</code>'s string value is current.
-It may end up calling an internal <samp><span
class="command">gawk</span></samp> function.
-It also guarantees that the string is zero-terminated.
-
- <p><a
name="index-_0040code_007bget_005fcurfunc_005farg_005fcount_007d-internal-function-1980"></a><br><dt><code>size_t
get_curfunc_arg_count(void)</code><dd>This function returns the actual number
of parameters passed
-to the current function. Inside the code of an extension
-this can be used to determine the maximum index which is
-safe to use with <code>stack_ptr</code>. If this value is
-greater than <code>tree->param_cnt</code>, the function was
-called incorrectly from the <samp><span class="command">awk</span></samp>
program.
-
- <p><strong>Caution:</strong> This function is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a name="index-parameters_0040comma_007b_007d-number-of-1981"></a><a
name="index-_0040code_007bparam_005fcnt_007d-internal-variable-1982"></a><br><dt><code>n->param_cnt</code><dd>Inside
an extension function, this is the maximum number of
-expected parameters, as set by the <code>make_builtin</code> function.
-
- <p><a name="index-_0040code_007bstptr_007d-internal-variable-1983"></a><a
name="index-_0040code_007bstlen_007d-internal-variable-1984"></a><br><dt><code>n->stptr</code><dt><code>n->stlen</code><dd>The
data and length of a <code>NODE</code>'s string value, respectively.
-The string is <em>not</em> guaranteed to be zero-terminated.
-If you need to pass the string value to a C library function, save
-the value in <code>n->stptr[n->stlen]</code>, assign <code>'\0'</code>
to it,
-call the routine, and then restore the value.
-
- <p><a
name="index-_0040code_007btype_007d-internal-variable-1985"></a><br><dt><code>n->type</code><dd>The
type of the <code>NODE</code>. This is a C <code>enum</code>. Values should
-be either <code>Node_var</code> or <code>Node_var_array</code> for function
-parameters.
-
- <p><a
name="index-_0040code_007bvname_007d-internal-variable-1986"></a><br><dt><code>n->vname</code><dd>The
“variable name” of a node. This is not of much use inside
-externally written extensions.
-
- <p><a name="index-arrays_002c-associative_002c-clearing-1987"></a><a
name="index-_0040code_007bassoc_005fclear_007d-internal-function-1988"></a><br><dt><code>void
assoc_clear(NODE *n)</code><dd>Clears the associative array pointed to by
<code>n</code>.
-Make sure that `<samp><span class="samp">n->type ==
Node_var_array</span></samp>' first.
-
- <p><a name="index-arrays_002c-elements_002c-installing-1989"></a><a
name="index-_0040code_007bassoc_005flookup_007d-internal-function-1990"></a><br><dt><code>NODE
**assoc_lookup(NODE *symbol, NODE *subs, int reference)</code><dd>Finds, and
installs if necessary, array elements.
-<code>symbol</code> is the array, <code>subs</code> is the subscript.
-This is usually a value created with <code>tmp_string</code> (see below).
-<code>reference</code> should be <code>TRUE</code> if it is an error to use the
-value before it is created. Typically, <code>FALSE</code> is the
-correct value to use from extension functions.
-
- <p><a name="index-strings-1991"></a><a
name="index-_0040code_007bmake_005fstring_007d-internal-function-1992"></a><br><dt><code>NODE
*make_string(char *s, size_t len)</code><dd>Take a C string and turn it into a
pointer to a <code>NODE</code> that
-can be stored appropriately. This is permanent storage; understanding
-of <samp><span class="command">gawk</span></samp> memory management is helpful.
-
- <p><a name="index-numbers-1993"></a><a
name="index-_0040code_007bmake_005fnumber_007d-internal-function-1994"></a><br><dt><code>NODE
*make_number(AWKNUM val)</code><dd>Take an <code>AWKNUM</code> and turn it
into a pointer to a <code>NODE</code> that
-can be stored appropriately. This is permanent storage; understanding
-of <samp><span class="command">gawk</span></samp> memory management is helpful.
-
- <p><a
name="index-_0040code_007btmp_005fstring_007d-internal-function-1995"></a><br><dt><code>NODE
*tmp_string(char *s, size_t len);</code><dd>Take a C string and turn it into a
pointer to a <code>NODE</code> that
-can be stored appropriately. This is temporary storage; understanding
-of <samp><span class="command">gawk</span></samp> memory management is helpful.
-
- <p><a
name="index-_0040code_007btmp_005fnumber_007d-internal-function-1996"></a><br><dt><code>NODE
*tmp_number(AWKNUM val)</code><dd>Take an <code>AWKNUM</code> and turn it into
a pointer to a <code>NODE</code> that
-can be stored appropriately. This is temporary storage;
-understanding of <samp><span class="command">gawk</span></samp> memory
management is helpful.
-
- <p><a name="index-nodes_0040comma_007b_007d-duplicating-1997"></a><a
name="index-_0040code_007bdupnode_007d-internal-function-1998"></a><br><dt><code>NODE
*dupnode(NODE *n)</code><dd>Duplicate a node. In most cases, this increments
an internal
-reference count instead of actually duplicating the entire <code>NODE</code>;
-understanding of <samp><span class="command">gawk</span></samp> memory
management is helpful.
-
- <p><a name="index-memory_002c-releasing-1999"></a><a
name="index-_0040code_007bfree_005ftemp_007d-internal-macro-2000"></a><br><dt><code>void
free_temp(NODE *n)</code><dd>This macro releases the memory associated with a
<code>NODE</code>
-allocated with <code>tmp_string</code> or <code>tmp_number</code>.
-Understanding of <samp><span class="command">gawk</span></samp> memory
management is helpful.
-
- <p><a
name="index-_0040code_007bmake_005fbuiltin_007d-internal-function-2001"></a><br><dt><code>void
make_builtin(char *name, NODE *(*func)(NODE *), int count)</code><dd>Register
a C function pointed to by <code>func</code> as new built-in
-function <code>name</code>. <code>name</code> is a regular C string.
<code>count</code>
-is the maximum number of arguments that the function takes.
-The function should be written in the following manner:
-
- <pre class="example"> /* do_xxx --- do xxx function for gawk */
-
- NODE *
- do_xxx(NODE *tree)
- {
- ...
- }
- </pre>
- <p><a name="index-arguments_002c-retrieving-2002"></a><a
name="index-_0040code_007bget_005fargument_007d-internal-function-2003"></a><br><dt><code>NODE
*get_argument(NODE *tree, int i)</code><dd>This function is called from within
a C extension function to get
-the <code>i</code>-th argument from the function call.
-The first argument is argument zero.
-
- <p><a
name="index-_0040code_007bget_005factual_005fargument_007d-internal-function-2004"></a><br><dt><code>NODE
*get_actual_argument(NODE *tree, unsigned int i,</code><dt><code>
int optional, int wantarray);</code><dd>This function retrieves a
particular argument <code>i</code>. <code>wantarray</code> is <code>TRUE</code>
-if the argument should be an array, <code>FALSE</code> otherwise. If
<code>optional</code> is
-<code>TRUE</code>, the argument need not have been supplied. If it wasn't,
the return
-value is <code>NULL</code>. It is a fatal error if <code>optional</code> is
<code>TRUE</code> but
-the argument was not provided.
-
- <p><strong>Caution:</strong> This function is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a
name="index-_0040code_007bget_005fscalar_005fargument_007d-internal-macro-2005"></a><br><dt><code>get_scalar_argument(t,
i, opt)</code><dd>This is a convenience macro that calls
<code>get_actual_argument</code>.
-
- <p><strong>Caution:</strong> This macro is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a
name="index-_0040code_007bget_005farray_005fargument_007d-internal-macro-2006"></a><br><dt><code>get_array_argument(t,
i, opt)</code><dd>This is a convenience macro that calls
<code>get_actual_argument</code>.
-
- <p><strong>Caution:</strong> This macro is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a
name="index-functions_002c-return-values_0040comma_007b_007d-setting-2007"></a><a
name="index-_0040code_007bset_005fvalue_007d-internal-function-2008"></a><br><dt><code>void
set_value(NODE *tree)</code><dd>This function is called from within a C
extension function to set
-the return value from the extension function. This value is
-what the <samp><span class="command">awk</span></samp> program sees as the
return value from the
-new <samp><span class="command">awk</span></samp> function.
-
- <p><a name="index-_0040code_007bERRNO_007d-variable-2009"></a><a
name="index-_0040code_007bupdate_005fERRNO_007d-internal-function-2010"></a><br><dt><code>void
update_ERRNO(void)</code><dd>This function is called from within a C extension
function to set
-the value of <samp><span class="command">gawk</span></samp>'s
<code>ERRNO</code> variable, based on the current
-value of the C <code>errno</code> variable.
-It is provided as a convenience.
-</dl>
-
- <p>An argument that is supposed to be an array needs to be handled with
-some extra code, in case the array being passed in is actually
-from a function parameter.
-
- <p>In versions of <samp><span class="command">gawk</span></samp> up to and
including 3.1.2, the
-following boilerplate code shows how to do this:
-
-<pre class="smallexample"> NODE *the_arg;
-
- the_arg = get_argument(tree, 2); /* assume need 3rd arg, 0-based */
-
- /* if a parameter, get it off the stack */
- if (the_arg->type == Node_param_list)
- the_arg = stack_ptr[the_arg->param_cnt];
-
- /* parameter referenced an array, get it */
- if (the_arg->type == Node_array_ref)
- the_arg = the_arg->orig_array;
-
- /* check type */
- if (the_arg->type != Node_var && the_arg->type !=
Node_var_array)
- fatal("newfunc: third argument is not an array");
-
- /* force it to be an array, if necessary, clear it */
- the_arg->type = Node_var_array;
- assoc_clear(the_arg);
-</pre>
- <p>For versions 3.1.3 and later, the internals changed. In particular,
-the interface was actually <em>simplified</em> drastically. The
-following boilerplate code now suffices:
-
-<pre class="smallexample"> NODE *the_arg;
-
- the_arg = get_argument(tree, 2); /* assume need 3rd arg, 0-based */
-
- /* force it to be an array: */
- the_arg = get_array(the_arg);
-
- /* if necessary, clear it: */
- assoc_clear(the_arg);
-</pre>
- <p>As of version 3.1.4, the internals improved again, and became
-even simpler:
-
-<pre class="smallexample"> NODE *the_arg;
-
- the_arg = get_array_argument(tree, 2, FALSE); /* assume need 3rd arg,
0-based */
-</pre>
- <p>Again, you should spend time studying the <samp><span
class="command">gawk</span></samp> internals;
-don't just blindly copy this code.
-<!-- ENDOFRANGE gawint -->
-
-<div class="node">
-<p><hr>
-<a name="Sample-Library"></a>Previous: <a rel="previous" accesskey="p"
href="#Internals">Internals</a>,
-Up: <a rel="up" accesskey="u" href="#Dynamic-Extensions">Dynamic
Extensions</a>
-<br>
-</div>
-
-<h4 class="appendixsubsec">C.3.2 Directory and File Operation Built-ins</h4>
-
-<!-- STARTOFRANGE chdirg -->
-<p><a
name="index-_0040code_007bchdir_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2011"></a><!--
STARTOFRANGE statg -->
-<a
name="index-_0040code_007bstat_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2012"></a><!--
STARTOFRANGE filre -->
-<a
name="index-files_002c-information-about_0040comma_007b_007d-retrieving-2013"></a><!--
STARTOFRANGE dirch -->
-<a name="index-directories_002c-changing-2014"></a>
-Two useful functions that are not in <samp><span
class="command">awk</span></samp> are <code>chdir</code>
-(so that an <samp><span class="command">awk</span></samp> program can change
its directory) and
-<code>stat</code> (so that an <samp><span class="command">awk</span></samp>
program can gather information about
-a file).
-This section implements these functions for <samp><span
class="command">gawk</span></samp> in an
-external extension library.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Internal-File-Description">Internal File
Description</a>: What the new functions will do.
-<li><a accesskey="2" href="#Internal-File-Ops">Internal File Ops</a>:
The code for internal file operations.
-<li><a accesskey="3" href="#Using-Internal-File-Ops">Using Internal File
Ops</a>: How to use an external extension.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Internal-File-Description"></a>Next: <a rel="next" accesskey="n"
href="#Internal-File-Ops">Internal File Ops</a>,
-Up: <a rel="up" accesskey="u" href="#Sample-Library">Sample Library</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">C.3.2.1 Using <code>chdir</code> and
<code>stat</code></h5>
-
-<p>This section shows how to use the new functions at the <samp><span
class="command">awk</span></samp>
-level once they've been integrated into the running <samp><span
class="command">gawk</span></samp>
-interpreter.
-Using <code>chdir</code> is very straightforward. It takes one argument,
-the new directory to change to:
-
-<pre class="example"> ...
- newdir = "/home/arnold/funstuff"
- ret = chdir(newdir)
- if (ret < 0) {
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
- exit 1
- }
- ...
-</pre>
- <p>The return value is negative if the <code>chdir</code> failed,
-and <code>ERRNO</code>
-(see <a href="#Built_002din-Variables">Built-in Variables</a>)
-is set to a string indicating the error.
-
- <p>Using <code>stat</code> is a bit more complicated.
-The C <code>stat</code> function fills in a structure that has a fair
-amount of information.
-The right way to model this in <samp><span class="command">awk</span></samp>
is to fill in an associative
-array with the appropriate information:
-
-<!-- broke printf for page breaking -->
-<pre class="example"> file = "/home/arnold/.profile"
- fdata[1] = "x" # force `fdata' to be an array
- ret = stat(file, fdata)
- if (ret < 0) {
- printf("could not stat %s: %s\n",
- file, ERRNO) > "/dev/stderr"
- exit 1
- }
- printf("size of %s is %d bytes\n", file, fdata["size"])
-</pre>
- <p>The <code>stat</code> function always clears the data array, even if
-the <code>stat</code> fails. It fills in the following elements:
-
- <dl>
-<dt><code>"name"</code><dd>The name of the file that was <code>stat</code>'ed.
-
- <br><dt><code>"dev"</code><dt><code>"ino"</code><dd>The file's device and
inode numbers, respectively.
-
- <br><dt><code>"mode"</code><dd>The file's mode, as a numeric value. This
includes both the file's
-type and its permissions.
-
- <br><dt><code>"nlink"</code><dd>The number of hard links (directory
entries) the file has.
-
- <br><dt><code>"uid"</code><dt><code>"gid"</code><dd>The numeric user and
group ID numbers of the file's owner.
-
- <br><dt><code>"size"</code><dd>The size in bytes of the file.
-
- <br><dt><code>"blocks"</code><dd>The number of disk blocks the file
actually occupies. This may not
-be a function of the file's size if the file has holes.
-
-
<br><dt><code>"atime"</code><dt><code>"mtime"</code><dt><code>"ctime"</code><dd>The
file's last access, modification, and inode update times,
-respectively. These are numeric timestamps, suitable for formatting
-with <code>strftime</code>
-(see <a href="#Built_002din">Built-in</a>).
-
- <br><dt><code>"pmode"</code><dd>The file's “printable mode.”
This is a string representation of
-the file's type and permissions, such as what is produced by
-`<samp><span class="samp">ls -l</span></samp>'—for example,
<code>"drwxr-xr-x"</code>.
-
- <br><dt><code>"type"</code><dd>A printable string representation of the
file's type. The value
-is one of the following:
-
- <dl>
-<dt><code>"blockdev"</code><dt><code>"chardev"</code><dd>The file is a block
or character device (“special file”).
-
- <br><dt><code>"directory"</code><dd>The file is a directory.
-
- <br><dt><code>"fifo"</code><dd>The file is a named-pipe (also known
as a FIFO).
-
- <br><dt><code>"file"</code><dd>The file is just a regular file.
-
- <br><dt><code>"socket"</code><dd>The file is an <code>AF_Unix</code>
(“Unix domain”) socket in the
-filesystem.
-
- <br><dt><code>"symlink"</code><dd>The file is a symbolic link.
-</dl>
- </dl>
-
- <p>Several additional elements may be present depending upon the operating
-system and the type of the file. You can test for them in your <samp><span
class="command">awk</span></samp>
-program by using the <code>in</code> operator
-(see <a href="#Reference-to-Elements">Reference to Elements</a>):
-
- <dl>
-<dt><code>"blksize"</code><dd>The preferred block size for I/O to the file.
This field is not
-present on all POSIX-like systems in the C <code>stat</code> structure.
-
- <br><dt><code>"linkval"</code><dd>If the file is a symbolic link, this
element is the name of the
-file the link points to (i.e., the value of the link).
-
-
<br><dt><code>"rdev"</code><dt><code>"major"</code><dt><code>"minor"</code><dd>If
the file is a block or character device file, then these values
-represent the numeric device number and the major and minor components
-of that number, respectively.
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="Internal-File-Ops"></a>Next: <a rel="next" accesskey="n"
href="#Using-Internal-File-Ops">Using Internal File Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Internal-File-Description">Internal File Description</a>,
-Up: <a rel="up" accesskey="u" href="#Sample-Library">Sample Library</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">C.3.2.2 C Code for <code>chdir</code> and
<code>stat</code></h5>
-
-<p>Here is the C code for these extensions. They were written for
-GNU/Linux. The code needs some more work for complete portability
-to other POSIX-compliant systems:<a rel="footnote" href="#fn-70"
name="fnd-70"><sup>70</sup></a>
-
-<!-- break line for page breaking -->
-<pre class="example"> #include "awk.h"
-
- #include <sys/sysmacros.h>
-
- /* do_chdir --- provide dynamically loaded
- chdir() builtin for gawk */
-
- static NODE *
- do_chdir(tree)
- NODE *tree;
- {
- NODE *newdir;
- int ret = -1;
-
- if (do_lint && get_curfunc_arg_count() != 1)
- lintwarn("chdir: called with incorrect number of arguments");
-
- newdir = get_scalar_argument(tree, 0);
-</pre>
- <p>The file includes the <code>"awk.h"</code> header file for definitions
-for the <samp><span class="command">gawk</span></samp> internals. It includes
<code><sys/sysmacros.h></code>
-for access to the <code>major</code> and <code>minor</code> macros.
-
- <p><a
name="index-programming-conventions_002c-_0040command_007bgawk_007d-internals-2015"></a>By
convention, for an <samp><span class="command">awk</span></samp> function
<code>foo</code>, the function that
-implements it is called `<samp><span class="samp">do_foo</span></samp>'. The
function should take
-a `<samp><span class="samp">NODE *</span></samp>' argument, usually called
<code>tree</code>, that
-represents the argument list to the function. The <code>newdir</code>
-variable represents the new directory to change to, retrieved
-with <code>get_argument</code>. Note that the first argument is
-numbered zero.
-
- <p>This code actually accomplishes the <code>chdir</code>. It first forces
-the argument to be a string and passes the string value to the
-<code>chdir</code> system call. If the <code>chdir</code> fails,
<code>ERRNO</code>
-is updated.
-The result of <code>force_string</code> has to be freed with
<code>free_temp</code>:
-
-<pre class="example"> (void) force_string(newdir);
- ret = chdir(newdir->stptr);
- if (ret < 0)
- update_ERRNO();
- free_temp(newdir);
-</pre>
- <p>Finally, the function returns the return value to the <samp><span
class="command">awk</span></samp> level,
-using <code>set_value</code>. Then it must return a value from the call to
-the new built-in (this value ignored by the interpreter):
-
-<pre class="example"> /* Set the return value */
- set_value(tmp_number((AWKNUM) ret));
-
- /* Just to make the interpreter happy */
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p>The <code>stat</code> built-in is more involved. First comes a function
-that turns a numeric mode into a printable representation
-(e.g., 644 becomes `<samp><span class="samp">-rw-r--r--</span></samp>'). This
is omitted here for brevity:
-
-<!-- break line for page breaking -->
-<pre class="example"> /* format_mode --- turn a stat mode field
- into something readable */
-
- static char *
- format_mode(fmode)
- unsigned long fmode;
- {
- ...
- }
-</pre>
- <p>Next comes the actual <code>do_stat</code> function itself. First come
the
-variable declarations and argument checking:
-
-<pre class="example"> /* do_stat --- provide a stat() function for gawk */
-
- static NODE *
- do_stat(tree)
- NODE *tree;
- {
- NODE *file, *array;
- struct stat sbuf;
- int ret;
- NODE **aptr;
- char *pmode; /* printable mode */
- char *type = "unknown";
-
-
- if (do_lint && get_curfunc_arg_count() > 2)
- lintwarn("stat: called with too many arguments");
-</pre>
- <p>Then comes the actual work. First, we get the arguments.
-Then, we always clear the array. To get the file information,
-we use <code>lstat</code>, in case the file is a symbolic link.
-If there's an error, we set <code>ERRNO</code> and return:
-
-<!-- comment made multiline for page breaking -->
-<pre class="example"> /* directory is first arg, array to hold results
is second */
- file = get_scalar_argument(tree, 0, FALSE);
- array = get_array_argument(tree, 1, FALSE);
-
- /* empty out the array */
- assoc_clear(array);
-
- /* lstat the file, if error, set ERRNO and return */
- (void) force_string(file);
- ret = lstat(file->stptr, & sbuf);
- if (ret < 0) {
- update_ERRNO();
-
- set_value(tmp_number((AWKNUM) ret));
-
- free_temp(file);
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p>Now comes the tedious part: filling in the array. Only a few of the
-calls are shown here, since they all follow the same pattern:
-
-<pre class="example"> /* fill in the array */
- aptr = assoc_lookup(array, tmp_string("name", 4), FALSE);
- *aptr = dupnode(file);
-
- aptr = assoc_lookup(array, tmp_string("mode", 4), FALSE);
- *aptr = make_number((AWKNUM) sbuf.st_mode);
-
- aptr = assoc_lookup(array, tmp_string("pmode", 5), FALSE);
- pmode = format_mode(sbuf.st_mode);
- *aptr = make_string(pmode, strlen(pmode));
-</pre>
- <p>When done, we free the temporary value containing the file name,
-set the return value, and return:
-
-<pre class="example"> free_temp(file);
-
- /* Set the return value */
- set_value(tmp_number((AWKNUM) ret));
-
- /* Just to make the interpreter happy */
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p><a
name="index-programming-conventions_002c-_0040command_007bgawk_007d-internals-2016"></a>Finally,
it's necessary to provide the “glue” that loads the
-new function(s) into <samp><span class="command">gawk</span></samp>. By
convention, each library has
-a routine named <code>dlload</code> that does the job:
-
-<pre class="example"> /* dlload --- load new builtins in this library */
-
- NODE *
- dlload(tree, dl)
- NODE *tree;
- void *dl;
- {
- make_builtin("chdir", do_chdir, 1);
- make_builtin("stat", do_stat, 2);
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p>And that's it! As an exercise, consider adding functions to
-implement system calls such as <code>chown</code>, <code>chmod</code>, and
<code>umask</code>.
-
-<div class="node">
-<p><hr>
-<a name="Using-Internal-File-Ops"></a>Previous: <a rel="previous"
accesskey="p" href="#Internal-File-Ops">Internal File Ops</a>,
-Up: <a rel="up" accesskey="u" href="#Sample-Library">Sample Library</a>
-<br>
-</div>
-
-<h5 class="appendixsubsubsec">C.3.2.3 Integrating the Extensions</h5>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2017"></a>Now
that the code is written, it must be possible to add it at
-runtime to the running <samp><span class="command">gawk</span></samp>
interpreter. First, the
-code must be compiled. Assuming that the functions are in
-a file named <samp><span class="file">filefuncs.c</span></samp>, and
<var>idir</var> is the location
-of the <samp><span class="command">gawk</span></samp> include files,
-the following steps create
-a GNU/Linux shared library:
-
-<pre class="example"> $ gcc -shared -DHAVE_CONFIG_H -c -O -g
-I<var>idir</var> filefuncs.c
- $ ld -o filefuncs.so -shared filefuncs.o
-</pre>
- <p><a
name="index-_0040code_007bextension_007d-function-_0028_0040command_007bgawk_007d_0029-2018"></a>Once
the library exists, it is loaded by calling the <code>extension</code>
-built-in function.
-This function takes two arguments: the name of the
-library to load and the name of a function to call when the library
-is first loaded. This function adds the new functions to <samp><span
class="command">gawk</span></samp>.
-It returns the value returned by the initialization function
-within the shared library:
-
-<pre class="example"> # file testff.awk
- BEGIN {
- extension("./filefuncs.so", "dlload")
-
- chdir(".") # no-op
-
- data[1] = 1 # force `data' to be an array
- print "Info for testff.awk"
- ret = stat("testff.awk", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
- }
-</pre>
- <p>Here are the results of running the program:
-
-<pre class="example"> $ gawk -f testff.awk
- -| Info for testff.awk
- -| ret = 0
- -| data["blksize"] = 4096
- -| data["mtime"] = 932361936
- -| data["mode"] = 33188
- -| data["type"] = file
- -| data["dev"] = 2065
- -| data["gid"] = 10
- -| data["ino"] = 878597
- -| data["ctime"] = 971431797
- -| data["blocks"] = 2
- -| data["nlink"] = 1
- -| data["name"] = testff.awk
- -| data["atime"] = 971608519
- -| data["pmode"] = -rw-r--r--
- -| data["size"] = 607
- -| data["uid"] = 2076
- -| testff.awk modified: 07 19 99 08:25:36
-</pre>
- <!-- ENDOFRANGE filre -->
-<!-- ENDOFRANGE dirch -->
-<!-- ENDOFRANGE statg -->
-<!-- ENDOFRANGE chdirg -->
-<!-- ENDOFRANGE gladfgaw -->
-<!-- ENDOFRANGE adfugaw -->
-<!-- ENDOFRANGE fubadgaw -->
-<div class="node">
-<p><hr>
-<a name="Future-Extensions"></a>Previous: <a rel="previous" accesskey="p"
href="#Dynamic-Extensions">Dynamic Extensions</a>,
-Up: <a rel="up" accesskey="u" href="#Notes">Notes</a>
-<br>
-</div>
-
-<h3 class="appendixsec">C.4 Probable Future Extensions</h3>
-
-<p><a name="index-PERL-2019"></a><a name="index-Wall_002c-Larry-2020"></a><a
name="index-Robbins_002c-Arnold-2021"></a><blockquote>
-<i>AWK is a language similar to PERL, only considerably more elegant.</i><br>
-Arnold Robbins
-
- <p><i>Hey!</i><br>
-Larry Wall
-</blockquote>
-
- <p>This section briefly lists extensions and possible improvements
-that indicate the directions we are
-currently considering for <samp><span class="command">gawk</span></samp>. The
file <samp><span class="file">FUTURES</span></samp> in the
-<samp><span class="command">gawk</span></samp> distribution lists these
extensions as well.
-
- <p>Following is a list of probable future changes visible at the
-<samp><span class="command">awk</span></samp> language level:
-
-<!-- these are ordered by likelihood -->
-<dl>
-<dt>Loadable module interface<dd>It is not clear that the <samp><span
class="command">awk</span></samp>-level interface to the
-modules facility is as good as it should be. The interface needs to be
-redesigned, particularly taking namespace issues into account, as
-well as possibly including issues such as library search path order
-and versioning.
-
- <br><dt><code>RECLEN</code> variable for fixed-length records<dd>Along
with <code>FIELDWIDTHS</code>, this would speed up the processing of
-fixed-length records.
-<code>PROCINFO["RS"]</code> would be <code>"RS"</code> or
<code>"RECLEN"</code>,
-depending upon which kind of record processing is in effect.
-
- <br><dt>Additional <code>printf</code> specifiers<dd>The 1999 ISO C
standard added a number of additional <code>printf</code>
-format specifiers. These should be evaluated for possible inclusion
-in <samp><span class="command">gawk</span></samp>.
-
- <br><dt>Databases<dd>It may be possible to map a GDBM/NDBM/SDBM file into
an <samp><span class="command">awk</span></samp> array.
-
- <br><dt>Large character sets<dd>It would be nice if <samp><span
class="command">gawk</span></samp> could handle UTF-8 and other
-character sets that are larger than eight bits.
-(<samp><span class="command">gawk</span></samp> currently has partial
multi-byte support, but it
-needs an expert to really think out the multi-byte issues and consult
-with the maintainer on the appropriate changes.)
-
- <br><dt>More <code>lint</code> warnings<dd>There are more things that
could be checked for portability.
-</dl>
-
- <p>Following is a list of probable improvements that will make <samp><span
class="command">gawk</span></samp>'s
-source code easier to work with:
-
- <dl>
-<dt>Loadable module mechanics<dd>The current extension mechanism works
-(see <a href="#Dynamic-Extensions">Dynamic Extensions</a>),
-but is rather primitive. It requires a fair amount of manual work
-to create and integrate a loadable module.
-Nor is the current mechanism as portable as might be desired.
-The GNU <samp><span class="command">libtool</span></samp> package provides a
number of features that
-would make using loadable modules much easier.
-<samp><span class="command">gawk</span></samp> should be changed to use
<samp><span class="command">libtool</span></samp>.
-
- <br><dt>Loadable module internals<dd>The API to its internals that
<samp><span class="command">gawk</span></samp> “exports” should be
revised.
-Too many things are needlessly exposed. A new API should be designed
-and implemented to make module writing easier.
-
- <br><dt>Better array subscript management<dd><samp><span
class="command">gawk</span></samp>'s management of array subscript storage
could use revamping,
-so that using the same value to index multiple arrays only
-stores one copy of the index value.
-
- <br><dt>Integrating the DBUG library<dd>Integrating Fred Fish's DBUG
library would be helpful during development,
-but it's a lot of work to do.
-</dl>
-
- <p>Following is a list of probable improvements that will make <samp><span
class="command">gawk</span></samp>
-perform better:
-
- <dl>
-<!-- NEXT ED: remove this item. awka and mawk do these respectively -->
-<dt>Compilation of <samp><span class="command">awk</span></samp>
programs<dd><samp><span class="command">gawk</span></samp> uses a Bison
(YACC-like)
-parser to convert the script given it into a syntax tree; the syntax
-tree is then executed by a simple recursive evaluator. This method incurs
-a lot of overhead, since the recursive evaluator performs many procedure
-calls to do even the simplest things.
-
- <p>It should be possible for <samp><span
class="command">gawk</span></samp> to convert the script's parse tree
-into a C program which the user would then compile, using the normal
-C compiler and a special <samp><span class="command">gawk</span></samp>
library to provide all the needed
-functions (regexps, fields, associative arrays, type coercion, and so on).
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2022"></a>An
easier possibility might be for an intermediate phase of <samp><span
class="command">gawk</span></samp> to
-convert the parse tree into a linear byte code form like the one used
-in GNU Emacs Lisp. The recursive evaluator would then be replaced by
-a straight line byte code interpreter that would be intermediate in speed
-between running a compiled program and doing what <samp><span
class="command">gawk</span></samp> does
-now.
-</dl>
-
- <p>Finally,
-the programs in the test suite could use documenting in this Web page.
-
- <p>See <a href="#Additions">Additions</a>,
-if you are interested in tackling any of these projects.
-<!-- ENDOFRANGE impis -->
-<!-- ENDOFRANGE gawii -->
-
-<div class="node">
-<p><hr>
-<a name="Basic-Concepts"></a>Next: <a rel="next" accesskey="n"
href="#Glossary">Glossary</a>,
-Previous: <a rel="previous" accesskey="p" href="#Notes">Notes</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="appendix">Appendix D Basic Programming Concepts</h2>
-
-<p><a name="index-programming_002c-concepts-2023"></a><!-- STARTOFRANGE procon
-->
-<a name="index-programming_002c-concepts-2024"></a>
-This appendix attempts to define some of the basic concepts
-and terms that are used throughout the rest of this Web page.
-As this Web page is specifically about <samp><span
class="command">awk</span></samp>,
-and not about computer programming in general, the coverage here
-is by necessity fairly cursory and simplistic.
-(If you need more background, there are many
-other introductory texts that you should refer to instead.)
-
-<ul class="menu">
-<li><a accesskey="1" href="#Basic-High-Level">Basic High Level</a>:
The high level view.
-<li><a accesskey="2" href="#Basic-Data-Typing">Basic Data Typing</a>:
A very quick intro to data types.
-<li><a accesskey="3" href="#Floating-Point-Issues">Floating Point Issues</a>:
Stuff to know about floating-point numbers.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Basic-High-Level"></a>Next: <a rel="next" accesskey="n"
href="#Basic-Data-Typing">Basic Data Typing</a>,
-Up: <a rel="up" accesskey="u" href="#Basic-Concepts">Basic Concepts</a>
-<br>
-</div>
-
-<h3 class="appendixsec">D.1 What a Program Does</h3>
-
-<p><a name="index-processing-data-2025"></a>At the most basic level, the job
of a program is to process
-some input data and produce results.
-
-<!-- NEXT ED: Use real images here -->
-<pre class="example"> _______
- +------+ / \ +---------+
- | Data | -----> < Program > -----> | Results |
- +------+ \_______/ +---------+
-</pre>
- <p><a name="index-compiled-programs-2026"></a><a
name="index-interpreted-programs-2027"></a>The “program” in the
figure can be either a compiled
-program<a rel="footnote" href="#fn-71" name="fnd-71"><sup>71</sup></a>
-(such as <samp><span class="command">ls</span></samp>),
-or it may be <dfn>interpreted</dfn>. In the latter case, a machine-executable
-program such as <samp><span class="command">awk</span></samp> reads your
program, and then uses the
-instructions in your program to process the data.
-
- <p><a name="index-programming_002c-basic-steps-2028"></a>When you write a
program, it usually consists
-of the following, very basic set of steps:
-
-<!-- NEXT ED: Use real images here -->
-<pre class="example"> ______
- +----------------+ / More \ No +----------+
- | Initialization | -------> < Data > -------> | Clean Up |
- +----------------+ ^ \ ? / +----------+
- | +--+-+
- | | Yes
- | |
- | V
- | +---------+
- +-----+ Process |
- +---------+
-</pre>
- <dl>
-<dt>Initialization<dd>These are the things you do before actually starting to
process
-data, such as checking arguments, initializing any data you need
-to work with, and so on.
-This step corresponds to <samp><span class="command">awk</span></samp>'s
<code>BEGIN</code> rule
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-
- <p>If you were baking a cake, this might consist of laying out all the
-mixing bowls and the baking pan, and making sure you have all the
-ingredients that you need.
-
- <br><dt>Processing<dd>This is where the actual work is done. Your
program reads data,
-one logical chunk at a time, and processes it as appropriate.
-
- <p>In most programming languages, you have to manually manage the reading
-of data, checking to see if there is more each time you read a chunk.
-<samp><span class="command">awk</span></samp>'s pattern-action paradigm
-(see <a href="#Getting-Started">Getting Started</a>)
-handles the mechanics of this for you.
-
- <p>In baking a cake, the processing corresponds to the actual labor:
-breaking eggs, mixing the flour, water, and other ingredients, and then
putting the cake
-into the oven.
-
- <br><dt>Clean Up<dd>Once you've processed all the data, you may have
things you need to
-do before exiting.
-This step corresponds to <samp><span class="command">awk</span></samp>'s
<code>END</code> rule
-(see <a href="#BEGIN_002fEND">BEGIN/END</a>).
-
- <p>After the cake comes out of the oven, you still have to wrap it in
-plastic wrap to keep anyone from tasting it, as well as wash
-the mixing bowls and utensils.
-</dl>
-
- <p><a name="index-algorithms-2029"></a>An <dfn>algorithm</dfn> is a
detailed set of instructions necessary to accomplish
-a task, or process data. It is much the same as a recipe for baking
-a cake. Programs implement algorithms. Often, it is up to you to design
-the algorithm and implement it, simultaneously.
-
- <p><a name="index-records-2030"></a><a name="index-fields-2031"></a>The
“logical chunks” we talked about previously are called
<dfn>records</dfn>,
-similar to the records a company keeps on employees, a school keeps for
-students, or a doctor keeps for patients.
-Each record has many component parts, such as first and last names,
-date of birth, address, and so on. The component parts are referred
-to as the <dfn>fields</dfn> of the record.
-
- <p>The act of reading data is termed <dfn>input</dfn>, and that of
-generating results, not too surprisingly, is termed <dfn>output</dfn>.
-They are often referred to together as “input/output,”
-and even more often, as “I/O” for short.
-(You will also see “input” and “output” used as verbs.)
-
- <p><a name="index-data_002ddriven-languages-2032"></a><a
name="index-languages_0040comma_007b_007d-data_002ddriven-2033"></a><samp><span
class="command">awk</span></samp> manages the reading of data for you, as well
as the
-breaking it up into records and fields. Your program's job is to
-tell <samp><span class="command">awk</span></samp> what to with the data. You
do this by describing
-<dfn>patterns</dfn> in the data to look for, and <dfn>actions</dfn> to execute
-when those patterns are seen. This <dfn>data-driven</dfn> nature of
-<samp><span class="command">awk</span></samp> programs usually makes them both
easier to write
-and easier to read.
-
-<div class="node">
-<p><hr>
-<a name="Basic-Data-Typing"></a>Next: <a rel="next" accesskey="n"
href="#Floating-Point-Issues">Floating Point Issues</a>,
-Previous: <a rel="previous" accesskey="p" href="#Basic-High-Level">Basic
High Level</a>,
-Up: <a rel="up" accesskey="u" href="#Basic-Concepts">Basic Concepts</a>
-<br>
-</div>
-
-<h3 class="appendixsec">D.2 Data Values in a Computer</h3>
-
-<p><a name="index-variables-2034"></a>In a program,
-you keep track of information and values in things called
<dfn>variables</dfn>.
-A variable is just a name for a given value, such as <code>first_name</code>,
-<code>last_name</code>, <code>address</code>, and so on.
-<samp><span class="command">awk</span></samp> has several predefined
variables, and it has
-special names to refer to the current input record
-and the fields of the record.
-You may also group multiple
-associated values under one name, as an array.
-
- <p><a name="index-values_002c-numeric-2035"></a><a
name="index-values_002c-string-2036"></a><a
name="index-scalar-values-2037"></a>Data, particularly in <samp><span
class="command">awk</span></samp>, consists of either numeric
-values, such as 42 or 3.1415927, or string values.
-String values are essentially anything that's not a number, such as a name.
-Strings are sometimes referred to as <dfn>character data</dfn>, since they
-store the individual characters that comprise them.
-Individual variables, as well as numeric and string variables, are
-referred to as <dfn>scalar</dfn> values.
-Groups of values, such as arrays, are not scalars.
-
- <p><a name="index-integers-2038"></a><a
name="index-floating_002dpoint_002c-numbers-2039"></a><a
name="index-numbers_002c-floating_002dpoint-2040"></a>Within computers, there
are two kinds of numeric values: <dfn>integers</dfn>
-and <dfn>floating-point</dfn>.
-In school, integer values were referred to as “whole”
numbers—that is,
-numbers without any fractional part, such as 1, 42, or −17.
-The advantage to integer numbers is that they represent values exactly.
-The disadvantage is that their range is limited. On most modern systems,
-this range is −2,147,483,648 to 2,147,483,647.
-
- <p><a name="index-unsigned-integers-2041"></a><a
name="index-integers_002c-unsigned-2042"></a>Integer values come in two
flavors: <dfn>signed</dfn> and <dfn>unsigned</dfn>.
-Signed values may be negative or positive, with the range of values just
-described.
-Unsigned values are always positive. On most modern systems,
-the range is from 0 to 4,294,967,295.
-
- <p><a name="index-double_002dprecision-floating_002dpoint-2043"></a><a
name="index-single_002dprecision-floating_002dpoint-2044"></a>Floating-point
numbers represent what are called “real” numbers; i.e.,
-those that do have a fractional part, such as 3.1415927.
-The advantage to floating-point numbers is that they
-can represent a much larger range of values.
-The disadvantage is that there are numbers that they cannot represent
-exactly.
-<samp><span class="command">awk</span></samp> uses <dfn>double-precision</dfn>
floating-point numbers, which
-can hold more digits than <dfn>single-precision</dfn>
-floating-point numbers.
-Floating-point issues are discussed more fully in
-<a href="#Floating-Point-Issues">Floating Point Issues</a>.
-
- <p>At the very lowest level, computers store values as groups of binary
digits,
-or <dfn>bits</dfn>. Modern computers group bits into groups of eight, called
<dfn>bytes</dfn>.
-Advanced applications sometimes have to manipulate bits directly,
-and <samp><span class="command">gawk</span></samp> provides functions for
doing so.
-
- <p><a name="index-null-strings-2045"></a>While you are probably used to the
idea of a number without a value (i.e., zero),
-it takes a bit more getting used to the idea of zero-length character data.
-Nevertheless, such a thing exists.
-It is called the <dfn>null string</dfn>.
-The null string is character data that has no value.
-In other words, it is empty. It is written in <samp><span
class="command">awk</span></samp> programs
-like this: <code>""</code>.
-
- <p>Humans are used to working in decimal; i.e., base 10. In base 10,
-numbers go from 0 to 9, and then “roll over” into the next
-column. (Remember grade school? 42 is 4 times 10 plus 2.)
-
- <p>There are other number bases though. Computers commonly use base 2
-or <dfn>binary</dfn>, base 8 or <dfn>octal</dfn>, and base 16 or
<dfn>hexadecimal</dfn>.
-In binary, each column represents two times the value in the column to
-its right. Each column may contain either a 0 or a 1.
-Thus, binary 1010 represents 1 times 8, plus 0 times 4, plus 1 times 2,
-plus 0 times 1, or decimal 10.
-Octal and hexadecimal are discussed more in
-<a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a>.
-
- <p>Programs are written in programming languages.
-Hundreds, if not thousands, of programming languages exist.
-One of the most popular is the C programming language.
-The C language had a very strong influence on the design of
-the <samp><span class="command">awk</span></samp> language.
-
- <p><a name="index-Kernighan_002c-Brian-2046"></a><a
name="index-Ritchie_002c-Dennis-2047"></a>There have been several versions of
C. The first is often referred to
-as “K&R” C, after the initials of Brian Kernighan and Dennis
Ritchie,
-the authors of the first book on C. (Dennis Ritchie created the language,
-and Brian Kernighan was one of the creators of <samp><span
class="command">awk</span></samp>.)
-
- <p>In the mid-1980s, an effort began to produce an international standard
-for C. This work culminated in 1989, with the production of the ANSI
-standard for C. This standard became an ISO standard in 1990.
-Where it makes sense, POSIX <samp><span class="command">awk</span></samp> is
compatible with 1990 ISO C.
-
- <p>In 1999, a revised ISO C standard was approved and released.
-Future versions of <samp><span class="command">gawk</span></samp> will be as
compatible as possible
-with this standard.
-
-<div class="node">
-<p><hr>
-<a name="Floating-Point-Issues"></a>Previous: <a rel="previous"
accesskey="p" href="#Basic-Data-Typing">Basic Data Typing</a>,
-Up: <a rel="up" accesskey="u" href="#Basic-Concepts">Basic Concepts</a>
-<br>
-</div>
-
-<h3 class="appendixsec">D.3 Floating-Point Number Caveats</h3>
-
-<p>As mentioned earlier, floating-point numbers represent what are called
-“real” numbers, i.e., those that have a fractional part.
<samp><span class="command">awk</span></samp>
-uses double-precision floating-point numbers to represent all
-numeric values. This section describes some of the issues
-involved in using floating-point numbers.
-
- <p>There is a very nice paper on floating-point arithmetic by
-David Goldberg, “What Every
-Computer Scientist Should Know About Floating-point Arithmetic,”
-<cite>ACM Computing Surveys</cite> <strong>23</strong>, 1 (1991-03),
-5-48.<a rel="footnote" href="#fn-72" name="fnd-72"><sup>72</sup></a>
-This is worth reading if you are interested in the details,
-but it does require a background in computer science.
-
- <p>Internally, <samp><span class="command">awk</span></samp> keeps both the
numeric value
-(double-precision floating-point) and the string value for a variable.
-Separately, <samp><span class="command">awk</span></samp> keeps
-track of what type the variable has
-(see <a href="#Typing-and-Comparison">Typing and Comparison</a>),
-which plays a role in how variables are used in comparisons.
-
- <p>It is important to note that the string value for a number may not
-reflect the full value (all the digits) that the numeric value
-actually contains.
-The following program (<samp><span class="file">values.awk</span></samp>)
illustrates this:
-
-<pre class="example"> {
- $1 = $2 + $3
- # see it for what it is
- printf("$1 = %.12g\n", $1)
- # use CONVFMT
- a = "<" $1 ">"
- print "a =", a
- # use OFMT
- print "$1 =", $1
- }
-</pre>
- <p class="noindent">This program shows the full value of the sum of
<code>$2</code> and <code>$3</code>
-using <code>printf</code>, and then prints the string values obtained
-from both automatic conversion (via <code>CONVFMT</code>) and
-from printing (via <code>OFMT</code>).
-
- <p>Here is what happens when the program is run:
-
-<pre class="example"> $ echo 2 3.654321 1.2345678 | awk -f values.awk
- -| $1 = 4.8888888
- -| a = <4.88889>
- -| $1 = 4.88889
-</pre>
- <p>This makes it clear that the full numeric value is different from
-what the default string representations show.
-
- <p><code>CONVFMT</code>'s default value is <code>"%.6g"</code>, which
yields a value with
-at least six significant digits. For some applications, you might want to
-change it to specify more precision.
-On most modern machines, most of the time,
-17 digits is enough to capture a floating-point number's
-value exactly.<a rel="footnote" href="#fn-73" name="fnd-73"><sup>73</sup></a>
-
- <p><a name="index-floating_002dpoint-2048"></a>Unlike numbers in the
abstract sense (such as what you studied in high school
-or college math), numbers stored in computers are limited in certain ways.
-They cannot represent an infinite number of digits, nor can they always
-represent things exactly.
-In particular,
-floating-point numbers cannot
-always represent values exactly. Here is an example:
-
-<pre class="example"> $ awk '{ printf("%010d\n", $1 * 100) }'
- 515.79
- -| 0000051579
- 515.80
- -| 0000051579
- 515.81
- -| 0000051580
- 515.82
- -| 0000051582
- <kbd>Ctrl-d</kbd>
-</pre>
- <p class="noindent">This shows that some values can be represented exactly,
-whereas others are only approximated. This is not a “bug”
-in <samp><span class="command">awk</span></samp>, but simply an artifact of
how computers
-represent numbers.
-
- <p><a name="index-negative-zero-2049"></a><a
name="index-positive-zero-2050"></a><a
name="index-zero_0040comma_007b_007d-negative-vs_002e_0040_003a-positive-2051"></a>Another
peculiarity of floating-point numbers on modern systems
-is that they often have more than one representation for the number zero!
-In particular, it is possible to represent “minus zero” as well as
-regular, or “positive” zero.
-
- <p>This example shows that negative and positive zero are distinct values
-when stored internally, but that they are in fact equal to each other,
-as well as to “regular” zero:
-
-<pre class="smallexample"> $ gawk 'BEGIN { mz = -0 ; pz = 0
- > printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz
- > printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0
- > }'
- -| -0 = -0, +0 = 0, (-0 == +0) -> 1
- -| mz == 0 -> 1, pz == 0 -> 1
-</pre>
- <p>It helps to keep this in mind should you process numeric data
-that contains negative zero values; the fact that the zero is negative
-is noted and can affect comparisons.
-<!-- ENDOFRANGE procon -->
-
-<div class="node">
-<p><hr>
-<a name="Glossary"></a>Next: <a rel="next" accesskey="n"
href="#Copying">Copying</a>,
-Previous: <a rel="previous" accesskey="p" href="#Basic-Concepts">Basic
Concepts</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">Glossary</h2>
-
- <dl>
-<dt>Action<dd>A series of <samp><span class="command">awk</span></samp>
statements attached to a rule. If the rule's
-pattern matches an input record, <samp><span class="command">awk</span></samp>
executes the
-rule's action. Actions are always enclosed in curly braces.
-(See <a href="#Action-Overview">Action Overview</a>.)
-
- <p><a name="index-Spencer_002c-Henry-2052"></a><a
name="index-_0040command_007bsed_007d-utility-2053"></a><a
name="index-amazing-_0040command_007bawk_007d-assembler-_0028_0040command_007baaa_007d_0029-2054"></a><br><dt>Amazing
<samp><span class="command">awk</span></samp> Assembler<dd>Henry Spencer at
the University of Toronto wrote a retargetable assembler
-completely as <samp><span class="command">sed</span></samp> and <samp><span
class="command">awk</span></samp> scripts. It is thousands
-of lines long, including machine descriptions for several eight-bit
-microcomputers. It is a good example of a program that would have been
-better written in another language.
-You can get it from <a
href="ftp://ftp.freefriends.org/arnold/Awkstuff/aaa.tgz">ftp://ftp.freefriends.org/arnold/Awkstuff/aaa.tgz</a>.
-
- <p><a
name="index-amazingly-workable-formatter-_0028_0040command_007bawf_007d_0029-2055"></a><a
name="index-_0040command_007bawf_007d-_0028amazingly-workable-formatter_0029-program-2056"></a><br><dt>Amazingly
Workable Formatter (<samp><span class="command">awf</span></samp>)<dd>Henry
Spencer at the University of Toronto wrote a formatter that accepts
-a large subset of the `<samp><span class="samp">nroff -ms</span></samp>' and
`<samp><span class="samp">nroff -man</span></samp>' formatting
-commands, using <samp><span class="command">awk</span></samp> and <samp><span
class="command">sh</span></samp>.
-It is available over the Internet
-from <a
href="ftp://ftp.freefriends.org/arnold/Awkstuff/awf.tgz">ftp://ftp.freefriends.org/arnold/Awkstuff/awf.tgz</a>.
-
- <br><dt>Anchor<dd>The regexp metacharacters `<samp><span
class="samp">^</span></samp>' and `<samp><span class="samp">$</span></samp>',
which force the match
-to the beginning or end of the string, respectively.
-
- <p><a name="index-ANSI-2057"></a><br><dt>ANSI<dd>The American National
Standards Institute. This organization produces
-many standards, among them the standards for the C and C++ programming
-languages.
-These standards often become international standards as well. See also
-“ISO.”
-
- <br><dt>Array<dd>A grouping of multiple values under the same name.
-Most languages just provide sequential arrays.
-<samp><span class="command">awk</span></samp> provides associative arrays.
-
- <br><dt>Assertion<dd>A statement in a program that a condition is true at
this point in the program.
-Useful for reasoning about how a program is supposed to behave.
-
- <br><dt>Assignment<dd>An <samp><span class="command">awk</span></samp>
expression that changes the value of some <samp><span
class="command">awk</span></samp>
-variable or data object. An object that you can assign to is called an
-<dfn>lvalue</dfn>. The assigned values are called <dfn>rvalues</dfn>.
-See <a href="#Assignment-Ops">Assignment Ops</a>.
-
- <br><dt>Associative Array<dd>Arrays in which the indices may be numbers
or strings, not just
-sequential integers in a fixed range.
-
- <br><dt><samp><span class="command">awk</span></samp> Language<dd>The
language in which <samp><span class="command">awk</span></samp> programs are
written.
-
- <br><dt><samp><span class="command">awk</span></samp> Program<dd>An
<samp><span class="command">awk</span></samp> program consists of a series of
<dfn>patterns</dfn> and
-<dfn>actions</dfn>, collectively known as <dfn>rules</dfn>. For each input
record
-given to the program, the program's rules are all processed in turn.
-<samp><span class="command">awk</span></samp> programs may also contain
function definitions.
-
- <br><dt><samp><span class="command">awk</span></samp> Script<dd>Another
name for an <samp><span class="command">awk</span></samp> program.
-
- <br><dt>Bash<dd>The GNU version of the standard shell
-(the <b>B</b>ourne-<b>A</b>gain <b>SH</b>ell).
-See also “Bourne Shell.”
-
- <br><dt>BBS<dd>See “Bulletin Board System.”
-
- <br><dt>Bit<dd>Short for “Binary Digit.”
-All values in computer memory ultimately reduce to binary digits: values
-that are either zero or one.
-Groups of bits may be interpreted differently—as integers,
-floating-point numbers, character data, addresses of other
-memory objects, or other data.
-<samp><span class="command">awk</span></samp> lets you work with
floating-point numbers and strings.
-<samp><span class="command">gawk</span></samp> lets you manipulate bit values
with the built-in
-functions described in
-<a href="#Bitwise-Functions">Bitwise Functions</a>.
-
- <p>Computers are often defined by how many bits they use to represent
integer
-values. Typical systems are 32-bit systems, but 64-bit systems are
-becoming increasingly popular, and 16-bit systems are waning in
-popularity.
-
- <br><dt>Boolean Expression<dd>Named after the English mathematician
Boole. See also “Logical Expression.”
-
- <br><dt>Bourne Shell<dd>The standard shell (<samp><span
class="file">/bin/sh</span></samp>) on Unix and Unix-like systems,
-originally written by Steven R. Bourne.
-Many shells (<samp><span class="command">bash</span></samp>, <samp><span
class="command">ksh</span></samp>, <samp><span
class="command">pdksh</span></samp>, <samp><span
class="command">zsh</span></samp>) are
-generally upwardly compatible with the Bourne shell.
-
- <br><dt>Built-in Function<dd>The <samp><span
class="command">awk</span></samp> language provides built-in functions that
perform various
-numerical, I/O-related, and string computations. Examples are
-<code>sqrt</code> (for the square root of a number) and <code>substr</code>
(for a
-substring of a string).
-<samp><span class="command">gawk</span></samp> provides functions for
timestamp management, bit manipulation,
-and runtime string translation.
-(See <a href="#Built_002din">Built-in</a>.)
-
- <br><dt>Built-in Variable<dd><code>ARGC</code>,
-<code>ARGV</code>,
-<code>CONVFMT</code>,
-<code>ENVIRON</code>,
-<code>FILENAME</code>,
-<code>FNR</code>,
-<code>FS</code>,
-<code>NF</code>,
-<code>NR</code>,
-<code>OFMT</code>,
-<code>OFS</code>,
-<code>ORS</code>,
-<code>RLENGTH</code>,
-<code>RSTART</code>,
-<code>RS</code>,
-and
-<code>SUBSEP</code>
-are the variables that have special meaning to <samp><span
class="command">awk</span></samp>.
-In addition,
-<code>ARGIND</code>,
-<code>BINMODE</code>,
-<code>ERRNO</code>,
-<code>FIELDWIDTHS</code>,
-<code>IGNORECASE</code>,
-<code>LINT</code>,
-<code>PROCINFO</code>,
-<code>RT</code>,
-and
-<code>TEXTDOMAIN</code>
-are the variables that have special meaning to <samp><span
class="command">gawk</span></samp>.
-Changing some of them affects <samp><span class="command">awk</span></samp>'s
running environment.
-(See <a href="#Built_002din-Variables">Built-in Variables</a>.)
-
- <br><dt>Braces<dd>See “Curly Braces.”
-
- <br><dt>Bulletin Board System<dd>A computer system allowing users to log
in and read and/or leave messages
-for other users of the system, much like leaving paper notes on a bulletin
-board.
-
- <br><dt>C<dd>The system programming language that most GNU software is
written in. The
-<samp><span class="command">awk</span></samp> programming language has C-like
syntax, and this Web page
-points out similarities between <samp><span class="command">awk</span></samp>
and C when appropriate.
-
- <p>In general, <samp><span class="command">gawk</span></samp> attempts to
be as similar to the 1990 version
-of ISO C as makes sense. Future versions of <samp><span
class="command">gawk</span></samp> may adopt features
-from the newer 1999 standard, as appropriate.
-
- <br><dt>C++<dd>A popular object-oriented programming language derived
from C.
-
- <p><a name="index-ISO-8859_002d1-2058"></a><a
name="index-ISO-Latin_002d1-2059"></a><a
name="index-character-sets-_0028machine-character-encodings_0029-2060"></a><br><dt>Character
Set<dd>The set of numeric codes used by a computer system to represent the
-characters (letters, numbers, punctuation, etc.) of a particular country
-or place. The most common character set in use today is ASCII (American
-Standard Code for Information Interchange). Many European
-countries use an extension of ASCII known as ISO-8859-1 (ISO Latin-1).
-
- <p><a
name="index-_0040command_007bchem_007d-utility-2061"></a><br><dt>CHEM<dd>A
preprocessor for <samp><span class="command">pic</span></samp> that reads
descriptions of molecules
-and produces <samp><span class="command">pic</span></samp> input for drawing
them.
-It was written in <samp><span class="command">awk</span></samp>
-by Brian Kernighan and Jon Bentley, and is available from
-<a
href="http://cm.bell-labs.com/netlib/typesetting/chem.gz">http://cm.bell-labs.com/netlib/typesetting/chem.gz</a>.
-
- <br><dt>Coprocess<dd>A subordinate program with which two-way
communications is possible.
-
- <p><a name="index-compiled-programs-2062"></a><br><dt>Compiler<dd>A
program that translates human-readable source code into
-machine-executable object code. The object code is then executed
-directly by the computer.
-See also “Interpreter.”
-
- <br><dt>Compound Statement<dd>A series of <samp><span
class="command">awk</span></samp> statements, enclosed in curly braces.
Compound
-statements may be nested.
-(See <a href="#Statements">Statements</a>.)
-
- <br><dt>Concatenation<dd>Concatenating two strings means sticking them
together, one after another,
-producing a new string. For example, the string `<samp><span
class="samp">foo</span></samp>' concatenated with
-the string `<samp><span class="samp">bar</span></samp>' gives the string
`<samp><span class="samp">foobar</span></samp>'.
-(See <a href="#Concatenation">Concatenation</a>.)
-
- <br><dt>Conditional Expression<dd>An expression using the `<samp><span
class="samp">?:</span></samp>' ternary operator, such as
-`<samp><var>expr1</var><span class="samp"> ? </span><var>expr2</var><span
class="samp"> : </span><var>expr3</var></samp>'. The expression
-<var>expr1</var> is evaluated; if the result is true, the value of the whole
-expression is the value of <var>expr2</var>; otherwise the value is
-<var>expr3</var>. In either case, only one of <var>expr2</var> and
<var>expr3</var>
-is evaluated. (See <a href="#Conditional-Exp">Conditional Exp</a>.)
-
- <br><dt>Comparison Expression<dd>A relation that is either true or false,
such as `<samp><span class="samp">(a < b)</span></samp>'.
-Comparison expressions are used in <code>if</code>, <code>while</code>,
<code>do</code>,
-and <code>for</code>
-statements, and in patterns to select which input records to process.
-(See <a href="#Typing-and-Comparison">Typing and Comparison</a>.)
-
- <br><dt>Curly Braces<dd>The characters `<samp><span
class="samp">{</span></samp>' and `<samp><span class="samp">}</span></samp>'.
Curly braces are used in
-<samp><span class="command">awk</span></samp> for delimiting actions, compound
statements, and function
-bodies.
-
- <p><a name="index-dark-corner-2063"></a><br><dt>Dark Corner<dd>An area in
the language where specifications often were (or still
-are) not clear, leading to unexpected or undesirable behavior.
-Such areas are marked in this Web page with
-“(d.c.)” in the text
-and are indexed under the heading “dark corner.”
-
- <br><dt>Data Driven<dd>A description of <samp><span
class="command">awk</span></samp> programs, where you specify the data you
-are interested in processing, and what to do when that data is seen.
-
- <br><dt>Data Objects<dd>These are numbers and strings of characters.
Numbers are converted into
-strings and vice versa, as needed.
-(See <a href="#Conversion">Conversion</a>.)
-
- <br><dt>Deadlock<dd>The situation in which two communicating processes
are each waiting
-for the other to perform an action.
-
- <br><dt>Double-Precision<dd>An internal representation of numbers that
can have fractional parts.
-Double-precision numbers keep track of more digits than do single-precision
-numbers, but operations on them are sometimes more expensive. This is the way
-<samp><span class="command">awk</span></samp> stores numeric values. It is
the C type <code>double</code>.
-
- <br><dt>Dynamic Regular Expression<dd>A dynamic regular expression is a
regular expression written as an
-ordinary expression. It could be a string constant, such as
-<code>"foo"</code>, but it may also be an expression whose value can vary.
-(See <a href="#Computed-Regexps">Computed Regexps</a>.)
-
- <br><dt>Environment<dd>A collection of strings, of the form
<var>name</var><code>=</code><var>val</var>, that each
-program has available to it. Users generally place values into the
-environment in order to provide information to various programs. Typical
-examples are the environment variables <samp><span
class="env">HOME</span></samp> and <samp><span class="env">PATH</span></samp>.
-
- <br><dt>Empty String<dd>See “Null String.”
-
- <p><a name="index-epoch_002c-definition-of-2064"></a><br><dt>Epoch<dd>The
date used as the “beginning of time” for timestamps.
-Time values in Unix systems are represented as seconds since the epoch,
-with library functions available for converting these values into
-standard date and time formats.
-
- <p>The epoch on Unix and POSIX systems is 1970-01-01 00:00:00 UTC.
-See also “GMT” and “UTC.”
-
- <br><dt>Escape Sequences<dd>A special sequence of characters used for
describing nonprinting
-characters, such as `<samp><span class="samp">\n</span></samp>' for newline or
`<samp><span class="samp">\033</span></samp>' for the ASCII
-ESC (Escape) character. (See <a href="#Escape-Sequences">Escape Sequences</a>.)
-
- <br><dt>FDL<dd>See “Free Documentation License.”
-
- <br><dt>Field<dd>When <samp><span class="command">awk</span></samp> reads
an input record, it splits the record into pieces
-separated by whitespace (or by a separator regexp that you can
-change by setting the built-in variable <code>FS</code>). Such pieces are
-called fields. If the pieces are of fixed length, you can use the built-in
-variable <code>FIELDWIDTHS</code> to describe their lengths.
-(See <a href="#Field-Separators">Field Separators</a>,
-and
-<a href="#Constant-Size">Constant Size</a>.)
-
- <br><dt>Flag<dd>A variable whose truth value indicates the existence or
nonexistence
-of some condition.
-
- <br><dt>Floating-Point Number<dd>Often referred to in mathematical terms
as a “rational” or real number,
-this is just a number that can have a fractional part.
-See also “Double-Precision” and “Single-Precision.”
-
- <br><dt>Format<dd>Format strings are used to control the appearance of
output in the
-<code>strftime</code> and <code>sprintf</code> functions, and are used in the
-<code>printf</code> statement as well. Also, data conversions from numbers to
strings
-are controlled by the format string contained in the built-in variable
-<code>CONVFMT</code>. (See <a href="#Control-Letters">Control Letters</a>.)
-
- <br><dt>Free Documentation License<dd>This document describes the terms
under which this Web page
-is published and may be copied. (See <a
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>.)
-
- <br><dt>Function<dd>A specialized group of statements used to encapsulate
general
-or program-specific tasks. <samp><span class="command">awk</span></samp> has
a number of built-in
-functions, and also allows you to define your own.
-(See <a href="#Functions">Functions</a>.)
-
- <br><dt>FSF<dd>See “Free Software Foundation.”
-
- <p><a name="index-FSF-_0028Free-Software-Foundation_0029-2065"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-2066"></a><a
name="index-Stallman_002c-Richard-2067"></a><br><dt>Free Software
Foundation<dd>A nonprofit organization dedicated
-to the production and distribution of freely distributable software.
-It was founded by Richard M. Stallman, the author of the original
-Emacs editor. GNU Emacs is the most widely used version of Emacs today.
-
- <br><dt><samp><span class="command">gawk</span></samp><dd>The GNU
implementation of <samp><span class="command">awk</span></samp>.
-
- <p><a name="index-GPL-_0028General-Public-License_0029-2068"></a><a
name="index-General-Public-License-_0028GPL_0029-2069"></a><a
name="index-GNU-General-Public-License-2070"></a><br><dt>General Public
License<dd>This document describes the terms under which <samp><span
class="command">gawk</span></samp> and its source
-code may be distributed. (See <a href="#Copying">Copying</a>.)
-
- <br><dt>GMT<dd>“Greenwich Mean Time.”
-This is the old term for UTC.
-It is the time of day used as the epoch for Unix and POSIX systems.
-See also “Epoch” and “UTC.”
-
- <p><a name="index-FSF-_0028Free-Software-Foundation_0029-2071"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-2072"></a><a
name="index-GNU-Project-2073"></a><br><dt>GNU<dd>“GNU's not Unix”.
An on-going project of the Free Software Foundation
-to create a complete, freely distributable, POSIX-compliant computing
-environment.
-
- <br><dt>GNU/Linux<dd>A variant of the GNU system using the Linux kernel,
instead of the
-Free Software Foundation's Hurd kernel.
-Linux is a stable, efficient, full-featured clone of Unix that has
-been ported to a variety of architectures.
-It is most popular on PC-class systems, but runs well on a variety of
-other systems too.
-The Linux kernel source code is available under the terms of the GNU General
-Public License, which is perhaps its most important aspect.
-
- <br><dt>GPL<dd>See “General Public License.”
-
- <br><dt>Hexadecimal<dd>Base 16 notation, where the digits are
<code>0</code>–<code>9</code> and
-<code>A</code>–<code>F</code>, with `<samp><span
class="samp">A</span></samp>'
-representing 10, `<samp><span class="samp">B</span></samp>' representing 11,
and so on, up to `<samp><span class="samp">F</span></samp>' for 15.
-Hexadecimal numbers are written in C using a leading `<samp><span
class="samp">0x</span></samp>',
-to indicate their base. Thus, <code>0x12</code> is 18 (1 times 16 plus 2).
-
- <br><dt>I/O<dd>Abbreviation for “Input/Output,” the act of
moving data into and/or
-out of a running program.
-
- <br><dt>Input Record<dd>A single chunk of data that is read in by
<samp><span class="command">awk</span></samp>. Usually, an <samp><span
class="command">awk</span></samp> input
-record consists of one line of text.
-(See <a href="#Records">Records</a>.)
-
- <br><dt>Integer<dd>A whole number, i.e., a number that does not have a
fractional part.
-
- <br><dt>Internationalization<dd>The process of writing or modifying a
program so
-that it can use multiple languages without requiring
-further source code changes.
-
- <p><a name="index-interpreted-programs-2074"></a><br><dt>Interpreter<dd>A
program that reads human-readable source code directly, and uses
-the instructions in it to process data and produce results.
-<samp><span class="command">awk</span></samp> is typically (but not always)
implemented as an interpreter.
-See also “Compiler.”
-
- <br><dt>Interval Expression<dd>A component of a regular expression that
lets you specify repeated matches of
-some part of the regexp. Interval expressions were not traditionally available
-in <samp><span class="command">awk</span></samp> programs.
-
- <p><a name="index-ISO-2075"></a><br><dt>ISO<dd>The International
Standards Organization.
-This organization produces international standards for many things, including
-programming languages, such as C and C++.
-In the computer arena, important standards like those for C, C++, and POSIX
-become both American national and ISO international standards simultaneously.
-This Web page refers to Standard C as “ISO C” throughout.
-
- <br><dt>Keyword<dd>In the <samp><span class="command">awk</span></samp>
language, a keyword is a word that has special
-meaning. Keywords are reserved and may not be used as variable names.
-
- <p><samp><span class="command">gawk</span></samp>'s keywords are:
-<code>BEGIN</code>,
-<code>END</code>,
-<code>if</code>,
-<code>else</code>,
-<code>while</code>,
-<code>do...while</code>,
-<code>for</code>,
-<code>for...in</code>,
-<code>break</code>,
-<code>continue</code>,
-<code>delete</code>,
-<code>next</code>,
-<code>nextfile</code>,
-<code>function</code>,
-<code>func</code>,
-and
-<code>exit</code>.
-
- <p><a
name="index-LGPL-_0028Lesser-General-Public-License_0029-2076"></a><a
name="index-Lesser-General-Public-License-_0028LGPL_0029-2077"></a><a
name="index-GNU-Lesser-General-Public-License-2078"></a><br><dt>Lesser General
Public License<dd>This document describes the terms under which binary library
archives
-or shared objects,
-and their source code may be distributed.
-
- <br><dt>Linux<dd>See “GNU/Linux.”
-
- <br><dt>LGPL<dd>See “Lesser General Public License.”
-
- <br><dt>Localization<dd>The process of providing the data necessary for an
-internationalized program to work in a particular language.
-
- <br><dt>Logical Expression<dd>An expression using the operators for
logic, AND, OR, and NOT, written
-`<samp><span class="samp">&&</span></samp>', `<samp><span
class="samp">||</span></samp>', and `<samp><span class="samp">!</span></samp>'
in <samp><span class="command">awk</span></samp>. Often called Boolean
-expressions, after the mathematician who pioneered this kind of
-mathematical logic.
-
- <br><dt>Lvalue<dd>An expression that can appear on the left side of an
assignment
-operator. In most languages, lvalues can be variables or array
-elements. In <samp><span class="command">awk</span></samp>, a field
designator can also be used as an
-lvalue.
-
- <br><dt>Matching<dd>The act of testing a string against a regular
expression. If the
-regexp describes the contents of the string, it is said to <dfn>match</dfn> it.
-
- <br><dt>Metacharacters<dd>Characters used within a regexp that do not
stand for themselves.
-Instead, they denote regular expression operations, such as repetition,
-grouping, or alternation.
-
- <br><dt>Null String<dd>A string with no characters in it. It is
represented explicitly in
-<samp><span class="command">awk</span></samp> programs by placing two double
quote characters next to
-each other (<code>""</code>). It can appear in input data by having two
successive
-occurrences of the field separator appear next to each other.
-
- <br><dt>Number<dd>A numeric-valued data object. Modern <samp><span
class="command">awk</span></samp> implementations use
-double-precision floating-point to represent numbers.
-Very old <samp><span class="command">awk</span></samp> implementations use
single-precision floating-point.
-
- <br><dt>Octal<dd>Base-eight notation, where the digits are
<code>0</code>–<code>7</code>.
-Octal numbers are written in C using a leading `<samp><span
class="samp">0</span></samp>',
-to indicate their base. Thus, <code>013</code> is 11 (one times 8 plus 3).
-
- <p><a
name="index-P1003_002e2-POSIX-standard-2079"></a><br><dt>P1003.2<dd>See
“POSIX.”
-
- <br><dt>Pattern<dd>Patterns tell <samp><span
class="command">awk</span></samp> which input records are interesting to which
-rules.
-
- <p>A pattern is an arbitrary conditional expression against which input is
-tested. If the condition is satisfied, the pattern is said to <dfn>match</dfn>
-the input record. A typical pattern might compare the input record against
-a regular expression. (See <a href="#Pattern-Overview">Pattern Overview</a>.)
-
- <br><dt>POSIX<dd>The name for a series of standards
-<!-- being developed by the IEEE -->
-that specify a Portable Operating System interface. The “IX”
denotes
-the Unix heritage of these standards. The main standard of interest for
-<samp><span class="command">awk</span></samp> users is
-<cite>IEEE Standard for Information Technology, Standard 1003.2-1992,
-Portable Operating System Interface (POSIX) Part 2: Shell and
Utilities</cite>.
-Informally, this standard is often referred to as simply “P1003.2.”
-
- <br><dt>Precedence<dd>The order in which operations are performed when
operators are used
-without explicit parentheses.
-
- <br><dt>Private<dd>Variables and/or functions that are meant for use
exclusively by library
-functions and not for the main <samp><span class="command">awk</span></samp>
program. Special care must be
-taken when naming such variables and functions.
-(See <a href="#Library-Names">Library Names</a>.)
-
- <br><dt>Range (of input lines)<dd>A sequence of consecutive lines from
the input file(s). A pattern
-can specify ranges of input lines for <samp><span
class="command">awk</span></samp> to process or it can
-specify single lines. (See <a href="#Pattern-Overview">Pattern Overview</a>.)
-
- <br><dt>Recursion<dd>When a function calls itself, either directly or
indirectly.
-If this isn't clear, refer to the entry for “recursion.”
-
- <br><dt>Redirection<dd>Redirection means performing input from something
other than the standard input
-stream, or performing output to something other than the standard output
stream.
-
- <p>You can redirect the output of the <code>print</code> and
<code>printf</code> statements
-to a file or a system command, using the `<samp><span
class="samp">></span></samp>', `<samp><span
class="samp">>></span></samp>', `<samp><span
class="samp">|</span></samp>', and `<samp><span
class="samp">|&</span></samp>'
-operators. You can redirect input to the <code>getline</code> statement using
-the `<samp><span class="samp"><</span></samp>', `<samp><span
class="samp">|</span></samp>', and `<samp><span
class="samp">|&</span></samp>' operators.
-(See <a href="#Redirection">Redirection</a>,
-and <a href="#Getline">Getline</a>.)
-
- <br><dt>Regexp<dd>Short for <dfn>regular expression</dfn>. A regexp is a
pattern that denotes a
-set of strings, possibly an infinite set. For example, the regexp
-`<samp><span class="samp">R.*xp</span></samp>' matches any string starting
with the letter `<samp><span class="samp">R</span></samp>'
-and ending with the letters `<samp><span class="samp">xp</span></samp>'. In
<samp><span class="command">awk</span></samp>, regexps are
-used in patterns and in conditional expressions. Regexps may contain
-escape sequences. (See <a href="#Regexp">Regexp</a>.)
-
- <br><dt>Regular Expression<dd>See “regexp.”
-
- <br><dt>Regular Expression Constant<dd>A regular expression constant is a
regular expression written within
-slashes, such as <code>/foo/</code>. This regular expression is chosen
-when you write the <samp><span class="command">awk</span></samp> program and
cannot be changed during
-its execution. (See <a href="#Regexp-Usage">Regexp Usage</a>.)
-
- <br><dt>Rule<dd>A segment of an <samp><span
class="command">awk</span></samp> program that specifies how to process single
-input records. A rule consists of a <dfn>pattern</dfn> and an
<dfn>action</dfn>.
-<samp><span class="command">awk</span></samp> reads an input record; then, for
each rule, if the input record
-satisfies the rule's pattern, <samp><span class="command">awk</span></samp>
executes the rule's action.
-Otherwise, the rule does nothing for that input record.
-
- <br><dt>Rvalue<dd>A value that can appear on the right side of an
assignment operator.
-In <samp><span class="command">awk</span></samp>, essentially every expression
has a value. These values
-are rvalues.
-
- <br><dt>Scalar<dd>A single value, be it a number or a string.
-Regular variables are scalars; arrays and functions are not.
-
- <br><dt>Search Path<dd>In <samp><span class="command">gawk</span></samp>,
a list of directories to search for <samp><span
class="command">awk</span></samp> program source files.
-In the shell, a list of directories to search for executable programs.
-
- <br><dt>Seed<dd>The initial value, or starting point, for a sequence of
random numbers.
-
- <br><dt><samp><span class="command">sed</span></samp><dd>See
“Stream Editor.”
-
- <br><dt>Shell<dd>The command interpreter for Unix and POSIX-compliant
systems.
-The shell works both interactively, and as a programming language
-for batch files, or shell scripts.
-
- <br><dt>Short-Circuit<dd>The nature of the <samp><span
class="command">awk</span></samp> logical operators `<samp><span
class="samp">&&</span></samp>' and `<samp><span
class="samp">||</span></samp>'.
-If the value of the entire expression is determinable from evaluating just
-the lefthand side of these operators, the righthand side is not
-evaluated.
-(See <a href="#Boolean-Ops">Boolean Ops</a>.)
-
- <br><dt>Side Effect<dd>A side effect occurs when an expression has an
effect aside from merely
-producing a value. Assignment expressions, increment and decrement
-expressions, and function calls have side effects.
-(See <a href="#Assignment-Ops">Assignment Ops</a>.)
-
- <br><dt>Single-Precision<dd>An internal representation of numbers that
can have fractional parts.
-Single-precision numbers keep track of fewer digits than do double-precision
-numbers, but operations on them are sometimes less expensive in terms of CPU
time.
-This is the type used by some very old versions of <samp><span
class="command">awk</span></samp> to store
-numeric values. It is the C type <code>float</code>.
-
- <br><dt>Space<dd>The character generated by hitting the space bar on the
keyboard.
-
- <br><dt>Special File<dd>A file name interpreted internally by <samp><span
class="command">gawk</span></samp>, instead of being handed
-directly to the underlying operating system—for example, <samp><span
class="file">/dev/stderr</span></samp>.
-(See <a href="#Special-Files">Special Files</a>.)
-
- <br><dt>Stream Editor<dd>A program that reads records from an input
stream and processes them one
-or more at a time. This is in contrast with batch programs, which may
-expect to read their input files in entirety before starting to do
-anything, as well as with interactive programs which require input from the
-user.
-
- <br><dt>String<dd>A datum consisting of a sequence of characters, such as
`<samp><span class="samp">I am a
-string</span></samp>'. Constant strings are written with double quotes in the
-<samp><span class="command">awk</span></samp> language and may contain escape
sequences.
-(See <a href="#Escape-Sequences">Escape Sequences</a>.)
-
- <br><dt>Tab<dd>The character generated by hitting the <kbd>TAB</kbd> key
on the keyboard.
-It usually expands to up to eight spaces upon output.
-
- <br><dt>Text Domain<dd>A unique name that identifies an application.
-Used for grouping messages that are translated at runtime
-into the local language.
-
- <br><dt>Timestamp<dd>A value in the “seconds since the epoch”
format used by Unix
-and POSIX systems. Used for the <samp><span
class="command">gawk</span></samp> functions
-<code>mktime</code>, <code>strftime</code>, and <code>systime</code>.
-See also “Epoch” and “UTC.”
-
- <p><a name="index-Linux-2080"></a><a
name="index-GNU_002fLinux-2081"></a><a name="index-Unix-2082"></a><a
name="index-BSD_002dbased-operating-systems-2083"></a><a
name="index-NetBSD-2084"></a><a name="index-FreeBSD-2085"></a><a
name="index-OpenBSD-2086"></a><br><dt>Unix<dd>A computer operating system
originally developed in the early 1970's at
-AT&T Bell Laboratories. It initially became popular in universities around
-the world and later moved into commercial environments as a software
-development system and network server system. There are many commercial
-versions of Unix, as well as several work-alike systems whose source code
-is freely available (such as GNU/Linux, NetBSD, FreeBSD, and OpenBSD).
-
- <br><dt>UTC<dd>The accepted abbreviation for “Universal Coordinated
Time.”
-This is standard time in Greenwich, England, which is used as a
-reference time for day and date calculations.
-See also “Epoch” and “GMT.”
-
- <br><dt>Whitespace<dd>A sequence of space, TAB, or newline characters
occurring inside an input
-record or a string.
-</dl>
-
-<div class="node">
-<p><hr>
-<a name="Copying"></a>Next: <a rel="next" accesskey="n"
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
-Previous: <a rel="previous" accesskey="p" href="#Glossary">Glossary</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">GNU General Public License</h2>
-
-<div align="center">Version 2, June 1991</div>
-
-<pre class="display"> Copyright © 1989, 1991 Free Software
Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-</pre>
- <!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">Preamble</h3>
-
-<p>The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software—to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- <p>When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- <p>To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- <p>For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- <p>We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- <p>Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- <p>Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- <p>The precise terms and conditions for copying, distribution and
-modification follow.
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">Terms and Conditions for Copying, Distribution and
Modification</h3>
-
- <ol type=1 start=0>
-<li>This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The “Program”,
below,
-refers to any such program or work, and a “work based on the
Program”
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term “modification”.) Each licensee is addressed as
“you”.
-
- <p>Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- <li>You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
- <p>You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- <li>You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- <ol type=a start=1>
-<li>You must cause the modified files to carry prominent notices
-stating that you changed the files and the date of any change.
-
- <li>You must cause any work that you distribute or publish, that in
-whole or in part contains or is derived from the Program or any
-part thereof, to be licensed as a whole at no charge to all third
-parties under the terms of this License.
-
- <li>If the modified program normally reads commands interactively
-when run, you must cause it, when started running for such
-interactive use in the most ordinary way, to print or display an
-announcement including an appropriate copyright notice and a
-notice that there is no warranty (or else, saying that you provide
-a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this
-License. (Exception: if the Program itself is interactive but
-does not normally print such an announcement, your work based on
-the Program is not required to print an announcement.)
- </ol>
-
- <p>These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
- <p>Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
- <p>In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- <li>You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- <ol type=a start=1>
-<li>Accompany it with the complete corresponding machine-readable
-source code, which must be distributed under the terms of Sections
-1 and 2 above on a medium customarily used for software interchange; or,
-
- <li>Accompany it with a written offer, valid for at least three
-years, to give any third party, for a charge no more than your
-cost of physically performing source distribution, a complete
-machine-readable copy of the corresponding source code, to be
-distributed under the terms of Sections 1 and 2 above on a medium
-customarily used for software interchange; or,
-
- <li>Accompany it with the information you received as to the offer
-to distribute corresponding source code. (This alternative is
-allowed only for noncommercial distribution and only if you
-received the program in object code or executable form with such
-an offer, in accord with Subsection b above.)
- </ol>
-
- <p>The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
- <p>If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- <li>You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- <li>You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- <li>Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- <li>If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
- <p>If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
- <p>It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
- <p>This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- <li>If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- <li>The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- <p>Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and “any
-later version”, you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- <li>If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- <!-- fakenode - for prepinfo -->
-<h3 class="heading">NO WARRANTY</h3>
-
- <li>BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- <li>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
- </ol>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="heading">END OF TERMS AND CONDITIONS</h3>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">How to Apply These Terms to Your New Programs</h3>
-
-<p>If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- <p>To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the “copyright” line and a pointer to where the full notice is
found.
-
-<pre class="smallexample"> <var>one line to give the program's name and an
idea of what it does.</var>
- Copyright (C) <var>year</var> <var>name of author</var>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
-</pre>
- <p>Also add information on how to contact you by electronic and paper mail.
-
- <p>If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-<pre class="smallexample"> Gnomovision version 69, Copyright (C)
<var>year</var> <var>name of author</var>
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
- type `show w'. This is free software, and you are welcome
- to redistribute it under certain conditions; type `show c'
- for details.
-</pre>
- <p>The hypothetical commands `<samp><span class="samp">show
w</span></samp>' and `<samp><span class="samp">show c</span></samp>' should show
-the appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `<samp><span
class="samp">show w</span></samp>' and
-`<samp><span class="samp">show c</span></samp>'; they could even be
mouse-clicks or menu items—whatever
-suits your program.
-
- <p>You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a “copyright disclaimer” for the program,
if
-necessary. Here is a sample; alter the names:
-
-<pre class="smallexample"> Yoyodyne, Inc., hereby disclaims all copyright
- interest in the program `Gnomovision'
- (which makes passes at compilers) written
- by James Hacker.
-
- <var>signature of Ty Coon</var>, 1 April 1989
- Ty Coon, President of Vice
-</pre>
- <p>This General Public License does not permit incorporating your program
into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
-
-<div class="node">
-<p><hr>
-<a name="GNU-Free-Documentation-License"></a>Next: <a rel="next"
accesskey="n" href="#Index">Index</a>,
-Previous: <a rel="previous" accesskey="p" href="#Copying">Copying</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">GNU Free Documentation License</h2>
-
-<p><a name="index-FDL-_0028Free-Documentation-License_0029-2087"></a><a
name="index-Free-Documentation-License-_0028FDL_0029-2088"></a><a
name="index-GNU-Free-Documentation-License-2089"></a><div
align="center">Version 1.2, November 2002</div>
-
-<pre class="display"> Copyright © 2000,2001,2002 Free Software
Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-</pre>
- <ol type=1 start=0>
-<li>PREAMBLE
-
- <p>The purpose of this License is to make a manual, textbook, or other
-functional and useful document <dfn>free</dfn> in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
- <p>This License is a kind of “copyleft”, which means that
derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
- <p>We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
- <li>APPLICABILITY AND DEFINITIONS
-
- <p>This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The “Document”, below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as “you”. You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
- <p>A “Modified Version” of the Document means any work
containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
- <p>A “Secondary Section” is a named appendix or a
front-matter section
-of the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
- <p>The “Invariant Sections” are certain Secondary Sections
whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
- <p>The “Cover Texts” are certain short passages of text that
are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
- <p>A “Transparent” copy of the Document means a
machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not “Transparent” is called
“Opaque”.
-
- <p>Examples of suitable formats for Transparent copies include plain
-<span class="sc">ascii</span> without markup, Texinfo input format, LaTeX input
-format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly
available
-<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> designed for human modification. Examples
-of transparent image formats include <acronym>PNG</acronym>,
<acronym>XCF</acronym> and
-<acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
-read and edited only by proprietary word processors, <acronym>SGML</acronym> or
-<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing
tools are
-not generally available, and the machine-generated <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> produced by some word processors for
-output purposes only.
-
- <p>The “Title Page” means, for a printed book, the title page
itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, “Title Page”
means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
- <p>A section “Entitled XYZ” means a named subunit of the
Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as “Acknowledgements”,
-“Dedications”, “Endorsements”, or
“History”.) To “Preserve the Title”
-of such a section when you modify the Document means that it remains a
-section “Entitled XYZ” according to this definition.
-
- <p>The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
- <li>VERBATIM COPYING
-
- <p>You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no other
-conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
- <p>You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
- <li>COPYING IN QUANTITY
-
- <p>If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
- <p>If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
- <p>If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
- <p>It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to give
-them a chance to provide you with an updated version of the Document.
-
- <li>MODIFICATIONS
-
- <p>You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
- <ol type=A start=1>
-<li>Use in the Title Page (and on the covers, if any) a title distinct
-from that of the Document, and from those of previous versions
-(which should, if there were any, be listed in the History section
-of the Document). You may use the same title as a previous version
-if the original publisher of that version gives permission.
-
- <li>List on the Title Page, as authors, one or more persons or
entities
-responsible for authorship of the modifications in the Modified
-Version, together with at least five of the principal authors of the
-Document (all of its principal authors, if it has fewer than five),
-unless they release you from this requirement.
-
- <li>State on the Title page the name of the publisher of the
-Modified Version, as the publisher.
-
- <li>Preserve all the copyright notices of the Document.
-
- <li>Add an appropriate copyright notice for your modifications
-adjacent to the other copyright notices.
-
- <li>Include, immediately after the copyright notices, a license
notice
-giving the public permission to use the Modified Version under the
-terms of this License, in the form shown in the Addendum below.
-
- <li>Preserve in that license notice the full lists of Invariant
Sections
-and required Cover Texts given in the Document's license notice.
-
- <li>Include an unaltered copy of this License.
-
- <li>Preserve the section Entitled “History”, Preserve
its Title, and add
-to it an item stating at least the title, year, new authors, and
-publisher of the Modified Version as given on the Title Page. If
-there is no section Entitled “History” in the Document, create one
-stating the title, year, authors, and publisher of the Document as
-given on its Title Page, then add an item describing the Modified
-Version as stated in the previous sentence.
-
- <li>Preserve the network location, if any, given in the Document for
-public access to a Transparent copy of the Document, and likewise
-the network locations given in the Document for previous versions
-it was based on. These may be placed in the “History” section.
-You may omit a network location for a work that was published at
-least four years before the Document itself, or if the original
-publisher of the version it refers to gives permission.
-
- <li>For any section Entitled “Acknowledgements” or
“Dedications”, Preserve
-the Title of the section, and preserve in the section all the
-substance and tone of each of the contributor acknowledgements and/or
-dedications given therein.
-
- <li>Preserve all the Invariant Sections of the Document,
-unaltered in their text and in their titles. Section numbers
-or the equivalent are not considered part of the section titles.
-
- <li>Delete any section Entitled “Endorsements”. Such a
section
-may not be included in the Modified Version.
-
- <li>Do not retitle any existing section to be Entitled
“Endorsements” or
-to conflict in title with any Invariant Section.
-
- <li>Preserve any Warranty Disclaimers.
- </ol>
-
- <p>If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
- <p>You may add a section Entitled “Endorsements”, provided it
contains
-nothing but endorsements of your Modified Version by various
-parties—for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
- <p>You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
- <p>The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
- <li>COMBINING DOCUMENTS
-
- <p>You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
- <p>The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
- <p>In the combination, you must combine any sections Entitled
“History”
-in the various original documents, forming one section Entitled
-“History”; likewise combine any sections Entitled
“Acknowledgements”,
-and any sections Entitled “Dedications”. You must delete all
-sections Entitled “Endorsements.”
-
- <li>COLLECTIONS OF DOCUMENTS
-
- <p>You may make a collection consisting of the Document and other
documents
-released under this License, and replace the individual copies of this
-License in the various documents with a single copy that is included in
-the collection, provided that you follow the rules of this License for
-verbatim copying of each of the documents in all other respects.
-
- <p>You may extract a single document from such a collection, and
distribute
-it individually under this License, provided you insert a copy of this
-License into the extracted document, and follow this License in all
-other respects regarding verbatim copying of that document.
-
- <li>AGGREGATION WITH INDEPENDENT WORKS
-
- <p>A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an “aggregate” if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
- <p>If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
- <li>TRANSLATION
-
- <p>Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warrany Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
- <p>If a section in the Document is Entitled
“Acknowledgements”,
-“Dedications”, or “History”, the requirement (section
4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
- <li>TERMINATION
-
- <p>You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License. Any other attempt to
-copy, modify, sublicense or distribute the Document is void, and will
-automatically terminate your rights under this License. However,
-parties who have received copies, or rights, from you under this
-License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- <li>FUTURE REVISIONS OF THIS LICENSE
-
- <p>The Free Software Foundation may publish new, revised versions
-of the GNU Free Documentation License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns. See
-<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
-
- <p>Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License “or any later version” applies to it, you have the option
of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation.
- </ol>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">ADDENDUM: How to use this License for your
documents</h3>
-
-<p>To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
-<pre class="smallexample"> Copyright (C) <var>year</var> <var>your
name</var>.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
- A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-</pre>
- <p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the “with...Texts.” line with this:
-
-<pre class="smallexample"> with the Invariant Sections being <var>list
their titles</var>, with
- the Front-Cover Texts being <var>list</var>, and with the Back-Cover
Texts
- being <var>list</var>.
-</pre>
- <p>If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
- <p>If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
-
-<!-- Local Variables: -->
-<!-- ispell-local-pdict: "ispell-dict" -->
-<!-- End: -->
-<div class="node">
-<p><hr>
-<a name="Index"></a>Previous: <a rel="previous" accesskey="p"
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">Index</h2>
-
-<ul class="index-cp" compact>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d--operator-791"><code>!</code>
(exclamation point), <code>!</code> operator</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-1756"><code>!</code>
(exclamation point), <code>!</code> operator</a>: <a
href="#Egrep-Program">Egrep Program</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-825"><code>!</code>
(exclamation point), <code>!</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-847"><code>!</code>
(exclamation point), <code>!=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-758"><code>!</code>
(exclamation point), <code>!=</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-897"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-862"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-762"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-622"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-329"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-321"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-177"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="#index-_0040code_007b_0021_007d-operator-1758"><code>!</code>
operator</a>: <a href="#Egrep-Program">Egrep Program</a></li>
-<li><a href="#index-_0040code_007b_0021_007d-operator-911"><code>!</code>
operator</a>: <a href="#Ranges">Ranges</a></li>
-<li><a
href="#index-_0040code_007b_0022_007d-_0028double-quote_0029-130"><code>"</code>
(double quote)</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-_0040code_007b_0022_007d-_0028double-quote_0029-92"><code>"</code>
(double quote)</a>: <a href="#Read-Terminal">Read Terminal</a></li>
-<li><a
href="#index-_0040code_007b_0022_007d-_0028double-quote_0029_002c-regexp-constants-334"><code>"</code>
(double quote), regexp constants</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a
href="#index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-105"><code>#</code>
(number sign), <code>#!</code> (executable scripts)</a>: <a
href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="#index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-108"><code>#</code>
(number sign), <code>#!</code> (executable scripts), portability issues
with</a>: <a href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="#index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-commenting-113"><code>#</code>
(number sign), commenting</a>: <a href="#Comments">Comments</a></li>
-<li><a
href="#index-_0040code_007b_0024_007d-_0028dollar-sign_0029-228"><code>$</code>
(dollar sign)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-811"><code>$</code>
(dollar sign), <code>$</code> field operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-385"><code>$</code>
(dollar sign), <code>$</code> field operator</a>: <a
href="#Fields">Fields</a></li>
-<li><a
href="#index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-incrementing-fields-and-arrays-717"><code>$</code>
(dollar sign), incrementing fields and arrays</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-_0040code_007b_0024_007d-field-operator-383"><code>$</code> field
operator</a>: <a href="#Fields">Fields</a></li>
-<li><a
href="#index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_007d-operator-831"><code>%</code>
(percent sign), <code>%</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-881"><code>%</code>
(percent sign), <code>%=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-692"><code>%</code>
(percent sign), <code>%=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-865"><code>&</code>
(ampersand), <code>&&</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-786"><code>&</code>
(ampersand), <code>&&</code> operator</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1203"><code>&</code>
(ampersand), <code>gsub</code>/<code>gensub</code>/<code>sub</code> functions
and</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a
href="#index-_0040code_007b_0027_007d-_0028single-quote_0029-128"><code>'</code>
(single quote)</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-_0040code_007b_0027_007d-_0028single-quote_0029-103"><code>'</code>
(single quote)</a>: <a href="#Long">Long</a></li>
-<li><a
href="#index-_0040code_007b_0027_007d-_0028single-quote_0029-81"><code>'</code>
(single quote)</a>: <a href="#One_002dshot">One-shot</a></li>
-<li><a
href="#index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-vs_002e-apostrophe-119"><code>'</code>
(single quote), vs. apostrophe</a>: <a href="#Comments">Comments</a></li>
-<li><a
href="#index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-with-double-quotes-132"><code>'</code>
(single quote), with double quotes</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-_0040code_007b_0028_0029_007d-_0028parentheses_0029-241"><code>()</code>
(parentheses)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_0028_0029_007d-_0028parentheses_0029_002c-_0040command_007bpgawk_007d-program-1454"><code>()</code>
(parentheses), <samp><span class="command">pgawk</span></samp> program</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-827"><code>*</code>
(asterisk), <code>*</code> operator, as multiplication operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-243"><code>*</code>
(asterisk), <code>*</code> operator, as regexp operator</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1209"><code>*</code>
(asterisk), <code>*</code> operator, null strings, matching</a>: <a
href="#Gory-Details">Gory Details</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-1533"><code>*</code>
(asterisk), <code>**</code> operator</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-819"><code>*</code>
(asterisk), <code>**</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-660"><code>*</code>
(asterisk), <code>**</code> operator</a>: <a href="#Arithmetic-Ops">Arithmetic
Ops</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1535"><code>*</code>
(asterisk), <code>**=</code> operator</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-877"><code>*</code>
(asterisk), <code>**=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-696"><code>*</code>
(asterisk), <code>**=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-875"><code>*</code>
(asterisk), <code>*=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-688"><code>*</code>
(asterisk), <code>*=</code> operator</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029-245"><code>+</code>
(plus sign)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_007d-operator-821"><code>+</code>
(plus sign), <code>+</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-813"><code>+</code>
(plus sign), <code>++</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-720"><code>+</code>
(plus sign), <code>++</code> operator</a>: <a href="#Increment-Ops">Increment
Ops</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-871"><code>+</code>
(plus sign), <code>+=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-681"><code>+</code>
(plus sign), <code>+=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-decrement_002fincrement-operators-714"><code>+</code>
(plus sign), decrement/increment operators</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-_0040code_007b_002c_007d-_0028comma_0029_002c-in-range-patterns-907"><code>,</code>
(comma), in range patterns</a>: <a href="#Ranges">Ranges</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_007d-operator-823"><code>-</code>
(hyphen), <code>-</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operator-815"><code>-</code>
(hyphen), <code>--</code> (decrement/increment) operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-operator-722"><code>-</code>
(hyphen), <code>--</code> operator</a>: <a href="#Increment-Ops">Increment
Ops</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-873"><code>-</code>
(hyphen), <code>-=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-686"><code>-</code>
(hyphen), <code>-=</code> operator</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-filenames-beginning-with-1498"><code>-</code>
(hyphen), filenames beginning with</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-in-character-lists-263"><code>-</code>
(hyphen), in character lists</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dassign_007d-option-1489"><code>--assign</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dcompat_007d-option-1500"><code>--compat</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dcopyleft_007d-option-1505"><code>--copyleft</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dcopyright_007d-option-1503"><code>--copyright</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002ddisable_002dlint_007d-configuration-option-1890"><code>--disable-lint</code>
configuration option</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002ddisable_002dnls_007d-configuration-option-1892"><code>--disable-nls</code>
configuration option</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1608"><code>--dump-variables</code>
option</a>: <a href="#Library-Names">Library Names</a></li>
-<li><a
href="#index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1506"><code>--dump-variables</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1881"><code>--enable-portals</code>
configuration option</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1434"><code>--enable-portals</code>
configuration option</a>: <a href="#Portal-Files">Portal Files</a></li>
-<li><a
href="#index-_0040code_007b_002d_002denable_002dswitch_007d-configuration-option-1883"><code>--enable-switch</code>
configuration option</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dfield_002dseparator_007d-option-1483"><code>--field-separator</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dfile_007d-option-1486"><code>--file</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dgen_002dpo_007d-option-1511"><code>--gen-po</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dgen_002dpo_007d-option-1364"><code>--gen-po</code>
option</a>: <a href="#String-Extraction">String Extraction</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dhelp_007d-option-1514"><code>--help</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dlint_007d-option-1519"><code>--lint</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dlint_007d-option-1476"><code>--lint</code>
option</a>: <a href="#Command-Line">Command Line</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dlint_002dold_007d-option-1522"><code>--lint-old</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1523"><code>--non-decimal-data</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1398"><code>--non-decimal-data</code>
option</a>: <a href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option_002c-_0040code_007bstrtonum_007d-function-and-1403"><code>--non-decimal-data</code>
option, <code>strtonum</code> function and</a>: <a
href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dposix_007d-option-1527"><code>--posix</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dposix_007d-option_002c-_0040code_007b_002d_002dtraditional_007d-option-and-1544"><code>--posix</code>
option, <code>--traditional</code> option and</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dprofile_007d-option-1545"><code>--profile</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dprofile_007d-option-1445"><code>--profile</code>
option</a>: <a href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dre_002dinterval_007d-option-1547"><code>--re-interval</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dsource_007d-option-1549"><code>--source</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dtraditional_007d-option-1501"><code>--traditional</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dtraditional_007d-option_002c-_0040code_007b_002d_002dposix_007d-option-and-1543"><code>--traditional</code>
option, <code>--posix</code> option and</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dusage_007d-option-1515"><code>--usage</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dversion_007d-option-1551"><code>--version</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1887"><code>--with-included-gettext</code>
configuration option</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1393"><code>--with-included-gettext</code>
configuration option</a>: <a href="#Gawk-I18N">Gawk I18N</a></li>
-<li><a
href="#index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option_002c-configuring-_0040command_007bgawk_007d-with-1888"><code>--with-included-gettext</code>
configuration option, configuring <samp><span
class="command">gawk</span></samp> with</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a href="#index-_0040code_007b_002df_007d-option-1485"><code>-f</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-_0040code_007b_002dF_007d-option-1482"><code>-F</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-_0040code_007b_002dF_007d-option-423"><code>-F</code>
option</a>: <a href="#Command-Line-Field-Separator">Command Line Field
Separator</a></li>
-<li><a href="#index-_0040code_007b_002df_007d-option-98"><code>-f</code>
option</a>: <a href="#Long">Long</a></li>
-<li><a
href="#index-_0040code_007b_002dF_007d-option_002c-_0040code_007b_002dFt_007d-sets-_0040code_007bFS_007d-to-TAB-1553"><code>-F</code>
option, <code>-Ft</code> sets <code>FS</code> to TAB</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002df_007d-option_002c-on-command-line-1554"><code>-f</code>
option, on command line</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002dF_007d-option_002c-troubleshooting-1588"><code>-F</code>
option, troubleshooting</a>: <a href="#Known-Bugs">Known Bugs</a></li>
-<li><a
href="#index-_0040code_007b_002dmf_007d_002f_0040code_007b_002dmr_007d-options-1493"><code>-mf</code>/<code>-mr</code>
options</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-_0040code_007b_002dv_007d-option-1488"><code>-v</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002dv_007d-option_002c-variables_0040comma_007b_007d-assigning-638"><code>-v</code>
option, variables, assigning</a>: <a href="#Assignment-Options">Assignment
Options</a></li>
-<li><a href="#index-_0040code_007b_002dW_007d-option-1495"><code>-W</code>
option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_002e_007d-_0028period_0029-230"><code>.</code>
(period)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a href="#index-_0040code_007b_002emo_007d-files-1314"><code>.mo</code>
files</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007b_002emo_007d-files_002c-converting-from-_0040code_007b_002epo_007d-1386"><code>.mo</code>
files, converting from <code>.po</code></a>: <a href="#I18N-Example">I18N
Example</a></li>
-<li><a
href="#index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1348"><code>.mo</code>
files, specifying directory of</a>: <a href="#Programmer-i18n">Programmer
i18n</a></li>
-<li><a
href="#index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1319"><code>.mo</code>
files, specifying directory of</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a href="#index-_0040code_007b_002epo_007d-files-1358"><code>.po</code>
files</a>: <a href="#Translator-i18n">Translator i18n</a></li>
-<li><a href="#index-_0040code_007b_002epo_007d-files-1310"><code>.po</code>
files</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007b_002epo_007d-files_002c-converting-to-_0040code_007b_002emo_007d-1384"><code>.po</code>
files, converting to <code>.mo</code></a>: <a href="#I18N-Example">I18N
Example</a></li>
-<li><a
href="#index-_0040code_007b_002f_007d-_0028forward-slash_0029-171"><code>/</code>
(forward slash)</a>: <a href="#Regexp">Regexp</a></li>
-<li><a
href="#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_007d-operator-829"><code>/</code>
(forward slash), <code>/</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-879"><code>/</code>
(forward slash), <code>/=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-690"><code>/</code>
(forward slash), <code>/=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-704"><code>/</code>
(forward slash), <code>/=</code> operator, vs. <code>/=.../</code> regexp
constant</a>: <a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-patterns-and-893"><code>/</code>
(forward slash), patterns and</a>: <a href="#Expression-Patterns">Expression
Patterns</a></li>
-<li><a
href="#index-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-710"><code>/=</code>
operator vs. <code>/=.../</code> regexp constant</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-_0028_0040command_007bgawk_007d_0029-578"><code>/dev/...</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-1422"><code>/inet/</code>
files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a
href="#index-_0040code_007b_002fp_007d-files-_0028_0040command_007bgawk_007d_0029-1432"><code>/p</code>
files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Portal-Files">Portal Files</a></li>
-<li><a
href="#index-_0040code_007b_003b_007d-_0028semicolon_0029-163"><code>;</code>
(semicolon)</a>: <a href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1907"><code>;</code>
(semicolon), <code>AWKPATH</code> variable and</a>: <a href="#PC-Using">PC
Using</a></li>
-<li><a
href="#index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-948"><code>;</code>
(semicolon), separating statements in actions</a>: <a
href="#Statements">Statements</a></li>
-<li><a
href="#index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-936"><code>;</code>
(semicolon), separating statements in actions</a>: <a
href="#Action-Overview">Action Overview</a></li>
-<li><a
href="#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-837"><code><</code>
(left angle bracket), <code><</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-748"><code><</code>
(left angle bracket), <code><</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-464"><code><</code>
(left angle bracket), <code><</code> operator (I/O)</a>: <a
href="#Getline_002fFile">Getline/File</a></li>
-<li><a
href="#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-839"><code><</code>
(left angle bracket), <code><=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-750"><code><</code>
(left angle bracket), <code><=</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_007d-operator-673"><code>=</code>
(equals sign), <code>=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-845"><code>=</code>
(equals sign), <code>==</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-756"><code>=</code>
(equals sign), <code>==</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-843"><code>></code>
(right angle bracket), <code>></code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-754"><code>></code>
(right angle bracket), <code>></code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-548"><code>></code>
(right angle bracket), <code>></code> operator (I/O)</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-841"><code>></code>
(right angle bracket), <code>>=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-752"><code>></code>
(right angle bracket), <code>>=</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-849"><code>></code>
(right angle bracket), <code>>></code> operator (I/O)</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-551"><code>></code>
(right angle bracket), <code>>></code> operator (I/O)</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040code_007b_003f_007d-_0028question-mark_0029-307"><code>?</code>
(question mark)</a>: <a href="#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="#index-_0040code_007b_003f_007d-_0028question-mark_0029-247"><code>?</code>
(question mark)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_003f_007d-_0028question-mark_0029_002c-_0040code_007b_003f_003a_007d-operator-869"><code>?</code>
(question mark), <code>?:</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_005b_005d_007d-_0028square-brackets_0029-233"><code>[]</code>
(square brackets)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029-223"><code>\</code>
(backslash)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029-125"><code>\</code>
(backslash)</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029-120"><code>\</code>
(backslash)</a>: <a href="#Comments">Comments</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029-93"><code>\</code>
(backslash)</a>: <a href="#Read-Terminal">Read Terminal</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-207"><code>\</code>
(backslash), <code>\"</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-304"><code>\</code>
(backslash), <code>\'</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-205"><code>\</code>
(backslash), <code>\/</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-290"><code>\</code>
(backslash), <code>\<</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-292"><code>\</code>
(backslash), <code>\></code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-302"><code>\</code>
(backslash), <code>\`</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ca_007d-escape-sequence-187"><code>\</code>
(backslash), <code>\a</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cb_007d-escape-sequence-189"><code>\</code>
(backslash), <code>\b</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-297"><code>\</code>
(backslash), <code>\B</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cf_007d-escape-sequence-191"><code>\</code>
(backslash), <code>\f</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cn_007d-escape-sequence-193"><code>\</code>
(backslash), <code>\n</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-201"><code>\</code>
(backslash), <code>\</code><var>nnn</var> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cr_007d-escape-sequence-195"><code>\</code>
(backslash), <code>\r</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ct_007d-escape-sequence-197"><code>\</code>
(backslash), <code>\t</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cv_007d-escape-sequence-199"><code>\</code>
(backslash), <code>\v</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-288"><code>\</code>
(backslash), <code>\W</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-286"><code>\</code>
(backslash), <code>\w</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cx_007d-escape-sequence-203"><code>\</code>
(backslash), <code>\x</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-294"><code>\</code>
(backslash), <code>\y</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-as-field-separators-429"><code>\</code>
(backslash), as field separators</a>: <a
href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-1760"><code>\</code>
(backslash), continuing lines and</a>: <a href="#Egrep-Program">Egrep
Program</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-153"><code>\</code>
(backslash), continuing lines and</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-comments-and-160"><code>\</code>
(backslash), continuing lines and, comments and</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-158"><code>\</code>
(backslash), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-147"><code>\</code>
(backslash), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a href="#More-Complex">More
Complex</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1201"><code>\</code>
(backslash), <code>gsub</code>/<code>gensub</code>/<code>sub</code> functions
and</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-character-lists-259"><code>\</code>
(backslash), in character lists</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences-186"><code>\</code>
(backslash), in escape sequences</a>: <a href="#Escape-Sequences">Escape
Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences_002c-POSIX-and-215"><code>\</code>
(backslash), in escape sequences, POSIX and</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-regexp-constants-332"><code>\</code>
(backslash), regexp constants</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029-305"><code>^</code>
(caret)</a>: <a href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029-226"><code>^</code>
(caret)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-1537"><code>^</code>
(caret), <code>^</code> operator</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-817"><code>^</code>
(caret), <code>^</code> operator</a>: <a href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-1539"><code>^</code>
(caret), <code>^=</code> operator</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-883"><code>^</code>
(caret), <code>^=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-694"><code>^</code>
(caret), <code>^=</code> operator</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="#index-_0040code_007b_005e_007d-_0028caret_0029_002c-in-character-lists-261"><code>^</code>
(caret), in character lists</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a
href="#index-_0040code_007b_005f_007d-_0028underscore_0029_002c-_0040code_007b_005f_007d-C-macro-1324"><code>_</code>
(underscore), <code>_</code> C macro</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007b_005f_007d-_0028underscore_0029_002c-in-names-of-private-variables-1606"><code>_</code>
(underscore), in names of private variables</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a
href="#index-_0040code_007b_005f_007d-_0028underscore_0029_002c-translatable-string-1355"><code>_</code>
(underscore), translatable string</a>: <a href="#Programmer-i18n">Programmer
i18n</a></li>
-<li><a
href="#index-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1730"><code>_gr_init</code>
user-defined function</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007b_005fpw_005finit_007d-user_002ddefined-function-1706"><code>_pw_init</code>
user-defined function</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="#index-accessing-fields-378">accessing fields</a>: <a
href="#Fields">Fields</a></li>
-<li><a href="#index-account-information-1725">account information</a>: <a
href="#Group-Functions">Group Functions</a></li>
-<li><a href="#index-account-information-1699">account information</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-actions-931">actions</a>: <a
href="#Action-Overview">Action Overview</a></li>
-<li><a href="#index-actions_002c-control-statements-in-941">actions, control
statements in</a>: <a href="#Statements">Statements</a></li>
-<li><a href="#index-actions_002c-default-138">actions, default</a>: <a
href="#Very-Simple">Very Simple</a></li>
-<li><a href="#index-actions_002c-empty-140">actions, empty</a>: <a
href="#Very-Simple">Very Simple</a></li>
-<li><a
href="#index-adding_002c-features-to-_0040command_007bgawk_007d-1955">adding,
features to <samp><span class="command">gawk</span></samp></a>: <a
href="#Adding-Code">Adding Code</a></li>
-<li><a href="#index-adding_002c-fields-393">adding, fields</a>: <a
href="#Changing-Fields">Changing Fields</a></li>
-<li><a
href="#index-adding_002c-functions-to-_0040command_007bgawk_007d-1967">adding,
functions to <samp><span class="command">gawk</span></samp></a>: <a
href="#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a href="#index-advanced-features_002c-buffering-1222">advanced features,
buffering</a>: <a href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="#index-advanced-features_002c-_0040code_007bclose_007d-function-598">advanced
features, <code>close</code> function</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a
href="#index-advanced-features_002c-constants_0040comma_007b_007d-values-of-618">advanced
features, constants, values of</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-advanced-features_002c-_0040value_007bDF_007ds-as-single-record-370">advanced
features, data files as single record</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-advanced-features_002c-fixed_002dwidth-data-440">advanced
features, fixed-width data</a>: <a href="#Constant-Size">Constant Size</a></li>
-<li><a
href="#index-advanced-features_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1069">advanced
features, <code>FNR</code>/<code>NR</code> variables</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-advanced-features_002c-_0040command_007bgawk_007d-1397">advanced
features, <samp><span class="command">gawk</span></samp></a>: <a
href="#Advanced-Features">Advanced Features</a></li>
-<li><a
href="#index-advanced-features_002c-_0040command_007bgawk_007d_002c-BSD-portals-1428">advanced
features, <samp><span class="command">gawk</span></samp>, BSD portals</a>: <a
href="#Portal-Files">Portal Files</a></li>
-<li><a
href="#index-advanced-features_002c-_0040command_007bgawk_007d_002c-network-programming-1419">advanced
features, <samp><span class="command">gawk</span></samp>, network
programming</a>: <a href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a
href="#index-advanced-features_002c-_0040command_007bgawk_007d_002c-nondecimal-input-data-1399">advanced
features, <samp><span class="command">gawk</span></samp>, nondecimal input
data</a>: <a href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="#index-advanced-features_002c-_0040command_007bgawk_007d_002c-processes_0040comma_007b_007d-communicating-with-1407">advanced
features, <samp><span class="command">gawk</span></samp>, processes,
communicating with</a>: <a href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="#index-advanced-features_002c-network-connections_002c-See-Also-networks_002c-connections-1395">advanced
features, network connections, See Also networks, connections</a>: <a
href="#Advanced-Features">Advanced Features</a></li>
-<li><a
href="#index-advanced-features_002c-null-strings_0040comma_007b_007d-matching-1206">advanced
features, null strings, matching</a>: <a href="#Gory-Details">Gory
Details</a></li>
-<li><a
href="#index-advanced-features_002c-operators_0040comma_007b_007d-precedence-724">advanced
features, operators, precedence</a>: <a href="#Increment-Ops">Increment
Ops</a></li>
-<li><a
href="#index-advanced-features_002c-piping-into-_0040command_007bsh_007d-565">advanced
features, piping into <samp><span class="command">sh</span></samp></a>: <a
href="#Redirection">Redirection</a></li>
-<li><a href="#index-advanced-features_002c-regexp-constants-702">advanced
features, regexp constants</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a href="#index-Aho_002c-Alfred-1838">Aho, Alfred</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Aho_002c-Alfred-13">Aho, Alfred</a>: <a
href="#History">History</a></li>
-<li><a href="#index-alarm-clock-example-program-1794">alarm clock example
program</a>: <a href="#Alarm-Program">Alarm Program</a></li>
-<li><a
href="#index-_0040code_007balarm_002eawk_007d-program-1795"><code>alarm.awk</code>
program</a>: <a href="#Alarm-Program">Alarm Program</a></li>
-<li><a href="#index-algorithms-2029">algorithms</a>: <a
href="#Basic-High-Level">Basic High Level</a></li>
-<li><a href="#index-Alpha-_0028DEC_0029-42">Alpha (DEC)</a>: <a
href="#Manual-History">Manual History</a></li>
-<li><a
href="#index-amazing-_0040command_007bawk_007d-assembler-_0028_0040command_007baaa_007d_0029-2054">amazing
<samp><span class="command">awk</span></samp> assembler (<samp><span
class="command">aaa</span></samp>)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-amazingly-workable-formatter-_0028_0040command_007bawf_007d_0029-2055">amazingly
workable formatter (<samp><span class="command">awf</span></samp>)</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a
href="#index-ambiguity_002c-syntactic_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-708">ambiguity,
syntactic: <code>/=</code> operator vs. <code>/=.../</code> regexp
constant</a>: <a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-amiga-1896">amiga</a>: <a href="#Amiga-Installation">Amiga
Installation</a></li>
-<li><a
href="#index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007d-operator-787">ampersand
(<code>&</code>), <code>&&</code> operator</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007doperator-866">ampersand
(<code>&</code>), <code>&&</code>operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1204">ampersand
(<code>&</code>), <code>gsub</code>/<code>gensub</code>/<code>sub</code>
functions and</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a href="#index-AND-bitwise-operation-1246">AND bitwise operation</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-and-Boolean_002dlogic-operator-774">and Boolean-logic
operator</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-_0040code_007band_007d-function-_0028_0040command_007bgawk_007d_0029-1257"><code>and</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-ANSI-2057">ANSI</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-archeologists-1921">archeologists</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a
href="#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1071"><code>ARGC</code>/<code>ARGV</code>
variables</a>: <a href="#ARGC-and-ARGV">ARGC and ARGV</a></li>
-<li><a
href="#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1043"><code>ARGC</code>/<code>ARGV</code>
variables</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-command_002dline-arguments-1564"><code>ARGC</code>/<code>ARGV</code>
variables, command-line arguments</a>: <a href="#Other-Arguments">Other
Arguments</a></li>
-<li><a
href="#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-portability-and-111"><code>ARGC</code>/<code>ARGV</code>
variables, portability and</a>: <a href="#Executable-Scripts">Executable
Scripts</a></li>
-<li><a
href="#index-_0040code_007bARGIND_007d-variable-1047"><code>ARGIND</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040code_007bARGIND_007d-variable_002c-command_002dline-arguments-1563"><code>ARGIND</code>
variable, command-line arguments</a>: <a href="#Other-Arguments">Other
Arguments</a></li>
-<li><a href="#index-arguments_002c-command_002dline-1562">arguments,
command-line</a>: <a href="#Other-Arguments">Other Arguments</a></li>
-<li><a href="#index-arguments_002c-command_002dline-1072">arguments,
command-line</a>: <a href="#ARGC-and-ARGV">ARGC and ARGV</a></li>
-<li><a href="#index-arguments_002c-command_002dline-1044">arguments,
command-line</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-arguments_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1469">arguments,
command-line, invoking <samp><span class="command">awk</span></samp></a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a href="#index-arguments_002c-in-function-calls-806">arguments, in
function calls</a>: <a href="#Function-Calls">Function Calls</a></li>
-<li><a href="#index-arguments_002c-processing-1686">arguments, processing</a>:
<a href="#Getopt-Function">Getopt Function</a></li>
-<li><a href="#index-arguments_002c-retrieving-2002">arguments, retrieving</a>:
<a href="#Internals">Internals</a></li>
-<li><a href="#index-arithmetic-operators-652">arithmetic operators</a>: <a
href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a href="#index-arrays-1075">arrays</a>: <a href="#Arrays">Arrays</a></li>
-<li><a href="#index-arrays_002c-as-parameters-to-functions-1292">arrays, as
parameters to functions</a>: <a href="#Function-Caveats">Function
Caveats</a></li>
-<li><a href="#index-arrays_002c-associative-1084">arrays, associative</a>: <a
href="#Array-Intro">Array Intro</a></li>
-<li><a href="#index-arrays_002c-associative_002c-clearing-1987">arrays,
associative, clearing</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-arrays_002c-associative_002c-library-functions-and-1609">arrays,
associative, library functions and</a>: <a href="#Library-Names">Library
Names</a></li>
-<li><a href="#index-arrays_002c-deleting-entire-contents-1109">arrays,
deleting entire contents</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-arrays_002c-elements_002c-assigning-1094">arrays,
elements, assigning</a>: <a href="#Assigning-Elements">Assigning
Elements</a></li>
-<li><a href="#index-arrays_002c-elements_002c-deleting-1105">arrays, elements,
deleting</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-arrays_002c-elements_002c-installing-1989">arrays,
elements, installing</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-arrays_002c-elements_002c-order-of-1101">arrays, elements,
order of</a>: <a href="#Scanning-an-Array">Scanning an Array</a></li>
-<li><a href="#index-arrays_002c-elements_002c-referencing-1090">arrays,
elements, referencing</a>: <a href="#Reference-to-Elements">Reference to
Elements</a></li>
-<li><a
href="#index-arrays_002c-elements_002c-retrieving-number-of-1162">arrays,
elements, retrieving number of</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-arrays_002c-_0040code_007bfor_007d-statement-and-1099">arrays,
<code>for</code> statement and</a>: <a href="#Scanning-an-Array">Scanning an
Array</a></li>
-<li><a
href="#index-arrays_002c-_0040code_007bIGNORECASE_007d-variable-and-1088">arrays,
<code>IGNORECASE</code> variable and</a>: <a href="#Array-Intro">Array
Intro</a></li>
-<li><a href="#index-arrays_002c-indexing-1081">arrays, indexing</a>: <a
href="#Array-Intro">Array Intro</a></li>
-<li><a href="#index-arrays_002c-merging-into-strings-1656">arrays, merging
into strings</a>: <a href="#Join-Function">Join Function</a></li>
-<li><a href="#index-arrays_002c-multidimensional-1128">arrays,
multidimensional</a>: <a
href="#Multi_002ddimensional">Multi-dimensional</a></li>
-<li><a href="#index-arrays_002c-multidimensional_002c-scanning-1131">arrays,
multidimensional, scanning</a>: <a
href="#Multi_002dscanning">Multi-scanning</a></li>
-<li><a href="#index-arrays_002c-names-of-1078">arrays, names of</a>: <a
href="#Arrays">Arrays</a></li>
-<li><a href="#index-arrays_002c-scanning-1097">arrays, scanning</a>: <a
href="#Scanning-an-Array">Scanning an Array</a></li>
-<li><a href="#index-arrays_002c-sorting-1132">arrays, sorting</a>: <a
href="#Array-Sorting">Array Sorting</a></li>
-<li><a
href="#index-arrays_002c-sorting_002c-_0040code_007bIGNORECASE_007d-variable-and-1138">arrays,
sorting, <code>IGNORECASE</code> variable and</a>: <a
href="#Array-Sorting">Array Sorting</a></li>
-<li><a href="#index-arrays_002c-sparse-1086">arrays, sparse</a>: <a
href="#Array-Intro">Array Intro</a></li>
-<li><a href="#index-arrays_002c-subscripts-1116">arrays, subscripts</a>: <a
href="#Numeric-Array-Subscripts">Numeric Array Subscripts</a></li>
-<li><a
href="#index-arrays_002c-subscripts_002c-uninitialized-variables-as-1123">arrays,
subscripts, uninitialized variables as</a>: <a
href="#Uninitialized-Subscripts">Uninitialized Subscripts</a></li>
-<li><a
href="#index-artificial-intelligence_0040comma_007b_007d-_0040command_007bgawk_007d-and-1877">artificial
intelligence, <samp><span class="command">gawk</span></samp> and</a>: <a
href="#Distribution-contents">Distribution contents</a></li>
-<li><a href="#index-ASCII-1650">ASCII</a>: <a
href="#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="#index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1163"><code>asort</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1133"><code>asort</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Array-Sorting">Array Sorting</a></li>
-<li><a
href="#index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029_002c-arrays_0040comma_007b_007d-sorting-1134"><code>asort</code>
function (<samp><span class="command">gawk</span></samp>), arrays,
sorting</a>: <a href="#Array-Sorting">Array Sorting</a></li>
-<li><a
href="#index-_0040code_007basorti_007d-function-_0028_0040command_007bgawk_007d_0029-1164"><code>asorti</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bassert_007d-function-_0028C-library_0029-1621"><code>assert</code>
function (C library)</a>: <a href="#Assert-Function">Assert Function</a></li>
-<li><a
href="#index-_0040code_007bassert_007d-user_002ddefined-function-1625"><code>assert</code>
user-defined function</a>: <a href="#Assert-Function">Assert Function</a></li>
-<li><a href="#index-assertions-1620">assertions</a>: <a
href="#Assert-Function">Assert Function</a></li>
-<li><a href="#index-assignment-operators-670">assignment operators</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-assignment-operators_002c-evaluation-order-685">assignment
operators, evaluation order</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="#index-assignment-operators_002c-lvalues_002frvalues-678">assignment
operators, lvalues/rvalues</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a href="#index-assignments-as-filenames-1678">assignments as
filenames</a>: <a href="#Ignoring-Assigns">Ignoring Assigns</a></li>
-<li><a
href="#index-_0040code_007bassoc_005fclear_007d-internal-function-1988"><code>assoc_clear</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bassoc_005flookup_007d-internal-function-1990"><code>assoc_lookup</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-associative-arrays-1083">associative arrays</a>: <a
href="#Array-Intro">Array Intro</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-828">asterisk
(<code>*</code>), <code>*</code> operator, as multiplication operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-244">asterisk
(<code>*</code>), <code>*</code> operator, as regexp operator</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1210">asterisk
(<code>*</code>), <code>*</code> operator, null strings, matching</a>: <a
href="#Gory-Details">Gory Details</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-1534">asterisk
(<code>*</code>), <code>**</code> operator</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-820">asterisk
(<code>*</code>), <code>**</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-661">asterisk
(<code>*</code>), <code>**</code> operator</a>: <a
href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1536">asterisk
(<code>*</code>), <code>**=</code> operator</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-878">asterisk
(<code>*</code>), <code>**=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-697">asterisk
(<code>*</code>), <code>**=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-876">asterisk
(<code>*</code>), <code>*=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-689">asterisk
(<code>*</code>), <code>*=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-_0040code_007batan2_007d-function-1156"><code>atan2</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-atari-1915">atari</a>: <a href="#Atari-Installation">Atari
Installation</a></li>
-<li><a
href="#index-_0040command_007bawf_007d-_0028amazingly-workable-formatter_0029-program-2056"><samp><span
class="command">awf</span></samp> (amazingly workable formatter) program</a>:
<a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-language_002c-POSIX-version-698"><samp><span
class="command">awk</span></samp> language, POSIX version</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-_0040command_007bawk_007d-programs-143"><samp><span
class="command">awk</span></samp> programs</a>: <a href="#Two-Rules">Two
Rules</a></li>
-<li><a href="#index-_0040command_007bawk_007d-programs-104"><samp><span
class="command">awk</span></samp> programs</a>: <a
href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a href="#index-_0040command_007bawk_007d-programs-75"><samp><span
class="command">awk</span></samp> programs</a>: <a
href="#Getting-Started">Getting Started</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-complex-167"><samp><span
class="command">awk</span></samp> programs, complex</a>: <a
href="#When">When</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-documenting-1600"><samp><span
class="command">awk</span></samp> programs, documenting</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-documenting-116"><samp><span
class="command">awk</span></samp> programs, documenting</a>: <a
href="#Comments">Comments</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-examples-of-1741"><samp><span
class="command">awk</span></samp> programs, examples of</a>: <a
href="#Sample-Programs">Sample Programs</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-execution-of-971"><samp><span
class="command">awk</span></samp> programs, execution of</a>: <a
href="#Next-Statement">Next Statement</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-internationalizing-1342"><samp><span
class="command">awk</span></samp> programs, internationalizing</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-internationalizing-1271"><samp><span
class="command">awk</span></samp> programs, internationalizing</a>: <a
href="#I18N-Functions">I18N Functions</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-lengthy-96"><samp><span
class="command">awk</span></samp> programs, lengthy</a>: <a
href="#Long">Long</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-lengthy_002c-assertions-1624"><samp><span
class="command">awk</span></samp> programs, lengthy, assertions</a>: <a
href="#Assert-Function">Assert Function</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-location-of-1487"><samp><span
class="command">awk</span></samp> programs, location of</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-one_002dline-examples-141"><samp><span
class="command">awk</span></samp> programs, one-line examples</a>: <a
href="#Very-Simple">Very Simple</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-profiling-1438"><samp><span
class="command">awk</span></samp> programs, profiling</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-profiling_002c-enabling-1546"><samp><span
class="command">awk</span></samp> programs, profiling, enabling</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-running-95"><samp><span
class="command">awk</span></samp> programs, running</a>: <a
href="#Long">Long</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-running-78"><samp><span
class="command">awk</span></samp> programs, running</a>: <a
href="#Running-gawk">Running gawk</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-running_002c-from-shell-scripts-83"><samp><span
class="command">awk</span></samp> programs, running, from shell scripts</a>:
<a href="#One_002dshot">One-shot</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-running_002c-without-input-files-89"><samp><span
class="command">awk</span></samp> programs, running, without input files</a>:
<a href="#Read-Terminal">Read Terminal</a></li>
-<li><a
href="#index-_0040command_007bawk_007d-programs_002c-shell-variables-in-929"><samp><span
class="command">awk</span></samp> programs, shell variables in</a>: <a
href="#Using-Shell-Variables">Using Shell Variables</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-function-of-72"><samp><span
class="command">awk</span></samp>, function of</a>: <a
href="#Getting-Started">Getting Started</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-26"><samp><span
class="command">awk</span></samp>, <samp><span
class="command">gawk</span></samp> and</a>: <a href="#This-Manual">This
Manual</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-5"><samp><span
class="command">awk</span></samp>, <samp><span
class="command">gawk</span></samp> and</a>: <a href="#Preface">Preface</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-history-of-16"><samp><span
class="command">awk</span></samp>, history of</a>: <a
href="#History">History</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-implementation-issues_002c-pipes-563"><samp><span
class="command">awk</span></samp>, implementation issues, pipes</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-implementations-1936"><samp><span
class="command">awk</span></samp>, implementations</a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-implementations_002c-limits-490"><samp><span
class="command">awk</span></samp>, implementations, limits</a>: <a
href="#Getline-Notes">Getline Notes</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-invoking-1468"><samp><span
class="command">awk</span></samp>, invoking</a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-new-vs_002e-old-20"><samp><span
class="command">awk</span></samp>, new vs. old</a>: <a
href="#Names">Names</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-new-vs_002e-old_002c-_0040code_007bOFMT_007d-variable-651"><samp><span
class="command">awk</span></samp>, new vs. old, <code>OFMT</code>
variable</a>: <a href="#Conversion">Conversion</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-POSIX-and-2"><samp><span
class="command">awk</span></samp>, POSIX and</a>: <a
href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-POSIX-and_002c-See-Also-POSIX-_0040command_007bawk_007d-1"><samp><span
class="command">awk</span></samp>, POSIX and, See Also POSIX <samp><span
class="command">awk</span></samp></a>: <a href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-regexp-constants-and-772"><samp><span
class="command">awk</span></samp>, regexp constants and</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-See-Also-_0040command_007bgawk_007d-7"><samp><span
class="command">awk</span></samp>, See Also <samp><span
class="command">gawk</span></samp></a>: <a href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-terms-describing-24"><samp><span
class="command">awk</span></samp>, terms describing</a>: <a
href="#This-Manual">This Manual</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-uses-for-166"><samp><span
class="command">awk</span></samp>, uses for</a>: <a href="#When">When</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-uses-for-73"><samp><span
class="command">awk</span></samp>, uses for</a>: <a
href="#Getting-Started">Getting Started</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-uses-for-6"><samp><span
class="command">awk</span></samp>, uses for</a>: <a
href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-versions-of-1824"><samp><span
class="command">awk</span></samp>, versions of</a>: <a
href="#V7_002fSVR3_002e1">V7/SVR3.1</a></li>
-<li><a href="#index-_0040command_007bawk_007d_002c-versions-of-21"><samp><span
class="command">awk</span></samp>, versions of</a>: <a
href="#Names">Names</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR3_002e1-and-SVR4-1826"><samp><span
class="command">awk</span></samp>, versions of, changes between SVR3.1 and
SVR4</a>: <a href="#SVR4">SVR4</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR4-and-POSIX-_0040command_007bawk_007d-1827"><samp><span
class="command">awk</span></samp>, versions of, changes between SVR4 and POSIX
<samp><span class="command">awk</span></samp></a>: <a
href="#POSIX">POSIX</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-V7-and-SVR3_002e1-1825"><samp><span
class="command">awk</span></samp>, versions of, changes between V7 and
SVR3.1</a>: <a href="#V7_002fSVR3_002e1">V7/SVR3.1</a></li>
-<li><a
href="#index-_0040command_007bawk_007d_002c-versions-of_002c-See-Also-Bell-Laboratories-_0040command_007bawk_007d-1829"><samp><span
class="command">awk</span></samp>, versions of, See Also Bell Laboratories
<samp><span class="command">awk</span></samp></a>: <a href="#BTL">BTL</a></li>
-<li><a
href="#index-_0040code_007bawk_002eh_007d-file-_0028internal_0029-1970"><code>awk.h</code>
file (internal)</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040command_007bawka_007d-compiler-for-_0040command_007bawk_007d-1945"><samp><span
class="command">awka</span></samp> compiler for <samp><span
class="command">awk</span></samp></a>: <a href="#Other-Versions">Other
Versions</a></li>
-<li><a
href="#index-_0040code_007bAWKNUM_007d-internal-type-1973"><code>AWKNUM</code>
internal type</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bAWKPATH_007d-environment-variable-1909"><code>AWKPATH</code>
environment variable</a>: <a href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-_0040env_007bAWKPATH_007d-environment-variable-1568"><samp><span
class="env">AWKPATH</span></samp> environment variable</a>: <a
href="#AWKPATH-Variable">AWKPATH Variable</a></li>
-<li><a
href="#index-_0040code_007bawkprof_002eout_007d-file-1442"><code>awkprof.out</code>
file</a>: <a href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040command_007bawksed_002eawk_007d-program-1816"><samp><span
class="command">awksed.awk</span></samp> program</a>: <a
href="#Simple-Sed">Simple Sed</a></li>
-<li><a
href="#index-_0040code_007bawkvars_002eout_007d-file-1507"><code>awkvars.out</code>
file</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029-222">backslash
(<code>\</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029-126">backslash
(<code>\</code>)</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029-121">backslash
(<code>\</code>)</a>: <a href="#Comments">Comments</a></li>
-<li><a href="#index-backslash-_0028_0040code_007b_005c_007d_0029-94">backslash
(<code>\</code>)</a>: <a href="#Read-Terminal">Read Terminal</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-208">backslash
(<code>\</code>), <code>\"</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-303">backslash
(<code>\</code>), <code>\'</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-206">backslash
(<code>\</code>), <code>\/</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-289">backslash
(<code>\</code>), <code>\<</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-291">backslash
(<code>\</code>), <code>\></code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-301">backslash
(<code>\</code>), <code>\`</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ca_007d-escape-sequence-188">backslash
(<code>\</code>), <code>\a</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cb_007d-escape-sequence-190">backslash
(<code>\</code>), <code>\b</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-296">backslash
(<code>\</code>), <code>\B</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cf_007d-escape-sequence-192">backslash
(<code>\</code>), <code>\f</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cn_007d-escape-sequence-194">backslash
(<code>\</code>), <code>\n</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-202">backslash
(<code>\</code>), <code>\</code><var>nnn</var> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cr_007d-escape-sequence-196">backslash
(<code>\</code>), <code>\r</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ct_007d-escape-sequence-198">backslash
(<code>\</code>), <code>\t</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cv_007d-escape-sequence-200">backslash
(<code>\</code>), <code>\v</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-287">backslash
(<code>\</code>), <code>\W</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-285">backslash
(<code>\</code>), <code>\w</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cx_007d-escape-sequence-204">backslash
(<code>\</code>), <code>\x</code> escape sequence</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-293">backslash
(<code>\</code>), <code>\y</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-as-field-separators-430">backslash
(<code>\</code>), as field separators</a>: <a
href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-1761">backslash
(<code>\</code>), continuing lines and</a>: <a href="#Egrep-Program">Egrep
Program</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-154">backslash
(<code>\</code>), continuing lines and</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-comments-and-159">backslash
(<code>\</code>), continuing lines and, comments and</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-157">backslash
(<code>\</code>), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-146">backslash
(<code>\</code>), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a href="#More-Complex">More
Complex</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1202">backslash
(<code>\</code>), <code>gsub</code>/<code>gensub</code>/<code>sub</code>
functions and</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-character-lists-260">backslash
(<code>\</code>), in character lists</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences-185">backslash
(<code>\</code>), in escape sequences</a>: <a href="#Escape-Sequences">Escape
Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences_002c-POSIX-and-214">backslash
(<code>\</code>), in escape sequences, POSIX and</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-regexp-constants-333">backslash
(<code>\</code>), regexp constants</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a
href="#index-_0040code_007bBBS_002dlist_007d-file-136"><code>BBS-list</code>
file</a>: <a href="#Sample-Data-Files">Sample Data Files</a></li>
-<li><a href="#index-Beebe_002c-Nelson-56">Beebe, Nelson</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Beebe_002c-Nelson-H_002eF_002e_0040_003a-1947">Beebe,
Nelson H.F.</a>: <a href="#Other-Versions">Other Versions</a></li>
-<li><a href="#index-_0040code_007bBEGIN_007d-pattern-912"><code>BEGIN</code>
pattern</a>: <a href="#BEGIN_002fEND">BEGIN/END</a></li>
-<li><a href="#index-_0040code_007bBEGIN_007d-pattern-407"><code>BEGIN</code>
pattern</a>: <a href="#Field-Separators">Field Separators</a></li>
-<li><a href="#index-_0040code_007bBEGIN_007d-pattern-356"><code>BEGIN</code>
pattern</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1627"><code>BEGIN</code>
pattern, <code>assert</code> user-defined function and</a>: <a
href="#Assert-Function">Assert Function</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-Boolean-patterns-and-902"><code>BEGIN</code>
pattern, Boolean patterns and</a>: <a href="#Expression-Patterns">Expression
Patterns</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bexit_007d-statement-and-986"><code>BEGIN</code>
pattern, <code>exit</code> statement and</a>: <a href="#Exit-Statement">Exit
Statement</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bgetline_007d-and-496"><code>BEGIN</code>
pattern, <code>getline</code> and</a>: <a href="#Getline-Notes">Getline
Notes</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-headings_0040comma_007b_007d-adding-509"><code>BEGIN</code>
pattern, headings, adding</a>: <a href="#Print-Examples">Print
Examples</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-972"><code>BEGIN</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#Next-Statement">Next Statement</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-924"><code>BEGIN</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bOFS_007d_002f_0040code_007bORS_007d-variables_002c-assigning-values-to-518"><code>BEGIN</code>
pattern, <code>OFS</code>/<code>ORS</code> variables, assigning values to</a>:
<a href="#Output-Separators">Output Separators</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-operators-and-914"><code>BEGIN</code>
pattern, operators and</a>: <a href="#Using-BEGIN_002fEND">Using
BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040command_007bpgawk_007d-program-1446"><code>BEGIN</code>
pattern, <samp><span class="command">pgawk</span></samp> program</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bprint_007d-statement-and-920"><code>BEGIN</code>
pattern, <code>print</code> statement and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bpwcat_007d-program-1707"><code>BEGIN</code>
pattern, <code>pwcat</code> program</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-running-_0040command_007bawk_007d-programs-and-1748"><code>BEGIN</code>
pattern, running <samp><span class="command">awk</span></samp> programs
and</a>: <a href="#Cut-Program">Cut Program</a></li>
-<li><a
href="#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bTEXTDOMAIN_007d-variable-and-1353"><code>BEGIN</code>
pattern, <code>TEXTDOMAIN</code> variable and</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040code_007bbeginfile_007d-user_002ddefined-function-1668"><code>beginfile</code>
user-defined function</a>: <a href="#Filetrans-Function">Filetrans
Function</a></li>
-<li><a
href="#index-Bell-Laboratories-_0040command_007bawk_007d-extensions-1831">Bell
Laboratories <samp><span class="command">awk</span></samp> extensions</a>: <a
href="#BTL">BTL</a></li>
-<li><a href="#index-Benzinger_002c-Michael-1866">Benzinger, Michael</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-BeOS-1898">BeOS</a>: <a href="#BeOS-Installation">BeOS
Installation</a></li>
-<li><a href="#index-Berry_002c-Karl-45">Berry, Karl</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-binary-input_002foutput-996">binary input/output</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bbindtextdomain_007d-function-_0028C-library_0029-1318"><code>bindtextdomain</code>
function (C library)</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="#index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1352"><code>bindtextdomain</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1274"><code>bindtextdomain</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#I18N-Functions">I18N Functions</a></li>
-<li><a
href="#index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1379"><code>bindtextdomain</code>
function (<samp><span class="command">gawk</span></samp>), portability
and</a>: <a href="#I18N-Portability">I18N Portability</a></li>
-<li><a
href="#index-_0040code_007bBINMODE_007d-variable-1911"><code>BINMODE</code>
variable</a>: <a href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-_0040code_007bBINMODE_007d-variable-995"><code>BINMODE</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bbits2str_007d-user_002ddefined-function-1263"><code>bits2str</code>
user-defined function</a>: <a href="#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="#index-bitwise_002c-complement-1250">bitwise, complement</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-bitwise_002c-operations-1245">bitwise, operations</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-bitwise_002c-shift-1252">bitwise, shift</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-body_002c-in-actions-944">body, in actions</a>: <a
href="#Statements">Statements</a></li>
-<li><a href="#index-body_002c-in-loops-954">body, in loops</a>: <a
href="#While-Statement">While Statement</a></li>
-<li><a href="#index-Boolean-expressions-778">Boolean expressions</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-Boolean-expressions_002c-as-patterns-901">Boolean
expressions, as patterns</a>: <a href="#Expression-Patterns">Expression
Patterns</a></li>
-<li><a
href="#index-Boolean-operators_002c-See-Boolean-expressions-780">Boolean
operators, See Boolean expressions</a>: <a href="#Boolean-Ops">Boolean
Ops</a></li>
-<li><a href="#index-Bourne-shell_002c-quoting-rules-for-124">Bourne shell,
quoting rules for</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-actions-and-933">braces
(<code>{}</code>), actions and</a>: <a href="#Action-Overview">Action
Overview</a></li>
-<li><a
href="#index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-_0040command_007bpgawk_007d-program-1453">braces
(<code>{}</code>), <samp><span class="command">pgawk</span></samp>
program</a>: <a href="#Profiling">Profiling</a></li>
-<li><a
href="#index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-statements_002c-grouping-946">braces
(<code>{}</code>), statements, grouping</a>: <a
href="#Statements">Statements</a></li>
-<li><a href="#index-bracket-expressions_002c-See-character-lists-237">bracket
expressions, See character lists</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="#index-_0040code_007bbreak_007d-statement-961"><code>break</code>
statement</a>: <a href="#Break-Statement">Break Statement</a></li>
-<li><a href="#index-Brennan_002c-Michael-1937">Brennan, Michael</a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a href="#index-Brennan_002c-Michael-1815">Brennan, Michael</a>: <a
href="#Simple-Sed">Simple Sed</a></li>
-<li><a href="#index-Brennan_002c-Michael-1405">Brennan, Michael</a>: <a
href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="#index-Brennan_002c-Michael-1113">Brennan, Michael</a>: <a
href="#Delete">Delete</a></li>
-<li><a href="#index-Broder_002c-Alan-J_002e_0040_003a-1863">Broder, Alan
J.</a>: <a href="#Contributors">Contributors</a></li>
-<li><a href="#index-Brown_002c-Martin-1930">Brown, Martin</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Brown_002c-Martin-1861">Brown, Martin</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Brown_002c-Martin-57">Brown, Martin</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-BSD-portals-1431">BSD portals</a>: <a
href="#Portal-Files">Portal Files</a></li>
-<li><a href="#index-BSD_002dbased-operating-systems-2083">BSD-based operating
systems</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-Buening_002c-Andreas-1864">Buening, Andreas</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Buening_002c-Andreas-58">Buening, Andreas</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-buffering_002c-input_002foutput-1415">buffering,
input/output</a>: <a href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="#index-buffering_002c-input_002foutput-1226">buffering,
input/output</a>: <a href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="#index-buffering_002c-interactive-vs_002e-noninteractive-1223">buffering,
interactive vs. noninteractive</a>: <a href="#I_002fO-Functions">I/O
Functions</a></li>
-<li><a href="#index-buffers_002c-flushing-1215">buffers, flushing</a>: <a
href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a href="#index-buffers_002c-operators-for-298">buffers, operators
for</a>: <a href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-bug-reports_002c-email-address_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1926">bug
reports, email address, <code>address@hidden</code></a>: <a
href="#Bugs">Bugs</a></li>
-<li><a
href="#index-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-bug-reporting-address-1924"><code>address@hidden</code>
bug reporting address</a>: <a href="#Bugs">Bugs</a></li>
-<li><a href="#index-built_002din-functions-1141">built-in functions</a>: <a
href="#Functions">Functions</a></li>
-<li><a
href="#index-built_002din-functions_002c-evaluation-order-1149">built-in
functions, evaluation order</a>: <a href="#Calling-Built_002din">Calling
Built-in</a></li>
-<li><a href="#index-built_002din-variables-990">built-in variables</a>: <a
href="#Built_002din-Variables">Built-in Variables</a></li>
-<li><a
href="#index-built_002din-variables_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1491">built-in
variables, <code>-v</code> option, setting with</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-built_002din-variables_002c-conveying-information-1041">built-in
variables, conveying information</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-built_002din-variables_002c-user_002dmodifiable-993">built-in
variables, user-modifiable</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-call-by-reference-1291">call by reference</a>: <a
href="#Function-Caveats">Function Caveats</a></li>
-<li><a href="#index-call-by-value-1290">call by value</a>: <a
href="#Function-Caveats">Function Caveats</a></li>
-<li><a href="#index-caret-_0028_0040code_007b_005e_007d_0029-306">caret
(<code>^</code>)</a>: <a href="#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a href="#index-caret-_0028_0040code_007b_005e_007d_0029-227">caret
(<code>^</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-1538">caret
(<code>^</code>), <code>^</code> operator</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-818">caret
(<code>^</code>), <code>^</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-1540">caret
(<code>^</code>), <code>^=</code> operator</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-884">caret
(<code>^</code>), <code>^=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-695">caret
(<code>^</code>), <code>^=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-caret-_0028_0040code_007b_005e_007d_0029_002c-in-character-lists-262">caret
(<code>^</code>), in character lists</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-_0040code_007bcase_007d-keyword-959"><code>case</code>
keyword</a>: <a href="#Switch-Statement">Switch Statement</a></li>
-<li><a href="#index-case-sensitivity_002c-array-indices-and-1087">case
sensitivity, array indices and</a>: <a href="#Array-Intro">Array Intro</a></li>
-<li><a href="#index-case-sensitivity_002c-converting-case-1193">case
sensitivity, converting case</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a href="#index-case-sensitivity_002c-example-programs-1595">case
sensitivity, example programs</a>: <a href="#Library-Functions">Library
Functions</a></li>
-<li><a href="#index-case-sensitivity_002c-_0040command_007bgawk_007d-317">case
sensitivity, <samp><span class="command">gawk</span></samp></a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a href="#index-case-sensitivity_002c-regexps-and-1016">case sensitivity,
regexps and</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-case-sensitivity_002c-regexps-and-315">case sensitivity,
regexps and</a>: <a href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a href="#index-case-sensitivity_002c-string-comparisons-and-1015">case
sensitivity, string comparisons and</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-character-encodings-1649">character encodings</a>: <a
href="#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a href="#index-character-lists-256">character lists</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a href="#index-character-lists-235">character lists</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a href="#index-character-lists_002c-character-classes-269">character
lists, character classes</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-character-lists_002c-collating-elements-271">character
lists, collating elements</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-character-lists_002c-collating-symbols-274">character
lists, collating symbols</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-character-lists_002c-complemented-238">character lists,
complemented</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a href="#index-character-lists_002c-equivalence-classes-276">character
lists, equivalence classes</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-character-lists_002c-non_002dASCII-272">character lists,
non-ASCII</a>: <a href="#Character-Lists">Character Lists</a></li>
-<li><a href="#index-character-lists_002c-range-expressions-257">character
lists, range expressions</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-character-sets-1648">character sets</a>: <a
href="#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="#index-character-sets-_0028machine-character-encodings_0029-2060">character
sets (machine character encodings)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-character-sets_002c-See-Also-character-lists-236">character sets,
See Also character lists</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="#index-characters_002c-counting-1782">characters, counting</a>:
<a href="#Wc-Program">Wc Program</a></li>
-<li><a href="#index-characters_002c-transliterating-1797">characters,
transliterating</a>: <a href="#Translate-Program">Translate Program</a></li>
-<li><a href="#index-characters_002c-values-of-as-numbers-1644">characters,
values of as numbers</a>: <a href="#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a href="#index-Chassell_002c-Robert-J_002e_0040_003a-46">Chassell, Robert
J.</a>: <a href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-_0040code_007bchdir_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2011"><code>chdir</code>
function, implementing in <samp><span class="command">gawk</span></samp></a>:
<a href="#Sample-Library">Sample Library</a></li>
-<li><a href="#index-_0040command_007bchem_007d-utility-2061"><samp><span
class="command">chem</span></samp> utility</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a
href="#index-_0040code_007bchr_007d-user_002ddefined-function-1647"><code>chr</code>
user-defined function</a>: <a href="#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a href="#index-Cliff-random-numbers-1638">Cliff random numbers</a>: <a
href="#Cliff-Random-Function">Cliff Random Function</a></li>
-<li><a
href="#index-_0040code_007bcliff_005frand_007d-user_002ddefined-function-1641"><code>cliff_rand</code>
user-defined function</a>: <a href="#Cliff-Random-Function">Cliff Random
Function</a></li>
-<li><a href="#index-_0040code_007bclose_007d-function-1211"><code>close</code>
function</a>: <a href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a href="#index-_0040code_007bclose_007d-function-594"><code>close</code>
function</a>: <a href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a href="#index-_0040code_007bclose_007d-function-475"><code>close</code>
function</a>: <a href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-_0040code_007bclose_007d-function-469"><code>close</code>
function</a>: <a
href="#Getline_002fVariable_002fFile">Getline/Variable/File</a></li>
-<li><a
href="#index-_0040code_007bclose_007d-function_002c-return-values-600"><code>close</code>
function, return values</a>: <a href="#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="#index-_0040code_007bclose_007d-function_002c-two_002dway-pipes-and-1417"><code>close</code>
function, two-way pipes and</a>: <a href="#Two_002dway-I_002fO">Two-way
I/O</a></li>
-<li><a href="#index-Close_002c-Diane-1843">Close, Diane</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Close_002c-Diane-43">Close, Diane</a>: <a
href="#Manual-History">Manual History</a></li>
-<li><a href="#index-collating-elements-273">collating elements</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a href="#index-collating-symbols-275">collating symbols</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a href="#index-columns_002c-aligning-511">columns, aligning</a>: <a
href="#Print-Examples">Print Examples</a></li>
-<li><a href="#index-columns_002c-cutting-1746">columns, cutting</a>: <a
href="#Cut-Program">Cut Program</a></li>
-<li><a
href="#index-comma-_0028_0040code_007b_002c_007d_0029_002c-in-range-patterns-908">comma
(<code>,</code>), in range patterns</a>: <a href="#Ranges">Ranges</a></li>
-<li><a href="#index-command-line_002c-arguments-1561">command line,
arguments</a>: <a href="#Other-Arguments">Other Arguments</a></li>
-<li><a href="#index-command-line_002c-arguments-1073">command line,
arguments</a>: <a href="#ARGC-and-ARGV">ARGC and ARGV</a></li>
-<li><a href="#index-command-line_002c-arguments-1045">command line,
arguments</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-command-line_002c-formats-79">command line, formats</a>:
<a href="#Running-gawk">Running gawk</a></li>
-<li><a
href="#index-command-line_002c-_0040code_007bFS_007d-on_0040comma_007b_007d-setting-427">command
line, <code>FS</code> on, setting</a>: <a
href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a
href="#index-command-line_002c-invoking-_0040command_007bawk_007d-from-1467">command
line, invoking <samp><span class="command">awk</span></samp> from</a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a href="#index-command-line_002c-options-1478">command line, options</a>:
<a href="#Options">Options</a></li>
-<li><a href="#index-command-line_002c-options-425">command line, options</a>:
<a href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a href="#index-command-line_002c-options-99">command line, options</a>:
<a href="#Long">Long</a></li>
-<li><a href="#index-command-line_002c-options_002c-end-of-1496">command line,
options, end of</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-command-line_002c-variables_0040comma_007b_007d-assigning-on-637">command
line, variables, assigning on</a>: <a href="#Assignment-Options">Assignment
Options</a></li>
-<li><a
href="#index-command_002dline-options_002c-processing-1683">command-line
options, processing</a>: <a href="#Getopt-Function">Getopt Function</a></li>
-<li><a
href="#index-command_002dline-options_002c-string-extraction-1365">command-line
options, string extraction</a>: <a href="#String-Extraction">String
Extraction</a></li>
-<li><a href="#index-commenting-115">commenting</a>: <a
href="#Comments">Comments</a></li>
-<li><a
href="#index-commenting_002c-backslash-continuation-and-161">commenting,
backslash continuation and</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040code_007bcomp_002elang_002eawk_007d-newsgroup-1928"><code>comp.lang.awk</code>
newsgroup</a>: <a href="#Bugs">Bugs</a></li>
-<li><a href="#index-comparison-expressions-737">comparison expressions</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-comparison-expressions_002c-as-patterns-891">comparison
expressions, as patterns</a>: <a href="#Expression-Patterns">Expression
Patterns</a></li>
-<li><a
href="#index-comparison-expressions_002c-string-vs_002e-regexp-767">comparison
expressions, string vs. regexp</a>: <a href="#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-extensions-1833">compatibility
mode (<samp><span class="command">gawk</span></samp>), extensions</a>: <a
href="#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-_0040value_007bFN_007ds-585">compatibility
mode (<samp><span class="command">gawk</span></samp>), file names</a>: <a
href="#Special-Caveats">Special Caveats</a></li>
-<li><a
href="#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-hexadecimal-numbers-617">compatibility
mode (<samp><span class="command">gawk</span></samp>), hexadecimal
numbers</a>: <a href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-octal-numbers-616">compatibility
mode (<samp><span class="command">gawk</span></samp>), octal numbers</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-specifying-1502">compatibility
mode (<samp><span class="command">gawk</span></samp>), specifying</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-compiled-programs-2062">compiled programs</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-compiled-programs-2026">compiled programs</a>: <a
href="#Basic-High-Level">Basic High Level</a></li>
-<li><a
href="#index-_0040code_007bcompl_007d-function-_0028_0040command_007bgawk_007d_0029-1260"><code>compl</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-complement_002c-bitwise-1251">complement, bitwise</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="#index-compound-statements_0040comma_007b_007d-control-statements-and-942">compound
statements, control statements and</a>: <a
href="#Statements">Statements</a></li>
-<li><a href="#index-concatenating-665">concatenating</a>: <a
href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-conditional-expressions-797">conditional expressions</a>:
<a href="#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="#index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dlint_007d-1891">configuration
option, <code>--disable-lint</code></a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dnls_007d-1893">configuration
option, <code>--disable-nls</code></a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-configuration-option_002c-_0040code_007b_002d_002denable_002dportals_007d-1882">configuration
option, <code>--enable-portals</code></a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-configuration-option_002c-_0040code_007b_002d_002denable_002dswitch_007d-1884">configuration
option, <code>--enable-switch</code></a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1889">configuration
option, <code>--with-included-gettext</code></a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1394">configuration
option, <code>--with-included-gettext</code></a>: <a href="#Gawk-I18N">Gawk
I18N</a></li>
-<li><a
href="#index-configuration-options_0040comma_007b_007d-_0040command_007bgawk_007d-1880">configuration
options, <samp><span class="command">gawk</span></samp></a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a href="#index-constants_002c-nondecimal-1401">constants, nondecimal</a>:
<a href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a href="#index-constants_002c-types-of-605">constants, types of</a>: <a
href="#Constants">Constants</a></li>
-<li><a
href="#index-_0040code_007bcontinue_007d-statement-966"><code>continue</code>
statement</a>: <a href="#Continue-Statement">Continue Statement</a></li>
-<li><a href="#index-control-statements-939">control statements</a>: <a
href="#Statements">Statements</a></li>
-<li><a href="#index-converting_002c-case-1194">converting, case</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a href="#index-converting_002c-dates-to-timestamps-1239">converting,
dates to timestamps</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-converting_002c-during-subscripting-1119">converting,
during subscripting</a>: <a href="#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a href="#index-converting_002c-numbers-643">converting, numbers</a>: <a
href="#Conversion">Conversion</a></li>
-<li><a href="#index-converting_002c-numbers_002c-to-strings-1267">converting,
numbers, to strings</a>: <a href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-converting_002c-strings-to-numbers-640">converting,
strings to numbers</a>: <a href="#Conversion">Conversion</a></li>
-<li><a
href="#index-_0040code_007bCONVFMT_007d-variable-999"><code>CONVFMT</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bCONVFMT_007d-variable-646"><code>CONVFMT</code>
variable</a>: <a href="#Conversion">Conversion</a></li>
-<li><a
href="#index-_0040code_007bCONVFMT_007d-variable_002c-array-subscripts-and-1118"><code>CONVFMT</code>
variable, array subscripts and</a>: <a
href="#Numeric-Array-Subscripts">Numeric Array Subscripts</a></li>
-<li><a href="#index-coprocesses-1409">coprocesses</a>: <a
href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="#index-coprocesses-556">coprocesses</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a href="#index-coprocesses_002c-closing-592">coprocesses, closing</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a
href="#index-coprocesses_002c-_0040code_007bgetline_007d-from-481">coprocesses,
<code>getline</code> from</a>: <a
href="#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a href="#index-_0040code_007bcos_007d-function-1155"><code>cos</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-counting-1779">counting</a>: <a href="#Wc-Program">Wc
Program</a></li>
-<li><a href="#index-_0040command_007bcsh_007d-utility-156"><samp><span
class="command">csh</span></samp> utility</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040command_007bcsh_007d-utility_002c-backslash-continuation-and-144"><samp><span
class="command">csh</span></samp> utility, backslash continuation and</a>: <a
href="#More-Complex">More Complex</a></li>
-<li><a
href="#index-_0040command_007bcsh_007d-utility_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1559"><samp><span
class="command">csh</span></samp> utility, <code>POSIXLY_CORRECT</code>
environment variable</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040command_007bcsh_007d-utility_002c-_0040code_007b_007c_0026_007d-operator_002c-comparison-with-1413"><samp><span
class="command">csh</span></samp> utility, <code>|&</code> operator,
comparison with</a>: <a href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="#index-_0040code_007bctime_007d-user_002ddefined-function-1288"><code>ctime</code>
user-defined function</a>: <a href="#Function-Example">Function
Example</a></li>
-<li><a href="#index-currency-symbols_002c-localization-1334">currency symbols,
localization</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bcustom_002eh_007d-file-1895"><code>custom.h</code>
file</a>: <a href="#Configuration-Philosophy">Configuration Philosophy</a></li>
-<li><a href="#index-_0040command_007bcut_007d-utility-1743"><samp><span
class="command">cut</span></samp> utility</a>: <a href="#Cut-Program">Cut
Program</a></li>
-<li><a
href="#index-_0040code_007bcut_002eawk_007d-program-1747"><code>cut.awk</code>
program</a>: <a href="#Cut-Program">Cut Program</a></li>
-<li><a href="#index-d_002ec_002e_002c-See-dark-corner-30">d.c., See dark
corner</a>: <a href="#Conventions">Conventions</a></li>
-<li><a href="#index-dark-corner-2063">dark corner</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-dark-corner-736">dark corner</a>: <a
href="#Truth-Values">Truth Values</a></li>
-<li><a href="#index-dark-corner-707">dark corner</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-dark-corner-541">dark corner</a>: <a
href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a href="#index-dark-corner-31">dark corner</a>: <a
href="#Conventions">Conventions</a></li>
-<li><a href="#index-dark-corner_002c-array-subscripts-1125">dark corner, array
subscripts</a>: <a href="#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bbreak_007d-statement-964">dark
corner, <code>break</code> statement</a>: <a href="#Break-Statement">Break
Statement</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bclose_007d-function-599">dark
corner, <code>close</code> function</a>: <a href="#Close-Files-And-Pipes">Close
Files And Pipes</a></li>
-<li><a href="#index-dark-corner_002c-command_002dline-arguments-639">dark
corner, command-line arguments</a>: <a href="#Assignment-Options">Assignment
Options</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bcontinue_007d-statement-968">dark
corner, <code>continue</code> statement</a>: <a
href="#Continue-Statement">Continue Statement</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bCONVFMT_007d-variable-647">dark
corner, <code>CONVFMT</code> variable</a>: <a
href="#Conversion">Conversion</a></li>
-<li><a href="#index-dark-corner_002c-escape-sequences-1566">dark corner,
escape sequences</a>: <a href="#Other-Arguments">Other Arguments</a></li>
-<li><a
href="#index-dark-corner_002c-escape-sequences_002c-for-metacharacters-220">dark
corner, escape sequences, for metacharacters</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bexit_007d-statement-988">dark
corner, <code>exit</code> statement</a>: <a href="#Exit-Statement">Exit
Statement</a></li>
-<li><a href="#index-dark-corner_002c-field-separators-435">dark corner, field
separators</a>: <a href="#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-1057">dark
corner, <code>FILENAME</code> variable</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-494">dark
corner, <code>FILENAME</code> variable</a>: <a href="#Getline-Notes">Getline
Notes</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1070">dark
corner, <code>FNR</code>/<code>NR</code> variables</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-dark-corner_002c-format_002dcontrol-characters-534">dark
corner, format-control characters</a>: <a href="#Control-Letters">Control
Letters</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bFS_007d-as-null-string-421">dark
corner, <code>FS</code> as null string</a>: <a
href="#Single-Character-Fields">Single Character Fields</a></li>
-<li><a href="#index-dark-corner_002c-input-files-359">dark corner, input
files</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-dark-corner_002c-invoking-_0040command_007bawk_007d-1474">dark
corner, invoking <samp><span class="command">awk</span></samp></a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a href="#index-dark-corner_002c-multiline-records-453">dark corner,
multiline records</a>: <a href="#Multiple-Line">Multiple Line</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bNF_007d-variable_002c-decrementing-398">dark
corner, <code>NF</code> variable, decrementing</a>: <a
href="#Changing-Fields">Changing Fields</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bOFMT_007d-variable-524">dark
corner, <code>OFMT</code> variable</a>: <a href="#OFMT">OFMT</a></li>
-<li><a href="#index-dark-corner_002c-regexp-constants-624">dark corner, regexp
constants</a>: <a href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-dark-corner_002c-regexp-constants_002c-_0040code_007b_002f_003d_007d-operator-and-703">dark
corner, regexp constants, <code>/=</code> operator and</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-dark-corner_002c-regexp-constants_002c-as-arguments-to-user_002ddefined-functions-628">dark
corner, regexp constants, as arguments to user-defined functions</a>: <a
href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-dark-corner_002c-_0040code_007bsplit_007d-function-1179">dark
corner, <code>split</code> function</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a href="#index-dark-corner_002c-strings_002c-storing-373">dark corner,
strings, storing</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-data_002c-fixed_002dwidth-438">data, fixed-width</a>: <a
href="#Constant-Size">Constant Size</a></li>
-<li><a href="#index-data_002ddriven-languages-2032">data-driven languages</a>:
<a href="#Basic-High-Level">Basic High Level</a></li>
-<li><a href="#index-database_002c-group_002c-reading-1720">database, group,
reading</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-database_002c-users_0040comma_007b_007d-reading-1693">database,
users, reading</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040command_007bdate_007d-utility_002c-GNU-1233"><samp><span
class="command">date</span></samp> utility, GNU</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a
href="#index-_0040code_007bdate_007d-utility_002c-POSIX-1243"><code>date</code>
utility, POSIX</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-dates_002c-converting-to-timestamps-1240">dates,
converting to timestamps</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a
href="#index-dates_002c-information-related-to_0040comma_007b_007d-localization-1339">dates,
information related to, localization</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="#index-Davies_002c-Stephen-1934">Davies, Stephen</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Davies_002c-Stephen-1860">Davies, Stephen</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a
href="#index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1346"><code>dcgettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1272"><code>dcgettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#I18N-Functions">I18N Functions</a></li>
-<li><a
href="#index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1380"><code>dcgettext</code>
function (<samp><span class="command">gawk</span></samp>), portability
and</a>: <a href="#I18N-Portability">I18N Portability</a></li>
-<li><a
href="#index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1347"><code>dcngettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1273"><code>dcngettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#I18N-Functions">I18N Functions</a></li>
-<li><a
href="#index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1381"><code>dcngettext</code>
function (<samp><span class="command">gawk</span></samp>), portability
and</a>: <a href="#I18N-Portability">I18N Portability</a></li>
-<li><a href="#index-deadlocks-1414">deadlocks</a>: <a
href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="#index-debugging-_0040command_007bgawk_007d-1585">debugging
<samp><span class="command">gawk</span></samp></a>: <a href="#Known-Bugs">Known
Bugs</a></li>
-<li><a
href="#index-debugging-_0040command_007bgawk_007d_002c-bug-reports-1922">debugging
<samp><span class="command">gawk</span></samp>, bug reports</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-decrement-operators-719">decrement operators</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-_0040code_007bdefault_007d-keyword-960"><code>default</code>
keyword</a>: <a href="#Switch-Statement">Switch Statement</a></li>
-<li><a href="#index-Deifik_002c-Scott-1931">Deifik, Scott</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Deifik_002c-Scott-1855">Deifik, Scott</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Deifik_002c-Scott-59">Deifik, Scott</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-_0040code_007bdelete_007d-statement-1103"><code>delete</code>
statement</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-deleting-elements-in-arrays-1104">deleting elements in
arrays</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-deleting-entire-arrays-1110">deleting entire arrays</a>:
<a href="#Delete">Delete</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1074">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>ARGC</code>/<code>ARGV</code>
variables</a>: <a href="#ARGC-and-ARGV">ARGC and ARGV</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGIND_007d-variable-1048">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>ARGIND</code> variable</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-array-elements_002c-deleting-1111">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, array elements, deleting</a>: <a
href="#Delete">Delete</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bAWKPATH_007d-environment-variable-1571">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>AWKPATH</code> environment
variable</a>: <a href="#AWKPATH-Variable">AWKPATH Variable</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-917">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>BEGIN</code>/<code>END</code>
patterns</a>: <a href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-1910">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>BINMODE</code> variable</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-998">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>BINMODE</code> variable</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bclose_007d-function-595">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>close</code> function</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bERRNO_007d-variable-1054">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>ERRNO</code> variable</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-error-messages-575">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, error messages</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-1004">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>FIELDWIDTHS</code> variable</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-function-arguments-_0028_0040command_007bgawk_007d_0029-1146">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, function arguments (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bgetline_007d-command-459">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>getline</code> command</a>: <a
href="#Getline">Getline</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-1014">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>IGNORECASE</code> variable</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-561">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, implementation limitations</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-488">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, implementation limitations</a>: <a
href="#Getline-Notes">Getline Notes</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-559">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, input/output operators</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-486">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, input/output operators</a>: <a
href="#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-line-continuations-801">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, line continuations</a>: <a
href="#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-1020">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>LINT</code> variable</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bmatch_007d-function-1174">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>match</code> function</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-978">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>next</code>/<code>nextfile</code>
statements</a>: <a href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-538">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>print</code>/<code>printf</code>
statements</a>: <a href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bPROCINFO_007d-array-1062">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>PROCINFO</code> array</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-record-separators-365">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, record separators</a>: <a
href="#Records">Records</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regexp-constants-627">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, regexp constants</a>: <a
href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regular-expressions-318">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, regular expressions</a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRS_007d_002f_0040code_007bRT_007d-variables-369">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>RS</code>/<code>RT</code>
variables</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRT_007d-variable-1066">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>RT</code> variable</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-single_002dcharacter-fields-418">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, single-character fields</a>: <a
href="#Single-Character-Fields">Single Character Fields</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bsplit_007d-function-1178">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>split</code> function</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings-608">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, strings</a>: <a
href="#Scalar-Constants">Scalar Constants</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings_002c-storing-372">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, strings, storing</a>: <a
href="#Records">Records</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1181">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>strtonum</code> function (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bTEXTDOMAIN_007d-variable-1039">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>TEXTDOMAIN</code> variable</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-trunc_002dmod-operation-657">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, trunc-mod operation</a>: <a
href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a href="#index-directories_002c-changing-2014">directories, changing</a>:
<a href="#Sample-Library">Sample Library</a></li>
-<li><a href="#index-directories_002c-searching-1823">directories,
searching</a>: <a href="#Igawk-Program">Igawk Program</a></li>
-<li><a href="#index-directories_002c-searching-1569">directories,
searching</a>: <a href="#AWKPATH-Variable">AWKPATH Variable</a></li>
-<li><a href="#index-division-656">division</a>: <a
href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="#index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-955"><code>do</code>-<code>while</code>
statement</a>: <a href="#Do-Statement">Do Statement</a></li>
-<li><a
href="#index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-181"><code>do</code>-<code>while</code>
statement</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="#index-documentation_002c-of-_0040command_007bawk_007d-programs-1601">documentation,
of <samp><span class="command">awk</span></samp> programs</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a href="#index-documentation_002c-online-38">documentation, online</a>:
<a href="#Manual-History">Manual History</a></li>
-<li><a href="#index-documents_0040comma_007b_007d-searching-1788">documents,
searching</a>: <a href="#Dupword-Program">Dupword Program</a></li>
-<li><a href="#index-dollar-sign-_0028_0040code_007b_0024_007d_0029-229">dollar
sign (<code>$</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-812">dollar
sign (<code>$</code>), <code>$</code> field operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-386">dollar
sign (<code>$</code>), <code>$</code> field operator</a>: <a
href="#Fields">Fields</a></li>
-<li><a
href="#index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-incrementing-fields-and-arrays-718">dollar
sign (<code>$</code>), incrementing fields and arrays</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-double-quote-_0028_0040code_007b_0022_007d_0029-129">double quote
(<code>"</code>)</a>: <a href="#Quoting">Quoting</a></li>
-<li><a href="#index-double-quote-_0028_0040code_007b_0022_007d_0029-91">double
quote (<code>"</code>)</a>: <a href="#Read-Terminal">Read Terminal</a></li>
-<li><a
href="#index-double-quote-_0028_0040code_007b_0022_007d_0029_002c-regexp-constants-335">double
quote (<code>"</code>), regexp constants</a>: <a
href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-double_002dprecision-floating_002dpoint-2043">double-precision
floating-point</a>: <a href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-Drepper_002c-Ulrich-53">Drepper, Ulrich</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-_0040code_007bdupnode_007d-internal-function-1998"><code>dupnode</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bdupword_002eawk_007d-program-1790"><code>dupword.awk</code>
program</a>: <a href="#Dupword-Program">Dupword Program</a></li>
-<li><a href="#index-EBCDIC-1651">EBCDIC</a>: <a
href="#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a href="#index-_0040command_007begrep_007d-utility-1754"><samp><span
class="command">egrep</span></samp> utility</a>: <a href="#Egrep-Program">Egrep
Program</a></li>
-<li><a href="#index-_0040command_007begrep_007d-utility-268"><samp><span
class="command">egrep</span></samp> utility</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a
href="#index-_0040code_007begrep_002eawk_007d-program-1755"><code>egrep.awk</code>
program</a>: <a href="#Egrep-Program">Egrep Program</a></li>
-<li><a href="#index-elements-in-arrays-1091">elements in arrays</a>: <a
href="#Reference-to-Elements">Reference to Elements</a></li>
-<li><a href="#index-elements-in-arrays_002c-assigning-1095">elements in
arrays, assigning</a>: <a href="#Assigning-Elements">Assigning Elements</a></li>
-<li><a href="#index-elements-in-arrays_002c-deleting-1106">elements in arrays,
deleting</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-elements-in-arrays_002c-order-of-1102">elements in arrays,
order of</a>: <a href="#Scanning-an-Array">Scanning an Array</a></li>
-<li><a href="#index-elements-in-arrays_002c-scanning-1096">elements in arrays,
scanning</a>: <a href="#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="#index-email-address-for-bug-reports_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1925">email
address for bug reports, <code>address@hidden</code></a>: <a
href="#Bugs">Bugs</a></li>
-<li><a
href="#index-_0040code_007bEMISTERED_007d-1424"><code>EMISTERED</code></a>: <a
href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a href="#index-empty-pattern-926">empty pattern</a>: <a
href="#Empty">Empty</a></li>
-<li><a href="#index-empty-strings_002c-See-null-strings-417">empty strings,
See null strings</a>: <a href="#Regexp-Field-Splitting">Regexp Field
Splitting</a></li>
-<li><a href="#index-_0040code_007bEND_007d-pattern-913"><code>END</code>
pattern</a>: <a href="#BEGIN_002fEND">BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1626"><code>END</code>
pattern, <code>assert</code> user-defined function and</a>: <a
href="#Assert-Function">Assert Function</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-backslash-continuation-and-1759"><code>END</code>
pattern, backslash continuation and</a>: <a href="#Egrep-Program">Egrep
Program</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-Boolean-patterns-and-903"><code>END</code>
pattern, Boolean patterns and</a>: <a href="#Expression-Patterns">Expression
Patterns</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bexit_007d-statement-and-987"><code>END</code>
pattern, <code>exit</code> statement and</a>: <a href="#Exit-Statement">Exit
Statement</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-973"><code>END</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#Next-Statement">Next Statement</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-925"><code>END</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-operators-and-915"><code>END</code>
pattern, operators and</a>: <a href="#Using-BEGIN_002fEND">Using
BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-_0040command_007bpgawk_007d-program-1447"><code>END</code>
pattern, <samp><span class="command">pgawk</span></samp> program</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bprint_007d-statement-and-921"><code>END</code>
pattern, <code>print</code> statement and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bendfile_007d-user_002ddefined-function-1669"><code>endfile</code>
user-defined function</a>: <a href="#Filetrans-Function">Filetrans
Function</a></li>
-<li><a
href="#index-_0040code_007bendgrent_007d-function-_0028C-library_0029-1739"><code>endgrent</code>
function (C library)</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bendgrent_007d-user_002ddefined-function-1740"><code>endgrent</code>
user-defined function</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bendpwent_007d-function-_0028C-library_0029-1715"><code>endpwent</code>
function (C library)</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040code_007bendpwent_007d-user_002ddefined-function-1716"><code>endpwent</code>
user-defined function</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="#index-_0040code_007bENVIRON_007d-variable-1051"><code>ENVIRON</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-environment-variables-1052">environment variables</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-epoch_002c-definition-of-2064">epoch, definition of</a>:
<a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_007d-operator-674">equals
sign (<code>=</code>), <code>=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-846">equals
sign (<code>=</code>), <code>==</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-757">equals
sign (<code>=</code>), <code>==</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-EREs-_0028Extended-Regular-Expressions_0029-267">EREs
(Extended Regular Expressions)</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-_0040code_007bERRNO_007d-variable-2009"><code>ERRNO</code>
variable</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-_0040code_007bERRNO_007d-variable-1053"><code>ERRNO</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-_0040code_007bERRNO_007d-variable-458"><code>ERRNO</code>
variable</a>: <a href="#Getline">Getline</a></li>
-<li><a href="#index-error-handling-576">error handling</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-error-handling_002c-_0040code_007bERRNO_007d-variable-and-1055">error
handling, <code>ERRNO</code> variable and</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-error-output-572">error output</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-escape-processing_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-1197">escape
processing, <code>gsub</code>/<code>gensub</code>/<code>sub</code>
functions</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a href="#index-escape-sequences-184">escape sequences</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a href="#index-escape-sequences_002c-unrecognized-1530">escape sequences,
unrecognized</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-evaluation-order-728">evaluation order</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-evaluation-order_002c-concatenation-668">evaluation order,
concatenation</a>: <a href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-evaluation-order_002c-functions-1147">evaluation order,
functions</a>: <a href="#Calling-Built_002din">Calling Built-in</a></li>
-<li><a href="#index-examining-fields-376">examining fields</a>: <a
href="#Fields">Fields</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-1757">exclamation
point (<code>!</code>), <code>!</code> operator</a>: <a
href="#Egrep-Program">Egrep Program</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-826">exclamation
point (<code>!</code>), <code>!</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-792">exclamation
point (<code>!</code>), <code>!</code> operator</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-848">exclamation
point (<code>!</code>), <code>!=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-759">exclamation
point (<code>!</code>), <code>!=</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-898">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-863">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-763">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-623">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-330">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-322">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-178">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="#index-_0040code_007bexit_007d-statement-985"><code>exit</code>
statement</a>: <a href="#Exit-Statement">Exit Statement</a></li>
-<li><a href="#index-_0040code_007bexp_007d-function-1152"><code>exp</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-_0040command_007bexpand_007d-utility-142"><samp><span
class="command">expand</span></samp> utility</a>: <a href="#Very-Simple">Very
Simple</a></li>
-<li><a href="#index-expressions-604">expressions</a>: <a
href="#Expressions">Expressions</a></li>
-<li><a href="#index-expressions_002c-as-patterns-890">expressions, as
patterns</a>: <a href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a href="#index-expressions_002c-assignment-672">expressions,
assignment</a>: <a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-expressions_002c-Boolean-777">expressions, Boolean</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-expressions_002c-comparison-738">expressions,
comparison</a>: <a href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-expressions_002c-conditional-798">expressions,
conditional</a>: <a href="#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="#index-expressions_002c-matching_002c-See-comparison-expressions-739">expressions,
matching, See comparison expressions</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-expressions_002c-selecting-799">expressions,
selecting</a>: <a href="#Conditional-Exp">Conditional Exp</a></li>
-<li><a href="#index-Extended-Regular-Expressions-_0028EREs_0029-266">Extended
Regular Expressions (EREs)</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a
href="#index-_0040code_007bextension_007d-function-_0028_0040command_007bgawk_007d_0029-2018"><code>extension</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Using-Internal-File-Ops">Using Internal File Ops</a></li>
-<li><a
href="#index-extensions_002c-Bell-Laboratories-_0040command_007bawk_007d-1830">extensions,
Bell Laboratories <samp><span class="command">awk</span></samp></a>: <a
href="#BTL">BTL</a></li>
-<li><a
href="#index-extensions_002c-in-_0040command_007bgawk_007d_002c-not-in-POSIX-_0040command_007bawk_007d-1834">extensions,
in <samp><span class="command">gawk</span></samp>, not in POSIX <samp><span
class="command">awk</span></samp></a>: <a
href="#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="#index-extensions_002c-_0040command_007bmawk_007d-1943">extensions,
<samp><span class="command">mawk</span></samp></a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a
href="#index-_0040code_007bextract_002eawk_007d-program-1812"><code>extract.awk</code>
program</a>: <a href="#Extract-Program">Extract Program</a></li>
-<li><a
href="#index-extraction_002c-of-marked-strings-_0028internationalization_0029-1368">extraction,
of marked strings (internationalization)</a>: <a
href="#String-Extraction">String Extraction</a></li>
-<li><a href="#index-false_002c-logical-733">false, logical</a>: <a
href="#Truth-Values">Truth Values</a></li>
-<li><a href="#index-FDL-_0028Free-Documentation-License_0029-2087">FDL (Free
Documentation License)</a>: <a href="#GNU-Free-Documentation-License">GNU Free
Documentation License</a></li>
-<li><a
href="#index-features_002c-adding-to-_0040command_007bgawk_007d-1956">features,
adding to <samp><span class="command">gawk</span></samp></a>: <a
href="#Adding-Code">Adding Code</a></li>
-<li><a
href="#index-features_002c-advanced_002c-See-advanced-features-1572">features,
advanced, See advanced features</a>: <a href="#Obsolete">Obsolete</a></li>
-<li><a href="#index-features_002c-deprecated-1574">features, deprecated</a>:
<a href="#Obsolete">Obsolete</a></li>
-<li><a href="#index-features_002c-undocumented-1579">features,
undocumented</a>: <a href="#Undocumented">Undocumented</a></li>
-<li><a href="#index-Fenlason_002c-Jay-1842">Fenlason, Jay</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Fenlason_002c-Jay-18">Fenlason, Jay</a>: <a
href="#History">History</a></li>
-<li><a
href="#index-_0040code_007bfflush_007d-function-1213"><code>fflush</code>
function</a>: <a href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="#index-_0040code_007bfflush_007d-function_0040comma_007b_007d-unsupported-1542"><code>fflush</code>
function, unsupported</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-field-numbers-391">field numbers</a>: <a
href="#Nonconstant-Fields">Nonconstant Fields</a></li>
-<li><a href="#index-field-operator-_0040code_007b_0024_007d-384">field
operator <code>$</code></a>: <a href="#Fields">Fields</a></li>
-<li><a
href="#index-field-operators_0040comma_007b_007d-dollar-sign-as-387">field
operators, dollar sign as</a>: <a href="#Fields">Fields</a></li>
-<li><a href="#index-field-separators-1010">field separators</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-field-separators-403">field separators</a>: <a
href="#Field-Separators">Field Separators</a></li>
-<li><a href="#index-field-separators_002c-choice-of-408">field separators,
choice of</a>: <a href="#Field-Separators">Field Separators</a></li>
-<li><a
href="#index-field-separators_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1005">field
separators, <code>FIELDWIDTHS</code> variable and</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-field-separators_002c-in-multiline-records-454">field
separators, in multiline records</a>: <a href="#Multiple-Line">Multiple
Line</a></li>
-<li><a href="#index-field-separators_002c-on-command-line-426">field
separators, on command line</a>: <a
href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a href="#index-field-separators_002c-POSIX-and-434">field separators,
POSIX and</a>: <a href="#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a href="#index-field-separators_002c-POSIX-and-381">field separators,
POSIX and</a>: <a href="#Fields">Fields</a></li>
-<li><a href="#index-field-separators_002c-regular-expressions-as-414">field
separators, regular expressions as</a>: <a
href="#Regexp-Field-Splitting">Regexp Field Splitting</a></li>
-<li><a href="#index-field-separators_002c-regular-expressions-as-410">field
separators, regular expressions as</a>: <a href="#Field-Separators">Field
Separators</a></li>
-<li><a
href="#index-field-separators_002c-See-Also-_0040code_007bOFS_007d-397">field
separators, See Also <code>OFS</code></a>: <a href="#Changing-Fields">Changing
Fields</a></li>
-<li><a href="#index-field-separators_002c-spaces-as-1750">field separators,
spaces as</a>: <a href="#Cut-Program">Cut Program</a></li>
-<li><a href="#index-fields-2031">fields</a>: <a href="#Basic-High-Level">Basic
High Level</a></li>
-<li><a href="#index-fields-377">fields</a>: <a href="#Fields">Fields</a></li>
-<li><a href="#index-fields-346">fields</a>: <a href="#Reading-Files">Reading
Files</a></li>
-<li><a href="#index-fields_002c-adding-394">fields, adding</a>: <a
href="#Changing-Fields">Changing Fields</a></li>
-<li><a href="#index-fields_002c-changing-contents-of-392">fields, changing
contents of</a>: <a href="#Changing-Fields">Changing Fields</a></li>
-<li><a href="#index-fields_002c-cutting-1745">fields, cutting</a>: <a
href="#Cut-Program">Cut Program</a></li>
-<li><a href="#index-fields_002c-examining-379">fields, examining</a>: <a
href="#Fields">Fields</a></li>
-<li><a href="#index-fields_002c-number-of-389">fields, number of</a>: <a
href="#Fields">Fields</a></li>
-<li><a href="#index-fields_002c-numbers-390">fields, numbers</a>: <a
href="#Nonconstant-Fields">Nonconstant Fields</a></li>
-<li><a href="#index-fields_002c-printing-506">fields, printing</a>: <a
href="#Print-Examples">Print Examples</a></li>
-<li><a href="#index-fields_002c-separating-402">fields, separating</a>: <a
href="#Field-Separators">Field Separators</a></li>
-<li><a href="#index-fields_002c-single_002dcharacter-420">fields,
single-character</a>: <a href="#Single-Character-Fields">Single Character
Fields</a></li>
-<li><a
href="#index-_0040code_007bFIELDWIDTHS_007d-variable-1003"><code>FIELDWIDTHS</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bFIELDWIDTHS_007d-variable-443"><code>FIELDWIDTHS</code>
variable</a>: <a href="#Constant-Size">Constant Size</a></li>
-<li><a href="#index-file-descriptors-573">file descriptors</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a href="#index-_0040value_007bFN_007ds_002c-distinguishing-1050">file
names, distinguishing</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040value_007bFN_007ds_002c-in-compatibility-mode-586">file
names, in compatibility mode</a>: <a href="#Special-Caveats">Special
Caveats</a></li>
-<li><a
href="#index-_0040value_007bFN_007ds_002c-standard-streams-in-_0040command_007bgawk_007d-577">file
names, standard streams in <samp><span class="command">gawk</span></samp></a>:
<a href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-_0040code_007bFILENAME_007d-variable-1056"><code>FILENAME</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040code_007bFILENAME_007d-variable-344"><code>FILENAME</code>
variable</a>: <a href="#Reading-Files">Reading Files</a></li>
-<li><a
href="#index-_0040code_007bFILENAME_007d-variable_002c-_0040code_007bgetline_007d_0040comma_007b_007d-setting-with-493"><code>FILENAME</code>
variable, <code>getline</code>, setting with</a>: <a
href="#Getline-Notes">Getline Notes</a></li>
-<li><a href="#index-filenames_002c-assignments-as-1679">filenames, assignments
as</a>: <a href="#Ignoring-Assigns">Ignoring Assigns</a></li>
-<li><a href="#index-files_002c-_0040code_007b_002emo_007d-1315">files,
<code>.mo</code></a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002emo_007d_002c-converting-from-_0040code_007b_002epo_007d-1387">files,
<code>.mo</code>, converting from <code>.po</code></a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1349">files,
<code>.mo</code>, specifying directory of</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1320">files,
<code>.mo</code>, specifying directory of</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="#index-files_002c-_0040code_007b_002epo_007d-1359">files,
<code>.po</code></a>: <a href="#Translator-i18n">Translator i18n</a></li>
-<li><a href="#index-files_002c-_0040code_007b_002epo_007d-1311">files,
<code>.po</code></a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002epo_007d_002c-converting-to-_0040code_007b_002emo_007d-1385">files,
<code>.po</code>, converting to <code>.mo</code></a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-579">files,
<code>/dev/...</code> special files</a>: <a href="#Special-FD">Special
FD</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-1423">files,
<code>/inet/</code> (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002fp_007d-_0028_0040command_007bgawk_007d_0029-1433">files,
<code>/p</code> (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Portal-Files">Portal Files</a></li>
-<li><a href="#index-files_002c-as-single-records-375">files, as single
records</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-files_002c-_0040command_007bawk_007d-programs-in-97">files,
<samp><span class="command">awk</span></samp> programs in</a>: <a
href="#Long">Long</a></li>
-<li><a href="#index-files_002c-_0040code_007bawkprof_002eout_007d-1443">files,
<code>awkprof.out</code></a>: <a href="#Profiling">Profiling</a></li>
-<li><a href="#index-files_002c-_0040code_007bawkvars_002eout_007d-1508">files,
<code>awkvars.out</code></a>: <a href="#Options">Options</a></li>
-<li><a href="#index-files_002c-closing-1212">files, closing</a>: <a
href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="#index-files_002c-descriptors_002c-See-file-descriptors-574">files,
descriptors, See file descriptors</a>: <a href="#Special-FD">Special FD</a></li>
-<li><a href="#index-files_002c-for-process-information-581">files, for process
information</a>: <a href="#Special-Process">Special Process</a></li>
-<li><a href="#index-files_002c-group-1727">files, group</a>: <a
href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-files_002c-information-about_0040comma_007b_007d-retrieving-2013">files,
information about, retrieving</a>: <a href="#Sample-Library">Sample
Library</a></li>
-<li><a href="#index-files_002c-initialization-and-cleanup-1667">files,
initialization and cleanup</a>: <a href="#Filetrans-Function">Filetrans
Function</a></li>
-<li><a href="#index-files_002c-input_002c-See-input-files-87">files, input,
See input files</a>: <a href="#Read-Terminal">Read Terminal</a></li>
-<li><a
href="#index-files_002c-log_0040comma_007b_007d-timestamps-in-1230">files, log,
timestamps in</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-files_002c-managing-1663">files, managing</a>: <a
href="#Data-File-Management">Data File Management</a></li>
-<li><a
href="#index-files_002c-managing_002c-_0040value_007bDF_007d-boundaries-1666">files,
managing, data file boundaries</a>: <a href="#Filetrans-Function">Filetrans
Function</a></li>
-<li><a href="#index-files_002c-message-object-1317">files, message object</a>:
<a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-files_002c-message-object_002c-converting-from-portable-object-files-1391">files,
message object, converting from portable object files</a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a
href="#index-files_002c-message-object_002c-specifying-directory-of-1351">files,
message object, specifying directory of</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-files_002c-message-object_002c-specifying-directory-of-1322">files,
message object, specifying directory of</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="#index-files_002c-multiple-passes-over-1567">files, multiple
passes over</a>: <a href="#Other-Arguments">Other Arguments</a></li>
-<li><a
href="#index-files_002c-multiple_0040comma_007b_007d-duplicating-output-into-1770">files,
multiple, duplicating output into</a>: <a href="#Tee-Program">Tee
Program</a></li>
-<li><a href="#index-files_002c-output_002c-See-output-files-588">files,
output, See output files</a>: <a href="#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a href="#index-files_002c-password-1701">files, password</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-files_002c-portable-object-1361">files, portable
object</a>: <a href="#Translator-i18n">Translator i18n</a></li>
-<li><a href="#index-files_002c-portable-object-1313">files, portable
object</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-files_002c-portable-object_002c-converting-to-message-object-files-1389">files,
portable object, converting to message object files</a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a href="#index-files_002c-portable-object_002c-generating-1513">files,
portable object, generating</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-files_002c-portal-1430">files, portal</a>: <a
href="#Portal-Files">Portal Files</a></li>
-<li><a
href="#index-files_002c-processing_0040comma_007b_007d-_0040code_007bARGIND_007d-variable-and-1049">files,
processing, <code>ARGIND</code> variable and</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-files_002c-reading-1670">files, reading</a>: <a
href="#Rewind-Function">Rewind Function</a></li>
-<li><a href="#index-files_002c-reading_002c-multiline-records-447">files,
reading, multiline records</a>: <a href="#Multiple-Line">Multiple Line</a></li>
-<li><a href="#index-files_002c-searching-for-regular-expressions-1753">files,
searching for regular expressions</a>: <a href="#Egrep-Program">Egrep
Program</a></li>
-<li><a href="#index-files_002c-skipping-1674">files, skipping</a>: <a
href="#File-Checking">File Checking</a></li>
-<li><a
href="#index-files_002c-source_0040comma_007b_007d-search-path-for-1822">files,
source, search path for</a>: <a href="#Igawk-Program">Igawk Program</a></li>
-<li><a href="#index-files_002c-splitting-1767">files, splitting</a>: <a
href="#Split-Program">Split Program</a></li>
-<li><a
href="#index-files_002c-Texinfo_0040comma_007b_007d-extracting-programs-from-1810">files,
Texinfo, extracting programs from</a>: <a href="#Extract-Program">Extract
Program</a></li>
-<li><a href="#index-Fish_002c-Fred-1929">Fish, Fred</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Fish_002c-Fred-1854">Fish, Fred</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-fixed_002dwidth-data-439">fixed-width data</a>: <a
href="#Constant-Size">Constant Size</a></li>
-<li><a href="#index-flag-variables-1773">flag variables</a>: <a
href="#Tee-Program">Tee Program</a></li>
-<li><a href="#index-flag-variables-795">flag variables</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-floating_002dpoint-2048">floating-point</a>: <a
href="#Floating-Point-Issues">Floating Point Issues</a></li>
-<li><a href="#index-floating_002dpoint_002c-numbers-2039">floating-point,
numbers</a>: <a href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a
href="#index-floating_002dpoint_002c-numbers_002c-_0040code_007bAWKNUM_007d-internal-type-1971">floating-point,
numbers, <code>AWKNUM</code> internal type</a>: <a
href="#Internals">Internals</a></li>
-<li><a href="#index-_0040code_007bFNR_007d-variable-1058"><code>FNR</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-_0040code_007bFNR_007d-variable-351"><code>FNR</code>
variable</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-_0040code_007bFNR_007d-variable_002c-changing-1068"><code>FNR</code>
variable, changing</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-_0040code_007bfor_007d-statement-956"><code>for</code>
statement</a>: <a href="#For-Statement">For Statement</a></li>
-<li><a
href="#index-_0040code_007bfor_007d-statement_002c-in-arrays-1100"><code>for</code>
statement, in arrays</a>: <a href="#Scanning-an-Array">Scanning an
Array</a></li>
-<li><a
href="#index-_0040code_007bforce_005fnumber_007d-internal-function-1977"><code>force_number</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bforce_005fstring_007d-internal-function-1979"><code>force_string</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-format-specifiers_002c-mixing-regular-with-positional-specifiers-1375">format
specifiers, mixing regular with positional specifiers</a>: <a
href="#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="#index-format-specifiers_002c-_0040code_007bprintf_007d-statement-533">format
specifiers, <code>printf</code> statement</a>: <a
href="#Control-Letters">Control Letters</a></li>
-<li><a
href="#index-format-specifiers_002c-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1242">format
specifiers, <code>strftime</code> function (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#Time-Functions">Time
Functions</a></li>
-<li><a href="#index-format-strings-531">format strings</a>: <a
href="#Basic-Printf">Basic Printf</a></li>
-<li><a href="#index-formats_0040comma_007b_007d-numeric-output-520">formats,
numeric output</a>: <a href="#OFMT">OFMT</a></li>
-<li><a href="#index-formatting-output-529">formatting output</a>: <a
href="#Printf">Printf</a></li>
-<li><a
href="#index-forward-slash-_0028_0040code_007b_002f_007d_0029-170">forward
slash (<code>/</code>)</a>: <a href="#Regexp">Regexp</a></li>
-<li><a
href="#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_007d-operator-830">forward
slash (<code>/</code>), <code>/</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-880">forward
slash (<code>/</code>), <code>/=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-691">forward
slash (<code>/</code>), <code>/=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-705">forward
slash (<code>/</code>), <code>/=</code> operator, vs. <code>/=.../</code>
regexp constant</a>: <a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-patterns-and-894">forward
slash (<code>/</code>), patterns and</a>: <a
href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a href="#index-Free-Documentation-License-_0028FDL_0029-2088">Free
Documentation License (FDL)</a>: <a href="#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a href="#index-Free-Software-Foundation-_0028FSF_0029-2066">Free Software
Foundation (FSF)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-Free-Software-Foundation-_0028FSF_0029-1875">Free Software
Foundation (FSF)</a>: <a href="#Getting">Getting</a></li>
-<li><a href="#index-Free-Software-Foundation-_0028FSF_0029-33">Free Software
Foundation (FSF)</a>: <a href="#Manual-History">Manual History</a></li>
-<li><a
href="#index-_0040code_007bfree_005ftemp_007d-internal-macro-2000"><code>free_temp</code>
internal macro</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-FreeBSD-2085">FreeBSD</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-_0040code_007bFS_007d-variable-1008"><code>FS</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-_0040code_007bFS_007d-variable-401"><code>FS</code>
variable</a>: <a href="#Field-Separators">Field Separators</a></li>
-<li><a
href="#index-_0040code_007bFS_007d-variable_002c-_0040code_007b_002d_002dfield_002dseparator_007d-option-and-1484"><code>FS</code>
variable, <code>--field-separator</code> option and</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-FS-variable_002c-as-null-string-422">FS variable, as null
string</a>: <a href="#Single-Character-Fields">Single Character Fields</a></li>
-<li><a
href="#index-_0040code_007bFS_007d-variable_002c-as-TAB-character-1541"><code>FS</code>
variable, as TAB character</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007bFS_007d-variable_002c-changing-value-of-1589"><code>FS</code>
variable, changing value of</a>: <a href="#Known-Bugs">Known Bugs</a></li>
-<li><a
href="#index-_0040code_007bFS_007d-variable_002c-changing-value-of-406"><code>FS</code>
variable, changing value of</a>: <a href="#Field-Separators">Field
Separators</a></li>
-<li><a
href="#index-_0040code_007bFS_007d-variable_002c-running-_0040command_007bawk_007d-programs-and-1749"><code>FS</code>
variable, running <samp><span class="command">awk</span></samp> programs
and</a>: <a href="#Cut-Program">Cut Program</a></li>
-<li><a
href="#index-_0040code_007bFS_007d-variable_002c-setting-from-command-line-428"><code>FS</code>
variable, setting from command line</a>: <a
href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a href="#index-FSF-_0028Free-Software-Foundation_0029-2065">FSF (Free
Software Foundation)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-FSF-_0028Free-Software-Foundation_0029-1874">FSF (Free
Software Foundation)</a>: <a href="#Getting">Getting</a></li>
-<li><a href="#index-FSF-_0028Free-Software-Foundation_0029-32">FSF (Free
Software Foundation)</a>: <a href="#Manual-History">Manual History</a></li>
-<li><a href="#index-function-calls-804">function calls</a>: <a
href="#Function-Calls">Function Calls</a></li>
-<li><a href="#index-functions_002c-arrays-as-parameters-to-1293">functions,
arrays as parameters to</a>: <a href="#Function-Caveats">Function
Caveats</a></li>
-<li><a href="#index-functions_002c-built_002din-1140">functions, built-in</a>:
<a href="#Functions">Functions</a></li>
-<li><a href="#index-functions_002c-built_002din-805">functions, built-in</a>:
<a href="#Function-Calls">Function Calls</a></li>
-<li><a
href="#index-functions_002c-built_002din_002c-adding-to-_0040command_007bgawk_007d-1968">functions,
built-in, adding to <samp><span class="command">gawk</span></samp></a>: <a
href="#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a
href="#index-functions_002c-built_002din_002c-evaluation-order-1148">functions,
built-in, evaluation order</a>: <a href="#Calling-Built_002din">Calling
Built-in</a></li>
-<li><a href="#index-functions_002c-defining-1277">functions, defining</a>: <a
href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a href="#index-functions_002c-library-1591">functions, library</a>: <a
href="#Library-Functions">Library Functions</a></li>
-<li><a href="#index-functions_002c-library_002c-assertions-1623">functions,
library, assertions</a>: <a href="#Assert-Function">Assert Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-associative-arrays-and-1611">functions,
library, associative arrays and</a>: <a href="#Library-Names">Library
Names</a></li>
-<li><a href="#index-functions_002c-library_002c-C-library-1685">functions,
library, C library</a>: <a href="#Getopt-Function">Getopt Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-character-values-as-numbers-1643">functions,
library, character values as numbers</a>: <a href="#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a
href="#index-functions_002c-library_002c-Cliff-random-numbers-1640">functions,
library, Cliff random numbers</a>: <a href="#Cliff-Random-Function">Cliff
Random Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-command_002dline-options-1682">functions,
library, command-line options</a>: <a href="#Getopt-Function">Getopt
Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-example-program-for-using-1818">functions,
library, example program for using</a>: <a href="#Igawk-Program">Igawk
Program</a></li>
-<li><a
href="#index-functions_002c-library_002c-group-database_002c-reading-1718">functions,
library, group database, reading</a>: <a href="#Group-Functions">Group
Functions</a></li>
-<li><a
href="#index-functions_002c-library_002c-managing-_0040value_007bDF_007ds-1665">functions,
library, managing data files</a>: <a href="#Data-File-Management">Data File
Management</a></li>
-<li><a href="#index-functions_002c-library_002c-managing-time-1659">functions,
library, managing time</a>: <a href="#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-merging-arrays-into-strings-1654">functions,
library, merging arrays into strings</a>: <a href="#Join-Function">Join
Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-_0040code_007bnextfile_007d-statement-1615">functions,
library, <code>nextfile</code> statement</a>: <a
href="#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-rounding-numbers-1632">functions,
library, rounding numbers</a>: <a href="#Round-Function">Round Function</a></li>
-<li><a
href="#index-functions_002c-library_002c-user-database_002c-reading-1691">functions,
library, user database, reading</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="#index-functions_002c-names-of-1279">functions, names of</a>: <a
href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a href="#index-functions_002c-names-of-1077">functions, names of</a>: <a
href="#Arrays">Arrays</a></li>
-<li><a href="#index-functions_002c-recursive-1284">functions, recursive</a>:
<a href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a
href="#index-functions_002c-return-values_0040comma_007b_007d-setting-2007">functions,
return values, setting</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-functions_002c-string_002dtranslation-1269">functions,
string-translation</a>: <a href="#I18N-Functions">I18N Functions</a></li>
-<li><a href="#index-functions_002c-undefined-1295">functions, undefined</a>:
<a href="#Function-Caveats">Function Caveats</a></li>
-<li><a href="#index-functions_002c-user_002ddefined-1276">functions,
user-defined</a>: <a href="#User_002ddefined">User-defined</a></li>
-<li><a
href="#index-functions_002c-user_002ddefined_002c-calling-1289">functions,
user-defined, calling</a>: <a href="#Function-Caveats">Function Caveats</a></li>
-<li><a
href="#index-functions_002c-user_002ddefined_002c-counts-1450">functions,
user-defined, counts</a>: <a href="#Profiling">Profiling</a></li>
-<li><a
href="#index-functions_002c-user_002ddefined_002c-library-of-1592">functions,
user-defined, library of</a>: <a href="#Library-Functions">Library
Functions</a></li>
-<li><a
href="#index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-979">functions,
user-defined, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-976">functions,
user-defined, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#Next-Statement">Next Statement</a></li>
-<li><a href="#index-G_002dd-71">G-d</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Garfinkle_002c-Scott-1849">Garfinkle, Scott</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-25"><samp><span
class="command">gawk</span></samp>, <samp><span
class="command">awk</span></samp> and</a>: <a href="#This-Manual">This
Manual</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-4"><samp><span
class="command">gawk</span></samp>, <samp><span
class="command">awk</span></samp> and</a>: <a href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-bitwise-operations-in-1256"><samp><span
class="command">gawk</span></samp>, bitwise operations in</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bbreak_007d-statement-in-965"><samp><span
class="command">gawk</span></samp>, <code>break</code> statement in</a>: <a
href="#Break-Statement">Break Statement</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-built_002din-variables-and-992"><samp><span
class="command">gawk</span></samp>, built-in variables and</a>: <a
href="#Built_002din-Variables">Built-in Variables</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-character-classes-and-278"><samp><span
class="command">gawk</span></samp>, character classes and</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-coding-style-in-1958"><samp><span
class="command">gawk</span></samp>, coding style in</a>: <a
href="#Adding-Code">Adding Code</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-command_002dline-options-313"><samp><span
class="command">gawk</span></samp>, command-line options</a>: <a
href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-comparison-operators-and-766"><samp><span
class="command">gawk</span></samp>, comparison operators and</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-configuring-1894"><samp><span
class="command">gawk</span></samp>, configuring</a>: <a
href="#Configuration-Philosophy">Configuration Philosophy</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-configuring_002c-options-1879"><samp><span
class="command">gawk</span></samp>, configuring, options</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bcontinue_007d-statement-in-969"><samp><span
class="command">gawk</span></samp>, <code>continue</code> statement in</a>: <a
href="#Continue-Statement">Continue Statement</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-debugging-1584"><samp><span
class="command">gawk</span></samp>, debugging</a>: <a href="#Known-Bugs">Known
Bugs</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-distribution-1876"><samp><span
class="command">gawk</span></samp>, distribution</a>: <a
href="#Distribution-contents">Distribution contents</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-escape-sequences-217"><samp><span
class="command">gawk</span></samp>, escape sequences</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-extensions_0040comma_007b_007d-disabling-1529"><samp><span
class="command">gawk</span></samp>, extensions, disabling</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-features_002c-adding-1957"><samp><span
class="command">gawk</span></samp>, features, adding</a>: <a
href="#Adding-Code">Adding Code</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-features_002c-advanced-1396"><samp><span
class="command">gawk</span></samp>, features, advanced</a>: <a
href="#Advanced-Features">Advanced Features</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bfflush_007d-function-in-1217"><samp><span
class="command">gawk</span></samp>, <code>fflush</code> function in</a>: <a
href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-field-separators-and-1012"><samp><span
class="command">gawk</span></samp>, field separators and</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-in-1007"><samp><span
class="command">gawk</span></samp>, <code>FIELDWIDTHS</code> variable in</a>:
<a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040value_007bFN_007ds-in-567"><samp><span
class="command">gawk</span></samp>, file names in</a>: <a
href="#Special-Files">Special Files</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-format_002dcontrol-characters-535"><samp><span
class="command">gawk</span></samp>, format-control characters</a>: <a
href="#Control-Letters">Control Letters</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-function-arguments-and-1145"><samp><span
class="command">gawk</span></samp>, function arguments and</a>: <a
href="#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-functions_002c-adding-1966"><samp><span
class="command">gawk</span></samp>, functions, adding</a>: <a
href="#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-hexadecimal-numbers-and-615"><samp><span
class="command">gawk</span></samp>, hexadecimal numbers and</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-in-1018"><samp><span
class="command">gawk</span></samp>, <code>IGNORECASE</code> variable in</a>:
<a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-implementation-issues-1949"><samp><span
class="command">gawk</span></samp>, implementation issues</a>: <a
href="#Notes">Notes</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-debugging-1952"><samp><span
class="command">gawk</span></samp>, implementation issues, debugging</a>: <a
href="#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-downward-compatibility-1951"><samp><span
class="command">gawk</span></samp>, implementation issues, downward
compatibility</a>: <a href="#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-limits-491"><samp><span
class="command">gawk</span></samp>, implementation issues, limits</a>: <a
href="#Getline-Notes">Getline Notes</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-pipes-564"><samp><span
class="command">gawk</span></samp>, implementation issues, pipes</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-installing-1870"><samp><span
class="command">gawk</span></samp>, installing</a>: <a
href="#Installation">Installation</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-internals-1969"><samp><span
class="command">gawk</span></samp>, internals</a>: <a
href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-internationalization-and_002c-See-internationalization-1301"><samp><span
class="command">gawk</span></samp>, internationalization and, See
internationalization</a>: <a
href="#Internationalization">Internationalization</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2022"><samp><span
class="command">gawk</span></samp>, interpreter, adding code to</a>: <a
href="#Future-Extensions">Future Extensions</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2017"><samp><span
class="command">gawk</span></samp>, interpreter, adding code to</a>: <a
href="#Using-Internal-File-Ops">Using Internal File Ops</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-interval-expressions-and-251"><samp><span
class="command">gawk</span></samp>, interval expressions and</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-line-continuation-in-803"><samp><span
class="command">gawk</span></samp>, line continuation in</a>: <a
href="#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-in-1022"><samp><span
class="command">gawk</span></samp>, <code>LINT</code> variable in</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-list-of-contributors-to-1837"><samp><span
class="command">gawk</span></samp>, list of contributors to</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-MS_002dDOS-version-of-1906"><samp><span
class="command">gawk</span></samp>, MS-DOS version of</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-newlines-in-152"><samp><span
class="command">gawk</span></samp>, newlines in</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bnext-file_007d-statement-in-982"><samp><span
class="command">gawk</span></samp>, <code>next file</code> statement in</a>:
<a href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-1617"><samp><span
class="command">gawk</span></samp>, <code>nextfile</code> statement in</a>: <a
href="#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-984"><samp><span
class="command">gawk</span></samp>, <code>nextfile</code> statement in</a>: <a
href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-octal-numbers-and-614"><samp><span
class="command">gawk</span></samp>, octal numbers and</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-OS_002f2-version-of-1905"><samp><span
class="command">gawk</span></samp>, OS/2 version of</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-regexp-constants-and-625"><samp><span
class="command">gawk</span></samp>, regexp constants and</a>: <a
href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-regular-expressions_002c-case-sensitivity-316"><samp><span
class="command">gawk</span></samp>, regular expressions, case sensitivity</a>:
<a href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-regular-expressions_002c-operators-281"><samp><span
class="command">gawk</span></samp>, regular expressions, operators</a>: <a
href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-regular-expressions_002c-precedence-255"><samp><span
class="command">gawk</span></samp>, regular expressions, precedence</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-See-Also-_0040command_007bawk_007d-8"><samp><span
class="command">gawk</span></samp>, See Also <samp><span
class="command">awk</span></samp></a>: <a href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-source-code_0040comma_007b_007d-obtaining-1873"><samp><span
class="command">gawk</span></samp>, source code, obtaining</a>: <a
href="#Getting">Getting</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-splitting-fields-and-444"><samp><span
class="command">gawk</span></samp>, splitting fields and</a>: <a
href="#Constant-Size">Constant Size</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-string_002dtranslation-functions-1268"><samp><span
class="command">gawk</span></samp>, string-translation functions</a>: <a
href="#I18N-Functions">I18N Functions</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-timestamps-1231"><samp><span
class="command">gawk</span></samp>, timestamps</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-_0040command_007bgawk_007d_002c-uses-for-9"><samp><span
class="command">gawk</span></samp>, uses for</a>: <a
href="#Preface">Preface</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-versions-of_002c-information-about_0040comma_007b_007d-printing-1552"><samp><span
class="command">gawk</span></samp>, versions of, information about,
printing</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-word_002dboundary-operator-309"><samp><span
class="command">gawk</span></samp>, word-boundary operator</a>: <a
href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a href="#index-General-Public-License-_0028GPL_0029-2069">General Public
License (GPL)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-General-Public-License_002c-See-GPL-37">General Public
License, See GPL</a>: <a href="#Manual-History">Manual History</a></li>
-<li><a
href="#index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-1189"><code>gensub</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-629"><code>gensub</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029_002c-escape-processing-1200"><code>gensub</code>
function (<samp><span class="command">gawk</span></samp>), escape
processing</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a
href="#index-_0040code_007bget_005factual_005fargument_007d-internal-function-2004"><code>get_actual_argument</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bget_005fargument_007d-internal-function-2003"><code>get_argument</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bget_005farray_005fargument_007d-internal-macro-2006"><code>get_array_argument</code>
internal macro</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bget_005fcurfunc_005farg_005fcount_007d-internal-function-1980"><code>get_curfunc_arg_count</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bget_005fscalar_005fargument_007d-internal-macro-2005"><code>get_scalar_argument</code>
internal macro</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bgetgrent_007d-function-_0028C-library_0029-1722"><code>getgrent</code>
function (C library)</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgrent_007d-user_002ddefined-function-1723"><code>getgrent</code>
user-defined function</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgrgid_007d-function-_0028C-library_0029-1733"><code>getgrgid</code>
function (C library)</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgrgid_007d-user_002ddefined-function-1734"><code>getgrgid</code>
user-defined function</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgrnam_007d-function-_0028C-library_0029-1731"><code>getgrnam</code>
function (C library)</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgrnam_007d-user_002ddefined-function-1732"><code>getgrnam</code>
user-defined function</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgruser_007d-function-_0028C-library_0029-1735"><code>getgruser</code>
function (C library)</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetgruser_007d-function_002c-user_002ddefined-1736"><code>getgruser</code>
function, user-defined</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command-347"><code>getline</code>
command</a>: <a href="#Reading-Files">Reading Files</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1729"><code>getline</code>
command, <code>_gr_init</code> user-defined function</a>: <a
href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fpw_005finit_007d-function-1708"><code>getline</code>
command, <code>_pw_init</code> function</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-593"><code>getline</code>
command, coprocesses, using from</a>: <a href="#Close-Files-And-Pipes">Close
Files And Pipes</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-482"><code>getline</code>
command, coprocesses, using from</a>: <a
href="#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-deadlock-and-1416"><code>getline</code>
command, deadlock and</a>: <a href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-explicit-input-with-456"><code>getline</code>
command, explicit input with</a>: <a href="#Getline">Getline</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-_0040code_007bFILENAME_007d-variable-and-495"><code>getline</code>
command, <code>FILENAME</code> variable and</a>: <a
href="#Getline-Notes">Getline Notes</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-return-values-460"><code>getline</code>
command, return values</a>: <a href="#Getline">Getline</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command_002c-variants-497"><code>getline</code>
command, variants</a>: <a href="#Getline-Summary">Getline Summary</a></li>
-<li><a
href="#index-_0040code_007bgetopt_007d-function-_0028C-library_0029-1687"><code>getopt</code>
function (C library)</a>: <a href="#Getopt-Function">Getopt Function</a></li>
-<li><a
href="#index-_0040code_007bgetopt_007d-user_002ddefined-function-1688"><code>getopt</code>
user-defined function</a>: <a href="#Getopt-Function">Getopt Function</a></li>
-<li><a
href="#index-_0040code_007bgetpwent_007d-function-_0028C-library_0029-1695"><code>getpwent</code>
function (C library)</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040code_007bgetpwent_007d-user_002ddefined-function-1696"><code>getpwent</code>
user-defined function</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="#index-_0040code_007bgetpwnam_007d-function-_0028C-library_0029-1709"><code>getpwnam</code>
function (C library)</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040code_007bgetpwnam_007d-user_002ddefined-function-1710"><code>getpwnam</code>
user-defined function</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="#index-_0040code_007bgetpwuid_007d-function-_0028C-library_0029-1711"><code>getpwuid</code>
function (C library)</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040code_007bgetpwuid_007d-user_002ddefined-function-1712"><code>getpwuid</code>
user-defined function</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="#index-_0040code_007bgetservbyname_007d-function-_0028C-library_0029-1427"><code>getservbyname</code>
function (C library)</a>: <a href="#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="#index-_0040code_007bgettext_007d-function-_0028C-library_0029-1323"><code>gettext</code>
function (C library)</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="#index-_0040code_007bgettext_007d-library-1307"><code>gettext</code>
library</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bgettext_007d-library_002c-locale-categories-1327"><code>gettext</code>
library, locale categories</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="#index-_0040code_007bgettimeofday_007d-user_002ddefined-function-1662"><code>gettimeofday</code>
user-defined function</a>: <a href="#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a href="#index-GNITS-mailing-list-54">GNITS mailing list</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-GNU-_0040command_007bawk_007d_002c-See-_0040command_007bgawk_007d-10">GNU
<samp><span class="command">awk</span></samp>, See <samp><span
class="command">gawk</span></samp></a>: <a href="#Preface">Preface</a></li>
-<li><a href="#index-GNU-Free-Documentation-License-2089">GNU Free
Documentation License</a>: <a href="#GNU-Free-Documentation-License">GNU Free
Documentation License</a></li>
-<li><a href="#index-GNU-General-Public-License-2070">GNU General Public
License</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-GNU-Lesser-General-Public-License-2078">GNU Lesser General
Public License</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-GNU-long-options-1479">GNU long options</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-GNU-long-options-1471">GNU long options</a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a href="#index-GNU-long-options_002c-printing-list-of-1516">GNU long
options, printing list of</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-GNU-Project-2073">GNU Project</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-GNU-Project-35">GNU Project</a>: <a
href="#Manual-History">Manual History</a></li>
-<li><a href="#index-GNU_002fLinux-2081">GNU/Linux</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-GNU_002fLinux-1918">GNU/Linux</a>: <a
href="#Atari-Compiling">Atari Compiling</a></li>
-<li><a href="#index-GNU_002fLinux-1886">GNU/Linux</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a href="#index-GNU_002fLinux-1383">GNU/Linux</a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a href="#index-GNU_002fLinux-40">GNU/Linux</a>: <a
href="#Manual-History">Manual History</a></li>
-<li><a href="#index-GPL-_0028General-Public-License_0029-2068">GPL (General
Public License)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-GPL-_0028General-Public-License_0029-36">GPL (General
Public License)</a>: <a href="#Manual-History">Manual History</a></li>
-<li><a
href="#index-GPL-_0028General-Public-License_0029_002c-printing-1504">GPL
(General Public License), printing</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-_0040command_007bgrcat_007d-program-1728"><samp><span
class="command">grcat</span></samp> program</a>: <a
href="#Group-Functions">Group Functions</a></li>
-<li><a href="#index-Grigera_002c-Juan-1933">Grigera, Juan</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Grigera_002c-Juan-1856">Grigera, Juan</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-group-database_002c-reading-1719">group database,
reading</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a href="#index-group-file-1726">group file</a>: <a
href="#Group-Functions">Group Functions</a></li>
-<li><a href="#index-groups_0040comma_007b_007d-information-about-1724">groups,
information about</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a href="#index-_0040code_007bgsub_007d-function-1188"><code>gsub</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a href="#index-_0040code_007bgsub_007d-function-631"><code>gsub</code>
function</a>: <a href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-_0040code_007bgsub_007d-function_002c-arguments-of-1186"><code>gsub</code>
function, arguments of</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-_0040code_007bgsub_007d-function_002c-escape-processing-1199"><code>gsub</code>
function, escape processing</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a href="#index-Hankerson_002c-Darrel-1932">Hankerson, Darrel</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Hankerson_002c-Darrel-1857">Hankerson, Darrel</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Hankerson_002c-Darrel-60">Hankerson, Darrel</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Hartholz_002c-Elaine-48">Hartholz, Elaine</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Hartholz_002c-Marshall-47">Hartholz, Marshall</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Hasegawa_002c-Isamu-1865">Hasegawa, Isamu</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Hasegawa_002c-Isamu-61">Hasegawa, Isamu</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-hexadecimal-numbers-611">hexadecimal numbers</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-hexadecimal-values_0040comma_007b_007d-enabling-interpretation-of-1524">hexadecimal
values, enabling interpretation of</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-_0040code_007bhistsort_002eawk_007d-program-1808"><code>histsort.awk</code>
program</a>: <a href="#History-Sorting">History Sorting</a></li>
-<li><a href="#index-Hughes_002c-Phil-51">Hughes, Phil</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-_0040code_007bHUP_007d-signal-1461"><code>HUP</code>
signal</a>: <a href="#Profiling">Profiling</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_007d-operator-824">hyphen
(<code>-</code>), <code>-</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operators-816">hyphen
(<code>-</code>), <code>--</code> (decrement/increment) operators</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-operator-723">hyphen
(<code>-</code>), <code>--</code> operator</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-874">hyphen
(<code>-</code>), <code>-=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-687">hyphen
(<code>-</code>), <code>-=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-filenames-beginning-with-1499">hyphen
(<code>-</code>), filenames beginning with</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-in-character-lists-264">hyphen
(<code>-</code>), in character lists</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a href="#index-_0040command_007bid_007d-utility-1764"><samp><span
class="command">id</span></samp> utility</a>: <a href="#Id-Program">Id
Program</a></li>
-<li><a
href="#index-_0040code_007bid_002eawk_007d-program-1765"><code>id.awk</code>
program</a>: <a href="#Id-Program">Id Program</a></li>
-<li><a href="#index-_0040code_007bif_007d-statement-950"><code>if</code>
statement</a>: <a href="#If-Statement">If Statement</a></li>
-<li><a href="#index-_0040code_007bif_007d-statement-179"><code>if</code>
statement</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="#index-_0040code_007bif_007d-statement_002c-actions_0040comma_007b_007d-changing-909"><code>if</code>
statement, actions, changing</a>: <a href="#Ranges">Ranges</a></li>
-<li><a
href="#index-_0040code_007bigawk_002esh_007d-program-1819"><code>igawk.sh</code>
program</a>: <a href="#Igawk-Program">Igawk Program</a></li>
-<li><a
href="#index-_0040code_007bIGNORECASE_007d-variable-1013"><code>IGNORECASE</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bIGNORECASE_007d-variable-323"><code>IGNORECASE</code>
variable</a>: <a href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="#index-_0040code_007bIGNORECASE_007d-variable_002c-array-sorting-and-1139"><code>IGNORECASE</code>
variable, array sorting and</a>: <a href="#Array-Sorting">Array
Sorting</a></li>
-<li><a
href="#index-_0040code_007bIGNORECASE_007d-variable_002c-array-subscripts-and-1089"><code>IGNORECASE</code>
variable, array subscripts and</a>: <a href="#Array-Intro">Array Intro</a></li>
-<li><a
href="#index-_0040code_007bIGNORECASE_007d-variable_002c-in-example-programs-1596"><code>IGNORECASE</code>
variable, in example programs</a>: <a href="#Library-Functions">Library
Functions</a></li>
-<li><a
href="#index-implementation-issues_002c-_0040command_007bgawk_007d-1950">implementation
issues, <samp><span class="command">gawk</span></samp></a>: <a
href="#Notes">Notes</a></li>
-<li><a
href="#index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-debugging-1954">implementation
issues, <samp><span class="command">gawk</span></samp>, debugging</a>: <a
href="#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="#index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-limits-562">implementation
issues, <samp><span class="command">gawk</span></samp>, limits</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-implementation-issues_002c-_0040command_007bgawk_007d_002c-limits-489">implementation
issues, <samp><span class="command">gawk</span></samp>, limits</a>: <a
href="#Getline-Notes">Getline Notes</a></li>
-<li><a href="#index-_0040code_007bin_007d-operator-1766"><code>in</code>
operator</a>: <a href="#Id-Program">Id Program</a></li>
-<li><a href="#index-_0040code_007bin_007d-operator-864"><code>in</code>
operator</a>: <a href="#Precedence">Precedence</a></li>
-<li><a href="#index-_0040code_007bin_007d-operator-764"><code>in</code>
operator</a>: <a href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007bin_007d-operator_002c-arrays-and-1098"><code>in</code>
operator, arrays and</a>: <a href="#Scanning-an-Array">Scanning an
Array</a></li>
-<li><a
href="#index-_0040code_007bin_007d-operator_002c-arrays-and-1092"><code>in</code>
operator, arrays and</a>: <a href="#Reference-to-Elements">Reference to
Elements</a></li>
-<li><a href="#index-increment-operators-711">increment operators</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-_0040code_007bindex_007d-function-1165"><code>index</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a href="#index-indexing-arrays-1082">indexing arrays</a>: <a
href="#Array-Intro">Array Intro</a></li>
-<li><a href="#index-initialization_002c-automatic-149">initialization,
automatic</a>: <a href="#More-Complex">More Complex</a></li>
-<li><a href="#index-input-files-343">input files</a>: <a
href="#Reading-Files">Reading Files</a></li>
-<li><a href="#index-input-files_002c-closing-589">input files, closing</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a href="#index-input-files_002c-counting-elements-in-1780">input files,
counting elements in</a>: <a href="#Wc-Program">Wc Program</a></li>
-<li><a href="#index-input-files_002c-examples-135">input files, examples</a>:
<a href="#Sample-Data-Files">Sample Data Files</a></li>
-<li><a href="#index-input-files_002c-reading-342">input files, reading</a>: <a
href="#Reading-Files">Reading Files</a></li>
-<li><a
href="#index-input-files_002c-running-_0040command_007bawk_007d-without-86">input
files, running <samp><span class="command">awk</span></samp> without</a>: <a
href="#Read-Terminal">Read Terminal</a></li>
-<li><a href="#index-input-files_002c-skipping-1613">input files, skipping</a>:
<a href="#Nextfile-Function">Nextfile Function</a></li>
-<li><a href="#index-input-files_002c-variable-assignments-and-1565">input
files, variable assignments and</a>: <a href="#Other-Arguments">Other
Arguments</a></li>
-<li><a href="#index-input-pipeline-472">input pipeline</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-input-redirection-462">input redirection</a>: <a
href="#Getline_002fFile">Getline/File</a></li>
-<li><a
href="#index-input_002c-data_0040comma_007b_007d-nondecimal-1400">input, data,
nondecimal</a>: <a href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a href="#index-input_002c-explicit-457">input, explicit</a>: <a
href="#Getline">Getline</a></li>
-<li><a href="#index-input_002c-files_002c-See-input-files-448">input, files,
See input files</a>: <a href="#Multiple-Line">Multiple Line</a></li>
-<li><a href="#index-input_002c-multiline-records-446">input, multiline
records</a>: <a href="#Multiple-Line">Multiple Line</a></li>
-<li><a href="#index-input_002c-splitting-into-records-348">input, splitting
into records</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-input_002c-standard-569">input, standard</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a href="#index-input_002c-standard-85">input, standard</a>: <a
href="#Read-Terminal">Read Terminal</a></li>
-<li><a href="#index-input_002foutput_002c-binary-997">input/output,
binary</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-input_002foutput_002c-from-_0040code_007bBEGIN_007d-and-_0040code_007bEND_007d-916">input/output,
from <code>BEGIN</code> and <code>END</code></a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a href="#index-input_002foutput_002c-two_002dway-1410">input/output,
two-way</a>: <a href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="#index-insomnia_002c-cure-for-1791">insomnia, cure for</a>: <a
href="#Alarm-Program">Alarm Program</a></li>
-<li><a href="#index-installation_002c-amiga-1897">installation, amiga</a>: <a
href="#Amiga-Installation">Amiga Installation</a></li>
-<li><a href="#index-installation_002c-atari-1916">installation, atari</a>: <a
href="#Atari-Installation">Atari Installation</a></li>
-<li><a href="#index-installation_002c-beos-1899">installation, beos</a>: <a
href="#BeOS-Installation">BeOS Installation</a></li>
-<li><a href="#index-installation_002c-tandem-1920">installation, tandem</a>:
<a href="#Tandem-Installation">Tandem Installation</a></li>
-<li><a href="#index-installation_002c-vms-1912">installation, vms</a>: <a
href="#VMS-Installation">VMS Installation</a></li>
-<li><a href="#index-installing-_0040command_007bgawk_007d-1871">installing
<samp><span class="command">gawk</span></samp></a>: <a
href="#Installation">Installation</a></li>
-<li><a href="#index-_0040code_007bint_007d-function-1150"><code>int</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a
href="#index-_0040code_007bINT_007d-signal-_0028MS_002dDOS_0029-1463"><code>INT</code>
signal (MS-DOS)</a>: <a href="#Profiling">Profiling</a></li>
-<li><a href="#index-integers-2038">integers</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-integers_002c-unsigned-2042">integers, unsigned</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-interacting-with-other-programs-1220">interacting with
other programs</a>: <a href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a href="#index-internationalization-1303">internationalization</a>: <a
href="#I18N-and-L10N">I18N and L10N</a></li>
-<li><a href="#index-internationalization-1270">internationalization</a>: <a
href="#I18N-Functions">I18N Functions</a></li>
-<li><a
href="#index-internationalization_002c-localization-1300">internationalization,
localization</a>: <a href="#Internationalization">Internationalization</a></li>
-<li><a
href="#index-internationalization_002c-localization-1040">internationalization,
localization</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-internationalization_002c-localization_002c-character-classes-277">internationalization,
localization, character classes</a>: <a href="#Character-Lists">Character
Lists</a></li>
-<li><a
href="#index-internationalization_002c-localization_002c-_0040command_007bgawk_007d-and-1302">internationalization,
localization, <samp><span class="command">gawk</span></samp> and</a>: <a
href="#Internationalization">Internationalization</a></li>
-<li><a
href="#index-internationalization_002c-localization_002c-locale-categories-1326">internationalization,
localization, locale categories</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="#index-internationalization_002c-localization_002c-marked-strings-1344">internationalization,
localization, marked strings</a>: <a href="#Programmer-i18n">Programmer
i18n</a></li>
-<li><a
href="#index-internationalization_002c-localization_002c-portability-and-1377">internationalization,
localization, portability and</a>: <a href="#I18N-Portability">I18N
Portability</a></li>
-<li><a href="#index-internationalizing-a-program-1306">internationalizing a
program</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="#index-interpreted-programs-2074">interpreted programs</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-interpreted-programs-2027">interpreted programs</a>: <a
href="#Basic-High-Level">Basic High Level</a></li>
-<li><a href="#index-interval-expressions-249">interval expressions</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007binventory_002dshipped_007d-file-137"><code>inventory-shipped</code>
file</a>: <a href="#Sample-Data-Files">Sample Data Files</a></li>
-<li><a href="#index-ISO-2075">ISO</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-ISO-8859_002d1-2058">ISO 8859-1</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-ISO-Latin_002d1-2059">ISO Latin-1</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-Jacobs_002c-Andrew-1703">Jacobs, Andrew</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-Jaegermann_002c-Michal-1853">Jaegermann, Michal</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Jaegermann_002c-Michal-62">Jaegermann, Michal</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Jedi-knights-1582">Jedi knights</a>: <a
href="#Undocumented">Undocumented</a></li>
-<li><a
href="#index-_0040code_007bjoin_007d-user_002ddefined-function-1657"><code>join</code>
user-defined function</a>: <a href="#Join-Function">Join Function</a></li>
-<li><a href="#index-Kahrs_002c-J_0040_0022urgen-1859">Kahrs, Jürgen</a>:
<a href="#Contributors">Contributors</a></li>
-<li><a href="#index-Kahrs_002c-J_0040_0022urgen-63">Kahrs, Jürgen</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Kenobi_002c-Obi_002dWan-1581">Kenobi, Obi-Wan</a>: <a
href="#Undocumented">Undocumented</a></li>
-<li><a href="#index-Kernighan_002c-Brian-2046">Kernighan, Brian</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-Kernighan_002c-Brian-1938">Kernighan, Brian</a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a href="#index-Kernighan_002c-Brian-1840">Kernighan, Brian</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Kernighan_002c-Brian-1832">Kernighan, Brian</a>: <a
href="#BTL">BTL</a></li>
-<li><a href="#index-Kernighan_002c-Brian-662">Kernighan, Brian</a>: <a
href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-Kernighan_002c-Brian-67">Kernighan, Brian</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Kernighan_002c-Brian-29">Kernighan, Brian</a>: <a
href="#Conventions">Conventions</a></li>
-<li><a href="#index-Kernighan_002c-Brian-15">Kernighan, Brian</a>: <a
href="#History">History</a></li>
-<li><a
href="#index-_0040command_007bkill_007d-command_0040comma_007b_007d-dynamic-profiling-1458"><samp><span
class="command">kill</span></samp> command, dynamic profiling</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a href="#index-Knights_002c-jedi-1583">Knights, jedi</a>: <a
href="#Undocumented">Undocumented</a></li>
-<li><a href="#index-Kwok_002c-Conrad-1848">Kwok, Conrad</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a
href="#index-_0040code_007blabels_002eawk_007d-program-1802"><code>labels.awk</code>
program</a>: <a href="#Labels-Program">Labels Program</a></li>
-<li><a
href="#index-languages_0040comma_007b_007d-data_002ddriven-2033">languages,
data-driven</a>: <a href="#Basic-High-Level">Basic High Level</a></li>
-<li><a
href="#index-_0040code_007bLC_005fALL_007d-locale-category-1341"><code>LC_ALL</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fCOLLATE_007d-locale-category-1331"><code>LC_COLLATE</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fCTYPE_007d-locale-category-1332"><code>LC_CTYPE</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fMESSAGES_007d-locale-category-1329"><code>LC_MESSAGES</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fMESSAGES_007d-locale-category_002c-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1357"><code>LC_MESSAGES</code>
locale category, <code>bindtextdomain</code> function (<samp><span
class="command">gawk</span></samp>)</a>: <a href="#Programmer-i18n">Programmer
i18n</a></li>
-<li><a
href="#index-_0040code_007bLC_005fMONETARY_007d-locale-category-1335"><code>LC_MONETARY</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fNUMERIC_007d-locale-category-1336"><code>LC_NUMERIC</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fRESPONSE_007d-locale-category-1337"><code>LC_RESPONSE</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-_0040code_007bLC_005fTIME_007d-locale-category-1340"><code>LC_TIME</code>
locale category</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-838">left
angle bracket (<code><</code>), <code><</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-749">left
angle bracket (<code><</code>), <code><</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-465">left
angle bracket (<code><</code>), <code><</code> operator (I/O)</a>: <a
href="#Getline_002fFile">Getline/File</a></li>
-<li><a
href="#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-840">left
angle bracket (<code><</code>), <code><=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-751">left
angle bracket (<code><</code>), <code><=</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-left-shift_002c-bitwise-1253">left shift, bitwise</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-leftmost-longest-match-451">leftmost longest match</a>: <a
href="#Multiple-Line">Multiple Line</a></li>
-<li><a
href="#index-_0040code_007blength_007d-function-1167"><code>length</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a href="#index-Lesser-General-Public-License-_0028LGPL_0029-2077">Lesser
General Public License (LGPL)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a href="#index-LGPL-_0028Lesser-General-Public-License_0029-2076">LGPL
(Lesser General Public License)</a>: <a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions-1590">libraries
of <samp><span class="command">awk</span></samp> functions</a>: <a
href="#Library-Functions">Library Functions</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-assertions-1622">libraries
of <samp><span class="command">awk</span></samp> functions, assertions</a>: <a
href="#Assert-Function">Assert Function</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-associative-arrays-and-1610">libraries
of <samp><span class="command">awk</span></samp> functions, associative arrays
and</a>: <a href="#Library-Names">Library Names</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-character-values-as-numbers-1642">libraries
of <samp><span class="command">awk</span></samp> functions, character values
as numbers</a>: <a href="#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-command_002dline-options-1681">libraries
of <samp><span class="command">awk</span></samp> functions, command-line
options</a>: <a href="#Getopt-Function">Getopt Function</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-example-program-for-using-1817">libraries
of <samp><span class="command">awk</span></samp> functions, example program
for using</a>: <a href="#Igawk-Program">Igawk Program</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-group-database_002c-reading-1717">libraries
of <samp><span class="command">awk</span></samp> functions, group database,
reading</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-_0040value_007bDF_007ds-1664">libraries
of <samp><span class="command">awk</span></samp> functions, managing, data
files</a>: <a href="#Data-File-Management">Data File Management</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-time-1658">libraries
of <samp><span class="command">awk</span></samp> functions, managing,
time</a>: <a href="#Gettimeofday-Function">Gettimeofday Function</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-merging-arrays-into-strings-1653">libraries
of <samp><span class="command">awk</span></samp> functions, merging arrays
into strings</a>: <a href="#Join-Function">Join Function</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-_0040code_007bnextfile_007d-statement-1614">libraries
of <samp><span class="command">awk</span></samp> functions,
<code>nextfile</code> statement</a>: <a href="#Nextfile-Function">Nextfile
Function</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-rounding-numbers-1631">libraries
of <samp><span class="command">awk</span></samp> functions, rounding
numbers</a>: <a href="#Round-Function">Round Function</a></li>
-<li><a
href="#index-libraries-of-_0040command_007bawk_007d-functions_002c-user-database_002c-reading-1690">libraries
of <samp><span class="command">awk</span></samp> functions, user database,
reading</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-line-breaks-150">line breaks</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a href="#index-line-continuations-790">line continuations</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-line-continuations_002c-_0040command_007bgawk_007d-802">line
continuations, <samp><span class="command">gawk</span></samp></a>: <a
href="#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="#index-line-continuations_002c-in-_0040code_007bprint_007d-statement-512">line
continuations, in <code>print</code> statement</a>: <a
href="#Print-Examples">Print Examples</a></li>
-<li><a href="#index-line-continuations_002c-with-C-shell-148">line
continuations, with C shell</a>: <a href="#More-Complex">More Complex</a></li>
-<li><a href="#index-lines_002c-blank_002c-printing-503">lines, blank,
printing</a>: <a href="#Print">Print</a></li>
-<li><a href="#index-lines_002c-counting-1783">lines, counting</a>: <a
href="#Wc-Program">Wc Program</a></li>
-<li><a
href="#index-lines_002c-duplicate_0040comma_007b_007d-removing-1806">lines,
duplicate, removing</a>: <a href="#History-Sorting">History Sorting</a></li>
-<li><a href="#index-lines_002c-matching-ranges-of-906">lines, matching ranges
of</a>: <a href="#Ranges">Ranges</a></li>
-<li><a href="#index-lines_002c-skipping-between-markers-910">lines, skipping
between markers</a>: <a href="#Ranges">Ranges</a></li>
-<li><a href="#index-lint-checking-1021">lint checking</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-lint-checking_002c-array-elements-1108">lint checking,
array elements</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-lint-checking_002c-array-subscripts-1126">lint checking,
array subscripts</a>: <a href="#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a href="#index-lint-checking_002c-empty-programs-1475">lint checking,
empty programs</a>: <a href="#Command-Line">Command Line</a></li>
-<li><a href="#index-lint-checking_002c-issuing-warnings-1520">lint checking,
issuing warnings</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-lint-checking_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1557">lint
checking, <code>POSIXLY_CORRECT</code> environment variable</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-lint-checking_002c-undefined-functions-1296">lint
checking, undefined functions</a>: <a href="#Function-Caveats">Function
Caveats</a></li>
-<li><a href="#index-_0040code_007bLINT_007d-variable-1019"><code>LINT</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-Linux-2080">Linux</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-Linux-1917">Linux</a>: <a href="#Atari-Compiling">Atari
Compiling</a></li>
-<li><a href="#index-Linux-1885">Linux</a>: <a
href="#Additional-Configuration-Options">Additional Configuration
Options</a></li>
-<li><a href="#index-Linux-1382">Linux</a>: <a href="#I18N-Example">I18N
Example</a></li>
-<li><a href="#index-Linux-39">Linux</a>: <a href="#Manual-History">Manual
History</a></li>
-<li><a href="#index-locale-categories-1328">locale categories</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="#index-localization-1305">localization</a>: <a
href="#I18N-and-L10N">I18N and L10N</a></li>
-<li><a
href="#index-localization_002c-See-internationalization_0040comma_007b_007d-localization-1304">localization,
See internationalization, localization</a>: <a href="#I18N-and-L10N">I18N and
L10N</a></li>
-<li><a href="#index-log-files_002c-timestamps-in-1229">log files, timestamps
in</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-_0040code_007blog_007d-function-1153"><code>log</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-logical-false_002ftrue-732">logical false/true</a>: <a
href="#Truth-Values">Truth Values</a></li>
-<li><a
href="#index-logical-operators_002c-See-Boolean-expressions-781">logical
operators, See Boolean expressions</a>: <a href="#Boolean-Ops">Boolean
Ops</a></li>
-<li><a href="#index-login-information-1698">login information</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-long-options-1472">long options</a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a href="#index-loops-952">loops</a>: <a href="#While-Statement">While
Statement</a></li>
-<li><a
href="#index-loops_002c-_0040code_007bcontinue_007d-statements-and-957">loops,
<code>continue</code> statements and</a>: <a href="#For-Statement">For
Statement</a></li>
-<li><a href="#index-loops_002c-count-for-header-1449">loops, count for
header</a>: <a href="#Profiling">Profiling</a></li>
-<li><a href="#index-loops_002c-exiting-962">loops, exiting</a>: <a
href="#Break-Statement">Break Statement</a></li>
-<li><a
href="#index-loops_002c-See-Also-_0040code_007bwhile_007d-statement-953">loops,
See Also <code>while</code> statement</a>: <a href="#While-Statement">While
Statement</a></li>
-<li><a href="#index-Lost-In-Space-1965">Lost In Space</a>: <a
href="#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a href="#index-_0040command_007bls_007d-utility-145"><samp><span
class="command">ls</span></samp> utility</a>: <a href="#More-Complex">More
Complex</a></li>
-<li><a
href="#index-_0040code_007blshift_007d-function-_0028_0040command_007bgawk_007d_0029-1261"><code>lshift</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-lvalues_002frvalues-676">lvalues/rvalues</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-mailing-labels_0040comma_007b_007d-printing-1801">mailing
labels, printing</a>: <a href="#Labels-Program">Labels Program</a></li>
-<li><a href="#index-mailing-list_002c-GNITS-55">mailing list, GNITS</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-_0040code_007bmake_005fbuiltin_007d-internal-function-2001"><code>make_builtin</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bmake_005fnumber_007d-internal-function-1994"><code>make_number</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bmake_005fstring_007d-internal-function-1992"><code>make_string</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-mark-parity-1652">mark parity</a>: <a
href="#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="#index-marked-string-extraction-_0028internationalization_0029-1367">marked
string extraction (internationalization)</a>: <a
href="#String-Extraction">String Extraction</a></li>
-<li><a href="#index-marked-strings_0040comma_007b_007d-extracting-1363">marked
strings, extracting</a>: <a href="#String-Extraction">String Extraction</a></li>
-<li><a href="#index-Marx_002c-Groucho-729">Marx, Groucho</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-_0040code_007bmatch_007d-function-1170"><code>match</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bmatch_007d-function_002c-_0040code_007bRSTART_007d_002f_0040code_007bRLENGTH_007d-variables-1173"><code>match</code>
function, <code>RSTART</code>/<code>RLENGTH</code> variables</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-matching_002c-expressions_002c-See-comparison-expressions-740">matching,
expressions, See comparison expressions</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-matching_002c-leftmost-longest-452">matching, leftmost
longest</a>: <a href="#Multiple-Line">Multiple Line</a></li>
-<li><a href="#index-matching_002c-null-strings-1207">matching, null
strings</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a href="#index-_0040command_007bmawk_007d-program-1941"><samp><span
class="command">mawk</span></samp> program</a>: <a href="#Other-Versions">Other
Versions</a></li>
-<li><a href="#index-McPhee_002c-Patrick-1867">McPhee, Patrick</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-memory_002c-releasing-1999">memory, releasing</a>: <a
href="#Internals">Internals</a></li>
-<li><a href="#index-memory_002c-setting-limits-1494">memory, setting
limits</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-message-object-files-1316">message object files</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-message-object-files_002c-converting-from-portable-object-files-1390">message
object files, converting from portable object files</a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a
href="#index-message-object-files_002c-specifying-directory-of-1350">message
object files, specifying directory of</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-message-object-files_002c-specifying-directory-of-1321">message
object files, specifying directory of</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-metacharacters_002c-escape-sequences-for-219">metacharacters,
escape sequences for</a>: <a href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-_0040code_007bmktime_007d-function-_0028_0040command_007bgawk_007d_0029-1237"><code>mktime</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a
href="#index-modifiers_0040comma_007b_007d-in-format-specifiers-537">modifiers,
in format specifiers</a>: <a href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a href="#index-monetary-information_002c-localization-1333">monetary
information, localization</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a href="#index-_0040command_007bmsgfmt_007d-utility-1392"><samp><span
class="command">msgfmt</span></samp> utility</a>: <a href="#I18N-Example">I18N
Example</a></li>
-<li><a href="#index-names_002c-arrays_002fvariables-1597">names,
arrays/variables</a>: <a href="#Library-Names">Library Names</a></li>
-<li><a href="#index-names_002c-arrays_002fvariables-1079">names,
arrays/variables</a>: <a href="#Arrays">Arrays</a></li>
-<li><a href="#index-names_002c-functions-1598">names, functions</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a href="#index-names_002c-functions-1278">names, functions</a>: <a
href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a href="#index-namespace-issues-1599">namespace issues</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a href="#index-namespace-issues-1080">namespace issues</a>: <a
href="#Arrays">Arrays</a></li>
-<li><a href="#index-namespace-issues_002c-functions-1280">namespace issues,
functions</a>: <a href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a href="#index-_0040command_007bnawk_007d-utility-22"><samp><span
class="command">nawk</span></samp> utility</a>: <a href="#Names">Names</a></li>
-<li><a href="#index-negative-zero-2049">negative zero</a>: <a
href="#Floating-Point-Issues">Floating Point Issues</a></li>
-<li><a href="#index-NetBSD-2084">NetBSD</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-networks_002c-programming-1420">networks, programming</a>:
<a href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a href="#index-networks_002c-support-for-583">networks, support for</a>:
<a href="#Special-Network">Special Network</a></li>
-<li><a href="#index-newlines-1531">newlines</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-newlines-793">newlines</a>: <a href="#Boolean-Ops">Boolean
Ops</a></li>
-<li><a href="#index-newlines-151">newlines</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a href="#index-newlines_002c-as-field-separators-411">newlines, as field
separators</a>: <a href="#Field-Separators">Field Separators</a></li>
-<li><a href="#index-newlines_002c-as-record-separators-354">newlines, as
record separators</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-newlines_002c-in-dynamic-regexps-340">newlines, in dynamic
regexps</a>: <a href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a href="#index-newlines_002c-in-regexp-constants-341">newlines, in regexp
constants</a>: <a href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a href="#index-newlines_002c-printing-505">newlines, printing</a>: <a
href="#Print-Examples">Print Examples</a></li>
-<li><a
href="#index-newlines_002c-separating-statements-in-actions-947">newlines,
separating statements in actions</a>: <a href="#Statements">Statements</a></li>
-<li><a
href="#index-newlines_002c-separating-statements-in-actions-935">newlines,
separating statements in actions</a>: <a href="#Action-Overview">Action
Overview</a></li>
-<li><a href="#index-_0040code_007bnext-file_007d-statement-1836"><code>next
file</code> statement</a>: <a href="#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="#index-_0040code_007bnext-file_007d-statement_002c-deprecated-1576"><code>next
file</code> statement, deprecated</a>: <a href="#Obsolete">Obsolete</a></li>
-<li><a
href="#index-_0040code_007bnext-file_007d-statement_002c-in-_0040command_007bgawk_007d-981"><code>next
file</code> statement, in <samp><span class="command">gawk</span></samp></a>:
<a href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a href="#index-_0040code_007bnext_007d-statement-970"><code>next</code>
statement</a>: <a href="#Next-Statement">Next Statement</a></li>
-<li><a href="#index-_0040code_007bnext_007d-statement-796"><code>next</code>
statement</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-_0040code_007bnext_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-922"><code>next</code>
statement, <code>BEGIN</code>/<code>END</code> patterns and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bnext_007d-statement_002c-user_002ddefined-functions-and-975"><code>next</code>
statement, user-defined functions and</a>: <a href="#Next-Statement">Next
Statement</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-statement-977"><code>nextfile</code>
statement</a>: <a href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-923"><code>nextfile</code>
statement, <code>BEGIN</code>/<code>END</code> patterns and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-statement_002c-implementing-1616"><code>nextfile</code>
statement, implementing</a>: <a href="#Nextfile-Function">Nextfile
Function</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-statement_002c-in-_0040command_007bgawk_007d-983"><code>nextfile</code>
statement, in <samp><span class="command">gawk</span></samp></a>: <a
href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bnext-file_007d-statement-and-1577"><code>nextfile</code>
statement, <code>next file</code> statement and</a>: <a
href="#Obsolete">Obsolete</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-statement_002c-user_002ddefined-functions-and-980"><code>nextfile</code>
statement, user-defined functions and</a>: <a
href="#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="#index-_0040code_007bnextfile_007d-user_002ddefined-function-1619"><code>nextfile</code>
user-defined function</a>: <a href="#Nextfile-Function">Nextfile
Function</a></li>
-<li><a href="#index-_0040code_007bNF_007d-variable-1059"><code>NF</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-_0040code_007bNF_007d-variable-388"><code>NF</code>
variable</a>: <a href="#Fields">Fields</a></li>
-<li><a
href="#index-_0040code_007bNF_007d-variable_002c-decrementing-399"><code>NF</code>
variable, decrementing</a>: <a href="#Changing-Fields">Changing Fields</a></li>
-<li><a
href="#index-_0040code_007bnoassign_002eawk_007d-program-1680"><code>noassign.awk</code>
program</a>: <a href="#Ignoring-Assigns">Ignoring Assigns</a></li>
-<li><a
href="#index-_0040code_007bNODE_007d-internal-type-1974"><code>NODE</code>
internal type</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-nodes_0040comma_007b_007d-duplicating-1997">nodes,
duplicating</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-not-Boolean_002dlogic-operator-776">not Boolean-logic
operator</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-_0040code_007bNR_007d-variable-1060"><code>NR</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-_0040code_007bNR_007d-variable-350"><code>NR</code>
variable</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-_0040code_007bNR_007d-variable_002c-changing-1067"><code>NR</code>
variable, changing</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-null-strings-2045">null strings</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-null-strings-735">null strings</a>: <a
href="#Truth-Values">Truth Values</a></li>
-<li><a href="#index-null-strings-415">null strings</a>: <a
href="#Regexp-Field-Splitting">Regexp Field Splitting</a></li>
-<li><a href="#index-null-strings-360">null strings</a>: <a
href="#Records">Records</a></li>
-<li><a href="#index-null-strings_002c-array-elements-and-1107">null strings,
array elements and</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-null-strings_002c-as-array-subscripts-1124">null strings,
as array subscripts</a>: <a href="#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a href="#index-null-strings_002c-converting-numbers-to-strings-644">null
strings, converting numbers to strings</a>: <a
href="#Conversion">Conversion</a></li>
-<li><a href="#index-null-strings_002c-matching-1208">null strings,
matching</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a href="#index-null-strings_002c-quoting-and-133">null strings, quoting
and</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-106">number
sign (<code>#</code>), <code>#!</code> (executable scripts)</a>: <a
href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="#index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-109">number
sign (<code>#</code>), <code>#!</code> (executable scripts), portability
issues with</a>: <a href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="#index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-commenting-114">number
sign (<code>#</code>), commenting</a>: <a href="#Comments">Comments</a></li>
-<li><a href="#index-numbers-1993">numbers</a>: <a
href="#Internals">Internals</a></li>
-<li><a href="#index-numbers_002c-as-array-subscripts-1115">numbers, as array
subscripts</a>: <a href="#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a href="#index-numbers_002c-as-values-of-characters-1645">numbers, as
values of characters</a>: <a href="#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a href="#index-numbers_002c-Cliff-random-1639">numbers, Cliff random</a>:
<a href="#Cliff-Random-Function">Cliff Random Function</a></li>
-<li><a href="#index-numbers_002c-converting-642">numbers, converting</a>: <a
href="#Conversion">Conversion</a></li>
-<li><a href="#index-numbers_002c-converting_002c-to-strings-1265">numbers,
converting, to strings</a>: <a href="#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="#index-numbers_002c-converting_002c-to-strings-1001">numbers,
converting, to strings</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-numbers_002c-floating_002dpoint-2040">numbers,
floating-point</a>: <a href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a
href="#index-numbers_002c-floating_002dpoint_002c-_0040code_007bAWKNUM_007d-internal-type-1972">numbers,
floating-point, <code>AWKNUM</code> internal type</a>: <a
href="#Internals">Internals</a></li>
-<li><a href="#index-numbers_002c-hexadecimal-613">numbers, hexadecimal</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-numbers_002c-_0040code_007bNODE_007d-internal-type-1976">numbers,
<code>NODE</code> internal type</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-numbers_002c-octal-612">numbers, octal</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a href="#index-numbers_002c-random-1159">numbers, random</a>: <a
href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-numbers_002c-rounding-1630">numbers, rounding</a>: <a
href="#Round-Function">Round Function</a></li>
-<li><a href="#index-numeric_002c-constants-606">numeric, constants</a>: <a
href="#Scalar-Constants">Scalar Constants</a></li>
-<li><a href="#index-numeric_002c-output-format-519">numeric, output
format</a>: <a href="#OFMT">OFMT</a></li>
-<li><a href="#index-numeric_002c-strings-745">numeric, strings</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-numeric_002c-values-1978">numeric, values</a>: <a
href="#Internals">Internals</a></li>
-<li><a href="#index-_0040command_007boawk_007d-utility-23"><samp><span
class="command">oawk</span></samp> utility</a>: <a href="#Names">Names</a></li>
-<li><a href="#index-obsolete-features-1575">obsolete features</a>: <a
href="#Obsolete">Obsolete</a></li>
-<li><a href="#index-octal-numbers-610">octal numbers</a>: <a
href="#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="#index-octal-values_0040comma_007b_007d-enabling-interpretation-of-1525">octal
values, enabling interpretation of</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-_0040code_007bOFMT_007d-variable-1023"><code>OFMT</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-_0040code_007bOFMT_007d-variable-649"><code>OFMT</code>
variable</a>: <a href="#Conversion">Conversion</a></li>
-<li><a href="#index-_0040code_007bOFMT_007d-variable-522"><code>OFMT</code>
variable</a>: <a href="#OFMT">OFMT</a></li>
-<li><a
href="#index-_0040code_007bOFMT_007d-variable_002c-POSIX-_0040command_007bawk_007d-and-526"><code>OFMT</code>
variable, POSIX <samp><span class="command">awk</span></samp> and</a>: <a
href="#OFMT">OFMT</a></li>
-<li><a href="#index-_0040code_007bOFS_007d-variable-1028"><code>OFS</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-_0040code_007bOFS_007d-variable-514"><code>OFS</code>
variable</a>: <a href="#Output-Separators">Output Separators</a></li>
-<li><a href="#index-_0040code_007bOFS_007d-variable-395"><code>OFS</code>
variable</a>: <a href="#Changing-Fields">Changing Fields</a></li>
-<li><a href="#index-OpenBSD-2086">OpenBSD</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-operating-systems_002c-BSD_002dbased-1435">operating
systems, BSD-based</a>: <a href="#Portal-Files">Portal Files</a></li>
-<li><a href="#index-operating-systems_002c-BSD_002dbased-41">operating
systems, BSD-based</a>: <a href="#Manual-History">Manual History</a></li>
-<li><a
href="#index-operating-systems_002c-PC_002c-_0040command_007bgawk_007d-on-1902">operating
systems, PC, <samp><span class="command">gawk</span></samp> on</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-operating-systems_002c-PC_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1901">operating
systems, PC, <samp><span class="command">gawk</span></samp> on,
installing</a>: <a href="#PC-Installation">PC Installation</a></li>
-<li><a
href="#index-operating-systems_002c-porting-_0040command_007bgawk_007d-to-1961">operating
systems, porting <samp><span class="command">gawk</span></samp> to</a>: <a
href="#New-Ports">New Ports</a></li>
-<li><a
href="#index-operating-systems_002c-See-Also-GNU_002fLinux_002c-PC-operating-systems_002c-Unix-1869">operating
systems, See Also GNU/Linux, PC operating systems, Unix</a>: <a
href="#Installation">Installation</a></li>
-<li><a href="#index-operations_002c-bitwise-1249">operations, bitwise</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-operators_002c-arithmetic-653">operators, arithmetic</a>:
<a href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a href="#index-operators_002c-assignment-671">operators, assignment</a>:
<a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-operators_002c-assignment_002c-evaluation-order-684">operators,
assignment, evaluation order</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="#index-operators_002c-Boolean_002c-See-Boolean-expressions-779">operators,
Boolean, See Boolean expressions</a>: <a href="#Boolean-Ops">Boolean
Ops</a></li>
-<li><a href="#index-operators_002c-decrement_002fincrement-712">operators,
decrement/increment</a>: <a href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-operators_002c-GNU_002dspecific-282">operators,
GNU-specific</a>: <a href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a href="#index-operators_002c-input_002foutput-851">operators,
input/output</a>: <a href="#Precedence">Precedence</a></li>
-<li><a href="#index-operators_002c-input_002foutput-550">operators,
input/output</a>: <a href="#Redirection">Redirection</a></li>
-<li><a href="#index-operators_002c-input_002foutput-485">operators,
input/output</a>: <a href="#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a href="#index-operators_002c-input_002foutput-474">operators,
input/output</a>: <a href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-operators_002c-input_002foutput-466">operators,
input/output</a>: <a href="#Getline_002fFile">Getline/File</a></li>
-<li><a
href="#index-operators_002c-logical_002c-See-Boolean-expressions-782">operators,
logical, See Boolean expressions</a>: <a href="#Boolean-Ops">Boolean
Ops</a></li>
-<li><a href="#index-operators_002c-precedence-810">operators, precedence</a>:
<a href="#Precedence">Precedence</a></li>
-<li><a href="#index-operators_002c-precedence-726">operators, precedence</a>:
<a href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-operators_002c-relational_002c-See-operators_0040comma_007b_007d-comparison-742">operators,
relational, See operators, comparison</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-operators_002c-short_002dcircuit-785">operators,
short-circuit</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-operators_002c-string-664">operators, string</a>: <a
href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-operators_002c-string_002dmatching-174">operators,
string-matching</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="#index-operators_002c-string_002dmatching_002c-for-buffers-300">operators,
string-matching, for buffers</a>: <a href="#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="#index-operators_002c-word_002dboundary-_0028_0040command_007bgawk_007d_0029-311">operators,
word-boundary (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a href="#index-options_002c-command_002dline-1477">options,
command-line</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-options_002c-command_002dline-424">options,
command-line</a>: <a href="#Command-Line-Field-Separator">Command Line Field
Separator</a></li>
-<li><a href="#index-options_002c-command_002dline-100">options,
command-line</a>: <a href="#Long">Long</a></li>
-<li><a href="#index-options_002c-command_002dline_002c-end-of-1497">options,
command-line, end of</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-options_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1470">options,
command-line, invoking <samp><span class="command">awk</span></samp></a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a
href="#index-options_002c-command_002dline_002c-processing-1684">options,
command-line, processing</a>: <a href="#Getopt-Function">Getopt
Function</a></li>
-<li><a href="#index-options_002c-deprecated-1573">options, deprecated</a>: <a
href="#Obsolete">Obsolete</a></li>
-<li><a href="#index-options_002c-long-1480">options, long</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-options_002c-long-1473">options, long</a>: <a
href="#Command-Line">Command Line</a></li>
-<li><a href="#index-options_002c-printing-list-of-1517">options, printing list
of</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-OR-bitwise-operation-1247">OR bitwise operation</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-or-Boolean_002dlogic-operator-775">or Boolean-logic
operator</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-_0040code_007bor_007d-function-_0028_0040command_007bgawk_007d_0029-1258"><code>or</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="#index-_0040code_007bord_007d-user_002ddefined-function-1646"><code>ord</code>
user-defined function</a>: <a href="#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a href="#index-order-of-evaluation_002c-concatenation-667">order of
evaluation, concatenation</a>: <a href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-_0040code_007bORS_007d-variable-1031"><code>ORS</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-_0040code_007bORS_007d-variable-517"><code>ORS</code>
variable</a>: <a href="#Output-Separators">Output Separators</a></li>
-<li><a
href="#index-output-field-separator_002c-See-_0040code_007bOFS_007d-variable-396">output
field separator, See <code>OFS</code> variable</a>: <a
href="#Changing-Fields">Changing Fields</a></li>
-<li><a
href="#index-output-record-separator_002c-See-_0040code_007bORS_007d-variable-516">output
record separator, See <code>ORS</code> variable</a>: <a
href="#Output-Separators">Output Separators</a></li>
-<li><a href="#index-output-redirection-544">output redirection</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a href="#index-output_002c-buffering-1216">output, buffering</a>: <a
href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a href="#index-output_002c-duplicating-into-files-1771">output,
duplicating into files</a>: <a href="#Tee-Program">Tee Program</a></li>
-<li><a href="#index-output_002c-files_0040comma_007b_007d-closing-590">output,
files, closing</a>: <a href="#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="#index-output_002c-format-specifier_0040comma_007b_007d-_0040code_007bOFMT_007d-523">output,
format specifier, <code>OFMT</code></a>: <a href="#OFMT">OFMT</a></li>
-<li><a href="#index-output_002c-formatted-528">output, formatted</a>: <a
href="#Printf">Printf</a></li>
-<li><a href="#index-output_002c-pipes-555">output, pipes</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a href="#index-output_002c-printing_002c-See-printing-499">output,
printing, See printing</a>: <a href="#Printing">Printing</a></li>
-<li><a href="#index-output_002c-records-515">output, records</a>: <a
href="#Output-Separators">Output Separators</a></li>
-<li><a href="#index-output_002c-standard-571">output, standard</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a href="#index-P1003_002e2-POSIX-standard-2079">P1003.2 POSIX
standard</a>: <a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-_0040code_007bparam_005fcnt_007d-internal-variable-1982"><code>param_cnt</code>
internal variable</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-parameters_0040comma_007b_007d-number-of-1981">parameters,
number of</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-parentheses-_0040code_007b_0028_0029_007d-242">parentheses
<code>()</code></a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-parentheses-_0040code_007b_0028_0029_007d_002c-_0040command_007bpgawk_007d-program-1455">parentheses
<code>()</code>, <samp><span class="command">pgawk</span></samp> program</a>:
<a href="#Profiling">Profiling</a></li>
-<li><a href="#index-password-file-1700">password file</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-patterns-886">patterns</a>: <a
href="#Patterns-and-Actions">Patterns and Actions</a></li>
-<li><a href="#index-patterns_002c-comparison-expressions-as-892">patterns,
comparison expressions as</a>: <a href="#Expression-Patterns">Expression
Patterns</a></li>
-<li><a href="#index-patterns_002c-counts-1448">patterns, counts</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a href="#index-patterns_002c-default-139">patterns, default</a>: <a
href="#Very-Simple">Very Simple</a></li>
-<li><a href="#index-patterns_002c-empty-927">patterns, empty</a>: <a
href="#Empty">Empty</a></li>
-<li><a href="#index-patterns_002c-expressions-as-888">patterns, expressions
as</a>: <a href="#Regexp-Patterns">Regexp Patterns</a></li>
-<li><a href="#index-patterns_002c-ranges-in-905">patterns, ranges in</a>: <a
href="#Ranges">Ranges</a></li>
-<li><a href="#index-patterns_002c-regexp-constants-as-900">patterns, regexp
constants as</a>: <a href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a href="#index-patterns_002c-types-of-887">patterns, types of</a>: <a
href="#Pattern-Overview">Pattern Overview</a></li>
-<li><a
href="#index-_0040command_007bpawk_007d-profiling-Bell-Labs-_0040command_007bawk_007d-1948"><samp><span
class="command">pawk</span></samp> profiling Bell Labs <samp><span
class="command">awk</span></samp></a>: <a href="#Other-Versions">Other
Versions</a></li>
-<li><a
href="#index-PC-operating-systems_002c-_0040command_007bgawk_007d-on-1903">PC
operating systems, <samp><span class="command">gawk</span></samp> on</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-PC-operating-systems_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1900">PC
operating systems, <samp><span class="command">gawk</span></samp> on,
installing</a>: <a href="#PC-Installation">PC Installation</a></li>
-<li><a
href="#index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_007d-operator-832">percent
sign (<code>%</code>), <code>%</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-882">percent
sign (<code>%</code>), <code>%=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-693">percent
sign (<code>%</code>), <code>%=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-period-_0028_0040code_007b_002e_007d_0029-231">period
(<code>.</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a href="#index-PERL-2019">PERL</a>: <a href="#Future-Extensions">Future
Extensions</a></li>
-<li><a href="#index-Peters_002c-Arno-1862">Peters, Arno</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Peterson_002c-Hal-1851">Peterson, Hal</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-_0040command_007bpgawk_007d-program-1440"><samp><span
class="command">pgawk</span></samp> program</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040command_007bpgawk_007d-program_002c-_0040code_007bawkprof_002eout_007d-file-1444"><samp><span
class="command">pgawk</span></samp> program, <code>awkprof.out</code>
file</a>: <a href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040command_007bpgawk_007d-program_002c-dynamic-profiling-1457"><samp><span
class="command">pgawk</span></samp> program, dynamic profiling</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a href="#index-pipes_002c-closing-591">pipes, closing</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a href="#index-pipes_002c-input-473">pipes, input</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-pipes_002c-output-554">pipes, output</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029-246">plus
sign (<code>+</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_007d-operator-822">plus
sign (<code>+</code>), <code>+</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-814">plus
sign (<code>+</code>), <code>++</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-721">plus
sign (<code>+</code>), <code>++</code> operator</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-872">plus
sign (<code>+</code>), <code>+=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-682">plus
sign (<code>+</code>), <code>+=</code> operator</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-decrement_002fincrement-operators-715">plus
sign (<code>+</code>), decrement/increment operators</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-portability-211">portability</a>: <a
href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-portability_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-110">portability,
<code>#!</code> (executable scripts)</a>: <a
href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="#index-portability_002c-_0040code_007b_002a_002a_007d-operator-and-659">portability,
<code>**</code> operator and</a>: <a href="#Arithmetic-Ops">Arithmetic
Ops</a></li>
-<li><a
href="#index-portability_002c-_0040code_007b_002a_002a_003d_007d-operator-and-701">portability,
<code>**=</code> operator and</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bARGV_007d-variable-112">portability,
<code>ARGV</code> variable</a>: <a href="#Executable-Scripts">Executable
Scripts</a></li>
-<li><a
href="#index-portability_002c-backslash-continuation-and-155">portability,
backslash continuation and</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-portability_002c-backslash-in-escape-sequences-212">portability,
backslash in escape sequences</a>: <a href="#Escape-Sequences">Escape
Sequences</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bclose_007d-function-and-596">portability,
<code>close</code> function and</a>: <a href="#Close-Files-And-Pipes">Close
Files And Pipes</a></li>
-<li><a
href="#index-portability_002c-_0040value_007bDF_007ds-as-single-record-371">portability,
data files as single record</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-portability_002c-deleting-array-elements-1112">portability,
deleting array elements</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-portability_002c-example-programs-1594">portability,
example programs</a>: <a href="#Library-Functions">Library Functions</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bfflush_007d-function-and-1214">portability,
<code>fflush</code> function and</a>: <a href="#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="#index-portability_002c-functions_0040comma_007b_007d-defining-1286">portability,
functions, defining</a>: <a href="#Definition-Syntax">Definition
Syntax</a></li>
-<li><a
href="#index-portability_002c-_0040command_007bgawk_007d-1960">portability,
<samp><span class="command">gawk</span></samp></a>: <a href="#New-Ports">New
Ports</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bgettext_007d-library-and-1308">portability,
<code>gettext</code> library and</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="#index-portability_002c-internationalization-and-1376">portability,
internationalization and</a>: <a href="#I18N-Portability">I18N
Portability</a></li>
-<li><a
href="#index-portability_002c-_0040code_007blength_007d-function-1168">portability,
<code>length</code> function</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-portability_002c-new-_0040command_007bawk_007d-vs_002e-old-_0040command_007bawk_007d-650">portability,
new <samp><span class="command">awk</span></samp> vs. old <samp><span
class="command">awk</span></samp></a>: <a href="#Conversion">Conversion</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bnext_007d-statement-in-user_002ddefined-functions-1297">portability,
<code>next</code> statement in user-defined functions</a>: <a
href="#Function-Caveats">Function Caveats</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bNF_007d-variable_0040comma_007b_007d-decrementing-400">portability,
<code>NF</code> variable, decrementing</a>: <a
href="#Changing-Fields">Changing Fields</a></li>
-<li><a href="#index-portability_002c-operators-727">portability,
operators</a>: <a href="#Increment-Ops">Increment Ops</a></li>
-<li><a
href="#index-portability_002c-operators_002c-not-in-POSIX-_0040command_007bawk_007d-885">portability,
operators, not in POSIX <samp><span class="command">awk</span></samp></a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1560">portability,
<code>POSIXLY_CORRECT</code> environment variable</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-portability_002c-_0040code_007bsubstr_007d-function-1192">portability,
<code>substr</code> function</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a href="#index-portable-object-files-1360">portable object files</a>: <a
href="#Translator-i18n">Translator i18n</a></li>
-<li><a href="#index-portable-object-files-1312">portable object files</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-portable-object-files_002c-converting-to-message-object-files-1388">portable
object files, converting to message object files</a>: <a
href="#I18N-Example">I18N Example</a></li>
-<li><a href="#index-portable-object-files_002c-generating-1512">portable
object files, generating</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-portal-files-1429">portal files</a>: <a
href="#Portal-Files">Portal Files</a></li>
-<li><a href="#index-porting-_0040command_007bgawk_007d-1962">porting
<samp><span class="command">gawk</span></samp></a>: <a href="#New-Ports">New
Ports</a></li>
-<li><a
href="#index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement-1372">positional
specifiers, <code>printf</code> statement</a>: <a
href="#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="#index-positional-specifiers_002c-_0040code_007bprintf_007d-statement-540">positional
specifiers, <code>printf</code> statement</a>: <a
href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="#index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement_002c-mixing-with-regular-formats-1374">positional
specifiers, <code>printf</code> statement, mixing with regular formats</a>: <a
href="#Printf-Ordering">Printf Ordering</a></li>
-<li><a href="#index-positive-zero-2050">positive zero</a>: <a
href="#Floating-Point-Issues">Floating Point Issues</a></li>
-<li><a href="#index-POSIX-_0040command_007bawk_007d-699">POSIX <samp><span
class="command">awk</span></samp></a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a href="#index-POSIX-_0040command_007bawk_007d-27">POSIX <samp><span
class="command">awk</span></samp></a>: <a href="#This-Manual">This
Manual</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_002a_002a_003d_007d-operator-and-700">POSIX
<samp><span class="command">awk</span></samp>, <code>**=</code> operator
and</a>: <a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_003c_007d-operator-and-467">POSIX
<samp><span class="command">awk</span></samp>, <code><</code> operator
and</a>: <a href="#Getline_002fFile">Getline/File</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-arithmetic-operators-and-654">POSIX
<samp><span class="command">awk</span></samp>, arithmetic operators and</a>:
<a href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-backslashes-in-string-constants-213">POSIX
<samp><span class="command">awk</span></samp>, backslashes in string
constants</a>: <a href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-918">POSIX
<samp><span class="command">awk</span></samp>,
<code>BEGIN</code>/<code>END</code> patterns</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bbreak_007d-statement-and-963">POSIX
<samp><span class="command">awk</span></samp>, <code>break</code> statement
and</a>: <a href="#Break-Statement">Break Statement</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-changes-in-_0040command_007bawk_007d-versions-1828">POSIX
<samp><span class="command">awk</span></samp>, changes in <samp><span
class="command">awk</span></samp> versions</a>: <a href="#POSIX">POSIX</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-character-lists-and-265">POSIX
<samp><span class="command">awk</span></samp>, character lists and</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-character-lists-and_002c-character-classes-270">POSIX
<samp><span class="command">awk</span></samp>, character lists and, character
classes</a>: <a href="#Character-Lists">Character Lists</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bcontinue_007d-statement-and-967">POSIX
<samp><span class="command">awk</span></samp>, <code>continue</code> statement
and</a>: <a href="#Continue-Statement">Continue Statement</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bCONVFMT_007d-variable-and-1000">POSIX
<samp><span class="command">awk</span></samp>, <code>CONVFMT</code> variable
and</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bdate_007d-utility-and-1244">POSIX
<samp><span class="command">awk</span></samp>, <code>date</code> utility
and</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-433">POSIX
<samp><span class="command">awk</span></samp>, field separators and</a>: <a
href="#Field-Splitting-Summary">Field Splitting Summary</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-380">POSIX
<samp><span class="command">awk</span></samp>, field separators and</a>: <a
href="#Fields">Fields</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bFS_007d-variable-and-1011">POSIX
<samp><span class="command">awk</span></samp>, <code>FS</code> variable
and</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bfunction_007d-keyword-in-1285">POSIX
<samp><span class="command">awk</span></samp>, <code>function</code> keyword
in</a>: <a href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-1205">POSIX
<samp><span class="command">awk</span></samp>, functions and,
<code>gsub</code>/<code>sub</code></a>: <a href="#Gory-Details">Gory
Details</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007blength_007d-1169">POSIX
<samp><span class="command">awk</span></samp>, functions and,
<code>length</code></a>: <a href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-GNU-long-options-and-1481">POSIX
<samp><span class="command">awk</span></samp>, GNU long options and</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-interval-expressions-in-250">POSIX
<samp><span class="command">awk</span></samp>, interval expressions in</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-974">POSIX
<samp><span class="command">awk</span></samp>,
<code>next</code>/<code>nextfile</code> statements and</a>: <a
href="#Next-Statement">Next Statement</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-numeric-strings-and-747">POSIX
<samp><span class="command">awk</span></samp>, numeric strings and</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-648">POSIX
<samp><span class="command">awk</span></samp>, <code>OFMT</code> variable
and</a>: <a href="#Conversion">Conversion</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-525">POSIX
<samp><span class="command">awk</span></samp>, <code>OFMT</code> variable
and</a>: <a href="#OFMT">OFMT</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-period-_0028_0040code_007b_002e_007d_0029_0040comma_007b_007d-using-232">POSIX
<samp><span class="command">awk</span></samp>, period (<code>.</code>),
using</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bprintf_007d-format-strings-and-543">POSIX
<samp><span class="command">awk</span></samp>, <code>printf</code> format
strings and</a>: <a href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-regular-expressions-and-254">POSIX
<samp><span class="command">awk</span></samp>, regular expressions and</a>: <a
href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-timestamps-and-1232">POSIX
<samp><span class="command">awk</span></samp>, timestamps and</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a
href="#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_007c_007d-I_002fO-operator-and-479">POSIX
<samp><span class="command">awk</span></samp>, <code>|</code> I/O operator
and</a>: <a href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-POSIX-mode-1528">POSIX mode</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-POSIX_002c-_0040command_007bawk_007d-and-3">POSIX,
<samp><span class="command">awk</span></samp> and</a>: <a
href="#Preface">Preface</a></li>
-<li><a
href="#index-POSIX_002c-_0040command_007bgawk_007d-extensions-not-included-in-1835">POSIX,
<samp><span class="command">gawk</span></samp> extensions not included in</a>:
<a href="#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="#index-POSIX_002c-programs_0040comma_007b_007d-implementing-in-_0040command_007bawk_007d-1742">POSIX,
programs, implementing in <samp><span class="command">awk</span></samp></a>:
<a href="#Clones">Clones</a></li>
-<li><a
href="#index-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1556"><code>POSIXLY_CORRECT</code>
environment variable</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-precedence-809">precedence</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a href="#index-precedence-725">precedence</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-precedence_002c-regexp-operators-252">precedence, regexp
operators</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a href="#index-_0040code_007bprint_007d-statement-500"><code>print</code>
statement</a>: <a href="#Printing">Printing</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-919"><code>print</code>
statement, <code>BEGIN</code>/<code>END</code> patterns and</a>: <a
href="#I_002fO-And-BEGIN_002fEND">I/O And BEGIN/END</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-commas_002c-omitting-507"><code>print</code>
statement, commas, omitting</a>: <a href="#Print-Examples">Print
Examples</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-I_002fO-operators-in-858"><code>print</code>
statement, I/O operators in</a>: <a href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-line-continuations-and-513"><code>print</code>
statement, line continuations and</a>: <a href="#Print-Examples">Print
Examples</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-_0040code_007bOFMT_007d-variable-and-1027"><code>print</code>
statement, <code>OFMT</code> variable and</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-See-Also-redirection_002c-of-output-546"><code>print</code>
statement, See Also redirection, of output</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040code_007bprint_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1633"><code>print</code>
statement, <code>sprintf</code> function and</a>: <a
href="#Round-Function">Round Function</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement-527"><code>printf</code>
statement</a>: <a href="#Printf">Printf</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement-501"><code>printf</code>
statement</a>: <a href="#Printing">Printing</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-columns_0040comma_007b_007d-aligning-510"><code>printf</code>
statement, columns, aligning</a>: <a href="#Print-Examples">Print
Examples</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-format_002dcontrol-characters-532"><code>printf</code>
statement, format-control characters</a>: <a href="#Control-Letters">Control
Letters</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-I_002fO-operators-in-859"><code>printf</code>
statement, I/O operators in</a>: <a href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-modifiers-536"><code>printf</code>
statement, modifiers</a>: <a href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-1371"><code>printf</code>
statement, positional specifiers</a>: <a href="#Printf-Ordering">Printf
Ordering</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-539"><code>printf</code>
statement, positional specifiers</a>: <a href="#Format-Modifiers">Format
Modifiers</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-positional-specifiers_002c-mixing-with-regular-formats-1373"><code>printf</code>
statement, positional specifiers, mixing with regular formats</a>: <a
href="#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-See-Also-redirection_002c-of-output-547"><code>printf</code>
statement, See Also redirection, of output</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1634"><code>printf</code>
statement, <code>sprintf</code> function and</a>: <a
href="#Round-Function">Round Function</a></li>
-<li><a
href="#index-_0040code_007bprintf_007d-statement_002c-syntax-of-530"><code>printf</code>
statement, syntax of</a>: <a href="#Basic-Printf">Basic Printf</a></li>
-<li><a href="#index-printing-498">printing</a>: <a
href="#Printing">Printing</a></li>
-<li><a href="#index-printing_002c-list-of-options-1518">printing, list of
options</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-printing_002c-mailing-labels-1800">printing, mailing
labels</a>: <a href="#Labels-Program">Labels Program</a></li>
-<li><a href="#index-printing_002c-unduplicated-lines-of-text-1775">printing,
unduplicated lines of text</a>: <a href="#Uniq-Program">Uniq Program</a></li>
-<li><a href="#index-printing_002c-user-information-1762">printing, user
information</a>: <a href="#Id-Program">Id Program</a></li>
-<li><a href="#index-private-variables-1603">private variables</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a href="#index-process-information_002c-files-for-582">process
information, files for</a>: <a href="#Special-Process">Special Process</a></li>
-<li><a
href="#index-processes_002c-two_002dway-communications-with-1408">processes,
two-way communications with</a>: <a href="#Two_002dway-I_002fO">Two-way
I/O</a></li>
-<li><a href="#index-processing-data-2025">processing data</a>: <a
href="#Basic-High-Level">Basic High Level</a></li>
-<li><a
href="#index-_0040code_007bPROCINFO_007d-array-1721"><code>PROCINFO</code>
array</a>: <a href="#Group-Functions">Group Functions</a></li>
-<li><a
href="#index-_0040code_007bPROCINFO_007d-array-1694"><code>PROCINFO</code>
array</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-_0040code_007bPROCINFO_007d-array-1061"><code>PROCINFO</code>
array</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040code_007bPROCINFO_007d-array-587"><code>PROCINFO</code>
array</a>: <a href="#Special-Caveats">Special Caveats</a></li>
-<li><a
href="#index-profiling-_0040command_007bawk_007d-programs-1439">profiling
<samp><span class="command">awk</span></samp> programs</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-profiling-_0040command_007bawk_007d-programs_002c-dynamically-1456">profiling
<samp><span class="command">awk</span></samp> programs, dynamically</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-profiling-_0040command_007bgawk_007d_002c-See-_0040command_007bpgawk_007d-program-1441">profiling
<samp><span class="command">gawk</span></samp>, See <samp><span
class="command">pgawk</span></samp> program</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a href="#index-program_002c-definition-of-76">program, definition of</a>:
<a href="#Getting-Started">Getting Started</a></li>
-<li><a href="#index-programmers_002c-attractiveness-of-1406">programmers,
attractiveness of</a>: <a href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="#index-programming-conventions_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1402">programming
conventions, <code>--non-decimal-data</code> option</a>: <a
href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="#index-programming-conventions_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1046">programming
conventions, <code>ARGC</code>/<code>ARGV</code> variables</a>: <a
href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-programming-conventions_002c-_0040code_007bexit_007d-statement-989">programming
conventions, <code>exit</code> statement</a>: <a href="#Exit-Statement">Exit
Statement</a></li>
-<li><a
href="#index-programming-conventions_002c-function-parameters-1299">programming
conventions, function parameters</a>: <a href="#Return-Statement">Return
Statement</a></li>
-<li><a
href="#index-programming-conventions_002c-functions_002c-calling-1142">programming
conventions, functions, calling</a>: <a href="#Calling-Built_002din">Calling
Built-in</a></li>
-<li><a
href="#index-programming-conventions_002c-functions_002c-writing-1281">programming
conventions, functions, writing</a>: <a href="#Definition-Syntax">Definition
Syntax</a></li>
-<li><a
href="#index-programming-conventions_002c-_0040command_007bgawk_007d-internals-2015">programming
conventions, <samp><span class="command">gawk</span></samp> internals</a>: <a
href="#Internal-File-Ops">Internal File Ops</a></li>
-<li><a
href="#index-programming-conventions_002c-_0040code_007bnextfile_007d-statement-1618">programming
conventions, <code>nextfile</code> statement</a>: <a
href="#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="#index-programming-conventions_002c-private-variable-names-1605">programming
conventions, private variable names</a>: <a href="#Library-Names">Library
Names</a></li>
-<li><a href="#index-programming-language_002c-recipe-for-12">programming
language, recipe for</a>: <a href="#History">History</a></li>
-<li><a
href="#index-programming-languages_0040comma_007b_007d-data_002ddriven-vs_002e-procedural-74">programming
languages, data-driven vs. procedural</a>: <a href="#Getting-Started">Getting
Started</a></li>
-<li><a href="#index-programming_002c-basic-steps-2028">programming, basic
steps</a>: <a href="#Basic-High-Level">Basic High Level</a></li>
-<li><a href="#index-programming_002c-concepts-2023">programming, concepts</a>:
<a href="#Basic-Concepts">Basic Concepts</a></li>
-<li><a href="#index-_0040command_007bpwcat_007d-program-1702"><samp><span
class="command">pwcat</span></samp> program</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="#index-question-mark-_0028_0040code_007b_003f_007d_0029-308">question
mark (<code>?</code>)</a>: <a href="#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="#index-question-mark-_0028_0040code_007b_003f_007d_0029-248">question
mark (<code>?</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-question-mark-_0028_0040code_007b_003f_007d_0029_002c-_0040code_007b_003f_003a_007d-operator-870">question
mark (<code>?</code>), <code>?:</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007bQUIT_007d-signal-_0028MS_002dDOS_0029-1465"><code>QUIT</code>
signal (MS-DOS)</a>: <a href="#Profiling">Profiling</a></li>
-<li><a href="#index-quoting-117">quoting</a>: <a
href="#Comments">Comments</a></li>
-<li><a href="#index-quoting-101">quoting</a>: <a href="#Long">Long</a></li>
-<li><a href="#index-quoting-90">quoting</a>: <a href="#Read-Terminal">Read
Terminal</a></li>
-<li><a href="#index-quoting_002c-rules-for-122">quoting, rules for</a>: <a
href="#Quoting">Quoting</a></li>
-<li><a href="#index-quoting_002c-tricks-for-134">quoting, tricks for</a>: <a
href="#Quoting">Quoting</a></li>
-<li><a href="#index-Rakitzis_002c-Byron-1807">Rakitzis, Byron</a>: <a
href="#History-Sorting">History Sorting</a></li>
-<li><a href="#index-_0040code_007brand_007d-function-1157"><code>rand</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-random-numbers_002c-Cliff-1637">random numbers, Cliff</a>:
<a href="#Cliff-Random-Function">Cliff Random Function</a></li>
-<li><a
href="#index-random-numbers_002c-_0040code_007brand_007d_002f_0040code_007bsrand_007d-functions-1158">random
numbers, <code>rand</code>/<code>srand</code> functions</a>: <a
href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-random-numbers_002c-seed-of-1160">random numbers, seed
of</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-range-expressions-258">range expressions</a>: <a
href="#Character-Lists">Character Lists</a></li>
-<li><a href="#index-range-patterns-904">range patterns</a>: <a
href="#Ranges">Ranges</a></li>
-<li><a href="#index-Rankin_002c-Pat-1935">Rankin, Pat</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Rankin_002c-Pat-1847">Rankin, Pat</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Rankin_002c-Pat-683">Rankin, Pat</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-Rankin_002c-Pat-64">Rankin, Pat</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-raw-sockets-1425">raw sockets</a>: <a
href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a
href="#index-readable-_0040value_007bDF_007ds_0040comma_007b_007d-checking-1673">readable
data files, checking</a>: <a href="#File-Checking">File Checking</a></li>
-<li><a
href="#index-_0040code_007breadable_002eawk_007d-program-1675"><code>readable.awk</code>
program</a>: <a href="#File-Checking">File Checking</a></li>
-<li><a href="#index-recipe-for-a-programming-language-11">recipe for a
programming language</a>: <a href="#History">History</a></li>
-<li><a href="#index-record-separators-1034">record separators</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-record-separators-353">record separators</a>: <a
href="#Records">Records</a></li>
-<li><a href="#index-record-separators_002c-changing-357">record separators,
changing</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-record-separators_002c-regular-expressions-as-367">record
separators, regular expressions as</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-record-separators_002c-with-multiline-records-449">record
separators, with multiline records</a>: <a href="#Multiple-Line">Multiple
Line</a></li>
-<li><a href="#index-records-2030">records</a>: <a
href="#Basic-High-Level">Basic High Level</a></li>
-<li><a href="#index-records-345">records</a>: <a href="#Reading-Files">Reading
Files</a></li>
-<li><a href="#index-records_002c-multiline-445">records, multiline</a>: <a
href="#Multiple-Line">Multiple Line</a></li>
-<li><a href="#index-records_002c-printing-502">records, printing</a>: <a
href="#Print">Print</a></li>
-<li><a href="#index-records_002c-splitting-input-into-349">records, splitting
input into</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-records_002c-terminating-363">records, terminating</a>: <a
href="#Records">Records</a></li>
-<li><a href="#index-records_002c-treating-files-as-374">records, treating
files as</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-recursive-functions-1283">recursive functions</a>: <a
href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a href="#index-redirection-of-input-463">redirection of input</a>: <a
href="#Getline_002fFile">Getline/File</a></li>
-<li><a href="#index-redirection-of-output-545">redirection of output</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a href="#index-reference-counting_002c-sorting-arrays-1137">reference
counting, sorting arrays</a>: <a href="#Array-Sorting">Array Sorting</a></li>
-<li><a href="#index-regexp-constants-773">regexp constants</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-regexp-constants-619">regexp constants</a>: <a
href="#Regexp-Constants">Regexp Constants</a></li>
-<li><a href="#index-regexp-constants-182">regexp constants</a>: <a
href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="#index-regexp-constants_002c-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d_002c-_0040code_007b_002f_003d_007d-operator-and-706">regexp
constants, <code>/=.../</code>, <code>/=</code> operator and</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-regexp-constants_002c-as-patterns-899">regexp constants,
as patterns</a>: <a href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="#index-regexp-constants_002c-in-_0040command_007bgawk_007d-626">regexp
constants, in <samp><span class="command">gawk</span></samp></a>: <a
href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a href="#index-regexp-constants_002c-slashes-vs_002e-quotes-331">regexp
constants, slashes vs. quotes</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a href="#index-regexp-constants_002c-vs_002e-string-constants-337">regexp
constants, vs. string constants</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a href="#index-regexp_002c-See-regular-expressions-168">regexp, See
regular expressions</a>: <a href="#Regexp">Regexp</a></li>
-<li><a href="#index-regular-expressions-169">regular expressions</a>: <a
href="#Regexp">Regexp</a></li>
-<li><a href="#index-regular-expressions-as-field-separators-409">regular
expressions as field separators</a>: <a href="#Field-Separators">Field
Separators</a></li>
-<li><a href="#index-regular-expressions_002c-anchors-in-224">regular
expressions, anchors in</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="#index-regular-expressions_002c-as-field-separators-413">regular
expressions, as field separators</a>: <a href="#Regexp-Field-Splitting">Regexp
Field Splitting</a></li>
-<li><a href="#index-regular-expressions_002c-as-patterns-889">regular
expressions, as patterns</a>: <a href="#Regexp-Patterns">Regexp
Patterns</a></li>
-<li><a href="#index-regular-expressions_002c-as-patterns-172">regular
expressions, as patterns</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="#index-regular-expressions_002c-as-record-separators-366">regular
expressions, as record separators</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-regular-expressions_002c-case-sensitivity-1017">regular
expressions, case sensitivity</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-regular-expressions_002c-case-sensitivity-314">regular
expressions, case sensitivity</a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a href="#index-regular-expressions_002c-computed-325">regular
expressions, computed</a>: <a href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-regular-expressions_002c-constants_002c-See-regexp-constants-183">regular
expressions, constants, See regexp constants</a>: <a
href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="#index-regular-expressions_002c-dynamic-326">regular expressions,
dynamic</a>: <a href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-regular-expressions_002c-dynamic_002c-with-embedded-newlines-339">regular
expressions, dynamic, with embedded newlines</a>: <a
href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-regular-expressions_002c-_0040command_007bgawk_007d_002c-command_002dline-options-312">regular
expressions, <samp><span class="command">gawk</span></samp>, command-line
options</a>: <a href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-regular-expressions_002c-interval-expressions-and-1548">regular
expressions, interval expressions and</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-regular-expressions_002c-leftmost-longest-match-324">regular
expressions, leftmost longest match</a>: <a href="#Leftmost-Longest">Leftmost
Longest</a></li>
-<li><a href="#index-regular-expressions_002c-operators-221">regular
expressions, operators</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="#index-regular-expressions_002c-operators-173">regular
expressions, operators</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="#index-regular-expressions_002c-operators_002c-for-buffers-299">regular
expressions, operators, for buffers</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-regular-expressions_002c-operators_002c-for-words-283">regular
expressions, operators, for words</a>: <a href="#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="#index-regular-expressions_002c-operators_002c-_0040command_007bgawk_007d-280">regular
expressions, operators, <samp><span class="command">gawk</span></samp></a>: <a
href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-regular-expressions_002c-operators_002c-precedence-of-253">regular
expressions, operators, precedence of</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="#index-regular-expressions_002c-searching-for-1751">regular
expressions, searching for</a>: <a href="#Egrep-Program">Egrep Program</a></li>
-<li><a
href="#index-relational-operators_002c-See-comparison-operators-741">relational
operators, See comparison operators</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-_0040code_007breturn_007d-statement_0040comma_007b_007d-user_002ddefined-functions-1298"><code>return</code>
statement, user-defined functions</a>: <a href="#Return-Statement">Return
Statement</a></li>
-<li><a
href="#index-return-values_0040comma_007b_007d-_0040code_007bclose_007d-function-601">return
values, <code>close</code> function</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a
href="#index-_0040code_007brev_007d-user_002ddefined-function-1287"><code>rev</code>
user-defined function</a>: <a href="#Function-Example">Function
Example</a></li>
-<li><a
href="#index-_0040code_007brewind_007d-user_002ddefined-function-1671"><code>rewind</code>
user-defined function</a>: <a href="#Rewind-Function">Rewind Function</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-844">right
angle bracket (<code>></code>), <code>></code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-755">right
angle bracket (<code>></code>), <code>></code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-549">right
angle bracket (<code>></code>), <code>></code> operator (I/O)</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-842">right
angle bracket (<code>></code>), <code>>=</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-753">right
angle bracket (<code>></code>), <code>>=</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-850">right
angle bracket (<code>></code>), <code>>></code> operator (I/O)</a>:
<a href="#Precedence">Precedence</a></li>
-<li><a
href="#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-552">right
angle bracket (<code>></code>), <code>>></code> operator (I/O)</a>:
<a href="#Redirection">Redirection</a></li>
-<li><a href="#index-right-shift_002c-bitwise-1254">right shift, bitwise</a>:
<a href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-Ritchie_002c-Dennis-2047">Ritchie, Dennis</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a
href="#index-_0040code_007bRLENGTH_007d-variable-1063"><code>RLENGTH</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040code_007bRLENGTH_007d-variable_002c-_0040code_007bmatch_007d-function-and-1172"><code>RLENGTH</code>
variable, <code>match</code> function and</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a href="#index-Robbins_002c-Arnold-2021">Robbins, Arnold</a>: <a
href="#Future-Extensions">Future Extensions</a></li>
-<li><a href="#index-Robbins_002c-Arnold-1927">Robbins, Arnold</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a href="#index-Robbins_002c-Arnold-1868">Robbins, Arnold</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Robbins_002c-Arnold-1792">Robbins, Arnold</a>: <a
href="#Alarm-Program">Alarm Program</a></li>
-<li><a href="#index-Robbins_002c-Arnold-1704">Robbins, Arnold</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-Robbins_002c-Arnold-478">Robbins, Arnold</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-Robbins_002c-Arnold-432">Robbins, Arnold</a>: <a
href="#Command-Line-Field-Separator">Command Line Field Separator</a></li>
-<li><a href="#index-Robbins_002c-Bill-476">Robbins, Bill</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-Robbins_002c-Harry-70">Robbins, Harry</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Robbins_002c-Jean-69">Robbins, Jean</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Robbins_002c-Miriam-1705">Robbins, Miriam</a>: <a
href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-Robbins_002c-Miriam-477">Robbins, Miriam</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="#index-Robbins_002c-Miriam-68">Robbins, Miriam</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Robinson_002c-Will-1963">Robinson, Will</a>: <a
href="#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a href="#index-robot_002c-the-1964">robot, the</a>: <a
href="#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a href="#index-Rommel_002c-Kai-Uwe-1852">Rommel, Kai Uwe</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Rommel_002c-Kai-Uwe-65">Rommel, Kai Uwe</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-_0040code_007bround_007d-user_002ddefined-function-1636"><code>round</code>
user-defined function</a>: <a href="#Round-Function">Round Function</a></li>
-<li><a href="#index-rounding-1628">rounding</a>: <a
href="#Round-Function">Round Function</a></li>
-<li><a href="#index-rounding-numbers-1629">rounding numbers</a>: <a
href="#Round-Function">Round Function</a></li>
-<li><a href="#index-_0040code_007bRS_007d-variable-1032"><code>RS</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-_0040code_007bRS_007d-variable-355"><code>RS</code>
variable</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-_0040code_007bRS_007d-variable_002c-multiline-records-and-450"><code>RS</code>
variable, multiline records and</a>: <a href="#Multiple-Line">Multiple
Line</a></li>
-<li><a
href="#index-_0040code_007brshift_007d-function-_0028_0040command_007bgawk_007d_0029-1262"><code>rshift</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="#index-_0040code_007bRSTART_007d-variable-1064"><code>RSTART</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a
href="#index-_0040code_007bRSTART_007d-variable_002c-_0040code_007bmatch_007d-function-and-1171"><code>RSTART</code>
variable, <code>match</code> function and</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a href="#index-_0040code_007bRT_007d-variable-1065"><code>RT</code>
variable</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-_0040code_007bRT_007d-variable-455"><code>RT</code>
variable</a>: <a href="#Multiple-Line">Multiple Line</a></li>
-<li><a href="#index-_0040code_007bRT_007d-variable-362"><code>RT</code>
variable</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-Rubin_002c-Paul-1841">Rubin, Paul</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Rubin_002c-Paul-17">Rubin, Paul</a>: <a
href="#History">History</a></li>
-<li><a href="#index-rule_002c-definition-of-77">rule, definition of</a>: <a
href="#Getting-Started">Getting Started</a></li>
-<li><a href="#index-rvalues_002flvalues-677">rvalues/lvalues</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="#index-scalar-values-2037">scalar values</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-Schreiber_002c-Bert-49">Schreiber, Bert</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Schreiber_002c-Rita-50">Schreiber, Rita</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-search-paths-1913">search paths</a>: <a
href="#VMS-Running">VMS Running</a></li>
-<li><a href="#index-search-paths-1904">search paths</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a href="#index-search-paths_002c-for-source-files-1914">search paths, for
source files</a>: <a href="#VMS-Running">VMS Running</a></li>
-<li><a href="#index-search-paths_002c-for-source-files-1820">search paths, for
source files</a>: <a href="#Igawk-Program">Igawk Program</a></li>
-<li><a href="#index-search-paths_002c-for-source-files-1570">search paths, for
source files</a>: <a href="#AWKPATH-Variable">AWKPATH Variable</a></li>
-<li><a href="#index-searching-1166">searching</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-searching_002c-files-for-regular-expressions-1752">searching,
files for regular expressions</a>: <a href="#Egrep-Program">Egrep
Program</a></li>
-<li><a href="#index-searching_002c-for-words-1787">searching, for words</a>:
<a href="#Dupword-Program">Dupword Program</a></li>
-<li><a href="#index-_0040command_007bsed_007d-utility-2053"><samp><span
class="command">sed</span></samp> utility</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-_0040command_007bsed_007d-utility-1813"><samp><span
class="command">sed</span></samp> utility</a>: <a href="#Simple-Sed">Simple
Sed</a></li>
-<li><a href="#index-_0040command_007bsed_007d-utility-436"><samp><span
class="command">sed</span></samp> utility</a>: <a
href="#Field-Splitting-Summary">Field Splitting Summary</a></li>
-<li><a
href="#index-semicolon-_0028_0040code_007b_003b_007d_0029-164">semicolon
(<code>;</code>)</a>: <a href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1908">semicolon
(<code>;</code>), <code>AWKPATH</code> variable and</a>: <a
href="#PC-Using">PC Using</a></li>
-<li><a
href="#index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-949">semicolon
(<code>;</code>), separating statements in actions</a>: <a
href="#Statements">Statements</a></li>
-<li><a
href="#index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-937">semicolon
(<code>;</code>), separating statements in actions</a>: <a
href="#Action-Overview">Action Overview</a></li>
-<li><a href="#index-separators_002c-field-1009">separators, field</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-separators_002c-field_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1006">separators,
field, <code>FIELDWIDTHS</code> variable and</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-separators_002c-field_002c-POSIX-and-382">separators,
field, POSIX and</a>: <a href="#Fields">Fields</a></li>
-<li><a href="#index-separators_002c-for-records-352">separators, for
records</a>: <a href="#Records">Records</a></li>
-<li><a
href="#index-separators_002c-for-records_002c-regular-expressions-as-368">separators,
for records, regular expressions as</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-separators_002c-for-statements-in-actions-934">separators,
for statements in actions</a>: <a href="#Action-Overview">Action
Overview</a></li>
-<li><a href="#index-separators_002c-record-1033">separators, record</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-separators_002c-subscript-1036">separators, subscript</a>:
<a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bset_005fvalue_007d-internal-function-2008"><code>set_value</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-shells_002c-piping-commands-into-566">shells, piping
commands into</a>: <a href="#Redirection">Redirection</a></li>
-<li><a href="#index-shells_002c-quoting-930">shells, quoting</a>: <a
href="#Using-Shell-Variables">Using Shell Variables</a></li>
-<li><a href="#index-shells_002c-quoting_002c-rules-for-123">shells, quoting,
rules for</a>: <a href="#Quoting">Quoting</a></li>
-<li><a href="#index-shells_002c-scripts-82">shells, scripts</a>: <a
href="#One_002dshot">One-shot</a></li>
-<li><a href="#index-shells_002c-variables-928">shells, variables</a>: <a
href="#Using-Shell-Variables">Using Shell Variables</a></li>
-<li><a href="#index-shift_002c-bitwise-1255">shift, bitwise</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-short_002dcircuit-operators-784">short-circuit
operators</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-side-effects-713">side effects</a>: <a
href="#Increment-Ops">Increment Ops</a></li>
-<li><a href="#index-side-effects-669">side effects</a>: <a
href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-side-effects_002c-array-indexing-1093">side effects, array
indexing</a>: <a href="#Reference-to-Elements">Reference to Elements</a></li>
-<li><a
href="#index-side-effects_002c-_0040code_007basort_007d-function-1136">side
effects, <code>asort</code> function</a>: <a href="#Array-Sorting">Array
Sorting</a></li>
-<li><a href="#index-side-effects_002c-assignment-expressions-675">side
effects, assignment expressions</a>: <a href="#Assignment-Ops">Assignment
Ops</a></li>
-<li><a href="#index-side-effects_002c-Boolean-operators-783">side effects,
Boolean operators</a>: <a href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="#index-side-effects_002c-conditional-expressions-800">side
effects, conditional expressions</a>: <a href="#Conditional-Exp">Conditional
Exp</a></li>
-<li><a
href="#index-side-effects_002c-decrement_002fincrement-operators-716">side
effects, decrement/increment operators</a>: <a href="#Increment-Ops">Increment
Ops</a></li>
-<li><a
href="#index-side-effects_002c-_0040code_007bFILENAME_007d-variable-492">side
effects, <code>FILENAME</code> variable</a>: <a href="#Getline-Notes">Getline
Notes</a></li>
-<li><a href="#index-side-effects_002c-function-calls-808">side effects,
function calls</a>: <a href="#Function-Calls">Function Calls</a></li>
-<li><a href="#index-side-effects_002c-statements-938">side effects,
statements</a>: <a href="#Action-Overview">Action Overview</a></li>
-<li><a
href="#index-signals_002c-_0040code_007bHUP_007d_002f_0040code_007bSIGHUP_007d-1462">signals,
<code>HUP</code>/<code>SIGHUP</code></a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-signals_002c-_0040code_007bINT_007d_002f_0040code_007bSIGINT_007d-_0028MS_002dDOS_0029-1464">signals,
<code>INT</code>/<code>SIGINT</code> (MS-DOS)</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-signals_002c-_0040code_007bQUIT_007d_002f_0040code_007bSIGQUIT_007d-_0028MS_002dDOS_0029-1466">signals,
<code>QUIT</code>/<code>SIGQUIT</code> (MS-DOS)</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-signals_002c-_0040code_007bUSR1_007d_002f_0040code_007bSIGUSR1_007d-1460">signals,
<code>USR1</code>/<code>SIGUSR1</code></a>: <a
href="#Profiling">Profiling</a></li>
-<li><a href="#index-_0040code_007bsin_007d-function-1154"><code>sin</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a
href="#index-single-quote-_0028_0040code_007b_0027_007d_0029-127">single quote
(<code>'</code>)</a>: <a href="#Quoting">Quoting</a></li>
-<li><a
href="#index-single-quote-_0028_0040code_007b_0027_007d_0029-102">single quote
(<code>'</code>)</a>: <a href="#Long">Long</a></li>
-<li><a href="#index-single-quote-_0028_0040code_007b_0027_007d_0029-80">single
quote (<code>'</code>)</a>: <a href="#One_002dshot">One-shot</a></li>
-<li><a
href="#index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-vs_002e-apostrophe-118">single
quote (<code>'</code>), vs. apostrophe</a>: <a
href="#Comments">Comments</a></li>
-<li><a
href="#index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-with-double-quotes-131">single
quote (<code>'</code>), with double quotes</a>: <a
href="#Quoting">Quoting</a></li>
-<li><a href="#index-single_002dcharacter-fields-419">single-character
fields</a>: <a href="#Single-Character-Fields">Single Character Fields</a></li>
-<li><a
href="#index-single_002dprecision-floating_002dpoint-2044">single-precision
floating-point</a>: <a href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-Skywalker_002c-Luke-1580">Skywalker, Luke</a>: <a
href="#Undocumented">Undocumented</a></li>
-<li><a href="#index-_0040command_007bsleep_007d-utility-1796"><samp><span
class="command">sleep</span></samp> utility</a>: <a href="#Alarm-Program">Alarm
Program</a></li>
-<li><a href="#index-sockets-1426">sockets</a>: <a
href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a href="#index-sort-function_002c-arrays_002c-sorting-1135">sort
function, arrays, sorting</a>: <a href="#Array-Sorting">Array Sorting</a></li>
-<li><a href="#index-_0040command_007bsort_007d-utility-1804"><samp><span
class="command">sort</span></samp> utility</a>: <a href="#Word-Sorting">Word
Sorting</a></li>
-<li><a
href="#index-_0040command_007bsort_007d-utility_002c-coprocesses-and-1418"><samp><span
class="command">sort</span></samp> utility, coprocesses and</a>: <a
href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="#index-sorting-characters-in-different-languages-1330">sorting
characters in different languages</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a href="#index-source-code_002c-_0040command_007bawka_007d-1946">source
code, <samp><span class="command">awka</span></samp></a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a
href="#index-source-code_002c-Bell-Laboratories-_0040command_007bawk_007d-1939">source
code, Bell Laboratories <samp><span class="command">awk</span></samp></a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a href="#index-source-code_002c-_0040command_007bgawk_007d-1872">source
code, <samp><span class="command">gawk</span></samp></a>: <a
href="#Gawk-Distribution">Gawk Distribution</a></li>
-<li><a href="#index-source-code_002c-_0040command_007bmawk_007d-1942">source
code, <samp><span class="command">mawk</span></samp></a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a href="#index-source-code_002c-mixing-1550">source code, mixing</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-source-files_0040comma_007b_007d-search-path-for-1821">source
files, search path for</a>: <a href="#Igawk-Program">Igawk Program</a></li>
-<li><a href="#index-sparse-arrays-1085">sparse arrays</a>: <a
href="#Array-Intro">Array Intro</a></li>
-<li><a href="#index-Spencer_002c-Henry-2052">Spencer, Henry</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-_0040code_007bsplit_007d-function-1176"><code>split</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bsplit_007d-function_002c-array-elements_0040comma_007b_007d-deleting-1114"><code>split</code>
function, array elements, deleting</a>: <a href="#Delete">Delete</a></li>
-<li><a href="#index-_0040code_007bsplit_007d-utility-1768"><code>split</code>
utility</a>: <a href="#Split-Program">Split Program</a></li>
-<li><a
href="#index-_0040code_007bsplit_002eawk_007d-program-1769"><code>split.awk</code>
program</a>: <a href="#Split-Program">Split Program</a></li>
-<li><a
href="#index-_0040code_007bsprintf_007d-function-1180"><code>sprintf</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bsprintf_007d-function-521"><code>sprintf</code>
function</a>: <a href="#OFMT">OFMT</a></li>
-<li><a
href="#index-_0040code_007bsprintf_007d-function_002c-_0040code_007bOFMT_007d-variable-and-1026"><code>sprintf</code>
function, <code>OFMT</code> variable and</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bsprintf_007d-function_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-and-1635"><code>sprintf</code>
function, <code>print</code>/<code>printf</code> statements and</a>: <a
href="#Round-Function">Round Function</a></li>
-<li><a href="#index-_0040code_007bsqrt_007d-function-1151"><code>sqrt</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a
href="#index-square-brackets-_0028_0040code_007b_005b_005d_007d_0029-234">square
brackets (<code>[]</code>)</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="#index-_0040code_007bsrand_007d-function-1161"><code>srand</code>
function</a>: <a href="#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="#index-Stallman_002c-Richard-2067">Stallman, Richard</a>: <a
href="#Glossary">Glossary</a></li>
-<li><a href="#index-Stallman_002c-Richard-1844">Stallman, Richard</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Stallman_002c-Richard-44">Stallman, Richard</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Stallman_002c-Richard-34">Stallman, Richard</a>: <a
href="#Manual-History">Manual History</a></li>
-<li><a href="#index-standard-input-568">standard input</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a href="#index-standard-input-84">standard input</a>: <a
href="#Read-Terminal">Read Terminal</a></li>
-<li><a href="#index-standard-output-570">standard output</a>: <a
href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-_0040code_007bstat_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2012"><code>stat</code>
function, implementing in <samp><span class="command">gawk</span></samp></a>:
<a href="#Sample-Library">Sample Library</a></li>
-<li><a
href="#index-statements_002c-compound_0040comma_007b_007d-control-statements-and-943">statements,
compound, control statements and</a>: <a href="#Statements">Statements</a></li>
-<li><a href="#index-statements_002c-control_002c-in-actions-940">statements,
control, in actions</a>: <a href="#Statements">Statements</a></li>
-<li><a href="#index-statements_002c-multiple-162">statements, multiple</a>: <a
href="#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="#index-_0040code_007bstlen_007d-internal-variable-1984"><code>stlen</code>
internal variable</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007bstptr_007d-internal-variable-1983"><code>stptr</code>
internal variable</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-stream-editors-1814">stream editors</a>: <a
href="#Simple-Sed">Simple Sed</a></li>
-<li><a href="#index-stream-editors-437">stream editors</a>: <a
href="#Field-Splitting-Summary">Field Splitting Summary</a></li>
-<li><a
href="#index-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1238"><code>strftime</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-string-constants-607">string constants</a>: <a
href="#Scalar-Constants">Scalar Constants</a></li>
-<li><a href="#index-string-constants_002c-vs_002e-regexp-constants-338">string
constants, vs. regexp constants</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a
href="#index-string-extraction-_0028internationalization_0029-1366">string
extraction (internationalization)</a>: <a href="#String-Extraction">String
Extraction</a></li>
-<li><a href="#index-string-operators-663">string operators</a>: <a
href="#Concatenation">Concatenation</a></li>
-<li><a href="#index-string_002dmatching-operators-175">string-matching
operators</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="#index-strings-1991">strings</a>: <a
href="#Internals">Internals</a></li>
-<li><a href="#index-strings_002c-converting-641">strings, converting</a>: <a
href="#Conversion">Conversion</a></li>
-<li><a href="#index-strings_002c-converting_002c-numbers-to-1266">strings,
converting, numbers to</a>: <a href="#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="#index-strings_002c-converting_002c-numbers-to-1002">strings,
converting, numbers to</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-strings_002c-empty_002c-See-null-strings-361">strings,
empty, See null strings</a>: <a href="#Records">Records</a></li>
-<li><a href="#index-strings_002c-extracting-1362">strings, extracting</a>: <a
href="#String-Extraction">String Extraction</a></li>
-<li><a href="#index-strings_002c-for-localization-1345">strings, for
localization</a>: <a href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a href="#index-strings_002c-length-of-609">strings, length of</a>: <a
href="#Scalar-Constants">Scalar Constants</a></li>
-<li><a href="#index-strings_002c-merging-arrays-into-1655">strings, merging
arrays into</a>: <a href="#Join-Function">Join Function</a></li>
-<li><a
href="#index-strings_002c-_0040code_007bNODE_007d-internal-type-1975">strings,
<code>NODE</code> internal type</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-strings_002c-null-416">strings, null</a>: <a
href="#Regexp-Field-Splitting">Regexp Field Splitting</a></li>
-<li><a href="#index-strings_002c-numeric-746">strings, numeric</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-strings_002c-splitting-1177">strings, splitting</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1182"><code>strtonum</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-and-1404"><code>strtonum</code>
function (<samp><span class="command">gawk</span></samp>),
<code>--non-decimal-data</code> option and</a>: <a
href="#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a href="#index-_0040code_007bsub_007d-function-1184"><code>sub</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a href="#index-_0040code_007bsub_007d-function-630"><code>sub</code>
function</a>: <a href="#Using-Constant-Regexps">Using Constant Regexps</a></li>
-<li><a
href="#index-_0040code_007bsub_007d-function_002c-arguments-of-1185"><code>sub</code>
function, arguments of</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-_0040code_007bsub_007d-function_002c-escape-processing-1198"><code>sub</code>
function, escape processing</a>: <a href="#Gory-Details">Gory Details</a></li>
-<li><a href="#index-subscript-separators-1037">subscript separators</a>: <a
href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-subscripts-in-arrays_002c-multidimensional-1127">subscripts in
arrays, multidimensional</a>: <a
href="#Multi_002ddimensional">Multi-dimensional</a></li>
-<li><a
href="#index-subscripts-in-arrays_002c-multidimensional_002c-scanning-1130">subscripts
in arrays, multidimensional, scanning</a>: <a
href="#Multi_002dscanning">Multi-scanning</a></li>
-<li><a href="#index-subscripts-in-arrays_002c-numbers-as-1117">subscripts in
arrays, numbers as</a>: <a href="#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a
href="#index-subscripts-in-arrays_002c-uninitialized-variables-as-1122">subscripts
in arrays, uninitialized variables as</a>: <a
href="#Uninitialized-Subscripts">Uninitialized Subscripts</a></li>
-<li><a
href="#index-_0040code_007bSUBSEP_007d-variable-1035"><code>SUBSEP</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bSUBSEP_007d-variable_002c-multidimensional-arrays-1129"><code>SUBSEP</code>
variable, multidimensional arrays</a>: <a
href="#Multi_002ddimensional">Multi-dimensional</a></li>
-<li><a
href="#index-_0040code_007bsubstr_007d-function-1190"><code>substr</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a href="#index-Sumner_002c-Andrew-1944">Sumner, Andrew</a>: <a
href="#Other-Versions">Other Versions</a></li>
-<li><a
href="#index-_0040code_007bswitch_007d-statement-958"><code>switch</code>
statement</a>: <a href="#Switch-Statement">Switch Statement</a></li>
-<li><a
href="#index-syntactic-ambiguity_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-709">syntactic
ambiguity: <code>/=</code> operator vs. <code>/=.../</code> regexp
constant</a>: <a href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-_0040code_007bsystem_007d-function-1219"><code>system</code>
function</a>: <a href="#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="#index-_0040code_007bsystime_007d-function-_0028_0040command_007bgawk_007d_0029-1235"><code>systime</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-tandem-1919">tandem</a>: <a
href="#Tandem-Installation">Tandem Installation</a></li>
-<li><a href="#index-Tcl-1612">Tcl</a>: <a href="#Library-Names">Library
Names</a></li>
-<li><a href="#index-TCP_002fIP-1421">TCP/IP</a>: <a
href="#TCP_002fIP-Networking">TCP/IP Networking</a></li>
-<li><a href="#index-TCP_002fIP_002c-support-for-584">TCP/IP, support for</a>:
<a href="#Special-Network">Special Network</a></li>
-<li><a href="#index-_0040code_007btee_007d-utility-1772"><code>tee</code>
utility</a>: <a href="#Tee-Program">Tee Program</a></li>
-<li><a
href="#index-_0040code_007btee_002eawk_007d-program-1774"><code>tee.awk</code>
program</a>: <a href="#Tee-Program">Tee Program</a></li>
-<li><a href="#index-terminating-records-364">terminating records</a>: <a
href="#Records">Records</a></li>
-<li><a
href="#index-_0040code_007btestbits_002eawk_007d-program-1264"><code>testbits.awk</code>
program</a>: <a href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-Texinfo-1959">Texinfo</a>: <a href="#Adding-Code">Adding
Code</a></li>
-<li><a href="#index-Texinfo-1878">Texinfo</a>: <a
href="#Distribution-contents">Distribution contents</a></li>
-<li><a href="#index-Texinfo-1811">Texinfo</a>: <a
href="#Extract-Program">Extract Program</a></li>
-<li><a href="#index-Texinfo-1789">Texinfo</a>: <a
href="#Dupword-Program">Dupword Program</a></li>
-<li><a href="#index-Texinfo-1593">Texinfo</a>: <a
href="#Library-Functions">Library Functions</a></li>
-<li><a href="#index-Texinfo-28">Texinfo</a>: <a
href="#Conventions">Conventions</a></li>
-<li><a href="#index-Texinfo_002c-chapter-beginnings-in-files-225">Texinfo,
chapter beginnings in files</a>: <a href="#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="#index-Texinfo_002c-extracting-programs-from-source-files-1809">Texinfo,
extracting programs from source files</a>: <a href="#Extract-Program">Extract
Program</a></li>
-<li><a href="#index-text_002c-printing-504">text, printing</a>: <a
href="#Print">Print</a></li>
-<li><a
href="#index-text_0040comma_007b_007d-printing_002c-unduplicated-lines-of-1776">text,
printing, unduplicated lines of</a>: <a href="#Uniq-Program">Uniq
Program</a></li>
-<li><a
href="#index-_0040code_007btextdomain_007d-function-_0028C-library_0029-1309"><code>textdomain</code>
function (C library)</a>: <a href="#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="#index-_0040code_007bTEXTDOMAIN_007d-variable-1343"><code>TEXTDOMAIN</code>
variable</a>: <a href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040code_007bTEXTDOMAIN_007d-variable-1038"><code>TEXTDOMAIN</code>
variable</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a
href="#index-_0040code_007bTEXTDOMAIN_007d-variable_002c-_0040code_007bBEGIN_007d-pattern-and-1354"><code>TEXTDOMAIN</code>
variable, <code>BEGIN</code> pattern and</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="#index-_0040code_007bTEXTDOMAIN_007d-variable_002c-portability-and-1378"><code>TEXTDOMAIN</code>
variable, portability and</a>: <a href="#I18N-Portability">I18N
Portability</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-896">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-861">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-761">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-621">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-328">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-320">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-176">tilde
(<code>~</code>), <code>~</code> operator</a>: <a href="#Regexp-Usage">Regexp
Usage</a></li>
-<li><a href="#index-time_002c-alarm-clock-example-program-1793">time, alarm
clock example program</a>: <a href="#Alarm-Program">Alarm Program</a></li>
-<li><a href="#index-time_002c-localization-and-1338">time, localization
and</a>: <a href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="#index-time_002c-managing-1661">time, managing</a>: <a
href="#Gettimeofday-Function">Gettimeofday Function</a></li>
-<li><a href="#index-time_002c-retrieving-1234">time, retrieving</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-timestamps-1228">timestamps</a>: <a
href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-timestamps_002c-converting-dates-to-1241">timestamps,
converting dates to</a>: <a href="#Time-Functions">Time Functions</a></li>
-<li><a href="#index-timestamps_002c-formatted-1660">timestamps, formatted</a>:
<a href="#Gettimeofday-Function">Gettimeofday Function</a></li>
-<li><a
href="#index-_0040code_007btmp_005fnumber_007d-internal-function-1996"><code>tmp_number</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007btmp_005fstring_007d-internal-function-1995"><code>tmp_string</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a
href="#index-_0040code_007btolower_007d-function-1195"><code>tolower</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-_0040code_007btoupper_007d-function-1196"><code>toupper</code>
function</a>: <a href="#String-Functions">String Functions</a></li>
-<li><a href="#index-_0040command_007btr_007d-utility-1798"><samp><span
class="command">tr</span></samp> utility</a>: <a
href="#Translate-Program">Translate Program</a></li>
-<li><a
href="#index-_0040code_007btranslate_002eawk_007d-program-1799"><code>translate.awk</code>
program</a>: <a href="#Translate-Program">Translate Program</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1526">troubleshooting,
<code>--non-decimal-data</code> option</a>: <a href="#Options">Options</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007b_002dF_007d-option-1587">troubleshooting,
<code>-F</code> option</a>: <a href="#Known-Bugs">Known Bugs</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007b_003d_003d_007d-operator-765">troubleshooting,
<code>==</code> operator</a>: <a href="#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040command_007bawk_007d-uses-_0040code_007bFS_007d-not-_0040code_007bIFS_007d-405">troubleshooting,
<samp><span class="command">awk</span></samp> uses <code>FS</code> not
<code>IFS</code></a>: <a href="#Field-Separators">Field Separators</a></li>
-<li><a
href="#index-troubleshooting_002c-backslash-before-nonspecial-character-216">troubleshooting,
backslash before nonspecial character</a>: <a href="#Escape-Sequences">Escape
Sequences</a></li>
-<li><a href="#index-troubleshooting_002c-division-655">troubleshooting,
division</a>: <a href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="#index-troubleshooting_002c-fatal-errors_002c-field-widths_0040comma_007b_007d-specifying-441">troubleshooting,
fatal errors, field widths, specifying</a>: <a href="#Constant-Size">Constant
Size</a></li>
-<li><a
href="#index-troubleshooting_002c-fatal-errors_002c-_0040code_007bprintf_007d-format-strings-542">troubleshooting,
fatal errors, <code>printf</code> format strings</a>: <a
href="#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bfflush_007d-function-1218">troubleshooting,
<code>fflush</code> function</a>: <a href="#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="#index-troubleshooting_002c-function-call-syntax-807">troubleshooting,
function call syntax</a>: <a href="#Function-Calls">Function Calls</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040command_007bgawk_007d-1953">troubleshooting,
<samp><span class="command">gawk</span></samp></a>: <a
href="#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040command_007bgawk_007d-1586">troubleshooting,
<samp><span class="command">gawk</span></samp></a>: <a
href="#Known-Bugs">Known Bugs</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040command_007bgawk_007d_002c-bug-reports-1923">troubleshooting,
<samp><span class="command">gawk</span></samp>, bug reports</a>: <a
href="#Bugs">Bugs</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040command_007bgawk_007d_002c-fatal-errors_0040comma_007b_007d-function-arguments-1144">troubleshooting,
<samp><span class="command">gawk</span></samp>, fatal errors, function
arguments</a>: <a href="#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bgetline_007d-function-1676">troubleshooting,
<code>getline</code> function</a>: <a href="#File-Checking">File
Checking</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-functions-1187">troubleshooting,
<code>gsub</code>/<code>sub</code> functions</a>: <a
href="#String-Functions">String Functions</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bmatch_007d-function-1175">troubleshooting,
<code>match</code> function</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bprint_007d-statement_0040comma_007b_007d-omitting-commas-508">troubleshooting,
<code>print</code> statement, omitting commas</a>: <a
href="#Print-Examples">Print Examples</a></li>
-<li><a href="#index-troubleshooting_002c-printing-560">troubleshooting,
printing</a>: <a href="#Redirection">Redirection</a></li>
-<li><a
href="#index-troubleshooting_002c-quotes-with-_0040value_007bFN_007ds-580">troubleshooting,
quotes with file names</a>: <a href="#Special-FD">Special FD</a></li>
-<li><a
href="#index-troubleshooting_002c-readable-_0040value_007bDF_007ds-1672">troubleshooting,
readable data files</a>: <a href="#File-Checking">File Checking</a></li>
-<li><a
href="#index-troubleshooting_002c-regexp-constants-vs_002e-string-constants-336">troubleshooting,
regexp constants vs. string constants</a>: <a
href="#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="#index-troubleshooting_002c-string-concatenation-666">troubleshooting,
string concatenation</a>: <a href="#Concatenation">Concatenation</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bsubstr_007d-function-1191">troubleshooting,
<code>substr</code> function</a>: <a href="#String-Functions">String
Functions</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040code_007bsystem_007d-function-1221">troubleshooting,
<code>system</code> function</a>: <a href="#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="#index-troubleshooting_002c-typographical-errors_0040comma_007b_007d-global-variables-1510">troubleshooting,
typographical errors, global variables</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-true_002c-logical-734">true, logical</a>: <a
href="#Truth-Values">Truth Values</a></li>
-<li><a href="#index-Trueman_002c-David-1846">Trueman, David</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Trueman_002c-David-52">Trueman, David</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a href="#index-Trueman_002c-David-19">Trueman, David</a>: <a
href="#History">History</a></li>
-<li><a href="#index-trunc_002dmod-operation-658">trunc-mod operation</a>: <a
href="#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a href="#index-truth-values-731">truth values</a>: <a
href="#Truth-Values">Truth Values</a></li>
-<li><a href="#index-type-conversion-645">type conversion</a>: <a
href="#Conversion">Conversion</a></li>
-<li><a
href="#index-_0040code_007btype_007d-internal-variable-1985"><code>type</code>
internal variable</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-undefined-functions-1294">undefined functions</a>: <a
href="#Function-Caveats">Function Caveats</a></li>
-<li><a
href="#index-underscore-_0028_0040code_007b_005f_007d_0029_002c-_0040code_007b_005f_007d-C-macro-1325">underscore
(<code>_</code>), <code>_</code> C macro</a>: <a
href="#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="#index-underscore-_0028_0040code_007b_005f_007d_0029_002c-in-names-of-private-variables-1607">underscore
(<code>_</code>), in names of private variables</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a
href="#index-underscore-_0028_0040code_007b_005f_007d_0029_002c-translatable-string-1356">underscore
(<code>_</code>), translatable string</a>: <a
href="#Programmer-i18n">Programmer i18n</a></li>
-<li><a href="#index-undocumented-features-1578">undocumented features</a>: <a
href="#Undocumented">Undocumented</a></li>
-<li><a
href="#index-uninitialized-variables_002c-as-array-subscripts-1121">uninitialized
variables, as array subscripts</a>: <a
href="#Uninitialized-Subscripts">Uninitialized Subscripts</a></li>
-<li><a href="#index-_0040command_007buniq_007d-utility-1777"><samp><span
class="command">uniq</span></samp> utility</a>: <a href="#Uniq-Program">Uniq
Program</a></li>
-<li><a
href="#index-_0040code_007buniq_002eawk_007d-program-1778"><code>uniq.awk</code>
program</a>: <a href="#Uniq-Program">Uniq Program</a></li>
-<li><a href="#index-Unix-2082">Unix</a>: <a href="#Glossary">Glossary</a></li>
-<li><a
href="#index-Unix-_0040command_007bawk_007d_002c-backslashes-in-escape-sequences-218">Unix
<samp><span class="command">awk</span></samp>, backslashes in escape
sequences</a>: <a href="#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="#index-Unix-_0040command_007bawk_007d_002c-_0040code_007bclose_007d-function-and-603">Unix
<samp><span class="command">awk</span></samp>, <code>close</code> function
and</a>: <a href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a
href="#index-Unix-_0040command_007bawk_007d_002c-password-files_0040comma_007b_007d-field-separators-and-431">Unix
<samp><span class="command">awk</span></samp>, password files, field
separators and</a>: <a href="#Command-Line-Field-Separator">Command Line Field
Separator</a></li>
-<li><a href="#index-Unix_002c-_0040command_007bawk_007d-scripts-and-107">Unix,
<samp><span class="command">awk</span></samp> scripts and</a>: <a
href="#Executable-Scripts">Executable Scripts</a></li>
-<li><a href="#index-unsigned-integers-2041">unsigned integers</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a
href="#index-_0040code_007bupdate_005fERRNO_007d-internal-function-2010"><code>update_ERRNO</code>
internal function</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-user-database_0040comma_007b_007d-reading-1692">user
database, reading</a>: <a href="#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="#index-user_002ddefined_002c-functions-1275">user-defined,
functions</a>: <a href="#User_002ddefined">User-defined</a></li>
-<li><a
href="#index-user_002ddefined_002c-functions_002c-counts-1451">user-defined,
functions, counts</a>: <a href="#Profiling">Profiling</a></li>
-<li><a href="#index-user_002ddefined_002c-variables-633">user-defined,
variables</a>: <a href="#Variables">Variables</a></li>
-<li><a href="#index-user_002dmodifiable-variables-994">user-modifiable
variables</a>: <a href="#User_002dmodified">User-modified</a></li>
-<li><a href="#index-users_002c-information-about_002c-printing-1763">users,
information about, printing</a>: <a href="#Id-Program">Id Program</a></li>
-<li><a href="#index-users_002c-information-about_002c-retrieving-1697">users,
information about, retrieving</a>: <a href="#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="#index-_0040code_007bUSR1_007d-signal-1459"><code>USR1</code>
signal</a>: <a href="#Profiling">Profiling</a></li>
-<li><a href="#index-values_002c-numeric-2035">values, numeric</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-values_002c-string-2036">values, string</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-variable-typing-743">variable typing</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a href="#index-variables-2034">variables</a>: <a
href="#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="#index-variables-165">variables</a>: <a
href="#Other-Features">Other Features</a></li>
-<li><a href="#index-variables_002c-assigning-on-command-line-636">variables,
assigning on command line</a>: <a href="#Assignment-Options">Assignment
Options</a></li>
-<li><a href="#index-variables_002c-built_002din-991">variables, built-in</a>:
<a href="#Built_002din-Variables">Built-in Variables</a></li>
-<li><a href="#index-variables_002c-built_002din-634">variables, built-in</a>:
<a href="#Using-Variables">Using Variables</a></li>
-<li><a
href="#index-variables_002c-built_002din_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1492">variables,
built-in, <code>-v</code> option, setting with</a>: <a
href="#Options">Options</a></li>
-<li><a
href="#index-variables_002c-built_002din_002c-conveying-information-1042">variables,
built-in, conveying information</a>: <a href="#Auto_002dset">Auto-set</a></li>
-<li><a href="#index-variables_002c-flag-794">variables, flag</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-487">variables,
<code>getline</code> command into, using</a>: <a
href="#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a></li>
-<li><a
href="#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-480">variables,
<code>getline</code> command into, using</a>: <a
href="#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a></li>
-<li><a
href="#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-468">variables,
<code>getline</code> command into, using</a>: <a
href="#Getline_002fVariable_002fFile">Getline/Variable/File</a></li>
-<li><a
href="#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-461">variables,
<code>getline</code> command into, using</a>: <a
href="#Getline_002fVariable">Getline/Variable</a></li>
-<li><a
href="#index-variables_002c-global_002c-for-library-functions-1602">variables,
global, for library functions</a>: <a href="#Library-Names">Library
Names</a></li>
-<li><a
href="#index-variables_002c-global_002c-printing-list-of-1509">variables,
global, printing list of</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-variables_002c-initializing-635">variables,
initializing</a>: <a href="#Using-Variables">Using Variables</a></li>
-<li><a href="#index-variables_002c-names-of-1076">variables, names of</a>: <a
href="#Arrays">Arrays</a></li>
-<li><a href="#index-variables_002c-private-1604">variables, private</a>: <a
href="#Library-Names">Library Names</a></li>
-<li><a href="#index-variables_002c-setting-1490">variables, setting</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-variables_002c-shadowing-1282">variables, shadowing</a>:
<a href="#Definition-Syntax">Definition Syntax</a></li>
-<li><a href="#index-variables_002c-types-of-680">variables, types of</a>: <a
href="#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="#index-variables_002c-types-of_002c-comparison-expressions-and-744">variables,
types of, comparison expressions and</a>: <a
href="#Typing-and-Comparison">Typing and Comparison</a></li>
-<li><a
href="#index-variables_002c-uninitialized_0040comma_007b_007d-as-array-subscripts-1120">variables,
uninitialized, as array subscripts</a>: <a
href="#Uninitialized-Subscripts">Uninitialized Subscripts</a></li>
-<li><a href="#index-variables_002c-user_002ddefined-632">variables,
user-defined</a>: <a href="#Variables">Variables</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029-240">vertical bar
(<code>|</code>)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-853">vertical
bar (<code>|</code>), <code>|</code> operator (I/O)</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-471">vertical
bar (<code>|</code>), <code>|</code> operator (I/O)</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-I_002fO-operator-_0028I_002fO_0029-1412">vertical
bar (<code>|</code>), <code>|&</code> I/O operator (I/O)</a>: <a
href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-856">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O)</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-484">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O)</a>: <a
href="#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1437">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O), two-way
communications</a>: <a href="#Portal-Files">Portal Files</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-868">vertical
bar (<code>|</code>), <code>||</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-789">vertical
bar (<code>|</code>), <code>||</code> operator</a>: <a
href="#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="#index-_0040code_007bvname_007d-internal-variable-1986"><code>vname</code>
internal variable</a>: <a href="#Internals">Internals</a></li>
-<li><a href="#index-_0040command_007bw_007d-utility-442"><samp><span
class="command">w</span></samp> utility</a>: <a href="#Constant-Size">Constant
Size</a></li>
-<li><a href="#index-Wall_002c-Larry-2020">Wall, Larry</a>: <a
href="#Future-Extensions">Future Extensions</a></li>
-<li><a href="#index-warnings_002c-issuing-1521">warnings, issuing</a>: <a
href="#Options">Options</a></li>
-<li><a href="#index-_0040command_007bwc_007d-utility-1784"><samp><span
class="command">wc</span></samp> utility</a>: <a href="#Wc-Program">Wc
Program</a></li>
-<li><a
href="#index-_0040code_007bwc_002eawk_007d-program-1785"><code>wc.awk</code>
program</a>: <a href="#Wc-Program">Wc Program</a></li>
-<li><a href="#index-Weinberger_002c-Peter-1839">Weinberger, Peter</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Weinberger_002c-Peter-14">Weinberger, Peter</a>: <a
href="#History">History</a></li>
-<li><a href="#index-_0040code_007bwhile_007d-statement-951"><code>while</code>
statement</a>: <a href="#While-Statement">While Statement</a></li>
-<li><a href="#index-_0040code_007bwhile_007d-statement-180"><code>while</code>
statement</a>: <a href="#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="#index-whitespace_002c-as-field-separators-412">whitespace, as
field separators</a>: <a href="#Field-Separators">Field Separators</a></li>
-<li><a
href="#index-whitespace_002c-functions_0040comma_007b_007d-calling-1143">whitespace,
functions, calling</a>: <a href="#Calling-Built_002din">Calling
Built-in</a></li>
-<li><a href="#index-whitespace_002c-newlines-as-1532">whitespace, newlines
as</a>: <a href="#Options">Options</a></li>
-<li><a href="#index-Williams_002c-Kent-1850">Williams, Kent</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-Woods_002c-John-1845">Woods, John</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a href="#index-word-boundaries_0040comma_007b_007d-matching-295">word
boundaries, matching</a>: <a href="#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a href="#index-word_002c-regexp-definition-of-284">word, regexp
definition of</a>: <a href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-word_002dboundary-operator-_0028_0040command_007bgawk_007d_0029-310">word-boundary
operator (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#GNU-Regexp-Operators">GNU Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007bwordfreq_002eawk_007d-program-1805"><code>wordfreq.awk</code>
program</a>: <a href="#Word-Sorting">Word Sorting</a></li>
-<li><a href="#index-words_002c-counting-1781">words, counting</a>: <a
href="#Wc-Program">Wc Program</a></li>
-<li><a
href="#index-words_002c-duplicate_0040comma_007b_007d-searching-for-1786">words,
duplicate, searching for</a>: <a href="#Dupword-Program">Dupword
Program</a></li>
-<li><a
href="#index-words_002c-usage-counts_0040comma_007b_007d-generating-1803">words,
usage counts, generating</a>: <a href="#Word-Sorting">Word Sorting</a></li>
-<li><a
href="#index-_0040code_007bxgettext_007d-utility-1370"><code>xgettext</code>
utility</a>: <a href="#String-Extraction">String Extraction</a></li>
-<li><a href="#index-XOR-bitwise-operation-1248">XOR bitwise operation</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="#index-_0040code_007bxor_007d-function-_0028_0040command_007bgawk_007d_0029-1259"><code>xor</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="#index-Zaretskii_002c-Eli-66">Zaretskii, Eli</a>: <a
href="#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="#index-zero_0040comma_007b_007d-negative-vs_002e_0040_003a-positive-2051">zero,
negative vs. positive</a>: <a href="#Floating-Point-Issues">Floating Point
Issues</a></li>
-<li><a
href="#index-_0040code_007bzerofile_002eawk_007d-program-1677"><code>zerofile.awk</code>
program</a>: <a href="#Empty-Files">Empty Files</a></li>
-<li><a href="#index-Zoulas_002c-Christos-1858">Zoulas, Christos</a>: <a
href="#Contributors">Contributors</a></li>
-<li><a
href="#index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-actions-and-932"><code>{}</code>
(braces), actions and</a>: <a href="#Action-Overview">Action Overview</a></li>
-<li><a
href="#index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-_0040command_007bpgawk_007d-program-1452"><code>{}</code>
(braces), <samp><span class="command">pgawk</span></samp> program</a>: <a
href="#Profiling">Profiling</a></li>
-<li><a
href="#index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-statements_002c-grouping-945"><code>{}</code>
(braces), statements, grouping</a>: <a href="#Statements">Statements</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029-239"><code>|</code>
(vertical bar)</a>: <a href="#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-852"><code>|</code>
(vertical bar), <code>|</code> operator (I/O)</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-553"><code>|</code>
(vertical bar), <code>|</code> operator (I/O)</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-470"><code>|</code>
(vertical bar), <code>|</code> operator (I/O)</a>: <a
href="#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-1411"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-855"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-557"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="#Redirection">Redirection</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-483"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-pipes_0040comma_007b_007d-closing-597"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O), pipes, closing</a>: <a
href="#Close-Files-And-Pipes">Close Files And Pipes</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1436"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O), two-way
communications</a>: <a href="#Portal-Files">Portal Files</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-867"><code>|</code>
(vertical bar), <code>||</code> operator</a>: <a
href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-788"><code>|</code>
(vertical bar), <code>||</code> operator</a>: <a href="#Boolean-Ops">Boolean
Ops</a></li>
-<li><a
href="#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-895"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-860"><code>~</code>
(tilde), <code>~</code> operator</a>: <a href="#Precedence">Precedence</a></li>
-<li><a
href="#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-760"><code>~</code>
(tilde), <code>~</code> operator</a>: <a href="#Typing-and-Comparison">Typing
and Comparison</a></li>
-<li><a
href="#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-620"><code>~</code>
(tilde), <code>~</code> operator</a>: <a href="#Regexp-Constants">Regexp
Constants</a></li>
-<li><a
href="#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-327"><code>~</code>
(tilde), <code>~</code> operator</a>: <a href="#Computed-Regexps">Computed
Regexps</a></li>
-<li><a
href="#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-319"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="#Case_002dsensitivity">Case-sensitivity</a></li>
- </ul><div class="footnote">
-<hr>
-<a name="texinfo-footnotes-in-document"></a><h4>Footnotes</h4><p
class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small> These
commands
-are available on POSIX-compliant systems, as well as on traditional
-Unix-based systems. If you are using some other operating system, you still
need to
-be familiar with the ideas of I/O redirection and pipes.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
Often, these systems
-use <samp><span class="command">gawk</span></samp> for their <samp><span
class="command">awk</span></samp> implementation!</p>
-
- <p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small> All
such differences
-appear in the index under the
-entry “differences in <samp><span class="command">awk</span></samp> and
<samp><span class="command">gawk</span></samp>.”</p>
-
- <p class="footnote"><small>[<a name="fn-4" href="#fnd-4">4</a>]</small> GNU
stands for “GNU's not Unix.”</p>
-
- <p class="footnote"><small>[<a name="fn-5" href="#fnd-5">5</a>]</small> The
terminology “GNU/Linux” is explained
-in the <a href="#Glossary">Glossary</a>.</p>
-
- <p class="footnote"><small>[<a name="fn-6" href="#fnd-6">6</a>]</small>
Although we generally recommend the use of single
-quotes around the program text, double quotes are needed here in order to
-put the single quote into the message.</p>
-
- <p class="footnote"><small>[<a name="fn-7" href="#fnd-7">7</a>]</small> The
`<samp><span class="samp">#!</span></samp>' mechanism works on
-Linux systems,
-systems derived from the 4.4-Lite Berkeley Software Distribution,
-and most commercial Unix systems.</p>
-
- <p class="footnote"><small>[<a name="fn-8" href="#fnd-8">8</a>]</small> The
-line beginning with `<samp><span class="samp">#!</span></samp>' lists the full
file name of an interpreter
-to run and an optional initial command-line argument to pass to that
-interpreter. The operating system then runs the interpreter with the given
-argument and the full argument list of the executed program. The first
argument
-in the list is the full file name of the <samp><span
class="command">awk</span></samp> program. The rest of the
-argument list contains either options to <samp><span
class="command">awk</span></samp>, or data files,
-or both.</p>
-
- <p class="footnote"><small>[<a name="fn-9" href="#fnd-9">9</a>]</small> In
the C shell (<samp><span class="command">csh</span></samp>), you need to type
-a semicolon and then a backslash at the end of the first line; see
-<a href="#Statements_002fLines">Statements/Lines</a>, for an
-explanation. In a POSIX-compliant shell, such as the Bourne
-shell or <samp><span class="command">bash</span></samp>, you can type the
example as shown. If the command
-`<samp><span class="samp">echo $path</span></samp>' produces an empty output
line, you are most likely
-using a POSIX-compliant shell. Otherwise, you are probably using the
-C shell or a shell derived from it.</p>
-
- <p class="footnote"><small>[<a name="fn-10" href="#fnd-10">10</a>]</small>
On some
-very old systems, you may need to use `<samp><span class="samp">ls
-lg</span></samp>' to get this output.</p>
-
- <p class="footnote"><small>[<a name="fn-11" href="#fnd-11">11</a>]</small>
The `<samp><span class="samp">?</span></samp>' and `<samp><span
class="samp">:</span></samp>' referred to here is the
-three-operand conditional expression described in
-<a href="#Conditional-Exp">Conditional Exp</a>.
-Splitting lines after `<samp><span class="samp">?</span></samp>' and
`<samp><span class="samp">:</span></samp>' is a minor <samp><span
class="command">gawk</span></samp>
-extension; if <samp><span class="option">--posix</span></samp> is specified
-(see <a href="#Options">Options</a>), then this extension is disabled.</p>
-
- <p class="footnote"><small>[<a name="fn-12" href="#fnd-12">12</a>]</small>
<a href="http://www.awk-scripting.de/cgi/wiki.cgi/yawk/">Yet Another Wiki
Clone</a>.</p>
-
- <p class="footnote"><small>[<a name="fn-13" href="#fnd-13">13</a>]</small>
In other literature,
-you may see a character list referred to as either a
-<dfn>character set</dfn>, a <dfn>character class</dfn>, or a <dfn>bracket
expression</dfn>.</p>
-
- <p class="footnote"><small>[<a name="fn-14" href="#fnd-14">14</a>]</small>
Use two backslashes if you're
-using a string constant with a regexp operator or function.</p>
-
- <p class="footnote"><small>[<a name="fn-15" href="#fnd-15">15</a>]</small>
Experienced C and C++ programmers will note
-that it is possible, using something like
-`<samp><span class="samp">IGNORECASE = 1 && /foObAr/ { ...
}</span></samp>'
-and
-`<samp><span class="samp">IGNORECASE = 0 || /foobar/ { ... }</span></samp>'.
-However, this is somewhat obscure and we don't recommend it.</p>
-
- <p class="footnote"><small>[<a name="fn-16" href="#fnd-16">16</a>]</small>
At least that we know
-about.</p>
-
- <p class="footnote"><small>[<a name="fn-17" href="#fnd-17">17</a>]</small>
In POSIX <samp><span class="command">awk</span></samp>, newlines are not
-considered whitespace for separating fields.</p>
-
- <p class="footnote"><small>[<a name="fn-18" href="#fnd-18">18</a>]</small>
The <samp><span class="command">sed</span></samp> utility is a “stream
editor.”
-Its behavior is also defined by the POSIX standard.</p>
-
- <p class="footnote"><small>[<a name="fn-19" href="#fnd-19">19</a>]</small>
When <code>FS</code> is the null string (<code>""</code>)
-or a regexp, this special feature of <code>RS</code> does not apply.
-It does apply to the default field separator of a single space:
-`<samp><span class="samp">FS = " "</span></samp>'.</p>
-
- <p class="footnote"><small>[<a name="fn-20" href="#fnd-20">20</a>]</small>
Older versions of
-<samp><span class="command">gawk</span></samp> would interpret these names
internally only if the system
-did not actually have a <samp><span class="file">/dev/fd</span></samp>
directory or any of the other
-special files listed earlier. Usually this didn't make a difference,
-but sometimes it did; thus, it was decided to make <samp><span
class="command">gawk</span></samp>'s
-behavior consistent on all systems and to have it always interpret
-the special file names itself.</p>
-
- <p class="footnote"><small>[<a name="fn-21" href="#fnd-21">21</a>]</small>
The technical terminology is rather morbid.
-The finished child is called a “zombie,” and cleaning up after
-it is referred to as “reaping.”</p>
-
- <p class="footnote"><small>[<a name="fn-22" href="#fnd-22">22</a>]</small>
-This is a full 16-bit value as returned by the <code>wait</code>
-system call. See the system manual pages for information on
-how to decode this value.</p>
-
- <p class="footnote"><small>[<a name="fn-23" href="#fnd-23">23</a>]</small>
The internal representation of all numbers,
-including integers, uses double-precision
-floating-point numbers.
-On most modern systems, these are in IEEE 754 standard format.</p>
-
- <p class="footnote"><small>[<a name="fn-24" href="#fnd-24">24</a>]</small>
Pathological cases can require up to
-752 digits (!), but we doubt that you need to worry about this.</p>
-
- <p class="footnote"><small>[<a name="fn-25" href="#fnd-25">25</a>]</small>
The POSIX standard is under
-revision. The revised standard's rules for typing and comparison are
-the same as just described for <samp><span
class="command">gawk</span></samp>.</p>
-
- <p class="footnote"><small>[<a name="fn-26" href="#fnd-26">26</a>]</small>
The original version of <samp><span class="command">awk</span></samp> used to
keep
-reading and ignoring input until the end of the file was seen.</p>
-
- <p class="footnote"><small>[<a name="fn-27" href="#fnd-27">27</a>]</small>
In
-POSIX <samp><span class="command">awk</span></samp>, newline does not count as
whitespace.</p>
-
- <p class="footnote"><small>[<a name="fn-28" href="#fnd-28">28</a>]</small>
Some early implementations of Unix <samp><span
class="command">awk</span></samp> initialized
-<code>FILENAME</code> to <code>"-"</code>, even if there were data files to be
-processed. This behavior was incorrect and should not be relied
-upon in your programs.</p>
-
- <p class="footnote"><small>[<a name="fn-29" href="#fnd-29">29</a>]</small>
Thanks to Michael Brennan for pointing this out.</p>
-
- <p class="footnote"><small>[<a name="fn-30" href="#fnd-30">30</a>]</small>
The C version of <code>rand</code>
-is known to produce fairly poor sequences of random numbers.
-However, nothing requires that an <samp><span
class="command">awk</span></samp> implementation use the C
-<code>rand</code> to implement the <samp><span
class="command">awk</span></samp> version of <code>rand</code>.
-In fact, <samp><span class="command">gawk</span></samp> uses the BSD
<code>random</code> function, which is
-considerably better than <code>rand</code>, to produce random numbers.</p>
-
- <p class="footnote"><small>[<a name="fn-31" href="#fnd-31">31</a>]</small>
Computer-generated random numbers really are not truly
-random. They are technically known as “pseudorandom.” This means
-that while the numbers in a sequence appear to be random, you can in
-fact generate the same sequence of random numbers over and over again.</p>
-
- <p class="footnote"><small>[<a name="fn-32" href="#fnd-32">32</a>]</small>
Unless
-you use the <samp><span class="option">--non-decimal-data</span></samp>
option, which isn't recommended.
-See <a href="#Nondecimal-Data">Nondecimal Data</a>, for more information.</p>
-
- <p class="footnote"><small>[<a name="fn-33" href="#fnd-33">33</a>]</small>
Note that this means
-that the record will first be regenerated using the value of <code>OFS</code>
if
-any fields have been changed, and that the fields will be updated
-after the substituion, even if the operation is a “no-op” such
-as `<samp><span class="samp">sub(/^/, "")</span></samp>'.</p>
-
- <p class="footnote"><small>[<a name="fn-34" href="#fnd-34">34</a>]</small>
This is different from
-C and C++, in which the first character is number zero.</p>
-
- <p class="footnote"><small>[<a name="fn-35" href="#fnd-35">35</a>]</small>
This consequence was certainly unintended.</p>
-
- <p class="footnote"><small>[<a name="fn-36" href="#fnd-36">36</a>]</small>
A program is interactive
-if the standard output is connected
-to a terminal device.</p>
-
- <p class="footnote"><small>[<a name="fn-37" href="#fnd-37">37</a>]</small>
See <a href="#Glossary">Glossary</a>,
-especially the entries “Epoch” and “UTC.”</p>
-
- <p class="footnote"><small>[<a name="fn-38" href="#fnd-38">38</a>]</small>
The GNU <samp><span class="command">date</span></samp> utility can
-also do many of the things described here. Its use may be preferable
-for simple time-related operations in shell scripts.</p>
-
- <p class="footnote"><small>[<a name="fn-39" href="#fnd-39">39</a>]</small>
Occasionally there are
-minutes in a year with a leap second, which is why the
-seconds can go up to 60.</p>
-
- <p class="footnote"><small>[<a name="fn-40" href="#fnd-40">40</a>]</small>
As this
-is a recent standard, not every system's <code>strftime</code> necessarily
-supports all of the conversions listed here.</p>
-
- <p class="footnote"><small>[<a name="fn-41" href="#fnd-41">41</a>]</small>
If you don't understand any of this, don't worry about
-it; these facilities are meant to make it easier to
“internationalize”
-programs.
-Other internationalization features are described in
-<a href="#Internationalization">Internationalization</a>.</p>
-
- <p class="footnote"><small>[<a name="fn-42" href="#fnd-42">42</a>]</small>
This is because ISO C leaves the
-behavior of the C version of <code>strftime</code> undefined and <samp><span
class="command">gawk</span></samp>
-uses the system's version of <code>strftime</code> if it's there.
-Typically, the conversion specifier either does not appear in the
-returned string or appears literally.</p>
-
- <p class="footnote"><small>[<a name="fn-43" href="#fnd-43">43</a>]</small>
This example
-shows that 0's come in on the left side. For <samp><span
class="command">gawk</span></samp>, this is
-always true, but in some languages, it's possible to have the left side
-fill with 1's. Caveat emptor.</p>
-
- <p class="footnote"><small>[<a name="fn-44" href="#fnd-44">44</a>]</small>
For some operating systems, the <samp><span class="command">gawk</span></samp>
-port doesn't support GNU <code>gettext</code>. This applies most notably to
-the PC operating systems. As such, these features are not available
-if you are using one of those operating systems. Sorry.</p>
-
- <p class="footnote"><small>[<a name="fn-45" href="#fnd-45">45</a>]</small>
Americans
-use a comma every three decimal places and a period for the decimal
-point, while many Europeans do exactly the opposite:
-<code>1,234.56</code> versus <code>1.234,56</code>.</p>
-
- <p class="footnote"><small>[<a name="fn-46" href="#fnd-46">46</a>]</small>
Starting with <code>gettext</code>
-version 0.11.5, the <samp><span class="command">xgettext</span></samp> utility
that comes with GNU
-<code>gettext</code> can handle <samp><span class="file">.awk</span></samp>
files.</p>
-
- <p class="footnote"><small>[<a name="fn-47" href="#fnd-47">47</a>]</small>
This example is borrowed
-from the GNU <code>gettext</code> manual.</p>
-
- <p class="footnote"><small>[<a name="fn-48" href="#fnd-48">48</a>]</small>
This is good fodder for an “Obfuscated
-<samp><span class="command">awk</span></samp>” contest.</p>
-
- <p class="footnote"><small>[<a name="fn-49" href="#fnd-49">49</a>]</small>
Perhaps it would be better if it were
-called “Hippy.” Ah, well.</p>
-
- <p class="footnote"><small>[<a name="fn-50" href="#fnd-50">50</a>]</small>
This is very
-different from the same operator in the C shell, <samp><span
class="command">csh</span></samp>.</p>
-
- <p class="footnote"><small>[<a name="fn-51" href="#fnd-51">51</a>]</small>
Not recommended.</p>
-
- <p class="footnote"><small>[<a name="fn-52" href="#fnd-52">52</a>]</small>
Your version of <samp><span class="command">gawk</span></samp>
-may use a different directory; it
-will depend upon how <samp><span class="command">gawk</span></samp> was built
and installed. The actual
-directory is the value of `<samp><span class="samp">$(datadir)</span></samp>'
generated when
-<samp><span class="command">gawk</span></samp> was configured. You probably
don't need to worry about this,
-though.</p>
-
- <p class="footnote"><small>[<a name="fn-53" href="#fnd-53">53</a>]</small>
The effects are
-not identical. Output of the transformed
-record will be in all lowercase, while <code>IGNORECASE</code> preserves the
original
-contents of the input record.</p>
-
- <p class="footnote"><small>[<a name="fn-54" href="#fnd-54">54</a>]</small>
While all the library routines could have
-been rewritten to use this convention, this was not done, in order to
-show how my own <samp><span class="command">awk</span></samp> programming
style has evolved and to
-provide some basis for this discussion.</p>
-
- <p class="footnote"><small>[<a name="fn-55" href="#fnd-55">55</a>]</small>
<samp><span class="command">gawk</span></samp>'s <samp><span
class="option">--dump-variables</span></samp> command-line
-option is useful for verifying this.</p>
-
- <p class="footnote"><small>[<a name="fn-56" href="#fnd-56">56</a>]</small>
<a
href="http://mathworld.wolfram.com/CliffRandomNumberGenerator.hmtl">http://mathworld.wolfram.com/CliffRandomNumberGenerator.hmtl</a></p>
-
- <p class="footnote"><small>[<a name="fn-57" href="#fnd-57">57</a>]</small>
ASCII
-has been extended in many countries to use the values from 128 to 255
-for country-specific characters. If your system uses these extensions,
-you can simplify <code>_ord_init</code> to simply loop from 0 to 255.</p>
-
- <p class="footnote"><small>[<a name="fn-58" href="#fnd-58">58</a>]</small>
It would
-be nice if <samp><span class="command">awk</span></samp> had an assignment
operator for concatenation.
-The lack of an explicit operator for concatenation makes string operations
-more difficult than they really need to be.</p>
-
- <p class="footnote"><small>[<a name="fn-59" href="#fnd-59">59</a>]</small>
This
-function was written before <samp><span class="command">gawk</span></samp>
acquired the ability to
-split strings into single characters using <code>""</code> as the separator.
-We have left it alone, since using <code>substr</code> is more portable.</p>
-
- <p class="footnote"><small>[<a name="fn-60" href="#fnd-60">60</a>]</small>
It is often the case that password
-information is stored in a network database.</p>
-
- <p class="footnote"><small>[<a name="fn-61" href="#fnd-61">61</a>]</small>
It
-also introduces a subtle bug;
-if a match happens, we output the translated line, not the original.</p>
-
- <p class="footnote"><small>[<a name="fn-62" href="#fnd-62">62</a>]</small>
<samp><span class="command">wc</span></samp> can't just use the value of
-<code>FNR</code> in <code>endfile</code>. If you examine
-the code in
-<a href="#Filetrans-Function">Filetrans Function</a>,
-you will see that
-<code>FNR</code> has already been reset by the time
-<code>endfile</code> is called.</p>
-
- <p class="footnote"><small>[<a name="fn-63" href="#fnd-63">63</a>]</small>
On some older
-System V systems,
-<samp><span class="command">tr</span></samp> may require that the lists be
written as
-range expressions enclosed in square brackets (`<samp><span
class="samp">[a-z]</span></samp>') and quoted,
-to prevent the shell from attempting a file name expansion. This is
-not a feature.</p>
-
- <p class="footnote"><small>[<a name="fn-64" href="#fnd-64">64</a>]</small>
This
-program was written before <samp><span class="command">gawk</span></samp>
acquired the ability to
-split each character in a string into separate array elements.</p>
-
- <p class="footnote"><small>[<a name="fn-65" href="#fnd-65">65</a>]</small>
“Real world” is defined as
-“a program actually used to get something done.”</p>
-
- <p class="footnote"><small>[<a name="fn-66" href="#fnd-66">66</a>]</small>
Fully explaining the <samp><span class="command">sh</span></samp> language is
beyond
-the scope of this book. We provide some minimal explanations, but see
-a good shell programming book if you wish to understand things in more
-depth.</p>
-
- <p class="footnote"><small>[<a name="fn-67" href="#fnd-67">67</a>]</small>
On some very old versions of <samp><span class="command">awk</span></samp>, the
test
-`<samp><span class="samp">getline junk < t</span></samp>' can loop forever
if the file exists but is empty.
-Caveat emptor.</p>
-
- <p class="footnote"><small>[<a name="fn-68" href="#fnd-68">68</a>]</small>
<a href="http://www.cygwin.com">http://www.cygwin.com</a></p>
-
- <p class="footnote"><small>[<a name="fn-69" href="#fnd-69">69</a>]</small>
<a
href="http://cm.bell-labs.com/who/bwk">http://cm.bell-labs.com/who/bwk</a></p>
-
- <p class="footnote"><small>[<a name="fn-70" href="#fnd-70">70</a>]</small>
This version is edited
-slightly for presentation. The complete version can be found in
-<samp><span class="file">extension/filefuncs.c</span></samp> in the
<samp><span class="command">gawk</span></samp> distribution.</p>
-
- <p class="footnote"><small>[<a name="fn-71" href="#fnd-71">71</a>]</small>
Compiled programs are typically written
-in lower-level languages such as C, C++, Fortran, or Ada,
-and then translated, or <dfn>compiled</dfn>, into a form that
-the computer can execute directly.</p>
-
- <p class="footnote"><small>[<a name="fn-72" href="#fnd-72">72</a>]</small>
<a
href="http://www.validlab.com/goldberg/paper.ps">http://www.validlab.com/goldberg/paper.ps</a>.</p>
-
- <p class="footnote"><small>[<a name="fn-73" href="#fnd-73">73</a>]</small>
Pathological cases can require up to
-752 digits (!), but we doubt that you need to worry about this.</p>
-
- <p><hr></div>
-
-</body></html>
-
Index: manual/gawk.html.gz
===================================================================
RCS file: manual/gawk.html.gz
diff -N manual/gawk.html.gz
Binary files /tmp/cvsPlbOpr and /dev/null differ
Index: manual/gawk.html_node.tar.gz
===================================================================
RCS file: manual/gawk.html_node.tar.gz
diff -N manual/gawk.html_node.tar.gz
Binary files /tmp/cvsjtRDft and /dev/null differ
Index: manual/gawk.info.tar.gz
===================================================================
RCS file: manual/gawk.info.tar.gz
diff -N manual/gawk.info.tar.gz
Binary files /tmp/cvs1lQUhz and /dev/null differ
Index: manual/gawk.pdf
===================================================================
RCS file: manual/gawk.pdf
diff -N manual/gawk.pdf
Binary files /tmp/cvs2LgAhA and /dev/null differ
Index: manual/gawk.ps.gz
===================================================================
RCS file: manual/gawk.ps.gz
diff -N manual/gawk.ps.gz
Binary files /tmp/cvsDk3OUI and /dev/null differ
Index: manual/gawk.texi.tar.gz
===================================================================
RCS file: manual/gawk.texi.tar.gz
diff -N manual/gawk.texi.tar.gz
Binary files /tmp/cvs6oWPEO and /dev/null differ
Index: manual/gawk.txt
===================================================================
RCS file: manual/gawk.txt
diff -N manual/gawk.txt
--- manual/gawk.txt 29 Jun 2005 21:04:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,22004 +0,0 @@
-General Introduction
-********************
-
-This file documents `awk', a program that you can use to select
-particular records in a file and perform operations upon them.
-
- Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003 Free Software Foundation, Inc.
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's
-Guide for GNU Awk', for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being "GNU General Public License", the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-"GNU Free Documentation License".
-
- a. "A GNU Manual"
-
- b. "You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development."
-
- To Miriam, for making me complete.
-
- To Chana, for the joy you bring us.
-
- To Rivka, for the exponential increase.
-
- To Nachum, for the added dimension.
-
- To Malka, for the new beginning.
-Short Contents
-**************
-
-General Introduction
-Foreword
-Preface
-1 Getting Started with `awk'
-2 Regular Expressions
-3 Reading Input Files
-4 Printing Output
-5 Expressions
-6 Patterns, Actions, and Variables
-7 Arrays in `awk'
-8 Functions
-9 Internationalization with `gawk'
-10 Advanced Features of `gawk'
-11 Running `awk' and `gawk'
-12 A Library of `awk' Functions
-13 Practical `awk' Programs
-Appendix A The Evolution of the `awk' Language
-Appendix B Installing `gawk'
-Appendix C Implementation Notes
-Appendix D Basic Programming Concepts
-Glossary
-GNU General Public License
-GNU Free Documentation License
-Index
-
-
-Table of Contents
-*****************
-
-General Introduction
-Foreword
-Preface
- History of `awk' and `gawk'
- A Rose by Any Other Name
- Using This Book
- Typographical Conventions
- The GNU Project and This Book
- How to Contribute
- Acknowledgments
-1 Getting Started with `awk'
- 1.1 How to Run `awk' Programs
- 1.1.1 One-Shot Throwaway `awk' Programs
- 1.1.2 Running `awk' Without Input Files
- 1.1.3 Running Long Programs
- 1.1.4 Executable `awk' Programs
- 1.1.5 Comments in `awk' Programs
- 1.1.6 Shell-Quoting Issues
- 1.2 Data Files for the Examples
- 1.3 Some Simple Examples
- 1.4 An Example with Two Rules
- 1.5 A More Complex Example
- 1.6 `awk' Statements Versus Lines
- 1.7 Other Features of `awk'
- 1.8 When to Use `awk'
-2 Regular Expressions
- 2.1 How to Use Regular Expressions
- 2.2 Escape Sequences
- 2.3 Regular Expression Operators
- 2.4 Using Character Lists
- 2.5 `gawk'-Specific Regexp Operators
- 2.6 Case Sensitivity in Matching
- 2.7 How Much Text Matches?
- 2.8 Using Dynamic Regexps
- 2.9 Where You Are Makes A Difference
-3 Reading Input Files
- 3.1 How Input Is Split into Records
- 3.2 Examining Fields
- 3.3 Nonconstant Field Numbers
- 3.4 Changing the Contents of a Field
- 3.5 Specifying How Fields Are Separated
- 3.5.1 Using Regular Expressions to Separate Fields
- 3.5.2 Making Each Character a Separate Field
- 3.5.3 Setting `FS' from the Command Line
- 3.5.4 Field-Splitting Summary
- 3.6 Reading Fixed-Width Data
- 3.7 Multiple-Line Records
- 3.8 Explicit Input with `getline'
- 3.8.1 Using `getline' with No Arguments
- 3.8.2 Using `getline' into a Variable
- 3.8.3 Using `getline' from a File
- 3.8.4 Using `getline' into a Variable from a File
- 3.8.5 Using `getline' from a Pipe
- 3.8.6 Using `getline' into a Variable from a Pipe
- 3.8.7 Using `getline' from a Coprocess
- 3.8.8 Using `getline' into a Variable from a Coprocess
- 3.8.9 Points to Remember About `getline'
- 3.8.10 Summary of `getline' Variants
-4 Printing Output
- 4.1 The `print' Statement
- 4.2 Examples of `print' Statements
- 4.3 Output Separators
- 4.4 Controlling Numeric Output with `print'
- 4.5 Using `printf' Statements for Fancier Printing
- 4.5.1 Introduction to the `printf' Statement
- 4.5.2 Format-Control Letters
- 4.5.3 Modifiers for `printf' Formats
- 4.5.4 Examples Using `printf'
- 4.6 Redirecting Output of `print' and `printf'
- 4.7 Special File Names in `gawk'
- 4.7.1 Special Files for Standard Descriptors
- 4.7.2 Special Files for Process-Related Information
- 4.7.3 Special Files for Network Communications
- 4.7.4 Special File Name Caveats
- 4.8 Closing Input and Output Redirections
-5 Expressions
- 5.1 Constant Expressions
- 5.1.1 Numeric and String Constants
- 5.1.2 Octal and Hexadecimal Numbers
- 5.1.3 Regular Expression Constants
- 5.2 Using Regular Expression Constants
- 5.3 Variables
- 5.3.1 Using Variables in a Program
- 5.3.2 Assigning Variables on the Command Line
- 5.4 Conversion of Strings and Numbers
- 5.5 Arithmetic Operators
- 5.6 String Concatenation
- 5.7 Assignment Expressions
- 5.8 Increment and Decrement Operators
- 5.9 True and False in `awk'
- 5.10 Variable Typing and Comparison Expressions
- 5.11 Boolean Expressions
- 5.12 Conditional Expressions
- 5.13 Function Calls
- 5.14 Operator Precedence (How Operators Nest)
-6 Patterns, Actions, and Variables
- 6.1 Pattern Elements
- 6.1.1 Regular Expressions as Patterns
- 6.1.2 Expressions as Patterns
- 6.1.3 Specifying Record Ranges with Patterns
- 6.1.4 The `BEGIN' and `END' Special Patterns
- 6.1.4.1 Startup and Cleanup Actions
- 6.1.4.2 Input/Output from `BEGIN' and `END' Rules
- 6.1.5 The Empty Pattern
- 6.2 Using Shell Variables in Programs
- 6.3 Actions
- 6.4 Control Statements in Actions
- 6.4.1 The `if'-`else' Statement
- 6.4.2 The `while' Statement
- 6.4.3 The `do'-`while' Statement
- 6.4.4 The `for' Statement
- 6.4.5 The `switch' Statement
- 6.4.6 The `break' Statement
- 6.4.7 The `continue' Statement
- 6.4.8 The `next' Statement
- 6.4.9 Using `gawk''s `nextfile' Statement
- 6.4.10 The `exit' Statement
- 6.5 Built-in Variables
- 6.5.1 Built-in Variables That Control `awk'
- 6.5.2 Built-in Variables That Convey Information
- 6.5.3 Using `ARGC' and `ARGV'
-7 Arrays in `awk'
- 7.1 Introduction to Arrays
- 7.2 Referring to an Array Element
- 7.3 Assigning Array Elements
- 7.4 Basic Array Example
- 7.5 Scanning All Elements of an Array
- 7.6 The `delete' Statement
- 7.7 Using Numbers to Subscript Arrays
- 7.8 Using Uninitialized Variables as Subscripts
- 7.9 Multidimensional Arrays
- 7.10 Scanning Multidimensional Arrays
- 7.11 Sorting Array Values and Indices with `gawk'
-8 Functions
- 8.1 Built-in Functions
- 8.1.1 Calling Built-in Functions
- 8.1.2 Numeric Functions
- 8.1.3 String-Manipulation Functions
- 8.1.3.1 More About `\' and `&' with `sub', `gsub', and `gensub'
- 8.1.4 Input/Output Functions
- 8.1.5 Using `gawk''s Timestamp Functions
- 8.1.6 Bit-Manipulation Functions of `gawk'
- 8.1.7 Using `gawk''s String-Translation Functions
- 8.2 User-Defined Functions
- 8.2.1 Function Definition Syntax
- 8.2.2 Function Definition Examples
- 8.2.3 Calling User-Defined Functions
- 8.2.4 The `return' Statement
- 8.2.5 Functions and Their Effects on Variable Typing
-9 Internationalization with `gawk'
- 9.1 Internationalization and Localization
- 9.2 GNU `gettext'
- 9.3 Internationalizing `awk' Programs
- 9.4 Translating `awk' Programs
- 9.4.1 Extracting Marked Strings
- 9.4.2 Rearranging `printf' Arguments
- 9.4.3 `awk' Portability Issues
- 9.5 A Simple Internationalization Example
- 9.6 `gawk' Can Speak Your Language
-10 Advanced Features of `gawk'
- 10.1 Allowing Nondecimal Input Data
- 10.2 Two-Way Communications with Another Process
- 10.3 Using `gawk' for Network Programming
- 10.4 Using `gawk' with BSD Portals
- 10.5 Profiling Your `awk' Programs
-11 Running `awk' and `gawk'
- 11.1 Invoking `awk'
- 11.2 Command-Line Options
- 11.3 Other Command-Line Arguments
- 11.4 The `AWKPATH' Environment Variable
- 11.5 Obsolete Options and/or Features
- 11.6 Undocumented Options and Features
- 11.7 Known Bugs in `gawk'
-12 A Library of `awk' Functions
- 12.1 Naming Library Function Global Variables
- 12.2 General Programming
- 12.2.1 Implementing `nextfile' as a Function
- 12.2.2 Converting Strings To Numbers
- 12.2.3 Assertions
- 12.2.4 Rounding Numbers
- 12.2.5 The Cliff Random Number Generator
- 12.2.6 Translating Between Characters and Numbers
- 12.2.7 Merging an Array into a String
- 12.2.8 Managing the Time of Day
- 12.3 Data File Management
- 12.3.1 Noting Data File Boundaries
- 12.3.2 Rereading the Current File
- 12.3.3 Checking for Readable Data Files
- 12.3.4 Checking For Zero-length Files
- 12.3.5 Treating Assignments as File Names
- 12.4 Processing Command-Line Options
- 12.5 Reading the User Database
- 12.6 Reading the Group Database
-13 Practical `awk' Programs
- 13.1 Running the Example Programs
- 13.2 Reinventing Wheels for Fun and Profit
- 13.2.1 Cutting out Fields and Columns
- 13.2.2 Searching for Regular Expressions in Files
- 13.2.3 Printing out User Information
- 13.2.4 Splitting a Large File into Pieces
- 13.2.5 Duplicating Output into Multiple Files
- 13.2.6 Printing Nonduplicated Lines of Text
- 13.2.7 Counting Things
- 13.3 A Grab Bag of `awk' Programs
- 13.3.1 Finding Duplicated Words in a Document
- 13.3.2 An Alarm Clock Program
- 13.3.3 Transliterating Characters
- 13.3.4 Printing Mailing Labels
- 13.3.5 Generating Word-Usage Counts
- 13.3.6 Removing Duplicates from Unsorted Text
- 13.3.7 Extracting Programs from Texinfo Source Files
- 13.3.8 A Simple Stream Editor
- 13.3.9 An Easy Way to Use Library Functions
-Appendix A The Evolution of the `awk' Language
- A.1 Major Changes Between V7 and SVR3.1
- A.2 Changes Between SVR3.1 and SVR4
- A.3 Changes Between SVR4 and POSIX `awk'
- A.4 Extensions in the Bell Laboratories `awk'
- A.5 Extensions in `gawk' Not in POSIX `awk'
- A.6 Major Contributors to `gawk'
-Appendix B Installing `gawk'
- B.1 The `gawk' Distribution
- B.1.1 Getting the `gawk' Distribution
- B.1.2 Extracting the Distribution
- B.1.3 Contents of the `gawk' Distribution
- B.2 Compiling and Installing `gawk' on Unix
- B.2.1 Compiling `gawk' for Unix
- B.2.2 Additional Configuration Options
- B.2.3 The Configuration Process
- B.3 Installation on Other Operating Systems
- B.3.1 Installing `gawk' on an Amiga
- B.3.2 Installing `gawk' on BeOS
- B.3.3 Installation on PC Operating Systems
- B.3.3.1 Installing a Prepared Distribution for PC Systems
- B.3.3.2 Compiling `gawk' for PC Operating Systems
- B.3.3.3 Compiling `gawk' For Dynamic Libraries
- B.3.3.4 Using `gawk' on PC Operating Systems
- B.3.3.5 Using `gawk' In The Cygwin Environment
- B.3.4 How to Compile and Install `gawk' on VMS
- B.3.4.1 Compiling `gawk' on VMS
- B.3.4.2 Installing `gawk' on VMS
- B.3.4.3 Running `gawk' on VMS
- B.3.4.4 Building and Using `gawk' on VMS POSIX
- B.4 Unsupported Operating System Ports
- B.4.1 Installing `gawk' on the Atari ST
- B.4.1.1 Compiling `gawk' on the Atari ST
- B.4.1.2 Running `gawk' on the Atari ST
- B.4.2 Installing `gawk' on a Tandem
- B.5 Reporting Problems and Bugs
- B.6 Other Freely Available `awk' Implementations
-Appendix C Implementation Notes
- C.1 Downward Compatibility and Debugging
- C.2 Making Additions to `gawk'
- C.2.1 Adding New Features
- C.2.2 Porting `gawk' to a New Operating System
- C.3 Adding New Built-in Functions to `gawk'
- C.3.1 A Minimal Introduction to `gawk' Internals
- C.3.2 Directory and File Operation Built-ins
- C.3.2.1 Using `chdir' and `stat'
- C.3.2.2 C Code for `chdir' and `stat'
- C.3.2.3 Integrating the Extensions
- C.4 Probable Future Extensions
-Appendix D Basic Programming Concepts
- D.1 What a Program Does
- D.2 Data Values in a Computer
- D.3 Floating-Point Number Caveats
-Glossary
-GNU General Public License
- Preamble
- How to Apply These Terms to Your New Programs
-GNU Free Documentation License
- ADDENDUM: How to use this License for your documents
-Index
-
-
-Foreword
-********
-
-Arnold Robbins and I are good friends. We were introduced 11 years ago
-by circumstances--and our favorite programming language, AWK. The
-circumstances started a couple of years earlier. I was working at a new
-job and noticed an unplugged Unix computer sitting in the corner. No
-one knew how to use it, and neither did I. However, a couple of days
-later it was running, and I was `root' and the one-and-only user. That
-day, I began the transition from statistician to Unix programmer.
-
- On one of many trips to the library or bookstore in search of books
-on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and
-Weinberger, `The AWK Programming Language', Addison-Wesley, 1988.
-AWK's simple programming paradigm--find a pattern in the input and then
-perform an action--often reduced complex or tedious data manipulations
-to few lines of code. I was excited to try my hand at programming in
-AWK.
-
- Alas, the `awk' on my computer was a limited version of the
-language described in the AWK book. I discovered that my computer had
-"old `awk'" and the AWK book described "new `awk'." I learned that
-this was typical; the old version refused to step aside or relinquish
-its name. If a system had a new `awk', it was invariably called
-`nawk', and few systems had it. The best way to get a new `awk' was to
-`ftp' the source code for `gawk' from `prep.ai.mit.edu'. `gawk' was a
-version of new `awk' written by David Trueman and Arnold, and available
-under the GNU General Public License.
-
- (Incidentally, it's no longer difficult to find a new `awk'. `gawk'
-ships with Linux, and you can download binaries or source code for
-almost any system; my wife uses `gawk' on her VMS box.)
-
- My Unix system started out unplugged from the wall; it certainly was
-not plugged into a network. So, oblivious to the existence of `gawk'
-and the Unix community in general, and desiring a new `awk', I wrote my
-own, called `mawk'. Before I was finished I knew about `gawk', but it
-was too late to stop, so I eventually posted to a `comp.sources'
-newsgroup.
-
- A few days after my posting, I got a friendly email from Arnold
-introducing himself. He suggested we share design and algorithms and
-attached a draft of the POSIX standard so that I could update `mawk' to
-support language extensions added after publication of the AWK book.
-
- Frankly, if our roles had been reversed, I would not have been so
-open and we probably would have never met. I'm glad we did meet. He
-is an AWK expert's AWK expert and a genuinely nice person. Arnold
-contributes significant amounts of his expertise and time to the Free
-Software Foundation.
-
- This book is the `gawk' reference manual, but at its core it is a
-book about AWK programming that will appeal to a wide audience. It is
-a definitive reference to the AWK language as defined by the 1987 Bell
-Labs release and codified in the 1992 POSIX Utilities standard.
-
- On the other hand, the novice AWK programmer can study a wealth of
-practical programs that emphasize the power of AWK's basic idioms: data
-driven control-flow, pattern matching with regular expressions, and
-associative arrays. Those looking for something new can try out
-`gawk''s interface to network protocols via special `/inet' files.
-
- The programs in this book make clear that an AWK program is
-typically much smaller and faster to develop than a counterpart written
-in C. Consequently, there is often a payoff to prototype an algorithm
-or design in AWK to get it running quickly and expose problems early.
-Often, the interpreted performance is adequate and the AWK prototype
-becomes the product.
-
- The new `pgawk' (profiling `gawk'), produces program execution
-counts. I recently experimented with an algorithm that for n lines of
-input, exhibited ~ C n^2 performance, while theory predicted ~ C n log n
-behavior. A few minutes poring over the `awkprof.out' profile
-pinpointed the problem to a single line of code. `pgawk' is a welcome
-addition to my programmer's toolbox.
-
- Arnold has distilled over a decade of experience writing and using
-AWK programs, and developing `gawk', into this book. If you use AWK or
-want to learn how, then read this book.
-
- Michael Brennan
- Author of `mawk'
-
-Preface
-*******
-
-Several kinds of tasks occur repeatedly when working with text files.
-You might want to extract certain lines and discard the rest. Or you
-may need to make changes wherever certain patterns appear, but leave
-the rest of the file alone. Writing single-use programs for these
-tasks in languages such as C, C++, or Pascal is time-consuming and
-inconvenient. Such jobs are often easier with `awk'. The `awk'
-utility interprets a special-purpose programming language that makes it
-easy to handle simple data-reformatting jobs.
-
- The GNU implementation of `awk' is called `gawk'; it is fully
-compatible with the System V Release 4 version of `awk'. `gawk' is
-also compatible with the POSIX specification of the `awk' language.
-This means that all properly written `awk' programs should work with
-`gawk'. Thus, we usually don't distinguish between `gawk' and other
-`awk' implementations.
-
- Using `awk' allows you to:
-
- * Manage small, personal databases
-
- * Generate reports
-
- * Validate data
-
- * Produce indexes and perform other document preparation tasks
-
- * Experiment with algorithms that you can adapt later to other
- computer languages
-
- In addition, `gawk' provides facilities that make it easy to:
-
- * Extract bits and pieces of data for processing
-
- * Sort data
-
- * Perform simple network communications
-
- This Info file teaches you about the `awk' language and how you can
-use it effectively. You should already be familiar with basic system
-commands, such as `cat' and `ls',(1) as well as basic shell facilities,
-such as input/output (I/O) redirection and pipes.
-
- Implementations of the `awk' language are available for many
-different computing environments. This Info file, while describing the
-`awk' language in general, also describes the particular implementation
-of `awk' called `gawk' (which stands for "GNU awk"). `gawk' runs on a
-broad range of Unix systems, ranging from 80386 PC-based computers up
-through large-scale systems, such as Crays. `gawk' has also been ported
-to Mac OS X, MS-DOS, Microsoft Windows (all versions) and OS/2 PCs,
-Atari and Amiga microcomputers, BeOS, Tandem D20, and VMS.
-
- ---------- Footnotes ----------
-
- (1) These commands are available on POSIX-compliant systems, as well
-as on traditional Unix-based systems. If you are using some other
-operating system, you still need to be familiar with the ideas of I/O
-redirection and pipes.
-
-History of `awk' and `gawk'
-===========================
-
- Recipe For A Programming Language
-
- 1 part `egrep' 1 part `snobol'
- 2 parts `ed' 3 parts C
-
- Blend all parts well using `lex' and `yacc'. Document minimally
- and release.
-
- After eight years, add another part `egrep' and two more parts C.
- Document very well and release.
-
- The name `awk' comes from the initials of its designers: Alfred V.
-Aho, Peter J. Weinberger and Brian W. Kernighan. The original version
-of `awk' was written in 1977 at AT&T Bell Laboratories. In 1985, a new
-version made the programming language more powerful, introducing
-user-defined functions, multiple input streams, and computed regular
-expressions. This new version became widely available with Unix System
-V Release 3.1 (SVR3.1). The version in SVR4 added some new features
-and cleaned up the behavior in some of the "dark corners" of the
-language. The specification for `awk' in the POSIX Command Language
-and Utilities standard further clarified the language. Both the `gawk'
-designers and the original Bell Laboratories `awk' designers provided
-feedback for the POSIX specification.
-
- Paul Rubin wrote the GNU implementation, `gawk', in 1986. Jay
-Fenlason completed it, with advice from Richard Stallman. John Woods
-contributed parts of the code as well. In 1988 and 1989, David
-Trueman, with help from me, thoroughly reworked `gawk' for compatibility
-with the newer `awk'. Circa 1995, I became the primary maintainer.
-Current development focuses on bug fixes, performance improvements,
-standards compliance, and occasionally, new features.
-
- In May of 1997, Ju"rgen Kahrs felt the need for network access from
-`awk', and with a little help from me, set about adding features to do
-this for `gawk'. At that time, he also wrote the bulk of `TCP/IP
-Internetworking with `gawk'' (a separate document, available as part of
-the `gawk' distribution). His code finally became part of the main
-`gawk' distribution with `gawk' version 3.1.
-
- *Note Contributors::, for a complete list of those who made
-important contributions to `gawk'.
-
-A Rose by Any Other Name
-========================
-
-The `awk' language has evolved over the years. Full details are
-provided in *Note Language History::. The language described in this
-Info file is often referred to as "new `awk'" (`nawk').
-
- Because of this, many systems have multiple versions of `awk'. Some
-systems have an `awk' utility that implements the original version of
-the `awk' language and a `nawk' utility for the new version. Others
-have an `oawk' version for the "old `awk'" language and plain `awk' for
-the new one. Still others only have one version, which is usually the
-new one.(1)
-
- All in all, this makes it difficult for you to know which version of
-`awk' you should run when writing your programs. The best advice I can
-give here is to check your local documentation. Look for `awk', `oawk',
-and `nawk', as well as for `gawk'. It is likely that you already have
-some version of new `awk' on your system, which is what you should use
-when running your programs. (Of course, if you're reading this Info
-file, chances are good that you have `gawk'!)
-
- Throughout this Info file, whenever we refer to a language feature
-that should be available in any complete implementation of POSIX `awk',
-we simply use the term `awk'. When referring to a feature that is
-specific to the GNU implementation, we use the term `gawk'.
-
- ---------- Footnotes ----------
-
- (1) Often, these systems use `gawk' for their `awk' implementation!
-
-Using This Book
-===============
-
-The term `awk' refers to a particular program as well as to the
-language you use to tell this program what to do. When we need to be
-careful, we call the language "the `awk' language," and the program
-"the `awk' utility." This Info file explains both the `awk' language
-and how to run the `awk' utility. The term "`awk' program" refers to a
-program written by you in the `awk' programming language.
-
- Primarily, this Info file explains the features of `awk', as defined
-in the POSIX standard. It does so in the context of the `gawk'
-implementation. While doing so, it also attempts to describe important
-differences between `gawk' and other `awk' implementations.(1) Finally,
-any `gawk' features that are not in the POSIX standard for `awk' are
-noted.
-
- There are subsections labelled as *Advanced Notes* scattered
-throughout the Info file. They add a more complete explanation of
-points that are relevant, but not likely to be of interest on first
-reading. All appear in the index, under the heading "advanced
-features."
-
- Most of the time, the examples use complete `awk' programs. In some
-of the more advanced sections, only the part of the `awk' program that
-illustrates the concept currently being described is shown.
-
- While this Info file is aimed principally at people who have not been
-exposed to `awk', there is a lot of information here that even the `awk'
-expert should find useful. In particular, the description of POSIX
-`awk' and the example programs in *Note Library Functions::, and in
-*Note Sample Programs::, should be of interest.
-
- *Note Getting Started::, provides the essentials you need to know to
-begin using `awk'.
-
- *Note Regexp::, introduces regular expressions in general, and in
-particular the flavors supported by POSIX `awk' and `gawk'.
-
- *Note Reading Files::, describes how `awk' reads your data. It
-introduces the concepts of records and fields, as well as the `getline'
-command. I/O redirection is first described here.
-
- *Note Printing::, describes how `awk' programs can produce output
-with `print' and `printf'.
-
- *Note Expressions::, describes expressions, which are the basic
-building blocks for getting most things done in a program.
-
- *Note Patterns and Actions::, describes how to write patterns for
-matching records, actions for doing something when a record is matched,
-and the built-in variables `awk' and `gawk' use.
-
- *Note Arrays::, covers `awk''s one-and-only data structure:
-associative arrays. Deleting array elements and whole arrays is also
-described, as well as sorting arrays in `gawk'.
-
- *Note Functions::, describes the built-in functions `awk' and `gawk'
-provide, as well as how to define your own functions.
-
- *Note Internationalization::, describes special features in `gawk'
-for translating program messages into different languages at runtime.
-
- *Note Advanced Features::, describes a number of `gawk'-specific
-advanced features. Of particular note are the abilities to have
-two-way communications with another process, perform TCP/IP networking,
-and profile your `awk' programs.
-
- *Note Invoking Gawk::, describes how to run `gawk', the meaning of
-its command-line options, and how it finds `awk' program source files.
-
- *Note Library Functions::, and *Note Sample Programs::, provide many
-sample `awk' programs. Reading them allows you to see `awk' solving
-real problems.
-
- *Note Language History::, describes how the `awk' language has
-evolved since first release to present. It also describes how `gawk'
-has acquired features over time.
-
- *Note Installation::, describes how to get `gawk', how to compile it
-under Unix, and how to compile and use it on different non-Unix
-systems. It also describes how to report bugs in `gawk' and where to
-get three other freely available implementations of `awk'.
-
- *Note Notes::, describes how to disable `gawk''s extensions, as well
-as how to contribute new code to `gawk', how to write extension
-libraries, and some possible future directions for `gawk' development.
-
- *Note Basic Concepts::, provides some very cursory background
-material for those who are completely unfamiliar with computer
-programming. Also centralized there is a discussion of some of the
-issues surrounding floating-point numbers.
-
- The *Note Glossary::, defines most, if not all, the significant
-terms used throughout the book. If you find terms that you aren't
-familiar with, try looking them up here.
-
- *Note Copying::, and *Note GNU Free Documentation License::, present
-the licenses that cover the `gawk' source code and this Info file,
-respectively.
-
- ---------- Footnotes ----------
-
- (1) All such differences appear in the index under the entry
-"differences in `awk' and `gawk'."
-
-Typographical Conventions
-=========================
-
-This Info file is written using Texinfo, the GNU documentation
-formatting language. A single Texinfo source file is used to produce
-both the printed and online versions of the documentation. This minor
-node briefly documents the typographical conventions used in Texinfo.
-
- Examples you would type at the command-line are preceded by the
-common shell primary and secondary prompts, `$' and `>'. Output from
-the command is preceded by the glyph "-|". This typically represents
-the command's standard output. Error messages, and other output on the
-command's standard error, are preceded by the glyph "error-->". For
-example:
-
- $ echo hi on stdout
- -| hi on stdout
- $ echo hello on stderr 1>&2
- error--> hello on stderr
-
- Characters that you type at the keyboard look `like this'. In
-particular, there are special characters called "control characters."
-These are characters that you type by holding down both the `CONTROL'
-key and another key, at the same time. For example, a `Ctrl-d' is typed
-by first pressing and holding the `CONTROL' key, next pressing the `d'
-key and finally releasing both keys.
-
-Dark Corners
-............
-
- Dark corners are basically fractal -- no matter how much you
- illuminate, there's always a smaller but darker one.
- Brian Kernighan
-
- Until the POSIX standard (and `The Gawk Manual'), many features of
-`awk' were either poorly documented or not documented at all.
-Descriptions of such features (often called "dark corners") are noted
-in this Info file with "(d.c.)". They also appear in the index under
-the heading "dark corner."
-
- As noted by the opening quote, though, any coverage of dark corners
-is, by definition, something that is incomplete.
-
-The GNU Project and This Book
-=============================
-
-The Free Software Foundation (FSF) is a nonprofit organization dedicated
-to the production and distribution of freely distributable software.
-It was founded by Richard M. Stallman, the author of the original Emacs
-editor. GNU Emacs is the most widely used version of Emacs today.
-
- The GNU(1) Project is an ongoing effort on the part of the Free
-Software Foundation to create a complete, freely distributable,
-POSIX-compliant computing environment. The FSF uses the "GNU General
-Public License" (GPL) to ensure that their software's source code is
-always available to the end user. A copy of the GPL is included for
-your reference (*note Copying::). The GPL applies to the C language
-source code for `gawk'. To find out more about the FSF and the GNU
-Project online, see the GNU Project's home page (http://www.gnu.org).
-This Info file may also be read from their web site
-(http://www.gnu.org/manual/gawk/).
-
- A shell, an editor (Emacs), highly portable optimizing C, C++, and
-Objective-C compilers, a symbolic debugger and dozens of large and
-small utilities (such as `gawk'), have all been completed and are
-freely available. The GNU operating system kernel (the HURD), has been
-released but is still in an early stage of development.
-
- Until the GNU operating system is more fully developed, you should
-consider using GNU/Linux, a freely distributable, Unix-like operating
-system for Intel 80386, DEC Alpha, Sun SPARC, IBM S/390, and other
-systems.(2) There are many books on GNU/Linux. One that is freely
-available is `Linux Installation and Getting Started', by Matt Welsh.
-Many GNU/Linux distributions are often available in computer stores or
-bundled on CD-ROMs with books about Linux. (There are three other
-freely available, Unix-like operating systems for 80386 and other
-systems: NetBSD, FreeBSD, and OpenBSD. All are based on the 4.4-Lite
-Berkeley Software Distribution, and they use recent versions of `gawk'
-for their versions of `awk'.)
-
- The Info file itself has gone through a number of previous editions.
-Paul Rubin wrote the very first draft of `The GAWK Manual'; it was
-around 40 pages in size. Diane Close and Richard Stallman improved it,
-yielding a version that was around 90 pages long and barely described
-the original, "old" version of `awk'.
-
- I started working with that version in the fall of 1988. As work on
-it progressed, the FSF published several preliminary versions (numbered
-0.X). In 1996, Edition 1.0 was released with `gawk' 3.0.0. The FSF
-published the first two editions under the title `The GNU Awk User's
-Guide'.
-
- This edition maintains the basic structure of Edition 1.0, but with
-significant additional material, reflecting the host of new features in
-`gawk' version 3.1. Of particular note is *Note Array Sorting::, as
-well as *Note Bitwise Functions::, *Note Internationalization::, and
-also *Note Advanced Features::, and *Note Dynamic Extensions::.
-
- `GAWK: Effective AWK Programming' will undoubtedly continue to
-evolve. An electronic version comes with the `gawk' distribution from
-the FSF. If you find an error in this Info file, please report it!
-*Note Bugs::, for information on submitting problem reports
-electronically, or write to me in care of the publisher.
-
- ---------- Footnotes ----------
-
- (1) GNU stands for "GNU's not Unix."
-
- (2) The terminology "GNU/Linux" is explained in the *Note Glossary::.
-
-How to Contribute
-=================
-
-As the maintainer of GNU `awk', I am starting a collection of publicly
-available `awk' programs. For more information, see
-`ftp://ftp.freefriends.org/arnold/Awkstuff'. If you have written an
-interesting `awk' program, or have written a `gawk' extension that you
-would like to share with the rest of the world, please contact me
-(<address@hidden>). Making things available on the Internet helps
-keep the `gawk' distribution down to manageable size.
-
-Acknowledgments
-===============
-
-The initial draft of `The GAWK Manual' had the following
-acknowledgments:
-
- Many people need to be thanked for their assistance in producing
- this manual. Jay Fenlason contributed many ideas and sample
- programs. Richard Mlynarik and Robert Chassell gave helpful
- comments on drafts of this manual. The paper `A Supplemental
- Document for `awk'' by John W. Pierce of the Chemistry Department
- at UC San Diego, pinpointed several issues relevant both to `awk'
- implementation and to this manual, that would otherwise have
- escaped us.
-
- I would like to acknowledge Richard M. Stallman, for his vision of a
-better world and for his courage in founding the FSF and starting the
-GNU Project.
-
- The following people (in alphabetical order) provided helpful
-comments on various versions of this book, up to and including this
-edition. Rick Adams, Nelson H.F. Beebe, Karl Berry, Dr. Michael
-Brennan, Rich Burridge, Claire Cloutier, Diane Close, Scott Deifik,
-Christopher ("Topher") Eliot, Jeffrey Friedl, Dr. Darrel Hankerson,
-Michal Jaegermann, Dr. Richard J. LeBlanc, Michael Lijewski, Pat Rankin,
-Miriam Robbins, Mary Sheehan, and Chuck Toporek.
-
- Robert J. Chassell provided much valuable advice on the use of
-Texinfo. He also deserves special thanks for convincing me _not_ to
-title this Info file `How To Gawk Politely'. Karl Berry helped
-significantly with the TeX part of Texinfo.
-
- I would like to thank Marshall and Elaine Hartholz of Seattle and
-Dr. Bert and Rita Schreiber of Detroit for large amounts of quiet
-vacation time in their homes, which allowed me to make significant
-progress on this Info file and on `gawk' itself.
-
- Phil Hughes of SSC contributed in a very important way by loaning me
-his laptop GNU/Linux system, not once, but twice, which allowed me to
-do a lot of work while away from home.
-
- David Trueman deserves special credit; he has done a yeoman job of
-evolving `gawk' so that it performs well and without bugs. Although he
-is no longer involved with `gawk', working with him on this project was
-a significant pleasure.
-
- The intrepid members of the GNITS mailing list, and most notably
-Ulrich Drepper, provided invaluable help and feedback for the design of
-the internationalization features.
-
- Nelson Beebe, Martin Brown, Andreas Buening, Scott Deifik, Darrel
-Hankerson, Isamu Hasegawa, Michal Jaegermann, Ju"rgen Kahrs, Pat Rankin,
-Kai Uwe Rommel, and Eli Zaretskii (in alphabetical order) make up the
-`gawk' "crack portability team." Without their hard work and help,
-`gawk' would not be nearly the fine program it is today. It has been
-and continues to be a pleasure working with this team of fine people.
-
- David and I would like to thank Brian Kernighan of Bell Laboratories
-for invaluable assistance during the testing and debugging of `gawk',
-and for help in clarifying numerous points about the language. We
-could not have done nearly as good a job on either `gawk' or its
-documentation without his help.
-
- Chuck Toporek, Mary Sheehan, and Claire Coutier of O'Reilly &
-Associates contributed significant editorial help for this Info file
-for the 3.1 release of `gawk'.
-
- I must thank my wonderful wife, Miriam, for her patience through the
-many versions of this project, for her proofreading, and for sharing me
-with the computer. I would like to thank my parents for their love,
-and for the grace with which they raised and educated me. Finally, I
-also must acknowledge my gratitude to G-d, for the many opportunities
-He has sent my way, as well as for the gifts He has given me with which
-to take advantage of those opportunities.
-
-
-Arnold Robbins
-Nof Ayalon
-ISRAEL
-March, 2001
-
-1 Getting Started with `awk'
-****************************
-
-The basic function of `awk' is to search files for lines (or other
-units of text) that contain certain patterns. When a line matches one
-of the patterns, `awk' performs specified actions on that line. `awk'
-keeps processing input lines in this way until it reaches the end of
-the input files.
-
- Programs in `awk' are different from programs in most other
-languages, because `awk' programs are "data-driven"; that is, you
-describe the data you want to work with and then what to do when you
-find it. Most other languages are "procedural"; you have to describe,
-in great detail, every step the program is to take. When working with
-procedural languages, it is usually much harder to clearly describe the
-data your program will process. For this reason, `awk' programs are
-often refreshingly easy to read and write.
-
- When you run `awk', you specify an `awk' "program" that tells `awk'
-what to do. The program consists of a series of "rules". (It may also
-contain "function definitions", an advanced feature that we will ignore
-for now. *Note User-defined::.) Each rule specifies one pattern to
-search for and one action to perform upon finding the pattern.
-
- Syntactically, a rule consists of a pattern followed by an action.
-The action is enclosed in curly braces to separate it from the pattern.
-Newlines usually separate rules. Therefore, an `awk' program looks
-like this:
-
- PATTERN { ACTION }
- PATTERN { ACTION }
- ...
-
-1.1 How to Run `awk' Programs
-=============================
-
-There are several ways to run an `awk' program. If the program is
-short, it is easiest to include it in the command that runs `awk', like
-this:
-
- awk 'PROGRAM' INPUT-FILE1 INPUT-FILE2 ...
-
- When the program is long, it is usually more convenient to put it in
-a file and run it with a command like this:
-
- awk -f PROGRAM-FILE INPUT-FILE1 INPUT-FILE2 ...
-
- This minor node discusses both mechanisms, along with several
-variations of each.
-
-1.1.1 One-Shot Throwaway `awk' Programs
----------------------------------------
-
-Once you are familiar with `awk', you will often type in simple
-programs the moment you want to use them. Then you can write the
-program as the first argument of the `awk' command, like this:
-
- awk 'PROGRAM' INPUT-FILE1 INPUT-FILE2 ...
-
-where PROGRAM consists of a series of PATTERNS and ACTIONS, as
-described earlier.
-
- This command format instructs the "shell", or command interpreter,
-to start `awk' and use the PROGRAM to process records in the input
-file(s). There are single quotes around PROGRAM so the shell won't
-interpret any `awk' characters as special shell characters. The quotes
-also cause the shell to treat all of PROGRAM as a single argument for
-`awk', and allow PROGRAM to be more than one line long.
-
- This format is also useful for running short or medium-sized `awk'
-programs from shell scripts, because it avoids the need for a separate
-file for the `awk' program. A self-contained shell script is more
-reliable because there are no other files to misplace.
-
- *Note Very Simple::, presents several short, self-contained programs.
-
-1.1.2 Running `awk' Without Input Files
----------------------------------------
-
-You can also run `awk' without any input files. If you type the
-following command line:
-
- awk 'PROGRAM'
-
-`awk' applies the PROGRAM to the "standard input", which usually means
-whatever you type on the terminal. This continues until you indicate
-end-of-file by typing `Ctrl-d'. (On other operating systems, the
-end-of-file character may be different. For example, on OS/2 and
-MS-DOS, it is `Ctrl-z'.)
-
- As an example, the following program prints a friendly piece of
-advice (from Douglas Adams's `The Hitchhiker's Guide to the Galaxy'),
-to keep you from worrying about the complexities of computer programming
-(`BEGIN' is a feature we haven't discussed yet):
-
- $ awk "BEGIN { print \"Don't Panic!\" }"
- -| Don't Panic!
-
- This program does not read any input. The `\' before each of the
-inner double quotes is necessary because of the shell's quoting
-rules--in particular because it mixes both single quotes and double
-quotes.(1)
-
- This next simple `awk' program emulates the `cat' utility; it copies
-whatever you type on the keyboard to its standard output (why this
-works is explained shortly).
-
- $ awk '{ print }'
- Now is the time for all good men
- -| Now is the time for all good men
- to come to the aid of their country.
- -| to come to the aid of their country.
- Four score and seven years ago, ...
- -| Four score and seven years ago, ...
- What, me worry?
- -| What, me worry?
- Ctrl-d
-
- ---------- Footnotes ----------
-
- (1) Although we generally recommend the use of single quotes around
-the program text, double quotes are needed here in order to put the
-single quote into the message.
-
-1.1.3 Running Long Programs
----------------------------
-
-Sometimes your `awk' programs can be very long. In this case, it is
-more convenient to put the program into a separate file. In order to
-tell `awk' to use that file for its program, you type:
-
- awk -f SOURCE-FILE INPUT-FILE1 INPUT-FILE2 ...
-
- The `-f' instructs the `awk' utility to get the `awk' program from
-the file SOURCE-FILE. Any file name can be used for SOURCE-FILE. For
-example, you could put the program:
-
- BEGIN { print "Don't Panic!" }
-
-into the file `advice'. Then this command:
-
- awk -f advice
-
-does the same thing as this one:
-
- awk "BEGIN { print \"Don't Panic!\" }"
-
-This was explained earlier (*note Read Terminal::). Note that you
-don't usually need single quotes around the file name that you specify
-with `-f', because most file names don't contain any of the shell's
-special characters. Notice that in `advice', the `awk' program did not
-have single quotes around it. The quotes are only needed for programs
-that are provided on the `awk' command line.
-
- If you want to identify your `awk' program files clearly as such,
-you can add the extension `.awk' to the file name. This doesn't affect
-the execution of the `awk' program but it does make "housekeeping"
-easier.
-
-1.1.4 Executable `awk' Programs
--------------------------------
-
-Once you have learned `awk', you may want to write self-contained `awk'
-scripts, using the `#!' script mechanism. You can do this on many Unix
-systems(1) as well as on the GNU system. For example, you could update
-the file `advice' to look like this:
-
- #! /bin/awk -f
-
- BEGIN { print "Don't Panic!" }
-
-After making this file executable (with the `chmod' utility), simply
-type `advice' at the shell and the system arranges to run `awk'(2) as
-if you had typed `awk -f advice':
-
- $ chmod +x advice
- $ advice
- -| Don't Panic!
-
-(We assume you have the current directory in your shell's search path
-variable (typically `$PATH'). If not, you may need to type `./advice'
-at the shell.)
-
- Self-contained `awk' scripts are useful when you want to write a
-program that users can invoke without their having to know that the
-program is written in `awk'.
-
-Advanced Notes: Portability Issues with `#!'
---------------------------------------------
-
-Some systems limit the length of the interpreter name to 32 characters.
-Often, this can be dealt with by using a symbolic link.
-
- You should not put more than one argument on the `#!' line after the
-path to `awk'. It does not work. The operating system treats the rest
-of the line as a single argument and passes it to `awk'. Doing this
-leads to confusing behavior--most likely a usage diagnostic of some
-sort from `awk'.
-
- Finally, the value of `ARGV[0]' (*note Built-in Variables::) varies
-depending upon your operating system. Some systems put `awk' there,
-some put the full pathname of `awk' (such as `/bin/awk'), and some put
-the name of your script (`advice'). Don't rely on the value of
-`ARGV[0]' to provide your script name.
-
- ---------- Footnotes ----------
-
- (1) The `#!' mechanism works on Linux systems, systems derived from
-the 4.4-Lite Berkeley Software Distribution, and most commercial Unix
-systems.
-
- (2) The line beginning with `#!' lists the full file name of an
-interpreter to run and an optional initial command-line argument to
-pass to that interpreter. The operating system then runs the
-interpreter with the given argument and the full argument list of the
-executed program. The first argument in the list is the full file name
-of the `awk' program. The rest of the argument list contains either
-options to `awk', or data files, or both.
-
-1.1.5 Comments in `awk' Programs
---------------------------------
-
-A "comment" is some text that is included in a program for the sake of
-human readers; it is not really an executable part of the program.
-Comments can explain what the program does and how it works. Nearly all
-programming languages have provisions for comments, as programs are
-typically hard to understand without them.
-
- In the `awk' language, a comment starts with the sharp sign
-character (`#') and continues to the end of the line. The `#' does not
-have to be the first character on the line. The `awk' language ignores
-the rest of a line following a sharp sign. For example, we could have
-put the following into `advice':
-
- # This program prints a nice friendly message. It helps
- # keep novice users from being afraid of the computer.
- BEGIN { print "Don't Panic!" }
-
- You can put comment lines into keyboard-composed throwaway `awk'
-programs, but this usually isn't very useful; the purpose of a comment
-is to help you or another person understand the program when reading it
-at a later time.
-
- *Caution:* As mentioned in *Note One-shot::, you can enclose small
-to medium programs in single quotes, in order to keep your shell
-scripts self-contained. When doing so, _don't_ put an apostrophe
-(i.e., a single quote) into a comment (or anywhere else in your
-program). The shell interprets the quote as the closing quote for the
-entire program. As a result, usually the shell prints a message about
-mismatched quotes, and if `awk' actually runs, it will probably print
-strange messages about syntax errors. For example, look at the
-following:
-
- $ awk '{ print "hello" } # let's be cute'
- >
-
- The shell sees that the first two quotes match, and that a new
-quoted object begins at the end of the command line. It therefore
-prompts with the secondary prompt, waiting for more input. With Unix
-`awk', closing the quoted string produces this result:
-
- $ awk '{ print "hello" } # let's be cute'
- > '
- error--> awk: can't open file be
- error--> source line number 1
-
- Putting a backslash before the single quote in `let's' wouldn't help,
-since backslashes are not special inside single quotes. The next
-node describes the shell's quoting rules.
-
-1.1.6 Shell-Quoting Issues
---------------------------
-
-For short to medium length `awk' programs, it is most convenient to
-enter the program on the `awk' command line. This is best done by
-enclosing the entire program in single quotes. This is true whether
-you are entering the program interactively at the shell prompt, or
-writing it as part of a larger shell script:
-
- awk 'PROGRAM TEXT' INPUT-FILE1 INPUT-FILE2 ...
-
- Once you are working with the shell, it is helpful to have a basic
-knowledge of shell quoting rules. The following rules apply only to
-POSIX-compliant, Bourne-style shells (such as `bash', the GNU
-Bourne-Again Shell). If you use `csh', you're on your own.
-
- * Quoted items can be concatenated with nonquoted items as well as
- with other quoted items. The shell turns everything into one
- argument for the command.
-
- * Preceding any single character with a backslash (`\') quotes that
- character. The shell removes the backslash and passes the quoted
- character on to the command.
-
- * Single quotes protect everything between the opening and closing
- quotes. The shell does no interpretation of the quoted text,
- passing it on verbatim to the command. It is _impossible_ to
- embed a single quote inside single-quoted text. Refer back to
- *Note Comments::, for an example of what happens if you try.
-
- * Double quotes protect most things between the opening and closing
- quotes. The shell does at least variable and command substitution
- on the quoted text. Different shells may do additional kinds of
- processing on double-quoted text.
-
- Since certain characters within double-quoted text are processed
- by the shell, they must be "escaped" within the text. Of note are
- the characters `$', ``', `\', and `"', all of which must be
- preceded by a backslash within double-quoted text if they are to
- be passed on literally to the program. (The leading backslash is
- stripped first.) Thus, the example seen in *Note Read Terminal::,
- is applicable:
-
- $ awk "BEGIN { print \"Don't Panic!\" }"
- -| Don't Panic!
-
- Note that the single quote is not special within double quotes.
-
- * Null strings are removed when they occur as part of a non-null
- command-line argument, while explicit non-null objects are kept.
- For example, to specify that the field separator `FS' should be
- set to the null string, use:
-
- awk -F "" 'PROGRAM' FILES # correct
-
- Don't use this:
-
- awk -F"" 'PROGRAM' FILES # wrong!
-
- In the second case, `awk' will attempt to use the text of the
- program as the value of `FS', and the first file name as the text
- of the program! This results in syntax errors at best, and
- confusing behavior at worst.
-
- Mixing single and double quotes is difficult. You have to resort to
-shell quoting tricks, like this:
-
- $ awk 'BEGIN { print "Here is a single quote <'"'"'>" }'
- -| Here is a single quote <'>
-
-This program consists of three concatenated quoted strings. The first
-and the third are single-quoted, the second is double-quoted.
-
- This can be "simplified" to:
-
- $ awk 'BEGIN { print "Here is a single quote <'\''>" }'
- -| Here is a single quote <'>
-
-Judge for yourself which of these two is the more readable.
-
- Another option is to use double quotes, escaping the embedded,
-`awk'-level double quotes:
-
- $ awk "BEGIN { print \"Here is a single quote <'>\" }"
- -| Here is a single quote <'>
-
-This option is also painful, because double quotes, backslashes, and
-dollar signs are very common in `awk' programs.
-
- A third option is to use the octal escape sequence equivalents for
-the single- and double-quote characters, like so:
-
- $ awk 'BEGIN { print "Here is a single quote <\47>" }'
- -| Here is a single quote <'>
- $ awk 'BEGIN { print "Here is a double quote <\42>" }'
- -| Here is a double quote <">
-
-This works nicely, except that you should comment clearly what the
-escapes mean.
-
- A fourth option is to use command-line variable assignment, like
-this:
-
- $ awk -v sq="'" 'BEGIN { print "Here is a single quote <" sq ">" }'
- -| Here is a single quote <'>
-
- If you really need both single and double quotes in your `awk'
-program, it is probably best to move it into a separate file, where the
-shell won't be part of the picture, and you can say what you mean.
-
-1.2 Data Files for the Examples
-===============================
-
-Many of the examples in this Info file take their input from two sample
-data files. The first, `BBS-list', represents a list of computer
-bulletin board systems together with information about those systems.
-The second data file, called `inventory-shipped', contains information
-about monthly shipments. In both files, each line is considered to be
-one "record".
-
- In the data file `BBS-list', each record contains the name of a
-computer bulletin board, its phone number, the board's baud rate(s),
-and a code for the number of hours it is operational. An `A' in the
-last column means the board operates 24 hours a day. A `B' in the last
-column means the board only operates on evening and weekend hours. A
-`C' means the board operates only on weekends:
-
- aardvark 555-5553 1200/300 B
- alpo-net 555-3412 2400/1200/300 A
- barfly 555-7685 1200/300 A
- bites 555-1675 2400/1200/300 A
- camelot 555-0542 300 C
- core 555-2912 1200/300 C
- fooey 555-1234 2400/1200/300 B
- foot 555-6699 1200/300 B
- macfoo 555-6480 1200/300 A
- sdace 555-3430 2400/1200/300 A
- sabafoo 555-2127 1200/300 C
-
- The data file `inventory-shipped' represents information about
-shipments during the year. Each record contains the month, the number
-of green crates shipped, the number of red boxes shipped, the number of
-orange bags shipped, and the number of blue packages shipped,
-respectively. There are 16 entries, covering the 12 months of last year
-and the first four months of the current year.
-
- Jan 13 25 15 115
- Feb 15 32 24 226
- Mar 15 24 34 228
- Apr 31 52 63 420
- May 16 34 29 208
- Jun 31 42 75 492
- Jul 24 34 67 436
- Aug 15 34 47 316
- Sep 13 55 37 277
- Oct 29 54 68 525
- Nov 20 87 82 577
- Dec 17 35 61 401
-
- Jan 21 36 64 620
- Feb 26 58 80 652
- Mar 24 75 70 495
- Apr 21 70 74 514
-
- If you are reading this in GNU Emacs using Info, you can copy the
-regions of text showing these sample files into your own test files.
-This way you can try out the examples shown in the remainder of this
-document. You do this by using the command `M-x write-region' to copy
-text from the Info file into a file for use with `awk' (*Note
-Miscellaneous File Operations: (emacs)Misc File Ops, for more
-information). Using this information, create your own `BBS-list' and
-`inventory-shipped' files and practice what you learn in this Info file.
-
- If you are using the stand-alone version of Info, see *Note Extract
-Program::, for an `awk' program that extracts these data files from
-`gawk.texi', the Texinfo source file for this Info file.
-
-1.3 Some Simple Examples
-========================
-
-The following command runs a simple `awk' program that searches the
-input file `BBS-list' for the character string `foo' (a grouping of
-characters is usually called a "string"; the term "string" is based on
-similar usage in English, such as "a string of pearls," or "a string of
-cars in a train"):
-
- awk '/foo/ { print $0 }' BBS-list
-
-When lines containing `foo' are found, they are printed because
-`print $0' means print the current line. (Just `print' by itself means
-the same thing, so we could have written that instead.)
-
- You will notice that slashes (`/') surround the string `foo' in the
-`awk' program. The slashes indicate that `foo' is the pattern to
-search for. This type of pattern is called a "regular expression",
-which is covered in more detail later (*note Regexp::). The pattern is
-allowed to match parts of words. There are single quotes around the
-`awk' program so that the shell won't interpret any of it as special
-shell characters.
-
- Here is what this program prints:
-
- $ awk '/foo/ { print $0 }' BBS-list
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sabafoo 555-2127 1200/300 C
-
- In an `awk' rule, either the pattern or the action can be omitted,
-but not both. If the pattern is omitted, then the action is performed
-for _every_ input line. If the action is omitted, the default action
-is to print all lines that match the pattern.
-
- Thus, we could leave out the action (the `print' statement and the
-curly braces) in the previous example and the result would be the same:
-all lines matching the pattern `foo' are printed. By comparison,
-omitting the `print' statement but retaining the curly braces makes an
-empty action that does nothing (i.e., no lines are printed).
-
- Many practical `awk' programs are just a line or two. Following is a
-collection of useful, short programs to get you started. Some of these
-programs contain constructs that haven't been covered yet. (The
-description of the program will give you a good idea of what is going
-on, but please read the rest of the Info file to become an `awk'
-expert!) Most of the examples use a data file named `data'. This is
-just a placeholder; if you use these programs yourself, substitute your
-own file names for `data'. For future reference, note that there is
-often more than one way to do things in `awk'. At some point, you may
-want to look back at these examples and see if you can come up with
-different ways to do the same things shown here:
-
- * Print the length of the longest input line:
-
- awk '{ if (length($0) > max) max = length($0) }
- END { print max }' data
-
- * Print every line that is longer than 80 characters:
-
- awk 'length($0) > 80' data
-
- The sole rule has a relational expression as its pattern and it
- has no action--so the default action, printing the record, is used.
-
- * Print the length of the longest line in `data':
-
- expand data | awk '{ if (x < length()) x = length() }
- END { print "maximum line length is " x }'
-
- The input is processed by the `expand' utility to change tabs into
- spaces, so the widths compared are actually the right-margin
- columns.
-
- * Print every line that has at least one field:
-
- awk 'NF > 0' data
-
- This is an easy way to delete blank lines from a file (or rather,
- to create a new file similar to the old file but from which the
- blank lines have been removed).
-
- * Print seven random numbers from 0 to 100, inclusive:
-
- awk 'BEGIN { for (i = 1; i <= 7; i++)
- print int(101 * rand()) }'
-
- * Print the total number of bytes used by FILES:
-
- ls -l FILES | awk '{ x += $5 }
- END { print "total bytes: " x }'
-
- * Print the total number of kilobytes used by FILES:
-
- ls -l FILES | awk '{ x += $5 }
- END { print "total K-bytes: " (x + 1023)/1024 }'
-
- * Print a sorted list of the login names of all users:
-
- awk -F: '{ print $1 }' /etc/passwd | sort
-
- * Count the lines in a file:
-
- awk 'END { print NR }' data
-
- * Print the even-numbered lines in the data file:
-
- awk 'NR % 2 == 0' data
-
- If you use the expression `NR % 2 == 1' instead, the program would
- print the odd-numbered lines.
-
-1.4 An Example with Two Rules
-=============================
-
-The `awk' utility reads the input files one line at a time. For each
-line, `awk' tries the patterns of each of the rules. If several
-patterns match, then several actions are run in the order in which they
-appear in the `awk' program. If no patterns match, then no actions are
-run.
-
- After processing all the rules that match the line (and perhaps
-there are none), `awk' reads the next line. (However, *note Next
-Statement::, and also *note Nextfile Statement::). This continues
-until the program reaches the end of the file. For example, the
-following `awk' program contains two rules:
-
- /12/ { print $0 }
- /21/ { print $0 }
-
-The first rule has the string `12' as the pattern and `print $0' as the
-action. The second rule has the string `21' as the pattern and also
-has `print $0' as the action. Each rule's action is enclosed in its
-own pair of braces.
-
- This program prints every line that contains the string `12' _or_
-the string `21'. If a line contains both strings, it is printed twice,
-once by each rule.
-
- This is what happens if we run this program on our two sample data
-files, `BBS-list' and `inventory-shipped':
-
- $ awk '/12/ { print $0 }
- > /21/ { print $0 }' BBS-list inventory-shipped
- -| aardvark 555-5553 1200/300 B
- -| alpo-net 555-3412 2400/1200/300 A
- -| barfly 555-7685 1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| core 555-2912 1200/300 C
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sdace 555-3430 2400/1200/300 A
- -| sabafoo 555-2127 1200/300 C
- -| sabafoo 555-2127 1200/300 C
- -| Jan 21 36 64 620
- -| Apr 21 70 74 514
-
-Note how the line beginning with `sabafoo' in `BBS-list' was printed
-twice, once for each rule.
-
-1.5 A More Complex Example
-==========================
-
-Now that we've mastered some simple tasks, let's look at what typical
-`awk' programs do. This example shows how `awk' can be used to
-summarize, select, and rearrange the output of another utility. It uses
-features that haven't been covered yet, so don't worry if you don't
-understand all the details:
-
- ls -l | awk '$6 == "Nov" { sum += $5 }
- END { print sum }'
-
- This command prints the total number of bytes in all the files in the
-current directory that were last modified in November (of any year).
-(1) The `ls -l' part of this example is a system command that gives you
-a listing of the files in a directory, including each file's size and
-the date the file was last modified. Its output looks like this:
-
- -rw-r--r-- 1 arnold user 1933 Nov 7 13:05 Makefile
- -rw-r--r-- 1 arnold user 10809 Nov 7 13:03 awk.h
- -rw-r--r-- 1 arnold user 983 Apr 13 12:14 awk.tab.h
- -rw-r--r-- 1 arnold user 31869 Jun 15 12:20 awk.y
- -rw-r--r-- 1 arnold user 22414 Nov 7 13:03 awk1.c
- -rw-r--r-- 1 arnold user 37455 Nov 7 13:03 awk2.c
- -rw-r--r-- 1 arnold user 27511 Dec 9 13:07 awk3.c
- -rw-r--r-- 1 arnold user 7989 Nov 7 13:03 awk4.c
-
-The first field contains read-write permissions, the second field
-contains the number of links to the file, and the third field
-identifies the owner of the file. The fourth field identifies the group
-of the file. The fifth field contains the size of the file in bytes.
-The sixth, seventh, and eighth fields contain the month, day, and time,
-respectively, that the file was last modified. Finally, the ninth field
-contains the name of the file.(2)
-
- The `$6 == "Nov"' in our `awk' program is an expression that tests
-whether the sixth field of the output from `ls -l' matches the string
-`Nov'. Each time a line has the string `Nov' for its sixth field, the
-action `sum += $5' is performed. This adds the fifth field (the file's
-size) to the variable `sum'. As a result, when `awk' has finished
-reading all the input lines, `sum' is the total of the sizes of the
-files whose lines matched the pattern. (This works because `awk'
-variables are automatically initialized to zero.)
-
- After the last line of output from `ls' has been processed, the
-`END' rule executes and prints the value of `sum'. In this example,
-the value of `sum' is 80600.
-
- These more advanced `awk' techniques are covered in later sections
-(*note Action Overview::). Before you can move on to more advanced
-`awk' programming, you have to know how `awk' interprets your input and
-displays your output. By manipulating fields and using `print'
-statements, you can produce some very useful and impressive-looking
-reports.
-
- ---------- Footnotes ----------
-
- (1) In the C shell (`csh'), you need to type a semicolon and then a
-backslash at the end of the first line; see *Note Statements/Lines::,
-for an explanation. In a POSIX-compliant shell, such as the Bourne
-shell or `bash', you can type the example as shown. If the command
-`echo $path' produces an empty output line, you are most likely using a
-POSIX-compliant shell. Otherwise, you are probably using the C shell
-or a shell derived from it.
-
- (2) On some very old systems, you may need to use `ls -lg' to get
-this output.
-
-1.6 `awk' Statements Versus Lines
-=================================
-
-Most often, each line in an `awk' program is a separate statement or
-separate rule, like this:
-
- awk '/12/ { print $0 }
- /21/ { print $0 }' BBS-list inventory-shipped
-
- However, `gawk' ignores newlines after any of the following symbols
-and keywords:
-
- , { ? : || && do else
-
-A newline at any other point is considered the end of the statement.(1)
-
- If you would like to split a single statement into two lines at a
-point where a newline would terminate it, you can "continue" it by
-ending the first line with a backslash character (`\'). The backslash
-must be the final character on the line in order to be recognized as a
-continuation character. A backslash is allowed anywhere in the
-statement, even in the middle of a string or regular expression. For
-example:
-
- awk '/This regular expression is too long, so continue it\
- on the next line/ { print $1 }'
-
-We have generally not used backslash continuation in the sample programs
-in this Info file. In `gawk', there is no limit on the length of a
-line, so backslash continuation is never strictly necessary; it just
-makes programs more readable. For this same reason, as well as for
-clarity, we have kept most statements short in the sample programs
-presented throughout the Info file. Backslash continuation is most
-useful when your `awk' program is in a separate source file instead of
-entered from the command line. You should also note that many `awk'
-implementations are more particular about where you may use backslash
-continuation. For example, they may not allow you to split a string
-constant using backslash continuation. Thus, for maximum portability
-of your `awk' programs, it is best not to split your lines in the
-middle of a regular expression or a string.
-
- *Caution:* _Backslash continuation does not work as described with
-the C shell._ It works for `awk' programs in files and for one-shot
-programs, _provided_ you are using a POSIX-compliant shell, such as the
-Unix Bourne shell or `bash'. But the C shell behaves differently!
-There, you must use two backslashes in a row, followed by a newline.
-Note also that when using the C shell, _every_ newline in your awk
-program must be escaped with a backslash. To illustrate:
-
- % awk 'BEGIN { \
- ? print \\
- ? "hello, world" \
- ? }'
- -| hello, world
-
-Here, the `%' and `?' are the C shell's primary and secondary prompts,
-analogous to the standard shell's `$' and `>'.
-
- Compare the previous example to how it is done with a
-POSIX-compliant shell:
-
- $ awk 'BEGIN {
- > print \
- > "hello, world"
- > }'
- -| hello, world
-
- `awk' is a line-oriented language. Each rule's action has to begin
-on the same line as the pattern. To have the pattern and action on
-separate lines, you _must_ use backslash continuation; there is no
-other option.
-
- Another thing to keep in mind is that backslash continuation and
-comments do not mix. As soon as `awk' sees the `#' that starts a
-comment, it ignores _everything_ on the rest of the line. For example:
-
- $ gawk 'BEGIN { print "dont panic" # a friendly \
- > BEGIN rule
- > }'
- error--> gawk: cmd. line:2: BEGIN rule
- error--> gawk: cmd. line:2: ^ parse error
-
-In this case, it looks like the backslash would continue the comment
-onto the next line. However, the backslash-newline combination is never
-even noticed because it is "hidden" inside the comment. Thus, the
-`BEGIN' is noted as a syntax error.
-
- When `awk' statements within one rule are short, you might want to
-put more than one of them on a line. This is accomplished by
-separating the statements with a semicolon (`;'). This also applies to
-the rules themselves. Thus, the program shown at the start of this
-minor node could also be written this way:
-
- /12/ { print $0 } ; /21/ { print $0 }
-
- NOTE: The requirement that states that rules on the same line must
- be separated with a semicolon was not in the original `awk'
- language; it was added for consistency with the treatment of
- statements within an action.
-
- ---------- Footnotes ----------
-
- (1) The `?' and `:' referred to here is the three-operand
-conditional expression described in *Note Conditional Exp::. Splitting
-lines after `?' and `:' is a minor `gawk' extension; if `--posix' is
-specified (*note Options::), then this extension is disabled.
-
-1.7 Other Features of `awk'
-===========================
-
-The `awk' language provides a number of predefined, or "built-in",
-variables that your programs can use to get information from `awk'.
-There are other variables your program can set as well to control how
-`awk' processes your data.
-
- In addition, `awk' provides a number of built-in functions for doing
-common computational and string-related operations. `gawk' provides
-built-in functions for working with timestamps, performing bit
-manipulation, and for runtime string translation.
-
- As we develop our presentation of the `awk' language, we introduce
-most of the variables and many of the functions. They are defined
-systematically in *Note Built-in Variables::, and *Note Built-in::.
-
-1.8 When to Use `awk'
-=====================
-
-Now that you've seen some of what `awk' can do, you might wonder how
-`awk' could be useful for you. By using utility programs, advanced
-patterns, field separators, arithmetic statements, and other selection
-criteria, you can produce much more complex output. The `awk' language
-is very useful for producing reports from large amounts of raw data,
-such as summarizing information from the output of other utility
-programs like `ls'. (*Note More Complex::.)
-
- Programs written with `awk' are usually much smaller than they would
-be in other languages. This makes `awk' programs easy to compose and
-use. Often, `awk' programs can be quickly composed at your terminal,
-used once, and thrown away. Because `awk' programs are interpreted, you
-can avoid the (usually lengthy) compilation part of the typical
-edit-compile-test-debug cycle of software development.
-
- Complex programs have been written in `awk', including a complete
-retargetable assembler for eight-bit microprocessors (*note Glossary::,
-for more information), and a microcode assembler for a special-purpose
-Prolog computer. More recently, `gawk' was used for writing a Wiki
-clone.(1) While the original `awk''s capabilities were strained by tasks
-of such complexity, modern versions are more capable. Even the Bell
-Labs version of `awk' has fewer predefined limits, and those that it
-has are much larger than they used to be.
-
- If you find yourself writing `awk' scripts of more than, say, a few
-hundred lines, you might consider using a different programming
-language. Emacs Lisp is a good choice if you need sophisticated string
-or pattern matching capabilities. The shell is also good at string and
-pattern matching; in addition, it allows powerful use of the system
-utilities. More conventional languages, such as C, C++, and Java, offer
-better facilities for system programming and for managing the complexity
-of large programs. Programs in these languages may require more lines
-of source code than the equivalent `awk' programs, but they are easier
-to maintain and usually run more efficiently.
-
- ---------- Footnotes ----------
-
- (1) Yet Another Wiki Clone
-(http://www.awk-scripting.de/cgi/wiki.cgi/yawk/).
-
-2 Regular Expressions
-*********************
-
-A "regular expression", or "regexp", is a way of describing a set of
-strings. Because regular expressions are such a fundamental part of
-`awk' programming, their format and use deserve a separate major node.
-
- A regular expression enclosed in slashes (`/') is an `awk' pattern
-that matches every input record whose text belongs to that set. The
-simplest regular expression is a sequence of letters, numbers, or both.
-Such a regexp matches any string that contains that sequence. Thus,
-the regexp `foo' matches any string containing `foo'. Therefore, the
-pattern `/foo/' matches any input record containing the three
-characters `foo' _anywhere_ in the record. Other kinds of regexps let
-you specify more complicated classes of strings.
-
-2.1 How to Use Regular Expressions
-==================================
-
-A regular expression can be used as a pattern by enclosing it in
-slashes. Then the regular expression is tested against the entire text
-of each record. (Normally, it only needs to match some part of the
-text in order to succeed.) For example, the following prints the
-second field of each record that contains the string `foo' anywhere in
-it:
-
- $ awk '/foo/ { print $2 }' BBS-list
- -| 555-1234
- -| 555-6699
- -| 555-6480
- -| 555-2127
-
- `~' (tilde), `~' operator Regular expressions can also be used in
-matching expressions. These expressions allow you to specify the
-string to match against; it need not be the entire current input
-record. The two operators `~' and `!~' perform regular expression
-comparisons. Expressions using these operators can be used as
-patterns, or in `if', `while', `for', and `do' statements. (*Note
-Statements::.) For example:
-
- EXP ~ /REGEXP/
-
-is true if the expression EXP (taken as a string) matches REGEXP. The
-following example matches, or selects, all input records with the
-uppercase letter `J' somewhere in the first field:
-
- $ awk '$1 ~ /J/' inventory-shipped
- -| Jan 13 25 15 115
- -| Jun 31 42 75 492
- -| Jul 24 34 67 436
- -| Jan 21 36 64 620
-
- So does this:
-
- awk '{ if ($1 ~ /J/) print }' inventory-shipped
-
- This next example is true if the expression EXP (taken as a
-character string) does _not_ match REGEXP:
-
- EXP !~ /REGEXP/
-
- The following example matches, or selects, all input records whose
-first field _does not_ contain the uppercase letter `J':
-
- $ awk '$1 !~ /J/' inventory-shipped
- -| Feb 15 32 24 226
- -| Mar 15 24 34 228
- -| Apr 31 52 63 420
- -| May 16 34 29 208
- ...
-
- When a regexp is enclosed in slashes, such as `/foo/', we call it a
-"regexp constant", much like `5.27' is a numeric constant and `"foo"'
-is a string constant.
-
-2.2 Escape Sequences
-====================
-
-Some characters cannot be included literally in string constants
-(`"foo"') or regexp constants (`/foo/'). Instead, they should be
-represented with "escape sequences", which are character sequences
-beginning with a backslash (`\'). One use of an escape sequence is to
-include a double-quote character in a string constant. Because a plain
-double quote ends the string, you must use `\"' to represent an actual
-double-quote character as a part of the string. For example:
-
- $ awk 'BEGIN { print "He said \"hi!\" to her." }'
- -| He said "hi!" to her.
-
- The backslash character itself is another character that cannot be
-included normally; you must write `\\' to put one backslash in the
-string or regexp. Thus, the string whose contents are the two
-characters `"' and `\' must be written `"\"\\"'.
-
- Backslash also represents unprintable characters such as TAB or
-newline. While there is nothing to stop you from entering most
-unprintable characters directly in a string constant or regexp constant,
-they may look ugly.
-
- The following table lists all the escape sequences used in `awk' and
-what they represent. Unless noted otherwise, all these escape sequences
-apply to both string constants and regexp constants:
-
-`\\'
- A literal backslash, `\'.
-
-`\a'
- The "alert" character, `Ctrl-g', ASCII code 7 (BEL). (This
- usually makes some sort of audible noise.)
-
-`\b'
- Backspace, `Ctrl-h', ASCII code 8 (BS).
-
-`\f'
- Formfeed, `Ctrl-l', ASCII code 12 (FF).
-
-`\n'
- Newline, `Ctrl-j', ASCII code 10 (LF).
-
-`\r'
- Carriage return, `Ctrl-m', ASCII code 13 (CR).
-
-`\t'
- Horizontal TAB, `Ctrl-i', ASCII code 9 (HT).
-
-`\v'
- Vertical tab, `Ctrl-k', ASCII code 11 (VT).
-
-`\NNN'
- The octal value NNN, where NNN stands for 1 to 3 digits between
- `0' and `7'. For example, the code for the ASCII ESC (escape)
- character is `\033'.
-
-`\xHH...'
- The hexadecimal value HH, where HH stands for a sequence of
- hexadecimal digits (`0'-`9', and either `A'-`F' or `a'-`f'). Like
- the same construct in ISO C, the escape sequence continues until
- the first nonhexadecimal digit is seen. However, using more than
- two hexadecimal digits produces undefined results. (The `\x'
- escape sequence is not allowed in POSIX `awk'.)
-
-`\/'
- A literal slash (necessary for regexp constants only). This
- expression is used when you want to write a regexp constant that
- contains a slash. Because the regexp is delimited by slashes, you
- need to escape the slash that is part of the pattern, in order to
- tell `awk' to keep processing the rest of the regexp.
-
-`\"'
- A literal double quote (necessary for string constants only).
- This expression is used when you want to write a string constant
- that contains a double quote. Because the string is delimited by
- double quotes, you need to escape the quote that is part of the
- string, in order to tell `awk' to keep processing the rest of the
- string.
-
- In `gawk', a number of additional two-character sequences that begin
-with a backslash have special meaning in regexps. *Note GNU Regexp
-Operators::.
-
- In a regexp, a backslash before any character that is not in the
-previous list and not listed in *Note GNU Regexp Operators::, means
-that the next character should be taken literally, even if it would
-normally be a regexp operator. For example, `/a\+b/' matches the three
-characters `a+b'.
-
- For complete portability, do not use a backslash before any
-character not shown in the previous list.
-
- To summarize:
-
- * The escape sequences in the table above are always processed first,
- for both string constants and regexp constants. This happens very
- early, as soon as `awk' reads your program.
-
- * `gawk' processes both regexp constants and dynamic regexps (*note
- Computed Regexps::), for the special operators listed in *Note GNU
- Regexp Operators::.
-
- * A backslash before any other character means to treat that
- character literally.
-
-Advanced Notes: Backslash Before Regular Characters
----------------------------------------------------
-
-If you place a backslash in a string constant before something that is
-not one of the characters previously listed, POSIX `awk' purposely
-leaves what happens as undefined. There are two choices:
-
-Strip the backslash out
- This is what Unix `awk' and `gawk' both do. For example, `"a\qc"'
- is the same as `"aqc"'. (Because this is such an easy bug both to
- introduce and to miss, `gawk' warns you about it.) Consider `FS =
- "[ \t]+\|[ \t]+"' to use vertical bars surrounded by whitespace as
- the field separator. There should be two backslashes in the string
- `FS = "[ \t]+\\|[ \t]+"'.)
-
-Leave the backslash alone
- Some other `awk' implementations do this. In such
- implementations, typing `"a\qc"' is the same as typing `"a\\qc"'.
-
-Advanced Notes: Escape Sequences for Metacharacters
----------------------------------------------------
-
-Suppose you use an octal or hexadecimal escape to represent a regexp
-metacharacter. (See *Note Regexp Operators::.) Does `awk' treat the
-character as a literal character or as a regexp operator?
-
- Historically, such characters were taken literally. (d.c.)
-However, the POSIX standard indicates that they should be treated as
-real metacharacters, which is what `gawk' does. In compatibility mode
-(*note Options::), `gawk' treats the characters represented by octal
-and hexadecimal escape sequences literally when used in regexp
-constants. Thus, `/a\52b/' is equivalent to `/a\*b/'.
-
-2.3 Regular Expression Operators
-================================
-
-You can combine regular expressions with special characters, called
-"regular expression operators" or "metacharacters", to increase the
-power and versatility of regular expressions.
-
- The escape sequences described in *Note Escape Sequences::, are
-valid inside a regexp. They are introduced by a `\' and are recognized
-and converted into corresponding real characters as the very first step
-in processing regexps.
-
- Here is a list of metacharacters. All characters that are not escape
-sequences and that are not listed in the table stand for themselves:
-
-`\'
- This is used to suppress the special meaning of a character when
- matching. For example, `\$' matches the character `$'.
-
-`^'
- This matches the beginning of a string. For example, address@hidden'
- matches address@hidden' at the beginning of a string and can be used to
- identify chapter beginnings in Texinfo source files. The `^' is
- known as an "anchor", because it anchors the pattern to match only
- at the beginning of the string.
-
- It is important to realize that `^' does not match the beginning of
- a line embedded in a string. The condition is not true in the
- following example:
-
- if ("line1\nLINE 2" ~ /^L/) ...
-
-`$'
- This is similar to `^', but it matches only at the end of a string.
- For example, `p$' matches a record that ends with a `p'. The `$'
- is an anchor and does not match the end of a line embedded in a
- string. The condition in the following example is not true:
-
- if ("line1\nLINE 2" ~ /1$/) ...
-
-`.'
- This matches any single character, _including_ the newline
- character. For example, `.P' matches any single character
- followed by a `P' in a string. Using concatenation, we can make a
- regular expression such as `U.A', which matches any
- three-character sequence that begins with `U' and ends with `A'.
-
- In strict POSIX mode (*note Options::), `.' does not match the NUL
- character, which is a character with all bits equal to zero.
- Otherwise, NUL is just another character. Other versions of `awk'
- may not be able to match the NUL character.
-
-`[...]'
- This is called a "character list".(1) It matches any _one_ of the
- characters that are enclosed in the square brackets. For example,
- `[MVX]' matches any one of the characters `M', `V', or `X' in a
- string. A full discussion of what can be inside the square
- brackets of a character list is given in *Note Character Lists::.
-
-`[^ ...]'
- This is a "complemented character list". The first character after
- the `[' _must_ be a `^'. It matches any characters _except_ those
- in the square brackets. For example, `[^awk]' matches any
- character that is not an `a', `w', or `k'.
-
-`|'
- This is the "alternation operator" and it is used to specify
- alternatives. The `|' has the lowest precedence of all the regular
- expression operators. For example, `^P|[[:digit:]]' matches any
- string that matches either `^P' or `[[:digit:]]'. This means it
- matches any string that starts with `P' or contains a digit.
-
- The alternation applies to the largest possible regexps on either
- side.
-
-`(...)'
- Parentheses are used for grouping in regular expressions, as in
- arithmetic. They can be used to concatenate regular expressions
- containing the alternation operator, `|'. For example,
- `@(samp|code)\{[^}]+\}' matches both address@hidden' and address@hidden'.
- (These are Texinfo formatting control sequences. The `+' is
- explained further on in this list.)
-
-`*'
- This symbol means that the preceding regular expression should be
- repeated as many times as necessary to find a match. For example,
- `ph*' applies the `*' symbol to the preceding `h' and looks for
- matches of one `p' followed by any number of `h's. This also
- matches just `p' if no `h's are present.
-
- The `*' repeats the _smallest_ possible preceding expression.
- (Use parentheses if you want to repeat a larger expression.) It
- finds as many repetitions as possible. For example, `awk
- '/\(c[ad][ad]*r x\)/ { print }' sample' prints every record in
- `sample' containing a string of the form `(car x)', `(cdr x)',
- `(cadr x)', and so on. Notice the escaping of the parentheses by
- preceding them with backslashes.
-
-`+'
- This symbol is similar to `*', except that the preceding
- expression must be matched at least once. This means that `wh+y'
- would match `why' and `whhy', but not `wy', whereas `wh*y' would
- match all three of these strings. The following is a simpler way
- of writing the last `*' example:
-
- awk '/\(c[ad]+r x\)/ { print }' sample
-
-`?'
- This symbol is similar to `*', except that the preceding
- expression can be matched either once or not at all. For example,
- `fe?d' matches `fed' and `fd', but nothing else.
-
-`{N}'
-`{N,}'
-`{N,M}'
- One or two numbers inside braces denote an "interval expression".
- If there is one number in the braces, the preceding regexp is
- repeated N times. If there are two numbers separated by a comma,
- the preceding regexp is repeated N to M times. If there is one
- number followed by a comma, then the preceding regexp is repeated
- at least N times:
-
- `wh{3}y'
- Matches `whhhy', but not `why' or `whhhhy'.
-
- `wh{3,5}y'
- Matches `whhhy', `whhhhy', or `whhhhhy', only.
-
- `wh{2,}y'
- Matches `whhy' or `whhhy', and so on.
-
- Interval expressions were not traditionally available in `awk'.
- They were added as part of the POSIX standard to make `awk' and
- `egrep' consistent with each other.
-
- However, because old programs may use `{' and `}' in regexp
- constants, by default `gawk' does _not_ match interval expressions
- in regexps. If either `--posix' or `--re-interval' are specified
- (*note Options::), then interval expressions are allowed in
- regexps.
-
- For new programs that use `{' and `}' in regexp constants, it is
- good practice to always escape them with a backslash. Then the
- regexp constants are valid and work the way you want them to, using
- any version of `awk'.(2)
-
- In regular expressions, the `*', `+', and `?' operators, as well as
-the braces `{' and `}', have the highest precedence, followed by
-concatenation, and finally by `|'. As in arithmetic, parentheses can
-change how operators are grouped.
-
- In POSIX `awk' and `gawk', the `*', `+', and `?' operators stand for
-themselves when there is nothing in the regexp that precedes them. For
-example, `/+/' matches a literal plus sign. However, many other
-versions of `awk' treat such a usage as a syntax error.
-
- If `gawk' is in compatibility mode (*note Options::), POSIX
-character classes and interval expressions are not available in regular
-expressions.
-
- ---------- Footnotes ----------
-
- (1) In other literature, you may see a character list referred to as
-either a "character set", a "character class", or a "bracket
-expression".
-
- (2) Use two backslashes if you're using a string constant with a
-regexp operator or function.
-
-2.4 Using Character Lists
-=========================
-
-Within a character list, a "range expression" consists of two
-characters separated by a hyphen. It matches any single character that
-sorts between the two characters, using the locale's collating sequence
-and character set. For example, in the default C locale, `[a-dx-z]' is
-equivalent to `[abcdxyz]'. Many locales sort characters in dictionary
-order, and in these locales, `[a-dx-z]' is typically not equivalent to
-`[abcdxyz]'; instead it might be equivalent to `[aBbCcDdxXyYz]', for
-example. To obtain the traditional interpretation of bracket
-expressions, you can use the C locale by setting the `LC_ALL'
-environment variable to the value `C'.
-
- To include one of the characters `\', `]', `-', or `^' in a
-character list, put a `\' in front of it. For example:
-
- [d\]]
-
-matches either `d' or `]'.
-
- This treatment of `\' in character lists is compatible with other
-`awk' implementations and is also mandated by POSIX. The regular
-expressions in `awk' are a superset of the POSIX specification for
-Extended Regular Expressions (EREs). POSIX EREs are based on the
-regular expressions accepted by the traditional `egrep' utility.
-
- "Character classes" are a new feature introduced in the POSIX
-standard. A character class is a special notation for describing lists
-of characters that have a specific attribute, but the actual characters
-can vary from country to country and/or from character set to character
-set. For example, the notion of what is an alphabetic character
-differs between the United States and France.
-
- A character class is only valid in a regexp _inside_ the brackets of
-a character list. Character classes consist of `[:', a keyword
-denoting the class, and `:]'. *Note table-char-classes:: lists the
-character classes defined by the POSIX standard.
-
-Class Meaning
---------------------------------------------------------------------------
-`[:alnum:]' Alphanumeric characters.
-`[:alpha:]' Alphabetic characters.
-`[:blank:]' Space and TAB characters.
-`[:cntrl:]' Control characters.
-`[:digit:]' Numeric characters.
-`[:graph:]' Characters that are both printable and visible. (A space is
- printable but not visible, whereas an `a' is both.)
-`[:lower:]' Lowercase alphabetic characters.
-`[:print:]' Printable characters (characters that are not control
- characters).
-`[:punct:]' Punctuation characters (characters that are not letters,
- digits, control characters, or space characters).
-`[:space:]' Space characters (such as space, TAB, and formfeed, to name
- a few).
-`[:upper:]' Uppercase alphabetic characters.
-`[:xdigit:]'Characters that are hexadecimal digits.
-
-Table 2.1: POSIX Character Classes
-
- For example, before the POSIX standard, you had to write
-`/[A-Za-z0-9]/' to match alphanumeric characters. If your character
-set had other alphabetic characters in it, this would not match them,
-and if your character set collated differently from ASCII, this might
-not even match the ASCII alphanumeric characters. With the POSIX
-character classes, you can write `/[[:alnum:]]/' to match the alphabetic
-and numeric characters in your character set.
-
- Two additional special sequences can appear in character lists.
-These apply to non-ASCII character sets, which can have single symbols
-(called "collating elements") that are represented with more than one
-character. They can also have several characters that are equivalent for
-"collating", or sorting, purposes. (For example, in French, a plain "e"
-and a grave-accented "e`" are equivalent.) These sequences are:
-
-Collating symbols
- Multicharacter collating elements enclosed between `[.' and `.]'.
- For example, if `ch' is a collating element, then `[[.ch.]]' is a
- regexp that matches this collating element, whereas `[ch]' is a
- regexp that matches either `c' or `h'.
-
-Equivalence classes
- Locale-specific names for a list of characters that are equal. The
- name is enclosed between `[=' and `=]'. For example, the name `e'
- might be used to represent all of "e," "e`," and "e'." In this
- case, `[[=e=]]' is a regexp that matches any of `e', `e'', or `e`'.
-
- These features are very valuable in non-English-speaking locales.
-
- *Caution:* The library functions that `gawk' uses for regular
-expression matching currently recognize only POSIX character classes;
-they do not recognize collating symbols or equivalence classes.
-
-2.5 `gawk'-Specific Regexp Operators
-====================================
-
-GNU software that deals with regular expressions provides a number of
-additional regexp operators. These operators are described in this
-minor node and are specific to `gawk'; they are not available in other
-`awk' implementations. Most of the additional operators deal with word
-matching. For our purposes, a "word" is a sequence of one or more
-letters, digits, or underscores (`_'):
-
-`\w'
- Matches any word-constituent character--that is, it matches any
- letter, digit, or underscore. Think of it as shorthand for
- `[[:alnum:]_]'.
-
-`\W'
- Matches any character that is not word-constituent. Think of it
- as shorthand for `[^[:alnum:]_]'.
-
-`\<'
- Matches the empty string at the beginning of a word. For example,
- `/\<away/' matches `away' but not `stowaway'.
-
-`\>'
- Matches the empty string at the end of a word. For example,
- `/stow\>/' matches `stow' but not `stowaway'.
-
-`\y'
- Matches the empty string at either the beginning or the end of a
- word (i.e., the word boundar*y*). For example, `\yballs?\y'
- matches either `ball' or `balls', as a separate word.
-
-`\B'
- Matches the empty string that occurs between two word-constituent
- characters. For example, `/\Brat\B/' matches `crate' but it does
- not match `dirty rat'. `\B' is essentially the opposite of `\y'.
-
- There are two other operators that work on buffers. In Emacs, a
-"buffer" is, naturally, an Emacs buffer. For other programs, `gawk''s
-regexp library routines consider the entire string to match as the
-buffer. The operators are:
-
-`\`'
- Matches the empty string at the beginning of a buffer (string).
-
-`\''
- Matches the empty string at the end of a buffer (string).
-
- Because `^' and `$' always work in terms of the beginning and end of
-strings, these operators don't add any new capabilities for `awk'.
-They are provided for compatibility with other GNU software.
-
- In other GNU software, the word-boundary operator is `\b'. However,
-that conflicts with the `awk' language's definition of `\b' as
-backspace, so `gawk' uses a different letter. An alternative method
-would have been to require two backslashes in the GNU operators, but
-this was deemed too confusing. The current method of using `\y' for the
-GNU `\b' appears to be the lesser of two evils.
-
- The various command-line options (*note Options::) control how
-`gawk' interprets characters in regexps:
-
-No options
- In the default case, `gawk' provides all the facilities of POSIX
- regexps and the GNU regexp operators described in *Note Regexp
- Operators::. However, interval expressions are not supported.
-
-`--posix'
- Only POSIX regexps are supported; the GNU operators are not special
- (e.g., `\w' matches a literal `w'). Interval expressions are
- allowed.
-
-`--traditional'
- Traditional Unix `awk' regexps are matched. The GNU operators are
- not special, interval expressions are not available, nor are the
- POSIX character classes (`[[:alnum:]]', etc.). Characters
- described by octal and hexadecimal escape sequences are treated
- literally, even if they represent regexp metacharacters.
-
-`--re-interval'
- Allow interval expressions in regexps, even if `--traditional' has
- been provided. (`--posix' automatically enables interval
- expressions, so `--re-interval' is redundant when `--posix' is is
- used.)
-
-2.6 Case Sensitivity in Matching
-================================
-
-Case is normally significant in regular expressions, both when matching
-ordinary characters (i.e., not metacharacters) and inside character
-sets. Thus, a `w' in a regular expression matches only a lowercase `w'
-and not an uppercase `W'.
-
- The simplest way to do a case-independent match is to use a character
-list--for example, `[Ww]'. However, this can be cumbersome if you need
-to use it often, and it can make the regular expressions harder to
-read. There are two alternatives that you might prefer.
-
- One way to perform a case-insensitive match at a particular point in
-the program is to convert the data to a single case, using the
-`tolower' or `toupper' built-in string functions (which we haven't
-discussed yet; *note String Functions::). For example:
-
- tolower($1) ~ /foo/ { ... }
-
-converts the first field to lowercase before matching against it. This
-works in any POSIX-compliant `awk'.
-
- Another method, specific to `gawk', is to set the variable
-`IGNORECASE' to a nonzero value (*note Built-in Variables::). When
-`IGNORECASE' is not zero, _all_ regexp and string operations ignore
-case. Changing the value of `IGNORECASE' dynamically controls the
-case-sensitivity of the program as it runs. Case is significant by
-default because `IGNORECASE' (like most variables) is initialized to
-zero:
-
- x = "aB"
- if (x ~ /ab/) ... # this test will fail
-
- IGNORECASE = 1
- if (x ~ /ab/) ... # now it will succeed
-
- In general, you cannot use `IGNORECASE' to make certain rules
-case-insensitive and other rules case-sensitive, because there is no
-straightforward way to set `IGNORECASE' just for the pattern of a
-particular rule.(1) To do this, use either character lists or
-`tolower'. However, one thing you can do with `IGNORECASE' only is
-dynamically turn case-sensitivity on or off for all the rules at once.
-
- `IGNORECASE' can be set on the command line or in a `BEGIN' rule
-(*note Other Arguments::; also *note Using BEGIN/END::). Setting
-`IGNORECASE' from the command line is a way to make a program
-case-insensitive without having to edit it.
-
- Prior to `gawk' 3.0, the value of `IGNORECASE' affected regexp
-operations only. It did not affect string comparison with `==', `!=',
-and so on. Beginning with version 3.0, both regexp and string
-comparison operations are also affected by `IGNORECASE'.
-
- Beginning with `gawk' 3.0, the equivalences between upper- and
-lowercase characters are based on the ISO-8859-1 (ISO Latin-1)
-character set. This character set is a superset of the traditional 128
-ASCII characters, which also provides a number of characters suitable
-for use with European languages.
-
- As of `gawk' 3.1.4, the case equivalencies are fully locale-aware.
-They are based on the C `<ctype.h>' facilities, such as `isalpha()' and
-`toupper()'.
-
- The value of `IGNORECASE' has no effect if `gawk' is in
-compatibility mode (*note Options::). Case is always significant in
-compatibility mode.
-
- ---------- Footnotes ----------
-
- (1) Experienced C and C++ programmers will note that it is possible,
-using something like `IGNORECASE = 1 && /foObAr/ { ... }' and
-`IGNORECASE = 0 || /foobar/ { ... }'. However, this is somewhat
-obscure and we don't recommend it.
-
-2.7 How Much Text Matches?
-==========================
-
-Consider the following:
-
- echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
-
- This example uses the `sub' function (which we haven't discussed yet;
-*note String Functions::) to make a change to the input record. Here,
-the regexp `/a+/' indicates "one or more `a' characters," and the
-replacement text is `<A>'.
-
- The input contains four `a' characters. `awk' (and POSIX) regular
-expressions always match the leftmost, _longest_ sequence of input
-characters that can match. Thus, all four `a' characters are replaced
-with `<A>' in this example:
-
- $ echo aaaabcd | awk '{ sub(/a+/, "<A>"); print }'
- -| <A>bcd
-
- For simple match/no-match tests, this is not so important. But when
-doing text matching and substitutions with the `match', `sub', `gsub',
-and `gensub' functions, it is very important. *Note String Functions::,
-for more information on these functions. Understanding this principle
-is also important for regexp-based record and field splitting (*note
-Records::, and also *note Field Separators::).
-
-2.8 Using Dynamic Regexps
-=========================
-
-The righthand side of a `~' or `!~' operator need not be a regexp
-constant (i.e., a string of characters between slashes). It may be any
-expression. The expression is evaluated and converted to a string if
-necessary; the contents of the string are used as the regexp. A regexp
-that is computed in this way is called a "dynamic regexp":
-
- BEGIN { digits_regexp = "[[:digit:]]+" }
- $0 ~ digits_regexp { print }
-
-This sets `digits_regexp' to a regexp that describes one or more digits,
-and tests whether the input record matches this regexp.
-
- *Caution:* When using the `~' and `!~' operators, there is a
-difference between a regexp constant enclosed in slashes and a string
-constant enclosed in double quotes. If you are going to use a string
-constant, you have to understand that the string is, in essence,
-scanned _twice_: the first time when `awk' reads your program, and the
-second time when it goes to match the string on the lefthand side of
-the operator with the pattern on the right. This is true of any
-string-valued expression (such as `digits_regexp', shown previously),
-not just string constants.
-
- What difference does it make if the string is scanned twice? The
-answer has to do with escape sequences, and particularly with
-backslashes. To get a backslash into a regular expression inside a
-string, you have to type two backslashes.
-
- For example, `/\*/' is a regexp constant for a literal `*'. Only
-one backslash is needed. To do the same thing with a string, you have
-to type `"\\*"'. The first backslash escapes the second one so that
-the string actually contains the two characters `\' and `*'.
-
- Given that you can use both regexp and string constants to describe
-regular expressions, which should you use? The answer is "regexp
-constants," for several reasons:
-
- * String constants are more complicated to write and more difficult
- to read. Using regexp constants makes your programs less
- error-prone. Not understanding the difference between the two
- kinds of constants is a common source of errors.
-
- * It is more efficient to use regexp constants. `awk' can note that
- you have supplied a regexp and store it internally in a form that
- makes pattern matching more efficient. When using a string
- constant, `awk' must first convert the string into this internal
- form and then perform the pattern matching.
-
- * Using regexp constants is better form; it shows clearly that you
- intend a regexp match.
-
-Advanced Notes: Using `\n' in Character Lists of Dynamic Regexps
-----------------------------------------------------------------
-
-Some commercial versions of `awk' do not allow the newline character to
-be used inside a character list for a dynamic regexp:
-
- $ awk '$0 ~ "[ \t\n]"'
- error--> awk: newline in character class [
- error--> ]...
- error--> source line number 1
- error--> context is
- error--> >>> <<<
-
- But a newline in a regexp constant works with no problem:
-
- $ awk '$0 ~ /[ \t\n]/'
- here is a sample line
- -| here is a sample line
- Ctrl-d
-
- `gawk' does not have this problem, and it isn't likely to occur
-often in practice, but it's worth noting for future reference.
-
-2.9 Where You Are Makes A Difference
-====================================
-
-Modern systems support the notion of "locales": a way to tell the
-system about the local character set and language. The current locale
-setting can affect the way regexp matching works, often in surprising
-ways. In particular, many locales do case-insensitive matching, even
-when you may have specified characters of only one particular case.
-
- The following example uses the `sub' function, which does text
-replacement (*note String Functions::). Here, the intent is to remove
-trailing uppercase characters:
-
- $ echo something1234abc | gawk '{ sub("[A-Z]*$", ""); print }'
- -| something1234
-
-This output is unexpected, since the `abc' at the end of
-`something1234abc' should not normally match `[A-Z]*'. This result is
-due to the locale setting (and thus you may not see it on your system).
-There are two fixes. The first is to use the POSIX character class
-`[[:upper:]]', instead of `[A-Z]'. The second is to change the locale
-setting in the environment, before running `gawk', by using the shell
-statements:
-
- LANG=C LC_ALL=C
- export LANG LC_ALL
-
- The setting `C' forces `gawk' to behave in the traditional Unix
-manner, where case distinctions do matter. You may wish to put these
-statements into your shell startup file, e.g., `$HOME/.profile'.
-
- Similar considerations apply to other ranges. For example, `["-/]'
-is perfectly valid in ASCII, but is not valid in many Unicode locales,
-such as `en_US.UTF-8'. (In general, such ranges should be avoided;
-either list the characters individually, or use a POSIX character class
-such as `[[:punct:]]'.)
-
- For the normal case of `RS = "\n"', the locale is largely irrelevant.
-For other single byte record separators, using `LC_ALL=C' will give you
-much better performance when reading records. Otherwise, `gawk' has to
-make several function calls, _per input character_ to find the record
-terminator.
-
-3 Reading Input Files
-*********************
-
-In the typical `awk' program, all input is read either from the
-standard input (by default, this is the keyboard, but often it is a
-pipe from another command) or from files whose names you specify on the
-`awk' command line. If you specify input files, `awk' reads them in
-order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
-`FILENAME' (*note Built-in Variables::).
-
- The input is read in units called "records", and is processed by the
-rules of your program one record at a time. By default, each record is
-one line. Each record is automatically split into chunks called
-"fields". This makes it more convenient for programs to work on the
-parts of a record.
-
- On rare occasions, you may need to use the `getline' command. The
-`getline' command is valuable, both because it can do explicit input
-from any number of files, and because the files used with it do not
-have to be named on the `awk' command line (*note Getline::).
-
-3.1 How Input Is Split into Records
-===================================
-
-The `awk' utility divides the input for your `awk' program into records
-and fields. `awk' keeps track of the number of records that have been
-read so far from the current input file. This value is stored in a
-built-in variable called `FNR'. It is reset to zero when a new file is
-started. Another built-in variable, `NR', is the total number of input
-records read so far from all data files. It starts at zero, but is
-never automatically reset to zero.
-
- Records are separated by a character called the "record separator".
-By default, the record separator is the newline character. This is why
-records are, by default, single lines. A different character can be
-used for the record separator by assigning the character to the
-built-in variable `RS'.
-
- Like any other variable, the value of `RS' can be changed in the
-`awk' program with the assignment operator, `=' (*note Assignment
-Ops::). The new record-separator character should be enclosed in
-quotation marks, which indicate a string constant. Often the right
-time to do this is at the beginning of execution, before any input is
-processed, so that the very first record is read with the proper
-separator. To do this, use the special `BEGIN' pattern (*note
-BEGIN/END::). For example:
-
- awk 'BEGIN { RS = "/" }
- { print $0 }' BBS-list
-
-changes the value of `RS' to `"/"', before reading any input. This is
-a string whose first character is a slash; as a result, records are
-separated by slashes. Then the input file is read, and the second rule
-in the `awk' program (the action with no pattern) prints each record.
-Because each `print' statement adds a newline at the end of its output,
-this `awk' program copies the input with each slash changed to a
-newline. Here are the results of running the program on `BBS-list':
-
- $ awk 'BEGIN { RS = "/" }
- > { print $0 }' BBS-list
- -| aardvark 555-5553 1200
- -| 300 B
- -| alpo-net 555-3412 2400
- -| 1200
- -| 300 A
- -| barfly 555-7685 1200
- -| 300 A
- -| bites 555-1675 2400
- -| 1200
- -| 300 A
- -| camelot 555-0542 300 C
- -| core 555-2912 1200
- -| 300 C
- -| fooey 555-1234 2400
- -| 1200
- -| 300 B
- -| foot 555-6699 1200
- -| 300 B
- -| macfoo 555-6480 1200
- -| 300 A
- -| sdace 555-3430 2400
- -| 1200
- -| 300 A
- -| sabafoo 555-2127 1200
- -| 300 C
- -|
-
-Note that the entry for the `camelot' BBS is not split. In the
-original data file (*note Sample Data Files::), the line looks like
-this:
-
- camelot 555-0542 300 C
-
-It has one baud rate only, so there are no slashes in the record,
-unlike the others which have two or more baud rates. In fact, this
-record is treated as part of the record for the `core' BBS; the newline
-separating them in the output is the original newline in the data file,
-not the one added by `awk' when it printed the record!
-
- Another way to change the record separator is on the command line,
-using the variable-assignment feature (*note Other Arguments::):
-
- awk '{ print $0 }' RS="/" BBS-list
-
-This sets `RS' to `/' before processing `BBS-list'.
-
- Using an unusual character such as `/' for the record separator
-produces correct behavior in the vast majority of cases. However, the
-following (extreme) pipeline prints a surprising `1':
-
- $ echo | awk 'BEGIN { RS = "a" } ; { print NF }'
- -| 1
-
- There is one field, consisting of a newline. The value of the
-built-in variable `NF' is the number of fields in the current record.
-
- Reaching the end of an input file terminates the current input
-record, even if the last character in the file is not the character in
-`RS'. (d.c.)
-
- The empty string `""' (a string without any characters) has a
-special meaning as the value of `RS'. It means that records are
-separated by one or more blank lines and nothing else. *Note Multiple
-Line::, for more details.
-
- If you change the value of `RS' in the middle of an `awk' run, the
-new value is used to delimit subsequent records, but the record
-currently being processed, as well as records already processed, are not
-affected.
-
- After the end of the record has been determined, `gawk' sets the
-variable `RT' to the text in the input that matched `RS'. When using
-`gawk', the value of `RS' is not limited to a one-character string. It
-can be any regular expression (*note Regexp::). In general, each record
-ends at the next string that matches the regular expression; the next
-record starts at the end of the matching string. This general rule is
-actually at work in the usual case, where `RS' contains just a newline:
-a record ends at the beginning of the next matching string (the next
-newline in the input), and the following record starts just after the
-end of this string (at the first character of the following line). The
-newline, because it matches `RS', is not part of either record.
-
- When `RS' is a single character, `RT' contains the same single
-character. However, when `RS' is a regular expression, `RT' contains
-the actual input text that matched the regular expression.
-
- The following example illustrates both of these features. It sets
-`RS' equal to a regular expression that matches either a newline or a
-series of one or more uppercase letters with optional leading and/or
-trailing whitespace:
-
- $ echo record 1 AAAA record 2 BBBB record 3 |
- > gawk 'BEGIN { RS = "\n|( *[[:upper:]]+ *)" }
- > { print "Record =", $0, "and RT =", RT }'
- -| Record = record 1 and RT = AAAA
- -| Record = record 2 and RT = BBBB
- -| Record = record 3 and RT =
- -|
-
-The final line of output has an extra blank line. This is because the
-value of `RT' is a newline, and the `print' statement supplies its own
-terminating newline. *Note Simple Sed::, for a more useful example of
-`RS' as a regexp and `RT'.
-
- If you set `RS' to a regular expression that allows optional
-trailing text, such as `RS = "abc(XYZ)?"' it is possible, due to
-implementation constraints, that `gawk' may match the leading part of
-the regular expression, but not the trailing part, particularly if the
-input text that could match the trailing part is fairly long. `gawk'
-attempts to avoid this problem, but currently, there's no guarantee
-that this will never happen.
-
- The use of `RS' as a regular expression and the `RT' variable are
-`gawk' extensions; they are not available in compatibility mode (*note
-Options::). In compatibility mode, only the first character of the
-value of `RS' is used to determine the end of the record.
-
-Advanced Notes: `RS = "\0"' Is Not Portable
--------------------------------------------
-
-There are times when you might want to treat an entire data file as a
-single record. The only way to make this happen is to give `RS' a
-value that you know doesn't occur in the input file. This is hard to
-do in a general way, such that a program always works for arbitrary
-input files.
-
- You might think that for text files, the NUL character, which
-consists of a character with all bits equal to zero, is a good value to
-use for `RS' in this case:
-
- BEGIN { RS = "\0" } # whole file becomes one record?
-
- `gawk' in fact accepts this, and uses the NUL character for the
-record separator. However, this usage is _not_ portable to other `awk'
-implementations.
-
- All other `awk' implementations(1) store strings internally as
-C-style strings. C strings use the NUL character as the string
-terminator. In effect, this means that `RS = "\0"' is the same as `RS
-= ""'. (d.c.)
-
- The best way to treat a whole file as a single record is to simply
-read the file in, one record at a time, concatenating each record onto
-the end of the previous ones.
-
- ---------- Footnotes ----------
-
- (1) At least that we know about.
-
-3.2 Examining Fields
-====================
-
-When `awk' reads an input record, the record is automatically "parsed"
-or separated by the interpreter into chunks called "fields". By
-default, fields are separated by "whitespace", like words in a line.
-Whitespace in `awk' means any string of one or more spaces, tabs, or
-newlines;(1) other characters, such as formfeed, vertical tab, etc.
-that are considered whitespace by other languages, are _not_ considered
-whitespace by `awk'.
-
- The purpose of fields is to make it more convenient for you to refer
-to these pieces of the record. You don't have to use them--you can
-operate on the whole record if you want--but fields are what make
-simple `awk' programs so powerful.
-
- A dollar-sign (`$') is used to refer to a field in an `awk' program,
-followed by the number of the field you want. Thus, `$1' refers to the
-first field, `$2' to the second, and so on. (Unlike the Unix shells,
-the field numbers are not limited to single digits. `$127' is the one
-hundred twenty-seventh field in the record.) For example, suppose the
-following is a line of input:
-
- This seems like a pretty nice example.
-
-Here the first field, or `$1', is `This', the second field, or `$2', is
-`seems', and so on. Note that the last field, `$7', is `example.'.
-Because there is no space between the `e' and the `.', the period is
-considered part of the seventh field.
-
- `NF' is a built-in variable whose value is the number of fields in
-the current record. `awk' automatically updates the value of `NF' each
-time it reads a record. No matter how many fields there are, the last
-field in a record can be represented by `$NF'. So, `$NF' is the same
-as `$7', which is `example.'. If you try to reference a field beyond
-the last one (such as `$8' when the record has only seven fields), you
-get the empty string. (If used in a numeric operation, you get zero.)
-
- The use of `$0', which looks like a reference to the "zero-th"
-field, is a special case: it represents the whole input record when you
-are not interested in specific fields. Here are some more examples:
-
- $ awk '$1 ~ /foo/ { print $0 }' BBS-list
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sabafoo 555-2127 1200/300 C
-
-This example prints each record in the file `BBS-list' whose first
-field contains the string `foo'. The operator `~' is called a
-"matching operator" (*note Regexp Usage::); it tests whether a string
-(here, the field `$1') matches a given regular expression.
-
- By contrast, the following example looks for `foo' in _the entire
-record_ and prints the first field and the last field for each matching
-input record:
-
- $ awk '/foo/ { print $1, $NF }' BBS-list
- -| fooey B
- -| foot B
- -| macfoo A
- -| sabafoo C
-
- ---------- Footnotes ----------
-
- (1) In POSIX `awk', newlines are not considered whitespace for
-separating fields.
-
-3.3 Nonconstant Field Numbers
-=============================
-
-The number of a field does not need to be a constant. Any expression in
-the `awk' language can be used after a `$' to refer to a field. The
-value of the expression specifies the field number. If the value is a
-string, rather than a number, it is converted to a number. Consider
-this example:
-
- awk '{ print $NR }'
-
-Recall that `NR' is the number of records read so far: one in the first
-record, two in the second, etc. So this example prints the first field
-of the first record, the second field of the second record, and so on.
-For the twentieth record, field number 20 is printed; most likely, the
-record has fewer than 20 fields, so this prints a blank line. Here is
-another example of using expressions as field numbers:
-
- awk '{ print $(2*2) }' BBS-list
-
- `awk' evaluates the expression `(2*2)' and uses its value as the
-number of the field to print. The `*' sign represents multiplication,
-so the expression `2*2' evaluates to four. The parentheses are used so
-that the multiplication is done before the `$' operation; they are
-necessary whenever there is a binary operator in the field-number
-expression. This example, then, prints the hours of operation (the
-fourth field) for every line of the file `BBS-list'. (All of the `awk'
-operators are listed, in order of decreasing precedence, in *Note
-Precedence::.)
-
- If the field number you compute is zero, you get the entire record.
-Thus, `$(2-2)' has the same value as `$0'. Negative field numbers are
-not allowed; trying to reference one usually terminates the program.
-(The POSIX standard does not define what happens when you reference a
-negative field number. `gawk' notices this and terminates your
-program. Other `awk' implementations may behave differently.)
-
- As mentioned in *Note Fields::, `awk' stores the current record's
-number of fields in the built-in variable `NF' (also *note Built-in
-Variables::). The expression `$NF' is not a special feature--it is the
-direct consequence of evaluating `NF' and using its value as a field
-number.
-
-3.4 Changing the Contents of a Field
-====================================
-
-The contents of a field, as seen by `awk', can be changed within an
-`awk' program; this changes what `awk' perceives as the current input
-record. (The actual input is untouched; `awk' _never_ modifies the
-input file.) Consider the following example and its output:
-
- $ awk '{ nboxes = $3 ; $3 = $3 - 10
- > print nboxes, $3 }' inventory-shipped
- -| 25 15
- -| 32 22
- -| 24 14
- ...
-
-The program first saves the original value of field three in the
-variable `nboxes'. The `-' sign represents subtraction, so this
-program reassigns field three, `$3', as the original value of field
-three minus ten: `$3 - 10'. (*Note Arithmetic Ops::.) Then it prints
-the original and new values for field three. (Someone in the warehouse
-made a consistent mistake while inventorying the red boxes.)
-
- For this to work, the text in field `$3' must make sense as a
-number; the string of characters must be converted to a number for the
-computer to do arithmetic on it. The number resulting from the
-subtraction is converted back to a string of characters that then
-becomes field three. *Note Conversion::.
-
- When the value of a field is changed (as perceived by `awk'), the
-text of the input record is recalculated to contain the new field where
-the old one was. In other words, `$0' changes to reflect the altered
-field. Thus, this program prints a copy of the input file, with 10
-subtracted from the second field of each line:
-
- $ awk '{ $2 = $2 - 10; print $0 }' inventory-shipped
- -| Jan 3 25 15 115
- -| Feb 5 32 24 226
- -| Mar 5 24 34 228
- ...
-
- It is also possible to also assign contents to fields that are out
-of range. For example:
-
- $ awk '{ $6 = ($5 + $4 + $3 + $2)
- > print $6 }' inventory-shipped
- -| 168
- -| 297
- -| 301
- ...
-
-We've just created `$6', whose value is the sum of fields `$2', `$3',
-`$4', and `$5'. The `+' sign represents addition. For the file
-`inventory-shipped', `$6' represents the total number of parcels
-shipped for a particular month.
-
- Creating a new field changes `awk''s internal copy of the current
-input record, which is the value of `$0'. Thus, if you do `print $0'
-after adding a field, the record printed includes the new field, with
-the appropriate number of field separators between it and the previously
-existing fields.
-
- This recomputation affects and is affected by `NF' (the number of
-fields; *note Fields::). For example, the value of `NF' is set to the
-number of the highest field you create. The exact format of `$0' is
-also affected by a feature that has not been discussed yet: the "output
-field separator", `OFS', used to separate the fields (*note Output
-Separators::).
-
- Note, however, that merely _referencing_ an out-of-range field does
-_not_ change the value of either `$0' or `NF'. Referencing an
-out-of-range field only produces an empty string. For example:
-
- if ($(NF+1) != "")
- print "can't happen"
- else
- print "everything is normal"
-
-should print `everything is normal', because `NF+1' is certain to be
-out of range. (*Note If Statement::, for more information about
-`awk''s `if-else' statements. *Note Typing and Comparison::, for more
-information about the `!=' operator.)
-
- It is important to note that making an assignment to an existing
-field changes the value of `$0' but does not change the value of `NF',
-even when you assign the empty string to a field. For example:
-
- $ echo a b c d | awk '{ OFS = ":"; $2 = ""
- > print $0; print NF }'
- -| a::c:d
- -| 4
-
-The field is still there; it just has an empty value, denoted by the
-two colons between `a' and `c'. This example shows what happens if you
-create a new field:
-
- $ echo a b c d | awk '{ OFS = ":"; $2 = ""; $6 = "new"
- > print $0; print NF }'
- -| a::c:d::new
- -| 6
-
-The intervening field, `$5', is created with an empty value (indicated
-by the second pair of adjacent colons), and `NF' is updated with the
-value six.
-
- Decrementing `NF' throws away the values of the fields after the new
-value of `NF' and recomputes `$0'. (d.c.) Here is an example:
-
- $ echo a b c d e f | awk '{ print "NF =", NF;
- > NF = 3; print $0 }'
- -| NF = 6
- -| a b c
-
- *Caution:* Some versions of `awk' don't rebuild `$0' when `NF' is
-decremented. Caveat emptor.
-
- Finally, there are times when it is convenient to force `awk' to
-rebuild the entire record, using the current value of the fields and
-`OFS'. To do this, use the seemingly innocuous assignment:
-
- $1 = $1 # force record to be reconstituted
- print $0 # or whatever else with $0
-
-This forces `awk' rebuild the record. It does help to add a comment,
-as we've shown here.
-
- There is a flip side to the relationship between `$0' and the
-fields. Any assignment to `$0' causes the record to be reparsed into
-fields using the _current_ value of `FS'. This also applies to any
-built-in function that updates `$0', such as `sub' and `gsub' (*note
-String Functions::).
-
-3.5 Specifying How Fields Are Separated
-=======================================
-
-The "field separator", which is either a single character or a regular
-expression, controls the way `awk' splits an input record into fields.
-`awk' scans the input record for character sequences that match the
-separator; the fields themselves are the text between the matches.
-
- In the examples that follow, we use the bullet symbol (*) to
-represent spaces in the output. If the field separator is `oo', then
-the following line:
-
- moo goo gai pan
-
-is split into three fields: `m', `*g', and `*gai*pan'. Note the
-leading spaces in the values of the second and third fields.
-
- The field separator is represented by the built-in variable `FS'.
-Shell programmers take note: `awk' does _not_ use the name `IFS' that
-is used by the POSIX-compliant shells (such as the Unix Bourne shell,
-`sh', or `bash').
-
- The value of `FS' can be changed in the `awk' program with the
-assignment operator, `=' (*note Assignment Ops::). Often the right
-time to do this is at the beginning of execution before any input has
-been processed, so that the very first record is read with the proper
-separator. To do this, use the special `BEGIN' pattern (*note
-BEGIN/END::). For example, here we set the value of `FS' to the string
-`","':
-
- awk 'BEGIN { FS = "," } ; { print $2 }'
-
-Given the input line:
-
- John Q. Smith, 29 Oak St., Walamazoo, MI 42139
-
-this `awk' program extracts and prints the string `*29*Oak*St.'.
-
- Sometimes the input data contains separator characters that don't
-separate fields the way you thought they would. For instance, the
-person's name in the example we just used might have a title or suffix
-attached, such as:
-
- John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139
-
-The same program would extract `*LXIX', instead of `*29*Oak*St.'. If
-you were expecting the program to print the address, you would be
-surprised. The moral is to choose your data layout and separator
-characters carefully to prevent such problems. (If the data is not in
-a form that is easy to process, perhaps you can massage it first with a
-separate `awk' program.)
-
- Fields are normally separated by whitespace sequences (spaces, tabs,
-and newlines), not by single spaces. Two spaces in a row do not
-delimit an empty field. The default value of the field separator `FS'
-is a string containing a single space, `" "'. If `awk' interpreted
-this value in the usual way, each space character would separate
-fields, so two spaces in a row would make an empty field between them.
-The reason this does not happen is that a single space as the value of
-`FS' is a special case--it is taken to specify the default manner of
-delimiting fields.
-
- If `FS' is any other single character, such as `","', then each
-occurrence of that character separates two fields. Two consecutive
-occurrences delimit an empty field. If the character occurs at the
-beginning or the end of the line, that too delimits an empty field. The
-space character is the only single character that does not follow these
-rules.
-
-3.5.1 Using Regular Expressions to Separate Fields
---------------------------------------------------
-
-The previous node discussed the use of single characters or simple
-strings as the value of `FS'. More generally, the value of `FS' may be
-a string containing any regular expression. In this case, each match
-in the record for the regular expression separates fields. For
-example, the assignment:
-
- FS = ", \t"
-
-makes every area of an input line that consists of a comma followed by a
-space and a TAB into a field separator. (`\t' is an "escape sequence"
-that stands for a TAB; *note Escape Sequences::, for the complete list
-of similar escape sequences.)
-
- For a less trivial example of a regular expression, try using single
-spaces to separate fields the way single commas are used. `FS' can be
-set to `"[ ]"' (left bracket, space, right bracket). This regular
-expression matches a single space and nothing else (*note Regexp::).
-
- There is an important difference between the two cases of `FS = " "'
-(a single space) and `FS = "[ \t\n]+"' (a regular expression matching
-one or more spaces, tabs, or newlines). For both values of `FS',
-fields are separated by "runs" (multiple adjacent occurrences) of
-spaces, tabs, and/or newlines. However, when the value of `FS' is
-`" "', `awk' first strips leading and trailing whitespace from the
-record and then decides where the fields are. For example, the
-following pipeline prints `b':
-
- $ echo ' a b c d ' | awk '{ print $2 }'
- -| b
-
-However, this pipeline prints `a' (note the extra spaces around each
-letter):
-
- $ echo ' a b c d ' | awk 'BEGIN { FS = "[ \t\n]+" }
- > { print $2 }'
- -| a
-
-In this case, the first field is "null" or empty.
-
- The stripping of leading and trailing whitespace also comes into
-play whenever `$0' is recomputed. For instance, study this pipeline:
-
- $ echo ' a b c d' | awk '{ print; $2 = $2; print }'
- -| a b c d
- -| a b c d
-
-The first `print' statement prints the record as it was read, with
-leading whitespace intact. The assignment to `$2' rebuilds `$0' by
-concatenating `$1' through `$NF' together, separated by the value of
-`OFS'. Because the leading whitespace was ignored when finding `$1',
-it is not part of the new `$0'. Finally, the last `print' statement
-prints the new `$0'.
-
-3.5.2 Making Each Character a Separate Field
---------------------------------------------
-
-There are times when you may want to examine each character of a record
-separately. This can be done in `gawk' by simply assigning the null
-string (`""') to `FS'. In this case, each individual character in the
-record becomes a separate field. For example:
-
- $ echo a b | gawk 'BEGIN { FS = "" }
- > {
- > for (i = 1; i <= NF; i = i + 1)
- > print "Field", i, "is", $i
- > }'
- -| Field 1 is a
- -| Field 2 is
- -| Field 3 is b
-
- Traditionally, the behavior of `FS' equal to `""' was not defined.
-In this case, most versions of Unix `awk' simply treat the entire record
-as only having one field. (d.c.) In compatibility mode (*note
-Options::), if `FS' is the null string, then `gawk' also behaves this
-way.
-
-3.5.3 Setting `FS' from the Command Line
-----------------------------------------
-
-`FS' can be set on the command line. Use the `-F' option to do so.
-For example:
-
- awk -F, 'PROGRAM' INPUT-FILES
-
-sets `FS' to the `,' character. Notice that the option uses an
-uppercase `F' instead of a lowercase `f'. The latter option (`-f')
-specifies a file containing an `awk' program. Case is significant in
-command-line options: the `-F' and `-f' options have nothing to do with
-each other. You can use both options at the same time to set the `FS'
-variable _and_ get an `awk' program from a file.
-
- The value used for the argument to `-F' is processed in exactly the
-same way as assignments to the built-in variable `FS'. Any special
-characters in the field separator must be escaped appropriately. For
-example, to use a `\' as the field separator on the command line, you
-would have to type:
-
- # same as FS = "\\"
- awk -F\\\\ '...' files ...
-
-Because `\' is used for quoting in the shell, `awk' sees `-F\\'. Then
-`awk' processes the `\\' for escape characters (*note Escape
-Sequences::), finally yielding a single `\' to use for the field
-separator.
-
- As a special case, in compatibility mode (*note Options::), if the
-argument to `-F' is `t', then `FS' is set to the TAB character. If you
-type `-F\t' at the shell, without any quotes, the `\' gets deleted, so
-`awk' figures that you really want your fields to be separated with
-tabs and not `t's. Use `-v FS="t"' or `-F"[t]"' on the command line if
-you really do want to separate your fields with `t's.
-
- For example, let's use an `awk' program file called `baud.awk' that
-contains the pattern `/300/' and the action `print $1':
-
- /300/ { print $1 }
-
- Let's also set `FS' to be the `-' character and run the program on
-the file `BBS-list'. The following command prints a list of the names
-of the bulletin boards that operate at 300 baud and the first three
-digits of their phone numbers:
-
- $ awk -F- -f baud.awk BBS-list
- -| aardvark 555
- -| alpo
- -| barfly 555
- -| bites 555
- -| camelot 555
- -| core 555
- -| fooey 555
- -| foot 555
- -| macfoo 555
- -| sdace 555
- -| sabafoo 555
-
-Note the second line of output. The second line in the original file
-looked like this:
-
- alpo-net 555-3412 2400/1200/300 A
-
- The `-' as part of the system's name was used as the field
-separator, instead of the `-' in the phone number that was originally
-intended. This demonstrates why you have to be careful in choosing
-your field and record separators.
-
- Perhaps the most common use of a single character as the field
-separator occurs when processing the Unix system password file. On
-many Unix systems, each user has a separate entry in the system password
-file, one line per user. The information in these lines is separated
-by colons. The first field is the user's logon name and the second is
-the user's (encrypted or shadow) password. A password file entry might
-look like this:
-
- arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/bash
-
- The following program searches the system password file and prints
-the entries for users who have no password:
-
- awk -F: '$2 == ""' /etc/passwd
-
-3.5.4 Field-Splitting Summary
------------------------------
-
-It is important to remember that when you assign a string constant as
-the value of `FS', it undergoes normal `awk' string processing. For
-example, with Unix `awk' and `gawk', the assignment `FS = "\.."'
-assigns the character string `".."' to `FS' (the backslash is
-stripped). This creates a regexp meaning "fields are separated by
-occurrences of any two characters." If instead you want fields to be
-separated by a literal period followed by any single character, use `FS
-= "\\.."'.
-
- The following table summarizes how fields are split, based on the
-value of `FS' (`==' means "is equal to"):
-
-`FS == " "'
- Fields are separated by runs of whitespace. Leading and trailing
- whitespace are ignored. This is the default.
-
-`FS == ANY OTHER SINGLE CHARACTER'
- Fields are separated by each occurrence of the character. Multiple
- successive occurrences delimit empty fields, as do leading and
- trailing occurrences. The character can even be a regexp
- metacharacter; it does not need to be escaped.
-
-`FS == REGEXP'
- Fields are separated by occurrences of characters that match
- REGEXP. Leading and trailing matches of REGEXP delimit empty
- fields.
-
-`FS == ""'
- Each individual character in the record becomes a separate field.
- (This is a `gawk' extension; it is not specified by the POSIX
- standard.)
-
-Advanced Notes: Changing `FS' Does Not Affect the Fields
---------------------------------------------------------
-
-According to the POSIX standard, `awk' is supposed to behave as if each
-record is split into fields at the time it is read. In particular,
-this means that if you change the value of `FS' after a record is read,
-the value of the fields (i.e., how they were split) should reflect the
-old value of `FS', not the new one.
-
- However, many implementations of `awk' do not work this way.
-Instead, they defer splitting the fields until a field is actually
-referenced. The fields are split using the _current_ value of `FS'!
-(d.c.) This behavior can be difficult to diagnose. The following
-example illustrates the difference between the two methods. (The
-`sed'(1) command prints just the first line of `/etc/passwd'.)
-
- sed 1q /etc/passwd | awk '{ FS = ":" ; print $1 }'
-
-which usually prints:
-
- root
-
-on an incorrect implementation of `awk', while `gawk' prints something
-like:
-
- root:nSijPlPhZZwgE:0:0:Root:/:
-
-Advanced Notes: `FS' and `IGNORECASE'
--------------------------------------
-
-The `IGNORECASE' variable (*note User-modified::) affects field
-splitting _only_ when the value of `FS' is a regexp. It has no effect
-when `FS' is a single character, even if that character is a letter.
-Thus, in the following code:
-
- FS = "c"
- IGNORECASE = 1
- $0 = "aCa"
- print $1
-
-The output is `aCa'. If you really want to split fields on an
-alphabetic character while ignoring case, use a regexp that will do it
-for you. E.g., `FS = "[c]"'. In this case, `IGNORECASE' will take
-effect.
-
- ---------- Footnotes ----------
-
- (1) The `sed' utility is a "stream editor." Its behavior is also
-defined by the POSIX standard.
-
-3.6 Reading Fixed-Width Data
-============================
-
-(This minor node discusses an advanced feature of `awk'. If you are a
-novice `awk' user, you might want to skip it on the first reading.)
-
-`gawk' version 2.13 introduced a facility for dealing with fixed-width
-fields with no distinctive field separator. For example, data of this
-nature arises in the input for old Fortran programs where numbers are
-run together, or in the output of programs that did not anticipate the
-use of their output as input for other programs.
-
- An example of the latter is a table where all the columns are lined
-up by the use of a variable number of spaces and _empty fields are just
-spaces_. Clearly, `awk''s normal field splitting based on `FS' does
-not work well in this case. Although a portable `awk' program can use
-a series of `substr' calls on `$0' (*note String Functions::), this is
-awkward and inefficient for a large number of fields.
-
- The splitting of an input record into fixed-width fields is
-specified by assigning a string containing space-separated numbers to
-the built-in variable `FIELDWIDTHS'. Each number specifies the width
-of the field, _including_ columns between fields. If you want to
-ignore the columns between fields, you can specify the width as a
-separate field that is subsequently ignored. It is a fatal error to
-supply a field width that is not a positive number. The following data
-is the output of the Unix `w' utility. It is useful to illustrate the
-use of `FIELDWIDTHS':
-
- 10:06pm up 21 days, 14:04, 23 users
- User tty login idle JCPU PCPU what
- hzuo ttyV0 8:58pm 9 5 vi p24.tex
- hzang ttyV3 6:37pm 50 -csh
- eklye ttyV5 9:53pm 7 1 em thes.tex
- dportein ttyV6 8:17pm 1:47 -csh
- gierd ttyD3 10:00pm 1 elm
- dave ttyD4 9:47pm 4 4 w
- brent ttyp0 26Jun91 4:46 26:46 4:41 bash
- dave ttyq4 26Jun9115days 46 46 wnewmail
-
- The following program takes the above input, converts the idle time
-to number of seconds, and prints out the first two fields and the
-calculated idle time:
-
- NOTE: This program uses a number of `awk' features that haven't
- been introduced yet.
-
- BEGIN { FIELDWIDTHS = "9 6 10 6 7 7 35" }
- NR > 2 {
- idle = $4
- sub(/^ */, "", idle) # strip leading spaces
- if (idle == "")
- idle = 0
- if (idle ~ /:/) {
- split(idle, t, ":")
- idle = t[1] * 60 + t[2]
- }
- if (idle ~ /days/)
- idle *= 24 * 60 * 60
-
- print $1, $2, idle
- }
-
- Running the program on the data produces the following results:
-
- hzuo ttyV0 0
- hzang ttyV3 50
- eklye ttyV5 0
- dportein ttyV6 107
- gierd ttyD3 1
- dave ttyD4 0
- brent ttyp0 286
- dave ttyq4 1296000
-
- Another (possibly more practical) example of fixed-width input data
-is the input from a deck of balloting cards. In some parts of the
-United States, voters mark their choices by punching holes in computer
-cards. These cards are then processed to count the votes for any
-particular candidate or on any particular issue. Because a voter may
-choose not to vote on some issue, any column on the card may be empty.
-An `awk' program for processing such data could use the `FIELDWIDTHS'
-feature to simplify reading the data. (Of course, getting `gawk' to
-run on a system with card readers is another story!)
-
- Assigning a value to `FS' causes `gawk' to use `FS' for field
-splitting again. Use `FS = FS' to make this happen, without having to
-know the current value of `FS'. In order to tell which kind of field
-splitting is in effect, use `PROCINFO["FS"]' (*note Auto-set::). The
-value is `"FS"' if regular field splitting is being used, or it is
-`"FIELDWIDTHS"' if fixed-width field splitting is being used:
-
- if (PROCINFO["FS"] == "FS")
- REGULAR FIELD SPLITTING ...
- else
- FIXED-WIDTH FIELD SPLITTING ...
-
- This information is useful when writing a function that needs to
-temporarily change `FS' or `FIELDWIDTHS', read some records, and then
-restore the original settings (*note Passwd Functions::, for an example
-of such a function).
-
-3.7 Multiple-Line Records
-=========================
-
-In some databases, a single line cannot conveniently hold all the
-information in one entry. In such cases, you can use multiline
-records. The first step in doing this is to choose your data format.
-
- One technique is to use an unusual character or string to separate
-records. For example, you could use the formfeed character (written
-`\f' in `awk', as in C) to separate them, making each record a page of
-the file. To do this, just set the variable `RS' to `"\f"' (a string
-containing the formfeed character). Any other character could equally
-well be used, as long as it won't be part of the data in a record.
-
- Another technique is to have blank lines separate records. By a
-special dispensation, an empty string as the value of `RS' indicates
-that records are separated by one or more blank lines. When `RS' is set
-to the empty string, each record always ends at the first blank line
-encountered. The next record doesn't start until the first nonblank
-line that follows. No matter how many blank lines appear in a row, they
-all act as one record separator. (Blank lines must be completely
-empty; lines that contain only whitespace do not count.)
-
- You can achieve the same effect as `RS = ""' by assigning the string
-`"\n\n+"' to `RS'. This regexp matches the newline at the end of the
-record and one or more blank lines after the record. In addition, a
-regular expression always matches the longest possible sequence when
-there is a choice (*note Leftmost Longest::). So the next record
-doesn't start until the first nonblank line that follows--no matter how
-many blank lines appear in a row, they are considered one record
-separator.
-
- There is an important difference between `RS = ""' and `RS =
-"\n\n+"'. In the first case, leading newlines in the input data file
-are ignored, and if a file ends without extra blank lines after the
-last record, the final newline is removed from the record. In the
-second case, this special processing is not done. (d.c.)
-
- Now that the input is separated into records, the second step is to
-separate the fields in the record. One way to do this is to divide each
-of the lines into fields in the normal manner. This happens by default
-as the result of a special feature. When `RS' is set to the empty
-string, _and_ `FS' is a set to a single character, the newline
-character _always_ acts as a field separator. This is in addition to
-whatever field separations result from `FS'.(1)
-
- The original motivation for this special exception was probably to
-provide useful behavior in the default case (i.e., `FS' is equal to
-`" "'). This feature can be a problem if you really don't want the
-newline character to separate fields, because there is no way to
-prevent it. However, you can work around this by using the `split'
-function to break up the record manually (*note String Functions::).
-If you have a single character field separator, you can work around the
-special feature in a different way, by making `FS' into a regexp for
-that single character. For example, if the field separator is a
-percent character, instead of `FS = "%"', use `FS = "[%]"'.
-
- Another way to separate fields is to put each field on a separate
-line: to do this, just set the variable `FS' to the string `"\n"'.
-(This single character seperator matches a single newline.) A
-practical example of a data file organized this way might be a mailing
-list, where each entry is separated by blank lines. Consider a mailing
-list in a file named `addresses', which looks like this:
-
- Jane Doe
- 123 Main Street
- Anywhere, SE 12345-6789
-
- John Smith
- 456 Tree-lined Avenue
- Smallville, MW 98765-4321
- ...
-
-A simple program to process this file is as follows:
-
- # addrs.awk --- simple mailing list program
-
- # Records are separated by blank lines.
- # Each line is one field.
- BEGIN { RS = "" ; FS = "\n" }
-
- {
- print "Name is:", $1
- print "Address is:", $2
- print "City and State are:", $3
- print ""
- }
-
- Running the program produces the following output:
-
- $ awk -f addrs.awk addresses
- -| Name is: Jane Doe
- -| Address is: 123 Main Street
- -| City and State are: Anywhere, SE 12345-6789
- -|
- -| Name is: John Smith
- -| Address is: 456 Tree-lined Avenue
- -| City and State are: Smallville, MW 98765-4321
- -|
- ...
-
- *Note Labels Program::, for a more realistic program that deals with
-address lists. The following table summarizes how records are split,
-based on the value of `RS'. (`==' means "is equal to.")
-
-`RS == "\n"'
- Records are separated by the newline character (`\n'). In effect,
- every line in the data file is a separate record, including blank
- lines. This is the default.
-
-`RS == ANY SINGLE CHARACTER'
- Records are separated by each occurrence of the character.
- Multiple successive occurrences delimit empty records.
-
-`RS == ""'
- Records are separated by runs of blank lines. The newline
- character always serves as a field separator, in addition to
- whatever value `FS' may have. Leading and trailing newlines in a
- file are ignored.
-
-`RS == REGEXP'
- Records are separated by occurrences of characters that match
- REGEXP. Leading and trailing matches of REGEXP delimit empty
- records. (This is a `gawk' extension; it is not specified by the
- POSIX standard.)
-
- In all cases, `gawk' sets `RT' to the input text that matched the
-value specified by `RS'.
-
- ---------- Footnotes ----------
-
- (1) When `FS' is the null string (`""') or a regexp, this special
-feature of `RS' does not apply. It does apply to the default field
-separator of a single space: `FS = " "'.
-
-3.8 Explicit Input with `getline'
-=================================
-
-So far we have been getting our input data from `awk''s main input
-stream--either the standard input (usually your terminal, sometimes the
-output from another program) or from the files specified on the command
-line. The `awk' language has a special built-in command called
-`getline' that can be used to read input under your explicit control.
-
- The `getline' command is used in several different ways and should
-_not_ be used by beginners. The examples that follow the explanation
-of the `getline' command include material that has not been covered
-yet. Therefore, come back and study the `getline' command _after_ you
-have reviewed the rest of this Info file and have a good knowledge of
-how `awk' works.
-
- The `getline' command returns one if it finds a record and zero if
-it encounters the end of the file. If there is some error in getting a
-record, such as a file that cannot be opened, then `getline' returns
--1. In this case, `gawk' sets the variable `ERRNO' to a string
-describing the error that occurred.
-
- In the following examples, COMMAND stands for a string value that
-represents a shell command.
-
-3.8.1 Using `getline' with No Arguments
----------------------------------------
-
-The `getline' command can be used without arguments to read input from
-the current input file. All it does in this case is read the next
-input record and split it up into fields. This is useful if you've
-finished processing the current record, but want to do some special
-processing on the next record _right now_. For example:
-
- {
- if ((t = index($0, "/*")) != 0) {
- # value of `tmp' will be "" if t is 1
- tmp = substr($0, 1, t - 1)
- u = index(substr($0, t + 2), "*/")
- while (u == 0) {
- if (getline <= 0) {
- m = "unexpected EOF or error"
- m = (m ": " ERRNO)
- print m > "/dev/stderr"
- exit
- }
- t = -1
- u = index($0, "*/")
- }
- # substr expression will be "" if */
- # occurred at end of line
- $0 = tmp substr($0, u + 2)
- }
- print $0
- }
-
- This `awk' program deletes all C-style comments (`/* ... */') from
-the input. By replacing the `print $0' with other statements, you
-could perform more complicated processing on the decommented input,
-such as searching for matches of a regular expression. (This program
-has a subtle problem--it does not work if one comment ends and another
-begins on the same line.)
-
- This form of the `getline' command sets `NF', `NR', `FNR', and the
-value of `$0'.
-
- NOTE: The new value of `$0' is used to test the patterns of any
- subsequent rules. The original value of `$0' that triggered the
- rule that executed `getline' is lost. By contrast, the `next'
- statement reads a new record but immediately begins processing it
- normally, starting with the first rule in the program. *Note Next
- Statement::.
-
-3.8.2 Using `getline' into a Variable
--------------------------------------
-
-You can use `getline VAR' to read the next record from `awk''s input
-into the variable VAR. No other processing is done. For example,
-suppose the next line is a comment or a special string, and you want to
-read it without triggering any rules. This form of `getline' allows
-you to read that line and store it in a variable so that the main
-read-a-line-and-check-each-rule loop of `awk' never sees it. The
-following example swaps every two lines of input:
-
- {
- if ((getline tmp) > 0) {
- print tmp
- print $0
- } else
- print $0
- }
-
-It takes the following list:
-
- wan
- tew
- free
- phore
-
-and produces these results:
-
- tew
- wan
- phore
- free
-
- The `getline' command used in this way sets only the variables `NR'
-and `FNR' (and of course, VAR). The record is not split into fields,
-so the values of the fields (including `$0') and the value of `NF' do
-not change.
-
-3.8.3 Using `getline' from a File
----------------------------------
-
-Use `getline < FILE' to read the next record from FILE. Here FILE is a
-string-valued expression that specifies the file name. `< FILE' is
-called a "redirection" because it directs input to come from a
-different place. For example, the following program reads its input
-record from the file `secondary.input' when it encounters a first field
-with a value equal to 10 in the current input file:
-
- {
- if ($1 == 10) {
- getline < "secondary.input"
- print
- } else
- print
- }
-
- Because the main input stream is not used, the values of `NR' and
-`FNR' are not changed. However, the record it reads is split into
-fields in the normal manner, so the values of `$0' and the other fields
-are changed, resulting in a new value of `NF'.
-
- According to POSIX, `getline < EXPRESSION' is ambiguous if
-EXPRESSION contains unparenthesized operators other than `$'; for
-example, `getline < dir "/" file' is ambiguous because the
-concatenation operator is not parenthesized. You should write it as
-`getline < (dir "/" file)' if you want your program to be portable to
-other `awk' implementations.
-
-3.8.4 Using `getline' into a Variable from a File
--------------------------------------------------
-
-Use `getline VAR < FILE' to read input from the file FILE, and put it
-in the variable VAR. As above, FILE is a string-valued expression that
-specifies the file from which to read.
-
- In this version of `getline', none of the built-in variables are
-changed and the record is not split into fields. The only variable
-changed is VAR. For example, the following program copies all the
-input files to the output, except for records that say
address@hidden FILENAME'. Such a record is replaced by the contents of the
-file FILENAME:
-
- {
- if (NF == 2 && $1 == "@include") {
- while ((getline line < $2) > 0)
- print line
- close($2)
- } else
- print
- }
-
- Note here how the name of the extra input file is not built into the
-program; it is taken directly from the data, specifically from the
-second field on the address@hidden' line.
-
- The `close' function is called to ensure that if two identical
address@hidden' lines appear in the input, the entire specified file is
-included twice. *Note Close Files And Pipes::.
-
- One deficiency of this program is that it does not process nested
address@hidden' statements (i.e., address@hidden' statements in included files)
-the way a true macro preprocessor would. *Note Igawk Program::, for a
-program that does handle nested address@hidden' statements.
-
-3.8.5 Using `getline' from a Pipe
----------------------------------
-
-The output of a command can also be piped into `getline', using
-`COMMAND | getline'. In this case, the string COMMAND is run as a
-shell command and its output is piped into `awk' to be used as input.
-This form of `getline' reads one record at a time from the pipe. For
-example, the following program copies its input to its output, except
-for lines that begin with address@hidden', which are replaced by the output
-produced by running the rest of the line as a shell command:
-
- {
- if ($1 == "@execute") {
- tmp = substr($0, 10)
- while ((tmp | getline) > 0)
- print
- close(tmp)
- } else
- print
- }
-
-The `close' function is called to ensure that if two identical
address@hidden' lines appear in the input, the command is run for each one.
-*Note Close Files And Pipes::. Given the input:
-
- foo
- bar
- baz
- @execute who
- bletch
-
-the program might produce:
-
- foo
- bar
- baz
- arnold ttyv0 Jul 13 14:22
- miriam ttyp0 Jul 13 14:23 (murphy:0)
- bill ttyp1 Jul 13 14:23 (murphy:0)
- bletch
-
-Notice that this program ran the command `who' and printed the previous
-result. (If you try this program yourself, you will of course get
-different results, depending upon who is logged in on your system.)
-
- This variation of `getline' splits the record into fields, sets the
-value of `NF', and recomputes the value of `$0'. The values of `NR'
-and `FNR' are not changed.
-
- According to POSIX, `EXPRESSION | getline' is ambiguous if
-EXPRESSION contains unparenthesized operators other than `$'--for
-example, `"echo " "date" | getline' is ambiguous because the
-concatenation operator is not parenthesized. You should write it as
-`("echo " "date") | getline' if you want your program to be portable to
-other `awk' implementations.
-
-3.8.6 Using `getline' into a Variable from a Pipe
--------------------------------------------------
-
-When you use `COMMAND | getline VAR', the output of COMMAND is sent
-through a pipe to `getline' and into the variable VAR. For example, the
-following program reads the current date and time into the variable
-`current_time', using the `date' utility, and then prints it:
-
- BEGIN {
- "date" | getline current_time
- close("date")
- print "Report printed on " current_time
- }
-
- In this version of `getline', none of the built-in variables are
-changed and the record is not split into fields.
-
- According to POSIX, `EXPRESSION | getline VAR' is ambiguous if
-EXPRESSION contains unparenthesized operators other than `$'; for
-example, `"echo " "date" | getline VAR' is ambiguous because the
-concatenation operator is not parenthesized. You should write it as
-`("echo " "date") | getline VAR' if you want your program to be
-portable to other `awk' implementations.
-
-3.8.7 Using `getline' from a Coprocess
---------------------------------------
-
-Input into `getline' from a pipe is a one-way operation. The command
-that is started with `COMMAND | getline' only sends data _to_ your
-`awk' program.
-
- On occasion, you might want to send data to another program for
-processing and then read the results back. `gawk' allows you start a
-"coprocess", with which two-way communications are possible. This is
-done with the `|&' operator. Typically, you write data to the
-coprocess first and then read results back, as shown in the following:
-
- print "SOME QUERY" |& "db_server"
- "db_server" |& getline
-
-which sends a query to `db_server' and then reads the results.
-
- The values of `NR' and `FNR' are not changed, because the main input
-stream is not used. However, the record is split into fields in the
-normal manner, thus changing the values of `$0', of the other fields,
-and of `NF'.
-
- Coprocesses are an advanced feature. They are discussed here only
-because this is the minor node on `getline'. *Note Two-way I/O::,
-where coprocesses are discussed in more detail.
-
-3.8.8 Using `getline' into a Variable from a Coprocess
-------------------------------------------------------
-
-When you use `COMMAND |& getline VAR', the output from the coprocess
-COMMAND is sent through a two-way pipe to `getline' and into the
-variable VAR.
-
- In this version of `getline', none of the built-in variables are
-changed and the record is not split into fields. The only variable
-changed is VAR.
-
- Coprocesses are an advanced feature. They are discussed here only
-because this is the minor node on `getline'. *Note Two-way I/O::,
-where coprocesses are discussed in more detail.
-
-3.8.9 Points to Remember About `getline'
-----------------------------------------
-
-Here are some miscellaneous points about `getline' that you should bear
-in mind:
-
- * When `getline' changes the value of `$0' and `NF', `awk' does
- _not_ automatically jump to the start of the program and start
- testing the new record against every pattern. However, the new
- record is tested against any subsequent rules.
-
- * Many `awk' implementations limit the number of pipelines that an
- `awk' program may have open to just one. In `gawk', there is no
- such limit. You can open as many pipelines (and coprocesses) as
- the underlying operating system permits.
-
- * An interesting side effect occurs if you use `getline' without a
- redirection inside a `BEGIN' rule. Because an unredirected
- `getline' reads from the command-line data files, the first
- `getline' command causes `awk' to set the value of `FILENAME'.
- Normally, `FILENAME' does not have a value inside `BEGIN' rules,
- because you have not yet started to process the command-line data
- files. (d.c.) (*Note BEGIN/END::, also *note Auto-set::.)
-
- * Using `FILENAME' with `getline' (`getline < FILENAME') is likely
- to be a source for confusion. `awk' opens a separate input stream
- from the current input file. However, by not using a variable,
- `$0' and `NR' are still updated. If you're doing this, it's
- probably by accident, and you should reconsider what it is you're
- trying to accomplish.
-
-3.8.10 Summary of `getline' Variants
-------------------------------------
-
-*Note table-getline-variants:: summarizes the eight variants of
-`getline', listing which built-in variables are set by each one.
-
-Variant Effect
---------------------------------------------------------------------------
-`getline' Sets `$0', `NF', `FNR', and `NR'
-`getline' VAR Sets VAR, `FNR', and `NR'
-`getline <' FILE Sets `$0' and `NF'
-`getline VAR < FILE' Sets VAR
-COMMAND `| getline' Sets `$0' and `NF'
-COMMAND `| getline' VAR Sets VAR
-COMMAND `|& getline' Sets `$0' and `NF'. This is a `gawk' extension
-COMMAND `|& getline' VAR Sets VAR. This is a `gawk' extension
-
-Table 3.1: getline Variants and What They Set
-
-4 Printing Output
-*****************
-
-One of the most common programming actions is to "print", or output,
-some or all of the input. Use the `print' statement for simple output,
-and the `printf' statement for fancier formatting. The `print'
-statement is not limited when computing _which_ values to print.
-However, with two exceptions, you cannot specify _how_ to print
-them--how many columns, whether to use exponential notation or not, and
-so on. (For the exceptions, *note Output Separators::, and *Note
-OFMT::.) For printing with specifications, you need the `printf'
-statement (*note Printf::).
-
- Besides basic and formatted printing, this major node also covers
-I/O redirections to files and pipes, introduces the special file names
-that `gawk' processes internally, and discusses the `close' built-in
-function.
-
-4.1 The `print' Statement
-=========================
-
-The `print' statement is used to produce output with simple,
-standardized formatting. Specify only the strings or numbers to print,
-in a list separated by commas. They are output, separated by single
-spaces, followed by a newline. The statement looks like this:
-
- print ITEM1, ITEM2, ...
-
-The entire list of items may be optionally enclosed in parentheses. The
-parentheses are necessary if any of the item expressions uses the `>'
-relational operator; otherwise it could be confused with a redirection
-(*note Redirection::).
-
- The items to print can be constant strings or numbers, fields of the
-current record (such as `$1'), variables, or any `awk' expression.
-Numeric values are converted to strings and then printed.
-
- The simple statement `print' with no items is equivalent to `print
-$0': it prints the entire current record. To print a blank line, use
-`print ""', where `""' is the empty string. To print a fixed piece of
-text, use a string constant, such as `"Don't Panic"', as one item. If
-you forget to use the double-quote characters, your text is taken as an
-`awk' expression, and you will probably get an error. Keep in mind
-that a space is printed between any two items.
-
-4.2 Examples of `print' Statements
-==================================
-
-Each `print' statement makes at least one line of output. However, it
-isn't limited to only one line. If an item value is a string that
-contains a newline, the newline is output along with the rest of the
-string. A single `print' statement can make any number of lines this
-way.
-
- The following is an example of printing a string that contains
-embedded newlines (the `\n' is an escape sequence, used to represent
-the newline character; *note Escape Sequences::):
-
- $ awk 'BEGIN { print "line one\nline two\nline three" }'
- -| line one
- -| line two
- -| line three
-
- The next example, which is run on the `inventory-shipped' file,
-prints the first two fields of each input record, with a space between
-them:
-
- $ awk '{ print $1, $2 }' inventory-shipped
- -| Jan 13
- -| Feb 15
- -| Mar 15
- ...
-
- A common mistake in using the `print' statement is to omit the comma
-between two items. This often has the effect of making the items run
-together in the output, with no space. The reason for this is that
-juxtaposing two string expressions in `awk' means to concatenate them.
-Here is the same program, without the comma:
-
- $ awk '{ print $1 $2 }' inventory-shipped
- -| Jan13
- -| Feb15
- -| Mar15
- ...
-
- To someone unfamiliar with the `inventory-shipped' file, neither
-example's output makes much sense. A heading line at the beginning
-would make it clearer. Let's add some headings to our table of months
-(`$1') and green crates shipped (`$2'). We do this using the `BEGIN'
-pattern (*note BEGIN/END::) so that the headings are only printed once:
-
- awk 'BEGIN { print "Month Crates"
- print "----- ------" }
- { print $1, $2 }' inventory-shipped
-
-When run, the program prints the following:
-
- Month Crates
- ----- ------
- Jan 13
- Feb 15
- Mar 15
- ...
-
-The only problem, however, is that the headings and the table data
-don't line up! We can fix this by printing some spaces between the two
-fields:
-
- awk 'BEGIN { print "Month Crates"
- print "----- ------" }
- { print $1, " ", $2 }' inventory-shipped
-
- Lining up columns this way can get pretty complicated when there are
-many columns to fix. Counting spaces for two or three columns is
-simple, but any more than this can take up a lot of time. This is why
-the `printf' statement was created (*note Printf::); one of its
-specialties is lining up columns of data.
-
- NOTE: You can continue either a `print' or `printf' statement
- simply by putting a newline after any comma (*note
- Statements/Lines::).
-
-4.3 Output Separators
-=====================
-
-As mentioned previously, a `print' statement contains a list of items
-separated by commas. In the output, the items are normally separated
-by single spaces. However, this doesn't need to be the case; a single
-space is only the default. Any string of characters may be used as the
-"output field separator" by setting the built-in variable `OFS'. The
-initial value of this variable is the string `" "'--that is, a single
-space.
-
- The output from an entire `print' statement is called an "output
-record". Each `print' statement outputs one output record, and then
-outputs a string called the "output record separator" (or `ORS'). The
-initial value of `ORS' is the string `"\n"'; i.e., a newline character.
-Thus, each `print' statement normally makes a separate line.
-
- In order to change how output fields and records are separated,
-assign new values to the variables `OFS' and `ORS'. The usual place to
-do this is in the `BEGIN' rule (*note BEGIN/END::), so that it happens
-before any input is processed. It can also be done with assignments on
-the command line, before the names of the input files, or using the
-`-v' command-line option (*note Options::). The following example
-prints the first and second fields of each input record, separated by a
-semicolon, with a blank line added after each newline:
-
- $ awk 'BEGIN { OFS = ";"; ORS = "\n\n" }
- > { print $1, $2 }' BBS-list
- -| aardvark;555-5553
- -|
- -| alpo-net;555-3412
- -|
- -| barfly;555-7685
- ...
-
- If the value of `ORS' does not contain a newline, the program's
-output is run together on a single line.
-
-4.4 Controlling Numeric Output with `print'
-===========================================
-
-When the `print' statement is used to print numeric values, `awk'
-internally converts the number to a string of characters and prints
-that string. `awk' uses the `sprintf' function to do this conversion
-(*note String Functions::). For now, it suffices to say that the
-`sprintf' function accepts a "format specification" that tells it how
-to format numbers (or strings), and that there are a number of
-different ways in which numbers can be formatted. The different format
-specifications are discussed more fully in *Note Control Letters::.
-
- The built-in variable `OFMT' contains the default format
-specification that `print' uses with `sprintf' when it wants to convert
-a number to a string for printing. The default value of `OFMT' is
-`"%.6g"'. The way `print' prints numbers can be changed by supplying
-different format specifications as the value of `OFMT', as shown in the
-following example:
-
- $ awk 'BEGIN {
- > OFMT = "%.0f" # print numbers as integers (rounds)
- > print 17.23, 17.54 }'
- -| 17 18
-
-According to the POSIX standard, `awk''s behavior is undefined if
-`OFMT' contains anything but a floating-point conversion specification.
-(d.c.)
-
-4.5 Using `printf' Statements for Fancier Printing
-==================================================
-
-For more precise control over the output format than what is normally
-provided by `print', use `printf'. `printf' can be used to specify the
-width to use for each item, as well as various formatting choices for
-numbers (such as what output base to use, whether to print an exponent,
-whether to print a sign, and how many digits to print after the decimal
-point). This is done by supplying a string, called the "format
-string", that controls how and where to print the other arguments.
-
-4.5.1 Introduction to the `printf' Statement
---------------------------------------------
-
-A simple `printf' statement looks like this:
-
- printf FORMAT, ITEM1, ITEM2, ...
-
-The entire list of arguments may optionally be enclosed in parentheses.
-The parentheses are necessary if any of the item expressions use the
-`>' relational operator; otherwise, it can be confused with a
-redirection (*note Redirection::).
-
- The difference between `printf' and `print' is the FORMAT argument.
-This is an expression whose value is taken as a string; it specifies
-how to output each of the other arguments. It is called the "format
-string".
-
- The format string is very similar to that in the ISO C library
-function `printf'. Most of FORMAT is text to output verbatim.
-Scattered among this text are "format specifiers"--one per item. Each
-format specifier says to output the next item in the argument list at
-that place in the format.
-
- The `printf' statement does not automatically append a newline to
-its output. It outputs only what the format string specifies. So if a
-newline is needed, you must include one in the format string. The
-output separator variables `OFS' and `ORS' have no effect on `printf'
-statements. For example:
-
- $ awk 'BEGIN {
- > ORS = "\nOUCH!\n"; OFS = "+"
- > msg = "Dont Panic!"
- > printf "%s\n", msg
- > }'
- -| Dont Panic!
-
-Here, neither the `+' nor the `OUCH' appear when the message is printed.
-
-4.5.2 Format-Control Letters
-----------------------------
-
-A format specifier starts with the character `%' and ends with a
-"format-control letter"--it tells the `printf' statement how to output
-one item. The format-control letter specifies what _kind_ of value to
-print. The rest of the format specifier is made up of optional
-"modifiers" that control _how_ to print the value, such as the field
-width. Here is a list of the format-control letters:
-
-`%c'
- This prints a number as an ASCII character; thus, `printf "%c",
- 65' outputs the letter `A'. (The output for a string value is the
- first character of the string.)
-
-`%d, %i'
- These are equivalent; they both print a decimal integer. (The
- `%i' specification is for compatibility with ISO C.)
-
-`%e, %E'
- These print a number in scientific (exponential) notation; for
- example:
-
- printf "%4.3e\n", 1950
-
- prints `1.950e+03', with a total of four significant figures,
- three of which follow the decimal point. (The `4.3' represents
- two modifiers, discussed in the next node.) `%E' uses `E' instead
- of `e' in the output.
-
-`%f'
- This prints a number in floating-point notation. For example:
-
- printf "%4.3f", 1950
-
- prints `1950.000', with a total of four significant figures, three
- of which follow the decimal point. (The `4.3' represents two
- modifiers, discussed in the next node.)
-
- On systems supporting IEEE 754 floating point format, values
- representing negative infinity are formatted as `-inf' or
- `-infinity', and positive infinity as `inf' and `-infinity'. The
- special "not a number" value formats as `-nan' or `nan'.
-
-`%F'
- Like `%f' but the infinity and "not a number" values are spelled
- using uppercase letters.
-
- The `%F' format is a POSIX extension to ISO C; not all systems
- support. On those that don't, `gawk' uses `%f' instead.
-
-`%g, %G'
- These print a number in either scientific notation or in
- floating-point notation, whichever uses fewer characters; if the
- result is printed in scientific notation, `%G' uses `E' instead of
- `e'.
-
-`%o'
- This prints an unsigned octal integer.
-
-`%s'
- This prints a string.
-
-`%u'
- This prints an unsigned decimal integer. (This format is of
- marginal use, because all numbers in `awk' are floating-point; it
- is provided primarily for compatibility with C.)
-
-`%x, %X'
- These print an unsigned hexadecimal integer; `%X' uses the letters
- `A' through `F' instead of `a' through `f'.
-
-`%%'
- This isn't a format-control letter, but it does have meaning--the
- sequence `%%' outputs one `%'; it does not consume an argument and
- it ignores any modifiers.
-
- NOTE: When using the integer format-control letters for values
- that are outside the range of the widest C integer type, `gawk'
- switches to the the `%g' format specifier. If `--lint' is provided
- on the command line (*note Options::), `gawk' warns about this.
- Other versions of `awk' may print invalid values or do something
- else entirely. (d.c.)
-
-4.5.3 Modifiers for `printf' Formats
-------------------------------------
-
-A format specification can also include "modifiers" that can control
-how much of the item's value is printed, as well as how much space it
-gets. The modifiers come between the `%' and the format-control letter.
-We will use the bullet symbol "*" in the following examples to represent
-spaces in the output. Here are the possible modifiers, in the order in
-which they may appear:
-
-`N$'
- An integer constant followed by a `$' is a "positional specifier".
- Normally, format specifications are applied to arguments in the
- order given in the format string. With a positional specifier,
- the format specification is applied to a specific argument,
- instead of what would be the next argument in the list.
- Positional specifiers begin counting with one. Thus:
-
- printf "%s %s\n", "don't", "panic"
- printf "%2$s %1$s\n", "panic", "don't"
-
- prints the famous friendly message twice.
-
- At first glance, this feature doesn't seem to be of much use. It
- is in fact a `gawk' extension, intended for use in translating
- messages at runtime. *Note Printf Ordering::, which describes how
- and why to use positional specifiers. For now, we will not use
- them.
-
-`-'
- The minus sign, used before the width modifier (see later on in
- this table), says to left-justify the argument within its
- specified width. Normally, the argument is printed
- right-justified in the specified width. Thus:
-
- printf "%-4s", "foo"
-
- prints `foo*'.
-
-`SPACE'
- For numeric conversions, prefix positive values with a space and
- negative values with a minus sign.
-
-`+'
- The plus sign, used before the width modifier (see later on in
- this table), says to always supply a sign for numeric conversions,
- even if the data to format is positive. The `+' overrides the
- space modifier.
-
-`#'
- Use an "alternate form" for certain control letters. For `%o',
- supply a leading zero. For `%x' and `%X', supply a leading `0x'
- or `0X' for a nonzero result. For `%e', `%E', and `%f', the
- result always contains a decimal point. For `%g' and `%G',
- trailing zeros are not removed from the result.
-
-`0'
- A leading `0' (zero) acts as a flag that indicates that output
- should be padded with zeros instead of spaces. This applies even
- to non-numeric output formats. (d.c.) This flag only has an
- effect when the field width is wider than the value to print.
-
-`''
- A single quote or apostrohe character is a POSIX extension to ISO
- C. It indicates that the integer part of a floating point value,
- or the entire part of an integer decimal value, should have a
- thousands-separator character in it. This only works in locales
- that support such characters. For example:
-
- $ cat thousands.awk Show source
program
- -| BEGIN { printf "%'d\n", 1234567 }
- $ LC_ALL=C gawk -f thousands.awk Run it in
"C" locale
- -| 1234567
- $ LC_ALL=en_US.UTF-8 gawk -f thousands.awk Run in US
English UTF locale
- -| 1,234,567
-
- For more information about locales and internationalization issues,
- *FIXME: see xxxx*.
-
- NOTE: The `'' flag is a nice feature, but its use complicates
- things: it now becomes difficult to use it in command-line
- programs. For information on appropriate quoting tricks,
- *FIXME: see XXXX*.
-
-`WIDTH'
- This is a number specifying the desired minimum width of a field.
- Inserting any number between the `%' sign and the format-control
- character forces the field to expand to this width. The default
- way to do this is to pad with spaces on the left. For example:
-
- printf "%4s", "foo"
-
- prints `*foo'.
-
- The value of WIDTH is a minimum width, not a maximum. If the item
- value requires more than WIDTH characters, it can be as wide as
- necessary. Thus, the following:
-
- printf "%4s", "foobar"
-
- prints `foobar'.
-
- Preceding the WIDTH with a minus sign causes the output to be
- padded with spaces on the right, instead of on the left.
-
-`.PREC'
- A period followed by an integer constant specifies the precision
- to use when printing. The meaning of the precision varies by
- control letter:
-
- `%e', `%E', `%f'
- Number of digits to the right of the decimal point.
-
- `%g', `%G'
- Maximum number of significant digits.
-
- `%d', `%i', `%o', `%u', `%x', `%X'
- Minimum number of digits to print.
-
- `%s'
- Maximum number of characters from the string that should
- print.
-
- Thus, the following:
-
- printf "%.4s", "foobar"
-
- prints `foob'.
-
- The C library `printf''s dynamic WIDTH and PREC capability (for
-example, `"%*.*s"') is supported. Instead of supplying explicit WIDTH
-and/or PREC values in the format string, they are passed in the
-argument list. For example:
-
- w = 5
- p = 3
- s = "abcdefg"
- printf "%*.*s\n", w, p, s
-
-is exactly equivalent to:
-
- s = "abcdefg"
- printf "%5.3s\n", s
-
-Both programs output `**abc'. Earlier versions of `awk' did not
-support this capability. If you must use such a version, you may
-simulate this feature by using concatenation to build up the format
-string, like so:
-
- w = 5
- p = 3
- s = "abcdefg"
- printf "%" w "." p "s\n", s
-
-This is not particularly easy to read but it does work.
-
- C programmers may be used to supplying additional `l', `L', and `h'
-modifiers in `printf' format strings. These are not valid in `awk'.
-Most `awk' implementations silently ignore these modifiers. If
-`--lint' is provided on the command line (*note Options::), `gawk'
-warns about their use. If `--posix' is supplied, their use is a fatal
-error.
-
-4.5.4 Examples Using `printf'
------------------------------
-
-The following is a simple example of how to use `printf' to make an
-aligned table:
-
- awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list
-
-This command prints the names of the bulletin boards (`$1') in the file
-`BBS-list' as a string of 10 characters that are left-justified. It
-also prints the phone numbers (`$2') next on the line. This produces
-an aligned two-column table of names and phone numbers, as shown here:
-
- $ awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list
- -| aardvark 555-5553
- -| alpo-net 555-3412
- -| barfly 555-7685
- -| bites 555-1675
- -| camelot 555-0542
- -| core 555-2912
- -| fooey 555-1234
- -| foot 555-6699
- -| macfoo 555-6480
- -| sdace 555-3430
- -| sabafoo 555-2127
-
- In this case, the phone numbers had to be printed as strings because
-the numbers are separated by a dash. Printing the phone numbers as
-numbers would have produced just the first three digits: `555'. This
-would have been pretty confusing.
-
- It wasn't necessary to specify a width for the phone numbers because
-they are last on their lines. They don't need to have spaces after
-them.
-
- The table could be made to look even nicer by adding headings to the
-tops of the columns. This is done using the `BEGIN' pattern (*note
-BEGIN/END::) so that the headers are only printed once, at the
-beginning of the `awk' program:
-
- awk 'BEGIN { print "Name Number"
- print "---- ------" }
- { printf "%-10s %s\n", $1, $2 }' BBS-list
-
- The above example mixed `print' and `printf' statements in the same
-program. Using just `printf' statements can produce the same results:
-
- awk 'BEGIN { printf "%-10s %s\n", "Name", "Number"
- printf "%-10s %s\n", "----", "------" }
- { printf "%-10s %s\n", $1, $2 }' BBS-list
-
-Printing each column heading with the same format specification used
-for the column elements ensures that the headings are aligned just like
-the columns.
-
- The fact that the same format specification is used three times can
-be emphasized by storing it in a variable, like this:
-
- awk 'BEGIN { format = "%-10s %s\n"
- printf format, "Name", "Number"
- printf format, "----", "------" }
- { printf format, $1, $2 }' BBS-list
-
- At this point, it would be a worthwhile exercise to use the `printf'
-statement to line up the headings and table data for the
-`inventory-shipped' example that was covered earlier in the minor node
-on the `print' statement (*note Print::).
-
-4.6 Redirecting Output of `print' and `printf'
-==============================================
-
-So far, the output from `print' and `printf' has gone to the standard
-output, usually the terminal. Both `print' and `printf' can also send
-their output to other places. This is called "redirection".
-
- A redirection appears after the `print' or `printf' statement.
-Redirections in `awk' are written just like redirections in shell
-commands, except that they are written inside the `awk' program.
-
- There are four forms of output redirection: output to a file, output
-appended to a file, output through a pipe to another command, and output
-to a coprocess. They are all shown for the `print' statement, but they
-work identically for `printf':
-
-`print ITEMS > OUTPUT-FILE'
- This type of redirection prints the items into the output file
- named OUTPUT-FILE. The file name OUTPUT-FILE can be any
- expression. Its value is changed to a string and then used as a
- file name (*note Expressions::).
-
- When this type of redirection is used, the OUTPUT-FILE is erased
- before the first output is written to it. Subsequent writes to
- the same OUTPUT-FILE do not erase OUTPUT-FILE, but append to it.
- (This is different from how you use redirections in shell scripts.)
- If OUTPUT-FILE does not exist, it is created. For example, here
- is how an `awk' program can write a list of BBS names to one file
- named `name-list', and a list of phone numbers to another file
- named `phone-list':
-
- $ awk '{ print $2 > "phone-list"
- > print $1 > "name-list" }' BBS-list
- $ cat phone-list
- -| 555-5553
- -| 555-3412
- ...
- $ cat name-list
- -| aardvark
- -| alpo-net
- ...
-
- Each output file contains one name or number per line.
-
-`print ITEMS >> OUTPUT-FILE'
- This type of redirection prints the items into the pre-existing
- output file named OUTPUT-FILE. The difference between this and the
- single-`>' redirection is that the old contents (if any) of
- OUTPUT-FILE are not erased. Instead, the `awk' output is appended
- to the file. If OUTPUT-FILE does not exist, then it is created.
-
-`print ITEMS | COMMAND'
- It is also possible to send output to another program through a
- pipe instead of into a file. This type of redirection opens a
- pipe to COMMAND, and writes the values of ITEMS through this pipe
- to another process created to execute COMMAND.
-
- The redirection argument COMMAND is actually an `awk' expression.
- Its value is converted to a string whose contents give the shell
- command to be run. For example, the following produces two files,
- one unsorted list of BBS names, and one list sorted in reverse
- alphabetical order:
-
- awk '{ print $1 > "names.unsorted"
- command = "sort -r > names.sorted"
- print $1 | command }' BBS-list
-
- The unsorted list is written with an ordinary redirection, while
- the sorted list is written by piping through the `sort' utility.
-
- The next example uses redirection to mail a message to the mailing
- list `bug-system'. This might be useful when trouble is
- encountered in an `awk' script run periodically for system
- maintenance:
-
- report = "mail bug-system"
- print "Awk script failed:", $0 | report
- m = ("at record number " FNR " of " FILENAME)
- print m | report
- close(report)
-
- The message is built using string concatenation and saved in the
- variable `m'. It's then sent down the pipeline to the `mail'
- program. (The parentheses group the items to concatenate--see
- *Note Concatenation::.)
-
- The `close' function is called here because it's a good idea to
- close the pipe as soon as all the intended output has been sent to
- it. *Note Close Files And Pipes::, for more information.
-
- This example also illustrates the use of a variable to represent a
- FILE or COMMAND--it is not necessary to always use a string
- constant. Using a variable is generally a good idea, because
- `awk' requires that the string value be spelled identically every
- time.
-
-`print ITEMS |& COMMAND'
- This type of redirection prints the items to the input of COMMAND.
- The difference between this and the single-`|' redirection is that
- the output from COMMAND can be read with `getline'. Thus COMMAND
- is a "coprocess", which works together with, but subsidiary to,
- the `awk' program.
-
- This feature is a `gawk' extension, and is not available in POSIX
- `awk'. *Note Two-way I/O::, for a more complete discussion.
-
- Redirecting output using `>', `>>', `|', or `|&' asks the system to
-open a file, pipe, or coprocess only if the particular FILE or COMMAND
-you specify has not already been written to by your program or if it
-has been closed since it was last written to.
-
- It is a common error to use `>' redirection for the first `print' to
-a file, and then to use `>>' for subsequent output:
-
- # clear the file
- print "Don't panic" > "guide.txt"
- ...
- # append
- print "Avoid improbability generators" >> "guide.txt"
-
-This is indeed how redirections must be used from the shell. But in
-`awk', it isn't necessary. In this kind of case, a program should use
-`>' for all the `print' statements, since the output file is only
-opened once.
-
- Many `awk' implementations limit the number of pipelines that an
-`awk' program may have open to just one! In `gawk', there is no such
-limit. `gawk' allows a program to open as many pipelines as the
-underlying operating system permits.
-
-Advanced Notes: Piping into `sh'
---------------------------------
-
-A particularly powerful way to use redirection is to build command lines
-and pipe them into the shell, `sh'. For example, suppose you have a
-list of files brought over from a system where all the file names are
-stored in uppercase, and you wish to rename them to have names in all
-lowercase. The following program is both simple and efficient:
-
- { printf("mv %s %s\n", $0, tolower($0)) | "sh" }
-
- END { close("sh") }
-
- The `tolower' function returns its argument string with all
-uppercase characters converted to lowercase (*note String Functions::).
-The program builds up a list of command lines, using the `mv' utility
-to rename the files. It then sends the list to the shell for execution.
-
-4.7 Special File Names in `gawk'
-================================
-
-`gawk' provides a number of special file names that it interprets
-internally. These file names provide access to standard file
-descriptors, process-related information, and TCP/IP networking.
-
-4.7.1 Special Files for Standard Descriptors
---------------------------------------------
-
-Running programs conventionally have three input and output streams
-already available to them for reading and writing. These are known as
-the "standard input", "standard output", and "standard error output".
-These streams are, by default, connected to your terminal, but they are
-often redirected with the shell, via the `<', `<<', `>', `>>', `>&',
-and `|' operators. Standard error is typically used for writing error
-messages; the reason there are two separate streams, standard output
-and standard error, is so that they can be redirected separately.
-
- In other implementations of `awk', the only way to write an error
-message to standard error in an `awk' program is as follows:
-
- print "Serious error detected!" | "cat 1>&2"
-
-This works by opening a pipeline to a shell command that can access the
-standard error stream that it inherits from the `awk' process. This is
-far from elegant, and it is also inefficient, because it requires a
-separate process. So people writing `awk' programs often don't do
-this. Instead, they send the error messages to the terminal, like this:
-
- print "Serious error detected!" > "/dev/tty"
-
-This usually has the same effect but not always: although the standard
-error stream is usually the terminal, it can be redirected; when that
-happens, writing to the terminal is not correct. In fact, if `awk' is
-run from a background job, it may not have a terminal at all. Then
-opening `/dev/tty' fails.
-
- `gawk' provides special file names for accessing the three standard
-streams, as well as any other inherited open files. If the file name
-matches one of these special names when `gawk' redirects input or
-output, then it directly uses the stream that the file name stands for.
-These special file names work for all operating systems that `gawk' has
-been ported to, not just those that are POSIX-compliant:
-
-`/dev/stdin'
- The standard input (file descriptor 0).
-
-`/dev/stdout'
- The standard output (file descriptor 1).
-
-`/dev/stderr'
- The standard error output (file descriptor 2).
-
-`/dev/fd/N'
- The file associated with file descriptor N. Such a file must be
- opened by the program initiating the `awk' execution (typically
- the shell). Unless special pains are taken in the shell from which
- `gawk' is invoked, only descriptors 0, 1, and 2 are available.
-
- The file names `/dev/stdin', `/dev/stdout', and `/dev/stderr' are
-aliases for `/dev/fd/0', `/dev/fd/1', and `/dev/fd/2', respectively.
-However, they are more self-explanatory. The proper way to write an
-error message in a `gawk' program is to use `/dev/stderr', like this:
-
- print "Serious error detected!" > "/dev/stderr"
-
- Note the use of quotes around the file name. Like any other
-redirection, the value must be a string. It is a common error to omit
-the quotes, which leads to confusing results.
-
-4.7.2 Special Files for Process-Related Information
----------------------------------------------------
-
-`gawk' also provides special file names that give access to information
-about the running `gawk' process. Each of these "files" provides a
-single record of information. To read them more than once, they must
-first be closed with the `close' function (*note Close Files And
-Pipes::). The file names are:
-
-`/dev/pid'
- Reading this file returns the process ID of the current process,
- in decimal form, terminated with a newline.
-
-`/dev/ppid'
- Reading this file returns the parent process ID of the current
- process, in decimal form, terminated with a newline.
-
-`/dev/pgrpid'
- Reading this file returns the process group ID of the current
- process, in decimal form, terminated with a newline.
-
-`/dev/user'
- Reading this file returns a single record terminated with a
- newline. The fields are separated with spaces. The fields
- represent the following information:
-
- `$1'
- The return value of the `getuid' system call (the real user
- ID number).
-
- `$2'
- The return value of the `geteuid' system call (the effective
- user ID number).
-
- `$3'
- The return value of the `getgid' system call (the real group
- ID number).
-
- `$4'
- The return value of the `getegid' system call (the effective
- group ID number).
-
- If there are any additional fields, they are the group IDs
- returned by the `getgroups' system call. (Multiple groups may not
- be supported on all systems.)
-
- These special file names may be used on the command line as data
-files, as well as for I/O redirections within an `awk' program. They
-may not be used as source files with the `-f' option.
-
- NOTE: The special files that provide process-related information
- are now considered obsolete and will disappear entirely in the
- next release of `gawk'. `gawk' prints a warning message every
- time you use one of these files. To obtain process-related
- information, use the `PROCINFO' array. *Note Auto-set::.
-
-4.7.3 Special Files for Network Communications
-----------------------------------------------
-
-Starting with version 3.1 of `gawk', `awk' programs can open a two-way
-TCP/IP connection, acting as either a client or a server. This is done
-using a special file name of the form:
-
- `/inet/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT'
-
- The PROTOCOL is one of `tcp', `udp', or `raw', and the other fields
-represent the other essential pieces of information for making a
-networking connection. These file names are used with the `|&'
-operator for communicating with a coprocess (*note Two-way I/O::).
-This is an advanced feature, mentioned here only for completeness.
-Full discussion is delayed until *Note TCP/IP Networking::.
-
-4.7.4 Special File Name Caveats
--------------------------------
-
-Here is a list of things to bear in mind when using the special file
-names that `gawk' provides:
-
- * Recognition of these special file names is disabled if `gawk' is in
- compatibility mode (*note Options::).
-
- * The special files that provide process-related information are now
- considered obsolete and will disappear entirely in the next
- release of `gawk'. `gawk' prints a warning message every time you
- use one of these files. To obtain process-related information,
- use the `PROCINFO' array. *Note Built-in Variables::.
-
- * Starting with version 3.1, `gawk' _always_ interprets these
- special file names.(1) For example, using `/dev/fd/4' for output
- actually writes on file descriptor 4, and not on a new file
- descriptor that is `dup''ed from file descriptor 4. Most of the
- time this does not matter; however, it is important to _not_ close
- any of the files related to file descriptors 0, 1, and 2. Doing
- so results in unpredictable behavior.
-
- ---------- Footnotes ----------
-
- (1) Older versions of `gawk' would interpret these names internally
-only if the system did not actually have a `/dev/fd' directory or any
-of the other special files listed earlier. Usually this didn't make a
-difference, but sometimes it did; thus, it was decided to make `gawk''s
-behavior consistent on all systems and to have it always interpret the
-special file names itself.
-
-4.8 Closing Input and Output Redirections
-=========================================
-
-If the same file name or the same shell command is used with `getline'
-more than once during the execution of an `awk' program (*note
-Getline::), the file is opened (or the command is executed) the first
-time only. At that time, the first record of input is read from that
-file or command. The next time the same file or command is used with
-`getline', another record is read from it, and so on.
-
- Similarly, when a file or pipe is opened for output, the file name or
-command associated with it is remembered by `awk', and subsequent
-writes to the same file or command are appended to the previous writes.
-The file or pipe stays open until `awk' exits.
-
- This implies that special steps are necessary in order to read the
-same file again from the beginning, or to rerun a shell command (rather
-than reading more output from the same command). The `close' function
-makes these things possible:
-
- close(FILENAME)
-
-or:
-
- close(COMMAND)
-
- The argument FILENAME or COMMAND can be any expression. Its value
-must _exactly_ match the string that was used to open the file or start
-the command (spaces and other "irrelevant" characters included). For
-example, if you open a pipe with this:
-
- "sort -r names" | getline foo
-
-then you must close it with this:
-
- close("sort -r names")
-
- Once this function call is executed, the next `getline' from that
-file or command, or the next `print' or `printf' to that file or
-command, reopens the file or reruns the command. Because the
-expression that you use to close a file or pipeline must exactly match
-the expression used to open the file or run the command, it is good
-practice to use a variable to store the file name or command. The
-previous example becomes the following:
-
- sortcom = "sort -r names"
- sortcom | getline foo
- ...
- close(sortcom)
-
-This helps avoid hard-to-find typographical errors in your `awk'
-programs. Here are some of the reasons for closing an output file:
-
- * To write a file and read it back later on in the same `awk'
- program. Close the file after writing it, then begin reading it
- with `getline'.
-
- * To write numerous files, successively, in the same `awk' program.
- If the files aren't closed, eventually `awk' may exceed a system
- limit on the number of open files in one process. It is best to
- close each one when the program has finished writing it.
-
- * To make a command finish. When output is redirected through a
- pipe, the command reading the pipe normally continues to try to
- read input as long as the pipe is open. Often this means the
- command cannot really do its work until the pipe is closed. For
- example, if output is redirected to the `mail' program, the
- message is not actually sent until the pipe is closed.
-
- * To run the same program a second time, with the same arguments.
- This is not the same thing as giving more input to the first run!
-
- For example, suppose a program pipes output to the `mail' program.
- If it outputs several lines redirected to this pipe without closing
- it, they make a single message of several lines. By contrast, if
- the program closes the pipe after each line of output, then each
- line makes a separate message.
-
- If you use more files than the system allows you to have open,
-`gawk' attempts to multiplex the available open files among your data
-files. `gawk''s ability to do this depends upon the facilities of your
-operating system, so it may not always work. It is therefore both good
-practice and good portability advice to always use `close' on your
-files when you are done with them. In fact, if you are using a lot of
-pipes, it is essential that you close commands when done. For example,
-consider something like this:
-
- {
- ...
- command = ("grep " $1 " /some/file | my_prog -q " $3)
- while ((command | getline) > 0) {
- PROCESS OUTPUT OF command
- }
- # need close(command) here
- }
-
- This example creates a new pipeline based on data in _each_ record.
-Without the call to `close' indicated in the comment, `awk' creates
-child processes to run the commands, until it eventually runs out of
-file descriptors for more pipelines.
-
- Even though each command has finished (as indicated by the
-end-of-file return status from `getline'), the child process is not
-terminated;(1) more importantly, the file descriptor for the pipe is
-not closed and released until `close' is called or `awk' exits.
-
- `close' will silently do nothing if given an argument that does not
-represent a file, pipe or coprocess that was opened with a redirection.
-
- Note also that `close(FILENAME)' has no "magic" effects on the
-implicit loop that reads through the files named on the command line.
-It is, more likely, a close of a file that was never opened, so `awk'
-silently does nothing.
-
- When using the `|&' operator to communicate with a coprocess, it is
-occasionally useful to be able to close one end of the two-way pipe
-without closing the other. This is done by supplying a second argument
-to `close'. As in any other call to `close', the first argument is the
-name of the command or special file used to start the coprocess. The
-second argument should be a string, with either of the values `"to"' or
-`"from"'. Case does not matter. As this is an advanced feature, a
-more complete discussion is delayed until *Note Two-way I/O::, which
-discusses it in more detail and gives an example.
-
-Advanced Notes: Using `close''s Return Value
---------------------------------------------
-
-In many versions of Unix `awk', the `close' function is actually a
-statement. It is a syntax error to try and use the return value from
-`close': (d.c.)
-
- command = "..."
- command | getline info
- retval = close(command) # syntax error in most Unix awks
-
- `gawk' treats `close' as a function. The return value is -1 if the
-argument names something that was never opened with a redirection, or
-if there is a system problem closing the file or process. In these
-cases, `gawk' sets the built-in variable `ERRNO' to a string describing
-the problem.
-
- In `gawk', when closing a pipe or coprocess, the return value is the
-exit status of the command.(2) Otherwise, it is the return value from
-the system's `close' or `fclose' C functions when closing input or
-output files, respectively. This value is zero if the close succeeds,
-or -1 if it fails.
-
- The POSIX standard is very vague; it says that `close' returns zero
-on success and non-zero otherwise. In general, different
-implementations vary in what they report when closing pipes; thus the
-return value cannot be used portably. (d.c.)
-
- ---------- Footnotes ----------
-
- (1) The technical terminology is rather morbid. The finished child
-is called a "zombie," and cleaning up after it is referred to as
-"reaping."
-
- (2) This is a full 16-bit value as returned by the `wait' system
-call. See the system manual pages for information on how to decode this
-value.
-
-5 Expressions
-*************
-
-Expressions are the basic building blocks of `awk' patterns and
-actions. An expression evaluates to a value that you can print, test,
-or pass to a function. Additionally, an expression can assign a new
-value to a variable or a field by using an assignment operator.
-
- An expression can serve as a pattern or action statement on its own.
-Most other kinds of statements contain one or more expressions that
-specify the data on which to operate. As in other languages,
-expressions in `awk' include variables, array references, constants,
-and function calls, as well as combinations of these with various
-operators.
-
-5.1 Constant Expressions
-========================
-
-The simplest type of expression is the "constant", which always has the
-same value. There are three types of constants: numeric, string, and
-regular expression.
-
- Each is used in the appropriate context when you need a data value
-that isn't going to change. Numeric constants can have different
-forms, but are stored identically internally.
-
-5.1.1 Numeric and String Constants
-----------------------------------
-
-A "numeric constant" stands for a number. This number can be an
-integer, a decimal fraction, or a number in scientific (exponential)
-notation.(1) Here are some examples of numeric constants that all have
-the same value:
-
- 105
- 1.05e+2
- 1050e-1
-
- A string constant consists of a sequence of characters enclosed in
-double-quotation marks. For example:
-
- "parrot"
-
-represents the string whose contents are `parrot'. Strings in `gawk'
-can be of any length, and they can contain any of the possible
-eight-bit ASCII characters including ASCII NUL (character code zero).
-Other `awk' implementations may have difficulty with some character
-codes.
-
- ---------- Footnotes ----------
-
- (1) The internal representation of all numbers, including integers,
-uses double-precision floating-point numbers. On most modern systems,
-these are in IEEE 754 standard format.
-
-5.1.2 Octal and Hexadecimal Numbers
------------------------------------
-
-In `awk', all numbers are in decimal; i.e., base 10. Many other
-programming languages allow you to specify numbers in other bases, often
-octal (base 8) and hexadecimal (base 16). In octal, the numbers go 0,
-1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc. Just as `11', in decimal, is 1
-times 10 plus 1, so `11', in octal, is 1 times 8, plus 1. This equals 9
-in decimal. In hexadecimal, there are 16 digits. Since the everyday
-decimal number system only has ten digits (`0'-`9'), the letters `a'
-through `f' are used to represent the rest. (Case in the letters is
-usually irrelevant; hexadecimal `a' and `A' have the same value.)
-Thus, `11', in hexadecimal, is 1 times 16 plus 1, which equals 17 in
-decimal.
-
- Just by looking at plain `11', you can't tell what base it's in.
-So, in C, C++, and other languages derived from C, there is a special
-notation to help signify the base. Octal numbers start with a leading
-`0', and hexadecimal numbers start with a leading `0x' or `0X':
-
-`11'
- Decimal value 11.
-
-`011'
- Octal 11, decimal value 9.
-
-`0x11'
- Hexadecimal 11, decimal value 17.
-
- This example shows the difference:
-
- $ gawk 'BEGIN { printf "%d, %d, %d\n", 011, 11, 0x11 }'
- -| 9, 11, 17
-
- Being able to use octal and hexadecimal constants in your programs
-is most useful when working with data that cannot be represented
-conveniently as characters or as regular numbers, such as binary data
-of various sorts.
-
- `gawk' allows the use of octal and hexadecimal constants in your
-program text. However, such numbers in the input data are not treated
-differently; doing so by default would break old programs. (If you
-really need to do this, use the `--non-decimal-data' command-line
-option; *note Nondecimal Data::.) If you have octal or hexadecimal
-data, you can use the `strtonum' function (*note String Functions::) to
-convert the data into a number. Most of the time, you will want to use
-octal or hexadecimal constants when working with the built-in bit
-manipulation functions; see *Note Bitwise Functions::, for more
-information.
-
- Unlike some early C implementations, `8' and `9' are not valid in
-octal constants; e.g., `gawk' treats `018' as decimal 18:
-
- $ gawk 'BEGIN { print "021 is", 021 ; print 018 }'
- -| 021 is 17
- -| 18
-
- Octal and hexadecimal source code constants are a `gawk' extension.
-If `gawk' is in compatibility mode (*note Options::), they are not
-available.
-
-Advanced Notes: A Constant's Base Does Not Affect Its Value
------------------------------------------------------------
-
-Once a numeric constant has been converted internally into a number,
-`gawk' no longer remembers what the original form of the constant was;
-the internal value is always used. This has particular consequences
-for conversion of numbers to strings:
-
- $ gawk 'BEGIN { printf "0x11 is <%s>\n", 0x11 }'
- -| 0x11 is <17>
-
-5.1.3 Regular Expression Constants
-----------------------------------
-
-A regexp constant is a regular expression description enclosed in
-slashes, such as `/^beginning and end$/'. Most regexps used in `awk'
-programs are constant, but the `~' and `!~' matching operators can also
-match computed or "dynamic" regexps (which are just ordinary strings or
-variables that contain a regexp).
-
-5.2 Using Regular Expression Constants
-======================================
-
-When used on the righthand side of the `~' or `!~' operators, a regexp
-constant merely stands for the regexp that is to be matched. However,
-regexp constants (such as `/foo/') may be used like simple expressions.
-When a regexp constant appears by itself, it has the same meaning as if
-it appeared in a pattern, i.e., `($0 ~ /foo/)' (d.c.) *Note Expression
-Patterns::. This means that the following two code segments:
-
- if ($0 ~ /barfly/ || $0 ~ /camelot/)
- print "found"
-
-and:
-
- if (/barfly/ || /camelot/)
- print "found"
-
-are exactly equivalent. One rather bizarre consequence of this rule is
-that the following Boolean expression is valid, but does not do what
-the user probably intended:
-
- # note that /foo/ is on the left of the ~
- if (/foo/ ~ $1) print "found foo"
-
-This code is "obviously" testing `$1' for a match against the regexp
-`/foo/'. But in fact, the expression `/foo/ ~ $1' actually means `($0
-~ /foo/) ~ $1'. In other words, first match the input record against
-the regexp `/foo/'. The result is either zero or one, depending upon
-the success or failure of the match. That result is then matched
-against the first field in the record. Because it is unlikely that you
-would ever really want to make this kind of test, `gawk' issues a
-warning when it sees this construct in a program. Another consequence
-of this rule is that the assignment statement:
-
- matches = /foo/
-
-assigns either zero or one to the variable `matches', depending upon
-the contents of the current input record. This feature of the language
-has never been well documented until the POSIX specification.
-
- Constant regular expressions are also used as the first argument for
-the `gensub', `sub', and `gsub' functions, and as the second argument
-of the `match' function (*note String Functions::). Modern
-implementations of `awk', including `gawk', allow the third argument of
-`split' to be a regexp constant, but some older implementations do not.
-(d.c.) This can lead to confusion when attempting to use regexp
-constants as arguments to user-defined functions (*note User-defined::).
-For example:
-
- function mysub(pat, repl, str, global)
- {
- if (global)
- gsub(pat, repl, str)
- else
- sub(pat, repl, str)
- return str
- }
-
- {
- ...
- text = "hi! hi yourself!"
- mysub(/hi/, "howdy", text, 1)
- ...
- }
-
- In this example, the programmer wants to pass a regexp constant to
-the user-defined function `mysub', which in turn passes it on to either
-`sub' or `gsub'. However, what really happens is that the `pat'
-parameter is either one or zero, depending upon whether or not `$0'
-matches `/hi/'. `gawk' issues a warning when it sees a regexp constant
-used as a parameter to a user-defined function, since passing a truth
-value in this way is probably not what was intended.
-
-5.3 Variables
-=============
-
-Variables are ways of storing values at one point in your program for
-use later in another part of your program. They can be manipulated
-entirely within the program text, and they can also be assigned values
-on the `awk' command line.
-
-5.3.1 Using Variables in a Program
-----------------------------------
-
-Variables let you give names to values and refer to them later.
-Variables have already been used in many of the examples. The name of
-a variable must be a sequence of letters, digits, or underscores, and
-it may not begin with a digit. Case is significant in variable names;
-`a' and `A' are distinct variables.
-
- A variable name is a valid expression by itself; it represents the
-variable's current value. Variables are given new values with
-"assignment operators", "increment operators", and "decrement
-operators". *Note Assignment Ops::.
-
- A few variables have special built-in meanings, such as `FS' (the
-field separator), and `NF' (the number of fields in the current input
-record). *Note Built-in Variables::, for a list of the built-in
-variables. These built-in variables can be used and assigned just like
-all other variables, but their values are also used or changed
-automatically by `awk'. All built-in variables' names are entirely
-uppercase.
-
- Variables in `awk' can be assigned either numeric or string values.
-The kind of value a variable holds can change over the life of a
-program. By default, variables are initialized to the empty string,
-which is zero if converted to a number. There is no need to
-"initialize" each variable explicitly in `awk', which is what you would
-do in C and in most other traditional languages.
-
-5.3.2 Assigning Variables on the Command Line
----------------------------------------------
-
-Any `awk' variable can be set by including a "variable assignment"
-among the arguments on the command line when `awk' is invoked (*note
-Other Arguments::). Such an assignment has the following form:
-
- VARIABLE=TEXT
-
-With it, a variable is set either at the beginning of the `awk' run or
-in between input files. When the assignment is preceded with the `-v'
-option, as in the following:
-
- -v VARIABLE=TEXT
-
-the variable is set at the very beginning, even before the `BEGIN'
-rules are run. The `-v' option and its assignment must precede all the
-file name arguments, as well as the program text. (*Note Options::,
-for more information about the `-v' option.) Otherwise, the variable
-assignment is performed at a time determined by its position among the
-input file arguments--after the processing of the preceding input file
-argument. For example:
-
- awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list
-
-prints the value of field number `n' for all input records. Before the
-first file is read, the command line sets the variable `n' equal to
-four. This causes the fourth field to be printed in lines from the
-file `inventory-shipped'. After the first file has finished, but
-before the second file is started, `n' is set to two, so that the
-second field is printed in lines from `BBS-list':
-
- $ awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list
- -| 15
- -| 24
- ...
- -| 555-5553
- -| 555-3412
- ...
-
- Command-line arguments are made available for explicit examination by
-the `awk' program in the `ARGV' array (*note ARGC and ARGV::). `awk'
-processes the values of command-line assignments for escape sequences
-(*note Escape Sequences::). (d.c.)
-
-5.4 Conversion of Strings and Numbers
-=====================================
-
-Strings are converted to numbers and numbers are converted to strings,
-if the context of the `awk' program demands it. For example, if the
-value of either `foo' or `bar' in the expression `foo + bar' happens to
-be a string, it is converted to a number before the addition is
-performed. If numeric values appear in string concatenation, they are
-converted to strings. Consider the following:
-
- two = 2; three = 3
- print (two three) + 4
-
-This prints the (numeric) value 27. The numeric values of the
-variables `two' and `three' are converted to strings and concatenated
-together. The resulting string is converted back to the number 23, to
-which 4 is then added.
-
- If, for some reason, you need to force a number to be converted to a
-string, concatenate the empty string, `""', with that number. To force
-a string to be converted to a number, add zero to that string. A
-string is converted to a number by interpreting any numeric prefix of
-the string as numerals: `"2.5"' converts to 2.5, `"1e3"' converts to
-1000, and `"25fix"' has a numeric value of 25. Strings that can't be
-interpreted as valid numbers convert to zero.
-
- The exact manner in which numbers are converted into strings is
-controlled by the `awk' built-in variable `CONVFMT' (*note Built-in
-Variables::). Numbers are converted using the `sprintf' function with
-`CONVFMT' as the format specifier (*note String Functions::).
-
- `CONVFMT''s default value is `"%.6g"', which prints a value with at
-least six significant digits. For some applications, you might want to
-change it to specify more precision. On most modern machines, 17
-digits is enough to capture a floating-point number's value exactly,
-most of the time.(1)
-
- Strange results can occur if you set `CONVFMT' to a string that
-doesn't tell `sprintf' how to format floating-point numbers in a useful
-way. For example, if you forget the `%' in the format, `awk' converts
-all numbers to the same constant string. As a special case, if a
-number is an integer, then the result of converting it to a string is
-_always_ an integer, no matter what the value of `CONVFMT' may be.
-Given the following code fragment:
-
- CONVFMT = "%2.2f"
- a = 12
- b = a ""
-
-`b' has the value `"12"', not `"12.00"'. (d.c.)
-
- Prior to the POSIX standard, `awk' used the value of `OFMT' for
-converting numbers to strings. `OFMT' specifies the output format to
-use when printing numbers with `print'. `CONVFMT' was introduced in
-order to separate the semantics of conversion from the semantics of
-printing. Both `CONVFMT' and `OFMT' have the same default value:
-`"%.6g"'. In the vast majority of cases, old `awk' programs do not
-change their behavior. However, these semantics for `OFMT' are
-something to keep in mind if you must port your new style program to
-older implementations of `awk'. We recommend that instead of changing
-your programs, just port `gawk' itself. *Note Print::, for more
-information on the `print' statement.
-
- Finally, once again, where you are can matter when it comes to
-converting between numbers and strings. In *Note Locales::, we
-mentioned that the local character set and language (the locale) can
-affect how `gawk' matches characters. The locale also affects numeric
-formats. In particular, for `awk' programs, it affects the decimal
-point character. The `"C"' locale, and most English-language locales,
-use the period character (`.') as the decimal point. However, many (if
-not most) European and non-English locales use the comma (`,') as the
-decimal point character.
-
- The POSIX standard says that `awk' always uses the period as the
-decimal point when reading the `awk' program source code, and for
-command-line variable assignments (*note Other Arguments::). However,
-when interpreting input data, for `print' and `printf' output, and for
-number to string conversion, the local decimal point character is used.
-As of version 3.1.3, `gawk' fully complies with this aspect of the
-standard. Here are some examples indicating the difference in behavior,
-on a GNU/Linux system:
-
- $ gawk 'BEGIN { printf "%g\n", 3.1415927 }'
- -| 3.14159
- $ LC_ALL=en_DK gawk 'BEGIN { printf "%g\n", 3.1415927 }'
- -| 3,14159
- $ echo 4,321 | gawk '{ print $1 + 1 }'
- -| 5
- $ echo 4,321 | LC_ALL=en_DK gawk '{ print $1 + 1 }'
- -| 5,321
-
-The `en_DK' locale is for English in Denmark, where the comma acts as
-the decimal point separator. In the normal `"C"' locale, `gawk' treats
-`4,321' as `4', while in the Danish locale, it's treated as the full
-number, `4.321'.
-
- ---------- Footnotes ----------
-
- (1) Pathological cases can require up to 752 digits (!), but we
-doubt that you need to worry about this.
-
-5.5 Arithmetic Operators
-========================
-
-The `awk' language uses the common arithmetic operators when evaluating
-expressions. All of these arithmetic operators follow normal
-precedence rules and work as you would expect them to.
-
- The following example uses a file named `grades', which contains a
-list of student names as well as three test scores per student (it's a
-small class):
-
- Pat 100 97 58
- Sandy 84 72 93
- Chris 72 92 89
-
-This programs takes the file `grades' and prints the average of the
-scores:
-
- $ awk '{ sum = $2 + $3 + $4 ; avg = sum / 3
- > print $1, avg }' grades
- -| Pat 85
- -| Sandy 83
- -| Chris 84.3333
-
- The following list provides the arithmetic operators in `awk', in
-order from the highest precedence to the lowest:
-
-`- X'
- Negation.
-
-`+ X'
- Unary plus; the expression is converted to a number.
-
-`X ^ Y'
-`X ** Y'
- Exponentiation; X raised to the Y power. `2 ^ 3' has the value
- eight; the character sequence `**' is equivalent to `^'.
-
-`X * Y'
- Multiplication.
-
-`X / Y'
- Division; because all numbers in `awk' are floating-point
- numbers, the result is _not_ rounded to an integer--`3 / 4' has
- the value 0.75. (It is a common mistake, especially for C
- programmers, to forget that _all_ numbers in `awk' are
- floating-point, and that division of integer-looking constants
- produces a real number, not an integer.)
-
-`X % Y'
- Remainder; further discussion is provided in the text, just after
- this list.
-
-`X + Y'
- Addition.
-
-`X - Y'
- Subtraction.
-
- Unary plus and minus have the same precedence, the multiplication
-operators all have the same precedence, and addition and subtraction
-have the same precedence.
-
- When computing the remainder of `X % Y', the quotient is rounded
-toward zero to an integer and multiplied by Y. This result is
-subtracted from X; this operation is sometimes known as "trunc-mod."
-The following relation always holds:
-
- b * int(a / b) + (a % b) == a
-
- One possibly undesirable effect of this definition of remainder is
-that `X % Y' is negative if X is negative. Thus:
-
- -17 % 8 = -1
-
- In other `awk' implementations, the signedness of the remainder may
-be machine-dependent.
-
- NOTE: The POSIX standard only specifies the use of `^' for
- exponentiation. For maximum portability, do not use the `**'
- operator.
-
-5.6 String Concatenation
-========================
-
- It seemed like a good idea at the time.
- Brian Kernighan
-
- There is only one string operation: concatenation. It does not have
-a specific operator to represent it. Instead, concatenation is
-performed by writing expressions next to one another, with no operator.
-For example:
-
- $ awk '{ print "Field number one: " $1 }' BBS-list
- -| Field number one: aardvark
- -| Field number one: alpo-net
- ...
-
- Without the space in the string constant after the `:', the line
-runs together. For example:
-
- $ awk '{ print "Field number one:" $1 }' BBS-list
- -| Field number one:aardvark
- -| Field number one:alpo-net
- ...
-
- Because string concatenation does not have an explicit operator, it
-is often necessary to insure that it happens at the right time by using
-parentheses to enclose the items to concatenate. For example, the
-following code fragment does not concatenate `file' and `name' as you
-might expect:
-
- file = "file"
- name = "name"
- print "something meaningful" > file name
-
-It is necessary to use the following:
-
- print "something meaningful" > (file name)
-
- Parentheses should be used around concatenation in all but the most
-common contexts, such as on the righthand side of `='. Be careful
-about the kinds of expressions used in string concatenation. In
-particular, the order of evaluation of expressions used for
-concatenation is undefined in the `awk' language. Consider this
-example:
-
- BEGIN {
- a = "don't"
- print (a " " (a = "panic"))
- }
-
-It is not defined whether the assignment to `a' happens before or after
-the value of `a' is retrieved for producing the concatenated value.
-The result could be either `don't panic', or `panic panic'. The
-precedence of concatenation, when mixed with other operators, is often
-counter-intuitive. Consider this example:
-
- $ awk 'BEGIN { print -12 " " -24 }'
- -| -12-24
-
- This "obviously" is concatenating -12, a space, and -24. But where
-did the space disappear to? The answer lies in the combination of
-operator precedences and `awk''s automatic conversion rules. To get
-the desired result, write the program in the following manner:
-
- $ awk 'BEGIN { print -12 " " (-24) }'
- -| -12 -24
-
- This forces `awk' to treat the `-' on the `-24' as unary.
-Otherwise, it's parsed as follows:
-
- -12 (`" "' - 24)
- => -12 (0 - 24)
- => -12 (-24)
- => -12-24
-
- As mentioned earlier, when doing concatenation, _parenthesize_.
-Otherwise, you're never quite sure what you'll get.
-
-5.7 Assignment Expressions
-==========================
-
-An "assignment" is an expression that stores a (usually different)
-value into a variable. For example, let's assign the value one to the
-variable `z':
-
- z = 1
-
- After this expression is executed, the variable `z' has the value
-one. Whatever old value `z' had before the assignment is forgotten.
-
- Assignments can also store string values. For example, the
-following stores the value `"this food is good"' in the variable
-`message':
-
- thing = "food"
- predicate = "good"
- message = "this " thing " is " predicate
-
-This also illustrates string concatenation. The `=' sign is called an
-"assignment operator". It is the simplest assignment operator because
-the value of the righthand operand is stored unchanged. Most operators
-(addition, concatenation, and so on) have no effect except to compute a
-value. If the value isn't used, there's no reason to use the operator.
-An assignment operator is different; it does produce a value, but even
-if you ignore it, the assignment still makes itself felt through the
-alteration of the variable. We call this a "side effect".
-
- The lefthand operand of an assignment need not be a variable (*note
-Variables::); it can also be a field (*note Changing Fields::) or an
-array element (*note Arrays::). These are all called "lvalues", which
-means they can appear on the lefthand side of an assignment operator.
-The righthand operand may be any expression; it produces the new value
-that the assignment stores in the specified variable, field, or array
-element. (Such values are called "rvalues".)
-
- It is important to note that variables do _not_ have permanent types.
-A variable's type is simply the type of whatever value it happens to
-hold at the moment. In the following program fragment, the variable
-`foo' has a numeric value at first, and a string value later on:
-
- foo = 1
- print foo
- foo = "bar"
- print foo
-
-When the second assignment gives `foo' a string value, the fact that it
-previously had a numeric value is forgotten.
-
- String values that do not begin with a digit have a numeric value of
-zero. After executing the following code, the value of `foo' is five:
-
- foo = "a string"
- foo = foo + 5
-
- NOTE: Using a variable as a number and then later as a string can
- be confusing and is poor programming style. The previous two
- examples illustrate how `awk' works, _not_ how you should write
- your programs!
-
- An assignment is an expression, so it has a value--the same value
-that is assigned. Thus, `z = 1' is an expression with the value one.
-One consequence of this is that you can write multiple assignments
-together, such as:
-
- x = y = z = 5
-
-This example stores the value five in all three variables (`x', `y',
-and `z'). It does so because the value of `z = 5', which is five, is
-stored into `y' and then the value of `y = z = 5', which is five, is
-stored into `x'.
-
- Assignments may be used anywhere an expression is called for. For
-example, it is valid to write `x != (y = 1)' to set `y' to one, and
-then test whether `x' equals one. But this style tends to make
-programs hard to read; such nesting of assignments should be avoided,
-except perhaps in a one-shot program.
-
- Aside from `=', there are several other assignment operators that do
-arithmetic with the old value of the variable. For example, the
-operator `+=' computes a new value by adding the righthand value to the
-old value of the variable. Thus, the following assignment adds five to
-the value of `foo':
-
- foo += 5
-
-This is equivalent to the following:
-
- foo = foo + 5
-
-Use whichever makes the meaning of your program clearer.
-
- There are situations where using `+=' (or any assignment operator)
-is _not_ the same as simply repeating the lefthand operand in the
-righthand expression. For example:
-
- # Thanks to Pat Rankin for this example
- BEGIN {
- foo[rand()] += 5
- for (x in foo)
- print x, foo[x]
-
- bar[rand()] = bar[rand()] + 5
- for (x in bar)
- print x, bar[x]
- }
-
-The indices of `bar' are practically guaranteed to be different, because
-`rand' returns different values each time it is called. (Arrays and
-the `rand' function haven't been covered yet. *Note Arrays::, and see
-*Note Numeric Functions::, for more information). This example
-illustrates an important fact about assignment operators: the lefthand
-expression is only evaluated _once_. It is up to the implementation as
-to which expression is evaluated first, the lefthand or the righthand.
-Consider this example:
-
- i = 1
- a[i += 2] = i + 1
-
-The value of `a[3]' could be either two or four.
-
- *Note table-assign-ops:: lists the arithmetic assignment operators.
-In each case, the righthand operand is an expression whose value is
-converted to a number.
-
-Operator Effect
---------------------------------------------------------------------------
-LVALUE `+=' INCREMENT Adds INCREMENT to the value of LVALUE.
-LVALUE `-=' DECREMENT Subtracts DECREMENT from the value of LVALUE.
-LVALUE `*=' Multiplies the value of LVALUE by COEFFICIENT.
-COEFFICIENT
-LVALUE `/=' DIVISOR Divides the value of LVALUE by DIVISOR.
-LVALUE `%=' MODULUS Sets LVALUE to its remainder by MODULUS.
-LVALUE `^=' POWER
-LVALUE `**=' POWER Raises LVALUE to the power POWER.
-
-Table 5.1: Arithmetic Assignment Operators
-
- NOTE: Only the `^=' operator is specified by POSIX. For maximum
- portability, do not use the `**=' operator.
-
-Advanced Notes: Syntactic Ambiguities Between `/=' and Regular Expressions
---------------------------------------------------------------------------
-
-There is a syntactic ambiguity between the `/=' assignment operator and
-regexp constants whose first character is an `='. (d.c.) This is most
-notable in commercial `awk' versions. For example:
-
- $ awk /==/ /dev/null
- error--> awk: syntax error at source line 1
- error--> context is
- error--> >>> /= <<<
- error--> awk: bailing out at source line 1
-
-A workaround is:
-
- awk '/[=]=/' /dev/null
-
- `gawk' does not have this problem, nor do the other freely available
-versions described in *Note Other Versions::.
-
-5.8 Increment and Decrement Operators
-=====================================
-
-"Increment" and "decrement operators" increase or decrease the value of
-a variable by one. An assignment operator can do the same thing, so
-the increment operators add no power to the `awk' language; however,
-they are convenient abbreviations for very common operations.
-
- The operator used for adding one is written `++'. It can be used to
-increment a variable either before or after taking its value. To
-pre-increment a variable `v', write `++v'. This adds one to the value
-of `v'--that new value is also the value of the expression. (The
-assignment expression `v += 1' is completely equivalent.) Writing the
-`++' after the variable specifies post-increment. This increments the
-variable value just the same; the difference is that the value of the
-increment expression itself is the variable's _old_ value. Thus, if
-`foo' has the value four, then the expression `foo++' has the value
-four, but it changes the value of `foo' to five. In other words, the
-operator returns the old value of the variable, but with the side
-effect of incrementing it.
-
- The post-increment `foo++' is nearly the same as writing `(foo += 1)
-- 1'. It is not perfectly equivalent because all numbers in `awk' are
-floating-point--in floating-point, `foo + 1 - 1' does not necessarily
-equal `foo'. But the difference is minute as long as you stick to
-numbers that are fairly small (less than 10e12).
-
- Fields and array elements are incremented just like variables. (Use
-`$(i++)' when you want to do a field reference and a variable increment
-at the same time. The parentheses are necessary because of the
-precedence of the field reference operator `$'.)
-
- The decrement operator `--' works just like `++', except that it
-subtracts one instead of adding it. As with `++', it can be used before
-the lvalue to pre-decrement or after it to post-decrement. Following
-is a summary of increment and decrement expressions:
-
-`++LVALUE'
- This expression increments LVALUE, and the new value becomes the
- value of the expression.
-
-`LVALUE++'
- This expression increments LVALUE, but the value of the expression
- is the _old_ value of LVALUE.
-
-`--LVALUE'
- This expression is like `++LVALUE', but instead of adding, it
- subtracts. It decrements LVALUE and delivers the value that is
- the result.
-
-`LVALUE--'
- This expression is like `LVALUE++', but instead of adding, it
- subtracts. It decrements LVALUE. The value of the expression is
- the _old_ value of LVALUE.
-
-Advanced Notes: Operator Evaluation Order
------------------------------------------
-
- Doctor, doctor! It hurts when I do this!
- So don't do that!
- Groucho Marx
-
-What happens for something like the following?
-
- b = 6
- print b += b++
-
-Or something even stranger?
-
- b = 6
- b += ++b + b++
- print b
-
- In other words, when do the various side effects prescribed by the
-postfix operators (`b++') take effect? When side effects happen is
-"implementation defined". In other words, it is up to the particular
-version of `awk'. The result for the first example may be 12 or 13,
-and for the second, it may be 22 or 23.
-
- In short, doing things like this is not recommended and definitely
-not anything that you can rely upon for portability. You should avoid
-such things in your own programs.
-
-5.9 True and False in `awk'
-===========================
-
-Many programming languages have a special representation for the
-concepts of "true" and "false." Such languages usually use the special
-constants `true' and `false', or perhaps their uppercase equivalents.
-However, `awk' is different. It borrows a very simple concept of true
-and false from C. In `awk', any nonzero numeric value _or_ any
-nonempty string value is true. Any other value (zero or the null
-string `""') is false. The following program prints `A strange truth
-value' three times:
-
- BEGIN {
- if (3.1415927)
- print "A strange truth value"
- if ("Four Score And Seven Years Ago")
- print "A strange truth value"
- if (j = 57)
- print "A strange truth value"
- }
-
- There is a surprising consequence of the "nonzero or non-null" rule:
-the string constant `"0"' is actually true, because it is non-null.
-(d.c.)
-
-5.10 Variable Typing and Comparison Expressions
-===============================================
-
- The Guide is definitive. Reality is frequently inaccurate.
- The Hitchhiker's Guide to the Galaxy
-
- Unlike other programming languages, `awk' variables do not have a
-fixed type. Instead, they can be either a number or a string, depending
-upon the value that is assigned to them.
-
- The 1992 POSIX standard introduced the concept of a "numeric
-string", which is simply a string that looks like a number--for
-example, `" +2"'. This concept is used for determining the type of a
-variable. The type of the variable is important because the types of
-two variables determine how they are compared. In `gawk', variable
-typing follows these rules:
-
- * A numeric constant or the result of a numeric operation has the
- NUMERIC attribute.
-
- * A string constant or the result of a string operation has the
- STRING attribute.
-
- * Fields, `getline' input, `FILENAME', `ARGV' elements, `ENVIRON'
- elements, and the elements of an array created by `split' that are
- numeric strings have the STRNUM attribute. Otherwise, they have
- the STRING attribute. Uninitialized variables also have the
- STRNUM attribute.
-
- * Attributes propagate across assignments but are not changed by any
- use.
-
- The last rule is particularly important. In the following program,
-`a' has numeric type, even though it is later used in a string
-operation:
-
- BEGIN {
- a = 12.345
- b = a " is a cute number"
- print b
- }
-
- When two operands are compared, either string comparison or numeric
-comparison may be used. This depends upon the attributes of the
-operands, according to the following symmetric matrix:
-
- +---------------------------------------------
- | STRING NUMERIC STRNUM
- -------+---------------------------------------------
- |
- STRING | string string string
- |
- NUMERIC | string numeric numeric
- |
- STRNUM | string numeric numeric
- -------+---------------------------------------------
-
- The basic idea is that user input that looks numeric--and _only_
-user input--should be treated as numeric, even though it is actually
-made of characters and is therefore also a string. Thus, for example,
-the string constant `" +3.14"' is a string, even though it looks
-numeric, and is _never_ treated as number for comparison purposes.
-
- In short, when one operand is a "pure" string, such as a string
-constant, then a string comparison is performed. Otherwise, a numeric
-comparison is performed.(1)
-
- "Comparison expressions" compare strings or numbers for
-relationships such as equality. They are written using "relational
-operators", which are a superset of those in C. *Note
-table-relational-ops:: describes them.
-
-Expression Result
---------------------------------------------------------------------------
-X `<' Y True if X is less than Y.
-X `<=' Y True if X is less than or equal to Y.
-X `>' Y True if X is greater than Y.
-X `>=' Y True if X is greater than or equal to Y.
-X `==' Y True if X is equal to Y.
-X `!=' Y True if X is not equal to Y.
-X `~' Y True if the string X matches the regexp denoted by Y.
-X `!~' Y True if the string X does not match the regexp
- denoted by Y.
-SUBSCRIPT `in' True if the array ARRAY has an element with the
-ARRAY subscript SUBSCRIPT.
-
-Table 5.2: Relational Operators
-
- Comparison expressions have the value one if true and zero if false.
-When comparing operands of mixed types, numeric operands are converted
-to strings using the value of `CONVFMT' (*note Conversion::).
-
- Strings are compared by comparing the first character of each, then
-the second character of each, and so on. Thus, `"10"' is less than
-`"9"'. If there are two strings where one is a prefix of the other,
-the shorter string is less than the longer one. Thus, `"abc"' is less
-than `"abcd"'.
-
- It is very easy to accidentally mistype the `==' operator and leave
-off one of the `=' characters. The result is still valid `awk' code,
-but the program does not do what is intended:
-
- if (a = b) # oops! should be a == b
- ...
- else
- ...
-
-Unless `b' happens to be zero or the null string, the `if' part of the
-test always succeeds. Because the operators are so similar, this kind
-of error is very difficult to spot when scanning the source code.
-
- The following table of expressions illustrates the kind of comparison
-`gawk' performs, as well as what the result of the comparison is:
-
-`1.5 <= 2.0'
- numeric comparison (true)
-
-`"abc" >= "xyz"'
- string comparison (false)
-
-`1.5 != " +2"'
- string comparison (true)
-
-`"1e2" < "3"'
- string comparison (true)
-
-`a = 2; b = "2"'
-`a == b'
- string comparison (true)
-
-`a = 2; b = " +2"'
-
-`a == b'
- string comparison (false)
-
- In the next example:
-
- $ echo 1e2 3 | awk '{ print ($1 < $2) ? "true" : "false" }'
- -| false
-
-the result is `false' because both `$1' and `$2' are user input. They
-are numeric strings--therefore both have the STRNUM attribute,
-dictating a numeric comparison. The purpose of the comparison rules
-and the use of numeric strings is to attempt to produce the behavior
-that is "least surprising," while still "doing the right thing."
-String comparisons and regular expression comparisons are very
-different. For example:
-
- x == "foo"
-
-has the value one, or is true if the variable `x' is precisely `foo'.
-By contrast:
-
- x ~ /foo/
-
-has the value one if `x' contains `foo', such as `"Oh, what a fool am
-I!"'.
-
- The righthand operand of the `~' and `!~' operators may be either a
-regexp constant (`/.../') or an ordinary expression. In the latter
-case, the value of the expression as a string is used as a dynamic
-regexp (*note Regexp Usage::; also *note Computed Regexps::).
-
- In modern implementations of `awk', a constant regular expression in
-slashes by itself is also an expression. The regexp `/REGEXP/' is an
-abbreviation for the following comparison expression:
-
- $0 ~ /REGEXP/
-
- One special place where `/foo/' is _not_ an abbreviation for `$0 ~
-/foo/' is when it is the righthand operand of `~' or `!~'. *Note Using
-Constant Regexps::, where this is discussed in more detail.
-
- ---------- Footnotes ----------
-
- (1) The POSIX standard is under revision. The revised standard's
-rules for typing and comparison are the same as just described for
-`gawk'.
-
-5.11 Boolean Expressions
-========================
-
-A "Boolean expression" is a combination of comparison expressions or
-matching expressions, using the Boolean operators "or" (`||'), "and"
-(`&&'), and "not" (`!'), along with parentheses to control nesting.
-The truth value of the Boolean expression is computed by combining the
-truth values of the component expressions. Boolean expressions are
-also referred to as "logical expressions". The terms are equivalent.
-
- Boolean expressions can be used wherever comparison and matching
-expressions can be used. They can be used in `if', `while', `do', and
-`for' statements (*note Statements::). They have numeric values (one
-if true, zero if false) that come into play if the result of the
-Boolean expression is stored in a variable or used in arithmetic.
-
- In addition, every Boolean expression is also a valid pattern, so
-you can use one as a pattern to control the execution of rules. The
-Boolean operators are:
-
-`BOOLEAN1 && BOOLEAN2'
- True if both BOOLEAN1 and BOOLEAN2 are true. For example, the
- following statement prints the current input record if it contains
- both `2400' and `foo':
-
- if ($0 ~ /2400/ && $0 ~ /foo/) print
-
- The subexpression BOOLEAN2 is evaluated only if BOOLEAN1 is true.
- This can make a difference when BOOLEAN2 contains expressions that
- have side effects. In the case of `$0 ~ /foo/ && ($2 == bar++)',
- the variable `bar' is not incremented if there is no substring
- `foo' in the record.
-
-`BOOLEAN1 || BOOLEAN2'
- True if at least one of BOOLEAN1 or BOOLEAN2 is true. For
- example, the following statement prints all records in the input
- that contain _either_ `2400' or `foo' or both:
-
- if ($0 ~ /2400/ || $0 ~ /foo/) print
-
- The subexpression BOOLEAN2 is evaluated only if BOOLEAN1 is false.
- This can make a difference when BOOLEAN2 contains expressions
- that have side effects.
-
-`! BOOLEAN'
- True if BOOLEAN is false. For example, the following program
- prints `no home!' in the unusual event that the `HOME' environment
- variable is not defined:
-
- BEGIN { if (! ("HOME" in ENVIRON))
- print "no home!" }
-
- (The `in' operator is described in *Note Reference to Elements::.)
-
- The `&&' and `||' operators are called "short-circuit" operators
-because of the way they work. Evaluation of the full expression is
-"short-circuited" if the result can be determined part way through its
-evaluation.
-
- Statements that use `&&' or `||' can be continued simply by putting
-a newline after them. But you cannot put a newline in front of either
-of these operators without using backslash continuation (*note
-Statements/Lines::).
-
- The actual value of an expression using the `!' operator is either
-one or zero, depending upon the truth value of the expression it is
-applied to. The `!' operator is often useful for changing the sense of
-a flag variable from false to true and back again. For example, the
-following program is one way to print lines in between special
-bracketing lines:
-
- $1 == "START" { interested = ! interested; next }
- interested == 1 { print }
- $1 == "END" { interested = ! interested; next }
-
-The variable `interested', as with all `awk' variables, starts out
-initialized to zero, which is also false. When a line is seen whose
-first field is `START', the value of `interested' is toggled to true,
-using `!'. The next rule prints lines as long as `interested' is true.
-When a line is seen whose first field is `END', `interested' is toggled
-back to false.
-
- NOTE: The `next' statement is discussed in *Note Next Statement::.
- `next' tells `awk' to skip the rest of the rules, get the next
- record, and start processing the rules over again at the top. The
- reason it's there is to avoid printing the bracketing `START' and
- `END' lines.
-
-5.12 Conditional Expressions
-============================
-
-A "conditional expression" is a special kind of expression that has
-three operands. It allows you to use one expression's value to select
-one of two other expressions. The conditional expression is the same
-as in the C language, as shown here:
-
- SELECTOR ? IF-TRUE-EXP : IF-FALSE-EXP
-
-There are three subexpressions. The first, SELECTOR, is always
-computed first. If it is "true" (not zero or not null), then
-IF-TRUE-EXP is computed next and its value becomes the value of the
-whole expression. Otherwise, IF-FALSE-EXP is computed next and its
-value becomes the value of the whole expression. For example, the
-following expression produces the absolute value of `x':
-
- x >= 0 ? x : -x
-
- Each time the conditional expression is computed, only one of
-IF-TRUE-EXP and IF-FALSE-EXP is used; the other is ignored. This is
-important when the expressions have side effects. For example, this
-conditional expression examines element `i' of either array `a' or
-array `b', and increments `i':
-
- x == y ? a[i++] : b[i++]
-
-This is guaranteed to increment `i' exactly once, because each time
-only one of the two increment expressions is executed and the other is
-not. *Note Arrays::, for more information about arrays.
-
- As a minor `gawk' extension, a statement that uses `?:' can be
-continued simply by putting a newline after either character. However,
-putting a newline in front of either character does not work without
-using backslash continuation (*note Statements/Lines::). If `--posix'
-is specified (*note Options::), then this extension is disabled.
-
-5.13 Function Calls
-===================
-
-A "function" is a name for a particular calculation. This enables you
-to ask for it by name at any point in the program. For example, the
-function `sqrt' computes the square root of a number.
-
- A fixed set of functions are "built-in", which means they are
-available in every `awk' program. The `sqrt' function is one of these.
-*Note Built-in::, for a list of built-in functions and their
-descriptions. In addition, you can define functions for use in your
-program. *Note User-defined::, for instructions on how to do this.
-
- The way to use a function is with a "function call" expression,
-which consists of the function name followed immediately by a list of
-"arguments" in parentheses. The arguments are expressions that provide
-the raw materials for the function's calculations. When there is more
-than one argument, they are separated by commas. If there are no
-arguments, just write `()' after the function name. The following
-examples show function calls with and without arguments:
-
- sqrt(x^2 + y^2) one argument
- atan2(y, x) two arguments
- rand() no arguments
-
- *Caution:* Do not put any space between the function name and the
-open-parenthesis! A user-defined function name looks just like the
-name of a variable--a space would make the expression look like
-concatenation of a variable with an expression inside parentheses.
-
- With built-in functions, space before the parenthesis is harmless,
-but it is best not to get into the habit of using space to avoid
-mistakes with user-defined functions. Each function expects a
-particular number of arguments. For example, the `sqrt' function must
-be called with a single argument, the number of which to take the
-square root:
-
- sqrt(ARGUMENT)
-
- Some of the built-in functions have one or more optional arguments.
-If those arguments are not supplied, the functions use a reasonable
-default value. *Note Built-in::, for full details. If arguments are
-omitted in calls to user-defined functions, then those arguments are
-treated as local variables and initialized to the empty string (*note
-User-defined::).
-
- Like every other expression, the function call has a value, which is
-computed by the function based on the arguments you give it. In this
-example, the value of `sqrt(ARGUMENT)' is the square root of ARGUMENT.
-A function can also have side effects, such as assigning values to
-certain variables or doing I/O. The following program reads numbers,
-one number per line, and prints the square root of each one:
-
- $ awk '{ print "The square root of", $1, "is", sqrt($1) }'
- 1
- -| The square root of 1 is 1
- 3
- -| The square root of 3 is 1.73205
- 5
- -| The square root of 5 is 2.23607
- Ctrl-d
-
-5.14 Operator Precedence (How Operators Nest)
-=============================================
-
-"Operator precedence" determines how operators are grouped when
-different operators appear close by in one expression. For example,
-`*' has higher precedence than `+'; thus, `a + b * c' means to multiply
-`b' and `c', and then add `a' to the product (i.e., `a + (b * c)').
-
- The normal precedence of the operators can be overruled by using
-parentheses. Think of the precedence rules as saying where the
-parentheses are assumed to be. In fact, it is wise to always use
-parentheses whenever there is an unusual combination of operators,
-because other people who read the program may not remember what the
-precedence is in this case. Even experienced programmers occasionally
-forget the exact rules, which leads to mistakes. Explicit parentheses
-help prevent any such mistakes.
-
- When operators of equal precedence are used together, the leftmost
-operator groups first, except for the assignment, conditional, and
-exponentiation operators, which group in the opposite order. Thus, `a
-- b + c' groups as `(a - b) + c' and `a = b = c' groups as `a = (b =
-c)'.
-
- The precedence of prefix unary operators does not matter as long as
-only unary operators are involved, because there is only one way to
-interpret them: innermost first. Thus, `$++i' means `$(++i)' and
-`++$x' means `++($x)'. However, when another operator follows the
-operand, then the precedence of the unary operators can matter. `$x^2'
-means `($x)^2', but `-x^2' means `-(x^2)', because `-' has lower
-precedence than `^', whereas `$' has higher precedence. This table
-presents `awk''s operators, in order of highest to lowest precedence:
-
-`(...)'
- Grouping.
-
-`$'
- Field.
-
-`++ --'
- Increment, decrement.
-
-`^ **'
- Exponentiation. These operators group right-to-left.
-
-`+ - !'
- Unary plus, minus, logical "not."
-
-`* / %'
- Multiplication, division, modulus.
-
-`+ -'
- Addition, subtraction.
-
-`String Concatenation'
- No special symbol is used to indicate concatenation. The operands
- are simply written side by side (*note Concatenation::).
-
-`< <= == !='
-`> >= >> | |&'
- Relational and redirection. The relational operators and the
- redirections have the same precedence level. Characters such as
- `>' serve both as relationals and as redirections; the context
- distinguishes between the two meanings.
-
- Note that the I/O redirection operators in `print' and `printf'
- statements belong to the statement level, not to expressions. The
- redirection does not produce an expression that could be the
- operand of another operator. As a result, it does not make sense
- to use a redirection operator near another operator of lower
- precedence without parentheses. Such combinations (for example,
- `print foo > a ? b : c'), result in syntax errors. The correct
- way to write this statement is `print foo > (a ? b : c)'.
-
-`~ !~'
- Matching, nonmatching.
-
-`in'
- Array membership.
-
-`&&'
- Logical "and".
-
-`||'
- Logical "or".
-
-`?:'
- Conditional. This operator groups right-to-left.
-
-`= += -= *='
-`/= %= ^= **='
- Assignment. These operators group right to left.
-
- NOTE: The `|&', `**', and `**=' operators are not specified by
- POSIX. For maximum portability, do not use them.
-
-6 Patterns, Actions, and Variables
-**********************************
-
-As you have already seen, each `awk' statement consists of a pattern
-with an associated action. This major node describes how you build
-patterns and actions, what kinds of things you can do within actions,
-and `awk''s built-in variables.
-
- The pattern-action rules and the statements available for use within
-actions form the core of `awk' programming. In a sense, everything
-covered up to here has been the foundation that programs are built on
-top of. Now it's time to start building something useful.
-
-6.1 Pattern Elements
-====================
-
-Patterns in `awk' control the execution of rules--a rule is executed
-when its pattern matches the current input record. The following is a
-summary of the types of `awk' patterns:
-
-`/REGULAR EXPRESSION/'
- A regular expression. It matches when the text of the input record
- fits the regular expression. (*Note Regexp::.)
-
-`EXPRESSION'
- A single expression. It matches when its value is nonzero (if a
- number) or non-null (if a string). (*Note Expression Patterns::.)
-
-`PAT1, PAT2'
- A pair of patterns separated by a comma, specifying a range of
- records. The range includes both the initial record that matches
- PAT1 and the final record that matches PAT2. (*Note Ranges::.)
-
-`BEGIN'
-`END'
- Special patterns for you to supply startup or cleanup actions for
- your `awk' program. (*Note BEGIN/END::.)
-
-`EMPTY'
- The empty pattern matches every input record. (*Note Empty::.)
-
-6.1.1 Regular Expressions as Patterns
--------------------------------------
-
-Regular expressions are one of the first kinds of patterns presented in
-this book. This kind of pattern is simply a regexp constant in the
-pattern part of a rule. Its meaning is `$0 ~ /PATTERN/'. The pattern
-matches when the input record matches the regexp. For example:
-
- /foo|bar|baz/ { buzzwords++ }
- END { print buzzwords, "buzzwords seen" }
-
-6.1.2 Expressions as Patterns
------------------------------
-
-Any `awk' expression is valid as an `awk' pattern. The pattern matches
-if the expression's value is nonzero (if a number) or non-null (if a
-string). The expression is reevaluated each time the rule is tested
-against a new input record. If the expression uses fields such as
-`$1', the value depends directly on the new input record's text;
-otherwise, it depends on only what has happened so far in the execution
-of the `awk' program.
-
- Comparison expressions, using the comparison operators described in
-*Note Typing and Comparison::, are a very common kind of pattern.
-Regexp matching and nonmatching are also very common expressions. The
-left operand of the `~' and `!~' operators is a string. The right
-operand is either a constant regular expression enclosed in slashes
-(`/REGEXP/'), or any expression whose string value is used as a dynamic
-regular expression (*note Computed Regexps::). The following example
-prints the second field of each input record whose first field is
-precisely `foo':
-
- $ awk '$1 == "foo" { print $2 }' BBS-list
-
-(There is no output, because there is no BBS site with the exact name
-`foo'.) Contrast this with the following regular expression match,
-which accepts any record with a first field that contains `foo':
-
- $ awk '$1 ~ /foo/ { print $2 }' BBS-list
- -| 555-1234
- -| 555-6699
- -| 555-6480
- -| 555-2127
-
- A regexp constant as a pattern is also a special case of an
-expression pattern. The expression `/foo/' has the value one if `foo'
-appears in the current input record. Thus, as a pattern, `/foo/'
-matches any record containing `foo'.
-
- Boolean expressions are also commonly used as patterns. Whether the
-pattern matches an input record depends on whether its subexpressions
-match. For example, the following command prints all the records in
-`BBS-list' that contain both `2400' and `foo':
-
- $ awk '/2400/ && /foo/' BBS-list
- -| fooey 555-1234 2400/1200/300 B
-
- The following command prints all records in `BBS-list' that contain
-_either_ `2400' or `foo' (or both, of course):
-
- $ awk '/2400/ || /foo/' BBS-list
- -| alpo-net 555-3412 2400/1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sdace 555-3430 2400/1200/300 A
- -| sabafoo 555-2127 1200/300 C
-
- The following command prints all records in `BBS-list' that do _not_
-contain the string `foo':
-
- $ awk '! /foo/' BBS-list
- -| aardvark 555-5553 1200/300 B
- -| alpo-net 555-3412 2400/1200/300 A
- -| barfly 555-7685 1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| camelot 555-0542 300 C
- -| core 555-2912 1200/300 C
- -| sdace 555-3430 2400/1200/300 A
-
- The subexpressions of a Boolean operator in a pattern can be
-constant regular expressions, comparisons, or any other `awk'
-expressions. Range patterns are not expressions, so they cannot appear
-inside Boolean patterns. Likewise, the special patterns `BEGIN' and
-`END', which never match any input record, are not expressions and
-cannot appear inside Boolean patterns.
-
-6.1.3 Specifying Record Ranges with Patterns
---------------------------------------------
-
-A "range pattern" is made of two patterns separated by a comma, in the
-form `BEGPAT, ENDPAT'. It is used to match ranges of consecutive input
-records. The first pattern, BEGPAT, controls where the range begins,
-while ENDPAT controls where the pattern ends. For example, the
-following:
-
- awk '$1 == "on", $1 == "off"' myfile
-
-prints every record in `myfile' between `on'/`off' pairs, inclusive.
-
- A range pattern starts out by matching BEGPAT against every input
-record. When a record matches BEGPAT, the range pattern is "turned on"
-and the range pattern matches this record as well. As long as the
-range pattern stays turned on, it automatically matches every input
-record read. The range pattern also matches ENDPAT against every input
-record; when this succeeds, the range pattern is turned off again for
-the following record. Then the range pattern goes back to checking
-BEGPAT against each record.
-
- The record that turns on the range pattern and the one that turns it
-off both match the range pattern. If you don't want to operate on
-these records, you can write `if' statements in the rule's action to
-distinguish them from the records you are interested in.
-
- It is possible for a pattern to be turned on and off by the same
-record. If the record satisfies both conditions, then the action is
-executed for just that record. For example, suppose there is text
-between two identical markers (e.g., the `%' symbol), each on its own
-line, that should be ignored. A first attempt would be to combine a
-range pattern that describes the delimited text with the `next'
-statement (not discussed yet, *note Next Statement::). This causes
-`awk' to skip any further processing of the current record and start
-over again with the next input record. Such a program looks like this:
-
- /^%$/,/^%$/ { next }
- { print }
-
-This program fails because the range pattern is both turned on and
-turned off by the first line, which just has a `%' on it. To
-accomplish this task, write the program in the following manner, using
-a flag:
-
- /^%$/ { skip = ! skip; next }
- skip == 1 { next } # skip lines with `skip' set
-
- In a range pattern, the comma (`,') has the lowest precedence of all
-the operators (i.e., it is evaluated last). Thus, the following
-program attempts to combine a range pattern with another, simpler test:
-
- echo Yes | awk '/1/,/2/ || /Yes/'
-
- The intent of this program is `(/1/,/2/) || /Yes/'. However, `awk'
-interprets this as `/1/, (/2/ || /Yes/)'. This cannot be changed or
-worked around; range patterns do not combine with other patterns:
-
- $ echo Yes | gawk '(/1/,/2/) || /Yes/'
- error--> gawk: cmd. line:1: (/1/,/2/) || /Yes/
- error--> gawk: cmd. line:1: ^ parse error
- error--> gawk: cmd. line:2: (/1/,/2/) || /Yes/
- error--> gawk: cmd. line:2: ^ unexpected newline
-
-6.1.4 The `BEGIN' and `END' Special Patterns
---------------------------------------------
-
-All the patterns described so far are for matching input records. The
-`BEGIN' and `END' special patterns are different. They supply startup
-and cleanup actions for `awk' programs. `BEGIN' and `END' rules must
-have actions; there is no default action for these rules because there
-is no current record when they run. `BEGIN' and `END' rules are often
-referred to as "`BEGIN' and `END' blocks" by long-time `awk'
-programmers.
-
-6.1.4.1 Startup and Cleanup Actions
-...................................
-
-A `BEGIN' rule is executed once only, before the first input record is
-read. Likewise, an `END' rule is executed once only, after all the
-input is read. For example:
-
- $ awk '
- > BEGIN { print "Analysis of \"foo\"" }
- > /foo/ { ++n }
- > END { print "\"foo\" appears", n, "times." }' BBS-list
- -| Analysis of "foo"
- -| "foo" appears 4 times.
-
- This program finds the number of records in the input file `BBS-list'
-that contain the string `foo'. The `BEGIN' rule prints a title for the
-report. There is no need to use the `BEGIN' rule to initialize the
-counter `n' to zero, since `awk' does this automatically (*note
-Variables::). The second rule increments the variable `n' every time a
-record containing the pattern `foo' is read. The `END' rule prints the
-value of `n' at the end of the run.
-
- The special patterns `BEGIN' and `END' cannot be used in ranges or
-with Boolean operators (indeed, they cannot be used with any operators).
-An `awk' program may have multiple `BEGIN' and/or `END' rules. They
-are executed in the order in which they appear: all the `BEGIN' rules
-at startup and all the `END' rules at termination. `BEGIN' and `END'
-rules may be intermixed with other rules. This feature was added in
-the 1987 version of `awk' and is included in the POSIX standard. The
-original (1978) version of `awk' required the `BEGIN' rule to be placed
-at the beginning of the program, the `END' rule to be placed at the
-end, and only allowed one of each. This is no longer required, but it
-is a good idea to follow this template in terms of program organization
-and readability.
-
- Multiple `BEGIN' and `END' rules are useful for writing library
-functions, because each library file can have its own `BEGIN' and/or
-`END' rule to do its own initialization and/or cleanup. The order in
-which library functions are named on the command line controls the
-order in which their `BEGIN' and `END' rules are executed. Therefore,
-you have to be careful when writing such rules in library files so that
-the order in which they are executed doesn't matter. *Note Options::,
-for more information on using library functions. *Note Library
-Functions::, for a number of useful library functions.
-
- If an `awk' program has only a `BEGIN' rule and no other rules, then
-the program exits after the `BEGIN' rule is run.(1) However, if an
-`END' rule exists, then the input is read, even if there are no other
-rules in the program. This is necessary in case the `END' rule checks
-the `FNR' and `NR' variables.
-
- ---------- Footnotes ----------
-
- (1) The original version of `awk' used to keep reading and ignoring
-input until the end of the file was seen.
-
-6.1.4.2 Input/Output from `BEGIN' and `END' Rules
-.................................................
-
-There are several (sometimes subtle) points to remember when doing I/O
-from a `BEGIN' or `END' rule. The first has to do with the value of
-`$0' in a `BEGIN' rule. Because `BEGIN' rules are executed before any
-input is read, there simply is no input record, and therefore no
-fields, when executing `BEGIN' rules. References to `$0' and the fields
-yield a null string or zero, depending upon the context. One way to
-give `$0' a real value is to execute a `getline' command without a
-variable (*note Getline::). Another way is simply to assign a value to
-`$0'.
-
- The second point is similar to the first but from the other
-direction. Traditionally, due largely to implementation issues, `$0'
-and `NF' were _undefined_ inside an `END' rule. The POSIX standard
-specifies that `NF' is available in an `END' rule. It contains the
-number of fields from the last input record. Most probably due to an
-oversight, the standard does not say that `$0' is also preserved,
-although logically one would think that it should be. In fact, `gawk'
-does preserve the value of `$0' for use in `END' rules. Be aware,
-however, that Unix `awk', and possibly other implementations, do not.
-
- The third point follows from the first two. The meaning of `print'
-inside a `BEGIN' or `END' rule is the same as always: `print $0'. If
-`$0' is the null string, then this prints an empty line. Many long
-time `awk' programmers use an unadorned `print' in `BEGIN' and `END'
-rules, to mean `print ""', relying on `$0' being null. Although one
-might generally get away with this in `BEGIN' rules, it is a very bad
-idea in `END' rules, at least in `gawk'. It is also poor style, since
-if an empty line is needed in the output, the program should print one
-explicitly.
-
- Finally, the `next' and `nextfile' statements are not allowed in a
-`BEGIN' rule, because the implicit
-read-a-record-and-match-against-the-rules loop has not started yet.
-Similarly, those statements are not valid in an `END' rule, since all
-the input has been read. (*Note Next Statement::, and see *Note
-Nextfile Statement::.)
-
-6.1.5 The Empty Pattern
------------------------
-
-An empty (i.e., nonexistent) pattern is considered to match _every_
-input record. For example, the program:
-
- awk '{ print $1 }' BBS-list
-
-prints the first field of every record.
-
-6.2 Using Shell Variables in Programs
-=====================================
-
-`awk' programs are often used as components in larger programs written
-in shell. For example, it is very common to use a shell variable to
-hold a pattern that the `awk' program searches for. There are two ways
-to get the value of the shell variable into the body of the `awk'
-program.
-
- The most common method is to use shell quoting to substitute the
-variable's value into the program inside the script. For example, in
-the following program:
-
- echo -n "Enter search pattern: "
- read pattern
- awk "/$pattern/ "'{ nmatches++ }
- END { print nmatches, "found" }' /path/to/data
-
-the `awk' program consists of two pieces of quoted text that are
-concatenated together to form the program. The first part is
-double-quoted, which allows substitution of the `pattern' variable
-inside the quotes. The second part is single-quoted.
-
- Variable substitution via quoting works, but can be potentially
-messy. It requires a good understanding of the shell's quoting rules
-(*note Quoting::), and it's often difficult to correctly match up the
-quotes when reading the program.
-
- A better method is to use `awk''s variable assignment feature (*note
-Assignment Options::) to assign the shell variable's value to an `awk'
-variable's value. Then use dynamic regexps to match the pattern (*note
-Computed Regexps::). The following shows how to redo the previous
-example using this technique:
-
- echo -n "Enter search pattern: "
- read pattern
- awk -v pat="$pattern" '$0 ~ pat { nmatches++ }
- END { print nmatches, "found" }' /path/to/data
-
-Now, the `awk' program is just one single-quoted string. The
-assignment `-v pat="$pattern"' still requires double quotes, in case
-there is whitespace in the value of `$pattern'. The `awk' variable
-`pat' could be named `pattern' too, but that would be more confusing.
-Using a variable also provides more flexibility, since the variable can
-be used anywhere inside the program--for printing, as an array
-subscript, or for any other use--without requiring the quoting tricks
-at every point in the program.
-
-6.3 Actions
-===========
-
-An `awk' program or script consists of a series of rules and function
-definitions interspersed. (Functions are described later. *Note
-User-defined::.) A rule contains a pattern and an action, either of
-which (but not both) may be omitted. The purpose of the "action" is to
-tell `awk' what to do once a match for the pattern is found. Thus, in
-outline, an `awk' program generally looks like this:
-
- [PATTERN] [{ ACTION }]
- [PATTERN] [{ ACTION }]
- ...
- function NAME(ARGS) { ... }
- ...
-
- An action consists of one or more `awk' "statements", enclosed in
-curly braces (`{...}'). Each statement specifies one thing to do. The
-statements are separated by newlines or semicolons. The curly braces
-around an action must be used even if the action contains only one
-statement, or if it contains no statements at all. However, if you
-omit the action entirely, omit the curly braces as well. An omitted
-action is equivalent to `{ print $0 }':
-
- /foo/ { } match `foo', do nothing -- empty action
- /foo/ match `foo', print the record -- omitted action
-
- The following types of statements are supported in `awk':
-
-Expressions
- Call functions or assign values to variables (*note
- Expressions::). Executing this kind of statement simply computes
- the value of the expression. This is useful when the expression
- has side effects (*note Assignment Ops::).
-
-Control statements
- Specify the control flow of `awk' programs. The `awk' language
- gives you C-like constructs (`if', `for', `while', and `do') as
- well as a few special ones (*note Statements::).
-
-Compound statements
- Consist of one or more statements enclosed in curly braces. A
- compound statement is used in order to put several statements
- together in the body of an `if', `while', `do', or `for' statement.
-
-Input statements
- Use the `getline' command (*note Getline::). Also supplied in
- `awk' are the `next' statement (*note Next Statement::), and the
- `nextfile' statement (*note Nextfile Statement::).
-
-Output statements
- Such as `print' and `printf'. *Note Printing::.
-
-Deletion statements
- For deleting array elements. *Note Delete::.
-
-6.4 Control Statements in Actions
-=================================
-
-"Control statements", such as `if', `while', and so on, control the
-flow of execution in `awk' programs. Most of the control statements in
-`awk' are patterned on similar statements in C.
-
- All the control statements start with special keywords, such as `if'
-and `while', to distinguish them from simple expressions. Many control
-statements contain other statements. For example, the `if' statement
-contains another statement that may or may not be executed. The
-contained statement is called the "body". To include more than one
-statement in the body, group them into a single "compound statement"
-with curly braces, separating them with newlines or semicolons.
-
-6.4.1 The `if'-`else' Statement
--------------------------------
-
-The `if'-`else' statement is `awk''s decision-making statement. It
-looks like this:
-
- if (CONDITION) THEN-BODY [else ELSE-BODY]
-
-The CONDITION is an expression that controls what the rest of the
-statement does. If the CONDITION is true, THEN-BODY is executed;
-otherwise, ELSE-BODY is executed. The `else' part of the statement is
-optional. The condition is considered false if its value is zero or
-the null string; otherwise, the condition is true. Refer to the
-following:
-
- if (x % 2 == 0)
- print "x is even"
- else
- print "x is odd"
-
- In this example, if the expression `x % 2 == 0' is true (that is, if
-the value of `x' is evenly divisible by two), then the first `print'
-statement is executed; otherwise, the second `print' statement is
-executed. If the `else' keyword appears on the same line as THEN-BODY
-and THEN-BODY is not a compound statement (i.e., not surrounded by
-curly braces), then a semicolon must separate THEN-BODY from the `else'.
-To illustrate this, the previous example can be rewritten as:
-
- if (x % 2 == 0) print "x is even"; else
- print "x is odd"
-
-If the `;' is left out, `awk' can't interpret the statement and it
-produces a syntax error. Don't actually write programs this way,
-because a human reader might fail to see the `else' if it is not the
-first thing on its line.
-
-6.4.2 The `while' Statement
----------------------------
-
-In programming, a "loop" is a part of a program that can be executed
-two or more times in succession. The `while' statement is the simplest
-looping statement in `awk'. It repeatedly executes a statement as long
-as a condition is true. For example:
-
- while (CONDITION)
- BODY
-
-BODY is a statement called the "body" of the loop, and CONDITION is an
-expression that controls how long the loop keeps running. The first
-thing the `while' statement does is test the CONDITION. If the
-CONDITION is true, it executes the statement BODY. (The CONDITION is
-true when the value is not zero and not a null string.) After BODY has
-been executed, CONDITION is tested again, and if it is still true, BODY
-is executed again. This process repeats until the CONDITION is no
-longer true. If the CONDITION is initially false, the body of the loop
-is never executed and `awk' continues with the statement following the
-loop. This example prints the first three fields of each record, one
-per line:
-
- awk '{ i = 1
- while (i <= 3) {
- print $i
- i++
- }
- }' inventory-shipped
-
-The body of this loop is a compound statement enclosed in braces,
-containing two statements. The loop works in the following manner:
-first, the value of `i' is set to one. Then, the `while' statement
-tests whether `i' is less than or equal to three. This is true when
-`i' equals one, so the `i'-th field is printed. Then the `i++'
-increments the value of `i' and the loop repeats. The loop terminates
-when `i' reaches four.
-
- A newline is not required between the condition and the body;
-however using one makes the program clearer unless the body is a
-compound statement or else is very simple. The newline after the
-open-brace that begins the compound statement is not required either,
-but the program is harder to read without it.
-
-6.4.3 The `do'-`while' Statement
---------------------------------
-
-The `do' loop is a variation of the `while' looping statement. The
-`do' loop executes the BODY once and then repeats the BODY as long as
-the CONDITION is true. It looks like this:
-
- do
- BODY
- while (CONDITION)
-
- Even if the CONDITION is false at the start, the BODY is executed at
-least once (and only once, unless executing BODY makes CONDITION true).
-Contrast this with the corresponding `while' statement:
-
- while (CONDITION)
- BODY
-
-This statement does not execute BODY even once if the CONDITION is
-false to begin with. The following is an example of a `do' statement:
-
- { i = 1
- do {
- print $0
- i++
- } while (i <= 10)
- }
-
-This program prints each input record 10 times. However, it isn't a
-very realistic example, since in this case an ordinary `while' would do
-just as well. This situation reflects actual experience; only
-occasionally is there a real use for a `do' statement.
-
-6.4.4 The `for' Statement
--------------------------
-
-The `for' statement makes it more convenient to count iterations of a
-loop. The general form of the `for' statement looks like this:
-
- for (INITIALIZATION; CONDITION; INCREMENT)
- BODY
-
-The INITIALIZATION, CONDITION, and INCREMENT parts are arbitrary `awk'
-expressions, and BODY stands for any `awk' statement.
-
- The `for' statement starts by executing INITIALIZATION. Then, as
-long as the CONDITION is true, it repeatedly executes BODY and then
-INCREMENT. Typically, INITIALIZATION sets a variable to either zero or
-one, INCREMENT adds one to it, and CONDITION compares it against the
-desired number of iterations. For example:
-
- awk '{ for (i = 1; i <= 3; i++)
- print $i
- }' inventory-shipped
-
-This prints the first three fields of each input record, with one field
-per line.
-
- It isn't possible to set more than one variable in the
-INITIALIZATION part without using a multiple assignment statement such
-as `x = y = 0'. This makes sense only if all the initial values are
-equal. (But it is possible to initialize additional variables by
-writing their assignments as separate statements preceding the `for'
-loop.)
-
- The same is true of the INCREMENT part. Incrementing additional
-variables requires separate statements at the end of the loop. The C
-compound expression, using C's comma operator, is useful in this
-context but it is not supported in `awk'.
-
- Most often, INCREMENT is an increment expression, as in the previous
-example. But this is not required; it can be any expression
-whatsoever. For example, the following statement prints all the powers
-of two between 1 and 100:
-
- for (i = 1; i <= 100; i *= 2)
- print i
-
- If there is nothing to be done, any of the three expressions in the
-parentheses following the `for' keyword may be omitted. Thus,
-`for (; x > 0;)' is equivalent to `while (x > 0)'. If the CONDITION is
-omitted, it is treated as true, effectively yielding an "infinite loop"
-(i.e., a loop that never terminates).
-
- In most cases, a `for' loop is an abbreviation for a `while' loop,
-as shown here:
-
- INITIALIZATION
- while (CONDITION) {
- BODY
- INCREMENT
- }
-
-The only exception is when the `continue' statement (*note Continue
-Statement::) is used inside the loop. Changing a `for' statement to a
-`while' statement in this way can change the effect of the `continue'
-statement inside the loop.
-
- The `awk' language has a `for' statement in addition to a `while'
-statement because a `for' loop is often both less work to type and more
-natural to think of. Counting the number of iterations is very common
-in loops. It can be easier to think of this counting as part of
-looping rather than as something to do inside the loop.
-
- There is an alternate version of the `for' loop, for iterating over
-all the indices of an array:
-
- for (i in array)
- DO SOMETHING WITH array[i]
-
-*Note Scanning an Array::, for more information on this version of the
-`for' loop.
-
-6.4.5 The `switch' Statement
-----------------------------
-
-*NOTE:* This node describes an experimental feature added in `gawk'
-3.1.3. It is _not_ enabled by default. To enable it, use the
-`--enable-switch' option to `configure' when `gawk' is being configured
-and built. *Note Additional Configuration Options::, for more
-information.
-
- The `switch' statement allows the evaluation of an expression and
-the execution of statements based on a `case' match. Case statements
-are checked for a match in the order they are defined. If no suitable
-`case' is found, the `default' section is executed, if supplied.
-
- Each `case' contains a single constant, be it numeric, string, or
-regexp. The `switch' expression is evaluated, and then each `case''s
-constant is compared against the result in turn. The type of constant
-determines the comparison: numeric or string do the usual comparisons.
-A regexp constant does a regular expression match against the string
-value of the original expression. The general form of the `switch'
-statement looks like this:
-
- switch (EXPRESSION) {
- case VALUE OR REGULAR EXPRESSION:
- CASE-BODY
- default:
- DEFAULT-BODY
- }
-
- Control flow in the `switch' statement works as it does in C. Once a
-match to a given case is made, case statement bodies are executed until
-a `break', `continue', `next', `nextfile' or `exit' is encountered, or
-the end of the `switch' statement itself. For example:
-
- switch (NR * 2 + 1) {
- case 3:
- case "11":
- print NR - 1
- break
-
- case /2[[:digit:]]+/:
- print NR
-
- default:
- print NR + 1
-
- case -1:
- print NR * -1
- }
-
- Note that if none of the statements specified above halt execution
-of a matched `case' statement, execution falls through to the next
-`case' until execution halts. In the above example, for any case value
-starting with `2' followed by one or more digits, the `print' statement
-is executed and then falls through into the `default' section,
-executing its `print' statement. In turn, the -1 case will also be
-executed since the `default' does not halt execution.
-
-6.4.6 The `break' Statement
----------------------------
-
-The `break' statement jumps out of the innermost `for', `while', or
-`do' loop that encloses it. The following example finds the smallest
-divisor of any integer, and also identifies prime numbers:
-
- # find smallest divisor of num
- {
- num = $1
- for (div = 2; div*div <= num; div++)
- if (num % div == 0)
- break
- if (num % div == 0)
- printf "Smallest divisor of %d is %d\n", num, div
- else
- printf "%d is prime\n", num
- }
-
- When the remainder is zero in the first `if' statement, `awk'
-immediately "breaks out" of the containing `for' loop. This means that
-`awk' proceeds immediately to the statement following the loop and
-continues processing. (This is very different from the `exit'
-statement, which stops the entire `awk' program. *Note Exit
-Statement::.)
-
- Th following program illustrates how the CONDITION of a `for' or
-`while' statement could be replaced with a `break' inside an `if':
-
- # find smallest divisor of num
- {
- num = $1
- for (div = 2; ; div++) {
- if (num % div == 0) {
- printf "Smallest divisor of %d is %d\n", num, div
- break
- }
- if (div*div > num) {
- printf "%d is prime\n", num
- break
- }
- }
- }
-
- The `break' statement has no meaning when used outside the body of a
-loop. However, although it was never documented, historical
-implementations of `awk' treated the `break' statement outside of a
-loop as if it were a `next' statement (*note Next Statement::). Recent
-versions of Unix `awk' no longer allow this usage. `gawk' supports
-this use of `break' only if `--traditional' has been specified on the
-command line (*note Options::). Otherwise, it is treated as an error,
-since the POSIX standard specifies that `break' should only be used
-inside the body of a loop. (d.c.)
-
-6.4.7 The `continue' Statement
-------------------------------
-
-As with `break', the `continue' statement is used only inside `for',
-`while', and `do' loops. It skips over the rest of the loop body,
-causing the next cycle around the loop to begin immediately. Contrast
-this with `break', which jumps out of the loop altogether.
-
- The `continue' statement in a `for' loop directs `awk' to skip the
-rest of the body of the loop and resume execution with the
-increment-expression of the `for' statement. The following program
-illustrates this fact:
-
- BEGIN {
- for (x = 0; x <= 20; x++) {
- if (x == 5)
- continue
- printf "%d ", x
- }
- print ""
- }
-
-This program prints all the numbers from 0 to 20--except for 5, for
-which the `printf' is skipped. Because the increment `x++' is not
-skipped, `x' does not remain stuck at 5. Contrast the `for' loop from
-the previous example with the following `while' loop:
-
- BEGIN {
- x = 0
- while (x <= 20) {
- if (x == 5)
- continue
- printf "%d ", x
- x++
- }
- print ""
- }
-
-This program loops forever once `x' reaches 5.
-
- The `continue' statement has no meaning when used outside the body of
-a loop. Historical versions of `awk' treated a `continue' statement
-outside a loop the same way they treated a `break' statement outside a
-loop: as if it were a `next' statement (*note Next Statement::).
-Recent versions of Unix `awk' no longer work this way, and `gawk'
-allows it only if `--traditional' is specified on the command line
-(*note Options::). Just like the `break' statement, the POSIX standard
-specifies that `continue' should only be used inside the body of a loop.
-(d.c.)
-
-6.4.8 The `next' Statement
---------------------------
-
-The `next' statement forces `awk' to immediately stop processing the
-current record and go on to the next record. This means that no
-further rules are executed for the current record, and the rest of the
-current rule's action isn't executed.
-
- Contrast this with the effect of the `getline' function (*note
-Getline::). That also causes `awk' to read the next record
-immediately, but it does not alter the flow of control in any way
-(i.e., the rest of the current action executes with a new input record).
-
- At the highest level, `awk' program execution is a loop that reads
-an input record and then tests each rule's pattern against it. If you
-think of this loop as a `for' statement whose body contains the rules,
-then the `next' statement is analogous to a `continue' statement. It
-skips to the end of the body of this implicit loop and executes the
-increment (which reads another record).
-
- For example, suppose an `awk' program works only on records with
-four fields, and it shouldn't fail when given bad input. To avoid
-complicating the rest of the program, write a "weed out" rule near the
-beginning, in the following manner:
-
- NF != 4 {
- err = sprintf("%s:%d: skipped: NF != 4\n", FILENAME, FNR)
- print err > "/dev/stderr"
- next
- }
-
-Because of the `next' statement, the program's subsequent rules won't
-see the bad record. The error message is redirected to the standard
-error output stream, as error messages should be. For more detail see
-*Note Special Files::.
-
- According to the POSIX standard, the behavior is undefined if the
-`next' statement is used in a `BEGIN' or `END' rule. `gawk' treats it
-as a syntax error. Although POSIX permits it, some other `awk'
-implementations don't allow the `next' statement inside function bodies
-(*note User-defined::). Just as with any other `next' statement, a
-`next' statement inside a function body reads the next record and
-starts processing it with the first rule in the program. If the `next'
-statement causes the end of the input to be reached, then the code in
-any `END' rules is executed. *Note BEGIN/END::.
-
-6.4.9 Using `gawk''s `nextfile' Statement
------------------------------------------
-
-`gawk' provides the `nextfile' statement, which is similar to the
-`next' statement. However, instead of abandoning processing of the
-current record, the `nextfile' statement instructs `gawk' to stop
-processing the current data file.
-
- The `nextfile' statement is a `gawk' extension. In most other `awk'
-implementations, or if `gawk' is in compatibility mode (*note
-Options::), `nextfile' is not special.
-
- Upon execution of the `nextfile' statement, `FILENAME' is updated to
-the name of the next data file listed on the command line, `FNR' is
-reset to one, `ARGIND' is incremented, and processing starts over with
-the first rule in the program. (`ARGIND' hasn't been introduced yet.
-*Note Built-in Variables::.) If the `nextfile' statement causes the
-end of the input to be reached, then the code in any `END' rules is
-executed. *Note BEGIN/END::.
-
- The `nextfile' statement is useful when there are many data files to
-process but it isn't necessary to process every record in every file.
-Normally, in order to move on to the next data file, a program has to
-continue scanning the unwanted records. The `nextfile' statement
-accomplishes this much more efficiently.
-
- While one might think that `close(FILENAME)' would accomplish the
-same as `nextfile', this isn't true. `close' is reserved for closing
-files, pipes, and coprocesses that are opened with redirections. It is
-not related to the main processing that `awk' does with the files
-listed in `ARGV'.
-
- If it's necessary to use an `awk' version that doesn't support
-`nextfile', see *Note Nextfile Function::, for a user-defined function
-that simulates the `nextfile' statement.
-
- The current version of the Bell Laboratories `awk' (*note Other
-Versions::) also supports `nextfile'. However, it doesn't allow the
-`nextfile' statement inside function bodies (*note User-defined::).
-`gawk' does; a `nextfile' inside a function body reads the next record
-and starts processing it with the first rule in the program, just as
-any other `nextfile' statement.
-
- *Caution:* Versions of `gawk' prior to 3.0 used two words (`next
-file') for the `nextfile' statement. In version 3.0, this was changed
-to one word, because the treatment of `file' was inconsistent. When it
-appeared after `next', `file' was a keyword; otherwise, it was a
-regular identifier. The old usage is no longer accepted; `next file'
-generates a syntax error.
-
-6.4.10 The `exit' Statement
----------------------------
-
-The `exit' statement causes `awk' to immediately stop executing the
-current rule and to stop processing input; any remaining input is
-ignored. The `exit' statement is written as follows:
-
- exit [RETURN CODE]
-
- When an `exit' statement is executed from a `BEGIN' rule, the
-program stops processing everything immediately. No input records are
-read. However, if an `END' rule is present, as part of executing the
-`exit' statement, the `END' rule is executed (*note BEGIN/END::). If
-`exit' is used as part of an `END' rule, it causes the program to stop
-immediately.
-
- An `exit' statement that is not part of a `BEGIN' or `END' rule
-stops the execution of any further automatic rules for the current
-record, skips reading any remaining input records, and executes the
-`END' rule if there is one.
-
- In such a case, if you don't want the `END' rule to do its job, set
-a variable to nonzero before the `exit' statement and check that
-variable in the `END' rule. *Note Assert Function::, for an example
-that does this.
-
- If an argument is supplied to `exit', its value is used as the exit
-status code for the `awk' process. If no argument is supplied, `exit'
-returns status zero (success). In the case where an argument is
-supplied to a first `exit' statement, and then `exit' is called a
-second time from an `END' rule with no argument, `awk' uses the
-previously supplied exit value. (d.c.)
-
- For example, suppose an error condition occurs that is difficult or
-impossible to handle. Conventionally, programs report this by exiting
-with a nonzero status. An `awk' program can do this using an `exit'
-statement with a nonzero argument, as shown in the following example:
-
- BEGIN {
- if (("date" | getline date_now) <= 0) {
- print "Can't get system date" > "/dev/stderr"
- exit 1
- }
- print "current date is", date_now
- close("date")
- }
-
-6.5 Built-in Variables
-======================
-
-Most `awk' variables are available to use for your own purposes; they
-never change unless your program assigns values to them, and they never
-affect anything unless your program examines them. However, a few
-variables in `awk' have special built-in meanings. `awk' examines some
-of these automatically, so that they enable you to tell `awk' how to do
-certain things. Others are set automatically by `awk', so that they
-carry information from the internal workings of `awk' to your program.
-
- This minor node documents all the built-in variables of `gawk', most
-of which are also documented in the chapters describing their areas of
-activity.
-
-6.5.1 Built-in Variables That Control `awk'
--------------------------------------------
-
-The following is an alphabetical list of variables that you can change
-to control how `awk' does certain things. The variables that are
-specific to `gawk' are marked with a pound sign (`#').
-
-`BINMODE #'
- On non-POSIX systems, this variable specifies use of binary mode
- for all I/O. Numeric values of one, two, or three specify that
- input files, output files, or all files, respectively, should use
- binary I/O. Alternatively, string values of `"r"' or `"w"'
- specify that input files and output files, respectively, should
- use binary I/O. A string value of `"rw"' or `"wr"' indicates that
- all files should use binary I/O. Any other string value is
- equivalent to `"rw"', but `gawk' generates a warning message.
- `BINMODE' is described in more detail in *Note PC Using::.
-
- This variable is a `gawk' extension. In other `awk'
- implementations (except `mawk', *note Other Versions::), or if
- `gawk' is in compatibility mode (*note Options::), it is not
- special.
-
-`CONVFMT'
- This string controls conversion of numbers to strings (*note
- Conversion::). It works by being passed, in effect, as the first
- argument to the `sprintf' function (*note String Functions::).
- Its default value is `"%.6g"'. `CONVFMT' was introduced by the
- POSIX standard.
-
-`FIELDWIDTHS #'
- This is a space-separated list of columns that tells `gawk' how to
- split input with fixed columnar boundaries. Assigning a value to
- `FIELDWIDTHS' overrides the use of `FS' for field splitting.
- *Note Constant Size::, for more information.
-
- If `gawk' is in compatibility mode (*note Options::), then
- `FIELDWIDTHS' has no special meaning, and field-splitting
- operations occur based exclusively on the value of `FS'.
-
-`FS'
- This is the input field separator (*note Field Separators::). The
- value is a single-character string or a multi-character regular
- expression that matches the separations between fields in an input
- record. If the value is the null string (`""'), then each
- character in the record becomes a separate field. (This behavior
- is a `gawk' extension. POSIX `awk' does not specify the behavior
- when `FS' is the null string.)
-
- The default value is `" "', a string consisting of a single space.
- As a special exception, this value means that any sequence of
- spaces, tabs, and/or newlines is a single separator.(1) It also
- causes spaces, tabs, and newlines at the beginning and end of a
- record to be ignored.
-
- You can set the value of `FS' on the command line using the `-F'
- option:
-
- awk -F, 'PROGRAM' INPUT-FILES
-
- If `gawk' is using `FIELDWIDTHS' for field splitting, assigning a
- value to `FS' causes `gawk' to return to the normal, `FS'-based
- field splitting. An easy way to do this is to simply say `FS =
- FS', perhaps with an explanatory comment.
-
-`IGNORECASE #'
- If `IGNORECASE' is nonzero or non-null, then all string comparisons
- and all regular expression matching are case independent. Thus,
- regexp matching with `~' and `!~', as well as the `gensub',
- `gsub', `index', `match', `split', and `sub' functions, record
- termination with `RS', and field splitting with `FS', all ignore
- case when doing their particular regexp operations. However, the
- value of `IGNORECASE' does _not_ affect array subscripting and it
- does not affect field splitting when using a single-character
- field separator. *Note Case-sensitivity::.
-
- If `gawk' is in compatibility mode (*note Options::), then
- `IGNORECASE' has no special meaning. Thus, string and regexp
- operations are always case-sensitive.
-
-`LINT #'
- When this variable is true (nonzero or non-null), `gawk' behaves
- as if the `--lint' command-line option is in effect. (*note
- Options::). With a value of `"fatal"', lint warnings become fatal
- errors. With a value of `"invalid"', only warnings about things
- that are actually invalid are issued. (This is not fully
- implemented yet.) Any other true value prints nonfatal warnings.
- Assigning a false value to `LINT' turns off the lint warnings.
-
- This variable is a `gawk' extension. It is not special in other
- `awk' implementations. Unlike the other special variables,
- changing `LINT' does affect the production of lint warnings, even
- if `gawk' is in compatibility mode. Much as the `--lint' and
- `--traditional' options independently control different aspects of
- `gawk''s behavior, the control of lint warnings during program
- execution is independent of the flavor of `awk' being executed.
-
-`OFMT'
- This string controls conversion of numbers to strings (*note
- Conversion::) for printing with the `print' statement. It works
- by being passed as the first argument to the `sprintf' function
- (*note String Functions::). Its default value is `"%.6g"'.
- Earlier versions of `awk' also used `OFMT' to specify the format
- for converting numbers to strings in general expressions; this is
- now done by `CONVFMT'.
-
-`OFS'
- This is the output field separator (*note Output Separators::).
- It is output between the fields printed by a `print' statement.
- Its default value is `" "', a string consisting of a single space.
-
-`ORS'
- This is the output record separator. It is output at the end of
- every `print' statement. Its default value is `"\n"', the newline
- character. (*Note Output Separators::.)
-
-`RS'
- This is `awk''s input record separator. Its default value is a
- string containing a single newline character, which means that an
- input record consists of a single line of text. It can also be
- the null string, in which case records are separated by runs of
- blank lines. If it is a regexp, records are separated by matches
- of the regexp in the input text. (*Note Records::.)
-
- The ability for `RS' to be a regular expression is a `gawk'
- extension. In most other `awk' implementations, or if `gawk' is
- in compatibility mode (*note Options::), just the first character
- of `RS''s value is used.
-
-`SUBSEP'
- This is the subscript separator. It has the default value of
- `"\034"' and is used to separate the parts of the indices of a
- multidimensional array. Thus, the expression `foo["A", "B"]'
- really accesses `foo["A\034B"]' (*note Multi-dimensional::).
-
-`TEXTDOMAIN #'
- This variable is used for internationalization of programs at the
- `awk' level. It sets the default text domain for specially marked
- string constants in the source text, as well as for the
- `dcgettext', `dcngettext' and `bindtextdomain' functions (*note
- Internationalization::). The default value of `TEXTDOMAIN' is
- `"messages"'.
-
- This variable is a `gawk' extension. In other `awk'
- implementations, or if `gawk' is in compatibility mode (*note
- Options::), it is not special.
-
- ---------- Footnotes ----------
-
- (1) In POSIX `awk', newline does not count as whitespace.
-
-6.5.2 Built-in Variables That Convey Information
-------------------------------------------------
-
-The following is an alphabetical list of variables that `awk' sets
-automatically on certain occasions in order to provide information to
-your program. The variables that are specific to `gawk' are marked
-with a pound sign (`#').
-
-`ARGC, ARGV'
- The command-line arguments available to `awk' programs are stored
- in an array called `ARGV'. `ARGC' is the number of command-line
- arguments present. *Note Other Arguments::. Unlike most `awk'
- arrays, `ARGV' is indexed from 0 to `ARGC' - 1. In the following
- example:
-
- $ awk 'BEGIN {
- > for (i = 0; i < ARGC; i++)
- > print ARGV[i]
- > }' inventory-shipped BBS-list
- -| awk
- -| inventory-shipped
- -| BBS-list
-
- `ARGV[0]' contains `"awk"', `ARGV[1]' contains
- `"inventory-shipped"', and `ARGV[2]' contains `"BBS-list"'. The
- value of `ARGC' is three, one more than the index of the last
- element in `ARGV', because the elements are numbered from zero.
-
- The names `ARGC' and `ARGV', as well as the convention of indexing
- the array from 0 to `ARGC' - 1, are derived from the C language's
- method of accessing command-line arguments.
-
- The value of `ARGV[0]' can vary from system to system. Also, you
- should note that the program text is _not_ included in `ARGV', nor
- are any of `awk''s command-line options. *Note ARGC and ARGV::,
- for information about how `awk' uses these variables.
-
-`ARGIND #'
- The index in `ARGV' of the current file being processed. Every
- time `gawk' opens a new data file for processing, it sets `ARGIND'
- to the index in `ARGV' of the file name. When `gawk' is
- processing the input files, `FILENAME == ARGV[ARGIND]' is always
- true.
-
- This variable is useful in file processing; it allows you to tell
- how far along you are in the list of data files as well as to
- distinguish between successive instances of the same file name on
- the command line.
-
- While you can change the value of `ARGIND' within your `awk'
- program, `gawk' automatically sets it to a new value when the next
- file is opened.
-
- This variable is a `gawk' extension. In other `awk'
- implementations, or if `gawk' is in compatibility mode (*note
- Options::), it is not special.
-
-`ENVIRON'
- An associative array that contains the values of the environment.
- The array indices are the environment variable names; the elements
- are the values of the particular environment variables. For
- example, `ENVIRON["HOME"]' might be `/home/arnold'. Changing this
- array does not affect the environment passed on to any programs
- that `awk' may spawn via redirection or the `system' function.
-
- Some operating systems may not have environment variables. On
- such systems, the `ENVIRON' array is empty (except for
- `ENVIRON["AWKPATH"]', *note AWKPATH Variable::).
-
-`ERRNO #'
- If a system error occurs during a redirection for `getline',
- during a read for `getline', or during a `close' operation, then
- `ERRNO' contains a string describing the error.
-
- `ERRNO' works similarly to the C variable `errno'. In particular
- `gawk' _never_ clears it (sets it to zero or `""'). Thus, you
- should only expect its value to be meaningful when an I/O
- operation returns a failure value, such as `getline' returning -1.
- You are, of course, free to clear it yourself before doing an I/O
- operation.
-
- This variable is a `gawk' extension. In other `awk'
- implementations, or if `gawk' is in compatibility mode (*note
- Options::), it is not special.
-
-`FILENAME'
- The name of the file that `awk' is currently reading. When no
- data files are listed on the command line, `awk' reads from the
- standard input and `FILENAME' is set to `"-"'. `FILENAME' is
- changed each time a new file is read (*note Reading Files::).
- Inside a `BEGIN' rule, the value of `FILENAME' is `""', since
- there are no input files being processed yet.(1) (d.c.) Note,
- though, that using `getline' (*note Getline::) inside a `BEGIN'
- rule can give `FILENAME' a value.
-
-`FNR'
- The current record number in the current file. `FNR' is
- incremented each time a new record is read (*note Getline::). It
- is reinitialized to zero each time a new input file is started.
-
-`NF'
- The number of fields in the current input record. `NF' is set
- each time a new record is read, when a new field is created or
- when `$0' changes (*note Fields::).
-
- Unlike most of the variables described in this node, assigning a
- value to `NF' has the potential to affect `awk''s internal
- workings. In particular, assignments to `NF' can be used to
- create or remove fields from the current record: *Note Changing
- Fields::.
-
-`NR'
- The number of input records `awk' has processed since the
- beginning of the program's execution (*note Records::). `NR' is
- incremented each time a new record is read.
-
-`PROCINFO #'
- The elements of this array provide access to information about the
- running `awk' program. The following elements (listed
- alphabetically) are guaranteed to be available:
-
- `PROCINFO["egid"]'
- The value of the `getegid' system call.
-
- `PROCINFO["euid"]'
- The value of the `geteuid' system call.
-
- `PROCINFO["FS"]'
- This is `"FS"' if field splitting with `FS' is in effect, or
- it is `"FIELDWIDTHS"' if field splitting with `FIELDWIDTHS'
- is in effect.
-
- `PROCINFO["gid"]'
- The value of the `getgid' system call.
-
- `PROCINFO["pgrpid"]'
- The process group ID of the current process.
-
- `PROCINFO["pid"]'
- The process ID of the current process.
-
- `PROCINFO["ppid"]'
- The parent process ID of the current process.
-
- `PROCINFO["uid"]'
- The value of the `getuid' system call.
-
- `PROCINFO["version"]'
- The version of `gawk'. This is available from version 3.1.4
- and later.
-
- On some systems, there may be elements in the array, `"group1"'
- through `"groupN"' for some N. N is the number of supplementary
- groups that the process has. Use the `in' operator to test for
- these elements (*note Reference to Elements::).
-
- This array is a `gawk' extension. In other `awk' implementations,
- or if `gawk' is in compatibility mode (*note Options::), it is not
- special.
-
-`RLENGTH'
- The length of the substring matched by the `match' function (*note
- String Functions::). `RLENGTH' is set by invoking the `match'
- function. Its value is the length of the matched string, or -1 if
- no match is found.
-
-`RSTART'
- The start-index in characters of the substring that is matched by
- the `match' function (*note String Functions::). `RSTART' is set
- by invoking the `match' function. Its value is the position of
- the string where the matched substring starts, or zero if no match
- was found.
-
-`RT #'
- This is set each time a record is read. It contains the input text
- that matched the text denoted by `RS', the record separator.
-
- This variable is a `gawk' extension. In other `awk'
- implementations, or if `gawk' is in compatibility mode (*note
- Options::), it is not special.
-
-Advanced Notes: Changing `NR' and `FNR'
----------------------------------------
-
-`awk' increments `NR' and `FNR' each time it reads a record, instead of
-setting them to the absolute value of the number of records read. This
-means that a program can change these variables and their new values
-are incremented for each record. (d.c.) This is demonstrated in the
-following example:
-
- $ echo '1
- > 2
- > 3
- > 4' | awk 'NR == 2 { NR = 17 }
- > { print NR }'
- -| 1
- -| 17
- -| 18
- -| 19
-
-Before `FNR' was added to the `awk' language (*note V7/SVR3.1::), many
-`awk' programs used this feature to track the number of records in a
-file by resetting `NR' to zero when `FILENAME' changed.
-
- ---------- Footnotes ----------
-
- (1) Some early implementations of Unix `awk' initialized `FILENAME'
-to `"-"', even if there were data files to be processed. This behavior
-was incorrect and should not be relied upon in your programs.
-
-6.5.3 Using `ARGC' and `ARGV'
------------------------------
-
-*Note Auto-set::, presented the following program describing the
-information contained in `ARGC' and `ARGV':
-
- $ awk 'BEGIN {
- > for (i = 0; i < ARGC; i++)
- > print ARGV[i]
- > }' inventory-shipped BBS-list
- -| awk
- -| inventory-shipped
- -| BBS-list
-
-In this example, `ARGV[0]' contains `awk', `ARGV[1]' contains
-`inventory-shipped', and `ARGV[2]' contains `BBS-list'. Notice that
-the `awk' program is not entered in `ARGV'. The other special
-command-line options, with their arguments, are also not entered. This
-includes variable assignments done with the `-v' option (*note
-Options::). Normal variable assignments on the command line _are_
-treated as arguments and do show up in the `ARGV' array:
-
- $ cat showargs.awk
- -| BEGIN {
- -| printf "A=%d, B=%d\n", A, B
- -| for (i = 0; i < ARGC; i++)
- -| printf "\tARGV[%d] = %s\n", i, ARGV[i]
- -| }
- -| END { printf "A=%d, B=%d\n", A, B }
- $ awk -v A=1 -f showargs.awk B=2 /dev/null
- -| A=1, B=0
- -| ARGV[0] = awk
- -| ARGV[1] = B=2
- -| ARGV[2] = /dev/null
- -| A=1, B=2
-
- A program can alter `ARGC' and the elements of `ARGV'. Each time
-`awk' reaches the end of an input file, it uses the next element of
-`ARGV' as the name of the next input file. By storing a different
-string there, a program can change which files are read. Use `"-"' to
-represent the standard input. Storing additional elements and
-incrementing `ARGC' causes additional files to be read.
-
- If the value of `ARGC' is decreased, that eliminates input files
-from the end of the list. By recording the old value of `ARGC'
-elsewhere, a program can treat the eliminated arguments as something
-other than file names.
-
- To eliminate a file from the middle of the list, store the null
-string (`""') into `ARGV' in place of the file's name. As a special
-feature, `awk' ignores file names that have been replaced with the null
-string. Another option is to use the `delete' statement to remove
-elements from `ARGV' (*note Delete::).
-
- All of these actions are typically done in the `BEGIN' rule, before
-actual processing of the input begins. *Note Split Program::, and see
-*Note Tee Program::, for examples of each way of removing elements from
-`ARGV'. The following fragment processes `ARGV' in order to examine,
-and then remove, command-line options:
-
- BEGIN {
- for (i = 1; i < ARGC; i++) {
- if (ARGV[i] == "-v")
- verbose = 1
- else if (ARGV[i] == "-d")
- debug = 1
- else if (ARGV[i] ~ /^-?/) {
- e = sprintf("%s: unrecognized option -- %c",
- ARGV[0], substr(ARGV[i], 1, ,1))
- print e > "/dev/stderr"
- } else
- break
- delete ARGV[i]
- }
- }
-
- To actually get the options into the `awk' program, end the `awk'
-options with `--' and then supply the `awk' program's options, in the
-following manner:
-
- awk -f myprog -- -v -d file1 file2 ...
-
- This is not necessary in `gawk'. Unless `--posix' has been
-specified, `gawk' silently puts any unrecognized options into `ARGV'
-for the `awk' program to deal with. As soon as it sees an unknown
-option, `gawk' stops looking for other options that it might otherwise
-recognize. The previous example with `gawk' would be:
-
- gawk -f myprog -d -v file1 file2 ...
-
-Because `-d' is not a valid `gawk' option, it and the following `-v'
-are passed on to the `awk' program.
-
-7 Arrays in `awk'
-*****************
-
-An "array" is a table of values called "elements". The elements of an
-array are distinguished by their indices. "Indices" may be either
-numbers or strings.
-
- This major node describes how arrays work in `awk', how to use array
-elements, how to scan through every element in an array, and how to
-remove array elements. It also describes how `awk' simulates
-multidimensional arrays, as well as some of the less obvious points
-about array usage. The major node finishes with a discussion of
-`gawk''s facility for sorting an array based on its indices.
-
- `awk' maintains a single set of names that may be used for naming
-variables, arrays, and functions (*note User-defined::). Thus, you
-cannot have a variable and an array with the same name in the same
-`awk' program.
-
-7.1 Introduction to Arrays
-==========================
-
-The `awk' language provides one-dimensional arrays for storing groups
-of related strings or numbers. Every `awk' array must have a name.
-Array names have the same syntax as variable names; any valid variable
-name would also be a valid array name. But one name cannot be used in
-both ways (as an array and as a variable) in the same `awk' program.
-
- Arrays in `awk' superficially resemble arrays in other programming
-languages, but there are fundamental differences. In `awk', it isn't
-necessary to specify the size of an array before starting to use it.
-Additionally, any number or string in `awk', not just consecutive
-integers, may be used as an array index.
-
- In most other languages, arrays must be "declared" before use,
-including a specification of how many elements or components they
-contain. In such languages, the declaration causes a contiguous block
-of memory to be allocated for that many elements. Usually, an index in
-the array must be a positive integer. For example, the index zero
-specifies the first element in the array, which is actually stored at
-the beginning of the block of memory. Index one specifies the second
-element, which is stored in memory right after the first element, and
-so on. It is impossible to add more elements to the array, because it
-has room only for as many elements as given in the declaration. (Some
-languages allow arbitrary starting and ending indices--e.g., `15 ..
-27'--but the size of the array is still fixed when the array is
-declared.)
-
- A contiguous array of four elements might look like the following
-example, conceptually, if the element values are 8, `"foo"', `""', and
-30:
-
- +---------+---------+--------+---------+
- | 8 | "foo" | "" | 30 | Value
- +---------+---------+--------+---------+
- 0 1 2 3 Index
-
-Only the values are stored; the indices are implicit from the order of
-the values. Here, 8 is the value at index zero, because 8 appears in the
-position with zero elements before it.
-
- Arrays in `awk' are different--they are "associative". This means
-that each array is a collection of pairs: an index and its corresponding
-array element value:
-
- Element 3 Value 30
- Element 1 Value "foo"
- Element 0 Value 8
- Element 2 Value ""
-
-The pairs are shown in jumbled order because their order is irrelevant.
-
- One advantage of associative arrays is that new pairs can be added
-at any time. For example, suppose a tenth element is added to the array
-whose value is `"number ten"'. The result is:
-
- Element 10 Value "number ten"
- Element 3 Value 30
- Element 1 Value "foo"
- Element 0 Value 8
- Element 2 Value ""
-
-Now the array is "sparse", which just means some indices are missing.
-It has elements 0-3 and 10, but doesn't have elements 4, 5, 6, 7, 8, or
-9.
-
- Another consequence of associative arrays is that the indices don't
-have to be positive integers. Any number, or even a string, can be an
-index. For example, the following is an array that translates words
-from English to French:
-
- Element "dog" Value "chien"
- Element "cat" Value "chat"
- Element "one" Value "un"
- Element 1 Value "un"
-
-Here we decided to translate the number one in both spelled-out and
-numeric form--thus illustrating that a single array can have both
-numbers and strings as indices. In fact, array subscripts are always
-strings; this is discussed in more detail in *Note Numeric Array
-Subscripts::. Here, the number `1' isn't double-quoted, since `awk'
-automatically converts it to a string.
-
- The value of `IGNORECASE' has no effect upon array subscripting.
-The identical string value used to store an array element must be used
-to retrieve it. When `awk' creates an array (e.g., with the `split'
-built-in function), that array's indices are consecutive integers
-starting at one. (*Note String Functions::.)
-
- `awk''s arrays are efficient--the time to access an element is
-independent of the number of elements in the array.
-
-7.2 Referring to an Array Element
-=================================
-
-The principal way to use an array is to refer to one of its elements.
-An array reference is an expression as follows:
-
- ARRAY[INDEX]
-
-Here, ARRAY is the name of an array. The expression INDEX is the index
-of the desired element of the array.
-
- The value of the array reference is the current value of that array
-element. For example, `foo[4.3]' is an expression for the element of
-array `foo' at index `4.3'.
-
- A reference to an array element that has no recorded value yields a
-value of `""', the null string. This includes elements that have not
-been assigned any value as well as elements that have been deleted
-(*note Delete::). Such a reference automatically creates that array
-element, with the null string as its value. (In some cases, this is
-unfortunate, because it might waste memory inside `awk'.)
-
- To determine whether an element exists in an array at a certain
-index, use the following expression:
-
- INDEX in ARRAY
-
-This expression tests whether the particular index exists, without the
-side effect of creating that element if it is not present. The
-expression has the value one (true) if `ARRAY[INDEX]' exists and zero
-(false) if it does not exist. For example, this statement tests
-whether the array `frequencies' contains the index `2':
-
- if (2 in frequencies)
- print "Subscript 2 is present."
-
- Note that this is _not_ a test of whether the array `frequencies'
-contains an element whose _value_ is two. There is no way to do that
-except to scan all the elements. Also, this _does not_ create
-`frequencies[2]', while the following (incorrect) alternative does:
-
- if (frequencies[2] != "")
- print "Subscript 2 is present."
-
-7.3 Assigning Array Elements
-============================
-
-Array elements can be assigned values just like `awk' variables:
-
- ARRAY[SUBSCRIPT] = VALUE
-
-ARRAY is the name of an array. The expression SUBSCRIPT is the index
-of the element of the array that is assigned a value. The expression
-VALUE is the value to assign to that element of the array.
-
-7.4 Basic Array Example
-=======================
-
-The following program takes a list of lines, each beginning with a line
-number, and prints them out in order of line number. The line numbers
-are not in order when they are first read--instead they are scrambled.
-This program sorts the lines by making an array using the line numbers
-as subscripts. The program then prints out the lines in sorted order
-of their numbers. It is a very simple program and gets confused upon
-encountering repeated numbers, gaps, or lines that don't begin with a
-number:
-
- {
- if ($1 > max)
- max = $1
- arr[$1] = $0
- }
-
- END {
- for (x = 1; x <= max; x++)
- print arr[x]
- }
-
- The first rule keeps track of the largest line number seen so far;
-it also stores each line into the array `arr', at an index that is the
-line's number. The second rule runs after all the input has been read,
-to print out all the lines. When this program is run with the
-following input:
-
- 5 I am the Five man
- 2 Who are you? The new number two!
- 4 . . . And four on the floor
- 1 Who is number one?
- 3 I three you.
-
-Its output is:
-
- 1 Who is number one?
- 2 Who are you? The new number two!
- 3 I three you.
- 4 . . . And four on the floor
- 5 I am the Five man
-
- If a line number is repeated, the last line with a given number
-overrides the others. Gaps in the line numbers can be handled with an
-easy improvement to the program's `END' rule, as follows:
-
- END {
- for (x = 1; x <= max; x++)
- if (x in arr)
- print arr[x]
- }
-
-7.5 Scanning All Elements of an Array
-=====================================
-
-In programs that use arrays, it is often necessary to use a loop that
-executes once for each element of an array. In other languages, where
-arrays are contiguous and indices are limited to positive integers,
-this is easy: all the valid indices can be found by counting from the
-lowest index up to the highest. This technique won't do the job in
-`awk', because any number or string can be an array index. So `awk'
-has a special kind of `for' statement for scanning an array:
-
- for (VAR in ARRAY)
- BODY
-
-This loop executes BODY once for each index in ARRAY that the program
-has previously used, with the variable VAR set to that index.
-
- The following program uses this form of the `for' statement. The
-first rule scans the input records and notes which words appear (at
-least once) in the input, by storing a one into the array `used' with
-the word as index. The second rule scans the elements of `used' to
-find all the distinct words that appear in the input. It prints each
-word that is more than 10 characters long and also prints the number of
-such words. *Note String Functions::, for more information on the
-built-in function `length'.
-
- # Record a 1 for each word that is used at least once
- {
- for (i = 1; i <= NF; i++)
- used[$i] = 1
- }
-
- # Find number of distinct words more than 10 characters long
- END {
- for (x in used)
- if (length(x) > 10) {
- ++num_long_words
- print x
- }
- print num_long_words, "words longer than 10 characters"
- }
-
-*Note Word Sorting::, for a more detailed example of this type.
-
- The order in which elements of the array are accessed by this
-statement is determined by the internal arrangement of the array
-elements within `awk' and cannot be controlled or changed. This can
-lead to problems if new elements are added to ARRAY by statements in
-the loop body; it is not predictable whether the `for' loop will reach
-them. Similarly, changing VAR inside the loop may produce strange
-results. It is best to avoid such things.
-
-7.6 The `delete' Statement
-==========================
-
-To remove an individual element of an array, use the `delete' statement:
-
- delete ARRAY[INDEX]
-
- Once an array element has been deleted, any value the element once
-had is no longer available. It is as if the element had never been
-referred to or had been given a value. The following is an example of
-deleting elements in an array:
-
- for (i in frequencies)
- delete frequencies[i]
-
-This example removes all the elements from the array `frequencies'.
-Once an element is deleted, a subsequent `for' statement to scan the
-array does not report that element and the `in' operator to check for
-the presence of that element returns zero (i.e., false):
-
- delete foo[4]
- if (4 in foo)
- print "This will never be printed"
-
- It is important to note that deleting an element is _not_ the same
-as assigning it a null value (the empty string, `""'). For example:
-
- foo[4] = ""
- if (4 in foo)
- print "This is printed, even though foo[4] is empty"
-
- It is not an error to delete an element that does not exist. If
-`--lint' is provided on the command line (*note Options::), `gawk'
-issues a warning message when an element that is not in the array is
-deleted.
-
- All the elements of an array may be deleted with a single statement
-by leaving off the subscript in the `delete' statement, as follows:
-
- delete ARRAY
-
- This ability is a `gawk' extension; it is not available in
-compatibility mode (*note Options::).
-
- Using this version of the `delete' statement is about three times
-more efficient than the equivalent loop that deletes each element one
-at a time.
-
- The following statement provides a portable but nonobvious way to
-clear out an array:(1)
-
- split("", array)
-
- The `split' function (*note String Functions::) clears out the
-target array first. This call asks it to split apart the null string.
-Because there is no data to split out, the function simply clears the
-array and then returns.
-
- *Caution:* Deleting an array does not change its type; you cannot
-delete an array and then use the array's name as a scalar (i.e., a
-regular variable). For example, the following does not work:
-
- a[1] = 3; delete a; a = 3
-
- ---------- Footnotes ----------
-
- (1) Thanks to Michael Brennan for pointing this out.
-
-7.7 Using Numbers to Subscript Arrays
-=====================================
-
-An important aspect about arrays to remember is that _array subscripts
-are always strings_. When a numeric value is used as a subscript, it
-is converted to a string value before being used for subscripting
-(*note Conversion::). This means that the value of the built-in
-variable `CONVFMT' can affect how your program accesses elements of an
-array. For example:
-
- xyz = 12.153
- data[xyz] = 1
- CONVFMT = "%2.2f"
- if (xyz in data)
- printf "%s is in data\n", xyz
- else
- printf "%s is not in data\n", xyz
-
-This prints `12.15 is not in data'. The first statement gives `xyz' a
-numeric value. Assigning to `data[xyz]' subscripts `data' with the
-string value `"12.153"' (using the default conversion value of
-`CONVFMT', `"%.6g"'). Thus, the array element `data["12.153"]' is
-assigned the value one. The program then changes the value of
-`CONVFMT'. The test `(xyz in data)' generates a new string value from
-`xyz'--this time `"12.15"'--because the value of `CONVFMT' only allows
-two significant digits. This test fails, since `"12.15"' is a
-different string from `"12.153"'.
-
- According to the rules for conversions (*note Conversion::), integer
-values are always converted to strings as integers, no matter what the
-value of `CONVFMT' may happen to be. So the usual case of the
-following works:
-
- for (i = 1; i <= maxsub; i++)
- do something with array[i]
-
- The "integer values always convert to strings as integers" rule has
-an additional consequence for array indexing. Octal and hexadecimal
-constants (*note Nondecimal-numbers::) are converted internally into
-numbers, and their original form is forgotten. This means, for
-example, that `array[17]', `array[021]', and `array[0x11]' all refer to
-the same element!
-
- As with many things in `awk', the majority of the time things work
-as one would expect them to. But it is useful to have a precise
-knowledge of the actual rules which sometimes can have a subtle effect
-on your programs.
-
-7.8 Using Uninitialized Variables as Subscripts
-===============================================
-
-Suppose it's necessary to write a program to print the input data in
-reverse order. A reasonable attempt to do so (with some test data)
-might look like this:
-
- $ echo 'line 1
- > line 2
- > line 3' | awk '{ l[lines] = $0; ++lines }
- > END {
- > for (i = lines-1; i >= 0; --i)
- > print l[i]
- > }'
- -| line 3
- -| line 2
-
- Unfortunately, the very first line of input data did not come out in
-the output!
-
- At first glance, this program should have worked. The variable
-`lines' is uninitialized, and uninitialized variables have the numeric
-value zero. So, `awk' should have printed the value of `l[0]'.
-
- The issue here is that subscripts for `awk' arrays are _always_
-strings. Uninitialized variables, when used as strings, have the value
-`""', not zero. Thus, `line 1' ends up stored in `l[""]'. The
-following version of the program works correctly:
-
- { l[lines++] = $0 }
- END {
- for (i = lines - 1; i >= 0; --i)
- print l[i]
- }
-
- Here, the `++' forces `lines' to be numeric, thus making the "old
-value" numeric zero. This is then converted to `"0"' as the array
-subscript.
-
- Even though it is somewhat unusual, the null string (`""') is a
-valid array subscript. (d.c.) `gawk' warns about the use of the null
-string as a subscript if `--lint' is provided on the command line
-(*note Options::).
-
-7.9 Multidimensional Arrays
-===========================
-
-A multidimensional array is an array in which an element is identified
-by a sequence of indices instead of a single index. For example, a
-two-dimensional array requires two indices. The usual way (in most
-languages, including `awk') to refer to an element of a two-dimensional
-array named `grid' is with `grid[X,Y]'.
-
- Multidimensional arrays are supported in `awk' through concatenation
-of indices into one string. `awk' converts the indices into strings
-(*note Conversion::) and concatenates them together, with a separator
-between them. This creates a single string that describes the values
-of the separate indices. The combined string is used as a single index
-into an ordinary, one-dimensional array. The separator used is the
-value of the built-in variable `SUBSEP'.
-
- For example, suppose we evaluate the expression `foo[5,12] = "value"'
-when the value of `SUBSEP' is `"@"'. The numbers 5 and 12 are
-converted to strings and concatenated with an `@' between them,
-yielding `"address@hidden"'; thus, the array element `foo["address@hidden"]'
is set to
-`"value"'.
-
- Once the element's value is stored, `awk' has no record of whether
-it was stored with a single index or a sequence of indices. The two
-expressions `foo[5,12]' and `foo[5 SUBSEP 12]' are always equivalent.
-
- The default value of `SUBSEP' is the string `"\034"', which contains
-a nonprinting character that is unlikely to appear in an `awk' program
-or in most input data. The usefulness of choosing an unlikely
-character comes from the fact that index values that contain a string
-matching `SUBSEP' can lead to combined strings that are ambiguous.
-Suppose that `SUBSEP' is `"@"'; then `foo["address@hidden", "c"]' and
-`foo["a", "address@hidden"]' are indistinguishable because both are actually
-stored as `foo["address@hidden@c"]'.
-
- To test whether a particular index sequence exists in a
-multidimensional array, use the same operator (`in') that is used for
-single dimensional arrays. Write the whole sequence of indices in
-parentheses, separated by commas, as the left operand:
-
- (SUBSCRIPT1, SUBSCRIPT2, ...) in ARRAY
-
- The following example treats its input as a two-dimensional array of
-fields; it rotates this array 90 degrees clockwise and prints the
-result. It assumes that all lines have the same number of elements:
-
- {
- if (max_nf < NF)
- max_nf = NF
- max_nr = NR
- for (x = 1; x <= NF; x++)
- vector[x, NR] = $x
- }
-
- END {
- for (x = 1; x <= max_nf; x++) {
- for (y = max_nr; y >= 1; --y)
- printf("%s ", vector[x, y])
- printf("\n")
- }
- }
-
-When given the input:
-
- 1 2 3 4 5 6
- 2 3 4 5 6 1
- 3 4 5 6 1 2
- 4 5 6 1 2 3
-
-the program produces the following output:
-
- 4 3 2 1
- 5 4 3 2
- 6 5 4 3
- 1 6 5 4
- 2 1 6 5
- 3 2 1 6
-
-7.10 Scanning Multidimensional Arrays
-=====================================
-
-There is no special `for' statement for scanning a "multidimensional"
-array. There cannot be one, because, in truth, there are no
-multidimensional arrays or elements--there is only a multidimensional
-_way of accessing_ an array.
-
- However, if your program has an array that is always accessed as
-multidimensional, you can get the effect of scanning it by combining
-the scanning `for' statement (*note Scanning an Array::) with the
-built-in `split' function (*note String Functions::). It works in the
-following manner:
-
- for (combined in array) {
- split(combined, separate, SUBSEP)
- ...
- }
-
-This sets the variable `combined' to each concatenated combined index
-in the array, and splits it into the individual indices by breaking it
-apart where the value of `SUBSEP' appears. The individual indices then
-become the elements of the array `separate'.
-
- Thus, if a value is previously stored in `array[1, "foo"]'; then an
-element with index `"1\034foo"' exists in `array'. (Recall that the
-default value of `SUBSEP' is the character with code 034.) Sooner or
-later, the `for' statement finds that index and does an iteration with
-the variable `combined' set to `"1\034foo"'. Then the `split' function
-is called as follows:
-
- split("1\034foo", separate, "\034")
-
-The result is to set `separate[1]' to `"1"' and `separate[2]' to
-`"foo"'. Presto! The original sequence of separate indices is
-recovered.
-
-7.11 Sorting Array Values and Indices with `gawk'
-=================================================
-
-The order in which an array is scanned with a `for (i in array)' loop
-is essentially arbitrary. In most `awk' implementations, sorting an
-array requires writing a `sort' function. While this can be
-educational for exploring different sorting algorithms, usually that's
-not the point of the program. `gawk' provides the built-in `asort' and
-`asorti' functions (*note String Functions::) for sorting arrays. For
-example:
-
- POPULATE THE ARRAY data
- n = asort(data)
- for (i = 1; i <= n; i++)
- DO SOMETHING WITH data[i]
-
- After the call to `asort', the array `data' is indexed from 1 to
-some number N, the total number of elements in `data'. (This count is
-`asort''s return value.) `data[1]' <= `data[2]' <= `data[3]', and so
-on. The comparison of array elements is done using `gawk''s usual
-comparison rules (*note Typing and Comparison::).
-
- An important side effect of calling `asort' is that _the array's
-original indices are irrevocably lost_. As this isn't always
-desirable, `asort' accepts a second argument:
-
- POPULATE THE ARRAY source
- n = asort(source, dest)
- for (i = 1; i <= n; i++)
- DO SOMETHING WITH dest[i]
-
- In this case, `gawk' copies the `source' array into the `dest' array
-and then sorts `dest', destroying its indices. However, the `source'
-array is not affected.
-
- Often, what's needed is to sort on the values of the _indices_
-instead of the values of the elements. To do that, starting with
-`gawk' 3.1.2, use the `asorti' function. The interface is identical to
-that of `asort', except that the index values are used for sorting, and
-become the values of the result array:
-
- { source[$0] = some_func($0) }
-
- END {
- n = asorti(source, dest)
- for (i = 1; i <= n; i++) {
- DO SOMETHING WITH dest[i] Work with sorted indices
directly
- ...
- DO SOMETHING WITH source[dest[i]] Access original array via
sorted indices
- }
- }
-
- If your version of `gawk' is 3.1.0 or 3.1.1, you don't have
-`asorti'. Instead, use a helper array to hold the sorted index values,
-and then access the original array's elements. It works in the
-following way:
-
- POPULATE THE ARRAY data
- # copy indices
- j = 1
- for (i in data) {
- ind[j] = i # index value becomes element value
- j++
- }
- n = asort(ind) # index values are now sorted
- for (i = 1; i <= n; i++) {
- DO SOMETHING WITH ind[i] Work with sorted indices directly
- ...
- DO SOMETHING WITH data[ind[i]] Access original array via sorted
indices
- }
-
- Sorting the array by replacing the indices provides maximal
-flexibility. To traverse the elements in decreasing order, use a loop
-that goes from N down to 1, either over the elements or over the
-indices.
-
- Copying array indices and elements isn't expensive in terms of
-memory. Internally, `gawk' maintains "reference counts" to data. For
-example, when `asort' copies the first array to the second one, there
-is only one copy of the original array elements' data, even though both
-arrays use the values. Similarly, when copying the indices from `data'
-to `ind', there is only one copy of the actual index strings.
-
- We said previously that comparisons are done using `gawk''s "usual
-comparison rules." Because `IGNORECASE' affects string comparisons,
-the value of `IGNORECASE' also affects sorting for both `asort' and
-`asorti'. Caveat Emptor.
-
-8 Functions
-***********
-
-This major node describes `awk''s built-in functions, which fall into
-three categories: numeric, string, and I/O. `gawk' provides additional
-groups of functions to work with values that represent time, do bit
-manipulation, and internationalize and localize programs.
-
- Besides the built-in functions, `awk' has provisions for writing new
-functions that the rest of a program can use. The second half of this
-major node describes these "user-defined" functions.
-
-8.1 Built-in Functions
-======================
-
-"Built-in" functions are always available for your `awk' program to
-call. This minor node defines all the built-in functions in `awk';
-some of these are mentioned in other sections but are summarized here
-for your convenience.
-
-8.1.1 Calling Built-in Functions
---------------------------------
-
-To call one of `awk''s built-in functions, write the name of the
-function followed by arguments in parentheses. For example, `atan2(y +
-z, 1)' is a call to the function `atan2' and has two arguments.
-
- Whitespace is ignored between the built-in function name and the
-open parenthesis, and it is good practice to avoid using whitespace
-there. User-defined functions do not permit whitespace in this way, and
-it is easier to avoid mistakes by following a simple convention that
-always works--no whitespace after a function name.
-
- Each built-in function accepts a certain number of arguments. In
-some cases, arguments can be omitted. The defaults for omitted
-arguments vary from function to function and are described under the
-individual functions. In some `awk' implementations, extra arguments
-given to built-in functions are ignored. However, in `gawk', it is a
-fatal error to give extra arguments to a built-in function.
-
- When a function is called, expressions that create the function's
-actual parameters are evaluated completely before the call is performed.
-For example, in the following code fragment:
-
- i = 4
- j = sqrt(i++)
-
-the variable `i' is incremented to the value five before `sqrt' is
-called with a value of four for its actual parameter. The order of
-evaluation of the expressions used for the function's parameters is
-undefined. Thus, avoid writing programs that assume that parameters
-are evaluated from left to right or from right to left. For example:
-
- i = 5
- j = atan2(i++, i *= 2)
-
- If the order of evaluation is left to right, then `i' first becomes
-6, and then 12, and `atan2' is called with the two arguments 6 and 12.
-But if the order of evaluation is right to left, `i' first becomes 10,
-then 11, and `atan2' is called with the two arguments 11 and 10.
-
-8.1.2 Numeric Functions
------------------------
-
-The following list describes all of the built-in functions that work
-with numbers. Optional parameters are enclosed in square
-brackets ([ ]):
-
-`int(X)'
- This returns the nearest integer to X, located between X and zero
- and truncated toward zero.
-
- For example, `int(3)' is 3, `int(3.9)' is 3, `int(-3.9)' is -3,
- and `int(-3)' is -3 as well.
-
-`sqrt(X)'
- This returns the positive square root of X. `gawk' reports an
- error if X is negative. Thus, `sqrt(4)' is 2.
-
-`exp(X)'
- This returns the exponential of X (`e ^ X') or reports an error if
- X is out of range. The range of values X can have depends on your
- machine's floating-point representation.
-
-`log(X)'
- This returns the natural logarithm of X, if X is positive;
- otherwise, it reports an error.
-
-`sin(X)'
- This returns the sine of X, with X in radians.
-
-`cos(X)'
- This returns the cosine of X, with X in radians.
-
-`atan2(Y, X)'
- This returns the arctangent of `Y / X' in radians.
-
-`rand()'
- This returns a random number. The values of `rand' are uniformly
- distributed between zero and one. The value could be zero but is
- never one.(1)
-
- Often random integers are needed instead. Following is a
- user-defined function that can be used to obtain a random
- non-negative integer less than N:
-
- function randint(n) {
- return int(n * rand())
- }
-
- The multiplication produces a random number greater than zero and
- less than `n'. Using `int', this result is made into an integer
- between zero and `n' - 1, inclusive.
-
- The following example uses a similar function to produce random
- integers between one and N. This program prints a new random
- number for each input record:
-
- # Function to roll a simulated die.
- function roll(n) { return 1 + int(rand() * n) }
-
- # Roll 3 six-sided dice and
- # print total number of points.
- {
- printf("%d points\n",
- roll(6)+roll(6)+roll(6))
- }
-
- *Caution:* In most `awk' implementations, including `gawk', `rand'
- starts generating numbers from the same starting number, or
- "seed", each time you run `awk'. Thus, a program generates the
- same results each time you run it. The numbers are random within
- one `awk' run but predictable from run to run. This is convenient
- for debugging, but if you want a program to do different things
- each time it is used, you must change the seed to a value that is
- different in each run. To do this, use `srand'.
-
-`srand([X])'
- The function `srand' sets the starting point, or seed, for
- generating random numbers to the value X.
-
- Each seed value leads to a particular sequence of random
- numbers.(2) Thus, if the seed is set to the same value a second
- time, the same sequence of random numbers is produced again.
-
- Different `awk' implementations use different random-number
- generators internally. Don't expect the same `awk' program to
- produce the same series of random numbers when executed by
- different versions of `awk'.
-
- If the argument X is omitted, as in `srand()', then the current
- date and time of day are used for a seed. This is the way to get
- random numbers that are truly unpredictable.
-
- The return value of `srand' is the previous seed. This makes it
- easy to keep track of the seeds in case you need to consistently
- reproduce sequences of random numbers.
-
- ---------- Footnotes ----------
-
- (1) The C version of `rand' is known to produce fairly poor
-sequences of random numbers. However, nothing requires that an `awk'
-implementation use the C `rand' to implement the `awk' version of
-`rand'. In fact, `gawk' uses the BSD `random' function, which is
-considerably better than `rand', to produce random numbers.
-
- (2) Computer-generated random numbers really are not truly random.
-They are technically known as "pseudorandom." This means that while
-the numbers in a sequence appear to be random, you can in fact generate
-the same sequence of random numbers over and over again.
-
-8.1.3 String-Manipulation Functions
------------------------------------
-
-The functions in this minor node look at or change the text of one or
-more strings. Optional parameters are enclosed in square
-brackets ([ ]). Those functions that are specific to `gawk' are marked
-with a pound sign (`#'):
-
-`asort(SOURCE [, DEST]) #'
- `asort' is a `gawk'-specific extension, returning the number of
- elements in the array SOURCE. The contents of SOURCE are sorted
- using `gawk''s normal rules for comparing values (in particular,
- `IGNORECASE' affects the sorting) and the indices of the sorted
- values of SOURCE are replaced with sequential integers starting
- with one. If the optional array DEST is specified, then SOURCE is
- duplicated into DEST. DEST is then sorted, leaving the indices of
- SOURCE unchanged. For example, if the contents of `a' are as
- follows:
-
- a["last"] = "de"
- a["first"] = "sac"
- a["middle"] = "cul"
-
- A call to `asort':
-
- asort(a)
-
- results in the following contents of `a':
-
- a[1] = "cul"
- a[2] = "de"
- a[3] = "sac"
-
- The `asort' function is described in more detail in *Note Array
- Sorting::. `asort' is a `gawk' extension; it is not available in
- compatibility mode (*note Options::).
-
-`asorti(SOURCE [, DEST]) #'
- `asorti' is a `gawk'-specific extension, returning the number of
- elements in the array SOURCE. It works similarly to `asort',
- however, the _indices_ are sorted, instead of the values. As
- array indices are always strings, the comparison performed is
- always a string comparison. (Here too, `IGNORECASE' affects the
- sorting.)
-
- The `asorti' function is described in more detail in *Note Array
- Sorting::. It was added in `gawk' 3.1.2. `asorti' is a `gawk'
- extension; it is not available in compatibility mode (*note
- Options::).
-
-`index(IN, FIND)'
- This searches the string IN for the first occurrence of the string
- FIND, and returns the position in characters where that occurrence
- begins in the string IN. Consider the following example:
-
- $ awk 'BEGIN { print index("peanut", "an") }'
- -| 3
-
- If FIND is not found, `index' returns zero. (Remember that string
- indices in `awk' start at one.)
-
-`length([STRING])'
- This returns the number of characters in STRING. If STRING is a
- number, the length of the digit string representing that number is
- returned. For example, `length("abcde")' is 5. By contrast,
- `length(15 * 35)' works out to 3. In this example, 15 * 35 = 525,
- and 525 is then converted to the string `"525"', which has three
- characters.
-
- If no argument is supplied, `length' returns the length of `$0'.
-
- NOTE: In older versions of `awk', the `length' function could
- be called without any parentheses. Doing so is marked as
- "deprecated" in the POSIX standard. This means that while a
- program can do this, it is a feature that can eventually be
- removed from a future version of the standard. Therefore,
- for programs to be maximally portable, always supply the
- parentheses.
-
-`match(STRING, REGEXP [, ARRAY])'
- The `match' function searches STRING for the longest, leftmost
- substring matched by the regular expression, REGEXP. It returns
- the character position, or "index", at which that substring begins
- (one, if it starts at the beginning of STRING). If no match is
- found, it returns zero.
-
- The REGEXP argument may be either a regexp constant (`/.../') or a
- string constant ("..."). In the latter case, the string is
- treated as a regexp to be matched. *Note Computed Regexps::, for a
- discussion of the difference between the two forms, and the
- implications for writing your program correctly.
-
- The order of the first two arguments is backwards from most other
- string functions that work with regular expressions, such as `sub'
- and `gsub'. It might help to remember that for `match', the order
- is the same as for the `~' operator: `STRING ~ REGEXP'.
-
- The `match' function sets the built-in variable `RSTART' to the
- index. It also sets the built-in variable `RLENGTH' to the length
- in characters of the matched substring. If no match is found,
- `RSTART' is set to zero, and `RLENGTH' to -1.
-
- For example:
-
- {
- if ($1 == "FIND")
- regex = $2
- else {
- where = match($0, regex)
- if (where != 0)
- print "Match of", regex, "found at",
- where, "in", $0
- }
- }
-
- This program looks for lines that match the regular expression
- stored in the variable `regex'. This regular expression can be
- changed. If the first word on a line is `FIND', `regex' is
- changed to be the second word on that line. Therefore, if given:
-
- FIND ru+n
- My program runs
- but not very quickly
- FIND Melvin
- JF+KM
- This line is property of Reality Engineering Co.
- Melvin was here.
-
- `awk' prints:
-
- Match of ru+n found at 12 in My program runs
- Match of Melvin found at 1 in Melvin was here.
-
- If ARRAY is present, it is cleared, and then the 0th element of
- ARRAY is set to the entire portion of STRING matched by REGEXP.
- If REGEXP contains parentheses, the integer-indexed elements of
- ARRAY are set to contain the portion of STRING matching the
- corresponding parenthesized subexpression. For example:
-
- $ echo foooobazbarrrrr |
- > gawk '{ match($0, /(fo+).+(bar*)/, arr)
- > print arr[1], arr[2] }'
- -| foooo barrrrr
-
- In addition, beginning with `gawk' 3.1.2, multidimensional
- subscripts are available providing the start index and length of
- each matched subexpression:
-
- $ echo foooobazbarrrrr |
- > gawk '{ match($0, /(fo+).+(bar*)/, arr)
- > print arr[1], arr[2]
- > print arr[1, "start"], arr[1, "length"]
- > print arr[2, "start"], arr[2, "length"]
- > }'
- -| foooo barrrrr
- -| 1 5
- -| 9 7
-
- There may not be subscripts for the start and index for every
- parenthesized subexpressions, since they may not all have matched
- text; thus they should be tested for with the `in' operator (*note
- Reference to Elements::).
-
- The ARRAY argument to `match' is a `gawk' extension. In
- compatibility mode (*note Options::), using a third argument is a
- fatal error.
-
-`split(STRING, ARRAY [, FIELDSEP])'
- This function divides STRING into pieces separated by FIELDSEP and
- stores the pieces in ARRAY. The first piece is stored in
- `ARRAY[1]', the second piece in `ARRAY[2]', and so forth. The
- string value of the third argument, FIELDSEP, is a regexp
- describing where to split STRING (much as `FS' can be a regexp
- describing where to split input records). If FIELDSEP is omitted,
- the value of `FS' is used. `split' returns the number of elements
- created.
-
- The `split' function splits strings into pieces in a manner
- similar to the way input lines are split into fields. For example:
-
- split("cul-de-sac", a, "-")
-
- splits the string `cul-de-sac' into three fields using `-' as the
- separator. It sets the contents of the array `a' as follows:
-
- a[1] = "cul"
- a[2] = "de"
- a[3] = "sac"
-
- The value returned by this call to `split' is three.
-
- As with input field-splitting, when the value of FIELDSEP is
- `" "', leading and trailing whitespace is ignored, and the elements
- are separated by runs of whitespace. Also as with input
- field-splitting, if FIELDSEP is the null string, each individual
- character in the string is split into its own array element.
- (This is a `gawk'-specific extension.)
-
- Note, however, that `RS' has no effect on the way `split' works.
- Even though `RS = ""' causes newline to also be an input field
- separator, this does not affect how `split' splits strings.
-
- Modern implementations of `awk', including `gawk', allow the third
- argument to be a regexp constant (`/abc/') as well as a string.
- (d.c.) The POSIX standard allows this as well. *Note Computed
- Regexps::, for a discussion of the difference between using a
- string constant or a regexp constant, and the implications for
- writing your program correctly.
-
- Before splitting the string, `split' deletes any previously
- existing elements in the array ARRAY.
-
- If STRING is null, the array has no elements. (So this is a
- portable way to delete an entire array with one statement. *Note
- Delete::.)
-
- If STRING does not match FIELDSEP at all (but is not null), ARRAY
- has one element only. The value of that element is the original
- STRING.
-
-`sprintf(FORMAT, EXPRESSION1, ...)'
- This returns (without printing) the string that `printf' would
- have printed out with the same arguments (*note Printf::). For
- example:
-
- pival = sprintf("pi = %.2f (approx.)", 22/7)
-
- assigns the string `"pi = 3.14 (approx.)"' to the variable `pival'.
-
-`strtonum(STR) #'
- Examines STR and returns its numeric value. If STR begins with a
- leading `0', `strtonum' assumes that STR is an octal number. If
- STR begins with a leading `0x' or `0X', `strtonum' assumes that
- STR is a hexadecimal number. For example:
-
- $ echo 0x11 |
- > gawk '{ printf "%d\n", strtonum($1) }'
- -| 17
-
- Using the `strtonum' function is _not_ the same as adding zero to
- a string value; the automatic coercion of strings to numbers works
- only for decimal data, not for octal or hexadecimal.(1)
-
- `strtonum' is a `gawk' extension; it is not available in
- compatibility mode (*note Options::).
-
-`sub(REGEXP, REPLACEMENT [, TARGET])'
- The `sub' function alters the value of TARGET. It searches this
- value, which is treated as a string, for the leftmost, longest
- substring matched by the regular expression REGEXP. Then the
- entire string is changed by replacing the matched text with
- REPLACEMENT. The modified string becomes the new value of TARGET.
-
- The REGEXP argument may be either a regexp constant (`/.../') or a
- string constant ("..."). In the latter case, the string is
- treated as a regexp to be matched. *Note Computed Regexps::, for a
- discussion of the difference between the two forms, and the
- implications for writing your program correctly.
-
- This function is peculiar because TARGET is not simply used to
- compute a value, and not just any expression will do--it must be a
- variable, field, or array element so that `sub' can store a
- modified value there. If this argument is omitted, then the
- default is to use and alter `$0'.(2) For example:
-
- str = "water, water, everywhere"
- sub(/at/, "ith", str)
-
- sets `str' to `"wither, water, everywhere"', by replacing the
- leftmost longest occurrence of `at' with `ith'.
-
- The `sub' function returns the number of substitutions made (either
- one or zero).
-
- If the special character `&' appears in REPLACEMENT, it stands for
- the precise substring that was matched by REGEXP. (If the regexp
- can match more than one string, then this precise substring may
- vary.) For example:
-
- { sub(/candidate/, "& and his wife"); print }
-
- changes the first occurrence of `candidate' to `candidate and his
- wife' on each input line. Here is another example:
-
- $ awk 'BEGIN {
- > str = "daabaaa"
- > sub(/a+/, "C&C", str)
- > print str
- > }'
- -| dCaaCbaaa
-
- This shows how `&' can represent a nonconstant string and also
- illustrates the "leftmost, longest" rule in regexp matching (*note
- Leftmost Longest::).
-
- The effect of this special character (`&') can be turned off by
- putting a backslash before it in the string. As usual, to insert
- one backslash in the string, you must write two backslashes.
- Therefore, write `\\&' in a string constant to include a literal
- `&' in the replacement. For example, the following shows how to
- replace the first `|' on each line with an `&':
-
- { sub(/\|/, "\\&"); print }
-
- As mentioned, the third argument to `sub' must be a variable,
- field or array reference. Some versions of `awk' allow the third
- argument to be an expression that is not an lvalue. In such a
- case, `sub' still searches for the pattern and returns zero or
- one, but the result of the substitution (if any) is thrown away
- because there is no place to put it. Such versions of `awk'
- accept expressions such as the following:
-
- sub(/USA/, "United States", "the USA and Canada")
-
- For historical compatibility, `gawk' accepts erroneous code, such
- as in the previous example. However, using any other nonchangeable
- object as the third parameter causes a fatal error and your program
- will not run.
-
- Finally, if the REGEXP is not a regexp constant, it is converted
- into a string, and then the value of that string is treated as the
- regexp to match.
-
-`gsub(REGEXP, REPLACEMENT [, TARGET])'
- This is similar to the `sub' function, except `gsub' replaces
- _all_ of the longest, leftmost, _nonoverlapping_ matching
- substrings it can find. The `g' in `gsub' stands for "global,"
- which means replace everywhere. For example:
-
- { gsub(/Britain/, "United Kingdom"); print }
-
- replaces all occurrences of the string `Britain' with `United
- Kingdom' for all input records.
-
- The `gsub' function returns the number of substitutions made. If
- the variable to search and alter (TARGET) is omitted, then the
- entire input record (`$0') is used. As in `sub', the characters
- `&' and `\' are special, and the third argument must be assignable.
-
-`gensub(REGEXP, REPLACEMENT, HOW [, TARGET]) #'
- `gensub' is a general substitution function. Like `sub' and
- `gsub', it searches the target string TARGET for matches of the
- regular expression REGEXP. Unlike `sub' and `gsub', the modified
- string is returned as the result of the function and the original
- target string is _not_ changed. If HOW is a string beginning with
- `g' or `G', then it replaces all matches of REGEXP with
- REPLACEMENT. Otherwise, HOW is treated as a number that indicates
- which match of REGEXP to replace. If no TARGET is supplied, `$0'
- is used.
-
- `gensub' provides an additional feature that is not available in
- `sub' or `gsub': the ability to specify components of a regexp in
- the replacement text. This is done by using parentheses in the
- regexp to mark the components and then specifying `\N' in the
- replacement text, where N is a digit from 1 to 9. For example:
-
- $ gawk '
- > BEGIN {
- > a = "abc def"
- > b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a)
- > print b
- > }'
- -| def abc
-
- As with `sub', you must type two backslashes in order to get one
- into the string. In the replacement text, the sequence `\0'
- represents the entire matched text, as does the character `&'.
-
- The following example shows how you can use the third argument to
- control which match of the regexp should be changed:
-
- $ echo a b c a b c |
- > gawk '{ print gensub(/a/, "AA", 2) }'
- -| a b c AA b c
-
- In this case, `$0' is used as the default target string. `gensub'
- returns the new string as its result, which is passed directly to
- `print' for printing.
-
- If the HOW argument is a string that does not begin with `g' or
- `G', or if it is a number that is less than or equal to zero, only
- one substitution is performed. If HOW is zero, `gawk' issues a
- warning message.
-
- If REGEXP does not match TARGET, `gensub''s return value is the
- original unchanged value of TARGET.
-
- `gensub' is a `gawk' extension; it is not available in
- compatibility mode (*note Options::).
-
-`substr(STRING, START [, LENGTH])'
- This returns a LENGTH-character-long substring of STRING, starting
- at character number START. The first character of a string is
- character number one.(3) For example, `substr("washington", 5, 3)'
- returns `"ing"'.
-
- If LENGTH is not present, this function returns the whole suffix of
- STRING that begins at character number START. For example,
- `substr("washington", 5)' returns `"ington"'. The whole suffix is
- also returned if LENGTH is greater than the number of characters
- remaining in the string, counting from character START.
-
- If START is less than one, `substr' treats it as if it was one.
- (POSIX doesn't specify what to do in this case: Unix `awk' acts
- this way, and therefore `gawk' does too.) If START is greater
- than the number of characters in the string, `substr' returns the
- null string. Similarly, if LENGTH is present but less than or
- equal to zero, the null string is returned.
-
- The string returned by `substr' _cannot_ be assigned. Thus, it is
- a mistake to attempt to change a portion of a string, as shown in
- the following example:
-
- string = "abcdef"
- # try to get "abCDEf", won't work
- substr(string, 3, 3) = "CDE"
-
- It is also a mistake to use `substr' as the third argument of
- `sub' or `gsub':
-
- gsub(/xyz/, "pdq", substr($0, 5, 20)) # WRONG
-
- (Some commercial versions of `awk' do in fact let you use `substr'
- this way, but doing so is not portable.)
-
- If you need to replace bits and pieces of a string, combine
- `substr' with string concatenation, in the following manner:
-
- string = "abcdef"
- ...
- string = substr(string, 1, 2) "CDE" substr(string, 6)
-
-`tolower(STRING)'
- This returns a copy of STRING, with each uppercase character in
- the string replaced with its corresponding lowercase character.
- Nonalphabetic characters are left unchanged. For example,
- `tolower("MiXeD cAsE 123")' returns `"mixed case 123"'.
-
-`toupper(STRING)'
- This returns a copy of STRING, with each lowercase character in
- the string replaced with its corresponding uppercase character.
- Nonalphabetic characters are left unchanged. For example,
- `toupper("MiXeD cAsE 123")' returns `"MIXED CASE 123"'.
-
- ---------- Footnotes ----------
-
- (1) Unless you use the `--non-decimal-data' option, which isn't
-recommended. *Note Nondecimal Data::, for more information.
-
- (2) Note that this means that the record will first be regenerated
-using the value of `OFS' if any fields have been changed, and that the
-fields will be updated after the substituion, even if the operation is
-a "no-op" such as `sub(/^/, "")'.
-
- (3) This is different from C and C++, in which the first character
-is number zero.
-
-8.1.3.1 More About `\' and `&' with `sub', `gsub', and `gensub'
-...............................................................
-
-When using `sub', `gsub', or `gensub', and trying to get literal
-backslashes and ampersands into the replacement text, you need to
-remember that there are several levels of "escape processing" going on.
-
- First, there is the "lexical" level, which is when `awk' reads your
-program and builds an internal copy of it that can be executed. Then
-there is the runtime level, which is when `awk' actually scans the
-replacement string to determine what to generate.
-
- At both levels, `awk' looks for a defined set of characters that can
-come after a backslash. At the lexical level, it looks for the escape
-sequences listed in *Note Escape Sequences::. Thus, for every `\' that
-`awk' processes at the runtime level, type two backslashes at the
-lexical level. When a character that is not valid for an escape
-sequence follows the `\', Unix `awk' and `gawk' both simply remove the
-initial `\' and put the next character into the string. Thus, for
-example, `"a\qb"' is treated as `"aqb"'.
-
- At the runtime level, the various functions handle sequences of `\'
-and `&' differently. The situation is (sadly) somewhat complex.
-Historically, the `sub' and `gsub' functions treated the two character
-sequence `\&' specially; this sequence was replaced in the generated
-text with a single `&'. Any other `\' within the REPLACEMENT string
-that did not precede an `&' was passed through unchanged. This is
-illustrated in *Note table-sub-escapes::.
-
- You type `sub' sees `sub' generates
- ------- --------- --------------
- `\&' `&' the matched text
- `\\&' `\&' a literal `&'
- `\\\&' `\&' a literal `&'
- `\\\\&' `\\&' a literal `\&'
- `\\\\\&' `\\&' a literal `\&'
- `\\\\\\&' `\\\&' a literal `\\&'
- `\\q' `\q' a literal `\q'
-
-Table 8.1: Historical Escape Sequence Processing for sub and gsub
-
-This table shows both the lexical-level processing, where an odd number
-of backslashes becomes an even number at the runtime level, as well as
-the runtime processing done by `sub'. (For the sake of simplicity, the
-rest of the following tables only show the case of even numbers of
-backslashes entered at the lexical level.)
-
- The problem with the historical approach is that there is no way to
-get a literal `\' followed by the matched text.
-
- The 1992 POSIX standard attempted to fix this problem. That standard
-says that `sub' and `gsub' look for either a `\' or an `&' after the
-`\'. If either one follows a `\', that character is output literally.
-The interpretation of `\' and `&' then becomes as shown in *Note
-table-sub-posix-92::.
-
- You type `sub' sees `sub' generates
- ------- --------- --------------
- `&' `&' the matched text
- `\\&' `\&' a literal `&'
- `\\\\&' `\\&' a literal `\', then the matched text
- `\\\\\\&' `\\\&' a literal `\&'
-
-Table 8.2: 1992 POSIX Rules for sub and gsub Escape Sequence Processing
-
-This appears to solve the problem. Unfortunately, the phrasing of the
-standard is unusual. It says, in effect, that `\' turns off the special
-meaning of any following character, but for anything other than `\' and
-`&', such special meaning is undefined. This wording leads to two
-problems:
-
- * Backslashes must now be doubled in the REPLACEMENT string, breaking
- historical `awk' programs.
-
- * To make sure that an `awk' program is portable, _every_ character
- in the REPLACEMENT string must be preceded with a backslash.(1)
-
- Because of the problems just listed, in 1996, the `gawk' maintainer
-submitted proposed text for a revised standard that reverts to rules
-that correspond more closely to the original existing practice. The
-proposed rules have special cases that make it possible to produce a
-`\' preceding the matched text. This is shown in *Note
-table-sub-proposed::.
-
- You type `sub' sees `sub' generates
- ------- --------- --------------
- `\\\\\\&' `\\\&' a literal `\&'
- `\\\\&' `\\&' a literal `\', followed by the
matched text
- `\\&' `\&' a literal `&'
- `\\q' `\q' a literal `\q'
- `\\\\' `\\' `\\'
-
-Table 8.3: Propsosed rules for sub and backslash
-
- In a nutshell, at the runtime level, there are now three special
-sequences of characters (`\\\&', `\\&' and `\&') whereas historically
-there was only one. However, as in the historical case, any `\' that
-is not part of one of these three sequences is not special and appears
-in the output literally.
-
- `gawk' 3.0 and 3.1 follow these proposed POSIX rules for `sub' and
-`gsub'. The POSIX standard took much longer to be revised than was
-expected in 1996. The 2001 standard does not follow the above rules.
-Instead, the rules there are somewhat simpler. The results are similar
-except for one case.
-
- The 2001 POSIX rules state that `\&' in the replacement string
-produces a literal `&', `\\' produces a literal `\', and `\' followed
-by anything else is not special; the `\' is placed straight into the
-output. These rules are presented in *Note table-posix-2001-sub::.
-
- You type `sub' sees `sub' generates
- ------- --------- --------------
- `\\\\\\&' `\\\&' a literal `\&'
- `\\\\&' `\\&' a literal `\', followed by the
matched text
- `\\&' `\&' a literal `&'
- `\\q' `\q' a literal `\q'
- `\\\\' `\\' `\'
-
-Table 8.4: POSIX 2001 rules for sub
-
- The only case where the difference is noticeable is the last one:
-`\\\\' is seen as `\\' and produces `\' instead of `\\'.
-
- Starting with version 3.1.4, `gawk' follows the POSIX rules when
-`--posix' is specified (*note Options::). Otherwise, it continues to
-follow the 1996 proposed rules, since, as of this writing, that has
-been its behavior for over seven years.
-
- NOTE: At the next major release, `gawk' will switch to using the
- POSIX 2001 rules by default.
-
- The rules for `gensub' are considerably simpler. At the runtime
-level, whenever `gawk' sees a `\', if the following character is a
-digit, then the text that matched the corresponding parenthesized
-subexpression is placed in the generated output. Otherwise, no matter
-what character follows the `\', it appears in the generated text and
-the `\' does not, as shown in *Note table-gensub-escapes::.
-
- You type `gensub' sees `gensub' generates
- ------- ------------ -----------------
- `&' `&' the matched text
- `\\&' `\&' a literal `&'
- `\\\\' `\\' a literal `\'
- `\\\\&' `\\&' a literal `\', then the
matched text
- `\\\\\\&' `\\\&' a literal `\&'
- `\\q' `\q' a literal `q'
-
-Table 8.5: Escape Sequence Processing for gensub
-
- Because of the complexity of the lexical and runtime level processing
-and the special cases for `sub' and `gsub', we recommend the use of
-`gawk' and `gensub' when you have to do substitutions.
-
-Advanced Notes: Matching the Null String
-----------------------------------------
-
-In `awk', the `*' operator can match the null string. This is
-particularly important for the `sub', `gsub', and `gensub' functions.
-For example:
-
- $ echo abc | awk '{ gsub(/m*/, "X"); print }'
- -| XaXbXcX
-
-Although this makes a certain amount of sense, it can be surprising.
-
- ---------- Footnotes ----------
-
- (1) This consequence was certainly unintended.
-
-8.1.4 Input/Output Functions
-----------------------------
-
-The following functions relate to input/output (I/O). Optional
-parameters are enclosed in square brackets ([ ]):
-
-`close(FILENAME [, HOW])'
- Close the file FILENAME for input or output. Alternatively, the
- argument may be a shell command that was used for creating a
- coprocess, or for redirecting to or from a pipe; then the
- coprocess or pipe is closed. *Note Close Files And Pipes::, for
- more information.
-
- When closing a coprocess, it is occasionally useful to first close
- one end of the two-way pipe and then to close the other. This is
- done by providing a second argument to `close'. This second
- argument should be one of the two string values `"to"' or `"from"',
- indicating which end of the pipe to close. Case in the string does
- not matter. *Note Two-way I/O::, which discusses this feature in
- more detail and gives an example.
-
-`fflush([FILENAME])'
- Flush any buffered output associated with FILENAME, which is
- either a file opened for writing or a shell command for
- redirecting output to a pipe or coprocess.
-
- Many utility programs "buffer" their output; i.e., they save
- information to write to a disk file or terminal in memory until
- there is enough for it to be worthwhile to send the data to the
- output device. This is often more efficient than writing every
- little bit of information as soon as it is ready. However,
- sometimes it is necessary to force a program to "flush" its
- buffers; that is, write the information to its destination, even
- if a buffer is not full. This is the purpose of the `fflush'
- function--`gawk' also buffers its output and the `fflush' function
- forces `gawk' to flush its buffers.
-
- `fflush' was added to the Bell Laboratories research version of
- `awk' in 1994; it is not part of the POSIX standard and is not
- available if `--posix' has been specified on the command line
- (*note Options::).
-
- `gawk' extends the `fflush' function in two ways. The first is to
- allow no argument at all. In this case, the buffer for the
- standard output is flushed. The second is to allow the null string
- (`""') as the argument. In this case, the buffers for _all_ open
- output files and pipes are flushed.
-
- `fflush' returns zero if the buffer is successfully flushed;
- otherwise, it returns -1. In the case where all buffers are
- flushed, the return value is zero only if all buffers were flushed
- successfully. Otherwise, it is -1, and `gawk' warns about the
- problem FILENAME.
-
- `gawk' also issues a warning message if you attempt to flush a
- file or pipe that was opened for reading (such as with `getline'),
- or if FILENAME is not an open file, pipe, or coprocess. In such a
- case, `fflush' returns -1, as well.
-
-`system(COMMAND)'
- Executes operating-system commands and then returns to the `awk'
- program. The `system' function executes the command given by the
- string COMMAND. It returns the status returned by the command
- that was executed as its value.
-
- For example, if the following fragment of code is put in your `awk'
- program:
-
- END {
- system("date | mail -s 'awk run done' root")
- }
-
- the system administrator is sent mail when the `awk' program
- finishes processing input and begins its end-of-input processing.
-
- Note that redirecting `print' or `printf' into a pipe is often
- enough to accomplish your task. If you need to run many commands,
- it is more efficient to simply print them down a pipeline to the
- shell:
-
- while (MORE STUFF TO DO)
- print COMMAND | "/bin/sh"
- close("/bin/sh")
-
- However, if your `awk' program is interactive, `system' is useful
- for cranking up large self-contained programs, such as a shell or
- an editor. Some operating systems cannot implement the `system'
- function. `system' causes a fatal error if it is not supported.
-
-Advanced Notes: Interactive Versus Noninteractive Buffering
------------------------------------------------------------
-
-As a side point, buffering issues can be even more confusing, depending
-upon whether your program is "interactive", i.e., communicating with a
-user sitting at a keyboard.(1)
-
- Interactive programs generally "line buffer" their output; i.e., they
-write out every line. Noninteractive programs wait until they have a
-full buffer, which may be many lines of output. Here is an example of
-the difference:
-
- $ awk '{ print $1 + $2 }'
- 1 1
- -| 2
- 2 3
- -| 5
- Ctrl-d
-
-Each line of output is printed immediately. Compare that behavior with
-this example:
-
- $ awk '{ print $1 + $2 }' | cat
- 1 1
- 2 3
- Ctrl-d
- -| 2
- -| 5
-
-Here, no output is printed until after the `Ctrl-d' is typed, because
-it is all buffered and sent down the pipe to `cat' in one shot.
-
-Advanced Notes: Controlling Output Buffering with `system'
-----------------------------------------------------------
-
-The `fflush' function provides explicit control over output buffering
-for individual files and pipes. However, its use is not portable to
-many other `awk' implementations. An alternative method to flush output
-buffers is to call `system' with a null string as its argument:
-
- system("") # flush output
-
-`gawk' treats this use of the `system' function as a special case and
-is smart enough not to run a shell (or other command interpreter) with
-the empty command. Therefore, with `gawk', this idiom is not only
-useful, it is also efficient. While this method should work with other
-`awk' implementations, it does not necessarily avoid starting an
-unnecessary shell. (Other implementations may only flush the buffer
-associated with the standard output and not necessarily all buffered
-output.)
-
- If you think about what a programmer expects, it makes sense that
-`system' should flush any pending output. The following program:
-
- BEGIN {
- print "first print"
- system("echo system echo")
- print "second print"
- }
-
-must print:
-
- first print
- system echo
- second print
-
-and not:
-
- system echo
- first print
- second print
-
- If `awk' did not flush its buffers before calling `system', you
-would see the latter (undesirable) output.
-
- ---------- Footnotes ----------
-
- (1) A program is interactive if the standard output is connected to
-a terminal device.
-
-8.1.5 Using `gawk''s Timestamp Functions
-----------------------------------------
-
-`awk' programs are commonly used to process log files containing
-timestamp information, indicating when a particular log record was
-written. Many programs log their timestamp in the form returned by the
-`time' system call, which is the number of seconds since a particular
-epoch. On POSIX-compliant systems, it is the number of seconds since
-1970-01-01 00:00:00 UTC, not counting leap seconds.(1) All known
-POSIX-compliant systems support timestamps from 0 through 2^31 - 1,
-which is sufficient to represent times through 2038-01-19 03:14:07 UTC.
-Many systems support a wider range of timestamps, including negative
-timestamps that represent times before the epoch.
-
- In order to make it easier to process such log files and to produce
-useful reports, `gawk' provides the following functions for working
-with timestamps. They are `gawk' extensions; they are not specified in
-the POSIX standard, nor are they in any other known version of `awk'.(2)
-Optional parameters are enclosed in square brackets ([ ]):
-
-`systime()'
- This function returns the current time as the number of seconds
- since the system epoch. On POSIX systems, this is the number of
- seconds since 1970-01-01 00:00:00 UTC, not counting leap seconds.
- It may be a different number on other systems.
-
-`mktime(DATESPEC)'
- This function turns DATESPEC into a timestamp in the same form as
- is returned by `systime'. It is similar to the function of the
- same name in ISO C. The argument, DATESPEC, is a string of the
- form `"YYYY MM DD HH MM SS [DST]"'. The string consists of six or
- seven numbers representing, respectively, the full year including
- century, the month from 1 to 12, the day of the month from 1 to
- 31, the hour of the day from 0 to 23, the minute from 0 to 59, the
- second from 0 to 60,(3) and an optional daylight-savings flag.
-
- The values of these numbers need not be within the ranges
- specified; for example, an hour of -1 means 1 hour before midnight.
- The origin-zero Gregorian calendar is assumed, with year 0
- preceding year 1 and year -1 preceding year 0. The time is
- assumed to be in the local timezone. If the daylight-savings flag
- is positive, the time is assumed to be daylight savings time; if
- zero, the time is assumed to be standard time; and if negative
- (the default), `mktime' attempts to determine whether daylight
- savings time is in effect for the specified time.
-
- If DATESPEC does not contain enough elements or if the resulting
- time is out of range, `mktime' returns -1.
-
-`strftime([FORMAT [, TIMESTAMP]])'
- This function returns a string. It is similar to the function of
- the same name in ISO C. The time specified by TIMESTAMP is used to
- produce a string, based on the contents of the FORMAT string. The
- TIMESTAMP is in the same format as the value returned by the
- `systime' function. If no TIMESTAMP argument is supplied, `gawk'
- uses the current time of day as the timestamp. If no FORMAT
- argument is supplied, `strftime' uses `"%a %b %d %H:%M:%S %Z %Y"'.
- This format string produces output that is (almost) equivalent to
- that of the `date' utility. (Versions of `gawk' prior to 3.0
- require the FORMAT argument.)
-
- The `systime' function allows you to compare a timestamp from a log
-file with the current time of day. In particular, it is easy to
-determine how long ago a particular record was logged. It also allows
-you to produce log records using the "seconds since the epoch" format.
-
- The `mktime' function allows you to convert a textual representation
-of a date and time into a timestamp. This makes it easy to do
-before/after comparisons of dates and times, particularly when dealing
-with date and time data coming from an external source, such as a log
-file.
-
- The `strftime' function allows you to easily turn a timestamp into
-human-readable information. It is similar in nature to the `sprintf'
-function (*note String Functions::), in that it copies nonformat
-specification characters verbatim to the returned string, while
-substituting date and time values for format specifications in the
-FORMAT string.
-
- `strftime' is guaranteed by the 1999 ISO C standard(4) to support
-the following date format specifications:
-
-`%a'
- The locale's abbreviated weekday name.
-
-`%A'
- The locale's full weekday name.
-
-`%b'
- The locale's abbreviated month name.
-
-`%B'
- The locale's full month name.
-
-`%c'
- The locale's "appropriate" date and time representation. (This is
- `%A %B %d %T %Y' in the `"C"' locale.)
-
-`%C'
- The century. This is the year divided by 100 and truncated to the
- next lower integer.
-
-`%d'
- The day of the month as a decimal number (01-31).
-
-`%D'
- Equivalent to specifying `%m/%d/%y'.
-
-`%e'
- The day of the month, padded with a space if it is only one digit.
-
-`%F'
- Equivalent to specifying `%Y-%m-%d'. This is the ISO 8601 date
- format.
-
-`%g'
- The year modulo 100 of the ISO week number, as a decimal number
- (00-99). For example, January 1, 1993 is in week 53 of 1992.
- Thus, the year of its ISO week number is 1992, even though its
- year is 1993. Similarly, December 31, 1973 is in week 1 of 1974.
- Thus, the year of its ISO week number is 1974, even though its
- year is 1973.
-
-`%G'
- The full year of the ISO week number, as a decimal number.
-
-`%h'
- Equivalent to `%b'.
-
-`%H'
- The hour (24-hour clock) as a decimal number (00-23).
-
-`%I'
- The hour (12-hour clock) as a decimal number (01-12).
-
-`%j'
- The day of the year as a decimal number (001-366).
-
-`%m'
- The month as a decimal number (01-12).
-
-`%M'
- The minute as a decimal number (00-59).
-
-`%n'
- A newline character (ASCII LF).
-
-`%p'
- The locale's equivalent of the AM/PM designations associated with
- a 12-hour clock.
-
-`%r'
- The locale's 12-hour clock time. (This is `%I:%M:%S %p' in the
- `"C"' locale.)
-
-`%R'
- Equivalent to specifying `%H:%M'.
-
-`%S'
- The second as a decimal number (00-60).
-
-`%t'
- A TAB character.
-
-`%T'
- Equivalent to specifying `%H:%M:%S'.
-
-`%u'
- The weekday as a decimal number (1-7). Monday is day one.
-
-`%U'
- The week number of the year (the first Sunday as the first day of
- week one) as a decimal number (00-53).
-
-`%V'
- The week number of the year (the first Monday as the first day of
- week one) as a decimal number (01-53). The method for determining
- the week number is as specified by ISO 8601. (To wit: if the week
- containing January 1 has four or more days in the new year, then
- it is week one; otherwise it is week 53 of the previous year and
- the next week is week one.)
-
-`%w'
- The weekday as a decimal number (0-6). Sunday is day zero.
-
-`%W'
- The week number of the year (the first Monday as the first day of
- week one) as a decimal number (00-53).
-
-`%x'
- The locale's "appropriate" date representation. (This is `%A %B
- %d %Y' in the `"C"' locale.)
-
-`%X'
- The locale's "appropriate" time representation. (This is `%T' in
- the `"C"' locale.)
-
-`%y'
- The year modulo 100 as a decimal number (00-99).
-
-`%Y'
- The full year as a decimal number (e.g., 1995).
-
-`%z'
- The timezone offset in a +HHMM format (e.g., the format necessary
- to produce RFC 822/RFC 1036 date headers).
-
-`%Z'
- The time zone name or abbreviation; no characters if no time zone
- is determinable.
-
-`%Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH'
-`%OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy'
- "Alternate representations" for the specifications that use only
- the second letter (`%c', `%C', and so on).(5) (These facilitate
- compliance with the POSIX `date' utility.)
-
-`%%'
- A literal `%'.
-
- If a conversion specifier is not one of the above, the behavior is
-undefined.(6)
-
- Informally, a "locale" is the geographic place in which a program is
-meant to run. For example, a common way to abbreviate the date
-September 4, 1991 in the United States is "9/4/91." In many countries
-in Europe, however, it is abbreviated "4.9.91." Thus, the `%x'
-specification in a `"US"' locale might produce `9/4/91', while in a
-`"EUROPE"' locale, it might produce `4.9.91'. The ISO C standard
-defines a default `"C"' locale, which is an environment that is typical
-of what most C programmers are used to.
-
- A public-domain C version of `strftime' is supplied with `gawk' for
-systems that are not yet fully standards-compliant. It supports all of
-the just listed format specifications. If that version is used to
-compile `gawk' (*note Installation::), then the following additional
-format specifications are available:
-
-`%k'
- The hour (24-hour clock) as a decimal number (0-23). Single-digit
- numbers are padded with a space.
-
-`%l'
- The hour (12-hour clock) as a decimal number (1-12). Single-digit
- numbers are padded with a space.
-
-`%N'
- The "Emperor/Era" name. Equivalent to `%C'.
-
-`%o'
- The "Emperor/Era" year. Equivalent to `%y'.
-
-`%s'
- The time as a decimal timestamp in seconds since the epoch.
-
-`%v'
- The date in VMS format (e.g., `20-JUN-1991').
-
- Additionally, the alternate representations are recognized but their
-normal representations are used.
-
- This example is an `awk' implementation of the POSIX `date' utility.
-Normally, the `date' utility prints the current date and time of day
-in a well-known format. However, if you provide an argument to it that
-begins with a `+', `date' copies nonformat specifier characters to the
-standard output and interprets the current time according to the format
-specifiers in the string. For example:
-
- $ date '+Today is %A, %B %d, %Y.'
- -| Today is Thursday, September 14, 2000.
-
- Here is the `gawk' version of the `date' utility. It has a shell
-"wrapper" to handle the `-u' option, which requires that `date' run as
-if the time zone is set to UTC:
-
- #! /bin/sh
- #
- # date --- approximate the P1003.2 'date' command
-
- case $1 in
- -u) TZ=UTC0 # use UTC
- export TZ
- shift ;;
- esac
-
- gawk 'BEGIN {
- format = "%a %b %d %H:%M:%S %Z %Y"
- exitval = 0
-
- if (ARGC > 2)
- exitval = 1
- else if (ARGC == 2) {
- format = ARGV[1]
- if (format ~ /^\+/)
- format = substr(format, 2) # remove leading +
- }
- print strftime(format)
- exit exitval
- }' "$@"
-
- ---------- Footnotes ----------
-
- (1) *Note Glossary::, especially the entries "Epoch" and "UTC."
-
- (2) The GNU `date' utility can also do many of the things described
-here. Its use may be preferable for simple time-related operations in
-shell scripts.
-
- (3) Occasionally there are minutes in a year with a leap second,
-which is why the seconds can go up to 60.
-
- (4) As this is a recent standard, not every system's `strftime'
-necessarily supports all of the conversions listed here.
-
- (5) If you don't understand any of this, don't worry about it; these
-facilities are meant to make it easier to "internationalize" programs.
-Other internationalization features are described in *Note
-Internationalization::.
-
- (6) This is because ISO C leaves the behavior of the C version of
-`strftime' undefined and `gawk' uses the system's version of `strftime'
-if it's there. Typically, the conversion specifier either does not
-appear in the returned string or appears literally.
-
-8.1.6 Bit-Manipulation Functions of `gawk'
-------------------------------------------
-
- I can explain it for you, but I can't understand it for you.
- Anonymous
-
- Many languages provide the ability to perform "bitwise" operations
-on two integer numbers. In other words, the operation is performed on
-each successive pair of bits in the operands. Three common operations
-are bitwise AND, OR, and XOR. The operations are described in *Note
-table-bitwise-ops::.
-
- Bit Operator
- | AND | OR | XOR
- |--+--+--+--+--+--
- Operands | 0 | 1 | 0 | 1 | 0 | 1
- ---------+--+--+--+--+--+--
- 0 | 0 0 | 0 1 | 0 1
- 1 | 0 1 | 1 1 | 1 0
-
-Table 8.6: Bitwise Operations
-
- As you can see, the result of an AND operation is 1 only when _both_
-bits are 1. The result of an OR operation is 1 if _either_ bit is 1.
-The result of an XOR operation is 1 if either bit is 1, but not both.
-The next operation is the "complement"; the complement of 1 is 0 and
-the complement of 0 is 1. Thus, this operation "flips" all the bits of
-a given value.
-
- Finally, two other common operations are to shift the bits left or
-right. For example, if you have a bit string `10111001' and you shift
-it right by three bits, you end up with `00010111'.(1) If you start over
-again with `10111001' and shift it left by three bits, you end up with
-`11001000'. `gawk' provides built-in functions that implement the
-bitwise operations just described. They are:
-
-`and(V1, V2)' Returns the bitwise AND of the values provided by V1
- and V2.
-`or(V1, V2)' Returns the bitwise OR of the values provided by V1
- and V2.
-`xor(V1, V2)' Returns the bitwise XOR of the values provided by V1
- and V2.
-`compl(VAL)' Returns the bitwise complement of VAL.
-`lshift(VAL, COUNT)' Returns the value of VAL, shifted left by COUNT bits.
-`rshift(VAL, COUNT)' Returns the value of VAL, shifted right by COUNT bits.
-
- For all of these functions, first the double-precision
-floating-point value is converted to the widest C unsigned integer
-type, then the bitwise operation is performed. If the result cannot be
-represented exactly as a C `double', leading nonzero bits are removed
-one by one until it can be represented exactly. The result is then
-converted back into a C `double'. (If you don't understand this
-paragraph, don't worry about it.)
-
- Here is a user-defined function (*note User-defined::) that
-illustrates the use of these functions:
-
- # bits2str --- turn a byte into readable 1's and 0's
-
- function bits2str(bits, data, mask)
- {
- if (bits == 0)
- return "0"
-
- mask = 1
- for (; bits != 0; bits = rshift(bits, 1))
- data = (and(bits, mask) ? "1" : "0") data
-
- while ((length(data) % 8) != 0)
- data = "0" data
-
- return data
- }
-
- BEGIN {
- printf "123 = %s\n", bits2str(123)
- printf "0123 = %s\n", bits2str(0123)
- printf "0x99 = %s\n", bits2str(0x99)
- comp = compl(0x99)
- printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp)
- shift = lshift(0x99, 2)
- printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
- shift = rshift(0x99, 2)
- printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
- }
-
-This program produces the following output when run:
-
- $ gawk -f testbits.awk
- -| 123 = 01111011
- -| 0123 = 01010011
- -| 0x99 = 10011001
- -| compl(0x99) = 0xffffff66 = 11111111111111111111111101100110
- -| lshift(0x99, 2) = 0x264 = 0000001001100100
- -| rshift(0x99, 2) = 0x26 = 00100110
-
- The `bits2str' function turns a binary number into a string. The
-number `1' represents a binary value where the rightmost bit is set to
-1. Using this mask, the function repeatedly checks the rightmost bit.
-ANDing the mask with the value indicates whether the rightmost bit is 1
-or not. If so, a `"1"' is concatenated onto the front of the string.
-Otherwise, a `"0"' is added. The value is then shifted right by one
-bit and the loop continues until there are no more 1 bits.
-
- If the initial value is zero it returns a simple `"0"'. Otherwise,
-at the end, it pads the value with zeros to represent multiples of
-8-bit quantities. This is typical in modern computers.
-
- The main code in the `BEGIN' rule shows the difference between the
-decimal and octal values for the same numbers (*note
-Nondecimal-numbers::), and then demonstrates the results of the
-`compl', `lshift', and `rshift' functions.
-
- ---------- Footnotes ----------
-
- (1) This example shows that 0's come in on the left side. For
-`gawk', this is always true, but in some languages, it's possible to
-have the left side fill with 1's. Caveat emptor.
-
-8.1.7 Using `gawk''s String-Translation Functions
--------------------------------------------------
-
-`gawk' provides facilities for internationalizing `awk' programs.
-These include the functions described in the following list. The
-descriptions here are purposely brief. *Note Internationalization::,
-for the full story. Optional parameters are enclosed in square
-brackets ([ ]):
-
-`dcgettext(STRING [, DOMAIN [, CATEGORY]])'
- This function returns the translation of STRING in text domain
- DOMAIN for locale category CATEGORY. The default value for DOMAIN
- is the current value of `TEXTDOMAIN'. The default value for
- CATEGORY is `"LC_MESSAGES"'.
-
-`dcngettext(STRING1, STRING2, NUMBER [, DOMAIN [, CATEGORY]])'
- This function returns the plural form used for NUMBER of the
- translation of STRING1 and STRING2 in text domain DOMAIN for
- locale category CATEGORY. STRING1 is the English singular variant
- of a message, and STRING2 the English plural variant of the same
- message. The default value for DOMAIN is the current value of
- `TEXTDOMAIN'. The default value for CATEGORY is `"LC_MESSAGES"'.
-
-`bindtextdomain(DIRECTORY [, DOMAIN])'
- This function allows you to specify the directory in which `gawk'
- will look for message translation files, in case they will not or
- cannot be placed in the "standard" locations (e.g., during
- testing). It returns the directory in which DOMAIN is "bound."
-
- The default DOMAIN is the value of `TEXTDOMAIN'. If DIRECTORY is
- the null string (`""'), then `bindtextdomain' returns the current
- binding for the given DOMAIN.
-
-8.2 User-Defined Functions
-==========================
-
-Complicated `awk' programs can often be simplified by defining your own
-functions. User-defined functions can be called just like built-in
-ones (*note Function Calls::), but it is up to you to define them,
-i.e., to tell `awk' what they should do.
-
-8.2.1 Function Definition Syntax
---------------------------------
-
-Definitions of functions can appear anywhere between the rules of an
-`awk' program. Thus, the general form of an `awk' program is extended
-to include sequences of rules _and_ user-defined function definitions.
-There is no need to put the definition of a function before all uses of
-the function. This is because `awk' reads the entire program before
-starting to execute any of it.
-
- The definition of a function named NAME looks like this:
-
- function NAME(PARAMETER-LIST)
- {
- BODY-OF-FUNCTION
- }
-
-NAME is the name of the function to define. A valid function name is
-like a valid variable name: a sequence of letters, digits, and
-underscores that doesn't start with a digit. Within a single `awk'
-program, any particular name can only be used as a variable, array, or
-function.
-
- PARAMETER-LIST is a list of the function's arguments and local
-variable names, separated by commas. When the function is called, the
-argument names are used to hold the argument values given in the call.
-The local variables are initialized to the empty string. A function
-cannot have two parameters with the same name, nor may it have a
-parameter with the same name as the function itself.
-
- The BODY-OF-FUNCTION consists of `awk' statements. It is the most
-important part of the definition, because it says what the function
-should actually _do_. The argument names exist to give the body a way
-to talk about the arguments; local variables exist to give the body
-places to keep temporary values.
-
- Argument names are not distinguished syntactically from local
-variable names. Instead, the number of arguments supplied when the
-function is called determines how many argument variables there are.
-Thus, if three argument values are given, the first three names in
-PARAMETER-LIST are arguments and the rest are local variables.
-
- It follows that if the number of arguments is not the same in all
-calls to the function, some of the names in PARAMETER-LIST may be
-arguments on some occasions and local variables on others. Another way
-to think of this is that omitted arguments default to the null string.
-
- Usually when you write a function, you know how many names you
-intend to use for arguments and how many you intend to use as local
-variables. It is conventional to place some extra space between the
-arguments and the local variables, in order to document how your
-function is supposed to be used.
-
- During execution of the function body, the arguments and local
-variable values hide, or "shadow", any variables of the same names used
-in the rest of the program. The shadowed variables are not accessible
-in the function definition, because there is no way to name them while
-their names have been taken away for the local variables. All other
-variables used in the `awk' program can be referenced or set normally
-in the function's body.
-
- The arguments and local variables last only as long as the function
-body is executing. Once the body finishes, you can once again access
-the variables that were shadowed while the function was running.
-
- The function body can contain expressions that call functions. They
-can even call this function, either directly or by way of another
-function. When this happens, we say the function is "recursive". The
-act of a function calling itself is called "recursion".
-
- In many `awk' implementations, including `gawk', the keyword
-`function' may be abbreviated `func'. However, POSIX only specifies
-the use of the keyword `function'. This actually has some practical
-implications. If `gawk' is in POSIX-compatibility mode (*note
-Options::), then the following statement does _not_ define a function:
-
- func foo() { a = sqrt($1) ; print a }
-
-Instead it defines a rule that, for each record, concatenates the value
-of the variable `func' with the return value of the function `foo'. If
-the resulting string is non-null, the action is executed. This is
-probably not what is desired. (`awk' accepts this input as
-syntactically valid, because functions may be used before they are
-defined in `awk' programs.)
-
- To ensure that your `awk' programs are portable, always use the
-keyword `function' when defining a function.
-
-8.2.2 Function Definition Examples
-----------------------------------
-
-Here is an example of a user-defined function, called `myprint', that
-takes a number and prints it in a specific format:
-
- function myprint(num)
- {
- printf "%6.3g\n", num
- }
-
-To illustrate, here is an `awk' rule that uses our `myprint' function:
-
- $3 > 0 { myprint($3) }
-
-This program prints, in our special format, all the third fields that
-contain a positive number in our input. Therefore, when given the
-following:
-
- 1.2 3.4 5.6 7.8
- 9.10 11.12 -13.14 15.16
- 17.18 19.20 21.22 23.24
-
-this program, using our function to format the results, prints:
-
- 5.6
- 21.2
-
- This function deletes all the elements in an array:
-
- function delarray(a, i)
- {
- for (i in a)
- delete a[i]
- }
-
- When working with arrays, it is often necessary to delete all the
-elements in an array and start over with a new list of elements (*note
-Delete::). Instead of having to repeat this loop everywhere that you
-need to clear out an array, your program can just call `delarray'.
-(This guarantees portability. The use of `delete ARRAY' to delete the
-contents of an entire array is a nonstandard extension.)
-
- The following is an example of a recursive function. It takes a
-string as an input parameter and returns the string in backwards order.
-Recursive functions must always have a test that stops the recursion.
-In this case, the recursion terminates when the starting position is
-zero, i.e., when there are no more characters left in the string.
-
- function rev(str, start)
- {
- if (start == 0)
- return ""
-
- return (substr(str, start, 1) rev(str, start - 1))
- }
-
- If this function is in a file named `rev.awk', it can be tested this
-way:
-
- $ echo "Don't Panic!" |
- > gawk --source '{ print rev($0, length($0)) }' -f rev.awk
- -| !cinaP t'noD
-
- The C `ctime' function takes a timestamp and returns it in a string,
-formatted in a well-known fashion. The following example uses the
-built-in `strftime' function (*note Time Functions::) to create an
-`awk' version of `ctime':
-
- # ctime.awk
- #
- # awk version of C ctime(3) function
-
- function ctime(ts, format)
- {
- format = "%a %b %d %H:%M:%S %Z %Y"
- if (ts == 0)
- ts = systime() # use current time as default
- return strftime(format, ts)
- }
-
-8.2.3 Calling User-Defined Functions
-------------------------------------
-
-"Calling a function" means causing the function to run and do its job.
-A function call is an expression and its value is the value returned by
-the function.
-
- A function call consists of the function name followed by the
-arguments in parentheses. `awk' expressions are what you write in the
-call for the arguments. Each time the call is executed, these
-expressions are evaluated, and the values are the actual arguments. For
-example, here is a call to `foo' with three arguments (the first being
-a string concatenation):
-
- foo(x y, "lose", 4 * z)
-
- *Caution:* Whitespace characters (spaces and tabs) are not allowed
-between the function name and the open-parenthesis of the argument list.
-If you write whitespace by mistake, `awk' might think that you mean to
-concatenate a variable with an expression in parentheses. However, it
-notices that you used a function name and not a variable name, and
-reports an error.
-
- When a function is called, it is given a _copy_ of the values of its
-arguments. This is known as "call by value". The caller may use a
-variable as the expression for the argument, but the called function
-does not know this--it only knows what value the argument had. For
-example, if you write the following code:
-
- foo = "bar"
- z = myfunc(foo)
-
-then you should not think of the argument to `myfunc' as being "the
-variable `foo'." Instead, think of the argument as the string value
-`"bar"'. If the function `myfunc' alters the values of its local
-variables, this has no effect on any other variables. Thus, if `myfunc'
-does this:
-
- function myfunc(str)
- {
- print str
- str = "zzz"
- print str
- }
-
-to change its first argument variable `str', it does _not_ change the
-value of `foo' in the caller. The role of `foo' in calling `myfunc'
-ended when its value (`"bar"') was computed. If `str' also exists
-outside of `myfunc', the function body cannot alter this outer value,
-because it is shadowed during the execution of `myfunc' and cannot be
-seen or changed from there.
-
- However, when arrays are the parameters to functions, they are _not_
-copied. Instead, the array itself is made available for direct
-manipulation by the function. This is usually called "call by
-reference". Changes made to an array parameter inside the body of a
-function _are_ visible outside that function.
-
- NOTE: Changing an array parameter inside a function can be very
- dangerous if you do not watch what you are doing. For example:
-
- function changeit(array, ind, nvalue)
- {
- array[ind] = nvalue
- }
-
- BEGIN {
- a[1] = 1; a[2] = 2; a[3] = 3
- changeit(a, 2, "two")
- printf "a[1] = %s, a[2] = %s, a[3] = %s\n",
- a[1], a[2], a[3]
- }
-
- prints `a[1] = 1, a[2] = two, a[3] = 3', because `changeit' stores
- `"two"' in the second element of `a'.
-
- Some `awk' implementations allow you to call a function that has not
-been defined. They only report a problem at runtime when the program
-actually tries to call the function. For example:
-
- BEGIN {
- if (0)
- foo()
- else
- bar()
- }
- function bar() { ... }
- # note that `foo' is not defined
-
-Because the `if' statement will never be true, it is not really a
-problem that `foo' has not been defined. Usually, though, it is a
-problem if a program calls an undefined function.
-
- If `--lint' is specified (*note Options::), `gawk' reports calls to
-undefined functions.
-
- Some `awk' implementations generate a runtime error if you use the
-`next' statement (*note Next Statement::) inside a user-defined
-function. `gawk' does not have this limitation.
-
-8.2.4 The `return' Statement
-----------------------------
-
-The body of a user-defined function can contain a `return' statement.
-This statement returns control to the calling part of the `awk'
-program. It can also be used to return a value for use in the rest of
-the `awk' program. It looks like this:
-
- return [EXPRESSION]
-
- The EXPRESSION part is optional. If it is omitted, then the returned
-value is undefined, and therefore, unpredictable.
-
- A `return' statement with no value expression is assumed at the end
-of every function definition. So if control reaches the end of the
-function body, then the function returns an unpredictable value. `awk'
-does _not_ warn you if you use the return value of such a function.
-
- Sometimes, you want to write a function for what it does, not for
-what it returns. Such a function corresponds to a `void' function in C
-or to a `procedure' in Pascal. Thus, it may be appropriate to not
-return any value; simply bear in mind that if you use the return value
-of such a function, you do so at your own risk.
-
- The following is an example of a user-defined function that returns
-a value for the largest number among the elements of an array:
-
- function maxelt(vec, i, ret)
- {
- for (i in vec) {
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- }
- return ret
- }
-
-You call `maxelt' with one argument, which is an array name. The local
-variables `i' and `ret' are not intended to be arguments; while there
-is nothing to stop you from passing more than one argument to `maxelt',
-the results would be strange. The extra space before `i' in the
-function parameter list indicates that `i' and `ret' are not supposed
-to be arguments. You should follow this convention when defining
-functions.
-
- The following program uses the `maxelt' function. It loads an
-array, calls `maxelt', and then reports the maximum number in that
-array:
-
- function maxelt(vec, i, ret)
- {
- for (i in vec) {
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- }
- return ret
- }
-
- # Load all fields of each record into nums.
- {
- for(i = 1; i <= NF; i++)
- nums[NR, i] = $i
- }
-
- END {
- print maxelt(nums)
- }
-
- Given the following input:
-
- 1 5 23 8 16
- 44 3 5 2 8 26
- 256 291 1396 2962 100
- -6 467 998 1101
- 99385 11 0 225
-
-the program reports (predictably) that `99385' is the largest number in
-the array.
-
-8.2.5 Functions and Their Effects on Variable Typing
-----------------------------------------------------
-
-`awk' is a very fluid language. It is possible that `awk' can't tell
-if an identifier represents a regular variable or an array until
-runtime. Here is an annotated sample program:
-
- function foo(a)
- {
- a[1] = 1 # parameter is an array
- }
-
- BEGIN {
- b = 1
- foo(b) # invalid: fatal type mismatch
-
- foo(x) # x uninitialized, becomes an array dynamically
- x = 1 # now not allowed, runtime error
- }
-
- Usually, such things aren't a big issue, but it's worth being aware
-of them.
-
-9 Internationalization with `gawk'
-**********************************
-
-Once upon a time, computer makers wrote software that worked only in
-English. Eventually, hardware and software vendors noticed that if
-their systems worked in the native languages of non-English-speaking
-countries, they were able to sell more systems. As a result,
-internationalization and localization of programs and software systems
-became a common practice.
-
- Until recently, the ability to provide internationalization was
-largely restricted to programs written in C and C++. This major node
-describes the underlying library `gawk' uses for internationalization,
-as well as how `gawk' makes internationalization features available at
-the `awk' program level. Having internationalization available at the
-`awk' level gives software developers additional flexibility--they are
-no longer required to write in C when internationalization is a
-requirement.
-
-9.1 Internationalization and Localization
-=========================================
-
-"Internationalization" means writing (or modifying) a program once, in
-such a way that it can use multiple languages without requiring further
-source-code changes. "Localization" means providing the data necessary
-for an internationalized program to work in a particular language.
-Most typically, these terms refer to features such as the language used
-for printing error messages, the language used to read responses, and
-information related to how numerical and monetary values are printed
-and read.
-
-9.2 GNU `gettext'
-=================
-
-The facilities in GNU `gettext' focus on messages; strings printed by a
-program, either directly or via formatting with `printf' or
-`sprintf'.(1)
-
- When using GNU `gettext', each application has its own "text
-domain". This is a unique name, such as `kpilot' or `gawk', that
-identifies the application. A complete application may have multiple
-components--programs written in C or C++, as well as scripts written in
-`sh' or `awk'. All of the components use the same text domain.
-
- To make the discussion concrete, assume we're writing an application
-named `guide'. Internationalization consists of the following steps,
-in this order:
-
- 1. The programmer goes through the source for all of `guide''s
- components and marks each string that is a candidate for
- translation. For example, `"`-F': option required"' is a good
- candidate for translation. A table with strings of option names
- is not (e.g., `gawk''s `--profile' option should remain the same,
- no matter what the local language).
-
- 2. The programmer indicates the application's text domain (`"guide"')
- to the `gettext' library, by calling the `textdomain' function.
-
- 3. Messages from the application are extracted from the source code
- and collected into a portable object file (`guide.po'), which
- lists the strings and their translations. The translations are
- initially empty. The original (usually English) messages serve as
- the key for lookup of the translations.
-
- 4. For each language with a translator, `guide.po' is copied and
- translations are created and shipped with the application.
-
- 5. Each language's `.po' file is converted into a binary message
- object (`.mo') file. A message object file contains the original
- messages and their translations in a binary format that allows
- fast lookup of translations at runtime.
-
- 6. When `guide' is built and installed, the binary translation files
- are installed in a standard place.
-
- 7. For testing and development, it is possible to tell `gettext' to
- use `.mo' files in a different directory than the standard one by
- using the `bindtextdomain' function.
-
- 8. At runtime, `guide' looks up each string via a call to `gettext'.
- The returned string is the translated string if available, or the
- original string if not.
-
- 9. If necessary, it is possible to access messages from a different
- text domain than the one belonging to the application, without
- having to switch the application's default text domain back and
- forth.
-
- In C (or C++), the string marking and dynamic translation lookup are
-accomplished by wrapping each string in a call to `gettext':
-
- printf(gettext("Don't Panic!\n"));
-
- The tools that extract messages from source code pull out all
-strings enclosed in calls to `gettext'.
-
- The GNU `gettext' developers, recognizing that typing `gettext' over
-and over again is both painful and ugly to look at, use the macro `_'
-(an underscore) to make things easier:
-
- /* In the standard header file: */
- #define _(str) gettext(str)
-
- /* In the program text: */
- printf(_("Don't Panic!\n"));
-
-This reduces the typing overhead to just three extra characters per
-string and is considerably easier to read as well. There are locale
-"categories" for different types of locale-related information. The
-defined locale categories that `gettext' knows about are:
-
-`LC_MESSAGES'
- Text messages. This is the default category for `gettext'
- operations, but it is possible to supply a different one
- explicitly, if necessary. (It is almost never necessary to supply
- a different category.)
-
-`LC_COLLATE'
- Text-collation information; i.e., how different characters and/or
- groups of characters sort in a given language.
-
-`LC_CTYPE'
- Character-type information (alphabetic, digit, upper- or
- lowercase, and so on). This information is accessed via the POSIX
- character classes in regular expressions, such as `/[[:alnum:]]/'
- (*note Regexp Operators::).
-
-`LC_MONETARY'
- Monetary information, such as the currency symbol, and whether the
- symbol goes before or after a number.
-
-`LC_NUMERIC'
- Numeric information, such as which characters to use for the
- decimal point and the thousands separator.(2)
-
-`LC_RESPONSE'
- Response information, such as how "yes" and "no" appear in the
- local language, and possibly other information as well.
-
-`LC_TIME'
- Time- and date-related information, such as 12- or 24-hour clock,
- month printed before or after day in a date, local month
- abbreviations, and so on.
-
-`LC_ALL'
- All of the above. (Not too useful in the context of `gettext'.)
-
- ---------- Footnotes ----------
-
- (1) For some operating systems, the `gawk' port doesn't support GNU
-`gettext'. This applies most notably to the PC operating systems. As
-such, these features are not available if you are using one of those
-operating systems. Sorry.
-
- (2) Americans use a comma every three decimal places and a period
-for the decimal point, while many Europeans do exactly the opposite:
-`1,234.56' versus `1.234,56'.
-
-9.3 Internationalizing `awk' Programs
-=====================================
-
-`gawk' provides the following variables and functions for
-internationalization:
-
-`TEXTDOMAIN'
- This variable indicates the application's text domain. For
- compatibility with GNU `gettext', the default value is
- `"messages"'.
-
-`_"your message here"'
- String constants marked with a leading underscore are candidates
- for translation at runtime. String constants without a leading
- underscore are not translated.
-
-`dcgettext(STRING [, DOMAIN [, CATEGORY]])'
- This built-in function returns the translation of STRING in text
- domain DOMAIN for locale category CATEGORY. The default value for
- DOMAIN is the current value of `TEXTDOMAIN'. The default value
- for CATEGORY is `"LC_MESSAGES"'.
-
- If you supply a value for CATEGORY, it must be a string equal to
- one of the known locale categories described in *Note Explaining
- gettext::. You must also supply a text domain. Use `TEXTDOMAIN'
- if you want to use the current domain.
-
- *Caution:* The order of arguments to the `awk' version of the
- `dcgettext' function is purposely different from the order for the
- C version. The `awk' version's order was chosen to be simple and
- to allow for reasonable `awk'-style default arguments.
-
-`dcngettext(STRING1, STRING2, NUMBER [, DOMAIN [, CATEGORY]])'
- This built-in function returns the plural form used for NUMBER of
- the translation of STRING1 and STRING2 in text domain DOMAIN for
- locale category CATEGORY. STRING1 is the English singular variant
- of a message, and STRING2 the English plural variant of the same
- message. The default value for DOMAIN is the current value of
- `TEXTDOMAIN'. The default value for CATEGORY is `"LC_MESSAGES"'.
-
- The same remarks as for the `dcgettext' function apply.
-
-`bindtextdomain(DIRECTORY [, DOMAIN])'
- This built-in function allows you to specify the directory in which
- `gettext' looks for `.mo' files, in case they will not or cannot
- be placed in the standard locations (e.g., during testing). It
- returns the directory in which DOMAIN is "bound."
-
- The default DOMAIN is the value of `TEXTDOMAIN'. If DIRECTORY is
- the null string (`""'), then `bindtextdomain' returns the current
- binding for the given DOMAIN.
-
- To use these facilities in your `awk' program, follow the steps
-outlined in *Note Explaining gettext::, like so:
-
- 1. Set the variable `TEXTDOMAIN' to the text domain of your program.
- This is best done in a `BEGIN' rule (*note BEGIN/END::), or it can
- also be done via the `-v' command-line option (*note Options::):
-
- BEGIN {
- TEXTDOMAIN = "guide"
- ...
- }
-
- 2. Mark all translatable strings with a leading underscore (`_')
- character. It _must_ be adjacent to the opening quote of the
- string. For example:
-
- print _"hello, world"
- x = _"you goofed"
- printf(_"Number of users is %d\n", nusers)
-
- 3. If you are creating strings dynamically, you can still translate
- them, using the `dcgettext' built-in function:
-
- message = nusers " users logged in"
- message = dcgettext(message, "adminprog")
- print message
-
- Here, the call to `dcgettext' supplies a different text domain
- (`"adminprog"') in which to find the message, but it uses the
- default `"LC_MESSAGES"' category.
-
- 4. During development, you might want to put the `.mo' file in a
- private directory for testing. This is done with the
- `bindtextdomain' built-in function:
-
- BEGIN {
- TEXTDOMAIN = "guide" # our text domain
- if (Testing) {
- # where to find our files
- bindtextdomain("testdir")
- # joe is in charge of adminprog
- bindtextdomain("../joe/testdir", "adminprog")
- }
- ...
- }
-
-
- *Note I18N Example::, for an example program showing the steps to
-create and use translations from `awk'.
-
-9.4 Translating `awk' Programs
-==============================
-
-Once a program's translatable strings have been marked, they must be
-extracted to create the initial `.po' file. As part of translation, it
-is often helpful to rearrange the order in which arguments to `printf'
-are output.
-
- `gawk''s `--gen-po' command-line option extracts the messages and is
-discussed next. After that, `printf''s ability to rearrange the order
-for `printf' arguments at runtime is covered.
-
-9.4.1 Extracting Marked Strings
--------------------------------
-
-Once your `awk' program is working, and all the strings have been
-marked and you've set (and perhaps bound) the text domain, it is time
-to produce translations. First, use the `--gen-po' command-line option
-to create the initial `.po' file:
-
- $ gawk --gen-po -f guide.awk > guide.po
-
- When run with `--gen-po', `gawk' does not execute your program.
-Instead, it parses it as usual and prints all marked strings to
-standard output in the format of a GNU `gettext' Portable Object file.
-Also included in the output are any constant strings that appear as the
-first argument to `dcgettext' or as the first and second argument to
-`dcngettext'.(1) *Note I18N Example::, for the full list of steps to go
-through to create and test translations for `guide'.
-
- ---------- Footnotes ----------
-
- (1) Starting with `gettext' version 0.11.5, the `xgettext' utility
-that comes with GNU `gettext' can handle `.awk' files.
-
-9.4.2 Rearranging `printf' Arguments
-------------------------------------
-
-Format strings for `printf' and `sprintf' (*note Printf::) present a
-special problem for translation. Consider the following:(1)
-
- printf(_"String `%s' has %d characters\n",
- string, length(string)))
-
- A possible German translation for this might be:
-
- "%d Zeichen lang ist die Zeichenkette `%s'\n"
-
- The problem should be obvious: the order of the format
-specifications is different from the original! Even though `gettext'
-can return the translated string at runtime, it cannot change the
-argument order in the call to `printf'.
-
- To solve this problem, `printf' format specificiers may have an
-additional optional element, which we call a "positional specifier".
-For example:
-
- "%2$d Zeichen lang ist die Zeichenkette `%1$s'\n"
-
- Here, the positional specifier consists of an integer count, which
-indicates which argument to use, and a `$'. Counts are one-based, and
-the format string itself is _not_ included. Thus, in the following
-example, `string' is the first argument and `length(string)' is the
-second:
-
- $ gawk 'BEGIN {
- > string = "Dont Panic"
- > printf _"%2$d characters live in \"%1$s\"\n",
- > string, length(string)
- > }'
- -| 10 characters live in "Dont Panic"
-
- If present, positional specifiers come first in the format
-specification, before the flags, the field width, and/or the precision.
-
- Positional specifiers can be used with the dynamic field width and
-precision capability:
-
- $ gawk 'BEGIN {
- > printf("%*.*s\n", 10, 20, "hello")
- > printf("%3$*2$.*1$s\n", 20, 10, "hello")
- > }'
- -| hello
- -| hello
-
- NOTE: When using `*' with a positional specifier, the `*' comes
- first, then the integer position, and then the `$'. This is
- somewhat counterintutive.
-
- `gawk' does not allow you to mix regular format specifiers and those
-with positional specifiers in the same string:
-
- $ gawk 'BEGIN { printf _"%d %3$s\n", 1, 2, "hi" }'
- error--> gawk: cmd. line:1: fatal: must use `count$' on all formats or
none
-
- NOTE: There are some pathological cases that `gawk' may fail to
- diagnose. In such cases, the output may not be what you expect.
- It's still a bad idea to try mixing them, even if `gawk' doesn't
- detect it.
-
- Although positional specifiers can be used directly in `awk'
-programs, their primary purpose is to help in producing correct
-translations of format strings into languages different from the one in
-which the program is first written.
-
- ---------- Footnotes ----------
-
- (1) This example is borrowed from the GNU `gettext' manual.
-
-9.4.3 `awk' Portability Issues
-------------------------------
-
-`gawk''s internationalization features were purposely chosen to have as
-little impact as possible on the portability of `awk' programs that use
-them to other versions of `awk'. Consider this program:
-
- BEGIN {
- TEXTDOMAIN = "guide"
- if (Test_Guide) # set with -v
- bindtextdomain("/test/guide/messages")
- print _"don't panic!"
- }
-
-As written, it won't work on other versions of `awk'. However, it is
-actually almost portable, requiring very little change:
-
- * Assignments to `TEXTDOMAIN' won't have any effect, since
- `TEXTDOMAIN' is not special in other `awk' implementations.
-
- * Non-GNU versions of `awk' treat marked strings as the
- concatenation of a variable named `_' with the string following
- it.(1) Typically, the variable `_' has the null string (`""') as
- its value, leaving the original string constant as the result.
-
- * By defining "dummy" functions to replace `dcgettext', `dcngettext'
- and `bindtextdomain', the `awk' program can be made to run, but
- all the messages are output in the original language. For example:
-
- function bindtextdomain(dir, domain)
- {
- return dir
- }
-
- function dcgettext(string, domain, category)
- {
- return string
- }
-
- function dcngettext(string1, string2, number, domain, category)
- {
- return (number == 1 ? string1 : string2)
- }
-
- * The use of positional specifications in `printf' or `sprintf' is
- _not_ portable. To support `gettext' at the C level, many
- systems' C versions of `sprintf' do support positional specifiers.
- But it works only if enough arguments are supplied in the
- function call. Many versions of `awk' pass `printf' formats and
- arguments unchanged to the underlying C library version of
- `sprintf', but only one format and argument at a time. What
- happens if a positional specification is used is anybody's guess.
- However, since the positional specifications are primarily for use
- in _translated_ format strings, and since non-GNU `awk's never
- retrieve the translated string, this should not be a problem in
- practice.
-
- ---------- Footnotes ----------
-
- (1) This is good fodder for an "Obfuscated `awk'" contest.
-
-9.5 A Simple Internationalization Example
-=========================================
-
-Now let's look at a step-by-step example of how to internationalize and
-localize a simple `awk' program, using `guide.awk' as our original
-source:
-
- BEGIN {
- TEXTDOMAIN = "guide"
- bindtextdomain(".") # for testing
- print _"Don't Panic"
- print _"The Answer Is", 42
- print "Pardon me, Zaphod who?"
- }
-
-Run `gawk --gen-po' to create the `.po' file:
-
- $ gawk --gen-po -f guide.awk > guide.po
-
-This produces:
-
- #: guide.awk:4
- msgid "Don't Panic"
- msgstr ""
-
- #: guide.awk:5
- msgid "The Answer Is"
- msgstr ""
-
- This original portable object file is saved and reused for each
-language into which the application is translated. The `msgid' is the
-original string and the `msgstr' is the translation.
-
- NOTE: Strings not marked with a leading underscore do not appear
- in the `guide.po' file.
-
- Next, the messages must be translated. Here is a translation to a
-hypothetical dialect of English, called "Mellow":(1)
-
- $ cp guide.po guide-mellow.po
- ADD TRANSLATIONS TO guide-mellow.po ...
-
-Following are the translations:
-
- #: guide.awk:4
- msgid "Don't Panic"
- msgstr "Hey man, relax!"
-
- #: guide.awk:5
- msgid "The Answer Is"
- msgstr "Like, the scoop is"
-
- The next step is to make the directory to hold the binary message
-object file and then to create the `guide.mo' file. The directory
-layout shown here is standard for GNU `gettext' on GNU/Linux systems.
-Other versions of `gettext' may use a different layout:
-
- $ mkdir en_US en_US/LC_MESSAGES
-
- The `msgfmt' utility does the conversion from human-readable `.po'
-file to machine-readable `.mo' file. By default, `msgfmt' creates a
-file named `messages'. This file must be renamed and placed in the
-proper directory so that `gawk' can find it:
-
- $ msgfmt guide-mellow.po
- $ mv messages en_US/LC_MESSAGES/guide.mo
-
- Finally, we run the program to test it:
-
- $ gawk -f guide.awk
- -| Hey man, relax!
- -| Like, the scoop is 42
- -| Pardon me, Zaphod who?
-
- If the three replacement functions for `dcgettext', `dcngettext' and
-`bindtextdomain' (*note I18N Portability::) are in a file named
-`libintl.awk', then we can run `guide.awk' unchanged as follows:
-
- $ gawk --posix -f guide.awk -f libintl.awk
- -| Don't Panic
- -| The Answer Is 42
- -| Pardon me, Zaphod who?
-
- ---------- Footnotes ----------
-
- (1) Perhaps it would be better if it were called "Hippy." Ah, well.
-
-9.6 `gawk' Can Speak Your Language
-==================================
-
-As of version 3.1, `gawk' itself has been internationalized using the
-GNU `gettext' package. (GNU `gettext' is described in complete detail
-in *Note Top::.) As of this writing, the latest version of GNU
-`gettext' is version 0.11.5
-(ftp://ftp.gnu.org/gnu/gettext/gettext-0.11.5.tar.gz).
-
- If a translation of `gawk''s messages exists, then `gawk' produces
-usage messages, warnings, and fatal errors in the local language.
-
- On systems that do not use version 2 (or later) of the GNU C
-library, you should configure `gawk' with the `--with-included-gettext'
-option before compiling and installing it. *Note Additional
-Configuration Options::, for more information.
-
-10 Advanced Features of `gawk'
-******************************
-
- Write documentation as if whoever reads it is a violent psychopath
- who knows where you live.
- Steve English, as quoted by Peter Langston
-
- This major node discusses advanced features in `gawk'. It's a bit
-of a "grab bag" of items that are otherwise unrelated to each other.
-First, a command-line option allows `gawk' to recognize nondecimal
-numbers in input data, not just in `awk' programs. Next, two-way I/O,
-discussed briefly in earlier parts of this Info file, is described in
-full detail, along with the basics of TCP/IP networking and BSD portal
-files. Finally, `gawk' can "profile" an `awk' program, making it
-possible to tune it for performance.
-
- *Note Dynamic Extensions::, discusses the ability to dynamically add
-new built-in functions to `gawk'. As this feature is still immature
-and likely to change, its description is relegated to an appendix.
-
-10.1 Allowing Nondecimal Input Data
-===================================
-
-If you run `gawk' with the `--non-decimal-data' option, you can have
-nondecimal constants in your input data:
-
- $ echo 0123 123 0x123 |
- > gawk --non-decimal-data '{ printf "%d, %d, %d\n",
- > $1, $2, $3 }'
- -| 83, 123, 291
-
- For this feature to work, write your program so that `gawk' treats
-your data as numeric:
-
- $ echo 0123 123 0x123 | gawk '{ print $1, $2, $3 }'
- -| 0123 123 0x123
-
-The `print' statement treats its expressions as strings. Although the
-fields can act as numbers when necessary, they are still strings, so
-`print' does not try to treat them numerically. You may need to add
-zero to a field to force it to be treated as a number. For example:
-
- $ echo 0123 123 0x123 | gawk --non-decimal-data '
- > { print $1, $2, $3
- > print $1 + 0, $2 + 0, $3 + 0 }'
- -| 0123 123 0x123
- -| 83 123 291
-
- Because it is common to have decimal data with leading zeros, and
-because using it could lead to surprising results, the default is to
-leave this facility disabled. If you want it, you must explicitly
-request it.
-
- *Caution:* _Use of this option is not recommended._ It can break old
-programs very badly. Instead, use the `strtonum' function to convert
-your data (*note Nondecimal-numbers::). This makes your programs
-easier to write and easier to read, and leads to less surprising
-results.
-
-10.2 Two-Way Communications with Another Process
-================================================
-
- From: address@hidden (Mike Brennan)
- Newsgroups: comp.lang.awk
- Subject: Re: Learn the SECRET to Attract Women Easily
- Date: 4 Aug 1997 17:34:46 GMT
- Message-ID: <address@hidden>
-
- On 3 Aug 1997 13:17:43 GMT, Want More Dates???
- <address@hidden> wrote:
- >Learn the SECRET to Attract Women Easily
- >
- >The SCENT(tm) Pheromone Sex Attractant For Men to Attract Women
-
- The scent of awk programmers is a lot more attractive to women than
- the scent of perl programmers.
- --
- Mike Brennan
-
- It is often useful to be able to send data to a separate program for
-processing and then read the result. This can always be done with
-temporary files:
-
- # write the data for processing
- tempfile = ("mydata." PROCINFO["pid"])
- while (NOT DONE WITH DATA)
- print DATA | ("subprogram > " tempfile)
- close("subprogram > " tempfile)
-
- # read the results, remove tempfile when done
- while ((getline newdata < tempfile) > 0)
- PROCESS newdata APPROPRIATELY
- close(tempfile)
- system("rm " tempfile)
-
-This works, but not elegantly. Among other things, it requires that
-the program be run in a directory that cannot be shared among users;
-for example, `/tmp' will not do, as another user might happen to be
-using a temporary file with the same name.
-
- Starting with version 3.1 of `gawk', it is possible to open a
-_two-way_ pipe to another process. The second process is termed a
-"coprocess", since it runs in parallel with `gawk'. The two-way
-connection is created using the new `|&' operator (borrowed from the
-Korn shell, `ksh'):(1)
-
- do {
- print DATA |& "subprogram"
- "subprogram" |& getline results
- } while (DATA LEFT TO PROCESS)
- close("subprogram")
-
- The first time an I/O operation is executed using the `|&' operator,
-`gawk' creates a two-way pipeline to a child process that runs the
-other program. Output created with `print' or `printf' is written to
-the program's standard input, and output from the program's standard
-output can be read by the `gawk' program using `getline'. As is the
-case with processes started by `|', the subprogram can be any program,
-or pipeline of programs, that can be started by the shell.
-
- There are some cautionary items to be aware of:
-
- * As the code inside `gawk' currently stands, the coprocess's
- standard error goes to the same place that the parent `gawk''s
- standard error goes. It is not possible to read the child's
- standard error separately.
-
- * I/O buffering may be a problem. `gawk' automatically flushes all
- output down the pipe to the child process. However, if the
- coprocess does not flush its output, `gawk' may hang when doing a
- `getline' in order to read the coprocess's results. This could
- lead to a situation known as "deadlock", where each process is
- waiting for the other one to do something.
-
- It is possible to close just one end of the two-way pipe to a
-coprocess, by supplying a second argument to the `close' function of
-either `"to"' or `"from"' (*note Close Files And Pipes::). These
-strings tell `gawk' to close the end of the pipe that sends data to the
-process or the end that reads from it, respectively.
-
- This is particularly necessary in order to use the system `sort'
-utility as part of a coprocess; `sort' must read _all_ of its input
-data before it can produce any output. The `sort' program does not
-receive an end-of-file indication until `gawk' closes the write end of
-the pipe.
-
- When you have finished writing data to the `sort' utility, you can
-close the `"to"' end of the pipe, and then start reading sorted data
-via `getline'. For example:
-
- BEGIN {
- command = "LC_ALL=C sort"
- n = split("abcdefghijklmnopqrstuvwxyz", a, "")
-
- for (i = n; i > 0; i--)
- print a[i] |& command
- close(command, "to")
-
- while ((command |& getline line) > 0)
- print "got", line
- close(command)
- }
-
- This program writes the letters of the alphabet in reverse order, one
-per line, down the two-way pipe to `sort'. It then closes the write
-end of the pipe, so that `sort' receives an end-of-file indication.
-This causes `sort' to sort the data and write the sorted data back to
-the `gawk' program. Once all of the data has been read, `gawk'
-terminates the coprocess and exits.
-
- As a side note, the assignment `LC_ALL=C' in the `sort' command
-ensures traditional Unix (ASCII) sorting from `sort'.
-
- Beginning with `gawk' 3.1.2, you may use Pseudo-ttys (ptys) for
-two-way communication instead of pipes, if your system supports them.
-This is done on a per-command basis, by setting a special element in
-the `PROCINFO' array (*note Auto-set::), like so:
-
- command = "sort -nr" # command, saved in variable for
convenience
- PROCINFO[command, "pty"] = 1 # update PROCINFO
- print ... |& command # start two-way pipe
- ...
-
-Using ptys avoids the buffer deadlock issues described earlier, at some
-loss in performance. If your system does not have ptys, or if all the
-system's ptys are in use, `gawk' automatically falls back to using
-regular pipes.
-
- ---------- Footnotes ----------
-
- (1) This is very different from the same operator in the C shell,
-`csh'.
-
-10.3 Using `gawk' for Network Programming
-=========================================
-
- `EMISTERED': A host is a host from coast to coast,
- and no-one can talk to host that's close,
- unless the host that isn't close
- is busy hung or dead.
-
- In addition to being able to open a two-way pipeline to a coprocess
-on the same system (*note Two-way I/O::), it is possible to make a
-two-way connection to another process on another system across an IP
-networking connection.
-
- You can think of this as just a _very long_ two-way pipeline to a
-coprocess. The way `gawk' decides that you want to use TCP/IP
-networking is by recognizing special file names that begin with
-`/inet/'.
-
- The full syntax of the special file name is
-`/inet/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT'. The components
-are:
-
-PROTOCOL
- The protocol to use over IP. This must be either `tcp', `udp', or
- `raw', for a TCP, UDP, or raw IP connection, respectively. The
- use of TCP is recommended for most applications.
-
- *Caution:* The use of raw sockets is not currently supported in
- version 3.1 of `gawk'.
-
-LOCAL-PORT
- The local TCP or UDP port number to use. Use a port number of `0'
- when you want the system to pick a port. This is what you should do
- when writing a TCP or UDP client. You may also use a well-known
- service name, such as `smtp' or `http', in which case `gawk'
- attempts to determine the predefined port number using the C
- `getservbyname' function.
-
-REMOTE-HOST
- The IP address or fully-qualified domain name of the Internet host
- to which you want to connect.
-
-REMOTE-PORT
- The TCP or UDP port number to use on the given REMOTE-HOST.
- Again, use `0' if you don't care, or else a well-known service
- name.
-
- Consider the following very simple example:
-
- BEGIN {
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
- }
-
- This program reads the current date and time from the local system's
-TCP `daytime' server. It then prints the results and closes the
-connection.
-
- Because this topic is extensive, the use of `gawk' for TCP/IP
-programming is documented separately. *Note Top::, for a much more
-complete introduction and discussion, as well as extensive examples.
-
-10.4 Using `gawk' with BSD Portals
-==================================
-
-Similar to the `/inet' special files, if `gawk' is configured with the
-`--enable-portals' option (*note Quick Installation::), then `gawk'
-treats files whose pathnames begin with `/p' as 4.4 BSD-style portals.
-
- When used with the `|&' operator, `gawk' opens the file for two-way
-communications. The operating system's portal mechanism then manages
-creating the process associated with the portal and the corresponding
-communications with the portal's process.
-
-10.5 Profiling Your `awk' Programs
-==================================
-
-Beginning with version 3.1 of `gawk', you may produce execution traces
-of your `awk' programs. This is done with a specially compiled version
-of `gawk', called `pgawk' ("profiling `gawk'").
-
- `pgawk' is identical in every way to `gawk', except that when it has
-finished running, it creates a profile of your program in a file named
-`awkprof.out'. Because it is profiling, it also executes up to 45%
-slower than `gawk' normally does.
-
- As shown in the following example, the `--profile' option can be
-used to change the name of the file where `pgawk' will write the
-profile:
-
- $ pgawk --profile=myprog.prof -f myprog.awk data1 data2
-
-In the above example, `pgawk' places the profile in `myprog.prof'
-instead of in `awkprof.out'.
-
- Regular `gawk' also accepts this option. When called with just
-`--profile', `gawk' "pretty prints" the program into `awkprof.out',
-without any execution counts. You may supply an option to `--profile'
-to change the file name. Here is a sample session showing a simple
-`awk' program, its input data, and the results from running `pgawk'.
-First, the `awk' program:
-
- BEGIN { print "First BEGIN rule" }
-
- END { print "First END rule" }
-
- /foo/ {
- print "matched /foo/, gosh"
- for (i = 1; i <= 3; i++)
- sing()
- }
-
- {
- if (/foo/)
- print "if is true"
- else
- print "else is true"
- }
-
- BEGIN { print "Second BEGIN rule" }
-
- END { print "Second END rule" }
-
- function sing( dummy)
- {
- print "I gotta be me!"
- }
-
- Following is the input data:
-
- foo
- bar
- baz
- foo
- junk
-
- Here is the `awkprof.out' that results from running `pgawk' on this
-program and data (this example also illustrates that `awk' programmers
-sometimes have to work late):
-
- # gawk profile, created Sun Aug 13 00:00:15 2000
-
- # BEGIN block(s)
-
- BEGIN {
- 1 print "First BEGIN rule"
- 1 print "Second BEGIN rule"
- }
-
- # Rule(s)
-
- 5 /foo/ { # 2
- 2 print "matched /foo/, gosh"
- 6 for (i = 1; i <= 3; i++) {
- 6 sing()
- }
- }
-
- 5 {
- 5 if (/foo/) { # 2
- 2 print "if is true"
- 3 } else {
- 3 print "else is true"
- }
- }
-
- # END block(s)
-
- END {
- 1 print "First END rule"
- 1 print "Second END rule"
- }
-
- # Functions, listed alphabetically
-
- 6 function sing(dummy)
- {
- 6 print "I gotta be me!"
- }
-
- This example illustrates many of the basic rules for profiling
-output. The rules are as follows:
-
- * The program is printed in the order `BEGIN' rule, pattern/action
- rules, `END' rule and functions, listed alphabetically. Multiple
- `BEGIN' and `END' rules are merged together.
-
- * Pattern-action rules have two counts. The first count, to the
- left of the rule, shows how many times the rule's pattern was
- _tested_. The second count, to the right of the rule's opening
- left brace in a comment, shows how many times the rule's action
- was _executed_. The difference between the two indicates how many
- times the rule's pattern evaluated to false.
-
- * Similarly, the count for an `if'-`else' statement shows how many
- times the condition was tested. To the right of the opening left
- brace for the `if''s body is a count showing how many times the
- condition was true. The count for the `else' indicates how many
- times the test failed.
-
- * The count for a loop header (such as `for' or `while') shows how
- many times the loop test was executed. (Because of this, you
- can't just look at the count on the first statement in a rule to
- determine how many times the rule was executed. If the first
- statement is a loop, the count is misleading.)
-
- * For user-defined functions, the count next to the `function'
- keyword indicates how many times the function was called. The
- counts next to the statements in the body show how many times
- those statements were executed.
-
- * The layout uses "K&R" style with tabs. Braces are used
- everywhere, even when the body of an `if', `else', or loop is only
- a single statement.
-
- * Parentheses are used only where needed, as indicated by the
- structure of the program and the precedence rules. For example,
- `(3 + 5) * 4' means add three plus five, then multiply the total
- by four. However, `3 + 5 * 4' has no parentheses, and means `3 +
- (5 * 4)'.
-
- * All string concatenations are parenthesized too. (This could be
- made a bit smarter.)
-
- * Parentheses are used around the arguments to `print' and `printf'
- only when the `print' or `printf' statement is followed by a
- redirection. Similarly, if the target of a redirection isn't a
- scalar, it gets parenthesized.
-
- * `pgawk' supplies leading comments in front of the `BEGIN' and
- `END' rules, the pattern/action rules, and the functions.
-
-
- The profiled version of your program may not look exactly like what
-you typed when you wrote it. This is because `pgawk' creates the
-profiled version by "pretty printing" its internal representation of
-the program. The advantage to this is that `pgawk' can produce a
-standard representation. The disadvantage is that all source-code
-comments are lost, as are the distinctions among multiple `BEGIN' and
-`END' rules. Also, things such as:
-
- /foo/
-
-come out as:
-
- /foo/ {
- print $0
- }
-
-which is correct, but possibly surprising.
-
- Besides creating profiles when a program has completed, `pgawk' can
-produce a profile while it is running. This is useful if your `awk'
-program goes into an infinite loop and you want to see what has been
-executed. To use this feature, run `pgawk' in the background:
-
- $ pgawk -f myprog &
- [1] 13992
-
-The shell prints a job number and process ID number; in this case,
-13992. Use the `kill' command to send the `USR1' signal to `pgawk':
-
- $ kill -USR1 13992
-
-As usual, the profiled version of the program is written to
-`awkprof.out', or to a different file if you use the `--profile' option.
-
- Along with the regular profile, as shown earlier, the profile
-includes a trace of any active functions:
-
- # Function Call Stack:
-
- # 3. baz
- # 2. bar
- # 1. foo
- # -- main --
-
- You may send `pgawk' the `USR1' signal as many times as you like.
-Each time, the profile and function call trace are appended to the
-output profile file.
-
- If you use the `HUP' signal instead of the `USR1' signal, `pgawk'
-produces the profile and the function call trace and then exits.
-
- When `pgawk' runs on MS-DOS or MS-Windows, it uses the `INT' and
-`QUIT' signals for producing the profile and, in the case of the `INT'
-signal, `pgawk' exits. This is because these systems don't support the
-`kill' command, so the only signals you can deliver to a program are
-those generated by the keyboard. The `INT' signal is generated by the
-`Ctrl-<C>' or `Ctrl-<BREAK>' key, while the `QUIT' signal is generated
-by the `Ctrl-<\>' key.
-
-11 Running `awk' and `gawk'
-***************************
-
-This major node covers how to run awk, both POSIX-standard and
-`gawk'-specific command-line options, and what `awk' and `gawk' do with
-non-option arguments. It then proceeds to cover how `gawk' searches
-for source files, obsolete options and/or features, and known bugs in
-`gawk'. This major node rounds out the discussion of `awk' as a
-program and as a language.
-
- While a number of the options and features described here were
-discussed in passing earlier in the book, this major node provides the
-full details.
-
-11.1 Invoking `awk'
-===================
-
-There are two ways to run `awk'--with an explicit program or with one
-or more program files. Here are templates for both of them; items
-enclosed in [...] in these templates are optional:
-
- awk [OPTIONS] -f progfile [`--'] FILE ...
- awk [OPTIONS] [`--'] 'PROGRAM' FILE ...
-
- Besides traditional one-letter POSIX-style options, `gawk' also
-supports GNU long options.
-
- It is possible to invoke `awk' with an empty program:
-
- awk '' datafile1 datafile2
-
-Doing so makes little sense, though; `awk' exits silently when given an
-empty program. (d.c.) If `--lint' has been specified on the command
-line, `gawk' issues a warning that the program is empty.
-
-11.2 Command-Line Options
-=========================
-
-Options begin with a dash and consist of a single character. GNU-style
-long options consist of two dashes and a keyword. The keyword can be
-abbreviated, as long as the abbreviation allows the option to be
-uniquely identified. If the option takes an argument, then the keyword
-is either immediately followed by an equals sign (`=') and the
-argument's value, or the keyword and the argument's value are separated
-by whitespace. If a particular option with a value is given more than
-once, it is the last value that counts.
-
- Each long option for `gawk' has a corresponding POSIX-style option.
-The long and short options are interchangeable in all contexts. The
-options and their meanings are as follows:
-
-`-F FS'
-`--field-separator FS'
- Sets the `FS' variable to FS (*note Field Separators::).
-
-`-f SOURCE-FILE'
-`--file SOURCE-FILE'
- Indicates that the `awk' program is to be found in SOURCE-FILE
- instead of in the first non-option argument.
-
-`-v VAR=VAL'
-`--assign VAR=VAL'
- Sets the variable VAR to the value VAL _before_ execution of the
- program begins. Such variable values are available inside the
- `BEGIN' rule (*note Other Arguments::).
-
- The `-v' option can only set one variable, but it can be used more
- than once, setting another variable each time, like this: `awk
- -v foo=1 -v bar=2 ...'.
-
- *Caution:* Using `-v' to set the values of the built-in variables
- may lead to surprising results. `awk' will reset the values of
- those variables as it needs to, possibly ignoring any predefined
- value you may have given.
-
-`-mf N'
-`-mr N'
- Sets various memory limits to the value N. The `f' flag sets the
- maximum number of fields and the `r' flag sets the maximum record
- size. These two flags and the `-m' option are from the Bell
- Laboratories research version of Unix `awk'. They are provided
- for compatibility but otherwise ignored by `gawk', since `gawk'
- has no predefined limits. (The Bell Laboratories `awk' no longer
- needs these options; it continues to accept them to avoid breaking
- old programs.)
-
-`-W GAWK-OPT'
- Following the POSIX standard, implementation-specific options are
- supplied as arguments to the `-W' option. These options also have
- corresponding GNU-style long options. Note that the long options
- may be abbreviated, as long as the abbreviations remain unique.
- The full list of `gawk'-specific options is provided next.
-
-`--'
- Signals the end of the command-line options. The following
- arguments are not treated as options even if they begin with `-'.
- This interpretation of `--' follows the POSIX argument parsing
- conventions.
-
- This is useful if you have file names that start with `-', or in
- shell scripts, if you have file names that will be specified by
- the user that could start with `-'.
-
- The previous list described options mandated by the POSIX standard,
-as well as options available in the Bell Laboratories version of `awk'.
-The following list describes `gawk'-specific options:
-
-`-W compat'
-`-W traditional'
-`--compat'
-`--traditional'
- Specifies "compatibility mode", in which the GNU extensions to the
- `awk' language are disabled, so that `gawk' behaves just like the
- Bell Laboratories research version of Unix `awk'. `--traditional'
- is the preferred form of this option. *Note POSIX/GNU::, which
- summarizes the extensions. Also see *Note Compatibility Mode::.
-
-`-W copyright'
-`--copyright'
- Print the short version of the General Public License and then
- exit.
-
-`-W copyleft'
-`--copyleft'
- Just like `--copyright'. This option may disappear in a future
- version of `gawk'.
-
-`-W dump-variables[=FILE]'
-`--dump-variables[=FILE]'
- Prints a sorted list of global variables, their types, and final
- values to FILE. If no FILE is provided, `gawk' prints this list
- to the file named `awkvars.out' in the current directory.
-
- Having a list of all global variables is a good way to look for
- typographical errors in your programs. You would also use this
- option if you have a large program with a lot of functions, and
- you want to be sure that your functions don't inadvertently use
- global variables that you meant to be local. (This is a
- particularly easy mistake to make with simple variable names like
- `i', `j', etc.)
-
-`-W gen-po'
-`--gen-po'
- Analyzes the source program and generates a GNU `gettext' Portable
- Object file on standard output for all string constants that have
- been marked for translation. *Note Internationalization::, for
- information about this option.
-
-`-W help'
-`-W usage'
-`--help'
-`--usage'
- Prints a "usage" message summarizing the short and long style
- options that `gawk' accepts and then exit.
-
-`-W lint[=fatal]'
-`--lint[=fatal]'
- Warns about constructs that are dubious or nonportable to other
- `awk' implementations. Some warnings are issued when `gawk' first
- reads your program. Others are issued at runtime, as your program
- executes. With an optional argument of `fatal', lint warnings
- become fatal errors. This may be drastic, but its use will
- certainly encourage the development of cleaner `awk' programs.
- With an optional argument of `invalid', only warnings about things
- that are actually invalid are issued. (This is not fully
- implemented yet.)
-
-`-W lint-old'
-`--lint-old'
- Warns about constructs that are not available in the original
- version of `awk' from Version 7 Unix (*note V7/SVR3.1::).
-
-`-W non-decimal-data'
-`--non-decimal-data'
- Enable automatic interpretation of octal and hexadecimal values in
- input data (*note Nondecimal Data::).
-
- *Caution:* This option can severely break old programs. Use with
- care.
-
-`-W posix'
-`--posix'
- Operates in strict POSIX mode. This disables all `gawk'
- extensions (just like `--traditional') and adds the following
- additional restrictions:
-
- * `\x' escape sequences are not recognized (*note Escape
- Sequences::).
-
- * Newlines do not act as whitespace to separate fields when
- `FS' is equal to a single space (*note Fields::).
-
- * Newlines are not allowed after `?' or `:' (*note Conditional
- Exp::).
-
- * The synonym `func' for the keyword `function' is not
- recognized (*note Definition Syntax::).
-
- * The `**' and `**=' operators cannot be used in place of `^'
- and `^=' (*note Arithmetic Ops::, and also *note Assignment
- Ops::).
-
- * Specifying `-Ft' on the command-line does not set the value
- of `FS' to be a single TAB character (*note Field
- Separators::).
-
- * The `fflush' built-in function is not supported (*note I/O
- Functions::).
-
- If you supply both `--traditional' and `--posix' on the command
- line, `--posix' takes precedence. `gawk' also issues a warning if
- both options are supplied.
-
-`-W profile[=FILE]'
-`--profile[=FILE]'
- Enable profiling of `awk' programs (*note Profiling::). By
- default, profiles are created in a file named `awkprof.out'. The
- optional FILE argument allows you to specify a different file name
- for the profile file.
-
- When run with `gawk', the profile is just a "pretty printed"
- version of the program. When run with `pgawk', the profile
- contains execution counts for each statement in the program in the
- left margin, and function call counts for each function.
-
-`-W re-interval'
-`--re-interval'
- Allows interval expressions (*note Regexp Operators::) in regexps.
- Because interval expressions were traditionally not available in
- `awk', `gawk' does not provide them by default. This prevents old
- `awk' programs from breaking.
-
-`-W source PROGRAM-TEXT'
-`--source PROGRAM-TEXT'
- Allows you to mix source code in files with source code that you
- enter on the command line. Program source code is taken from the
- PROGRAM-TEXT. This is particularly useful when you have library
- functions that you want to use from your command-line programs
- (*note AWKPATH Variable::).
-
-`-W version'
-`--version'
- Prints version information for this particular copy of `gawk'.
- This allows you to determine if your copy of `gawk' is up to date
- with respect to whatever the Free Software Foundation is currently
- distributing. It is also useful for bug reports (*note Bugs::).
-
- As long as program text has been supplied, any other options are
-flagged as invalid with a warning message but are otherwise ignored.
-
- In compatibility mode, as a special case, if the value of FS supplied
-to the `-F' option is `t', then `FS' is set to the TAB character
-(`"\t"'). This is true only for `--traditional' and not for `--posix'
-(*note Field Separators::).
-
- The `-f' option may be used more than once on the command line. If
-it is, `awk' reads its program source from all of the named files, as
-if they had been concatenated together into one big file. This is
-useful for creating libraries of `awk' functions. These functions can
-be written once and then retrieved from a standard place, instead of
-having to be included into each individual program. (As mentioned in
-*Note Definition Syntax::, function names must be unique.)
-
- Library functions can still be used, even if the program is entered
-at the terminal, by specifying `-f /dev/tty'. After typing your
-program, type `Ctrl-d' (the end-of-file character) to terminate it.
-(You may also use `-f -' to read program source from the standard input
-but then you will not be able to also use the standard input as a
-source of data.)
-
- Because it is clumsy using the standard `awk' mechanisms to mix
-source file and command-line `awk' programs, `gawk' provides the
-`--source' option. This does not require you to pre-empt the standard
-input for your source code; it allows you to easily mix command-line
-and library source code (*note AWKPATH Variable::).
-
- If no `-f' or `--source' option is specified, then `gawk' uses the
-first non-option command-line argument as the text of the program
-source code.
-
- If the environment variable `POSIXLY_CORRECT' exists, then `gawk'
-behaves in strict POSIX mode, exactly as if you had supplied the
-`--posix' command-line option. Many GNU programs look for this
-environment variable to turn on strict POSIX mode. If `--lint' is
-supplied on the command line and `gawk' turns on POSIX mode because of
-`POSIXLY_CORRECT', then it issues a warning message indicating that
-POSIX mode is in effect. You would typically set this variable in your
-shell's startup file. For a Bourne-compatible shell (such as `bash'),
-you would add these lines to the `.profile' file in your home directory:
-
- POSIXLY_CORRECT=true
- export POSIXLY_CORRECT
-
- For a `csh'-compatible shell,(1) you would add this line to the
-`.login' file in your home directory:
-
- setenv POSIXLY_CORRECT true
-
- Having `POSIXLY_CORRECT' set is not recommended for daily use, but
-it is good for testing the portability of your programs to other
-environments.
-
- ---------- Footnotes ----------
-
- (1) Not recommended.
-
-11.3 Other Command-Line Arguments
-=================================
-
-Any additional arguments on the command line are normally treated as
-input files to be processed in the order specified. However, an
-argument that has the form `VAR=VALUE', assigns the value VALUE to the
-variable VAR--it does not specify a file at all. (This was discussed
-earlier in *Note Assignment Options::.)
-
- All these arguments are made available to your `awk' program in the
-`ARGV' array (*note Built-in Variables::). Command-line options and
-the program text (if present) are omitted from `ARGV'. All other
-arguments, including variable assignments, are included. As each
-element of `ARGV' is processed, `gawk' sets the variable `ARGIND' to
-the index in `ARGV' of the current element.
-
- The distinction between file name arguments and variable-assignment
-arguments is made when `awk' is about to open the next input file. At
-that point in execution, it checks the file name to see whether it is
-really a variable assignment; if so, `awk' sets the variable instead of
-reading a file.
-
- Therefore, the variables actually receive the given values after all
-previously specified files have been read. In particular, the values of
-variables assigned in this fashion are _not_ available inside a `BEGIN'
-rule (*note BEGIN/END::), because such rules are run before `awk'
-begins scanning the argument list.
-
- The variable values given on the command line are processed for
-escape sequences (*note Escape Sequences::). (d.c.)
-
- In some earlier implementations of `awk', when a variable assignment
-occurred before any file names, the assignment would happen _before_
-the `BEGIN' rule was executed. `awk''s behavior was thus inconsistent;
-some command-line assignments were available inside the `BEGIN' rule,
-while others were not. Unfortunately, some applications came to depend
-upon this "feature." When `awk' was changed to be more consistent, the
-`-v' option was added to accommodate applications that depended upon
-the old behavior.
-
- The variable assignment feature is most useful for assigning to
-variables such as `RS', `OFS', and `ORS', which control input and
-output formats before scanning the data files. It is also useful for
-controlling state if multiple passes are needed over a data file. For
-example:
-
- awk 'pass == 1 { PASS 1 STUFF }
- pass == 2 { PASS 2 STUFF }' pass=1 mydata pass=2 mydata
-
- Given the variable assignment feature, the `-F' option for setting
-the value of `FS' is not strictly necessary. It remains for historical
-compatibility.
-
-11.4 The `AWKPATH' Environment Variable
-=======================================
-
-The previous minor node described how `awk' program files can be named
-on the command-line with the `-f' option. In most `awk'
-implementations, you must supply a precise path name for each program
-file, unless the file is in the current directory. But in `gawk', if
-the file name supplied to the `-f' option does not contain a `/', then
-`gawk' searches a list of directories (called the "search path"), one
-by one, looking for a file with the specified name.
-
-The search path is a string consisting of directory names separated by
-colons. `gawk' gets its search path from the `AWKPATH' environment
-variable. If that variable does not exist, `gawk' uses a default path,
-`.:/usr/local/share/awk'.(1) (Programs written for use by system
-administrators should use an `AWKPATH' variable that does not include
-the current directory, `.'.)
-
- The search path feature is particularly useful for building libraries
-of useful `awk' functions. The library files can be placed in a
-standard directory in the default path and then specified on the
-command line with a short file name. Otherwise, the full file name
-would have to be typed for each file.
-
- By using both the `--source' and `-f' options, your command-line
-`awk' programs can use facilities in `awk' library files (*note Library
-Functions::). Path searching is not done if `gawk' is in compatibility
-mode. This is true for both `--traditional' and `--posix'. *Note
-Options::.
-
- NOTE: If you want files in the current directory to be found, you
- must include the current directory in the path, either by including
- `.' explicitly in the path or by writing a null entry in the path.
- (A null entry is indicated by starting or ending the path with a
- colon or by placing two colons next to each other (`::').) If the
- current directory is not included in the path, then files cannot be
- found in the current directory. This path search mechanism is
- identical to the shell's.
-
- Starting with version 3.0, if `AWKPATH' is not defined in the
-environment, `gawk' places its default search path into
-`ENVIRON["AWKPATH"]'. This makes it easy to determine the actual search
-path that `gawk' will use from within an `awk' program.
-
- While you can change `ENVIRON["AWKPATH"]' within your `awk' program,
-this has no effect on the running program's behavior. This makes
-sense: the `AWKPATH' environment variable is used to find the program
-source files. Once your program is running, all the files have been
-found, and `gawk' no longer needs to use `AWKPATH'.
-
- ---------- Footnotes ----------
-
- (1) Your version of `gawk' may use a different directory; it will
-depend upon how `gawk' was built and installed. The actual directory is
-the value of `$(datadir)' generated when `gawk' was configured. You
-probably don't need to worry about this, though.
-
-11.5 Obsolete Options and/or Features
-=====================================
-
-This minor node describes features and/or command-line options from
-previous releases of `gawk' that are either not available in the
-current version or that are still supported but deprecated (meaning that
-they will _not_ be in the next release).
-
- For version 3.1 of `gawk', there are no deprecated command-line
-options from the previous version of `gawk'. The use of `next file'
-(two words) for `nextfile' was deprecated in `gawk' 3.0 but still
-worked. Starting with version 3.1, the two-word usage is no longer
-accepted.
-
- The process-related special files described in *Note Special
-Process::, work as described, but are now considered deprecated.
-`gawk' prints a warning message every time they are used. (Use
-`PROCINFO' instead; see *Note Auto-set::.) They will be removed from
-the next release of `gawk'.
-
-11.6 Undocumented Options and Features
-======================================
-
- Use the Source, Luke!
- Obi-Wan
-
- This minor node intentionally left blank.
-
-11.7 Known Bugs in `gawk'
-=========================
-
- * The `-F' option for changing the value of `FS' (*note Options::)
- is not necessary given the command-line variable assignment
- feature; it remains only for backward compatibility.
-
- * Syntactically invalid single-character programs tend to overflow
- the parse stack, generating a rather unhelpful message. Such
- programs are surprisingly difficult to diagnose in the completely
- general case, and the effort to do so really is not worth it.
-
-12 A Library of `awk' Functions
-*******************************
-
-*Note User-defined::, describes how to write your own `awk' functions.
-Writing functions is important, because it allows you to encapsulate
-algorithms and program tasks in a single place. It simplifies
-programming, making program development more manageable, and making
-programs more readable.
-
- One valuable way to learn a new programming language is to _read_
-programs in that language. To that end, this major node and *Note
-Sample Programs::, provide a good-sized body of code for you to read,
-and hopefully, to learn from.
-
- This major node presents a library of useful `awk' functions. Many
-of the sample programs presented later in this Info file use these
-functions. The functions are presented here in a progression from
-simple to complex.
-
- *Note Extract Program::, presents a program that you can use to
-extract the source code for these example library functions and
-programs from the Texinfo source for this Info file. (This has already
-been done as part of the `gawk' distribution.)
-
- If you have written one or more useful, general-purpose `awk'
-functions and would like to contribute them to the author's collection
-of `awk' programs, see *Note How To Contribute::, for more information.
-
- The programs in this major node and in *Note Sample Programs::,
-freely use features that are `gawk'-specific. Rewriting these programs
-for different implementations of awk is pretty straightforward.
-
- Diagnostic error messages are sent to `/dev/stderr'. Use `| "cat
-1>&2"' instead of `> "/dev/stderr"' if your system does not have a
-`/dev/stderr', or if you cannot use `gawk'.
-
- A number of programs use `nextfile' (*note Nextfile Statement::) to
-skip any remaining input in the input file. *Note Nextfile Function::,
-shows you how to write a function that does the same thing.
-
- Finally, some of the programs choose to ignore upper- and lowercase
-distinctions in their input. They do so by assigning one to
-`IGNORECASE'. You can achieve almost the same effect(1) by adding the
-following rule to the beginning of the program:
-
- # ignore case
- { $0 = tolower($0) }
-
-Also, verify that all regexp and string constants used in comparisons
-use only lowercase letters.
-
- ---------- Footnotes ----------
-
- (1) The effects are not identical. Output of the transformed record
-will be in all lowercase, while `IGNORECASE' preserves the original
-contents of the input record.
-
-12.1 Naming Library Function Global Variables
-=============================================
-
-Due to the way the `awk' language evolved, variables are either
-"global" (usable by the entire program) or "local" (usable just by a
-specific function). There is no intermediate state analogous to
-`static' variables in C.
-
- Library functions often need to have global variables that they can
-use to preserve state information between calls to the function--for
-example, `getopt''s variable `_opti' (*note Getopt Function::). Such
-variables are called "private", since the only functions that need to
-use them are the ones in the library.
-
- When writing a library function, you should try to choose names for
-your private variables that will not conflict with any variables used by
-either another library function or a user's main program. For example,
-a name like `i' or `j' is not a good choice, because user programs
-often use variable names like these for their own purposes.
-
- The example programs shown in this major node all start the names of
-their private variables with an underscore (`_'). Users generally
-don't use leading underscores in their variable names, so this
-convention immediately decreases the chances that the variable name
-will be accidentally shared with the user's program.
-
- In addition, several of the library functions use a prefix that helps
-indicate what function or set of functions use the variables--for
-example, `_pw_byname' in the user database routines (*note Passwd
-Functions::). This convention is recommended, since it even further
-decreases the chance of inadvertent conflict among variable names.
-Note that this convention is used equally well for variable names and
-for private function names as well.(1)
-
- As a final note on variable naming, if a function makes global
-variables available for use by a main program, it is a good convention
-to start that variable's name with a capital letter--for example,
-`getopt''s `Opterr' and `Optind' variables (*note Getopt Function::).
-The leading capital letter indicates that it is global, while the fact
-that the variable name is not all capital letters indicates that the
-variable is not one of `awk''s built-in variables, such as `FS'.
-
- It is also important that _all_ variables in library functions that
-do not need to save state are, in fact, declared local.(2) If this is
-not done, the variable could accidentally be used in the user's
-program, leading to bugs that are very difficult to track down:
-
- function lib_func(x, y, l1, l2)
- {
- ...
- USE VARIABLE some_var # some_var should be local
- ... # but is not by oversight
- }
-
- A different convention, common in the Tcl community, is to use a
-single associative array to hold the values needed by the library
-function(s), or "package." This significantly decreases the number of
-actual global names in use. For example, the functions described in
-*Note Passwd Functions::, might have used array elements
-`PW_data["inited"]', `PW_data["total"]', `PW_data["count"]', and
-`PW_data["awklib"]', instead of `_pw_inited', `_pw_awklib', `_pw_total',
-and `_pw_count'.
-
- The conventions presented in this minor node are exactly that:
-conventions. You are not required to write your programs this way--we
-merely recommend that you do so.
-
- ---------- Footnotes ----------
-
- (1) While all the library routines could have been rewritten to use
-this convention, this was not done, in order to show how my own `awk'
-programming style has evolved and to provide some basis for this
-discussion.
-
- (2) `gawk''s `--dump-variables' command-line option is useful for
-verifying this.
-
-12.2 General Programming
-========================
-
-This minor node presents a number of functions that are of general
-programming use.
-
-12.2.1 Implementing `nextfile' as a Function
---------------------------------------------
-
-The `nextfile' statement, presented in *Note Nextfile Statement::, is a
-`gawk'-specific extension--it is not available in most other
-implementations of `awk'. This minor node shows two versions of a
-`nextfile' function that you can use to simulate `gawk''s `nextfile'
-statement if you cannot use `gawk'.
-
- A first attempt at writing a `nextfile' function is as follows:
-
- # nextfile --- skip remaining records in current file
- # this should be read in before the "main" awk program
-
- function nextfile() { _abandon_ = FILENAME; next }
- _abandon_ == FILENAME { next }
-
- Because it supplies a rule that must be executed first, this file
-should be included before the main program. This rule compares the
-current data file's name (which is always in the `FILENAME' variable) to
-a private variable named `_abandon_'. If the file name matches, then
-the action part of the rule executes a `next' statement to go on to the
-next record. (The use of `_' in the variable name is a convention. It
-is discussed more fully in *Note Library Names::.)
-
- The use of the `next' statement effectively creates a loop that reads
-all the records from the current data file. The end of the file is
-eventually reached and a new data file is opened, changing the value of
-`FILENAME'. Once this happens, the comparison of `_abandon_' to
-`FILENAME' fails, and execution continues with the first rule of the
-"real" program.
-
- The `nextfile' function itself simply sets the value of `_abandon_'
-and then executes a `next' statement to start the loop.
-
- This initial version has a subtle problem. If the same data file is
-listed _twice_ on the commandline, one right after the other or even
-with just a variable assignment between them, this code skips right
-through the file a second time, even though it should stop when it gets
-to the end of the first occurrence. A second version of `nextfile'
-that remedies this problem is shown here:
-
- # nextfile --- skip remaining records in current file
- # correctly handle successive occurrences of the same file
- # this should be read in before the "main" awk program
-
- function nextfile() { _abandon_ = FILENAME; next }
-
- _abandon_ == FILENAME {
- if (FNR == 1)
- _abandon_ = ""
- else
- next
- }
-
- The `nextfile' function has not changed. It makes `_abandon_' equal
-to the current file name and then executes a `next' statement. The
-`next' statement reads the next record and increments `FNR' so that
-`FNR' is guaranteed to have a value of at least two. However, if
-`nextfile' is called for the last record in the file, then `awk' closes
-the current data file and moves on to the next one. Upon doing so,
-`FILENAME' is set to the name of the new file and `FNR' is reset to
-one. If this next file is the same as the previous one, `_abandon_' is
-still equal to `FILENAME'. However, `FNR' is equal to one, telling us
-that this is a new occurrence of the file and not the one we were
-reading when the `nextfile' function was executed. In that case,
-`_abandon_' is reset to the empty string, so that further executions of
-this rule fail (until the next time that `nextfile' is called).
-
- If `FNR' is not one, then we are still in the original data file and
-the program executes a `next' statement to skip through it.
-
- An important question to ask at this point is: given that the
-functionality of `nextfile' can be provided with a library file, why is
-it built into `gawk'? Adding features for little reason leads to
-larger, slower programs that are harder to maintain. The answer is
-that building `nextfile' into `gawk' provides significant gains in
-efficiency. If the `nextfile' function is executed at the beginning of
-a large data file, `awk' still has to scan the entire file, splitting
-it up into records, just to skip over it. The built-in `nextfile' can
-simply close the file immediately and proceed to the next one, which
-saves a lot of time. This is particularly important in `awk', because
-`awk' programs are generally I/O-bound (i.e., they spend most of their
-time doing input and output, instead of performing computations).
-
-12.2.2 Converting Strings To Numbers
-------------------------------------
-
-The `strtonum' function (*note String Functions::) is a `gawk'
-extension. The following function provides an implementation for other
-versions of `awk':
-
- # strtonum --- convert string to number
- function mystrtonum(str, ret, chars, n, i, k, c)
- {
- if (str ~ /^0[0-7]*$/) {
- # octal
- n = length(str)
- ret = 0
- for (i = 1; i <= n; i++) {
- c = substr(str, i, 1)
- if ((k = index("01234567", c)) > 0)
- k-- # adjust for 1-basing in awk
-
- ret = ret * 8 + k
- }
- } else if (str ~ /^0[xX][0-9a-fA-f]+/) {
- # hexadecimal
- str = substr(str, 3) # lop off leading 0x
- n = length(str)
- ret = 0
- for (i = 1; i <= n; i++) {
- c = substr(str, i, 1)
- c = tolower(c)
- if ((k = index("0123456789", c)) > 0)
- k-- # adjust for 1-basing in awk
- else if ((k = index("abcdef", c)) > 0)
- k += 9
-
- ret = ret * 16 + k
- }
- } else if (str ~
/^[-+]?([0-9]+([.][0-9]*([Ee][0-9]+)?)?|([.][0-9]+([Ee][-+]?[0-9]+)?))$/) {
- # decimal number, possibly floating point
- ret = str + 0
- } else
- ret = "NOT-A-NUMBER"
-
- return ret
- }
-
- # BEGIN { # gawk test harness
- # a[1] = "25"
- # a[2] = ".31"
- # a[3] = "0123"
- # a[4] = "0xdeadBEEF"
- # a[5] = "123.45"
- # a[6] = "1.e3"
- # a[7] = "1.32"
- # a[7] = "1.32E2"
- #
- # for (i = 1; i in a; i++)
- # print a[i], strtonum(a[i]), mystrtonum(a[i])
- # }
-
- The function first looks for C-style octal numbers (base 8). If the
-input string matches a regular expression describing octal numbers,
-then `mystrtonum' loops through each character in the string. It sets
-`k' to the index in `"01234567"' of the current octal digit. Since the
-return value is one-based, the `k--' adjusts `k' so it can be used in
-computing the return value.
-
- Similar logic applies to the code that checks for and converts a
-hexadecimal value, which starts with `0x' or `0X'. The use of
-`tolower' simplifies the computation for finding the correct numeric
-value for each hexadecimal digit.
-
- Finally, if the string matches the (rather complicated) regex for a
-regular decimal integer or floating-point numer, the computation `ret =
-str + 0' lets `awk' convert the value to a number.
-
- A commented-out test program is included, so that the function can
-be tested with `gawk' and the results compared to the built-in
-`strtonum' function.
-
-12.2.3 Assertions
------------------
-
-When writing large programs, it is often useful to know that a
-condition or set of conditions is true. Before proceeding with a
-particular computation, you make a statement about what you believe to
-be the case. Such a statement is known as an "assertion". The C
-language provides an `<assert.h>' header file and corresponding
-`assert' macro that the programmer can use to make assertions. If an
-assertion fails, the `assert' macro arranges to print a diagnostic
-message describing the condition that should have been true but was
-not, and then it kills the program. In C, using `assert' looks this:
-
- #include <assert.h>
-
- int myfunc(int a, double b)
- {
- assert(a <= 5 && b >= 17.1);
- ...
- }
-
- If the assertion fails, the program prints a message similar to this:
-
- prog.c:5: assertion failed: a <= 5 && b >= 17.1
-
- The C language makes it possible to turn the condition into a string
-for use in printing the diagnostic message. This is not possible in
-`awk', so this `assert' function also requires a string version of the
-condition that is being tested. Following is the function:
-
- # assert --- assert that a condition is true. Otherwise exit.
- function assert(condition, string)
- {
- if (! condition) {
- printf("%s:%d: assertion failed: %s\n",
- FILENAME, FNR, string) > "/dev/stderr"
- _assert_exit = 1
- exit 1
- }
- }
-
- END {
- if (_assert_exit)
- exit 1
- }
-
- The `assert' function tests the `condition' parameter. If it is
-false, it prints a message to standard error, using the `string'
-parameter to describe the failed condition. It then sets the variable
-`_assert_exit' to one and executes the `exit' statement. The `exit'
-statement jumps to the `END' rule. If the `END' rules finds
-`_assert_exit' to be true, it exits immediately.
-
- The purpose of the test in the `END' rule is to keep any other `END'
-rules from running. When an assertion fails, the program should exit
-immediately. If no assertions fail, then `_assert_exit' is still false
-when the `END' rule is run normally, and the rest of the program's
-`END' rules execute. For all of this to work correctly, `assert.awk'
-must be the first source file read by `awk'. The function can be used
-in a program in the following way:
-
- function myfunc(a, b)
- {
- assert(a <= 5 && b >= 17.1, "a <= 5 && b >= 17.1")
- ...
- }
-
-If the assertion fails, you see a message similar to the following:
-
- mydata:1357: assertion failed: a <= 5 && b >= 17.1
-
- There is a small problem with this version of `assert'. An `END'
-rule is automatically added to the program calling `assert'. Normally,
-if a program consists of just a `BEGIN' rule, the input files and/or
-standard input are not read. However, now that the program has an `END'
-rule, `awk' attempts to read the input data files or standard input
-(*note Using BEGIN/END::), most likely causing the program to hang as
-it waits for input.
-
- There is a simple workaround to this: make sure the `BEGIN' rule
-always ends with an `exit' statement.
-
-12.2.4 Rounding Numbers
------------------------
-
-The way `printf' and `sprintf' (*note Printf::) perform rounding often
-depends upon the system's C `sprintf' subroutine. On many machines,
-`sprintf' rounding is "unbiased," which means it doesn't always round a
-trailing `.5' up, contrary to naive expectations. In unbiased
-rounding, `.5' rounds to even, rather than always up, so 1.5 rounds to
-2 but 4.5 rounds to 4. This means that if you are using a format that
-does rounding (e.g., `"%.0f"'), you should check what your system does.
-The following function does traditional rounding; it might be useful
-if your awk's `printf' does unbiased rounding:
-
- # round.awk --- do normal rounding
- function round(x, ival, aval, fraction)
- {
- ival = int(x) # integer part, int() truncates
-
- # see if fractional part
- if (ival == x) # no fraction
- return x
-
- if (x < 0) {
- aval = -x # absolute value
- ival = int(aval)
- fraction = aval - ival
- if (fraction >= .5)
- return int(x) - 1 # -2.5 --> -3
- else
- return int(x) # -2.3 --> -2
- } else {
- fraction = x - ival
- if (fraction >= .5)
- return ival + 1
- else
- return ival
- }
- }
-
- # test harness
- { print $0, round($0) }
-
-12.2.5 The Cliff Random Number Generator
-----------------------------------------
-
-The Cliff random number generator(1) is a very simple random number
-generator that "passes the noise sphere test for randomness by showing
-no structure." It is easily programmed, in less than 10 lines of `awk'
-code:
-
- # cliff_rand.awk --- generate Cliff random numbers
- BEGIN { _cliff_seed = 0.1 }
-
- function cliff_rand()
- {
- _cliff_seed = (100 * log(_cliff_seed)) % 1
- if (_cliff_seed < 0)
- _cliff_seed = - _cliff_seed
- return _cliff_seed
- }
-
- This algorithm requires an initial "seed" of 0.1. Each new value
-uses the current seed as input for the calculation. If the built-in
-`rand' function (*note Numeric Functions::) isn't random enough, you
-might try using this function instead.
-
- ---------- Footnotes ----------
-
- (1) `http://mathworld.wolfram.com/CliffRandomNumberGenerator.hmtl'
-
-12.2.6 Translating Between Characters and Numbers
--------------------------------------------------
-
-One commercial implementation of `awk' supplies a built-in function,
-`ord', which takes a character and returns the numeric value for that
-character in the machine's character set. If the string passed to
-`ord' has more than one character, only the first one is used.
-
- The inverse of this function is `chr' (from the function of the same
-name in Pascal), which takes a number and returns the corresponding
-character. Both functions are written very nicely in `awk'; there is
-no real reason to build them into the `awk' interpreter:
-
- # ord.awk --- do ord and chr
-
- # Global identifiers:
- # _ord_: numerical values indexed by characters
- # _ord_init: function to initialize _ord_
- BEGIN { _ord_init() }
-
- function _ord_init( low, high, i, t)
- {
- low = sprintf("%c", 7) # BEL is ascii 7
- if (low == "\a") { # regular ascii
- low = 0
- high = 127
- } else if (sprintf("%c", 128 + 7) == "\a") {
- # ascii, mark parity
- low = 128
- high = 255
- } else { # ebcdic(!)
- low = 0
- high = 255
- }
-
- for (i = low; i <= high; i++) {
- t = sprintf("%c", i)
- _ord_[t] = i
- }
- }
-
- Some explanation of the numbers used by `chr' is worthwhile. The
-most prominent character set in use today is ASCII. Although an 8-bit
-byte can hold 256 distinct values (from 0 to 255), ASCII only defines
-characters that use the values from 0 to 127.(1) In the now distant
-past, at least one minicomputer manufacturer used ASCII, but with mark
-parity, meaning that the leftmost bit in the byte is always 1. This
-means that on those systems, characters have numeric values from 128 to
-255. Finally, large mainframe systems use the EBCDIC character set,
-which uses all 256 values. While there are other character sets in use
-on some older systems, they are not really worth worrying about:
-
- function ord(str, c)
- {
- # only first character is of interest
- c = substr(str, 1, 1)
- return _ord_[c]
- }
-
- function chr(c)
- {
- # force c to be numeric by adding 0
- return sprintf("%c", c + 0)
- }
-
- #### test code ####
- # BEGIN \
- # {
- # for (;;) {
- # printf("enter a character: ")
- # if (getline var <= 0)
- # break
- # printf("ord(%s) = %d\n", var, ord(var))
- # }
- # }
-
- An obvious improvement to these functions is to move the code for the
-`_ord_init' function into the body of the `BEGIN' rule. It was written
-this way initially for ease of development. There is a "test program"
-in a `BEGIN' rule, to test the function. It is commented out for
-production use.
-
- ---------- Footnotes ----------
-
- (1) ASCII has been extended in many countries to use the values from
-128 to 255 for country-specific characters. If your system uses these
-extensions, you can simplify `_ord_init' to simply loop from 0 to 255.
-
-12.2.7 Merging an Array into a String
--------------------------------------
-
-When doing string processing, it is often useful to be able to join all
-the strings in an array into one long string. The following function,
-`join', accomplishes this task. It is used later in several of the
-application programs (*note Sample Programs::).
-
- Good function design is important; this function needs to be general
-but it should also have a reasonable default behavior. It is called
-with an array as well as the beginning and ending indices of the
-elements in the array to be merged. This assumes that the array
-indices are numeric--a reasonable assumption since the array was likely
-created with `split' (*note String Functions::):
-
- # join.awk --- join an array into a string
- function join(array, start, end, sep, result, i)
- {
- if (sep == "")
- sep = " "
- else if (sep == SUBSEP) # magic value
- sep = ""
- result = array[start]
- for (i = start + 1; i <= end; i++)
- result = result sep array[i]
- return result
- }
-
- An optional additional argument is the separator to use when joining
-the strings back together. If the caller supplies a nonempty value,
-`join' uses it; if it is not supplied, it has a null value. In this
-case, `join' uses a single blank as a default separator for the
-strings. If the value is equal to `SUBSEP', then `join' joins the
-strings with no separator between them. `SUBSEP' serves as a "magic"
-value to indicate that there should be no separation between the
-component strings.(1)
-
- ---------- Footnotes ----------
-
- (1) It would be nice if `awk' had an assignment operator for
-concatenation. The lack of an explicit operator for concatenation
-makes string operations more difficult than they really need to be.
-
-12.2.8 Managing the Time of Day
--------------------------------
-
-The `systime' and `strftime' functions described in *Note Time
-Functions::, provide the minimum functionality necessary for dealing
-with the time of day in human readable form. While `strftime' is
-extensive, the control formats are not necessarily easy to remember or
-intuitively obvious when reading a program.
-
- The following function, `gettimeofday', populates a user-supplied
-array with preformatted time information. It returns a string with the
-current time formatted in the same way as the `date' utility:
-
- # gettimeofday.awk --- get the time of day in a usable format
-
- # Returns a string in the format of output of date(1)
- # Populates the array argument time with individual values:
- # time["second"] -- seconds (0 - 59)
- # time["minute"] -- minutes (0 - 59)
- # time["hour"] -- hours (0 - 23)
- # time["althour"] -- hours (0 - 12)
- # time["monthday"] -- day of month (1 - 31)
- # time["month"] -- month of year (1 - 12)
- # time["monthname"] -- name of the month
- # time["shortmonth"] -- short name of the month
- # time["year"] -- year modulo 100 (0 - 99)
- # time["fullyear"] -- full year
- # time["weekday"] -- day of week (Sunday = 0)
- # time["altweekday"] -- day of week (Monday = 0)
- # time["dayname"] -- name of weekday
- # time["shortdayname"] -- short name of weekday
- # time["yearday"] -- day of year (0 - 365)
- # time["timezone"] -- abbreviation of timezone name
- # time["ampm"] -- AM or PM designation
- # time["weeknum"] -- week number, Sunday first day
- # time["altweeknum"] -- week number, Monday first day
-
- function gettimeofday(time, ret, now, i)
- {
- # get time once, avoids unnecessary system calls
- now = systime()
-
- # return date(1)-style output
- ret = strftime("%a %b %d %H:%M:%S %Z %Y", now)
-
- # clear out target array
- delete time
-
- # fill in values, force numeric values to be
- # numeric by adding 0
- time["second"] = strftime("%S", now) + 0
- time["minute"] = strftime("%M", now) + 0
- time["hour"] = strftime("%H", now) + 0
- time["althour"] = strftime("%I", now) + 0
- time["monthday"] = strftime("%d", now) + 0
- time["month"] = strftime("%m", now) + 0
- time["monthname"] = strftime("%B", now)
- time["shortmonth"] = strftime("%b", now)
- time["year"] = strftime("%y", now) + 0
- time["fullyear"] = strftime("%Y", now) + 0
- time["weekday"] = strftime("%w", now) + 0
- time["altweekday"] = strftime("%u", now) + 0
- time["dayname"] = strftime("%A", now)
- time["shortdayname"] = strftime("%a", now)
- time["yearday"] = strftime("%j", now) + 0
- time["timezone"] = strftime("%Z", now)
- time["ampm"] = strftime("%p", now)
- time["weeknum"] = strftime("%U", now) + 0
- time["altweeknum"] = strftime("%W", now) + 0
-
- return ret
- }
-
- The string indices are easier to use and read than the various
-formats required by `strftime'. The `alarm' program presented in *Note
-Alarm Program::, uses this function. A more general design for the
-`gettimeofday' function would have allowed the user to supply an
-optional timestamp value to use instead of the current time.
-
-12.3 Data File Management
-=========================
-
-This minor node presents functions that are useful for managing
-command-line data files.
-
-12.3.1 Noting Data File Boundaries
-----------------------------------
-
-The `BEGIN' and `END' rules are each executed exactly once at the
-beginning and end of your `awk' program, respectively (*note
-BEGIN/END::). We (the `gawk' authors) once had a user who mistakenly
-thought that the `BEGIN' rule is executed at the beginning of each data
-file and the `END' rule is executed at the end of each data file. When
-informed that this was not the case, the user requested that we add new
-special patterns to `gawk', named `BEGIN_FILE' and `END_FILE', that
-would have the desired behavior. He even supplied us the code to do so.
-
- Adding these special patterns to `gawk' wasn't necessary; the job
-can be done cleanly in `awk' itself, as illustrated by the following
-library program. It arranges to call two user-supplied functions,
-`beginfile' and `endfile', at the beginning and end of each data file.
-Besides solving the problem in only nine(!) lines of code, it does so
-_portably_; this works with any implementation of `awk':
-
- # transfile.awk
- #
- # Give the user a hook for filename transitions
- #
- # The user must supply functions beginfile() and endfile()
- # that each take the name of the file being started or
- # finished, respectively.
-
- FILENAME != _oldfilename \
- {
- if (_oldfilename != "")
- endfile(_oldfilename)
- _oldfilename = FILENAME
- beginfile(FILENAME)
- }
-
- END { endfile(FILENAME) }
-
- This file must be loaded before the user's "main" program, so that
-the rule it supplies is executed first.
-
- This rule relies on `awk''s `FILENAME' variable that automatically
-changes for each new data file. The current file name is saved in a
-private variable, `_oldfilename'. If `FILENAME' does not equal
-`_oldfilename', then a new data file is being processed and it is
-necessary to call `endfile' for the old file. Because `endfile' should
-only be called if a file has been processed, the program first checks
-to make sure that `_oldfilename' is not the null string. The program
-then assigns the current file name to `_oldfilename' and calls
-`beginfile' for the file. Because, like all `awk' variables,
-`_oldfilename' is initialized to the null string, this rule executes
-correctly even for the first data file.
-
- The program also supplies an `END' rule to do the final processing
-for the last file. Because this `END' rule comes before any `END' rules
-supplied in the "main" program, `endfile' is called first. Once again
-the value of multiple `BEGIN' and `END' rules should be clear.
-
- This version has same problem as the first version of `nextfile'
-(*note Nextfile Function::). If the same data file occurs twice in a
-row on the command line, then `endfile' and `beginfile' are not
-executed at the end of the first pass and at the beginning of the
-second pass. The following version solves the problem:
-
- # ftrans.awk --- handle data file transitions
- #
- # user supplies beginfile() and endfile() functions
- FNR == 1 {
- if (_filename_ != "")
- endfile(_filename_)
- _filename_ = FILENAME
- beginfile(FILENAME)
- }
-
- END { endfile(_filename_) }
-
- *Note Wc Program::, shows how this library function can be used and
-how it simplifies writing the main program.
-
-12.3.2 Rereading the Current File
----------------------------------
-
-Another request for a new built-in function was for a `rewind' function
-that would make it possible to reread the current file. The requesting
-user didn't want to have to use `getline' (*note Getline::) inside a
-loop.
-
- However, as long as you are not in the `END' rule, it is quite easy
-to arrange to immediately close the current input file and then start
-over with it from the top. For lack of a better name, we'll call it
-`rewind':
-
- # rewind.awk --- rewind the current file and start over
- function rewind( i)
- {
- # shift remaining arguments up
- for (i = ARGC; i > ARGIND; i--)
- ARGV[i] = ARGV[i-1]
-
- # make sure gawk knows to keep going
- ARGC++
-
- # make current file next to get done
- ARGV[ARGIND+1] = FILENAME
-
- # do it
- nextfile
- }
-
- This code relies on the `ARGIND' variable (*note Auto-set::), which
-is specific to `gawk'. If you are not using `gawk', you can use ideas
-presented in *Note Filetrans Function::, to either update `ARGIND' on
-your own or modify this code as appropriate.
-
- The `rewind' function also relies on the `nextfile' keyword (*note
-Nextfile Statement::). *Note Nextfile Function::, for a function
-version of `nextfile'.
-
-12.3.3 Checking for Readable Data Files
----------------------------------------
-
-Normally, if you give `awk' a data file that isn't readable, it stops
-with a fatal error. There are times when you might want to just ignore
-such files and keep going. You can do this by prepending the following
-program to your `awk' program:
-
- # readable.awk --- library file to skip over unreadable files
- BEGIN {
- for (i = 1; i < ARGC; i++) {
- if (ARGV[i] ~ /^[A-Za-z_][A-Za-z0-9_]*=.*/ \
- || ARGV[i] == "-")
- continue # assignment or standard input
- else if ((getline junk < ARGV[i]) < 0) # unreadable
- delete ARGV[i]
- else
- close(ARGV[i])
- }
- }
-
- In `gawk', the `getline' won't be fatal (unless `--posix' is in
-force). Removing the element from `ARGV' with `delete' skips the file
-(since it's no longer in the list).
-
-12.3.4 Checking For Zero-length Files
--------------------------------------
-
-All known `awk' implementations silently skip over zero-length files.
-This is a by-product of `awk''s implicit
-read-a-record-and-match-against-the-rules loop: when `awk' tries to
-read a record from an empty file, it immediately receives an end of
-file indication, closes the file, and proceeds on to the next
-command-line data file, _without_ executing any user-level `awk'
-program code.
-
- Using `gawk''s `ARGIND' variable (*note Built-in Variables::), it is
-possible to detect when an empty data file has been skipped. Similar
-to the library file presented in *Note Filetrans Function::, the
-following library file calls a function named `zerofile' that the user
-must provide. The arguments passed are the file name and the position
-in `ARGV' where it was found:
-
- # zerofile.awk --- library file to process empty input files
- BEGIN { Argind = 0 }
-
- ARGIND > Argind + 1 {
- for (Argind++; Argind < ARGIND; Argind++)
- zerofile(ARGV[Argind], Argind)
- }
-
- ARGIND != Argind { Argind = ARGIND }
-
- END {
- if (ARGIND > Argind)
- for (Argind++; Argind <= ARGIND; Argind++)
- zerofile(ARGV[Argind], Argind)
- }
-
- The user-level variable `Argind' allows the `awk' program to track
-its progress through `ARGV'. Whenever the program detects that
-`ARGIND' is greater than `Argind + 1', it means that one or more empty
-files were skipped. The action then calls `zerofile' for each such
-file, incrementing `Argind' along the way.
-
- The `Argind != ARGIND' rule simply keeps `Argind' up to date in the
-normal case.
-
- Finally, the `END' rule catches the case of any empty files at the
-end of the command-line arguments. Note that the test in the condition
-of the `for' loop uses the `<=' operator, not `<'.
-
- As an exercise, you might consider whether this same problem can be
-solved without relying on `gawk''s `ARGIND' variable.
-
- As a second exercise, revise this code to handle the case where an
-intervening value in `ARGV' is a variable assignment.
-
-12.3.5 Treating Assignments as File Names
------------------------------------------
-
-Occasionally, you might not want `awk' to process command-line variable
-assignments (*note Assignment Options::). In particular, if you have
-file names that contain an `=' character, `awk' treats the file name as
-an assignment, and does not process it.
-
- Some users have suggested an additional command-line option for
-`gawk' to disable command-line assignments. However, some simple
-programming with a library file does the trick:
-
- # noassign.awk --- library file to avoid the need for a
- # special option that disables command-line assignments
- function disable_assigns(argc, argv, i)
- {
- for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[A-Za-z_][A-Za-z_0-9]*=.*/)
- argv[i] = ("./" argv[i])
- }
-
- BEGIN {
- if (No_command_assign)
- disable_assigns(ARGC, ARGV)
- }
-
- You then run your program this way:
-
- awk -v No_command_assign=1 -f noassign.awk -f yourprog.awk *
-
- The function works by looping through the arguments. It prepends
-`./' to any argument that matches the form of a variable assignment,
-turning that argument into a file name.
-
- The use of `No_command_assign' allows you to disable command-line
-assignments at invocation time, by giving the variable a true value.
-When not set, it is initially zero (i.e., false), so the command-line
-arguments are left alone.
-
-12.4 Processing Command-Line Options
-====================================
-
-Most utilities on POSIX compatible systems take options, or "switches,"
-on the command line that can be used to change the way a program
-behaves. `awk' is an example of such a program (*note Options::).
-Often, options take "arguments"; i.e., data that the program needs to
-correctly obey the command-line option. For example, `awk''s `-F'
-option requires a string to use as the field separator. The first
-occurrence on the command line of either `--' or a string that does not
-begin with `-' ends the options.
-
- Modern Unix systems provide a C function named `getopt' for
-processing command-line arguments. The programmer provides a string
-describing the one-letter options. If an option requires an argument,
-it is followed in the string with a colon. `getopt' is also passed the
-count and values of the command-line arguments and is called in a loop.
-`getopt' processes the command-line arguments for option letters. Each
-time around the loop, it returns a single character representing the
-next option letter that it finds, or `?' if it finds an invalid option.
-When it returns -1, there are no options left on the command line.
-
- When using `getopt', options that do not take arguments can be
-grouped together. Furthermore, options that take arguments require
-that the argument is present. The argument can immediately follow the
-option letter, or it can be a separate command-line argument.
-
- Given a hypothetical program that takes three command-line options,
-`-a', `-b', and `-c', where `-b' requires an argument, all of the
-following are valid ways of invoking the program:
-
- prog -a -b foo -c data1 data2 data3
- prog -ac -bfoo -- data1 data2 data3
- prog -acbfoo data1 data2 data3
-
- Notice that when the argument is grouped with its option, the rest of
-the argument is considered to be the option's argument. In this
-example, `-acbfoo' indicates that all of the `-a', `-b', and `-c'
-options were supplied, and that `foo' is the argument to the `-b'
-option.
-
- `getopt' provides four external variables that the programmer can
-use:
-
-`optind'
- The index in the argument value array (`argv') where the first
- nonoption command-line argument can be found.
-
-`optarg'
- The string value of the argument to an option.
-
-`opterr'
- Usually `getopt' prints an error message when it finds an invalid
- option. Setting `opterr' to zero disables this feature. (An
- application might want to print its own error message.)
-
-`optopt'
- The letter representing the command-line option.
-
- The following C fragment shows how `getopt' might process
-command-line arguments for `awk':
-
- int
- main(int argc, char *argv[])
- {
- ...
- /* print our own message */
- opterr = 0;
- while ((c = getopt(argc, argv, "v:f:F:W:")) != -1) {
- switch (c) {
- case 'f': /* file */
- ...
- break;
- case 'F': /* field separator */
- ...
- break;
- case 'v': /* variable assignment */
- ...
- break;
- case 'W': /* extension */
- ...
- break;
- case '?':
- default:
- usage();
- break;
- }
- }
- ...
- }
-
- As a side point, `gawk' actually uses the GNU `getopt_long' function
-to process both normal and GNU-style long options (*note Options::).
-
- The abstraction provided by `getopt' is very useful and is quite
-handy in `awk' programs as well. Following is an `awk' version of
-`getopt'. This function highlights one of the greatest weaknesses in
-`awk', which is that it is very poor at manipulating single characters.
-Repeated calls to `substr' are necessary for accessing individual
-characters (*note String Functions::).(1)
-
- The discussion that follows walks through the code a bit at a time:
-
- # getopt.awk --- do C library getopt(3) function in awk
- # External variables:
- # Optind -- index in ARGV of first nonoption argument
- # Optarg -- string value of argument to current option
- # Opterr -- if nonzero, print our own diagnostic
- # Optopt -- current option letter
-
- # Returns:
- # -1 at end of options
- # ? for unrecognized option
- # <c> a character representing the current option
-
- # Private Data:
- # _opti -- index in multi-flag option, e.g., -abc
-
- The function starts out with a list of the global variables it uses,
-what the return values are, what they mean, and any global variables
-that are "private" to this library function. Such documentation is
-essential for any program, and particularly for library functions.
-
- The `getopt' function first checks that it was indeed called with a
-string of options (the `options' parameter). If `options' has a zero
-length, `getopt' immediately returns -1:
-
- function getopt(argc, argv, options, thisopt, i)
- {
- if (length(options) == 0) # no options given
- return -1
-
- if (argv[Optind] == "--") { # all done
- Optind++
- _opti = 0
- return -1
- } else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) {
- _opti = 0
- return -1
- }
-
- The next thing to check for is the end of the options. A `--' ends
-the command-line options, as does any command-line argument that does
-not begin with a `-'. `Optind' is used to step through the array of
-command-line arguments; it retains its value across calls to `getopt',
-because it is a global variable.
-
- The regular expression that is used, `/^-[^: \t\n\f\r\v\b]/', is
-perhaps a bit of overkill; it checks for a `-' followed by anything
-that is not whitespace and not a colon. If the current command-line
-argument does not match this pattern, it is not an option, and it ends
-option processing:
-
- if (_opti == 0)
- _opti = 2
- thisopt = substr(argv[Optind], _opti, 1)
- Optopt = thisopt
- i = index(options, thisopt)
- if (i == 0) {
- if (Opterr)
- printf("%c -- invalid option\n",
- thisopt) > "/dev/stderr"
- if (_opti >= length(argv[Optind])) {
- Optind++
- _opti = 0
- } else
- _opti++
- return "?"
- }
-
- The `_opti' variable tracks the position in the current command-line
-argument (`argv[Optind]'). If multiple options are grouped together
-with one `-' (e.g., `-abx'), it is necessary to return them to the user
-one at a time.
-
- If `_opti' is equal to zero, it is set to two, which is the index in
-the string of the next character to look at (we skip the `-', which is
-at position one). The variable `thisopt' holds the character, obtained
-with `substr'. It is saved in `Optopt' for the main program to use.
-
- If `thisopt' is not in the `options' string, then it is an invalid
-option. If `Opterr' is nonzero, `getopt' prints an error message on
-the standard error that is similar to the message from the C version of
-`getopt'.
-
- Because the option is invalid, it is necessary to skip it and move
-on to the next option character. If `_opti' is greater than or equal
-to the length of the current command-line argument, it is necessary to
-move on to the next argument, so `Optind' is incremented and `_opti' is
-reset to zero. Otherwise, `Optind' is left alone and `_opti' is merely
-incremented.
-
- In any case, because the option is invalid, `getopt' returns `?'.
-The main program can examine `Optopt' if it needs to know what the
-invalid option letter actually is. Continuing on:
-
- if (substr(options, i + 1, 1) == ":") {
- # get option argument
- if (length(substr(argv[Optind], _opti + 1)) > 0)
- Optarg = substr(argv[Optind], _opti + 1)
- else
- Optarg = argv[++Optind]
- _opti = 0
- } else
- Optarg = ""
-
- If the option requires an argument, the option letter is followed by
-a colon in the `options' string. If there are remaining characters in
-the current command-line argument (`argv[Optind]'), then the rest of
-that string is assigned to `Optarg'. Otherwise, the next command-line
-argument is used (`-xFOO' versus `-x FOO'). In either case, `_opti' is
-reset to zero, because there are no more characters left to examine in
-the current command-line argument. Continuing:
-
- if (_opti == 0 || _opti >= length(argv[Optind])) {
- Optind++
- _opti = 0
- } else
- _opti++
- return thisopt
- }
-
- Finally, if `_opti' is either zero or greater than the length of the
-current command-line argument, it means this element in `argv' is
-through being processed, so `Optind' is incremented to point to the
-next element in `argv'. If neither condition is true, then only
-`_opti' is incremented, so that the next option letter can be processed
-on the next call to `getopt'.
-
- The `BEGIN' rule initializes both `Opterr' and `Optind' to one.
-`Opterr' is set to one, since the default behavior is for `getopt' to
-print a diagnostic message upon seeing an invalid option. `Optind' is
-set to one, since there's no reason to look at the program name, which
-is in `ARGV[0]':
-
- BEGIN {
- Opterr = 1 # default is to diagnose
- Optind = 1 # skip ARGV[0]
-
- # test program
- if (_getopt_test) {
- while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1)
- printf("c = <%c>, optarg = <%s>\n",
- _go_c, Optarg)
- printf("non-option arguments:\n")
- for (; Optind < ARGC; Optind++)
- printf("\tARGV[%d] = <%s>\n",
- Optind, ARGV[Optind])
- }
- }
-
- The rest of the `BEGIN' rule is a simple test program. Here is the
-result of two sample runs of the test program:
-
- $ awk -f getopt.awk -v _getopt_test=1 -- -a -cbARG bax -x
- -| c = <a>, optarg = <>
- -| c = <c>, optarg = <>
- -| c = <b>, optarg = <ARG>
- -| non-option arguments:
- -| ARGV[3] = <bax>
- -| ARGV[4] = <-x>
-
- $ awk -f getopt.awk -v _getopt_test=1 -- -a -x -- xyz abc
- -| c = <a>, optarg = <>
- error--> x -- invalid option
- -| c = <?>, optarg = <>
- -| non-option arguments:
- -| ARGV[4] = <xyz>
- -| ARGV[5] = <abc>
-
- In both runs, the first `--' terminates the arguments to `awk', so
-that it does not try to interpret the `-a', etc., as its own options.
-Several of the sample programs presented in *Note Sample Programs::,
-use `getopt' to process their arguments.
-
- ---------- Footnotes ----------
-
- (1) This function was written before `gawk' acquired the ability to
-split strings into single characters using `""' as the separator. We
-have left it alone, since using `substr' is more portable.
-
-12.5 Reading the User Database
-==============================
-
-The `PROCINFO' array (*note Built-in Variables::) provides access to
-the current user's real and effective user and group ID numbers, and if
-available, the user's supplementary group set. However, because these
-are numbers, they do not provide very useful information to the average
-user. There needs to be some way to find the user information
-associated with the user and group ID numbers. This minor node
-presents a suite of functions for retrieving information from the user
-database. *Note Group Functions::, for a similar suite that retrieves
-information from the group database.
-
- The POSIX standard does not define the file where user information is
-kept. Instead, it provides the `<pwd.h>' header file and several C
-language subroutines for obtaining user information. The primary
-function is `getpwent', for "get password entry." The "password" comes
-from the original user database file, `/etc/passwd', which stores user
-information, along with the encrypted passwords (hence the name).
-
- While an `awk' program could simply read `/etc/passwd' directly,
-this file may not contain complete information about the system's set
-of users.(1) To be sure you are able to produce a readable and complete
-version of the user database, it is necessary to write a small C
-program that calls `getpwent'. `getpwent' is defined as returning a
-pointer to a `struct passwd'. Each time it is called, it returns the
-next entry in the database. When there are no more entries, it returns
-`NULL', the null pointer. When this happens, the C program should call
-`endpwent' to close the database. Following is `pwcat', a C program
-that "cats" the password database:
-
- /*
- * pwcat.c
- *
- * Generate a printable version of the password database
- */
- #include <stdio.h>
- #include <pwd.h>
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct passwd *p;
-
- while ((p = getpwent()) != NULL)
- printf("%s:%s:%ld:%ld:%s:%s:%s\n",
- p->pw_name, p->pw_passwd, (long) p->pw_uid,
- (long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell);
-
- endpwent();
- return 0;
- }
-
- If you don't understand C, don't worry about it. The output from
-`pwcat' is the user database, in the traditional `/etc/passwd' format
-of colon-separated fields. The fields are:
-
-Login name The user's login name.
-Encrypted password The user's encrypted password. This may not be
- available on some systems.
-User-ID The user's numeric user ID number.
-Group-ID The user's numeric group ID number.
-Full name The user's full name, and perhaps other
- information associated with the user.
-Home directory The user's login (or "home") directory
- (familiar to shell programmers as `$HOME').
-Login shell The program that is run when the user logs in.
- This is usually a shell, such as `bash'.
-
- A few lines representative of `pwcat''s output are as follows:
-
- $ pwcat
- -| root:3Ov02d5VaUPB6:0:1:Operator:/:/bin/sh
- -| nobody:*:65534:65534::/:
- -| daemon:*:1:1::/:
- -| sys:*:2:2::/:/bin/csh
- -| bin:*:3:3::/bin:
- -| arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/sh
- -| miriam:yxaay:112:10:Miriam Robbins:/home/miriam:/bin/sh
- -| andy:abcca2:113:10:Andy Jacobs:/home/andy:/bin/sh
- ...
-
- With that introduction, following is a group of functions for
-getting user information. There are several functions here,
-corresponding to the C functions of the same names:
-
- # passwd.awk --- access password file information
- BEGIN {
- # tailor this to suit your system
- _pw_awklib = "/usr/local/libexec/awk/"
- }
-
- function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw)
- {
- if (_pw_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
- FS = ":"
- RS = "\n"
-
- pwcat = _pw_awklib "pwcat"
- while ((pwcat | getline) > 0) {
- _pw_byname[$1] = $0
- _pw_byuid[$3] = $0
- _pw_bycount[++_pw_total] = $0
- }
- close(pwcat)
- _pw_count = 0
- _pw_inited = 1
- FS = oldfs
- if (using_fw)
- FIELDWIDTHS = FIELDWIDTHS
- RS = oldrs
- $0 = olddol0
- }
-
- The `BEGIN' rule sets a private variable to the directory where
-`pwcat' is stored. Because it is used to help out an `awk' library
-routine, we have chosen to put it in `/usr/local/libexec/awk'; however,
-you might want it to be in a different directory on your system.
-
- The function `_pw_init' keeps three copies of the user information
-in three associative arrays. The arrays are indexed by username
-(`_pw_byname'), by user ID number (`_pw_byuid'), and by order of
-occurrence (`_pw_bycount'). The variable `_pw_inited' is used for
-efficiency; `_pw_init' needs only to be called once.
-
- Because this function uses `getline' to read information from
-`pwcat', it first saves the values of `FS', `RS', and `$0'. It notes
-in the variable `using_fw' whether field splitting with `FIELDWIDTHS'
-is in effect or not. Doing so is necessary, since these functions
-could be called from anywhere within a user's program, and the user may
-have his or her own way of splitting records and fields.
-
- The `using_fw' variable checks `PROCINFO["FS"]', which is
-`"FIELDWIDTHS"' if field splitting is being done with `FIELDWIDTHS'.
-This makes it possible to restore the correct field-splitting mechanism
-later. The test can only be true for `gawk'. It is false if using
-`FS' or on some other `awk' implementation.
-
- The main part of the function uses a loop to read database lines,
-split the line into fields, and then store the line into each array as
-necessary. When the loop is done, `_pw_init' cleans up by closing the
-pipeline, setting `_pw_inited' to one, and restoring `FS' (and
-`FIELDWIDTHS' if necessary), `RS', and `$0'. The use of `_pw_count' is
-explained shortly.
-
- The `getpwnam' function takes a username as a string argument. If
-that user is in the database, it returns the appropriate line.
-Otherwise, it returns the null string:
-
- function getpwnam(name)
- {
- _pw_init()
- if (name in _pw_byname)
- return _pw_byname[name]
- return ""
- }
-
- Similarly, the `getpwuid' function takes a user ID number argument.
-If that user number is in the database, it returns the appropriate
-line. Otherwise, it returns the null string:
-
- function getpwuid(uid)
- {
- _pw_init()
- if (uid in _pw_byuid)
- return _pw_byuid[uid]
- return ""
- }
-
- The `getpwent' function simply steps through the database, one entry
-at a time. It uses `_pw_count' to track its current position in the
-`_pw_bycount' array:
-
- function getpwent()
- {
- _pw_init()
- if (_pw_count < _pw_total)
- return _pw_bycount[++_pw_count]
- return ""
- }
-
- The `endpwent' function resets `_pw_count' to zero, so that
-subsequent calls to `getpwent' start over again:
-
- function endpwent()
- {
- _pw_count = 0
- }
-
- A conscious design decision in this suite was made that each
-subroutine calls `_pw_init' to initialize the database arrays. The
-overhead of running a separate process to generate the user database,
-and the I/O to scan it, are only incurred if the user's main program
-actually calls one of these functions. If this library file is loaded
-along with a user's program, but none of the routines are ever called,
-then there is no extra runtime overhead. (The alternative is move the
-body of `_pw_init' into a `BEGIN' rule, which always runs `pwcat'.
-This simplifies the code but runs an extra process that may never be
-needed.)
-
- In turn, calling `_pw_init' is not too expensive, because the
-`_pw_inited' variable keeps the program from reading the data more than
-once. If you are worried about squeezing every last cycle out of your
-`awk' program, the check of `_pw_inited' could be moved out of
-`_pw_init' and duplicated in all the other functions. In practice,
-this is not necessary, since most `awk' programs are I/O-bound, and it
-clutters up the code.
-
- The `id' program in *Note Id Program::, uses these functions.
-
- ---------- Footnotes ----------
-
- (1) It is often the case that password information is stored in a
-network database.
-
-12.6 Reading the Group Database
-===============================
-
-Much of the discussion presented in *Note Passwd Functions::, applies
-to the group database as well. Although there has traditionally been a
-well-known file (`/etc/group') in a well-known format, the POSIX
-standard only provides a set of C library routines (`<grp.h>' and
-`getgrent') for accessing the information. Even though this file may
-exist, it likely does not have complete information. Therefore, as
-with the user database, it is necessary to have a small C program that
-generates the group database as its output.
-
- `grcat', a C program that "cats" the group database, is as follows:
-
- /*
- * grcat.c
- *
- * Generate a printable version of the group database
- */
- #include <stdio.h>
- #include <grp.h>
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct group *g;
- int i;
-
- while ((g = getgrent()) != NULL) {
- printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
- (long) g->gr_gid);
- for (i = 0; g->gr_mem[i] != NULL; i++) {
- printf("%s", g->gr_mem[i]);
- if (g->gr_mem[i+1] != NULL)
- putchar(',');
- }
- putchar('\n');
- }
- endgrent();
- return 0;
- }
-
- Each line in the group database represents one group. The fields are
-separated with colons and represent the following information:
-
-Group name The group's name.
-Group password The group's encrypted password. In practice,
- this field is never used; it is usually empty
- or set to `*'.
-Group-ID The group's numeric group ID number; this
- number should be unique within the file.
-Group member list A comma-separated list of usernames. These
- users are members of the group. Modern Unix
- systems allow users to be members of several
- groups simultaneously. If your system does,
- then there are elements `"group1"' through
- `"groupN"' in `PROCINFO' for those group ID
- numbers. (Note that `PROCINFO' is a `gawk'
- extension; *note Built-in Variables::.)
-
- Here is what running `grcat' might produce:
-
- $ grcat
- -| wheel:*:0:arnold
- -| nogroup:*:65534:
- -| daemon:*:1:
- -| kmem:*:2:
- -| staff:*:10:arnold,miriam,andy
- -| other:*:20:
- ...
-
- Here are the functions for obtaining information from the group
-database. There are several, modeled after the C library functions of
-the same names:
-
- # group.awk --- functions for dealing with the group file
- BEGIN \
- {
- # Change to suit your system
- _gr_awklib = "/usr/local/libexec/awk/"
- }
-
- function _gr_init( oldfs, oldrs, olddol0, grcat,
- using_fw, n, a, i)
- {
- if (_gr_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
- FS = ":"
- RS = "\n"
-
- grcat = _gr_awklib "grcat"
- while ((grcat | getline) > 0) {
- if ($1 in _gr_byname)
- _gr_byname[$1] = _gr_byname[$1] "," $4
- else
- _gr_byname[$1] = $0
- if ($3 in _gr_bygid)
- _gr_bygid[$3] = _gr_bygid[$3] "," $4
- else
- _gr_bygid[$3] = $0
-
- n = split($4, a, "[ \t]*,[ \t]*")
- for (i = 1; i <= n; i++)
- if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
- else
- _gr_groupsbyuser[a[i]] = $1
-
- _gr_bycount[++_gr_count] = $0
- }
- close(grcat)
- _gr_count = 0
- _gr_inited++
- FS = oldfs
- if (using_fw)
- FIELDWIDTHS = FIELDWIDTHS
- RS = oldrs
- $0 = olddol0
- }
-
- The `BEGIN' rule sets a private variable to the directory where
-`grcat' is stored. Because it is used to help out an `awk' library
-routine, we have chosen to put it in `/usr/local/libexec/awk'. You
-might want it to be in a different directory on your system.
-
- These routines follow the same general outline as the user database
-routines (*note Passwd Functions::). The `_gr_inited' variable is used
-to ensure that the database is scanned no more than once. The
-`_gr_init' function first saves `FS', `FIELDWIDTHS', `RS', and `$0',
-and then sets `FS' and `RS' to the correct values for scanning the
-group information.
-
- The group information is stored is several associative arrays. The
-arrays are indexed by group name (`_gr_byname'), by group ID number
-(`_gr_bygid'), and by position in the database (`_gr_bycount'). There
-is an additional array indexed by username (`_gr_groupsbyuser'), which
-is a space-separated list of groups to which each user belongs.
-
- Unlike the user database, it is possible to have multiple records in
-the database for the same group. This is common when a group has a
-large number of members. A pair of such entries might look like the
-following:
-
- tvpeople:*:101:johnny,jay,arsenio
- tvpeople:*:101:david,conan,tom,joan
-
- For this reason, `_gr_init' looks to see if a group name or group ID
-number is already seen. If it is, then the usernames are simply
-concatenated onto the previous list of users. (There is actually a
-subtle problem with the code just presented. Suppose that the first
-time there were no names. This code adds the names with a leading
-comma. It also doesn't check that there is a `$4'.)
-
- Finally, `_gr_init' closes the pipeline to `grcat', restores `FS'
-(and `FIELDWIDTHS' if necessary), `RS', and `$0', initializes
-`_gr_count' to zero (it is used later), and makes `_gr_inited' nonzero.
-
- The `getgrnam' function takes a group name as its argument, and if
-that group exists, it is returned. Otherwise, `getgrnam' returns the
-null string:
-
- function getgrnam(group)
- {
- _gr_init()
- if (group in _gr_byname)
- return _gr_byname[group]
- return ""
- }
-
- The `getgrgid' function is similar, it takes a numeric group ID and
-looks up the information associated with that group ID:
-
- function getgrgid(gid)
- {
- _gr_init()
- if (gid in _gr_bygid)
- return _gr_bygid[gid]
- return ""
- }
-
- The `getgruser' function does not have a C counterpart. It takes a
-username and returns the list of groups that have the user as a member:
-
- function getgruser(user)
- {
- _gr_init()
- if (user in _gr_groupsbyuser)
- return _gr_groupsbyuser[user]
- return ""
- }
-
- The `getgrent' function steps through the database one entry at a
-time. It uses `_gr_count' to track its position in the list:
-
- function getgrent()
- {
- _gr_init()
- if (++_gr_count in _gr_bycount)
- return _gr_bycount[_gr_count]
- return ""
- }
-
- The `endgrent' function resets `_gr_count' to zero so that
-`getgrent' can start over again:
-
- function endgrent()
- {
- _gr_count = 0
- }
-
- As with the user database routines, each function calls `_gr_init' to
-initialize the arrays. Doing so only incurs the extra overhead of
-running `grcat' if these functions are used (as opposed to moving the
-body of `_gr_init' into a `BEGIN' rule).
-
- Most of the work is in scanning the database and building the various
-associative arrays. The functions that the user calls are themselves
-very simple, relying on `awk''s associative arrays to do work.
-
- The `id' program in *Note Id Program::, uses these functions.
-
-13 Practical `awk' Programs
-***************************
-
-*Note Library Functions::, presents the idea that reading programs in a
-language contributes to learning that language. This major node
-continues that theme, presenting a potpourri of `awk' programs for your
-reading enjoyment.
-
- Many of these programs use the library functions presented in *Note
-Library Functions::.
-
-13.1 Running the Example Programs
-=================================
-
-To run a given program, you would typically do something like this:
-
- awk -f PROGRAM -- OPTIONS FILES
-
-Here, PROGRAM is the name of the `awk' program (such as `cut.awk'),
-OPTIONS are any command-line options for the program that start with a
-`-', and FILES are the actual data files.
-
- If your system supports the `#!' executable interpreter mechanism
-(*note Executable Scripts::), you can instead run your program directly:
-
- cut.awk -c1-8 myfiles > results
-
- If your `awk' is not `gawk', you may instead need to use this:
-
- cut.awk -- -c1-8 myfiles > results
-
-13.2 Reinventing Wheels for Fun and Profit
-==========================================
-
-This minor node presents a number of POSIX utilities that are
-implemented in `awk'. Reinventing these programs in `awk' is often
-enjoyable, because the algorithms can be very clearly expressed, and
-the code is usually very concise and simple. This is true because
-`awk' does so much for you.
-
- It should be noted that these programs are not necessarily intended
-to replace the installed versions on your system. Instead, their
-purpose is to illustrate `awk' language programming for "real world"
-tasks.
-
- The programs are presented in alphabetical order.
-
-13.2.1 Cutting out Fields and Columns
--------------------------------------
-
-The `cut' utility selects, or "cuts," characters or fields from its
-standard input and sends them to its standard output. Fields are
-separated by tabs by default, but you may supply a command-line option
-to change the field "delimiter" (i.e., the field-separator character).
-`cut''s definition of fields is less general than `awk''s.
-
- A common use of `cut' might be to pull out just the login name of
-logged-on users from the output of `who'. For example, the following
-pipeline generates a sorted, unique list of the logged-on users:
-
- who | cut -c1-8 | sort | uniq
-
- The options for `cut' are:
-
-`-c LIST'
- Use LIST as the list of characters to cut out. Items within the
- list may be separated by commas, and ranges of characters can be
- separated with dashes. The list `1-8,15,22-35' specifies
- characters 1 through 8, 15, and 22 through 35.
-
-`-f LIST'
- Use LIST as the list of fields to cut out.
-
-`-d DELIM'
- Use DELIM as the field-separator character instead of the tab
- character.
-
-`-s'
- Suppress printing of lines that do not contain the field delimiter.
-
- The `awk' implementation of `cut' uses the `getopt' library function
-(*note Getopt Function::) and the `join' library function (*note Join
-Function::).
-
- The program begins with a comment describing the options, the library
-functions needed, and a `usage' function that prints out a usage
-message and exits. `usage' is called if invalid arguments are supplied:
-
- # cut.awk --- implement cut in awk
- # Options:
- # -f list Cut fields
- # -d c Field delimiter character
- # -c list Cut characters
- #
- # -s Suppress lines without the delimiter
- #
- # Requires getopt and join library functions
-
- function usage( e1, e2)
- {
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
- exit 1
- }
-
-The variables `e1' and `e2' are used so that the function fits nicely
-on the screen.
-
- Next comes a `BEGIN' rule that parses the command-line options. It
-sets `FS' to a single TAB character, because that is `cut''s default
-field separator. The output field separator is also set to be the same
-as the input field separator. Then `getopt' is used to step through
-the command-line options. Exactly one of the variables `by_fields' or
-`by_chars' is set to true, to indicate that processing should be done
-by fields or by characters, respectively. When cutting by characters,
-the output field separator is set to the null string:
-
- BEGIN \
- {
- FS = "\t" # default
- OFS = FS
- while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) {
- if (c == "f") {
- by_fields = 1
- fieldlist = Optarg
- } else if (c == "c") {
- by_chars = 1
- fieldlist = Optarg
- OFS = ""
- } else if (c == "d") {
- if (length(Optarg) > 1) {
- printf("Using first character of %s" \
- " for delimiter\n", Optarg) > "/dev/stderr"
- Optarg = substr(Optarg, 1, 1)
- }
- FS = Optarg
- OFS = FS
- if (FS == " ") # defeat awk semantics
- FS = "[ ]"
- } else if (c == "s")
- suppress++
- else
- usage()
- }
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- Special care is taken when the field delimiter is a space. Using a
-single space (`" "') for the value of `FS' is incorrect--`awk' would
-separate fields with runs of spaces, tabs, and/or newlines, and we want
-them to be separated with individual spaces. Also, note that after
-`getopt' is through, we have to clear out all the elements of `ARGV'
-from 1 to `Optind', so that `awk' does not try to process the
-command-line options as file names.
-
- After dealing with the command-line options, the program verifies
-that the options make sense. Only one or the other of `-c' and `-f'
-should be used, and both require a field list. Then the program calls
-either `set_fieldlist' or `set_charlist' to pull apart the list of
-fields or characters:
-
- if (by_fields && by_chars)
- usage()
-
- if (by_fields == 0 && by_chars == 0)
- by_fields = 1 # default
-
- if (fieldlist == "") {
- print "cut: needs list for -c or -f" > "/dev/stderr"
- exit 1
- }
-
- if (by_fields)
- set_fieldlist()
- else
- set_charlist()
- }
-
- `set_fieldlist' is used to split the field list apart at the commas
-and into an array. Then, for each element of the array, it looks to
-see if it is actually a range, and if so, splits it apart. The range is
-verified to make sure the first number is smaller than the second.
-Each number in the list is added to the `flist' array, which simply
-lists the fields that will be printed. Normal field splitting is used.
-The program lets `awk' handle the job of doing the field splitting:
-
- function set_fieldlist( n, m, i, j, k, f, g)
- {
- n = split(fieldlist, f, ",")
- j = 1 # index in flist
- for (i = 1; i <= n; i++) {
- if (index(f[i], "-") != 0) { # a range
- m = split(f[i], g, "-")
- if (m != 2 || g[1] >= g[2]) {
- printf("bad field list: %s\n",
- f[i]) > "/dev/stderr"
- exit 1
- }
- for (k = g[1]; k <= g[2]; k++)
- flist[j++] = k
- } else
- flist[j++] = f[i]
- }
- nfields = j - 1
- }
-
- The `set_charlist' function is more complicated than `set_fieldlist'.
-The idea here is to use `gawk''s `FIELDWIDTHS' variable (*note Constant
-Size::), which describes constant-width input. When using a character
-list, that is exactly what we have.
-
- Setting up `FIELDWIDTHS' is more complicated than simply listing the
-fields that need to be printed. We have to keep track of the fields to
-print and also the intervening characters that have to be skipped. For
-example, suppose you wanted characters 1 through 8, 15, and 22 through
-35. You would use `-c 1-8,15,22-35'. The necessary value for
-`FIELDWIDTHS' is `"8 6 1 6 14"'. This yields five fields, and the
-fields to print are `$1', `$3', and `$5'. The intermediate fields are
-"filler", which is stuff in between the desired data. `flist' lists
-the fields to print, and `t' tracks the complete field list, including
-filler fields:
-
- function set_charlist( field, i, j, f, g, t,
- filler, last, len)
- {
- field = 1 # count total fields
- n = split(fieldlist, f, ",")
- j = 1 # index in flist
- for (i = 1; i <= n; i++) {
- if (index(f[i], "-") != 0) { # range
- m = split(f[i], g, "-")
- if (m != 2 || g[1] >= g[2]) {
- printf("bad character list: %s\n",
- f[i]) > "/dev/stderr"
- exit 1
- }
- len = g[2] - g[1] + 1
- if (g[1] > 1) # compute length of filler
- filler = g[1] - last - 1
- else
- filler = 0
- if (filler)
- t[field++] = filler
- t[field++] = len # length of field
- last = g[2]
- flist[j++] = field - 1
- } else {
- if (f[i] > 1)
- filler = f[i] - last - 1
- else
- filler = 0
- if (filler)
- t[field++] = filler
- t[field++] = 1
- last = f[i]
- flist[j++] = field - 1
- }
- }
- FIELDWIDTHS = join(t, 1, field - 1)
- nfields = j - 1
- }
-
- Next is the rule that actually processes the data. If the `-s'
-option is given, then `suppress' is true. The first `if' statement
-makes sure that the input record does have the field separator. If
-`cut' is processing fields, `suppress' is true, and the field separator
-character is not in the record, then the record is skipped.
-
- If the record is valid, then `gawk' has split the data into fields,
-either using the character in `FS' or using fixed-length fields and
-`FIELDWIDTHS'. The loop goes through the list of fields that should be
-printed. The corresponding field is printed if it contains data. If
-the next field also has data, then the separator character is written
-out between the fields:
-
- {
- if (by_fields && suppress && index($0, FS) != 0)
- next
-
- for (i = 1; i <= nfields; i++) {
- if ($flist[i] != "") {
- printf "%s", $flist[i]
- if (i < nfields && $flist[i+1] != "")
- printf "%s", OFS
- }
- }
- print ""
- }
-
- This version of `cut' relies on `gawk''s `FIELDWIDTHS' variable to
-do the character-based cutting. While it is possible in other `awk'
-implementations to use `substr' (*note String Functions::), it is also
-extremely painful. The `FIELDWIDTHS' variable supplies an elegant
-solution to the problem of picking the input line apart by characters.
-
-13.2.2 Searching for Regular Expressions in Files
--------------------------------------------------
-
-The `egrep' utility searches files for patterns. It uses regular
-expressions that are almost identical to those available in `awk'
-(*note Regexp::). It is used in the following manner:
-
- egrep [ OPTIONS ] 'PATTERN' FILES ...
-
- The PATTERN is a regular expression. In typical usage, the regular
-expression is quoted to prevent the shell from expanding any of the
-special characters as file name wildcards. Normally, `egrep' prints
-the lines that matched. If multiple file names are provided on the
-command line, each output line is preceded by the name of the file and
-a colon.
-
- The options to `egrep' are as follows:
-
-`-c'
- Print out a count of the lines that matched the pattern, instead
- of the lines themselves.
-
-`-s'
- Be silent. No output is produced and the exit value indicates
- whether the pattern was matched.
-
-`-v'
- Invert the sense of the test. `egrep' prints the lines that do
- _not_ match the pattern and exits successfully if the pattern is
- not matched.
-
-`-i'
- Ignore case distinctions in both the pattern and the input data.
-
-`-l'
- Only print (list) the names of the files that matched, not the
- lines that matched.
-
-`-e PATTERN'
- Use PATTERN as the regexp to match. The purpose of the `-e'
- option is to allow patterns that start with a `-'.
-
- This version uses the `getopt' library function (*note Getopt
-Function::) and the file transition library program (*note Filetrans
-Function::).
-
- The program begins with a descriptive comment and then a `BEGIN' rule
-that processes the command-line arguments with `getopt'. The `-i'
-(ignore case) option is particularly easy with `gawk'; we just use the
-`IGNORECASE' built-in variable (*note Built-in Variables::):
-
- # egrep.awk --- simulate egrep in awk
- # Options:
- # -c count of lines
- # -s silent - use exit value
- # -v invert test, success if no match
- # -i ignore case
- # -l print filenames only
- # -e argument is pattern
- #
- # Requires getopt and file transition library functions
-
- BEGIN {
- while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) {
- if (c == "c")
- count_only++
- else if (c == "s")
- no_print++
- else if (c == "v")
- invert++
- else if (c == "i")
- IGNORECASE = 1
- else if (c == "l")
- filenames_only++
- else if (c == "e")
- pattern = Optarg
- else
- usage()
- }
-
- Next comes the code that handles the `egrep'-specific behavior. If no
-pattern is supplied with `-e', the first nonoption on the command line
-is used. The `awk' command-line arguments up to `ARGV[Optind]' are
-cleared, so that `awk' won't try to process them as files. If no files
-are specified, the standard input is used, and if multiple files are
-specified, we make sure to note this so that the file names can precede
-the matched lines in the output:
-
- if (pattern == "")
- pattern = ARGV[Optind++]
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
- if (Optind >= ARGC) {
- ARGV[1] = "-"
- ARGC = 2
- } else if (ARGC - Optind > 1)
- do_filenames++
-
- # if (IGNORECASE)
- # pattern = tolower(pattern)
- }
-
- The last two lines are commented out, since they are not needed in
-`gawk'. They should be uncommented if you have to use another version
-of `awk'.
-
- The next set of lines should be uncommented if you are not using
-`gawk'. This rule translates all the characters in the input line into
-lowercase if the `-i' option is specified.(1) The rule is commented out
-since it is not necessary with `gawk':
-
- #{
- # if (IGNORECASE)
- # $0 = tolower($0)
- #}
-
- The `beginfile' function is called by the rule in `ftrans.awk' when
-each new file is processed. In this case, it is very simple; all it
-does is initialize a variable `fcount' to zero. `fcount' tracks how
-many lines in the current file matched the pattern (naming the
-parameter `junk' shows we know that `beginfile' is called with a
-parameter, but that we're not interested in its value):
-
- function beginfile(junk)
- {
- fcount = 0
- }
-
- The `endfile' function is called after each file has been processed.
-It affects the output only when the user wants a count of the number of
-lines that matched. `no_print' is true only if the exit status is
-desired. `count_only' is true if line counts are desired. `egrep'
-therefore only prints line counts if printing and counting are enabled.
-The output format must be adjusted depending upon the number of files to
-process. Finally, `fcount' is added to `total', so that we know the
-total number of lines that matched the pattern:
-
- function endfile(file)
- {
- if (! no_print && count_only)
- if (do_filenames)
- print file ":" fcount
- else
- print fcount
-
- total += fcount
- }
-
- The following rule does most of the work of matching lines. The
-variable `matches' is true if the line matched the pattern. If the user
-wants lines that did not match, the sense of `matches' is inverted
-using the `!' operator. `fcount' is incremented with the value of
-`matches', which is either one or zero, depending upon a successful or
-unsuccessful match. If the line does not match, the `next' statement
-just moves on to the next record.
-
- A number of additional tests are made, but they are only done if we
-are not counting lines. First, if the user only wants exit status
-(`no_print' is true), then it is enough to know that _one_ line in this
-file matched, and we can skip on to the next file with `nextfile'.
-Similarly, if we are only printing file names, we can print the file
-name, and then skip to the next file with `nextfile'. Finally, each
-line is printed, with a leading file name and colon if necessary:
-
- {
- matches = ($0 ~ pattern)
- if (invert)
- matches = ! matches
-
- fcount += matches # 1 or 0
-
- if (! matches)
- next
-
- if (! count_only) {
- if (no_print)
- nextfile
-
- if (filenames_only) {
- print FILENAME
- nextfile
- }
-
- if (do_filenames)
- print FILENAME ":" $0
- else
- print
- }
- }
-
- The `END' rule takes care of producing the correct exit status. If
-there are no matches, the exit status is one; otherwise it is zero:
-
- END \
- {
- if (total == 0)
- exit 1
- exit 0
- }
-
- The `usage' function prints a usage message in case of invalid
-options, and then exits:
-
- function usage( e)
- {
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
- exit 1
- }
-
- The variable `e' is used so that the function fits nicely on the
-printed page.
-
- Just a note on programming style: you may have noticed that the `END'
-rule uses backslash continuation, with the open brace on a line by
-itself. This is so that it more closely resembles the way functions
-are written. Many of the examples in this major node use this style.
-You can decide for yourself if you like writing your `BEGIN' and `END'
-rules this way or not.
-
- ---------- Footnotes ----------
-
- (1) It also introduces a subtle bug; if a match happens, we output
-the translated line, not the original.
-
-13.2.3 Printing out User Information
-------------------------------------
-
-The `id' utility lists a user's real and effective user ID numbers,
-real and effective group ID numbers, and the user's group set, if any.
-`id' only prints the effective user ID and group ID if they are
-different from the real ones. If possible, `id' also supplies the
-corresponding user and group names. The output might look like this:
-
- $ id
- -| uid=2076(arnold) gid=10(staff) groups=10(staff),4(tty)
-
- This information is part of what is provided by `gawk''s `PROCINFO'
-array (*note Built-in Variables::). However, the `id' utility provides
-a more palatable output than just individual numbers.
-
- Here is a simple version of `id' written in `awk'. It uses the user
-database library functions (*note Passwd Functions::) and the group
-database library functions (*note Group Functions::):
-
- The program is fairly straightforward. All the work is done in the
-`BEGIN' rule. The user and group ID numbers are obtained from
-`PROCINFO'. The code is repetitive. The entry in the user database
-for the real user ID number is split into parts at the `:'. The name is
-the first field. Similar code is used for the effective user ID number
-and the group numbers:
-
- # id.awk --- implement id in awk
- #
- # Requires user and group library functions
- # output is:
- # uid=12(foo) euid=34(bar) gid=3(baz) \
- # egid=5(blat) groups=9(nine),2(two),1(one)
-
- BEGIN \
- {
- uid = PROCINFO["uid"]
- euid = PROCINFO["euid"]
- gid = PROCINFO["gid"]
- egid = PROCINFO["egid"]
-
- printf("uid=%d", uid)
- pw = getpwuid(uid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
-
- if (euid != uid) {
- printf(" euid=%d", euid)
- pw = getpwuid(euid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- }
-
- printf(" gid=%d", gid)
- pw = getgrgid(gid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
-
- if (egid != gid) {
- printf(" egid=%d", egid)
- pw = getgrgid(egid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- }
-
- for (i = 1; ("group" i) in PROCINFO; i++) {
- if (i == 1)
- printf(" groups=")
- group = PROCINFO["group" i]
- printf("%d", group)
- pw = getgrgid(group)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- if (("group" (i+1)) in PROCINFO)
- printf(",")
- }
-
- print ""
- }
-
- The test in the `for' loop is worth noting. Any supplementary
-groups in the `PROCINFO' array have the indices `"group1"' through
-`"groupN"' for some N, i.e., the total number of supplementary groups.
-However, we don't know in advance how many of these groups there are.
-
- This loop works by starting at one, concatenating the value with
-`"group"', and then using `in' to see if that value is in the array.
-Eventually, `i' is incremented past the last group in the array and the
-loop exits.
-
- The loop is also correct if there are _no_ supplementary groups;
-then the condition is false the first time it's tested, and the loop
-body never executes.
-
-13.2.4 Splitting a Large File into Pieces
------------------------------------------
-
-The `split' program splits large text files into smaller pieces. Usage
-is as follows:
-
- split [-COUNT] file [ PREFIX ]
-
- By default, the output files are named `xaa', `xab', and so on. Each
-file has 1000 lines in it, with the likely exception of the last file.
-To change the number of lines in each file, supply a number on the
-command line preceded with a minus; e.g., `-500' for files with 500
-lines in them instead of 1000. To change the name of the output files
-to something like `myfileaa', `myfileab', and so on, supply an
-additional argument that specifies the file name prefix.
-
- Here is a version of `split' in `awk'. It uses the `ord' and `chr'
-functions presented in *Note Ordinal Functions::.
-
- The program first sets its defaults, and then tests to make sure
-there are not too many arguments. It then looks at each argument in
-turn. The first argument could be a minus sign followed by a number.
-If it is, this happens to look like a negative number, so it is made
-positive, and that is the count of lines. The data file name is
-skipped over and the final argument is used as the prefix for the
-output file names:
-
- # split.awk --- do split in awk
- #
- # Requires ord and chr library functions
- # usage: split [-num] [file] [outname]
-
- BEGIN {
- outfile = "x" # default
- count = 1000
- if (ARGC > 4)
- usage()
-
- i = 1
- if (ARGV[i] ~ /^-[0-9]+$/) {
- count = -ARGV[i]
- ARGV[i] = ""
- i++
- }
- # test argv in case reading from stdin instead of file
- if (i in ARGV)
- i++ # skip data file name
- if (i in ARGV) {
- outfile = ARGV[i]
- ARGV[i] = ""
- }
-
- s1 = s2 = "a"
- out = (outfile s1 s2)
- }
-
- The next rule does most of the work. `tcount' (temporary count)
-tracks how many lines have been printed to the output file so far. If
-it is greater than `count', it is time to close the current file and
-start a new one. `s1' and `s2' track the current suffixes for the file
-name. If they are both `z', the file is just too big. Otherwise, `s1'
-moves to the next letter in the alphabet and `s2' starts over again at
-`a':
-
- {
- if (++tcount > count) {
- close(out)
- if (s2 == "z") {
- if (s1 == "z") {
- printf("split: %s is too large to split\n",
- FILENAME) > "/dev/stderr"
- exit 1
- }
- s1 = chr(ord(s1) + 1)
- s2 = "a"
- }
- else
- s2 = chr(ord(s2) + 1)
- out = (outfile s1 s2)
- tcount = 1
- }
- print > out
- }
-
-The `usage' function simply prints an error message and exits:
-
- function usage( e)
- {
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
- exit 1
- }
-
-The variable `e' is used so that the function fits nicely on the screen.
-
- This program is a bit sloppy; it relies on `awk' to automatically
-close the last file instead of doing it in an `END' rule. It also
-assumes that letters are contiguous in the character set, which isn't
-true for EBCDIC systems.
-
-13.2.5 Duplicating Output into Multiple Files
----------------------------------------------
-
-The `tee' program is known as a "pipe fitting." `tee' copies its
-standard input to its standard output and also duplicates it to the
-files named on the command line. Its usage is as follows:
-
- tee [-a] file ...
-
- The `-a' option tells `tee' to append to the named files, instead of
-truncating them and starting over.
-
- The `BEGIN' rule first makes a copy of all the command-line arguments
-into an array named `copy'. `ARGV[0]' is not copied, since it is not
-needed. `tee' cannot use `ARGV' directly, since `awk' attempts to
-process each file name in `ARGV' as input data.
-
- If the first argument is `-a', then the flag variable `append' is
-set to true, and both `ARGV[1]' and `copy[1]' are deleted. If `ARGC' is
-less than two, then no file names were supplied and `tee' prints a
-usage message and exits. Finally, `awk' is forced to read the standard
-input by setting `ARGV[1]' to `"-"' and `ARGC' to two:
-
- # tee.awk --- tee in awk
- BEGIN \
- {
- for (i = 1; i < ARGC; i++)
- copy[i] = ARGV[i]
-
- if (ARGV[1] == "-a") {
- append = 1
- delete ARGV[1]
- delete copy[1]
- ARGC--
- }
- if (ARGC < 2) {
- print "usage: tee [-a] file ..." > "/dev/stderr"
- exit 1
- }
- ARGV[1] = "-"
- ARGC = 2
- }
-
- The single rule does all the work. Since there is no pattern, it is
-executed for each line of input. The body of the rule simply prints the
-line into each file on the command line, and then to the standard
-output:
-
- {
- # moving the if outside the loop makes it run faster
- if (append)
- for (i in copy)
- print >> copy[i]
- else
- for (i in copy)
- print > copy[i]
- print
- }
-
-It is also possible to write the loop this way:
-
- for (i in copy)
- if (append)
- print >> copy[i]
- else
- print > copy[i]
-
-This is more concise but it is also less efficient. The `if' is tested
-for each record and for each output file. By duplicating the loop
-body, the `if' is only tested once for each input record. If there are
-N input records and M output files, the first method only executes N
-`if' statements, while the second executes N`*'M `if' statements.
-
- Finally, the `END' rule cleans up by closing all the output files:
-
- END \
- {
- for (i in copy)
- close(copy[i])
- }
-
-13.2.6 Printing Nonduplicated Lines of Text
--------------------------------------------
-
-The `uniq' utility reads sorted lines of data on its standard input,
-and by default removes duplicate lines. In other words, it only prints
-unique lines--hence the name. `uniq' has a number of options. The
-usage is as follows:
-
- uniq [-udc [-N]] [+N] [ INPUT FILE [ OUTPUT FILE ]]
-
- The options for `uniq' are:
-
-`-d'
- Pnly print only repeated lines.
-
-`-u'
- Print only nonrepeated lines.
-
-`-c'
- Count lines. This option overrides `-d' and `-u'. Both repeated
- and nonrepeated lines are counted.
-
-`-N'
- Skip N fields before comparing lines. The definition of fields is
- similar to `awk''s default: nonwhitespace characters separated by
- runs of spaces and/or tabs.
-
-`+N'
- Skip N characters before comparing lines. Any fields specified
- with `-N' are skipped first.
-
-`INPUT FILE'
- Data is read from the input file named on the command line,
- instead of from the standard input.
-
-`OUTPUT FILE'
- The generated output is sent to the named output file, instead of
- to the standard output.
-
- Normally `uniq' behaves as if both the `-d' and `-u' options are
-provided.
-
- `uniq' uses the `getopt' library function (*note Getopt Function::)
-and the `join' library function (*note Join Function::).
-
- The program begins with a `usage' function and then a brief outline
-of the options and their meanings in a comment. The `BEGIN' rule deals
-with the command-line arguments and options. It uses a trick to get
-`getopt' to handle options of the form `-25', treating such an option
-as the option letter `2' with an argument of `5'. If indeed two or more
-digits are supplied (`Optarg' looks like a number), `Optarg' is
-concatenated with the option digit and then the result is added to zero
-to make it into a number. If there is only one digit in the option,
-then `Optarg' is not needed. In this case, `Optind' must be decremented
-so that `getopt' processes it next time. This code is admittedly a bit
-tricky.
-
- If no options are supplied, then the default is taken, to print both
-repeated and nonrepeated lines. The output file, if provided, is
-assigned to `outputfile'. Early on, `outputfile' is initialized to the
-standard output, `/dev/stdout':
-
- # uniq.awk --- do uniq in awk
- #
- # Requires getopt and join library functions
- function usage( e)
- {
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
- exit 1
- }
-
- # -c count lines. overrides -d and -u
- # -d only repeated lines
- # -u only non-repeated lines
- # -n skip n fields
- # +n skip n characters, skip fields first
-
- BEGIN \
- {
- count = 1
- outputfile = "/dev/stdout"
- opts = "udc0:1:2:3:4:5:6:7:8:9:"
- while ((c = getopt(ARGC, ARGV, opts)) != -1) {
- if (c == "u")
- non_repeated_only++
- else if (c == "d")
- repeated_only++
- else if (c == "c")
- do_count++
- else if (index("0123456789", c) != 0) {
- # getopt requires args to options
- # this messes us up for things like -5
- if (Optarg ~ /^[0-9]+$/)
- fcount = (c Optarg) + 0
- else {
- fcount = c + 0
- Optind--
- }
- } else
- usage()
- }
-
- if (ARGV[Optind] ~ /^\+[0-9]+$/) {
- charcount = substr(ARGV[Optind], 2) + 0
- Optind++
- }
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- if (repeated_only == 0 && non_repeated_only == 0)
- repeated_only = non_repeated_only = 1
-
- if (ARGC - Optind == 2) {
- outputfile = ARGV[ARGC - 1]
- ARGV[ARGC - 1] = ""
- }
- }
-
- The following function, `are_equal', compares the current line,
-`$0', to the previous line, `last'. It handles skipping fields and
-characters. If no field count and no character count are specified,
-`are_equal' simply returns one or zero depending upon the result of a
-simple string comparison of `last' and `$0'. Otherwise, things get more
-complicated. If fields have to be skipped, each line is broken into an
-array using `split' (*note String Functions::); the desired fields are
-then joined back into a line using `join'. The joined lines are stored
-in `clast' and `cline'. If no fields are skipped, `clast' and `cline'
-are set to `last' and `$0', respectively. Finally, if characters are
-skipped, `substr' is used to strip off the leading `charcount'
-characters in `clast' and `cline'. The two strings are then compared
-and `are_equal' returns the result:
-
- function are_equal( n, m, clast, cline, alast, aline)
- {
- if (fcount == 0 && charcount == 0)
- return (last == $0)
-
- if (fcount > 0) {
- n = split(last, alast)
- m = split($0, aline)
- clast = join(alast, fcount+1, n)
- cline = join(aline, fcount+1, m)
- } else {
- clast = last
- cline = $0
- }
- if (charcount) {
- clast = substr(clast, charcount + 1)
- cline = substr(cline, charcount + 1)
- }
-
- return (clast == cline)
- }
-
- The following two rules are the body of the program. The first one
-is executed only for the very first line of data. It sets `last' equal
-to `$0', so that subsequent lines of text have something to be compared
-to.
-
- The second rule does the work. The variable `equal' is one or zero,
-depending upon the results of `are_equal''s comparison. If `uniq' is
-counting repeated lines, and the lines are equal, then it increments
-the `count' variable. Otherwise, it prints the line and resets `count',
-since the two lines are not equal.
-
- If `uniq' is not counting, and if the lines are equal, `count' is
-incremented. Nothing is printed, since the point is to remove
-duplicates. Otherwise, if `uniq' is counting repeated lines and more
-than one line is seen, or if `uniq' is counting nonrepeated lines and
-only one line is seen, then the line is printed, and `count' is reset.
-
- Finally, similar logic is used in the `END' rule to print the final
-line of input data:
-
- NR == 1 {
- last = $0
- next
- }
-
- {
- equal = are_equal()
-
- if (do_count) { # overrides -d and -u
- if (equal)
- count++
- else {
- printf("%4d %s\n", count, last) > outputfile
- last = $0
- count = 1 # reset
- }
- next
- }
-
- if (equal)
- count++
- else {
- if ((repeated_only && count > 1) ||
- (non_repeated_only && count == 1))
- print last > outputfile
- last = $0
- count = 1
- }
- }
-
- END {
- if (do_count)
- printf("%4d %s\n", count, last) > outputfile
- else if ((repeated_only && count > 1) ||
- (non_repeated_only && count == 1))
- print last > outputfile
- }
-
-13.2.7 Counting Things
-----------------------
-
-The `wc' (word count) utility counts lines, words, and characters in
-one or more input files. Its usage is as follows:
-
- wc [-lwc] [ FILES ... ]
-
- If no files are specified on the command line, `wc' reads its
-standard input. If there are multiple files, it also prints total
-counts for all the files. The options and their meanings are shown in
-the following list:
-
-`-l'
- Count only lines.
-
-`-w'
- Count only words. A "word" is a contiguous sequence of
- nonwhitespace characters, separated by spaces and/or tabs.
- Luckily, this is the normal way `awk' separates fields in its
- input data.
-
-`-c'
- Count only characters.
-
- Implementing `wc' in `awk' is particularly elegant, since `awk' does
-a lot of the work for us; it splits lines into words (i.e., fields) and
-counts them, it counts lines (i.e., records), and it can easily tell us
-how long a line is.
-
- This uses the `getopt' library function (*note Getopt Function::)
-and the file-transition functions (*note Filetrans Function::).
-
- This version has one notable difference from traditional versions of
-`wc': it always prints the counts in the order lines, words, and
-characters. Traditional versions note the order of the `-l', `-w', and
-`-c' options on the command line, and print the counts in that order.
-
- The `BEGIN' rule does the argument processing. The variable
-`print_total' is true if more than one file is named on the command
-line:
-
- # wc.awk --- count lines, words, characters
-
- # Options:
- # -l only count lines
- # -w only count words
- # -c only count characters
- #
- # Default is to count lines, words, characters
- #
- # Requires getopt and file transition library functions
-
- BEGIN {
- # let getopt print a message about
- # invalid options. we ignore them
- while ((c = getopt(ARGC, ARGV, "lwc")) != -1) {
- if (c == "l")
- do_lines = 1
- else if (c == "w")
- do_words = 1
- else if (c == "c")
- do_chars = 1
- }
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- # if no options, do all
- if (! do_lines && ! do_words && ! do_chars)
- do_lines = do_words = do_chars = 1
-
- print_total = (ARGC - i > 2)
- }
-
- The `beginfile' function is simple; it just resets the counts of
-lines, words, and characters to zero, and saves the current file name in
-`fname':
-
- function beginfile(file)
- {
- chars = lines = words = 0
- fname = FILENAME
- }
-
- The `endfile' function adds the current file's numbers to the running
-totals of lines, words, and characters.(1) It then prints out those
-numbers for the file that was just read. It relies on `beginfile' to
-reset the numbers for the following data file:
-
- function endfile(file)
- {
- tchars += chars
- tlines += lines
- twords += words
- if (do_lines)
- printf "\t%d", lines
- if (do_words)
- printf "\t%d", words
- if (do_chars)
- printf "\t%d", chars
- printf "\t%s\n", fname
- }
-
- There is one rule that is executed for each line. It adds the length
-of the record, plus one, to `chars'. Adding one plus the record length
-is needed because the newline character separating records (the value
-of `RS') is not part of the record itself, and thus not included in its
-length. Next, `lines' is incremented for each line read, and `words'
-is incremented by the value of `NF', which is the number of "words" on
-this line:
-
- # do per line
- {
- chars += length($0) + 1 # get newline
- lines++
- words += NF
- }
-
- Finally, the `END' rule simply prints the totals for all the files:
-
- END {
- if (print_total) {
- if (do_lines)
- printf "\t%d", tlines
- if (do_words)
- printf "\t%d", twords
- if (do_chars)
- printf "\t%d", tchars
- print "\ttotal"
- }
- }
-
- ---------- Footnotes ----------
-
- (1) `wc' can't just use the value of `FNR' in `endfile'. If you
-examine the code in *Note Filetrans Function::, you will see that `FNR'
-has already been reset by the time `endfile' is called.
-
-13.3 A Grab Bag of `awk' Programs
-=================================
-
-This minor node is a large "grab bag" of miscellaneous programs. We
-hope you find them both interesting and enjoyable.
-
-13.3.1 Finding Duplicated Words in a Document
----------------------------------------------
-
-A common error when writing large amounts of prose is to accidentally
-duplicate words. Typically you will see this in text as something like
-"the the program does the following..." When the text is online, often
-the duplicated words occur at the end of one line and the beginning of
-another, making them very difficult to spot.
-
- This program, `dupword.awk', scans through a file one line at a time
-and looks for adjacent occurrences of the same word. It also saves the
-last word on a line (in the variable `prev') for comparison with the
-first word on the next line.
-
- The first two statements make sure that the line is all lowercase,
-so that, for example, "The" and "the" compare equal to each other. The
-next statement replaces nonalphanumeric and nonwhitespace characters
-with spaces, so that punctuation does not affect the comparison either.
-The characters are replaced with spaces so that formatting controls
-don't create nonsense words (e.g., the Texinfo address@hidden' becomes
-`codeNF' if punctuation is simply deleted). The record is then resplit
-into fields, yielding just the actual words on the line, and ensuring
-that there are no empty fields.
-
- If there are no fields left after removing all the punctuation, the
-current record is skipped. Otherwise, the program loops through each
-word, comparing it to the previous one:
-
- # dupword.awk --- find duplicate words in text
- {
- $0 = tolower($0)
- gsub(/[^[:alnum:][:blank:]]/, " ");
- $0 = $0 # re-split
- if (NF == 0)
- next
- if ($1 == prev)
- printf("%s:%d: duplicate %s\n",
- FILENAME, FNR, $1)
- for (i = 2; i <= NF; i++)
- if ($i == $(i-1))
- printf("%s:%d: duplicate %s\n",
- FILENAME, FNR, $i)
- prev = $NF
- }
-
-13.3.2 An Alarm Clock Program
------------------------------
-
- Nothing cures insomnia like a ringing alarm clock.
- Arnold Robbins
-
- The following program is a simple "alarm clock" program. You give
-it a time of day and an optional message. At the specified time, it
-prints the message on the standard output. In addition, you can give it
-the number of times to repeat the message as well as a delay between
-repetitions.
-
- This program uses the `gettimeofday' function from *Note
-Gettimeofday Function::.
-
- All the work is done in the `BEGIN' rule. The first part is argument
-checking and setting of defaults: the delay, the count, and the message
-to print. If the user supplied a message without the ASCII BEL
-character (known as the "alert" character, `"\a"'), then it is added to
-the message. (On many systems, printing the ASCII BEL generates an
-audible alert. Thus when the alarm goes off, the system calls attention
-to itself in case the user is not looking at the computer or terminal.)
-Here is the program:
-
- # alarm.awk --- set an alarm
- #
- # Requires gettimeofday library function
- # usage: alarm time [ "message" [ count [ delay ] ] ]
-
- BEGIN \
- {
- # Initial argument sanity checking
- usage1 = "usage: alarm time ['message' [count [delay]]]"
- usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1])
-
- if (ARGC < 2) {
- print usage1 > "/dev/stderr"
- print usage2 > "/dev/stderr"
- exit 1
- } else if (ARGC == 5) {
- delay = ARGV[4] + 0
- count = ARGV[3] + 0
- message = ARGV[2]
- } else if (ARGC == 4) {
- count = ARGV[3] + 0
- message = ARGV[2]
- } else if (ARGC == 3) {
- message = ARGV[2]
- } else if (ARGV[1] !~ /[0-9]?[0-9]:[0-9][0-9]/) {
- print usage1 > "/dev/stderr"
- print usage2 > "/dev/stderr"
- exit 1
- }
-
- # set defaults for once we reach the desired time
- if (delay == 0)
- delay = 180 # 3 minutes
- if (count == 0)
- count = 5
- if (message == "")
- message = sprintf("\aIt is now %s!\a", ARGV[1])
- else if (index(message, "\a") == 0)
- message = "\a" message "\a"
-
- The next minor node of code turns the alarm time into hours and
-minutes, converts it (if necessary) to a 24-hour clock, and then turns
-that time into a count of the seconds since midnight. Next it turns
-the current time into a count of seconds since midnight. The
-difference between the two is how long to wait before setting off the
-alarm:
-
- # split up alarm time
- split(ARGV[1], atime, ":")
- hour = atime[1] + 0 # force numeric
- minute = atime[2] + 0 # force numeric
-
- # get current broken down time
- gettimeofday(now)
-
- # if time given is 12-hour hours and it's after that
- # hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m.,
- # then add 12 to real hour
- if (hour < 12 && now["hour"] > hour)
- hour += 12
-
- # set target time in seconds since midnight
- target = (hour * 60 * 60) + (minute * 60)
-
- # get current time in seconds since midnight
- current = (now["hour"] * 60 * 60) + \
- (now["minute"] * 60) + now["second"]
-
- # how long to sleep for
- naptime = target - current
- if (naptime <= 0) {
- print "time is in the past!" > "/dev/stderr"
- exit 1
- }
-
- Finally, the program uses the `system' function (*note I/O
-Functions::) to call the `sleep' utility. The `sleep' utility simply
-pauses for the given number of seconds. If the exit status is not zero,
-the program assumes that `sleep' was interrupted and exits. If `sleep'
-exited with an OK status (zero), then the program prints the message in
-a loop, again using `sleep' to delay for however many seconds are
-necessary:
-
- # zzzzzz..... go away if interrupted
- if (system(sprintf("sleep %d", naptime)) != 0)
- exit 1
-
- # time to notify!
- command = sprintf("sleep %d", delay)
- for (i = 1; i <= count; i++) {
- print message
- # if sleep command interrupted, go away
- if (system(command) != 0)
- break
- }
-
- exit 0
- }
-
-13.3.3 Transliterating Characters
----------------------------------
-
-The system `tr' utility transliterates characters. For example, it is
-often used to map uppercase letters into lowercase for further
-processing:
-
- GENERATE DATA | tr 'A-Z' 'a-z' | PROCESS DATA ...
-
- `tr' requires two lists of characters.(1) When processing the
-input, the first character in the first list is replaced with the first
-character in the second list, the second character in the first list is
-replaced with the second character in the second list, and so on. If
-there are more characters in the "from" list than in the "to" list, the
-last character of the "to" list is used for the remaining characters in
-the "from" list.
-
- Some time ago, a user proposed that a transliteration function should
-be added to `gawk'. The following program was written to prove that
-character transliteration could be done with a user-level function.
-This program is not as complete as the system `tr' utility but it does
-most of the job.
-
- The `translate' program demonstrates one of the few weaknesses of
-standard `awk': dealing with individual characters is very painful,
-requiring repeated use of the `substr', `index', and `gsub' built-in
-functions (*note String Functions::).(2) There are two functions. The
-first, `stranslate', takes three arguments:
-
-`from'
- A list of characters from which to translate.
-
-`to'
- A list of characters to which to translate.
-
-`target'
- The string on which to do the translation.
-
- Associative arrays make the translation part fairly easy. `t_ar'
-holds the "to" characters, indexed by the "from" characters. Then a
-simple loop goes through `from', one character at a time. For each
-character in `from', if the character appears in `target', `gsub' is
-used to change it to the corresponding `to' character.
-
- The `translate' function simply calls `stranslate' using `$0' as the
-target. The main program sets two global variables, `FROM' and `TO',
-from the command line, and then changes `ARGV' so that `awk' reads from
-the standard input.
-
- Finally, the processing rule simply calls `translate' for each
-record:
-
- # translate.awk --- do tr-like stuff
- # Bugs: does not handle things like: tr A-Z a-z, it has
- # to be spelled out. However, if `to' is shorter than `from',
- # the last character in `to' is used for the rest of `from'.
-
- function stranslate(from, to, target, lf, lt, t_ar, i, c)
- {
- lf = length(from)
- lt = length(to)
- for (i = 1; i <= lt; i++)
- t_ar[substr(from, i, 1)] = substr(to, i, 1)
- if (lt < lf)
- for (; i <= lf; i++)
- t_ar[substr(from, i, 1)] = substr(to, lt, 1)
- for (i = 1; i <= lf; i++) {
- c = substr(from, i, 1)
- if (index(target, c) > 0)
- gsub(c, t_ar[c], target)
- }
- return target
- }
-
- function translate(from, to)
- {
- return $0 = stranslate(from, to, $0)
- }
-
- # main program
- BEGIN {
- if (ARGC < 3) {
- print "usage: translate from to" > "/dev/stderr"
- exit
- }
- FROM = ARGV[1]
- TO = ARGV[2]
- ARGC = 2
- ARGV[1] = "-"
- }
-
- {
- translate(FROM, TO)
- print
- }
-
- While it is possible to do character transliteration in a user-level
-function, it is not necessarily efficient, and we (the `gawk' authors)
-started to consider adding a built-in function. However, shortly after
-writing this program, we learned that the System V Release 4 `awk' had
-added the `toupper' and `tolower' functions (*note String Functions::).
-These functions handle the vast majority of the cases where character
-transliteration is necessary, and so we chose to simply add those
-functions to `gawk' as well and then leave well enough alone.
-
- An obvious improvement to this program would be to set up the `t_ar'
-array only once, in a `BEGIN' rule. However, this assumes that the
-"from" and "to" lists will never change throughout the lifetime of the
-program.
-
- ---------- Footnotes ----------
-
- (1) On some older System V systems, `tr' may require that the lists
-be written as range expressions enclosed in square brackets (`[a-z]')
-and quoted, to prevent the shell from attempting a file name expansion.
-This is not a feature.
-
- (2) This program was written before `gawk' acquired the ability to
-split each character in a string into separate array elements.
-
-13.3.4 Printing Mailing Labels
-------------------------------
-
-Here is a "real world"(1) program. This script reads lists of names and
-addresses and generates mailing labels. Each page of labels has 20
-labels on it, 2 across and 10 down. The addresses are guaranteed to be
-no more than 5 lines of data. Each address is separated from the next
-by a blank line.
-
- The basic idea is to read 20 labels worth of data. Each line of
-each label is stored in the `line' array. The single rule takes care
-of filling the `line' array and printing the page when 20 labels have
-been read.
-
- The `BEGIN' rule simply sets `RS' to the empty string, so that `awk'
-splits records at blank lines (*note Records::). It sets `MAXLINES' to
-100, since 100 is the maximum number of lines on the page (20 * 5 =
-100).
-
- Most of the work is done in the `printpage' function. The label
-lines are stored sequentially in the `line' array. But they have to
-print horizontally; `line[1]' next to `line[6]', `line[2]' next to
-`line[7]', and so on. Two loops are used to accomplish this. The
-outer loop, controlled by `i', steps through every 10 lines of data;
-this is each row of labels. The inner loop, controlled by `j', goes
-through the lines within the row. As `j' goes from 0 to 4, `i+j' is
-the `j'-th line in the row, and `i+j+5' is the entry next to it. The
-output ends up looking something like this:
-
- line 1 line 6
- line 2 line 7
- line 3 line 8
- line 4 line 9
- line 5 line 10
- ...
-
- As a final note, an extra blank line is printed at lines 21 and 61,
-to keep the output lined up on the labels. This is dependent on the
-particular brand of labels in use when the program was written. You
-will also note that there are 2 blank lines at the top and 2 blank
-lines at the bottom.
-
- The `END' rule arranges to flush the final page of labels; there may
-not have been an even multiple of 20 labels in the data:
-
- # labels.awk --- print mailing labels
-
- # Each label is 5 lines of data that may have blank lines.
- # The label sheets have 2 blank lines at the top and 2 at
- # the bottom.
-
- BEGIN { RS = "" ; MAXLINES = 100 }
-
- function printpage( i, j)
- {
- if (Nlines <= 0)
- return
-
- printf "\n\n" # header
-
- for (i = 1; i <= Nlines; i += 10) {
- if (i == 21 || i == 61)
- print ""
- for (j = 0; j < 5; j++) {
- if (i + j > MAXLINES)
- break
- printf " %-41s %s\n", line[i+j], line[i+j+5]
- }
- print ""
- }
-
- printf "\n\n" # footer
-
- for (i in line)
- line[i] = ""
- }
-
- # main rule
- {
- if (Count >= 20) {
- printpage()
- Count = 0
- Nlines = 0
- }
- n = split($0, a, "\n")
- for (i = 1; i <= n; i++)
- line[++Nlines] = a[i]
- for (; i <= 5; i++)
- line[++Nlines] = ""
- Count++
- }
-
- END \
- {
- printpage()
- }
-
- ---------- Footnotes ----------
-
- (1) "Real world" is defined as "a program actually used to get
-something done."
-
-13.3.5 Generating Word-Usage Counts
------------------------------------
-
-The following `awk' program prints the number of occurrences of each
-word in its input. It illustrates the associative nature of `awk'
-arrays by using strings as subscripts. It also demonstrates the `for
-INDEX in ARRAY' mechanism. Finally, it shows how `awk' is used in
-conjunction with other utility programs to do a useful task of some
-complexity with a minimum of effort. Some explanations follow the
-program listing:
-
- # Print list of word frequencies
- {
- for (i = 1; i <= NF; i++)
- freq[$i]++
- }
-
- END {
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
- }
-
- This program has two rules. The first rule, because it has an empty
-pattern, is executed for every input line. It uses `awk''s
-field-accessing mechanism (*note Fields::) to pick out the individual
-words from the line, and the built-in variable `NF' (*note Built-in
-Variables::) to know how many fields are available. For each input
-word, it increments an element of the array `freq' to reflect that the
-word has been seen an additional time.
-
- The second rule, because it has the pattern `END', is not executed
-until the input has been exhausted. It prints out the contents of the
-`freq' table that has been built up inside the first action. This
-program has several problems that would prevent it from being useful by
-itself on real text files:
-
- * Words are detected using the `awk' convention that fields are
- separated just by whitespace. Other characters in the input
- (except newlines) don't have any special meaning to `awk'. This
- means that punctuation characters count as part of words.
-
- * The `awk' language considers upper- and lowercase characters to be
- distinct. Therefore, "bartender" and "Bartender" are not treated
- as the same word. This is undesirable, since in normal text, words
- are capitalized if they begin sentences, and a frequency analyzer
- should not be sensitive to capitalization.
-
- * The output does not come out in any useful order. You're more
- likely to be interested in which words occur most frequently or in
- having an alphabetized table of how frequently each word occurs.
-
- The way to solve these problems is to use some of `awk''s more
-advanced features. First, we use `tolower' to remove case
-distinctions. Next, we use `gsub' to remove punctuation characters.
-Finally, we use the system `sort' utility to process the output of the
-`awk' script. Here is the new version of the program:
-
- # wordfreq.awk --- print list of word frequencies
-
- {
- $0 = tolower($0) # remove case distinctions
- # remove punctuation
- gsub(/[^[:alnum:]_[:blank:]]/, "", $0)
- for (i = 1; i <= NF; i++)
- freq[$i]++
- }
-
- END {
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
- }
-
- Assuming we have saved this program in a file named `wordfreq.awk',
-and that the data is in `file1', the following pipeline:
-
- awk -f wordfreq.awk file1 | sort -k 2nr
-
-produces a table of the words appearing in `file1' in order of
-decreasing frequency. The `awk' program suitably massages the data and
-produces a word frequency table, which is not ordered.
-
- The `awk' script's output is then sorted by the `sort' utility and
-printed on the terminal. The options given to `sort' specify a sort
-that uses the second field of each input line (skipping one field),
-that the sort keys should be treated as numeric quantities (otherwise
-`15' would come before `5'), and that the sorting should be done in
-descending (reverse) order.
-
- The `sort' could even be done from within the program, by changing
-the `END' action to:
-
- END {
- sort = "sort -k 2nr"
- for (word in freq)
- printf "%s\t%d\n", word, freq[word] | sort
- close(sort)
- }
-
- This way of sorting must be used on systems that do not have true
-pipes at the command-line (or batch-file) level. See the general
-operating system documentation for more information on how to use the
-`sort' program.
-
-13.3.6 Removing Duplicates from Unsorted Text
----------------------------------------------
-
-The `uniq' program (*note Uniq Program::), removes duplicate lines from
-_sorted_ data.
-
- Suppose, however, you need to remove duplicate lines from a data
-file but that you want to preserve the order the lines are in. A good
-example of this might be a shell history file. The history file keeps
-a copy of all the commands you have entered, and it is not unusual to
-repeat a command several times in a row. Occasionally you might want
-to compact the history by removing duplicate entries. Yet it is
-desirable to maintain the order of the original commands.
-
- This simple program does the job. It uses two arrays. The `data'
-array is indexed by the text of each line. For each line, `data[$0]'
-is incremented. If a particular line has not been seen before, then
-`data[$0]' is zero. In this case, the text of the line is stored in
-`lines[count]'. Each element of `lines' is a unique command, and the
-indices of `lines' indicate the order in which those lines are
-encountered. The `END' rule simply prints out the lines, in order:
-
- # histsort.awk --- compact a shell history file
- # Thanks to Byron Rakitzis for the general idea
- {
- if (data[$0]++ == 0)
- lines[++count] = $0
- }
-
- END {
- for (i = 1; i <= count; i++)
- print lines[i]
- }
-
- This program also provides a foundation for generating other useful
-information. For example, using the following `print' statement in the
-`END' rule indicates how often a particular command is used:
-
- print data[lines[i]], lines[i]
-
- This works because `data[$0]' is incremented each time a line is
-seen.
-
-13.3.7 Extracting Programs from Texinfo Source Files
-----------------------------------------------------
-
-The nodes *Note Library Functions::, and *Note Sample Programs::, are
-the top level nodes for a large number of `awk' programs. If you want
-to experiment with these programs, it is tedious to have to type them
-in by hand. Here we present a program that can extract parts of a
-Texinfo input file into separate files.
-
-This Info file is written in Texinfo, the GNU project's document
-formatting language. A single Texinfo source file can be used to
-produce both printed and online documentation. The Texinfo language is
-described fully, starting with *Note Top::.
-
- For our purposes, it is enough to know three things about Texinfo
-input files:
-
- * The "at" symbol (`@') is special in Texinfo, much as the backslash
- (`\') is in C or `awk'. Literal `@' symbols are represented in
- Texinfo source files as `@@'.
-
- * Comments start with either address@hidden' or address@hidden'. The
- file-extraction program works by using special comments that start
- at the beginning of a line.
-
- * Lines containing address@hidden' and address@hidden group' commands
bracket
- example text that should not be split across a page boundary.
- (Unfortunately, TeX isn't always smart enough to do things exactly
- right, and we have to give it some help.)
-
- The following program, `extract.awk', reads through a Texinfo source
-file and does two things, based on the special comments. Upon seeing
address@hidden system ...', it runs a command, by extracting the command text
from
-the control line and passing it on to the `system' function (*note I/O
-Functions::). Upon seeing address@hidden file FILENAME', each subsequent line
is
-sent to the file FILENAME, until address@hidden endfile' is encountered. The
-rules in `extract.awk' match either address@hidden' or address@hidden' by
letting the
-`omment' part be optional. Lines containing address@hidden' and
address@hidden group'
-are simply removed. `extract.awk' uses the `join' library function
-(*note Join Function::).
-
- The example programs in the online Texinfo source for `GAWK:
-Effective AWK Programming' (`gawk.texi') have all been bracketed inside
-`file' and `endfile' lines. The `gawk' distribution uses a copy of
-`extract.awk' to extract the sample programs and install many of them
-in a standard directory where `gawk' can find them. The Texinfo file
-looks something like this:
-
- ...
- This program has a @code{BEGIN} rule,
- that prints a nice message:
-
- @example
- @c file examples/messages.awk
- BEGIN @{ print "Don't panic!" @}
- @c end file
- @end example
-
- It also prints some final advice:
-
- @example
- @c file examples/messages.awk
- END @{ print "Always avoid bored archeologists!" @}
- @c end file
- @end example
- ...
-
- `extract.awk' begins by setting `IGNORECASE' to one, so that mixed
-upper- and lowercase letters in the directives won't matter.
-
- The first rule handles calling `system', checking that a command is
-given (`NF' is at least three) and also checking that the command exits
-with a zero exit status, signifying OK:
-
- # extract.awk --- extract files and run programs
- # from texinfo files
- BEGIN { IGNORECASE = 1 }
-
- /address@hidden(omment)?[ \t]+system/ \
- {
- if (NF < 3) {
- e = (FILENAME ":" FNR)
- e = (e ": badly formed `system' line")
- print e > "/dev/stderr"
- next
- }
- $1 = ""
- $2 = ""
- stat = system($0)
- if (stat != 0) {
- e = (FILENAME ":" FNR)
- e = (e ": warning: system returned " stat)
- print e > "/dev/stderr"
- }
- }
-
-The variable `e' is used so that the function fits nicely on the screen.
-
- The second rule handles moving data into files. It verifies that a
-file name is given in the directive. If the file named is not the
-current file, then the current file is closed. Keeping the current file
-open until a new file is encountered allows the use of the `>'
-redirection for printing the contents, keeping open file management
-simple.
-
- The `for' loop does the work. It reads lines using `getline' (*note
-Getline::). For an unexpected end of file, it calls the
-`unexpected_eof' function. If the line is an "endfile" line, then it
-breaks out of the loop. If the line is an address@hidden' or address@hidden
group'
-line, then it ignores it and goes on to the next line. Similarly,
-comments within examples are also ignored.
-
- Most of the work is in the following few lines. If the line has no
-`@' symbols, the program can print it directly. Otherwise, each
-leading `@' must be stripped off. To remove the `@' symbols, the line
-is split into separate elements of the array `a', using the `split'
-function (*note String Functions::). The `@' symbol is used as the
-separator character. Each element of `a' that is empty indicates two
-successive `@' symbols in the original line. For each two empty
-elements (`@@' in the original file), we have to add a single `@'
-symbol back in.
-
- When the processing of the array is finished, `join' is called with
-the value of `SUBSEP', to rejoin the pieces back into a single line.
-That line is then printed to the output file:
-
- /address@hidden(omment)?[ \t]+file/ \
- {
- if (NF != 3) {
- e = (FILENAME ":" FNR ": badly formed `file' line")
- print e > "/dev/stderr"
- next
- }
- if ($3 != curfile) {
- if (curfile != "")
- close(curfile)
- curfile = $3
- }
-
- for (;;) {
- if ((getline line) <= 0)
- unexpected_eof()
- if (line ~ /address@hidden(omment)?[ \t]+endfile/)
- break
- else if (line ~ /^@(end[ \t]+)?group/)
- continue
- else if (line ~ /address@hidden(omment+)?[ \t]+/)
- continue
- if (index(line, "@") == 0) {
- print line > curfile
- continue
- }
- n = split(line, a, "@")
- # if a[1] == "", means leading @,
- # don't add one back in.
- for (i = 2; i <= n; i++) {
- if (a[i] == "") { # was an @@
- a[i] = "@"
- if (a[i+1] == "")
- i++
- }
- }
- print join(a, 1, n, SUBSEP) > curfile
- }
- }
-
- An important thing to note is the use of the `>' redirection.
-Output done with `>' only opens the file once; it stays open and
-subsequent output is appended to the file (*note Redirection::). This
-makes it easy to mix program text and explanatory prose for the same
-sample source file (as has been done here!) without any hassle. The
-file is only closed when a new data file name is encountered or at the
-end of the input file.
-
- Finally, the function `unexpected_eof' prints an appropriate error
-message and then exits. The `END' rule handles the final cleanup,
-closing the open file:
-
- function unexpected_eof() {
- printf("%s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
- exit 1
- }
-
- END {
- if (curfile)
- close(curfile)
- }
-
-13.3.8 A Simple Stream Editor
------------------------------
-
-The `sed' utility is a stream editor, a program that reads a stream of
-data, makes changes to it, and passes it on. It is often used to make
-global changes to a large file or to a stream of data generated by a
-pipeline of commands. While `sed' is a complicated program in its own
-right, its most common use is to perform global substitutions in the
-middle of a pipeline:
-
- command1 < orig.data | sed 's/old/new/g' | command2 > result
-
- Here, `s/old/new/g' tells `sed' to look for the regexp `old' on each
-input line and globally replace it with the text `new', i.e., all the
-occurrences on a line. This is similar to `awk''s `gsub' function
-(*note String Functions::).
-
- The following program, `awksed.awk', accepts at least two
-command-line arguments: the pattern to look for and the text to replace
-it with. Any additional arguments are treated as data file names to
-process. If none are provided, the standard input is used:
-
- # awksed.awk --- do s/foo/bar/g using just print
- # Thanks to Michael Brennan for the idea
- function usage()
- {
- print "usage: awksed pat repl [files...]" > "/dev/stderr"
- exit 1
- }
-
- BEGIN {
- # validate arguments
- if (ARGC < 3)
- usage()
-
- RS = ARGV[1]
- ORS = ARGV[2]
-
- # don't use arguments as files
- ARGV[1] = ARGV[2] = ""
- }
-
- # look ma, no hands!
- {
- if (RT == "")
- printf "%s", $0
- else
- print
- }
-
- The program relies on `gawk''s ability to have `RS' be a regexp, as
-well as on the setting of `RT' to the actual text that terminates the
-record (*note Records::).
-
- The idea is to have `RS' be the pattern to look for. `gawk'
-automatically sets `$0' to the text between matches of the pattern.
-This is text that we want to keep, unmodified. Then, by setting `ORS'
-to the replacement text, a simple `print' statement outputs the text we
-want to keep, followed by the replacement text.
-
- There is one wrinkle to this scheme, which is what to do if the last
-record doesn't end with text that matches `RS'. Using a `print'
-statement unconditionally prints the replacement text, which is not
-correct. However, if the file did not end in text that matches `RS',
-`RT' is set to the null string. In this case, we can print `$0' using
-`printf' (*note Printf::).
-
- The `BEGIN' rule handles the setup, checking for the right number of
-arguments and calling `usage' if there is a problem. Then it sets `RS'
-and `ORS' from the command-line arguments and sets `ARGV[1]' and
-`ARGV[2]' to the null string, so that they are not treated as file names
-(*note ARGC and ARGV::).
-
- The `usage' function prints an error message and exits. Finally,
-the single rule handles the printing scheme outlined above, using
-`print' or `printf' as appropriate, depending upon the value of `RT'.
-
-13.3.9 An Easy Way to Use Library Functions
--------------------------------------------
-
-Using library functions in `awk' can be very beneficial. It encourages
-code reuse and the writing of general functions. Programs are smaller
-and therefore clearer. However, using library functions is only easy
-when writing `awk' programs; it is painful when running them, requiring
-multiple `-f' options. If `gawk' is unavailable, then so too is the
-`AWKPATH' environment variable and the ability to put `awk' functions
-into a library directory (*note Options::). It would be nice to be
-able to write programs in the following manner:
-
- # library functions
- @include getopt.awk
- @include join.awk
- ...
-
- # main program
- BEGIN {
- while ((c = getopt(ARGC, ARGV, "a:b:cde")) != -1)
- ...
- ...
- }
-
- The following program, `igawk.sh', provides this service. It
-simulates `gawk''s searching of the `AWKPATH' variable and also allows
-"nested" includes; i.e., a file that is included with address@hidden' can
-contain further address@hidden' statements. `igawk' makes an effort to only
-include files once, so that nested includes don't accidentally include
-a library function twice.
-
- `igawk' should behave just like `gawk' externally. This means it
-should accept all of `gawk''s command-line arguments, including the
-ability to have multiple source files specified via `-f', and the
-ability to mix command-line and library source files.
-
- The program is written using the POSIX Shell (`sh') command
-language.(1) It works as follows:
-
- 1. Loop through the arguments, saving anything that doesn't represent
- `awk' source code for later, when the expanded program is run.
-
- 2. For any arguments that do represent `awk' text, put the arguments
- into a shell variable that will be expanded. There are two cases:
-
- a. Literal text, provided with `--source' or `--source='. This
- text is just appended directly.
-
- b. Source file names, provided with `-f'. We use a neat trick
- and append address@hidden FILENAME' to the shell variable's
- contents. Since the file-inclusion program works the way
- `gawk' does, this gets the text of the file included into the
- program at the correct point.
-
- 3. Run an `awk' program (naturally) over the shell variable's
- contents to expand address@hidden' statements. The expanded program is
- placed in a second shell variable.
-
- 4. Run the expanded program with `gawk' and any other original
- command-line arguments that the user supplied (such as the data
- file names).
-
- This program uses shell variables extensively; for storing command
-line arguments, the text of the `awk' program that will expand the
-user's program, for the user's original program, and for the expanded
-program. Doing so removes some potential problems that might arise
-were we to use temporary files instead, at the cost of making the
-script somewhat more complicated.
-
- The initial part of the program turns on shell tracing if the first
-argument is `debug'.
-
- The next part loops through all the command-line arguments. There
-are several cases of interest:
-
-`--'
- This ends the arguments to `igawk'. Anything else should be
- passed on to the user's `awk' program without being evaluated.
-
-`-W'
- This indicates that the next option is specific to `gawk'. To make
- argument processing easier, the `-W' is appended to the front of
- the remaining arguments and the loop continues. (This is an `sh'
- programming trick. Don't worry about it if you are not familiar
- with `sh'.)
-
-`-v, -F'
- These are saved and passed on to `gawk'.
-
-`-f, --file, --file=, -Wfile='
- The file name is appended to the shell variable `program' with an
- address@hidden' statement. The `expr' utility is used to remove the
- leading option part of the argument (e.g., `--file='). (Typical
- `sh' usage would be to use the `echo' and `sed' utilities to do
- this work. Unfortunately, some versions of `echo' evaluate escape
- sequences in their arguments, possibly mangling the program text.
- Using `expr' avoids this problem.)
-
-`--source, --source=, -Wsource='
- The source text is appended to `program'.
-
-`--version, -Wversion'
- `igawk' prints its version number, runs `gawk --version' to get
- the `gawk' version information, and then exits.
-
- If none of the `-f', `--file', `-Wfile', `--source', or `-Wsource'
-arguments are supplied, then the first nonoption argument should be the
-`awk' program. If there are no command-line arguments left, `igawk'
-prints an error message and exits. Otherwise, the first argument is
-appended to `program'. In any case, after the arguments have been
-processed, `program' contains the complete text of the original `awk'
-program.
-
- The program is as follows:
-
- #! /bin/sh
- # igawk --- like gawk but do @include processing
- if [ "$1" = debug ]
- then
- set -x
- shift
- fi
-
- # A literal newline, so that program text is formmatted correctly
- n='
- '
-
- # Initialize variables to empty
- program=
- opts=
-
- while [ $# -ne 0 ] # loop over arguments
- do
- case $1 in
- --) shift; break;;
-
- -W) shift
- # The ${x?'message here'} construct prints a
- # diagnostic if $x is the null string
- set -- -W"address@hidden'missing operand'}"
- continue;;
-
- -[vF]) opts="$opts $1 '${2?'missing operand'}'"
- shift;;
-
- -[vF]*) opts="$opts '$1'" ;;
-
- -f) program="address@hidden ${2?'missing operand'}"
- shift;;
-
- -f*) f=`expr "$1" : '-f\(.*\)'`
- program="address@hidden $f";;
-
- -[W-]file=*)
- f=`expr "$1" : '-.file=\(.*\)'`
- program="address@hidden $f";;
-
- -[W-]file)
- program="address@hidden ${2?'missing operand'}"
- shift;;
-
- -[W-]source=*)
- t=`expr "$1" : '-.source=\(.*\)'`
- program="$program$n$t";;
-
- -[W-]source)
- program="$program$n${2?'missing operand'}"
- shift;;
-
- -[W-]version)
- echo igawk: version 2.0 1>&2
- gawk --version
- exit 0 ;;
-
- -[W-]*) opts="$opts '$1'" ;;
-
- *) break;;
- esac
- shift
- done
-
- if [ -z "$program" ]
- then
- program=${1?'missing program'}
- shift
- fi
-
- # At this point, `program' has the program.
-
- The `awk' program to process address@hidden' directives is stored in the
-shell variable `expand_prog'. Doing this keeps the shell script
-readable. The `awk' program reads through the user's program, one line
-at a time, using `getline' (*note Getline::). The input file names and
address@hidden' statements are managed using a stack. As each address@hidden'
is
-encountered, the current file name is "pushed" onto the stack and the
-file named in the address@hidden' directive becomes the current file name.
-As each file is finished, the stack is "popped," and the previous input
-file becomes the current input file again. The process is started by
-making the original file the first one on the stack.
-
- The `pathto' function does the work of finding the full path to a
-file. It simulates `gawk''s behavior when searching the `AWKPATH'
-environment variable (*note AWKPATH Variable::). If a file name has a
-`/' in it, no path search is done. Otherwise, the file name is
-concatenated with the name of each directory in the path, and an
-attempt is made to open the generated file name. The only way to test
-if a file can be read in `awk' is to go ahead and try to read it with
-`getline'; this is what `pathto' does.(2) If the file can be read, it
-is closed and the file name is returned:
-
- expand_prog='
-
- function pathto(file, i, t, junk)
- {
- if (index(file, "/") != 0)
- return file
-
- for (i = 1; i <= ndirs; i++) {
- t = (pathlist[i] "/" file)
- if ((getline junk < t) > 0) {
- # found it
- close(t)
- return t
- }
- }
- return ""
- }
-
- The main program is contained inside one `BEGIN' rule. The first
-thing it does is set up the `pathlist' array that `pathto' uses. After
-splitting the path on `:', null elements are replaced with `"."', which
-represents the current directory:
-
- BEGIN {
- path = ENVIRON["AWKPATH"]
- ndirs = split(path, pathlist, ":")
- for (i = 1; i <= ndirs; i++) {
- if (pathlist[i] == "")
- pathlist[i] = "."
- }
-
- The stack is initialized with `ARGV[1]', which will be `/dev/stdin'.
-The main loop comes next. Input lines are read in succession. Lines
-that do not start with address@hidden' are printed verbatim. If the line
-does start with address@hidden', the file name is in `$2'. `pathto' is
-called to generate the full path. If it cannot, then we print an error
-message and continue.
-
- The next thing to check is if the file is included already. The
-`processed' array is indexed by the full file name of each included
-file and it tracks this information for us. If the file is seen again,
-a warning message is printed. Otherwise, the new file name is pushed
-onto the stack and processing continues.
-
- Finally, when `getline' encounters the end of the input file, the
-file is closed and the stack is popped. When `stackptr' is less than
-zero, the program is done:
-
- stackptr = 0
- input[stackptr] = ARGV[1] # ARGV[1] is first file
-
- for (; stackptr >= 0; stackptr--) {
- while ((getline < input[stackptr]) > 0) {
- if (tolower($1) != "@include") {
- print
- continue
- }
- fpath = pathto($2)
- if (fpath == "") {
- printf("igawk:%s:%d: cannot find %s\n",
- input[stackptr], FNR, $2) > "/dev/stderr"
- continue
- }
- if (! (fpath in processed)) {
- processed[fpath] = input[stackptr]
- input[++stackptr] = fpath # push onto stack
- } else
- print $2, "included in", input[stackptr],
- "already included in",
- processed[fpath] > "/dev/stderr"
- }
- close(input[stackptr])
- }
- }' # close quote ends `expand_prog' variable
-
- processed_program=`gawk -- "$expand_prog" /dev/stdin <<EOF
- $program
- EOF
- `
-
- The shell construct `COMMAND << MARKER' is called a "here document".
-Everything in the shell script up to the MARKER is fed to COMMAND as
-input. The shell processes the contents of the here document for
-variable and command substitution (and possibly other things as well,
-depending upon the shell).
-
- The shell construct ``...`' is called "command substitution". The
-output of the command between the two backquotes (grave accents) is
-substituted into the command line. It is saved as a single string,
-even if the results contain whitespace.
-
- The expanded program is saved in the variable `processed_program'.
-It's done in these steps:
-
- 1. Run `gawk' with the address@hidden'-processing program (the value of
- the `expand_prog' shell variable) on standard input.
-
- 2. Standard input is the contents of the user's program, from the
- shell variable `program'. Its contents are fed to `gawk' via a
- here document.
-
- 3. The results of this processing are saved in the shell variable
- `processed_program' by using command substitution.
-
- The last step is to call `gawk' with the expanded program, along
-with the original options and command-line arguments that the user
-supplied.
-
- eval gawk $opts -- '"$processed_program"' '"$@"'
-
- The `eval' command is a shell construct that reruns the shell's
-parsing process. This keeps things properly quoted.
-
- This version of `igawk' represents my fourth attempt at this program.
-There are four key simplifications that make the program work better:
-
- * Using address@hidden' even for the files named with `-f' makes building
- the initial collected `awk' program much simpler; all the
- address@hidden' processing can be done once.
-
- * Not trying to save the line read with `getline' in the `pathto'
- function when testing for the file's accessibility for use with
- the main program simplifies things considerably.
-
- * Using a `getline' loop in the `BEGIN' rule does it all in one
- place. It is not necessary to call out to a separate loop for
- processing nested address@hidden' statements.
-
- * Instead of saving the expanded program in a temporary file,
- putting it in a shell variable avoids some potential security
- problems. This has the disadvantage that the script relies upon
- more features of the `sh' language, making it harder to follow for
- those who aren't familiar with `sh'.
-
- Also, this program illustrates that it is often worthwhile to combine
-`sh' and `awk' programming together. You can usually accomplish quite
-a lot, without having to resort to low-level programming in C or C++,
-and it is frequently easier to do certain kinds of string and argument
-manipulation using the shell than it is in `awk'.
-
- Finally, `igawk' shows that it is not always necessary to add new
-features to a program; they can often be layered on top. With `igawk',
-there is no real reason to build address@hidden' processing into `gawk'
-itself.
-
- As an additional example of this, consider the idea of having two
-files in a directory in the search path:
-
-`default.awk'
- This file contains a set of default library functions, such as
- `getopt' and `assert'.
-
-`site.awk'
- This file contains library functions that are specific to a site or
- installation; i.e., locally developed functions. Having a
- separate file allows `default.awk' to change with new `gawk'
- releases, without requiring the system administrator to update it
- each time by adding the local functions.
-
- One user suggested that `gawk' be modified to automatically read
-these files upon startup. Instead, it would be very simple to modify
-`igawk' to do this. Since `igawk' can process nested address@hidden'
-directives, `default.awk' could simply contain address@hidden' statements
-for the desired library functions.
-
- ---------- Footnotes ----------
-
- (1) Fully explaining the `sh' language is beyond the scope of this
-book. We provide some minimal explanations, but see a good shell
-programming book if you wish to understand things in more depth.
-
- (2) On some very old versions of `awk', the test `getline junk < t'
-can loop forever if the file exists but is empty. Caveat emptor.
-
-Appendix A The Evolution of the `awk' Language
-**********************************************
-
-This Info file describes the GNU implementation of `awk', which follows
-the POSIX specification. Many long-time `awk' users learned `awk'
-programming with the original `awk' implementation in Version 7 Unix.
-(This implementation was the basis for `awk' in Berkeley Unix, through
-4.3-Reno. Subsequent versions of Berkeley Unix, and systems derived
-from 4.4BSD-Lite, use various versions of `gawk' for their `awk'.)
-This major node briefly describes the evolution of the `awk' language,
-with cross-references to other parts of the Info file where you can
-find more information.
-
-A.1 Major Changes Between V7 and SVR3.1
-=======================================
-
-The `awk' language evolved considerably between the release of Version
-7 Unix (1978) and the new version that was first made generally
-available in System V Release 3.1 (1987). This minor node summarizes
-the changes, with cross-references to further details:
-
- * The requirement for `;' to separate rules on a line (*note
- Statements/Lines::).
-
- * User-defined functions and the `return' statement (*note
- User-defined::).
-
- * The `delete' statement (*note Delete::).
-
- * The `do'-`while' statement (*note Do Statement::).
-
- * The built-in functions `atan2', `cos', `sin', `rand', and `srand'
- (*note Numeric Functions::).
-
- * The built-in functions `gsub', `sub', and `match' (*note String
- Functions::).
-
- * The built-in functions `close' and `system' (*note I/O
- Functions::).
-
- * The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP'
- built-in variables (*note Built-in Variables::).
-
- * The conditional expression using the ternary operator `?:' (*note
- Conditional Exp::).
-
- * The exponentiation operator `^' (*note Arithmetic Ops::) and its
- assignment operator form `^=' (*note Assignment Ops::).
-
- * C-compatible operator precedence, which breaks some old `awk'
- programs (*note Precedence::).
-
- * Regexps as the value of `FS' (*note Field Separators::) and as the
- third argument to the `split' function (*note String Functions::).
-
- * Dynamic regexps as operands of the `~' and `!~' operators (*note
- Regexp Usage::).
-
- * The escape sequences `\b', `\f', and `\r' (*note Escape
- Sequences::). (Some vendors have updated their old versions of
- `awk' to recognize `\b', `\f', and `\r', but this is not something
- you can rely on.)
-
- * Redirection of input for the `getline' function (*note Getline::).
-
- * Multiple `BEGIN' and `END' rules (*note BEGIN/END::).
-
- * Multidimensional arrays (*note Multi-dimensional::).
-
-A.2 Changes Between SVR3.1 and SVR4
-===================================
-
-The System V Release 4 (1989) version of Unix `awk' added these features
-(some of which originated in `gawk'):
-
- * The `ENVIRON' variable (*note Built-in Variables::).
-
- * Multiple `-f' options on the command line (*note Options::).
-
- * The `-v' option for assigning variables before program execution
- begins (*note Options::).
-
- * The `--' option for terminating command-line options.
-
- * The `\a', `\v', and `\x' escape sequences (*note Escape
- Sequences::).
-
- * A defined return value for the `srand' built-in function (*note
- Numeric Functions::).
-
- * The `toupper' and `tolower' built-in string functions for case
- translation (*note String Functions::).
-
- * A cleaner specification for the `%c' format-control letter in the
- `printf' function (*note Control Letters::).
-
- * The ability to dynamically pass the field width and precision
- (`"%*.*d"') in the argument list of the `printf' function (*note
- Control Letters::).
-
- * The use of regexp constants, such as `/foo/', as expressions, where
- they are equivalent to using the matching operator, as in `$0 ~
- /foo/' (*note Using Constant Regexps::).
-
- * Processing of escape sequences inside command-line variable
- assignments (*note Assignment Options::).
-
-A.3 Changes Between SVR4 and POSIX `awk'
-========================================
-
-The POSIX Command Language and Utilities standard for `awk' (1992)
-introduced the following changes into the language:
-
- * The use of `-W' for implementation-specific options (*note
- Options::).
-
- * The use of `CONVFMT' for controlling the conversion of numbers to
- strings (*note Conversion::).
-
- * The concept of a numeric string and tighter comparison rules to go
- with it (*note Typing and Comparison::).
-
- * More complete documentation of many of the previously undocumented
- features of the language.
-
- The following common extensions are not permitted by the POSIX
-standard:
-
- * `\x' escape sequences are not recognized (*note Escape
- Sequences::).
-
- * Newlines do not act as whitespace to separate fields when `FS' is
- equal to a single space (*note Fields::).
-
- * Newlines are not allowed after `?' or `:' (*note Conditional
- Exp::).
-
- * The synonym `func' for the keyword `function' is not recognized
- (*note Definition Syntax::).
-
- * The operators `**' and `**=' cannot be used in place of `^' and
- `^=' (*note Arithmetic Ops::, and *Note Assignment Ops::).
-
- * Specifying `-Ft' on the command line does not set the value of
- `FS' to be a single TAB character (*note Field Separators::).
-
- * The `fflush' built-in function is not supported (*note I/O
- Functions::).
-
-A.4 Extensions in the Bell Laboratories `awk'
-=============================================
-
-Brian Kernighan, one of the original designers of Unix `awk', has made
-his version available via his home page (*note Other Versions::). This
-minor node describes extensions in his version of `awk' that are not in
-POSIX `awk':
-
- * The `-mf N' and `-mr N' command-line options to set the maximum
- number of fields and the maximum record size, respectively (*note
- Options::). As a side note, his `awk' no longer needs these
- options; it continues to accept them to avoid breaking old
- programs.
-
- * The `fflush' built-in function for flushing buffered output (*note
- I/O Functions::).
-
- * The `**' and `**=' operators (*note Arithmetic Ops:: and *Note
- Assignment Ops::).
-
- * The use of `func' as an abbreviation for `function' (*note
- Definition Syntax::).
-
-
- The Bell Laboratories `awk' also incorporates the following
-extensions, originally developed for `gawk':
-
- * The `\x' escape sequence (*note Escape Sequences::).
-
- * The `/dev/stdin', `/dev/stdout', and `/dev/stderr' special files
- (*note Special Files::).
-
- * The ability for `FS' and for the third argument to `split' to be
- null strings (*note Single Character Fields::).
-
- * The `nextfile' statement (*note Nextfile Statement::).
-
- * The ability to delete all of an array at once with `delete ARRAY'
- (*note Delete::).
-
-A.5 Extensions in `gawk' Not in POSIX `awk'
-===========================================
-
-The GNU implementation, `gawk', adds a large number of features. This
-minor node lists them in the order they were added to `gawk'. They can
-all be disabled with either the `--traditional' or `--posix' options
-(*note Options::).
-
- Version 2.10 of `gawk' introduced the following features:
-
- * The `AWKPATH' environment variable for specifying a path search for
- the `-f' command-line option (*note Options::).
-
- * The `IGNORECASE' variable and its effects (*note
- Case-sensitivity::).
-
- * The `/dev/stdin', `/dev/stdout', `/dev/stderr' and `/dev/fd/N'
- special file names (*note Special Files::).
-
- Version 2.13 of `gawk' introduced the following features:
-
- * The `FIELDWIDTHS' variable and its effects (*note Constant Size::).
-
- * The `systime' and `strftime' built-in functions for obtaining and
- printing timestamps (*note Time Functions::).
-
- * The `-W lint' option to provide error and portability checking for
- both the source code and at runtime (*note Options::).
-
- * The `-W compat' option to turn off the GNU extensions (*note
- Options::).
-
- * The `-W posix' option for full POSIX compliance (*note Options::).
-
- Version 2.14 of `gawk' introduced the following feature:
-
- * The `next file' statement for skipping to the next data file
- (*note Nextfile Statement::).
-
- Version 2.15 of `gawk' introduced the following features:
-
- * The `ARGIND' variable, which tracks the movement of `FILENAME'
- through `ARGV' (*note Built-in Variables::).
-
- * The `ERRNO' variable, which contains the system error message when
- `getline' returns -1 or `close' fails (*note Built-in Variables::).
-
- * The `/dev/pid', `/dev/ppid', `/dev/pgrpid', and `/dev/user' file
- name interpretation (*note Special Files::).
-
- * The ability to delete all of an array at once with `delete ARRAY'
- (*note Delete::).
-
- * The ability to use GNU-style long-named options that start with
- `--' (*note Options::).
-
- * The `--source' option for mixing command-line and library-file
- source code (*note Options::).
-
- Version 3.0 of `gawk' introduced the following features:
-
- * `IGNORECASE' changed, now applying to string comparison as well as
- regexp operations (*note Case-sensitivity::).
-
- * The `RT' variable that contains the input text that matched `RS'
- (*note Records::).
-
- * Full support for both POSIX and GNU regexps (*note Regexp::).
-
- * The `gensub' function for more powerful text manipulation (*note
- String Functions::).
-
- * The `strftime' function acquired a default time format, allowing
- it to be called with no arguments (*note Time Functions::).
-
- * The ability for `FS' and for the third argument to `split' to be
- null strings (*note Single Character Fields::).
-
- * The ability for `RS' to be a regexp (*note Records::).
-
- * The `next file' statement became `nextfile' (*note Nextfile
- Statement::).
-
- * The `--lint-old' option to warn about constructs that are not
- available in the original Version 7 Unix version of `awk' (*note
- V7/SVR3.1::).
-
- * The `-m' option and the `fflush' function from the Bell
- Laboratories research version of `awk' (*note Options::; also
- *note I/O Functions::).
-
- * The `--re-interval' option to provide interval expressions in
- regexps (*note Regexp Operators::).
-
- * The `--traditional' option was added as a better name for
- `--compat' (*note Options::).
-
- * The use of GNU Autoconf to control the configuration process
- (*note Quick Installation::).
-
- * Amiga support (*note Amiga Installation::).
-
-
- Version 3.1 of `gawk' introduced the following features:
-
- * The `BINMODE' special variable for non-POSIX systems, which allows
- binary I/O for input and/or output files (*note PC Using::).
-
- * The `LINT' special variable, which dynamically controls lint
- warnings (*note Built-in Variables::).
-
- * The `PROCINFO' array for providing process-related information
- (*note Built-in Variables::).
-
- * The `TEXTDOMAIN' special variable for setting an application's
- internationalization text domain (*note Built-in Variables::, and
- *Note Internationalization::).
-
- * The ability to use octal and hexadecimal constants in `awk'
- program source code (*note Nondecimal-numbers::).
-
- * The `|&' operator for two-way I/O to a coprocess (*note Two-way
- I/O::).
-
- * The `/inet' special files for TCP/IP networking using `|&' (*note
- TCP/IP Networking::).
-
- * The optional second argument to `close' that allows closing one end
- of a two-way pipe to a coprocess (*note Two-way I/O::).
-
- * The optional third argument to the `match' function for capturing
- text-matching subexpressions within a regexp (*note String
- Functions::).
-
- * Positional specifiers in `printf' formats for making translations
- easier (*note Printf Ordering::).
-
- * The `asort' and `asorti' functions for sorting arrays (*note Array
- Sorting::).
-
- * The `bindtextdomain', `dcgettext' and `dcngettext' functions for
- internationalization (*note Programmer i18n::).
-
- * The `extension' built-in function and the ability to add new
- built-in functions dynamically (*note Dynamic Extensions::).
-
- * The `mktime' built-in function for creating timestamps (*note Time
- Functions::).
-
- * The `and', `or', `xor', `compl', `lshift', `rshift', and
- `strtonum' built-in functions (*note Bitwise Functions::).
-
- * The support for `next file' as two words was removed completely
- (*note Nextfile Statement::).
-
- * The `--dump-variables' option to print a list of all global
- variables (*note Options::).
-
- * The `--gen-po' command-line option and the use of a leading
- underscore to mark strings that should be translated (*note String
- Extraction::).
-
- * The `--non-decimal-data' option to allow non-decimal input data
- (*note Nondecimal Data::).
-
- * The `--profile' option and `pgawk', the profiling version of
- `gawk', for producing execution profiles of `awk' programs (*note
- Profiling::).
-
- * The `--enable-portals' configuration option to enable special
- treatment of pathnames that begin with `/p' as BSD portals (*note
- Portal Files::).
-
- * The use of GNU Automake to help in standardizing the configuration
- process (*note Quick Installation::).
-
- * The use of GNU `gettext' for `gawk''s own message output (*note
- Gawk I18N::).
-
- * BeOS support (*note BeOS Installation::).
-
- * Tandem support (*note Tandem Installation::).
-
- * The Atari port became officially unsupported (*note Atari
- Installation::).
-
- * The source code now uses new-style function definitions, with
- `ansi2knr' to convert the code on systems with old compilers.
-
- * The `--disable-lint' configuration option to disable lint checking
- at compile time (*note Additional Configuration Options::).
-
- * POSIX compliance for `sub' and `gsub' (*note Gory Details::).
-
-
-A.6 Major Contributors to `gawk'
-================================
-
- Always give credit where credit is due.
- Anonymous
-
- This minor node names the major contributors to `gawk' and/or this
-Info file, in approximate chronological order:
-
- * Dr. Alfred V. Aho, Dr. Peter J. Weinberger, and Dr. Brian W.
- Kernighan, all of Bell Laboratories, designed and implemented Unix
- `awk', from which `gawk' gets the majority of its feature set.
-
- * Paul Rubin did the initial design and implementation in 1986, and
- wrote the first draft (around 40 pages) of this Info file.
-
- * Jay Fenlason finished the initial implementation.
-
- * Diane Close revised the first draft of this Info file, bringing it
- to around 90 pages.
-
- * Richard Stallman helped finish the implementation and the initial
- draft of this Info file. He is also the founder of the FSF and
- the GNU project.
-
- * John Woods contributed parts of the code (mostly fixes) in the
- initial version of `gawk'.
-
- * In 1988, David Trueman took over primary maintenance of `gawk',
- making it compatible with "new" `awk', and greatly improving its
- performance.
-
- * Pat Rankin provided the VMS port and its documentation.
-
- * Conrad Kwok, Scott Garfinkle, and Kent Williams did the initial
- ports to MS-DOS with various versions of MSC.
-
- * Hal Peterson provided help in porting `gawk' to Cray systems.
-
- * Kai Uwe Rommel provided the initial port to OS/2 and its
- documentation.
-
- * Michal Jaegermann provided the port to Atari systems and its
- documentation. He continues to provide portability checking with
- DEC Alpha systems, and has done a lot of work to make sure `gawk'
- works on non-32-bit systems.
-
- * Fred Fish provided the port to Amiga systems and its documentation.
-
- * Scott Deifik currently maintains the MS-DOS port.
-
- * Juan Grigera maintains the port to Windows32 systems.
-
- * Dr. Darrel Hankerson acts as coordinator for the various ports to
- different PC platforms and creates binary distributions for
- various PC operating systems. He is also instrumental in keeping
- the documentation up to date for the various PC platforms.
-
- * Christos Zoulas provided the `extension' built-in function for
- dynamically adding new modules.
-
- * Ju"rgen Kahrs contributed the initial version of the TCP/IP
- networking code and documentation, and motivated the inclusion of
- the `|&' operator.
-
- * Stephen Davies provided the port to Tandem systems and its
- documentation.
-
- * Martin Brown provided the port to BeOS and its documentation.
-
- * Arno Peters did the initial work to convert `gawk' to use GNU
- Automake and `gettext'.
-
- * Alan J. Broder provided the initial version of the `asort' function
- as well as the code for the new optional third argument to the
- `match' function.
-
- * Andreas Buening updated the `gawk' port for OS/2.
-
- Isamu Hasegawa, of IBM in Japan, contributed support for multibyte
- characters.
-
- Michael Benzinger contributed the initial code for `switch'
- statements.
-
- Patrick T.J. McPhee contributed the code for dynamic loading in
- Windows32 environments.
-
- * Arnold Robbins has been working on `gawk' since 1988, at first
- helping David Trueman, and as the primary maintainer since around
- 1994.
-
-Appendix B Installing `gawk'
-****************************
-
-This appendix provides instructions for installing `gawk' on the
-various platforms that are supported by the developers. The primary
-developer supports GNU/Linux (and Unix), whereas the other ports are
-contributed. *Note Bugs::, for the electronic mail addresses of the
-people who did the respective ports.
-
-B.1 The `gawk' Distribution
-===========================
-
-This minor node describes how to get the `gawk' distribution, how to
-extract it, and then what is in the various files and subdirectories.
-
-B.1.1 Getting the `gawk' Distribution
--------------------------------------
-
-There are three ways to get GNU software:
-
- * Copy it from someone else who already has it.
-
- * Order `gawk' directly from the Free Software Foundation. Software
- distributions are available for Gnu/Linux, Unix, and MS-Windows,
- in several CD packages. Their address is:
-
- Free Software Foundation
- 51 Franklin Street, Fifth Floor
- Boston, MA 02110-1301 USA
- Phone: +1-617-542-5942
- Fax (including Japan): +1-617-542-2652
- Email: <address@hidden>
- URL: `http://www.gnu.org'
-
- Ordering from the FSF directly contributes to the support of the
- foundation and to the production of more free software.
-
- * Retrieve `gawk' by using anonymous `ftp' to the Internet host
- `ftp.gnu.org', in the directory `/gnu/gawk'.
-
- The GNU software archive is mirrored around the world. The
-up-to-date list of mirror sites is available from the main FSF web site
-(http://www.gnu.org/order/ftp.html). Try to use one of the mirrors;
-they will be less busy, and you can usually find one closer to your
-site.
-
-B.1.2 Extracting the Distribution
----------------------------------
-
-`gawk' is distributed as a `tar' file compressed with the GNU Zip
-program, `gzip'.
-
- Once you have the distribution (for example, `gawk-3.1.4.tar.gz'),
-use `gzip' to expand the file and then use `tar' to extract it. You
-can use the following pipeline to produce the `gawk' distribution:
-
- # Under System V, add 'o' to the tar options
- gzip -d -c gawk-3.1.4.tar.gz | tar -xvpf -
-
-This creates a directory named `gawk-3.1.4' in the current directory.
-
- The distribution file name is of the form `gawk-V.R.P.tar.gz'. The
-V represents the major version of `gawk', the R represents the current
-release of version V, and the P represents a "patch level", meaning
-that minor bugs have been fixed in the release. The current patch
-level is 4, but when retrieving distributions, you should get the
-version with the highest version, release, and patch level. (Note,
-however, that patch levels greater than or equal to 80 denote "beta" or
-nonproduction software; you might not want to retrieve such a version
-unless you don't mind experimenting.) If you are not on a Unix system,
-you need to make other arrangements for getting and extracting the
-`gawk' distribution. You should consult a local expert.
-
-B.1.3 Contents of the `gawk' Distribution
------------------------------------------
-
-The `gawk' distribution has a number of C source files, documentation
-files, subdirectories, and files related to the configuration process
-(*note Unix Installation::), as well as several subdirectories related
-to different non-Unix operating systems:
-
-Various `.c', `.y', and `.h' files
- The actual `gawk' source code.
-
-`README'
-`README_d/README.*'
- Descriptive files: `README' for `gawk' under Unix and the rest for
- the various hardware and software combinations.
-
-`INSTALL'
- A file providing an overview of the configuration and installation
- process.
-
-`ChangeLog'
- A detailed list of source code changes as bugs are fixed or
- improvements made.
-
-`NEWS'
- A list of changes to `gawk' since the last release or patch.
-
-`COPYING'
- The GNU General Public License.
-
-`FUTURES'
- A brief list of features and changes being contemplated for future
- releases, with some indication of the time frame for the feature,
- based on its difficulty.
-
-`LIMITATIONS'
- A list of those factors that limit `gawk''s performance. Most of
- these depend on the hardware or operating system software and are
- not limits in `gawk' itself.
-
-`POSIX.STD'
- A description of one area in which the POSIX standard for `awk' is
- incorrect as well as how `gawk' handles the problem.
-
-`doc/awkforai.txt'
- A short article describing why `gawk' is a good language for AI
- (Artificial Intelligence) programming.
-
-`doc/README.card'
-`doc/ad.block'
-`doc/awkcard.in'
-`doc/cardfonts'
-`doc/colors'
-`doc/macros'
-`doc/no.colors'
-`doc/setter.outline'
- The `troff' source for a five-color `awk' reference card. A
- modern version of `troff' such as GNU `troff' (`groff') is needed
- to produce the color version. See the file `README.card' for
- instructions if you have an older `troff'.
-
-`doc/gawk.1'
- The `troff' source for a manual page describing `gawk'. This is
- distributed for the convenience of Unix users.
-
-`doc/gawk.texi'
- The Texinfo source file for this Info file. It should be
- processed with TeX to produce a printed document, and with
- `makeinfo' to produce an Info or HTML file.
-
-`doc/gawk.info'
- The generated Info file for this Info file.
-
-`doc/gawkinet.texi'
- The Texinfo source file for *Note Top::. It should be processed
- with TeX to produce a printed document and with `makeinfo' to
- produce an Info or HTML file.
-
-`doc/gawkinet.info'
- The generated Info file for `TCP/IP Internetworking with `gawk''.
-
-`doc/igawk.1'
- The `troff' source for a manual page describing the `igawk'
- program presented in *Note Igawk Program::.
-
-`doc/Makefile.in'
- The input file used during the configuration process to generate
- the actual `Makefile' for creating the documentation.
-
-`Makefile.am'
-`*/Makefile.am'
- Files used by the GNU `automake' software for generating the
- `Makefile.in' files used by `autoconf' and `configure'.
-
-`Makefile.in'
-`acconfig.h'
-`acinclude.m4'
-`aclocal.m4'
-`configh.in'
-`configure.in'
-`configure'
-`custom.h'
-`missing_d/*'
-`m4/*'
- These files and subdirectories are used when configuring `gawk'
- for various Unix systems. They are explained in *Note Unix
- Installation::.
-
-`intl/*'
-`po/*'
- The `intl' directory provides the GNU `gettext' library, which
- implements `gawk''s internationalization features, while the `po'
- library contains message translations.
-
-`awklib/extract.awk'
-`awklib/Makefile.am'
-`awklib/Makefile.in'
-`awklib/eg/*'
- The `awklib' directory contains a copy of `extract.awk' (*note
- Extract Program::), which can be used to extract the sample
- programs from the Texinfo source file for this Info file. It also
- contains a `Makefile.in' file, which `configure' uses to generate
- a `Makefile'. `Makefile.am' is used by GNU Automake to create
- `Makefile.in'. The library functions from *Note Library
- Functions::, and the `igawk' program from *Note Igawk Program::,
- are included as ready-to-use files in the `gawk' distribution.
- They are installed as part of the installation process. The rest
- of the programs in this Info file are available in appropriate
- subdirectories of `awklib/eg'.
-
-`unsupported/atari/*'
- Files needed for building `gawk' on an Atari ST (*note Atari
- Installation::, for details).
-
-`unsupported/tandem/*'
- Files needed for building `gawk' on a Tandem (*note Tandem
- Installation::, for details).
-
-`posix/*'
- Files needed for building `gawk' on POSIX-compliant systems.
-
-`pc/*'
- Files needed for building `gawk' under MS-DOS, MS Windows and OS/2
- (*note PC Installation::, for details).
-
-`vms/*'
- Files needed for building `gawk' under VMS (*note VMS
- Installation::, for details).
-
-`test/*'
- A test suite for `gawk'. You can use `make check' from the
- top-level `gawk' directory to run your version of `gawk' against
- the test suite. If `gawk' successfully passes `make check', then
- you can be confident of a successful port.
-
-B.2 Compiling and Installing `gawk' on Unix
-===========================================
-
-Usually, you can compile and install `gawk' by typing only two
-commands. However, if you use an unusual system, you may need to
-configure `gawk' for your system yourself.
-
-B.2.1 Compiling `gawk' for Unix
--------------------------------
-
-After you have extracted the `gawk' distribution, `cd' to
-`gawk-3.1.4'. Like most GNU software, `gawk' is configured
-automatically for your Unix system by running the `configure' program.
-This program is a Bourne shell script that is generated automatically
-using GNU `autoconf'. (The `autoconf' software is described fully
-starting with *Note Top::.)
-
- To configure `gawk', simply run `configure':
-
- sh ./configure
-
- This produces a `Makefile' and `config.h' tailored to your system.
-The `config.h' file describes various facts about your system. You
-might want to edit the `Makefile' to change the `CFLAGS' variable,
-which controls the command-line options that are passed to the C
-compiler (such as optimization levels or compiling for debugging).
-
- Alternatively, you can add your own values for most `make' variables
-on the command line, such as `CC' and `CFLAGS', when running
-`configure':
-
- CC=cc CFLAGS=-g sh ./configure
-
-See the file `INSTALL' in the `gawk' distribution for all the details.
-
- After you have run `configure' and possibly edited the `Makefile',
-type:
-
- make
-
-Shortly thereafter, you should have an executable version of `gawk'.
-That's all there is to it! To verify that `gawk' is working properly,
-run `make check'. All of the tests should succeed. If these steps do
-not work, or if any of the tests fail, check the files in the
-`README_d' directory to see if you've found a known problem. If the
-failure is not described there, please send in a bug report (*note
-Bugs::.)
-
-B.2.2 Additional Configuration Options
---------------------------------------
-
-There are several additional options you may use on the `configure'
-command line when compiling `gawk' from scratch, including:
-
-`--enable-portals'
- Treat pathnames that begin with `/p' as BSD portal files when
- doing two-way I/O with the `|&' operator (*note Portal Files::).
-
-`--enable-switch'
- Enable the recognition and execution of C-style `switch' statements
- in `awk' programs (*note Switch Statement::.)
-
-`--with-included-gettext'
- Use the version of the `gettext' library that comes with `gawk'.
- This option should be used on systems that do _not_ use version 2
- (or later) of the GNU C library. All known modern GNU/Linux
- systems use Glibc 2. Use this option on any other system.
-
-`--disable-lint'
- This option disables all lint checking within `gawk'. The
- `--lint' and `--lint-old' options (*note Options::) are accepted,
- but silently do nothing. Similarly, setting the `LINT' variable
- (*note User-modified::) has no effect on the running `awk' program.
-
- When used with GCC's automatic dead-code-elimination, this option
- cuts almost 200K bytes off the size of the `gawk' executable on
- GNU/Linux x86 systems. Results on other systems and with other
- compilers are likely to vary. Using this option may bring you
- some slight performance improvement.
-
- Using this option will cause some of the tests in the test suite
- to fail. This option may be removed at a later date.
-
-`--disable-nls'
- Disable all message-translation facilities. This is usually not
- desirable, but it may bring you some slight performance
- improvement. You should also use this option if
- `--with-included-gettext' doesn't work on your system.
-
-B.2.3 The Configuration Process
--------------------------------
-
-This minor node is of interest only if you know something about using
-the C language and the Unix operating system.
-
- The source code for `gawk' generally attempts to adhere to formal
-standards wherever possible. This means that `gawk' uses library
-routines that are specified by the ISO C standard and by the POSIX
-operating system interface standard. When using an ISO C compiler,
-function prototypes are used to help improve the compile-time checking.
-
- Many Unix systems do not support all of either the ISO or the POSIX
-standards. The `missing_d' subdirectory in the `gawk' distribution
-contains replacement versions of those functions that are most likely
-to be missing.
-
- The `config.h' file that `configure' creates contains definitions
-that describe features of the particular operating system where you are
-attempting to compile `gawk'. The three things described by this file
-are: what header files are available, so that they can be correctly
-included, what (supposedly) standard functions are actually available
-in your C libraries, and various miscellaneous facts about your variant
-of Unix. For example, there may not be an `st_blksize' element in the
-`stat' structure. In this case, `HAVE_ST_BLKSIZE' is undefined.
-
- It is possible for your C compiler to lie to `configure'. It may do
-so by not exiting with an error when a library function is not
-available. To get around this, edit the file `custom.h'. Use an
-`#ifdef' that is appropriate for your system, and either `#define' any
-constants that `configure' should have defined but didn't, or `#undef'
-any constants that `configure' defined and should not have. `custom.h'
-is automatically included by `config.h'.
-
- It is also possible that the `configure' program generated by
-`autoconf' will not work on your system in some other fashion. If you
-do have a problem, the file `configure.in' is the input for `autoconf'.
-You may be able to change this file and generate a new version of
-`configure' that works on your system (*note Bugs::, for information on
-how to report problems in configuring `gawk'). The same mechanism may
-be used to send in updates to `configure.in' and/or `custom.h'.
-
-B.3 Installation on Other Operating Systems
-===========================================
-
-This minor node describes how to install `gawk' on various non-Unix
-systems.
-
-B.3.1 Installing `gawk' on an Amiga
------------------------------------
-
-You can install `gawk' on an Amiga system using a Unix emulation
-environment, available via anonymous `ftp' from `ftp.ninemoons.com' in
-the directory `pub/ade/current'. This includes a shell based on
-`pdksh'. The primary component of this environment is a Unix emulation
-library, `ixemul.lib'.
-
- A more complete distribution for the Amiga is available on the Geek
-Gadgets CD-ROM, available from:
-
- CRONUS
- 1840 E. Warner Road #105-265
- Tempe, AZ 85284 USA
- US Toll Free: (800) 804-0833
- Phone: +1-602-491-0442
- FAX: +1-602-491-0048
- Email: <address@hidden>
- WWW: `http://www.ninemoons.com'
- Anonymous `ftp' site: `ftp.ninemoons.com'
-
- Once you have the distribution, you can configure `gawk' simply by
-running `configure':
-
- configure -v m68k-amigaos
-
- Then run `make' and you should be all set! If these steps do not
-work, please send in a bug report (*note Bugs::).
-
-B.3.2 Installing `gawk' on BeOS
--------------------------------
-
-Since BeOS DR9, all the tools that you should need to build `gawk' are
-included with BeOS. The process is basically identical to the Unix
-process of running `configure' and then `make'. Full instructions are
-given below.
-
- You can compile `gawk' under BeOS by extracting the standard sources
-and running `configure'. You _must_ specify the location prefix for the
-installation directory. For BeOS DR9 and beyond, the best directory to
-use is `/boot/home/config', so the `configure' command is:
-
- configure --prefix=/boot/home/config
-
- This installs the compiled application into `/boot/home/config/bin',
-which is already specified in the standard `PATH'.
-
- Once the configuration process is completed, you can run `make', and
-then `make install':
-
- $ make
- ...
- $ make install
-
- BeOS uses `bash' as its shell; thus, you use `gawk' the same way you
-would under Unix. If these steps do not work, please send in a bug
-report (*note Bugs::).
-
-B.3.3 Installation on PC Operating Systems
-------------------------------------------
-
-This minor node covers installation and usage of `gawk' on x86 machines
-running DOS, any version of Windows, or OS/2. In this minor node, the
-term "Windows32" refers to any of Windows-95/98/ME/NT/2000.
-
- The limitations of DOS (and DOS shells under Windows or OS/2) has
-meant that various "DOS extenders" are often used with programs such as
-`gawk'. The varying capabilities of Microsoft Windows 3.1 and
-Windows32 can add to the confusion. For an overview of the
-considerations, please refer to `README_d/README.pc' in the
-distribution.
-
-B.3.3.1 Installing a Prepared Distribution for PC Systems
-.........................................................
-
-If you have received a binary distribution prepared by the DOS
-maintainers, then `gawk' and the necessary support files appear under
-the `gnu' directory, with executables in `gnu/bin', libraries in
-`gnu/lib/awk', and manual pages under `gnu/man'. This is designed for
-easy installation to a `/gnu' directory on your drive--however, the
-files can be installed anywhere provided `AWKPATH' is set properly.
-Regardless of the installation directory, the first line of `igawk.cmd'
-and `igawk.bat' (in `gnu/bin') may need to be edited.
-
- The binary distribution contains a separate file describing the
-contents. In particular, it may include more than one version of the
-`gawk' executable.
-
- OS/2 (32 bit, EMX) binary distributions are prepared for the `/usr'
-directory of your preferred drive. Set `UNIXROOT' to your installation
-drive (e.g., `e:') if you want to install `gawk' onto another drive
-than the hardcoded default `c:'. Executables appear in `/usr/bin',
-libraries under `/usr/share/awk', manual pages under `/usr/man',
-Texinfo documentation under `/usr/info' and NLS files under
-`/usr/share/locale'. If you already have a file `/usr/info/dir' from
-another package _do not overwrite it!_ Instead enter the following
-commands at your prompt (replace `x:' by your installation drive):
-
- install-info --info-dir=x:/usr/info x:/usr/info/gawk.info
- install-info --info-dir=x:/usr/info x:/usr/info/gawkinet.info
-
- However, the files can be installed anywhere provided `AWKPATH' is
-set properly.
-
- The binary distribution may contain a separate file containing
-additional or more detailed installation instructions.
-
-B.3.3.2 Compiling `gawk' for PC Operating Systems
-.................................................
-
-`gawk' can be compiled for MS-DOS, Windows32, and OS/2 using the GNU
-development tools from DJ Delorie (DJGPP; MS-DOS only) or Eberhard
-Mattes (EMX; MS-DOS, Windows32 and OS/2). Microsoft Visual C/C++ can
-be used to build a Windows32 version, and Microsoft C/C++ can be used
-to build 16-bit versions for MS-DOS and OS/2. (As of `gawk' 3.1.2, the
-MSC version doesn't work. However, the maintainer is working on fixing
-it.) The file `README_d/README.pc' in the `gawk' distribution contains
-additional notes, and `pc/Makefile' contains important information on
-compilation options.
-
- To build `gawk' for MS-DOS, Windows32, and OS/2 (16 bit only; for 32
-bit (EMX) you can use the `configure' script and skip the following
-paragraphs; for details see below), copy the files in the `pc'
-directory (_except_ for `ChangeLog') to the directory with the rest of
-the `gawk' sources. The `Makefile' contains a configuration section
-with comments and may need to be edited in order to work with your
-`make' utility.
-
- The `Makefile' contains a number of targets for building various
-MS-DOS, Windows32, and OS/2 versions. A list of targets is printed if
-the `make' command is given without a target. As an example, to build
-`gawk' using the DJGPP tools, enter `make djgpp'. (The DJGPP tools may
-be found at `ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/'.)
-
- Using `make' to run the standard tests and to install `gawk'
-requires additional Unix-like tools, including `sh', `sed', and `cp'.
-In order to run the tests, the `test/*.ok' files may need to be
-converted so that they have the usual DOS-style end-of-line markers.
-Most of the tests work properly with Stewartson's shell along with the
-companion utilities or appropriate GNU utilities. However, some
-editing of `test/Makefile' is required. It is recommended that you copy
-the file `pc/Makefile.tst' over the file `test/Makefile' as a
-replacement. Details can be found in `README_d/README.pc' and in the
-file `pc/Makefile.tst'.
-
- The 32 bit EMX version of `gawk' works "out of the box" under OS/2.
-In principle, it is possible to compile `gawk' the following way:
-
- $ ./configure
- $ make
-
- This is not recommended, though. To get an OMF executable you should
-use the following commands at your `sh' prompt:
-
- $ CPPFLAGS="-D__ST_MT_ERRNO__"
- $ export CPPFLAGS
- $ CFLAGS="-O2 -Zomf -Zmt"
- $ export CFLAGS
- $ LDFLAGS="-s -Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack
0x8000"
- $ export LDFLAGS
- $ RANLIB="echo"
- $ export RANLIB
- $ ./configure --prefix=c:/usr --without-included-gettext
- $ make AR=emxomfar
-
- These are just suggestions. You may use any other set of
-(self-consistent) environment variables and compiler flags.
-
- To get an FHS-compliant file hierarchy it is recommended to use the
-additional `configure' options `--infodir=c:/usr/share/info',
-`--mandir=c:/usr/share/man' and `--libexecdir=c:/usr/lib'.
-
- The internal `gettext' library tends to be problematic. It is
-therefore recommended to use either an external one
-(`--without-included-gettext') or to disable NLS entirely
-(`--disable-nls').
-
- If you use GCC 2.95 or newer it is recommended to use also:
-
- $ LIBS="-lgcc"
- $ export LIBS
-
- You can also get an `a.out' executable if you prefer:
-
- $ CPPFLAGS="-D__ST_MT_ERRNO__"
- $ export CPPFLAGS
- $ CFLAGS="-O2 -Zmt"
- $ export CFLAGS
- $ LDFLAGS="-s -Zstack 0x8000"
- $ LIBS="-lgcc"
- $ unset RANLIB
- $ ./configure --prefix=c:/usr --without-included-gettext
- $ make
-
- NOTE: Even if the compiled `gawk.exe' (`a.out') executable
- contains a DOS header, it does _not_ work under DOS. To compile an
- executable that runs under DOS, `"-DPIPES_SIMULATED"' must be
- added to `CPPFLAGS'. But then some nonstandard extensions of
- `gawk' (e.g., `|&') do not work!
-
- After compilation the internal tests can be performed. Enter `make
-check CMP="diff -a"' at your command prompt. All tests but the `pid'
-test are expected to work properly. The `pid' test fails because child
-processes are not started by `fork()'.
-
- `make install' works as expected.
-
- NOTE: Most OS/2 ports of GNU `make' are not able to handle the
- Makefiles of this package. If you encounter any problems with
- `make' try GNU Make 3.79.1 or later versions. You should find the
- latest version on `http://www.unixos2.org/sw/pub/binary/make/' or
- on `ftp://hobbes.nmsu.edu/pub/os2/'.
-
-B.3.3.3 Compiling `gawk' For Dynamic Libraries
-..............................................
-
-To compile `gawk' with dynamic extension support, uncomment the
-definitions of `DYN_FLAGS', `DYN_EXP', `DYN_OBJ', and `DYN_MAKEXP' in
-the configuration section of the `Makefile'. There are two definitions
-for `DYN_MAKEXP': pick the one that matches your target.
-
- To build some of the example extension libraries, `cd' to the
-extension directory and copy `Makefile.pc' to `Makefile'. You can then
-build using the same two targets. To run the example `awk' scripts,
-you'll need to either change the call to the `extension' function to
-match the name of the library (for instance, change `"./ordchr.so"' to
-`"ordchr.dll"' or simply `"ordchr"'), or rename the library to match
-the call (for instance, rename `ordchr.dll' to `ordchr.so').
-
- If you build `gawk.exe' with one compiler but want to build an
-extension library with the other, you need to copy the import library.
-Visual C uses a library called `gawk.lib', while MinGW uses a library
-called `libgawk.a'. These files are equivalent and will interoperate if
-you give them the correct name. The resulting shared libraries are
-also interoperable.
-
- To create your own extension library, you can use the examples as
-models, but you're essentially on your own. Post to `comp.lang.awk' or
-send electronic mail to <address@hidden> if you have problems getting
-started. If you need to access functions or variables which are not
-exported by `gawk.exe', add them to `gawkw32.def' and rebuild. You
-should also add `ATTRIBUTE_EXPORTED' to the declaration in `awk.h' of
-any variables you add to `gawkw32.def'.
-
- Note that extension libraries have the name of the `awk' executable
-embedded in them at link time, so they will work only with `gawk.exe'.
-In particular, they won't work if you rename `gawk.exe' to `awk.exe' or
-if you try to use `pgawk.exe'. You can perform profiling by temporarily
-renaming `pgawk.exe' to `gawk.exe'. You can resolve this problem by
-changing the program name in the definition of `DYN_MAKEXP' for your
-compiler.
-
- On Windows32, libraries are sought first in the current directory,
-then in the directory containing `gawk.exe', and finally through the
-`PATH' environment variable.
-
-B.3.3.4 Using `gawk' on PC Operating Systems
-............................................
-
-With the exception of the Cygwin environment, the `|&' operator and
-TCP/IP networking (*note TCP/IP Networking::) are not supported for
-MS-DOS or MS-Windows. EMX (OS/2 only) does support at least the `|&'
-operator.
-
- The OS/2 and MS-DOS versions of `gawk' search for program files as
-described in *Note AWKPATH Variable::. However, semicolons (rather
-than colons) separate elements in the `AWKPATH' variable. If `AWKPATH'
-is not set or is empty, then the default search path for OS/2 (16 bit)
-and MS-DOS versions is `".;c:/lib/awk;c:/gnu/lib/awk"'.
-
- The search path for OS/2 (32 bit, EMX) is determined by the prefix
-directory (most likely `/usr' or `c:/usr') that has been specified as
-an option of the `configure' script like it is the case for the Unix
-versions. If `c:/usr' is the prefix directory then the default search
-path contains `.' and `c:/usr/share/awk'. Additionally, to support
-binary distributions of `gawk' for OS/2 systems whose drive `c:' might
-not support long file names or might not exist at all, there is a
-special environment variable. If `UNIXROOT' specifies a drive then this
-specific drive is also searched for program files. E.g., if `UNIXROOT'
-is set to `e:' the complete default search path is
-`".;c:/usr/share/awk;e:/usr/share/awk"'.
-
- An `sh'-like shell (as opposed to `command.com' under MS-DOS or
-`cmd.exe' under OS/2) may be useful for `awk' programming. Ian
-Stewartson has written an excellent shell for MS-DOS and OS/2, Daisuke
-Aoyama has ported GNU `bash' to MS-DOS using the DJGPP tools, and
-several shells are available for OS/2, including `ksh'. The file
-`README_d/README.pc' in the `gawk' distribution contains information on
-these shells. Users of Stewartson's shell on DOS should examine its
-documentation for handling command lines; in particular, the setting
-for `gawk' in the shell configuration may need to be changed and the
-`ignoretype' option may also be of interest.
-
- Under OS/2 and DOS, `gawk' (and many other text programs) silently
-translate end-of-line `"\r\n"' to `"\n"' on input and `"\n"' to
-`"\r\n"' on output. A special `BINMODE' variable allows control over
-these translations and is interpreted as follows:
-
- * If `BINMODE' is `"r"', or `(BINMODE & 1)' is nonzero, then binary
- mode is set on read (i.e., no translations on reads).
-
- * If `BINMODE' is `"w"', or `(BINMODE & 2)' is nonzero, then binary
- mode is set on write (i.e., no translations on writes).
-
- * If `BINMODE' is `"rw"' or `"wr"', binary mode is set for both read
- and write (same as `(BINMODE & 3)').
-
- * `BINMODE=NON-NULL-STRING' is the same as `BINMODE=3' (i.e., no
- translations on reads or writes). However, `gawk' issues a warning
- message if the string is not one of `"rw"' or `"wr"'.
-
-The modes for standard input and standard output are set one time only
-(after the command line is read, but before processing any of the `awk'
-program). Setting `BINMODE' for standard input or standard output is
-accomplished by using an appropriate `-v BINMODE=N' option on the
-command line. `BINMODE' is set at the time a file or pipe is opened
-and cannot be changed mid-stream.
-
- The name `BINMODE' was chosen to match `mawk' (*note Other
-Versions::). Both `mawk' and `gawk' handle `BINMODE' similarly;
-however, `mawk' adds a `-W BINMODE=N' option and an environment
-variable that can set `BINMODE', `RS', and `ORS'. The files
-`binmode[1-3].awk' (under `gnu/lib/awk' in some of the prepared
-distributions) have been chosen to match `mawk''s `-W BINMODE=N'
-option. These can be changed or discarded; in particular, the setting
-of `RS' giving the fewest "surprises" is open to debate. `mawk' uses
-`RS = "\r\n"' if binary mode is set on read, which is appropriate for
-files with the DOS-style end-of-line.
-
- To illustrate, the following examples set binary mode on writes for
-standard output and other files, and set `ORS' as the "usual" DOS-style
-end-of-line:
-
- gawk -v BINMODE=2 -v ORS="\r\n" ...
-
-or:
-
- gawk -v BINMODE=w -f binmode2.awk ...
-
-These give the same result as the `-W BINMODE=2' option in `mawk'. The
-following changes the record separator to `"\r\n"' and sets binary mode
-on reads, but does not affect the mode on standard input:
-
- gawk -v RS="\r\n" --source "BEGIN { BINMODE = 1 }" ...
-
-or:
-
- gawk -f binmode1.awk ...
-
-With proper quoting, in the first example the setting of `RS' can be
-moved into the `BEGIN' rule.
-
-B.3.3.5 Using `gawk' In The Cygwin Environment
-..............................................
-
-`gawk' can be used "out of the box" under Windows if you are using the
-Cygwin environment.(1) This environment provides an excellent
-simulation of Unix, using the GNU tools, such as `bash', the GNU
-Compiler Collection (GCC), GNU Make, and other GNU tools. Compilation
-and installation for Cygwin is the same as for a Unix system:
-
- tar -xvpzf gawk-3.1.4.tar.gz
- cd gawk-3.1.4
- ./configure
- make
-
- When compared to GNU/Linux on the same system, the `configure' step
-on Cygwin takes considerably longer. However, it does finish, and then
-the `make' proceeds as usual.
-
- NOTE: The `|&' operator and TCP/IP networking (*note TCP/IP
- Networking::) are fully supported in the Cygwin environment. This
- is not true for any other environment for MS-DOS or MS-Windows.
-
- ---------- Footnotes ----------
-
- (1) `http://www.cygwin.com'
-
-B.3.4 How to Compile and Install `gawk' on VMS
-----------------------------------------------
-
-This node describes how to compile and install `gawk' under VMS.
-
-B.3.4.1 Compiling `gawk' on VMS
-...............................
-
-To compile `gawk' under VMS, there is a `DCL' command procedure that
-issues all the necessary `CC' and `LINK' commands. There is also a
-`Makefile' for use with the `MMS' utility. From the source directory,
-use either:
-
- $ @[.VMS]VMSBUILD.COM
-
-or:
-
- $ MMS/DESCRIPTION=[.VMS]DESCRIP.MMS GAWK
-
- Depending upon which C compiler you are using, follow one of the sets
-of instructions in this table:
-
-VAX C V3.x
- Use either `vmsbuild.com' or `descrip.mms' as is. These use
- `CC/OPTIMIZE=NOLINE', which is essential for Version 3.0.
-
-VAX C V2.x
- You must have Version 2.3 or 2.4; older ones won't work. Edit
- either `vmsbuild.com' or `descrip.mms' according to the comments
- in them. For `vmsbuild.com', this just entails removing two `!'
- delimiters. Also edit `config.h' (which is a copy of file
- `[.config]vms-conf.h') and comment out or delete the two lines
- `#define __STDC__ 0' and `#define VAXC_BUILTINS' near the end.
-
-GNU C
- Edit `vmsbuild.com' or `descrip.mms'; the changes are different
- from those for VAX C V2.x but equally straightforward. No changes
- to `config.h' are needed.
-
-DEC C
- Edit `vmsbuild.com' or `descrip.mms' according to their comments.
- No changes to `config.h' are needed.
-
- `gawk' has been tested under VAX/VMS 5.5-1 using VAX C V3.2, and GNU
-C 1.40 and 2.3. It should work without modifications for VMS V4.6 and
-up.
-
-B.3.4.2 Installing `gawk' on VMS
-................................
-
-To install `gawk', all you need is a "foreign" command, which is a
-`DCL' symbol whose value begins with a dollar sign. For example:
-
- $ GAWK :== $disk1:[gnubin]GAWK
-
-Substitute the actual location of `gawk.exe' for `$disk1:[gnubin]'. The
-symbol should be placed in the `login.com' of any user who wants to run
-`gawk', so that it is defined every time the user logs on.
-Alternatively, the symbol may be placed in the system-wide
-`sylogin.com' procedure, which allows all users to run `gawk'.
-
- Optionally, the help entry can be loaded into a VMS help library:
-
- $ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP
-
-(You may want to substitute a site-specific help library rather than
-the standard VMS library `HELPLIB'.) After loading the help text, the
-command:
-
- $ HELP GAWK
-
-provides information about both the `gawk' implementation and the `awk'
-programming language.
-
- The logical name `AWK_LIBRARY' can designate a default location for
-`awk' program files. For the `-f' option, if the specified file name
-has no device or directory path information in it, `gawk' looks in the
-current directory first, then in the directory specified by the
-translation of `AWK_LIBRARY' if the file is not found. If, after
-searching in both directories, the file still is not found, `gawk'
-appends the suffix `.awk' to the filename and retries the file search.
-If `AWK_LIBRARY' is not defined, that portion of the file search fails
-benignly.
-
-B.3.4.3 Running `gawk' on VMS
-.............................
-
-Command-line parsing and quoting conventions are significantly different
-on VMS, so examples in this Info file or from other sources often need
-minor changes. They _are_ minor though, and all `awk' programs should
-run correctly.
-
- Here are a couple of trivial tests:
-
- $ gawk -- "BEGIN {print ""Hello, World!""}"
- $ gawk -"W" version
- ! could also be -"W version" or "-W version"
-
-Note that uppercase and mixed-case text must be quoted.
-
- The VMS port of `gawk' includes a `DCL'-style interface in addition
-to the original shell-style interface (see the help entry for details).
-One side effect of dual command-line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
-becomes ambiguous. To work around this, the normally optional `--'
-flag is required to force Unix style rather than `DCL' parsing. If any
-other dash-type options (or multiple parameters such as data files to
-process) are present, there is no ambiguity and `--' can be omitted.
-
- The default search path, when looking for `awk' program files
-specified by the `-f' option, is `"SYS$DISK:[],AWK_LIBRARY:"'. The
-logical name `AWKPATH' can be used to override this default. The format
-of `AWKPATH' is a comma-separated list of directory specifications.
-When defining it, the value should be quoted so that it retains a single
-translation and not a multitranslation `RMS' searchlist.
-
-B.3.4.4 Building and Using `gawk' on VMS POSIX
-..............................................
-
-Ignore the instructions above, although `vms/gawk.hlp' should still be
-made available in a help library. The source tree should be unpacked
-into a container file subsystem rather than into the ordinary VMS
-filesystem. Make sure that the two scripts, `configure' and
-`vms/posix-cc.sh', are executable; use `chmod +x' on them if necessary.
-Then execute the following two commands:
-
- psx> CC=vms/posix-cc.sh configure
- psx> make CC=c89 gawk
-
-The first command constructs files `config.h' and `Makefile' out of
-templates, using a script to make the C compiler fit `configure''s
-expectations. The second command compiles and links `gawk' using the C
-compiler directly; ignore any warnings from `make' about being unable
-to redefine `CC'. `configure' takes a very long time to execute, but
-at least it provides incremental feedback as it runs.
-
- This has been tested with VAX/VMS V6.2, VMS POSIX V2.0, and DEC C
-V5.2.
-
- Once built, `gawk' works like any other shell utility. Unlike the
-normal VMS port of `gawk', no special command-line manipulation is
-needed in the VMS POSIX environment.
-
-B.4 Unsupported Operating System Ports
-======================================
-
-This sections describes systems for which the `gawk' port is no longer
-supported.
-
-B.4.1 Installing `gawk' on the Atari ST
----------------------------------------
-
-The Atari port is no longer supported. It is included for those who
-might want to use it but it is no longer being actively maintained.
-
- There are no substantial differences when installing `gawk' on
-various Atari models. Compiled `gawk' executables do not require a
-large amount of memory with most `awk' programs, and should run on all
-Motorola processor-based models (called further ST, even if that is not
-exactly right).
-
- In order to use `gawk', you need to have a shell, either text or
-graphics, that does not map all the characters of a command line to
-uppercase. Maintaining case distinction in option flags is very
-important (*note Options::). These days this is the default and it may
-only be a problem for some very old machines. If your system does not
-preserve the case of option flags, you need to upgrade your tools.
-Support for I/O redirection is necessary to make it easy to import
-`awk' programs from other environments. Pipes are nice to have but not
-vital.
-
-B.4.1.1 Compiling `gawk' on the Atari ST
-........................................
-
-A proper compilation of `gawk' sources when `sizeof(int)' differs from
-`sizeof(void *)' requires an ISO C compiler. An initial port was done
-with `gcc'. You may actually prefer executables where `int's are four
-bytes wide but the other variant works as well.
-
- You may need quite a bit of memory when trying to recompile the
-`gawk' sources, as some source files (`regex.c' in particular) are quite
-big. If you run out of memory compiling such a file, try reducing the
-optimization level for this particular file, which may help.
-
- With a reasonable shell (`bash' will do), you have a pretty good
-chance that the `configure' utility will succeed, and in particular if
-you run GNU/Linux, MiNT or a similar operating system. Otherwise
-sample versions of `config.h' and `Makefile.st' are given in the
-`atari' subdirectory and can be edited and copied to the corresponding
-files in the main source directory. Even if `configure' produces
-something, it might be advisable to compare its results with the sample
-versions and possibly make adjustments.
-
- Some `gawk' source code fragments depend on a preprocessor define
-`atarist'. This basically assumes the TOS environment with `gcc'.
-Modify these sections as appropriate if they are not right for your
-environment. Also see the remarks about `AWKPATH' and `envsep' in
-*Note Atari Using::.
-
- As shipped, the sample `config.h' claims that the `system' function
-is missing from the libraries, which is not true, and an alternative
-implementation of this function is provided in
-`unsupported/atari/system.c'. Depending upon your particular
-combination of shell and operating system, you might want to change the
-file to indicate that `system' is available.
-
-B.4.1.2 Running `gawk' on the Atari ST
-......................................
-
-An executable version of `gawk' should be placed, as usual, anywhere in
-your `PATH' where your shell can find it.
-
- While executing, the Atari version of `gawk' creates a number of
-temporary files. When using `gcc' libraries for TOS, `gawk' looks for
-either of the environment variables, `TEMP' or `TMPDIR', in that order.
-If either one is found, its value is assumed to be a directory for
-temporary files. This directory must exist, and if you can spare the
-memory, it is a good idea to put it on a RAM drive. If neither `TEMP'
-nor `TMPDIR' are found, then `gawk' uses the current directory for its
-temporary files.
-
- The ST version of `gawk' searches for its program files, as
-described in *Note AWKPATH Variable::. The default value for the
-`AWKPATH' variable is taken from `DEFPATH' defined in `Makefile'. The
-sample `gcc'/TOS `Makefile' for the ST in the distribution sets
-`DEFPATH' to `".,c:\lib\awk,c:\gnu\lib\awk"'. The search path can be
-modified by explicitly setting `AWKPATH' to whatever you want. Note
-that colons cannot be used on the ST to separate elements in the
-`AWKPATH' variable, since they have another reserved meaning. Instead,
-you must use a comma to separate elements in the path. When
-recompiling, the separating character can be modified by initializing
-the `envsep' variable in `unsupported/atari/gawkmisc.atr' to another
-value.
-
- Although `awk' allows great flexibility in doing I/O redirections
-from within a program, this facility should be used with care on the ST
-running under TOS. In some circumstances, the OS routines for
-file-handle pool processing lose track of certain events, causing the
-computer to crash and requiring a reboot. Often a warm reboot is
-sufficient. Fortunately, this happens infrequently and in rather
-esoteric situations. In particular, avoid having one part of an `awk'
-program using `print' statements explicitly redirected to
-`/dev/stdout', while other `print' statements use the default standard
-output, and a calling shell has redirected standard output to a file.
-
- When `gawk' is compiled with the ST version of `gcc' and its usual
-libraries, it accepts both `/' and `\' as path separators. While this
-is convenient, it should be remembered that this removes one
-technically valid character (`/') from your file name. It may also
-create problems for external programs called via the `system' function,
-which may not support this convention. Whenever it is possible that a
-file created by `gawk' will be used by some other program, use only
-backslashes. Also remember that in `awk', backslashes in strings have
-to be doubled in order to get literal backslashes (*note Escape
-Sequences::).
-
-B.4.2 Installing `gawk' on a Tandem
------------------------------------
-
-The Tandem port is only minimally supported. The port's contributor no
-longer has access to a Tandem system.
-
- The Tandem port was done on a Cyclone machine running D20. The port
-is pretty clean and all facilities seem to work except for the I/O
-piping facilities (*note Getline/Pipe::, *Note Getline/Variable/Pipe::,
-and *Note Redirection::), which is just too foreign a concept for
-Tandem.
-
- To build a Tandem executable from source, download all of the files
-so that the file names on the Tandem box conform to the restrictions of
-D20. For example, `array.c' becomes `ARRAYC', and `awk.h' becomes
-`AWKH'. The totally Tandem-specific files are in the `tandem'
-"subvolume" (`unsupported/tandem' in the `gawk' distribution) and
-should be copied to the main source directory before building `gawk'.
-
- The file `compit' can then be used to compile and bind an executable.
-Alas, there is no `configure' or `make'.
-
- Usage is the same as for Unix, except that D20 requires all `{' and
-`}' characters to be escaped with `~' on the command line (but _not_ in
-script files). Also, the standard Tandem syntax for `/in filename,out
-filename/' must be used instead of the usual Unix `<' and `>' for file
-redirection. (Redirection options on `getline', `print' etc., are
-supported.)
-
- The `-mr VAL' option (*note Options::) has been "stolen" to enable
-Tandem users to process fixed-length records with no "end-of-line"
-character. That is, `-mr 74' tells `gawk' to read the input file as
-fixed 74-byte records.
-
-B.5 Reporting Problems and Bugs
-===============================
-
- There is nothing more dangerous than a bored archeologist.
- The Hitchhiker's Guide to the Galaxy
-
- If you have problems with `gawk' or think that you have found a bug,
-please report it to the developers; we cannot promise to do anything
-but we might well want to fix it.
-
- Before reporting a bug, make sure you have actually found a real bug.
-Carefully reread the documentation and see if it really says you can do
-what you're trying to do. If it's not clear whether you should be able
-to do something or not, report that too; it's a bug in the
-documentation!
-
- Before reporting a bug or trying to fix it yourself, try to isolate
-it to the smallest possible `awk' program and input data file that
-reproduces the problem. Then send us the program and data file, some
-idea of what kind of Unix system you're using, the compiler you used to
-compile `gawk', and the exact results `gawk' gave you. Also say what
-you expected to occur; this helps us decide whether the problem is
-really in the documentation.
-
- Once you have a precise problem, send email to <address@hidden>.
-
- Please include the version number of `gawk' you are using. You can
-get this information with the command `gawk --version'. Using this
-address automatically sends a carbon copy of your mail to me. If
-necessary, I can be reached directly at <address@hidden>. The bug
-reporting address is preferred since the email list is archived at the
-GNU Project. _All email should be in English, since that is my native
-language._
-
- *Caution:* Do _not_ try to report bugs in `gawk' by posting to the
-Usenet/Internet newsgroup `comp.lang.awk'. While the `gawk' developers
-do occasionally read this newsgroup, there is no guarantee that we will
-see your posting. The steps described above are the official
-recognized ways for reporting bugs.
-
- Non-bug suggestions are always welcome as well. If you have
-questions about things that are unclear in the documentation or are
-just obscure features, ask me; I will try to help you out, although I
-may not have the time to fix the problem. You can send me electronic
-mail at the Internet address noted previously.
-
- If you find bugs in one of the non-Unix ports of `gawk', please send
-an electronic mail message to the person who maintains that port. They
-are named in the following list, as well as in the `README' file in the
-`gawk' distribution. Information in the `README' file should be
-considered authoritative if it conflicts with this Info file.
-
- The people maintaining the non-Unix ports of `gawk' are as follows:
-
-Amiga Fred Fish, <address@hidden>.
-BeOS Martin Brown, <address@hidden>.
-MS-DOS Scott Deifik, <address@hidden> and Darrel
- Hankerson, <address@hidden>.
-MS-Windows Juan Grigera, <address@hidden>.
-OS/2 The Unix for OS/2 team,
- <address@hidden>.
-Tandem Stephen Davies, <address@hidden>.
-VMS Pat Rankin, <address@hidden>.
-
- If your bug is also reproducible under Unix, please send a copy of
-your report to the <address@hidden> email list as well.
-
-B.6 Other Freely Available `awk' Implementations
-================================================
-
- It's kind of fun to put comments like this in your awk code.
- `// Do C++ comments work? answer: yes! of course'
- Michael Brennan
-
- There are three other freely available `awk' implementations. This
-minor node briefly describes where to get them:
-
-Unix `awk'
- Brian Kernighan has made his implementation of `awk' freely
- available. You can retrieve this version via the World Wide Web
- from his home page.(1) It is available in several archive formats:
-
- Shell archive
- `http://cm.bell-labs.com/who/bwk/awk.shar'
-
- Compressed `tar' file
- `http://cm.bell-labs.com/who/bwk/awk.tar.gz'
-
- Zip file
- `http://cm.bell-labs.com/who/bwk/awk.zip'
-
- This version requires an ISO C (1990 standard) compiler; the C
- compiler from GCC (the GNU Compiler Collection) works quite nicely.
-
- *Note BTL::, for a list of extensions in this `awk' that are not
- in POSIX `awk'.
-
-`mawk'
- Michael Brennan has written an independent implementation of `awk',
- called `mawk'. It is available under the GPL (*note Copying::),
- just as `gawk' is.
-
- You can get it via anonymous `ftp' to the host `ftp.whidbey.net'.
- Change directory to `/pub/brennan'. Use "binary" or "image" mode,
- and retrieve `mawk1.3.3.tar.gz' (or the latest version that is
- there).
-
- `gunzip' may be used to decompress this file. Installation is
- similar to `gawk''s (*note Unix Installation::).
-
- `mawk' has the following extensions that are not in POSIX `awk':
-
- * The `fflush' built-in function for flushing buffered output
- (*note I/O Functions::).
-
- * The `**' and `**=' operators (*note Arithmetic Ops:: and also
- see *Note Assignment Ops::).
-
- * The use of `func' as an abbreviation for `function' (*note
- Definition Syntax::).
-
- * The `\x' escape sequence (*note Escape Sequences::).
-
- * The `/dev/stdout', and `/dev/stderr' special files (*note
- Special Files::). Use `"-"' instead of `"/dev/stdin"' with
- `mawk'.
-
- * The ability for `FS' and for the third argument to `split' to
- be null strings (*note Single Character Fields::).
-
- * The ability to delete all of an array at once with `delete
- ARRAY' (*note Delete::).
-
- * The ability for `RS' to be a regexp (*note Records::).
-
- * The `BINMODE' special variable for non-Unix operating systems
- (*note PC Using::).
-
- The next version of `mawk' will support `nextfile'.
-
-`awka'
- Written by Andrew Sumner, `awka' translates `awk' programs into C,
- compiles them, and links them with a library of functions that
- provides the core `awk' functionality. It also has a number of
- extensions.
-
- The `awk' translator is released under the GPL, and the library is
- under the LGPL.
-
- To get `awka', go to `http://awka.sourceforge.net'. You can reach
- Andrew Sumner at <address@hidden>.
-
-`pawk'
- Nelson H.F. Beebe at the University of Utah has modified the Bell
- Labs `awk' to provide timing and profiling information. It is
- different from `pgawk' (*note Profiling::), in that it uses
- CPU-based profiling, not line-count profiling. You may find it at
- either `ftp://ftp.math.utah.edu/pub/pawk/pawk-20020210.tar.gz' or
- `http://www.math.utah.edu/pub/pawk/pawk-20020210.tar.gz'.
-
-
- ---------- Footnotes ----------
-
- (1) `http://cm.bell-labs.com/who/bwk'
-
-Appendix C Implementation Notes
-*******************************
-
-This appendix contains information mainly of interest to implementors
-and maintainers of `gawk'. Everything in it applies specifically to
-`gawk' and not to other implementations.
-
-C.1 Downward Compatibility and Debugging
-========================================
-
-*Note POSIX/GNU::, for a summary of the GNU extensions to the `awk'
-language and program. All of these features can be turned off by
-invoking `gawk' with the `--traditional' option or with the `--posix'
-option.
-
- If `gawk' is compiled for debugging with `-DDEBUG', then there is
-one more option available on the command line:
-
-`-W parsedebug'
-`--parsedebug'
- Prints out the parse stack information as the program is being
- parsed.
-
- This option is intended only for serious `gawk' developers and not
-for the casual user. It probably has not even been compiled into your
-version of `gawk', since it slows down execution.
-
-C.2 Making Additions to `gawk'
-==============================
-
-If you find that you want to enhance `gawk' in a significant fashion,
-you are perfectly free to do so. That is the point of having free
-software; the source code is available and you are free to change it as
-you want (*note Copying::).
-
- This minor node discusses the ways you might want to change `gawk'
-as well as any considerations you should bear in mind.
-
-C.2.1 Adding New Features
--------------------------
-
-You are free to add any new features you like to `gawk'. However, if
-you want your changes to be incorporated into the `gawk' distribution,
-there are several steps that you need to take in order to make it
-possible for me to include your changes:
-
- 1. Before building the new feature into `gawk' itself, consider
- writing it as an extension module (*note Dynamic Extensions::).
- If that's not possible, continue with the rest of the steps in
- this list.
-
- 2. Get the latest version. It is much easier for me to integrate
- changes if they are relative to the most recent distributed
- version of `gawk'. If your version of `gawk' is very old, I may
- not be able to integrate them at all. (*Note Getting::, for
- information on getting the latest version of `gawk'.)
-
- 3. See *note (Version)Top:: standards, GNU Coding Standards. This
- document describes how GNU software should be written. If you
- haven't read it, please do so, preferably _before_ starting to
- modify `gawk'. (The `GNU Coding Standards' are available from the
- GNU Project's `ftp' site, at
- `ftp://ftp.gnu.org/gnu/GNUinfo/standards.text'. An HTML version,
- suitable for reading with a WWW browser, is available at
- `http://www.gnu.org/prep/standards_toc.html'. Texinfo, Info, and
- DVI versions are also available.)
-
- 4. Use the `gawk' coding style. The C code for `gawk' follows the
- instructions in the `GNU Coding Standards', with minor exceptions.
- The code is formatted using the traditional "K&R" style,
- particularly as regards to the placement of braces and the use of
- tabs. In brief, the coding rules for `gawk' are as follows:
-
- * Use ANSI/ISO style (prototype) function headers when defining
- functions.
-
- * Put the name of the function at the beginning of its own line.
-
- * Put the return type of the function, even if it is `int', on
- the line above the line with the name and arguments of the
- function.
-
- * Put spaces around parentheses used in control structures
- (`if', `while', `for', `do', `switch', and `return').
-
- * Do not put spaces in front of parentheses used in function
- calls.
-
- * Put spaces around all C operators and after commas in
- function calls.
-
- * Do not use the comma operator to produce multiple side
- effects, except in `for' loop initialization and increment
- parts, and in macro bodies.
-
- * Use real tabs for indenting, not spaces.
-
- * Use the "K&R" brace layout style.
-
- * Use comparisons against `NULL' and `'\0'' in the conditions of
- `if', `while', and `for' statements, as well as in the `case's
- of `switch' statements, instead of just the plain pointer or
- character value.
-
- * Use the `TRUE', `FALSE' and `NULL' symbolic constants and the
- character constant `'\0'' where appropriate, instead of `1'
- and `0'.
-
- * Use the `ISALPHA', `ISDIGIT', etc. macros, instead of the
- traditional lowercase versions; these macros are better
- behaved for non-ASCII character sets.
-
- * Provide one-line descriptive comments for each function.
-
- * Do not use `#elif'. Many older Unix C compilers cannot handle
- it.
-
- * Do not use the `alloca' function for allocating memory off
- the stack. Its use causes more portability trouble than is
- worth the minor benefit of not having to free the storage.
- Instead, use `malloc' and `free'.
-
- NOTE: If I have to reformat your code to follow the coding
- style used in `gawk', I may not bother to integrate your
- changes at all.
-
- 5. Be prepared to sign the appropriate paperwork. In order for the
- FSF to distribute your changes, you must either place those
- changes in the public domain and submit a signed statement to that
- effect, or assign the copyright in your changes to the FSF. Both
- of these actions are easy to do and _many_ people have done so
- already. If you have questions, please contact me (*note Bugs::),
- or <address@hidden>.
-
- 6. Update the documentation. Along with your new code, please supply
- new sections and/or chapters for this Info file. If at all
- possible, please use real Texinfo, instead of just supplying
- unformatted ASCII text (although even that is better than no
- documentation at all). Conventions to be followed in `GAWK:
- Effective AWK Programming' are provided after the address@hidden' at the
- end of the Texinfo source file. If possible, please update the
- `man' page as well.
-
- You will also have to sign paperwork for your documentation
- changes.
-
- 7. Submit changes as context diffs or unified diffs. Use `diff -c -r
- -N' or `diff -u -r -N' to compare the original `gawk' source tree
- with your version. (I find context diffs to be more readable but
- unified diffs are more compact.) I recommend using the GNU
- version of `diff'. Send the output produced by either run of
- `diff' to me when you submit your changes. (*Note Bugs::, for the
- electronic mail information.)
-
- Using this format makes it easy for me to apply your changes to the
- master version of the `gawk' source code (using `patch'). If I
- have to apply the changes manually, using a text editor, I may not
- do so, particularly if there are lots of changes.
-
- 8. Include an entry for the `ChangeLog' file with your submission.
- This helps further minimize the amount of work I have to do,
- making it easier for me to accept patches.
-
- Although this sounds like a lot of work, please remember that while
-you may write the new code, I have to maintain it and support it. If it
-isn't possible for me to do that with a minimum of extra work, then I
-probably will not.
-
-C.2.2 Porting `gawk' to a New Operating System
-----------------------------------------------
-
-If you want to port `gawk' to a new operating system, there are several
-steps:
-
- 1. Follow the guidelines in *Note Adding Code::, concerning coding
- style, submission of diffs, and so on.
-
- 2. When doing a port, bear in mind that your code must coexist
- peacefully with the rest of `gawk' and the other ports. Avoid
- gratuitous changes to the system-independent parts of the code. If
- at all possible, avoid sprinkling `#ifdef's just for your port
- throughout the code.
-
- If the changes needed for a particular system affect too much of
- the code, I probably will not accept them. In such a case, you
- can, of course, distribute your changes on your own, as long as
- you comply with the GPL (*note Copying::).
-
- 3. A number of the files that come with `gawk' are maintained by other
- people at the Free Software Foundation. Thus, you should not
- change them unless it is for a very good reason; i.e., changes are
- not out of the question, but changes to these files are
- scrutinized extra carefully. The files are `getopt.h', `getopt.c',
- `getopt1.c', `regex.h', `regex.c', `dfa.h', `dfa.c', `install-sh',
- and `mkinstalldirs'.
-
- 4. Be willing to continue to maintain the port. Non-Unix operating
- systems are supported by volunteers who maintain the code needed
- to compile and run `gawk' on their systems. If noone volunteers to
- maintain a port, it becomes unsupported and it may be necessary to
- remove it from the distribution.
-
- 5. Supply an appropriate `gawkmisc.???' file. Each port has its own
- `gawkmisc.???' that implements certain operating system specific
- functions. This is cleaner than a plethora of `#ifdef's scattered
- throughout the code. The `gawkmisc.c' in the main source
- directory includes the appropriate `gawkmisc.???' file from each
- subdirectory. Be sure to update it as well.
-
- Each port's `gawkmisc.???' file has a suffix reminiscent of the
- machine or operating system for the port--for example,
- `pc/gawkmisc.pc' and `vms/gawkmisc.vms'. The use of separate
- suffixes, instead of plain `gawkmisc.c', makes it possible to move
- files from a port's subdirectory into the main subdirectory,
- without accidentally destroying the real `gawkmisc.c' file.
- (Currently, this is only an issue for the PC operating system
- ports.)
-
- 6. Supply a `Makefile' as well as any other C source and header files
- that are necessary for your operating system. All your code
- should be in a separate subdirectory, with a name that is the same
- as, or reminiscent of, either your operating system or the
- computer system. If possible, try to structure things so that it
- is not necessary to move files out of the subdirectory into the
- main source directory. If that is not possible, then be sure to
- avoid using names for your files that duplicate the names of files
- in the main source directory.
-
- 7. Update the documentation. Please write a section (or sections)
- for this Info file describing the installation and compilation
- steps needed to compile and/or install `gawk' for your system.
-
- 8. Be prepared to sign the appropriate paperwork. In order for the
- FSF to distribute your code, you must either place your code in
- the public domain and submit a signed statement to that effect, or
- assign the copyright in your code to the FSF. Both of these
- actions are easy to do and _many_ people have done so already. If
- you have questions, please contact me, or <address@hidden>.
-
- Following these steps makes it much easier to integrate your changes
-into `gawk' and have them coexist happily with other operating systems'
-code that is already there.
-
- In the code that you supply and maintain, feel free to use a coding
-style and brace layout that suits your taste.
-
-C.3 Adding New Built-in Functions to `gawk'
-===========================================
-
- Danger Will Robinson! Danger!!
- Warning! Warning!
- The Robot
-
- Beginning with `gawk' 3.1, it is possible to add new built-in
-functions to `gawk' using dynamically loaded libraries. This facility
-is available on systems (such as GNU/Linux) that support the `dlopen'
-and `dlsym' functions. This minor node describes how to write and use
-dynamically loaded extensions for `gawk'. Experience with programming
-in C or C++ is necessary when reading this minor node.
-
- *Caution:* The facilities described in this minor node are very much
-subject to change in a future `gawk' release. Be aware that you may
-have to re-do everything, perhaps from scratch, at some future time.
-
-C.3.1 A Minimal Introduction to `gawk' Internals
-------------------------------------------------
-
-The truth is that `gawk' was not designed for simple extensibility.
-The facilities for adding functions using shared libraries work, but
-are something of a "bag on the side." Thus, this tour is brief and
-simplistic; would-be `gawk' hackers are encouraged to spend some time
-reading the source code before trying to write extensions based on the
-material presented here. Of particular note are the files `awk.h',
-`builtin.c', and `eval.c'. Reading `awk.y' in order to see how the
-parse tree is built would also be of use.
-
- With the disclaimers out of the way, the following types, structure
-members, functions, and macros are declared in `awk.h' and are of use
-when writing extensions. The next minor node shows how they are used:
-
-`AWKNUM'
- An `AWKNUM' is the internal type of `awk' floating-point numbers.
- Typically, it is a C `double'.
-
-`NODE'
- Just about everything is done using objects of type `NODE'. These
- contain both strings and numbers, as well as variables and arrays.
-
-`AWKNUM force_number(NODE *n)'
- This macro forces a value to be numeric. It returns the actual
- numeric value contained in the node. It may end up calling an
- internal `gawk' function.
-
-`void force_string(NODE *n)'
- This macro guarantees that a `NODE''s string value is current. It
- may end up calling an internal `gawk' function. It also
- guarantees that the string is zero-terminated.
-
-`size_t get_curfunc_arg_count(void)'
- This function returns the actual number of parameters passed to
- the current function. Inside the code of an extension this can be
- used to determine the maximum index which is safe to use with
- `stack_ptr'. If this value is greater than `tree->param_cnt', the
- function was called incorrectly from the `awk' program.
-
- *Caution:* This function is new as of `gawk' 3.1.4.
-
-`n->param_cnt'
- Inside an extension function, this is the maximum number of
- expected parameters, as set by the `make_builtin' function.
-
-`n->stptr'
-`n->stlen'
- The data and length of a `NODE''s string value, respectively. The
- string is _not_ guaranteed to be zero-terminated. If you need to
- pass the string value to a C library function, save the value in
- `n->stptr[n->stlen]', assign `'\0'' to it, call the routine, and
- then restore the value.
-
-`n->type'
- The type of the `NODE'. This is a C `enum'. Values should be
- either `Node_var' or `Node_var_array' for function parameters.
-
-`n->vname'
- The "variable name" of a node. This is not of much use inside
- externally written extensions.
-
-`void assoc_clear(NODE *n)'
- Clears the associative array pointed to by `n'. Make sure that
- `n->type == Node_var_array' first.
-
-`NODE **assoc_lookup(NODE *symbol, NODE *subs, int reference)'
- Finds, and installs if necessary, array elements. `symbol' is the
- array, `subs' is the subscript. This is usually a value created
- with `tmp_string' (see below). `reference' should be `TRUE' if it
- is an error to use the value before it is created. Typically,
- `FALSE' is the correct value to use from extension functions.
-
-`NODE *make_string(char *s, size_t len)'
- Take a C string and turn it into a pointer to a `NODE' that can be
- stored appropriately. This is permanent storage; understanding of
- `gawk' memory management is helpful.
-
-`NODE *make_number(AWKNUM val)'
- Take an `AWKNUM' and turn it into a pointer to a `NODE' that can
- be stored appropriately. This is permanent storage; understanding
- of `gawk' memory management is helpful.
-
-`NODE *tmp_string(char *s, size_t len);'
- Take a C string and turn it into a pointer to a `NODE' that can be
- stored appropriately. This is temporary storage; understanding of
- `gawk' memory management is helpful.
-
-`NODE *tmp_number(AWKNUM val)'
- Take an `AWKNUM' and turn it into a pointer to a `NODE' that can
- be stored appropriately. This is temporary storage; understanding
- of `gawk' memory management is helpful.
-
-`NODE *dupnode(NODE *n)'
- Duplicate a node. In most cases, this increments an internal
- reference count instead of actually duplicating the entire `NODE';
- understanding of `gawk' memory management is helpful.
-
-`void free_temp(NODE *n)'
- This macro releases the memory associated with a `NODE' allocated
- with `tmp_string' or `tmp_number'. Understanding of `gawk' memory
- management is helpful.
-
-`void make_builtin(char *name, NODE *(*func)(NODE *), int count)'
- Register a C function pointed to by `func' as new built-in
- function `name'. `name' is a regular C string. `count' is the
- maximum number of arguments that the function takes. The function
- should be written in the following manner:
-
- /* do_xxx --- do xxx function for gawk */
-
- NODE *
- do_xxx(NODE *tree)
- {
- ...
- }
-
-`NODE *get_argument(NODE *tree, int i)'
- This function is called from within a C extension function to get
- the `i'-th argument from the function call. The first argument is
- argument zero.
-
-`NODE *get_actual_argument(NODE *tree, unsigned int i,'
-` int optional, int wantarray);'
- This function retrieves a particular argument `i'. `wantarray' is
- `TRUE' if the argument should be an array, `FALSE' otherwise. If
- `optional' is `TRUE', the argument need not have been supplied.
- If it wasn't, the return value is `NULL'. It is a fatal error if
- `optional' is `TRUE' but the argument was not provided.
-
- *Caution:* This function is new as of `gawk' 3.1.4.
-
-`get_scalar_argument(t, i, opt)'
- This is a convenience macro that calls `get_actual_argument'.
-
- *Caution:* This macro is new as of `gawk' 3.1.4.
-
-`get_array_argument(t, i, opt)'
- This is a convenience macro that calls `get_actual_argument'.
-
- *Caution:* This macro is new as of `gawk' 3.1.4.
-
-`void set_value(NODE *tree)'
- This function is called from within a C extension function to set
- the return value from the extension function. This value is what
- the `awk' program sees as the return value from the new `awk'
- function.
-
-`void update_ERRNO(void)'
- This function is called from within a C extension function to set
- the value of `gawk''s `ERRNO' variable, based on the current value
- of the C `errno' variable. It is provided as a convenience.
-
- An argument that is supposed to be an array needs to be handled with
-some extra code, in case the array being passed in is actually from a
-function parameter.
-
- In versions of `gawk' up to and including 3.1.2, the following
-boilerplate code shows how to do this:
-
- NODE *the_arg;
-
- the_arg = get_argument(tree, 2); /* assume need 3rd arg, 0-based */
-
- /* if a parameter, get it off the stack */
- if (the_arg->type == Node_param_list)
- the_arg = stack_ptr[the_arg->param_cnt];
-
- /* parameter referenced an array, get it */
- if (the_arg->type == Node_array_ref)
- the_arg = the_arg->orig_array;
-
- /* check type */
- if (the_arg->type != Node_var && the_arg->type != Node_var_array)
- fatal("newfunc: third argument is not an array");
-
- /* force it to be an array, if necessary, clear it */
- the_arg->type = Node_var_array;
- assoc_clear(the_arg);
-
- For versions 3.1.3 and later, the internals changed. In particular,
-the interface was actually _simplified_ drastically. The following
-boilerplate code now suffices:
-
- NODE *the_arg;
-
- the_arg = get_argument(tree, 2); /* assume need 3rd arg, 0-based */
-
- /* force it to be an array: */
- the_arg = get_array(the_arg);
-
- /* if necessary, clear it: */
- assoc_clear(the_arg);
-
- As of version 3.1.4, the internals improved again, and became even
-simpler:
-
- NODE *the_arg;
-
- the_arg = get_array_argument(tree, 2, FALSE); /* assume need 3rd arg,
0-based */
-
- Again, you should spend time studying the `gawk' internals; don't
-just blindly copy this code.
-
-C.3.2 Directory and File Operation Built-ins
---------------------------------------------
-
-Two useful functions that are not in `awk' are `chdir' (so that an
-`awk' program can change its directory) and `stat' (so that an `awk'
-program can gather information about a file). This minor node
-implements these functions for `gawk' in an external extension library.
-
-C.3.2.1 Using `chdir' and `stat'
-................................
-
-This minor node shows how to use the new functions at the `awk' level
-once they've been integrated into the running `gawk' interpreter.
-Using `chdir' is very straightforward. It takes one argument, the new
-directory to change to:
-
- ...
- newdir = "/home/arnold/funstuff"
- ret = chdir(newdir)
- if (ret < 0) {
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
- exit 1
- }
- ...
-
- The return value is negative if the `chdir' failed, and `ERRNO'
-(*note Built-in Variables::) is set to a string indicating the error.
-
- Using `stat' is a bit more complicated. The C `stat' function fills
-in a structure that has a fair amount of information. The right way to
-model this in `awk' is to fill in an associative array with the
-appropriate information:
-
- file = "/home/arnold/.profile"
- fdata[1] = "x" # force `fdata' to be an array
- ret = stat(file, fdata)
- if (ret < 0) {
- printf("could not stat %s: %s\n",
- file, ERRNO) > "/dev/stderr"
- exit 1
- }
- printf("size of %s is %d bytes\n", file, fdata["size"])
-
- The `stat' function always clears the data array, even if the `stat'
-fails. It fills in the following elements:
-
-`"name"'
- The name of the file that was `stat''ed.
-
-`"dev"'
-`"ino"'
- The file's device and inode numbers, respectively.
-
-`"mode"'
- The file's mode, as a numeric value. This includes both the file's
- type and its permissions.
-
-`"nlink"'
- The number of hard links (directory entries) the file has.
-
-`"uid"'
-`"gid"'
- The numeric user and group ID numbers of the file's owner.
-
-`"size"'
- The size in bytes of the file.
-
-`"blocks"'
- The number of disk blocks the file actually occupies. This may not
- be a function of the file's size if the file has holes.
-
-`"atime"'
-`"mtime"'
-`"ctime"'
- The file's last access, modification, and inode update times,
- respectively. These are numeric timestamps, suitable for
- formatting with `strftime' (*note Built-in::).
-
-`"pmode"'
- The file's "printable mode." This is a string representation of
- the file's type and permissions, such as what is produced by `ls
- -l'--for example, `"drwxr-xr-x"'.
-
-`"type"'
- A printable string representation of the file's type. The value
- is one of the following:
-
- `"blockdev"'
- `"chardev"'
- The file is a block or character device ("special file").
-
- `"directory"'
- The file is a directory.
-
- `"fifo"'
- The file is a named-pipe (also known as a FIFO).
-
- `"file"'
- The file is just a regular file.
-
- `"socket"'
- The file is an `AF_UNIX' ("Unix domain") socket in the
- filesystem.
-
- `"symlink"'
- The file is a symbolic link.
-
- Several additional elements may be present depending upon the
-operating system and the type of the file. You can test for them in
-your `awk' program by using the `in' operator (*note Reference to
-Elements::):
-
-`"blksize"'
- The preferred block size for I/O to the file. This field is not
- present on all POSIX-like systems in the C `stat' structure.
-
-`"linkval"'
- If the file is a symbolic link, this element is the name of the
- file the link points to (i.e., the value of the link).
-
-`"rdev"'
-`"major"'
-`"minor"'
- If the file is a block or character device file, then these values
- represent the numeric device number and the major and minor
- components of that number, respectively.
-
-C.3.2.2 C Code for `chdir' and `stat'
-.....................................
-
-Here is the C code for these extensions. They were written for
-GNU/Linux. The code needs some more work for complete portability to
-other POSIX-compliant systems:(1)
-
- #include "awk.h"
-
- #include <sys/sysmacros.h>
-
- /* do_chdir --- provide dynamically loaded
- chdir() builtin for gawk */
-
- static NODE *
- do_chdir(tree)
- NODE *tree;
- {
- NODE *newdir;
- int ret = -1;
-
- if (do_lint && get_curfunc_arg_count() != 1)
- lintwarn("chdir: called with incorrect number of arguments");
-
- newdir = get_scalar_argument(tree, 0);
-
- The file includes the `"awk.h"' header file for definitions for the
-`gawk' internals. It includes `<sys/sysmacros.h>' for access to the
-`major' and `minor' macros.
-
- By convention, for an `awk' function `foo', the function that
-implements it is called `do_foo'. The function should take a `NODE *'
-argument, usually called `tree', that represents the argument list to
-the function. The `newdir' variable represents the new directory to
-change to, retrieved with `get_argument'. Note that the first argument
-is numbered zero.
-
- This code actually accomplishes the `chdir'. It first forces the
-argument to be a string and passes the string value to the `chdir'
-system call. If the `chdir' fails, `ERRNO' is updated. The result of
-`force_string' has to be freed with `free_temp':
-
- (void) force_string(newdir);
- ret = chdir(newdir->stptr);
- if (ret < 0)
- update_ERRNO();
- free_temp(newdir);
-
- Finally, the function returns the return value to the `awk' level,
-using `set_value'. Then it must return a value from the call to the new
-built-in (this value ignored by the interpreter):
-
- /* Set the return value */
- set_value(tmp_number((AWKNUM) ret));
-
- /* Just to make the interpreter happy */
- return tmp_number((AWKNUM) 0);
- }
-
- The `stat' built-in is more involved. First comes a function that
-turns a numeric mode into a printable representation (e.g., 644 becomes
-`-rw-r--r--'). This is omitted here for brevity:
-
- /* format_mode --- turn a stat mode field
- into something readable */
-
- static char *
- format_mode(fmode)
- unsigned long fmode;
- {
- ...
- }
-
- Next comes the actual `do_stat' function itself. First come the
-variable declarations and argument checking:
-
- /* do_stat --- provide a stat() function for gawk */
-
- static NODE *
- do_stat(tree)
- NODE *tree;
- {
- NODE *file, *array;
- struct stat sbuf;
- int ret;
- NODE **aptr;
- char *pmode; /* printable mode */
- char *type = "unknown";
-
-
- if (do_lint && get_curfunc_arg_count() > 2)
- lintwarn("stat: called with too many arguments");
-
- Then comes the actual work. First, we get the arguments. Then, we
-always clear the array. To get the file information, we use `lstat',
-in case the file is a symbolic link. If there's an error, we set
-`ERRNO' and return:
-
- /* directory is first arg, array to hold results is second */
- file = get_scalar_argument(tree, 0, FALSE);
- array = get_array_argument(tree, 1, FALSE);
-
- /* empty out the array */
- assoc_clear(array);
-
- /* lstat the file, if error, set ERRNO and return */
- (void) force_string(file);
- ret = lstat(file->stptr, & sbuf);
- if (ret < 0) {
- update_ERRNO();
-
- set_value(tmp_number((AWKNUM) ret));
-
- free_temp(file);
- return tmp_number((AWKNUM) 0);
- }
-
- Now comes the tedious part: filling in the array. Only a few of the
-calls are shown here, since they all follow the same pattern:
-
- /* fill in the array */
- aptr = assoc_lookup(array, tmp_string("name", 4), FALSE);
- *aptr = dupnode(file);
-
- aptr = assoc_lookup(array, tmp_string("mode", 4), FALSE);
- *aptr = make_number((AWKNUM) sbuf.st_mode);
-
- aptr = assoc_lookup(array, tmp_string("pmode", 5), FALSE);
- pmode = format_mode(sbuf.st_mode);
- *aptr = make_string(pmode, strlen(pmode));
-
- When done, we free the temporary value containing the file name, set
-the return value, and return:
-
- free_temp(file);
-
- /* Set the return value */
- set_value(tmp_number((AWKNUM) ret));
-
- /* Just to make the interpreter happy */
- return tmp_number((AWKNUM) 0);
- }
-
- Finally, it's necessary to provide the "glue" that loads the new
-function(s) into `gawk'. By convention, each library has a routine
-named `dlload' that does the job:
-
- /* dlload --- load new builtins in this library */
-
- NODE *
- dlload(tree, dl)
- NODE *tree;
- void *dl;
- {
- make_builtin("chdir", do_chdir, 1);
- make_builtin("stat", do_stat, 2);
- return tmp_number((AWKNUM) 0);
- }
-
- And that's it! As an exercise, consider adding functions to
-implement system calls such as `chown', `chmod', and `umask'.
-
- ---------- Footnotes ----------
-
- (1) This version is edited slightly for presentation. The complete
-version can be found in `extension/filefuncs.c' in the `gawk'
-distribution.
-
-C.3.2.3 Integrating the Extensions
-..................................
-
-Now that the code is written, it must be possible to add it at runtime
-to the running `gawk' interpreter. First, the code must be compiled.
-Assuming that the functions are in a file named `filefuncs.c', and IDIR
-is the location of the `gawk' include files, the following steps create
-a GNU/Linux shared library:
-
- $ gcc -shared -DHAVE_CONFIG_H -c -O -g -IIDIR filefuncs.c
- $ ld -o filefuncs.so -shared filefuncs.o
-
- Once the library exists, it is loaded by calling the `extension'
-built-in function. This function takes two arguments: the name of the
-library to load and the name of a function to call when the library is
-first loaded. This function adds the new functions to `gawk'. It
-returns the value returned by the initialization function within the
-shared library:
-
- # file testff.awk
- BEGIN {
- extension("./filefuncs.so", "dlload")
-
- chdir(".") # no-op
-
- data[1] = 1 # force `data' to be an array
- print "Info for testff.awk"
- ret = stat("testff.awk", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
- }
-
- Here are the results of running the program:
-
- $ gawk -f testff.awk
- -| Info for testff.awk
- -| ret = 0
- -| data["blksize"] = 4096
- -| data["mtime"] = 932361936
- -| data["mode"] = 33188
- -| data["type"] = file
- -| data["dev"] = 2065
- -| data["gid"] = 10
- -| data["ino"] = 878597
- -| data["ctime"] = 971431797
- -| data["blocks"] = 2
- -| data["nlink"] = 1
- -| data["name"] = testff.awk
- -| data["atime"] = 971608519
- -| data["pmode"] = -rw-r--r--
- -| data["size"] = 607
- -| data["uid"] = 2076
- -| testff.awk modified: 07 19 99 08:25:36
-
-C.4 Probable Future Extensions
-==============================
-
- AWK is a language similar to PERL, only considerably more elegant.
- Arnold Robbins
-
- Hey!
- Larry Wall
-
- This minor node briefly lists extensions and possible improvements
-that indicate the directions we are currently considering for `gawk'.
-The file `FUTURES' in the `gawk' distribution lists these extensions as
-well.
-
- Following is a list of probable future changes visible at the `awk'
-language level:
-
-Loadable module interface
- It is not clear that the `awk'-level interface to the modules
- facility is as good as it should be. The interface needs to be
- redesigned, particularly taking namespace issues into account, as
- well as possibly including issues such as library search path order
- and versioning.
-
-`RECLEN' variable for fixed-length records
- Along with `FIELDWIDTHS', this would speed up the processing of
- fixed-length records. `PROCINFO["RS"]' would be `"RS"' or
- `"RECLEN"', depending upon which kind of record processing is in
- effect.
-
-Additional `printf' specifiers
- The 1999 ISO C standard added a number of additional `printf'
- format specifiers. These should be evaluated for possible
- inclusion in `gawk'.
-
-Databases
- It may be possible to map a GDBM/NDBM/SDBM file into an `awk'
- array.
-
-Large character sets
- It would be nice if `gawk' could handle UTF-8 and other character
- sets that are larger than eight bits. (`gawk' currently has
- partial multi-byte support, but it needs an expert to really think
- out the multi-byte issues and consult with the maintainer on the
- appropriate changes.)
-
-More `lint' warnings
- There are more things that could be checked for portability.
-
- Following is a list of probable improvements that will make `gawk''s
-source code easier to work with:
-
-Loadable module mechanics
- The current extension mechanism works (*note Dynamic Extensions::),
- but is rather primitive. It requires a fair amount of manual work
- to create and integrate a loadable module. Nor is the current
- mechanism as portable as might be desired. The GNU `libtool'
- package provides a number of features that would make using
- loadable modules much easier. `gawk' should be changed to use
- `libtool'.
-
-Loadable module internals
- The API to its internals that `gawk' "exports" should be revised.
- Too many things are needlessly exposed. A new API should be
- designed and implemented to make module writing easier.
-
-Better array subscript management
- `gawk''s management of array subscript storage could use revamping,
- so that using the same value to index multiple arrays only stores
- one copy of the index value.
-
-Integrating the DBUG library
- Integrating Fred Fish's DBUG library would be helpful during
- development, but it's a lot of work to do.
-
- Following is a list of probable improvements that will make `gawk'
-perform better:
-
-Compilation of `awk' programs
- `gawk' uses a Bison (YACC-like) parser to convert the script given
- it into a syntax tree; the syntax tree is then executed by a
- simple recursive evaluator. This method incurs a lot of overhead,
- since the recursive evaluator performs many procedure calls to do
- even the simplest things.
-
- It should be possible for `gawk' to convert the script's parse tree
- into a C program which the user would then compile, using the
- normal C compiler and a special `gawk' library to provide all the
- needed functions (regexps, fields, associative arrays, type
- coercion, and so on).
-
- An easier possibility might be for an intermediate phase of `gawk'
- to convert the parse tree into a linear byte code form like the
- one used in GNU Emacs Lisp. The recursive evaluator would then be
- replaced by a straight line byte code interpreter that would be
- intermediate in speed between running a compiled program and doing
- what `gawk' does now.
-
- Finally, the programs in the test suite could use documenting in
-this Info file.
-
- *Note Additions::, if you are interested in tackling any of these
-projects.
-
-Appendix D Basic Programming Concepts
-*************************************
-
-This major node attempts to define some of the basic concepts and terms
-that are used throughout the rest of this Info file. As this Info file
-is specifically about `awk', and not about computer programming in
-general, the coverage here is by necessity fairly cursory and
-simplistic. (If you need more background, there are many other
-introductory texts that you should refer to instead.)
-
-D.1 What a Program Does
-=======================
-
-At the most basic level, the job of a program is to process some input
-data and produce results.
-
- _______
- +------+ / \ +---------+
- | Data | -----> < Program > -----> | Results |
- +------+ \_______/ +---------+
-
- The "program" in the figure can be either a compiled program(1)
-(such as `ls'), or it may be "interpreted". In the latter case, a
-machine-executable program such as `awk' reads your program, and then
-uses the instructions in your program to process the data.
-
- When you write a program, it usually consists of the following, very
-basic set of steps:
-
- ______
- +----------------+ / More \ No +----------+
- | Initialization | -------> < Data > -------> | Clean Up |
- +----------------+ ^ \ ? / +----------+
- | +--+-+
- | | Yes
- | |
- | V
- | +---------+
- +-----+ Process |
- +---------+
-
-Initialization
- These are the things you do before actually starting to process
- data, such as checking arguments, initializing any data you need
- to work with, and so on. This step corresponds to `awk''s `BEGIN'
- rule (*note BEGIN/END::).
-
- If you were baking a cake, this might consist of laying out all the
- mixing bowls and the baking pan, and making sure you have all the
- ingredients that you need.
-
-Processing
- This is where the actual work is done. Your program reads data,
- one logical chunk at a time, and processes it as appropriate.
-
- In most programming languages, you have to manually manage the
- reading of data, checking to see if there is more each time you
- read a chunk. `awk''s pattern-action paradigm (*note Getting
- Started::) handles the mechanics of this for you.
-
- In baking a cake, the processing corresponds to the actual labor:
- breaking eggs, mixing the flour, water, and other ingredients, and
- then putting the cake into the oven.
-
-Clean Up
- Once you've processed all the data, you may have things you need to
- do before exiting. This step corresponds to `awk''s `END' rule
- (*note BEGIN/END::).
-
- After the cake comes out of the oven, you still have to wrap it in
- plastic wrap to keep anyone from tasting it, as well as wash the
- mixing bowls and utensils.
-
- An "algorithm" is a detailed set of instructions necessary to
-accomplish a task, or process data. It is much the same as a recipe
-for baking a cake. Programs implement algorithms. Often, it is up to
-you to design the algorithm and implement it, simultaneously.
-
- The "logical chunks" we talked about previously are called "records",
-similar to the records a company keeps on employees, a school keeps for
-students, or a doctor keeps for patients. Each record has many
-component parts, such as first and last names, date of birth, address,
-and so on. The component parts are referred to as the "fields" of the
-record.
-
- The act of reading data is termed "input", and that of generating
-results, not too surprisingly, is termed "output". They are often
-referred to together as "input/output," and even more often, as "I/O"
-for short. (You will also see "input" and "output" used as verbs.)
-
- `awk' manages the reading of data for you, as well as the breaking
-it up into records and fields. Your program's job is to tell `awk'
-what to with the data. You do this by describing "patterns" in the
-data to look for, and "actions" to execute when those patterns are
-seen. This "data-driven" nature of `awk' programs usually makes them
-both easier to write and easier to read.
-
- ---------- Footnotes ----------
-
- (1) Compiled programs are typically written in lower-level languages
-such as C, C++, Fortran, or Ada, and then translated, or "compiled",
-into a form that the computer can execute directly.
-
-D.2 Data Values in a Computer
-=============================
-
-In a program, you keep track of information and values in things called
-"variables". A variable is just a name for a given value, such as
-`first_name', `last_name', `address', and so on. `awk' has several
-predefined variables, and it has special names to refer to the current
-input record and the fields of the record. You may also group multiple
-associated values under one name, as an array.
-
- Data, particularly in `awk', consists of either numeric values, such
-as 42 or 3.1415927, or string values. String values are essentially
-anything that's not a number, such as a name. Strings are sometimes
-referred to as "character data", since they store the individual
-characters that comprise them. Individual variables, as well as
-numeric and string variables, are referred to as "scalar" values.
-Groups of values, such as arrays, are not scalars.
-
- Within computers, there are two kinds of numeric values: "integers"
-and "floating-point". In school, integer values were referred to as
-"whole" numbers--that is, numbers without any fractional part, such as
-1, 42, or -17. The advantage to integer numbers is that they represent
-values exactly. The disadvantage is that their range is limited. On
-most modern systems, this range is -2,147,483,648 to 2,147,483,647.
-
- Integer values come in two flavors: "signed" and "unsigned". Signed
-values may be negative or positive, with the range of values just
-described. Unsigned values are always positive. On most modern
-systems, the range is from 0 to 4,294,967,295.
-
- Floating-point numbers represent what are called "real" numbers;
-i.e., those that do have a fractional part, such as 3.1415927. The
-advantage to floating-point numbers is that they can represent a much
-larger range of values. The disadvantage is that there are numbers
-that they cannot represent exactly. `awk' uses "double-precision"
-floating-point numbers, which can hold more digits than
-"single-precision" floating-point numbers. Floating-point issues are
-discussed more fully in *Note Floating Point Issues::.
-
- At the very lowest level, computers store values as groups of binary
-digits, or "bits". Modern computers group bits into groups of eight,
-called "bytes". Advanced applications sometimes have to manipulate
-bits directly, and `gawk' provides functions for doing so.
-
- While you are probably used to the idea of a number without a value
-(i.e., zero), it takes a bit more getting used to the idea of
-zero-length character data. Nevertheless, such a thing exists. It is
-called the "null string". The null string is character data that has
-no value. In other words, it is empty. It is written in `awk' programs
-like this: `""'.
-
- Humans are used to working in decimal; i.e., base 10. In base 10,
-numbers go from 0 to 9, and then "roll over" into the next column.
-(Remember grade school? 42 is 4 times 10 plus 2.)
-
- There are other number bases though. Computers commonly use base 2
-or "binary", base 8 or "octal", and base 16 or "hexadecimal". In
-binary, each column represents two times the value in the column to its
-right. Each column may contain either a 0 or a 1. Thus, binary 1010
-represents 1 times 8, plus 0 times 4, plus 1 times 2, plus 0 times 1,
-or decimal 10. Octal and hexadecimal are discussed more in *Note
-Nondecimal-numbers::.
-
- Programs are written in programming languages. Hundreds, if not
-thousands, of programming languages exist. One of the most popular is
-the C programming language. The C language had a very strong influence
-on the design of the `awk' language.
-
- There have been several versions of C. The first is often referred
-to as "K&R" C, after the initials of Brian Kernighan and Dennis Ritchie,
-the authors of the first book on C. (Dennis Ritchie created the
-language, and Brian Kernighan was one of the creators of `awk'.)
-
- In the mid-1980s, an effort began to produce an international
-standard for C. This work culminated in 1989, with the production of
-the ANSI standard for C. This standard became an ISO standard in 1990.
-Where it makes sense, POSIX `awk' is compatible with 1990 ISO C.
-
- In 1999, a revised ISO C standard was approved and released. Future
-versions of `gawk' will be as compatible as possible with this standard.
-
-D.3 Floating-Point Number Caveats
-=================================
-
-As mentioned earlier, floating-point numbers represent what are called
-"real" numbers, i.e., those that have a fractional part. `awk' uses
-double-precision floating-point numbers to represent all numeric
-values. This minor node describes some of the issues involved in using
-floating-point numbers.
-
- There is a very nice paper on floating-point arithmetic by David
-Goldberg, "What Every Computer Scientist Should Know About
-Floating-point Arithmetic," `ACM Computing Surveys' *23*, 1 (1991-03),
-5-48.(1) This is worth reading if you are interested in the details,
-but it does require a background in computer science.
-
- Internally, `awk' keeps both the numeric value (double-precision
-floating-point) and the string value for a variable. Separately, `awk'
-keeps track of what type the variable has (*note Typing and
-Comparison::), which plays a role in how variables are used in
-comparisons.
-
- It is important to note that the string value for a number may not
-reflect the full value (all the digits) that the numeric value actually
-contains. The following program (`values.awk') illustrates this:
-
- {
- $1 = $2 + $3
- # see it for what it is
- printf("$1 = %.12g\n", $1)
- # use CONVFMT
- a = "<" $1 ">"
- print "a =", a
- # use OFMT
- print "$1 =", $1
- }
-
-This program shows the full value of the sum of `$2' and `$3' using
-`printf', and then prints the string values obtained from both
-automatic conversion (via `CONVFMT') and from printing (via `OFMT').
-
- Here is what happens when the program is run:
-
- $ echo 2 3.654321 1.2345678 | awk -f values.awk
- -| $1 = 4.8888888
- -| a = <4.88889>
- -| $1 = 4.88889
-
- This makes it clear that the full numeric value is different from
-what the default string representations show.
-
- `CONVFMT''s default value is `"%.6g"', which yields a value with at
-least six significant digits. For some applications, you might want to
-change it to specify more precision. On most modern machines, most of
-the time, 17 digits is enough to capture a floating-point number's
-value exactly.(2)
-
- Unlike numbers in the abstract sense (such as what you studied in
-high school or college math), numbers stored in computers are limited
-in certain ways. They cannot represent an infinite number of digits,
-nor can they always represent things exactly. In particular,
-floating-point numbers cannot always represent values exactly. Here is
-an example:
-
- $ awk '{ printf("%010d\n", $1 * 100) }'
- 515.79
- -| 0000051579
- 515.80
- -| 0000051579
- 515.81
- -| 0000051580
- 515.82
- -| 0000051582
- Ctrl-d
-
-This shows that some values can be represented exactly, whereas others
-are only approximated. This is not a "bug" in `awk', but simply an
-artifact of how computers represent numbers.
-
- Another peculiarity of floating-point numbers on modern systems is
-that they often have more than one representation for the number zero!
-In particular, it is possible to represent "minus zero" as well as
-regular, or "positive" zero.
-
- This example shows that negative and positive zero are distinct
-values when stored internally, but that they are in fact equal to each
-other, as well as to "regular" zero:
-
- $ gawk 'BEGIN { mz = -0 ; pz = 0
- > printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz
- > printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0
- > }'
- -| -0 = -0, +0 = 0, (-0 == +0) -> 1
- -| mz == 0 -> 1, pz == 0 -> 1
-
- It helps to keep this in mind should you process numeric data that
-contains negative zero values; the fact that the zero is negative is
-noted and can affect comparisons.
-
- ---------- Footnotes ----------
-
- (1) `http://www.validlab.com/goldberg/paper.ps'.
-
- (2) Pathological cases can require up to 752 digits (!), but we
-doubt that you need to worry about this.
-
-Glossary
-********
-
-Action
- A series of `awk' statements attached to a rule. If the rule's
- pattern matches an input record, `awk' executes the rule's action.
- Actions are always enclosed in curly braces. (*Note Action
- Overview::.)
-
-Amazing `awk' Assembler
- Henry Spencer at the University of Toronto wrote a retargetable
- assembler completely as `sed' and `awk' scripts. It is thousands
- of lines long, including machine descriptions for several eight-bit
- microcomputers. It is a good example of a program that would have
- been better written in another language. You can get it from
- `ftp://ftp.freefriends.org/arnold/Awkstuff/aaa.tgz'.
-
-Amazingly Workable Formatter (`awf')
- Henry Spencer at the University of Toronto wrote a formatter that
- accepts a large subset of the `nroff -ms' and `nroff -man'
- formatting commands, using `awk' and `sh'. It is available over
- the Internet from
- `ftp://ftp.freefriends.org/arnold/Awkstuff/awf.tgz'.
-
-Anchor
- The regexp metacharacters `^' and `$', which force the match to
- the beginning or end of the string, respectively.
-
-ANSI
- The American National Standards Institute. This organization
- produces many standards, among them the standards for the C and
- C++ programming languages. These standards often become
- international standards as well. See also "ISO."
-
-Array
- A grouping of multiple values under the same name. Most languages
- just provide sequential arrays. `awk' provides associative arrays.
-
-Assertion
- A statement in a program that a condition is true at this point in
- the program. Useful for reasoning about how a program is supposed
- to behave.
-
-Assignment
- An `awk' expression that changes the value of some `awk' variable
- or data object. An object that you can assign to is called an
- "lvalue". The assigned values are called "rvalues". *Note
- Assignment Ops::.
-
-Associative Array
- Arrays in which the indices may be numbers or strings, not just
- sequential integers in a fixed range.
-
-`awk' Language
- The language in which `awk' programs are written.
-
-`awk' Program
- An `awk' program consists of a series of "patterns" and "actions",
- collectively known as "rules". For each input record given to the
- program, the program's rules are all processed in turn. `awk'
- programs may also contain function definitions.
-
-`awk' Script
- Another name for an `awk' program.
-
-Bash
- The GNU version of the standard shell (the Bourne-Again SHell).
- See also "Bourne Shell."
-
-BBS
- See "Bulletin Board System."
-
-Bit
- Short for "Binary Digit." All values in computer memory
- ultimately reduce to binary digits: values that are either zero or
- one. Groups of bits may be interpreted differently--as integers,
- floating-point numbers, character data, addresses of other memory
- objects, or other data. `awk' lets you work with floating-point
- numbers and strings. `gawk' lets you manipulate bit values with
- the built-in functions described in *Note Bitwise Functions::.
-
- Computers are often defined by how many bits they use to represent
- integer values. Typical systems are 32-bit systems, but 64-bit
- systems are becoming increasingly popular, and 16-bit systems are
- waning in popularity.
-
-Boolean Expression
- Named after the English mathematician Boole. See also "Logical
- Expression."
-
-Bourne Shell
- The standard shell (`/bin/sh') on Unix and Unix-like systems,
- originally written by Steven R. Bourne. Many shells (`bash',
- `ksh', `pdksh', `zsh') are generally upwardly compatible with the
- Bourne shell.
-
-Built-in Function
- The `awk' language provides built-in functions that perform various
- numerical, I/O-related, and string computations. Examples are
- `sqrt' (for the square root of a number) and `substr' (for a
- substring of a string). `gawk' provides functions for timestamp
- management, bit manipulation, and runtime string translation.
- (*Note Built-in::.)
-
-Built-in Variable
- `ARGC', `ARGV', `CONVFMT', `ENVIRON', `FILENAME', `FNR', `FS',
- `NF', `NR', `OFMT', `OFS', `ORS', `RLENGTH', `RSTART', `RS', and
- `SUBSEP' are the variables that have special meaning to `awk'. In
- addition, `ARGIND', `BINMODE', `ERRNO', `FIELDWIDTHS',
- `IGNORECASE', `LINT', `PROCINFO', `RT', and `TEXTDOMAIN' are the
- variables that have special meaning to `gawk'. Changing some of
- them affects `awk''s running environment. (*Note Built-in
- Variables::.)
-
-Braces
- See "Curly Braces."
-
-Bulletin Board System
- A computer system allowing users to log in and read and/or leave
- messages for other users of the system, much like leaving paper
- notes on a bulletin board.
-
-C
- The system programming language that most GNU software is written
- in. The `awk' programming language has C-like syntax, and this
- Info file points out similarities between `awk' and C when
- appropriate.
-
- In general, `gawk' attempts to be as similar to the 1990 version
- of ISO C as makes sense. Future versions of `gawk' may adopt
- features from the newer 1999 standard, as appropriate.
-
-C++
- A popular object-oriented programming language derived from C.
-
-Character Set
- The set of numeric codes used by a computer system to represent the
- characters (letters, numbers, punctuation, etc.) of a particular
- country or place. The most common character set in use today is
- ASCII (American Standard Code for Information Interchange). Many
- European countries use an extension of ASCII known as ISO-8859-1
- (ISO Latin-1).
-
-CHEM
- A preprocessor for `pic' that reads descriptions of molecules and
- produces `pic' input for drawing them. It was written in `awk' by
- Brian Kernighan and Jon Bentley, and is available from
- `http://cm.bell-labs.com/netlib/typesetting/chem.gz'.
-
-Coprocess
- A subordinate program with which two-way communications is
- possible.
-
-Compiler
- A program that translates human-readable source code into
- machine-executable object code. The object code is then executed
- directly by the computer. See also "Interpreter."
-
-Compound Statement
- A series of `awk' statements, enclosed in curly braces. Compound
- statements may be nested. (*Note Statements::.)
-
-Concatenation
- Concatenating two strings means sticking them together, one after
- another, producing a new string. For example, the string `foo'
- concatenated with the string `bar' gives the string `foobar'.
- (*Note Concatenation::.)
-
-Conditional Expression
- An expression using the `?:' ternary operator, such as `EXPR1 ?
- EXPR2 : EXPR3'. The expression EXPR1 is evaluated; if the result
- is true, the value of the whole expression is the value of EXPR2;
- otherwise the value is EXPR3. In either case, only one of EXPR2
- and EXPR3 is evaluated. (*Note Conditional Exp::.)
-
-Comparison Expression
- A relation that is either true or false, such as `(a < b)'.
- Comparison expressions are used in `if', `while', `do', and `for'
- statements, and in patterns to select which input records to
- process. (*Note Typing and Comparison::.)
-
-Curly Braces
- The characters `{' and `}'. Curly braces are used in `awk' for
- delimiting actions, compound statements, and function bodies.
-
-Dark Corner
- An area in the language where specifications often were (or still
- are) not clear, leading to unexpected or undesirable behavior.
- Such areas are marked in this Info file with "(d.c.)" in the text
- and are indexed under the heading "dark corner."
-
-Data Driven
- A description of `awk' programs, where you specify the data you
- are interested in processing, and what to do when that data is
- seen.
-
-Data Objects
- These are numbers and strings of characters. Numbers are
- converted into strings and vice versa, as needed. (*Note
- Conversion::.)
-
-Deadlock
- The situation in which two communicating processes are each waiting
- for the other to perform an action.
-
-Double-Precision
- An internal representation of numbers that can have fractional
- parts. Double-precision numbers keep track of more digits than do
- single-precision numbers, but operations on them are sometimes
- more expensive. This is the way `awk' stores numeric values. It
- is the C type `double'.
-
-Dynamic Regular Expression
- A dynamic regular expression is a regular expression written as an
- ordinary expression. It could be a string constant, such as
- `"foo"', but it may also be an expression whose value can vary.
- (*Note Computed Regexps::.)
-
-Environment
- A collection of strings, of the form NAME`='VAL, that each program
- has available to it. Users generally place values into the
- environment in order to provide information to various programs.
- Typical examples are the environment variables `HOME' and `PATH'.
-
-Empty String
- See "Null String."
-
-Epoch
- The date used as the "beginning of time" for timestamps. Time
- values in Unix systems are represented as seconds since the epoch,
- with library functions available for converting these values into
- standard date and time formats.
-
- The epoch on Unix and POSIX systems is 1970-01-01 00:00:00 UTC.
- See also "GMT" and "UTC."
-
-Escape Sequences
- A special sequence of characters used for describing nonprinting
- characters, such as `\n' for newline or `\033' for the ASCII ESC
- (Escape) character. (*Note Escape Sequences::.)
-
-FDL
- See "Free Documentation License."
-
-Field
- When `awk' reads an input record, it splits the record into pieces
- separated by whitespace (or by a separator regexp that you can
- change by setting the built-in variable `FS'). Such pieces are
- called fields. If the pieces are of fixed length, you can use the
- built-in variable `FIELDWIDTHS' to describe their lengths. (*Note
- Field Separators::, and *Note Constant Size::.)
-
-Flag
- A variable whose truth value indicates the existence or
- nonexistence of some condition.
-
-Floating-Point Number
- Often referred to in mathematical terms as a "rational" or real
- number, this is just a number that can have a fractional part.
- See also "Double-Precision" and "Single-Precision."
-
-Format
- Format strings are used to control the appearance of output in the
- `strftime' and `sprintf' functions, and are used in the `printf'
- statement as well. Also, data conversions from numbers to strings
- are controlled by the format string contained in the built-in
- variable `CONVFMT'. (*Note Control Letters::.)
-
-Free Documentation License
- This document describes the terms under which this Info file is
- published and may be copied. (*Note GNU Free Documentation
- License::.)
-
-Function
- A specialized group of statements used to encapsulate general or
- program-specific tasks. `awk' has a number of built-in functions,
- and also allows you to define your own. (*Note Functions::.)
-
-FSF
- See "Free Software Foundation."
-
-Free Software Foundation
- A nonprofit organization dedicated to the production and
- distribution of freely distributable software. It was founded by
- Richard M. Stallman, the author of the original Emacs editor. GNU
- Emacs is the most widely used version of Emacs today.
-
-`gawk'
- The GNU implementation of `awk'.
-
-General Public License
- This document describes the terms under which `gawk' and its source
- code may be distributed. (*Note Copying::.)
-
-GMT
- "Greenwich Mean Time." This is the old term for UTC. It is the
- time of day used as the epoch for Unix and POSIX systems. See
- also "Epoch" and "UTC."
-
-GNU
- "GNU's not Unix". An on-going project of the Free Software
- Foundation to create a complete, freely distributable,
- POSIX-compliant computing environment.
-
-GNU/Linux
- A variant of the GNU system using the Linux kernel, instead of the
- Free Software Foundation's Hurd kernel. Linux is a stable,
- efficient, full-featured clone of Unix that has been ported to a
- variety of architectures. It is most popular on PC-class systems,
- but runs well on a variety of other systems too. The Linux kernel
- source code is available under the terms of the GNU General Public
- License, which is perhaps its most important aspect.
-
-GPL
- See "General Public License."
-
-Hexadecimal
- Base 16 notation, where the digits are `0'-`9' and `A'-`F', with
- `A' representing 10, `B' representing 11, and so on, up to `F' for
- 15. Hexadecimal numbers are written in C using a leading `0x', to
- indicate their base. Thus, `0x12' is 18 (1 times 16 plus 2).
-
-I/O
- Abbreviation for "Input/Output," the act of moving data into and/or
- out of a running program.
-
-Input Record
- A single chunk of data that is read in by `awk'. Usually, an
- `awk' input record consists of one line of text. (*Note
- Records::.)
-
-Integer
- A whole number, i.e., a number that does not have a fractional
- part.
-
-Internationalization
- The process of writing or modifying a program so that it can use
- multiple languages without requiring further source code changes.
-
-Interpreter
- A program that reads human-readable source code directly, and uses
- the instructions in it to process data and produce results. `awk'
- is typically (but not always) implemented as an interpreter. See
- also "Compiler."
-
-Interval Expression
- A component of a regular expression that lets you specify repeated
- matches of some part of the regexp. Interval expressions were not
- traditionally available in `awk' programs.
-
-ISO
- The International Standards Organization. This organization
- produces international standards for many things, including
- programming languages, such as C and C++. In the computer arena,
- important standards like those for C, C++, and POSIX become both
- American national and ISO international standards simultaneously.
- This Info file refers to Standard C as "ISO C" throughout.
-
-Keyword
- In the `awk' language, a keyword is a word that has special
- meaning. Keywords are reserved and may not be used as variable
- names.
-
- `gawk''s keywords are: `BEGIN', `END', `if', `else', `while',
- `do...while', `for', `for...in', `break', `continue', `delete',
- `next', `nextfile', `function', `func', and `exit'.
-
-Lesser General Public License
- This document describes the terms under which binary library
- archives or shared objects, and their source code may be
- distributed.
-
-Linux
- See "GNU/Linux."
-
-LGPL
- See "Lesser General Public License."
-
-Localization
- The process of providing the data necessary for an
- internationalized program to work in a particular language.
-
-Logical Expression
- An expression using the operators for logic, AND, OR, and NOT,
- written `&&', `||', and `!' in `awk'. Often called Boolean
- expressions, after the mathematician who pioneered this kind of
- mathematical logic.
-
-Lvalue
- An expression that can appear on the left side of an assignment
- operator. In most languages, lvalues can be variables or array
- elements. In `awk', a field designator can also be used as an
- lvalue.
-
-Matching
- The act of testing a string against a regular expression. If the
- regexp describes the contents of the string, it is said to "match"
- it.
-
-Metacharacters
- Characters used within a regexp that do not stand for themselves.
- Instead, they denote regular expression operations, such as
- repetition, grouping, or alternation.
-
-Null String
- A string with no characters in it. It is represented explicitly in
- `awk' programs by placing two double quote characters next to each
- other (`""'). It can appear in input data by having two successive
- occurrences of the field separator appear next to each other.
-
-Number
- A numeric-valued data object. Modern `awk' implementations use
- double-precision floating-point to represent numbers. Very old
- `awk' implementations use single-precision floating-point.
-
-Octal
- Base-eight notation, where the digits are `0'-`7'. Octal numbers
- are written in C using a leading `0', to indicate their base.
- Thus, `013' is 11 (one times 8 plus 3).
-
-P1003.2
- See "POSIX."
-
-Pattern
- Patterns tell `awk' which input records are interesting to which
- rules.
-
- A pattern is an arbitrary conditional expression against which
- input is tested. If the condition is satisfied, the pattern is
- said to "match" the input record. A typical pattern might compare
- the input record against a regular expression. (*Note Pattern
- Overview::.)
-
-POSIX
- The name for a series of standards that specify a Portable
- Operating System interface. The "IX" denotes the Unix heritage of
- these standards. The main standard of interest for `awk' users is
- `IEEE Standard for Information Technology, Standard 1003.2-1992,
- Portable Operating System Interface (POSIX) Part 2: Shell and
- Utilities'. Informally, this standard is often referred to as
- simply "P1003.2."
-
-Precedence
- The order in which operations are performed when operators are used
- without explicit parentheses.
-
-Private
- Variables and/or functions that are meant for use exclusively by
- library functions and not for the main `awk' program. Special care
- must be taken when naming such variables and functions. (*Note
- Library Names::.)
-
-Range (of input lines)
- A sequence of consecutive lines from the input file(s). A pattern
- can specify ranges of input lines for `awk' to process or it can
- specify single lines. (*Note Pattern Overview::.)
-
-Recursion
- When a function calls itself, either directly or indirectly. If
- this isn't clear, refer to the entry for "recursion."
-
-Redirection
- Redirection means performing input from something other than the
- standard input stream, or performing output to something other
- than the standard output stream.
-
- You can redirect the output of the `print' and `printf' statements
- to a file or a system command, using the `>', `>>', `|', and `|&'
- operators. You can redirect input to the `getline' statement using
- the `<', `|', and `|&' operators. (*Note Redirection::, and *Note
- Getline::.)
-
-Regexp
- Short for "regular expression". A regexp is a pattern that
- denotes a set of strings, possibly an infinite set. For example,
- the regexp `R.*xp' matches any string starting with the letter `R'
- and ending with the letters `xp'. In `awk', regexps are used in
- patterns and in conditional expressions. Regexps may contain
- escape sequences. (*Note Regexp::.)
-
-Regular Expression
- See "regexp."
-
-Regular Expression Constant
- A regular expression constant is a regular expression written
- within slashes, such as `/foo/'. This regular expression is chosen
- when you write the `awk' program and cannot be changed during its
- execution. (*Note Regexp Usage::.)
-
-Rule
- A segment of an `awk' program that specifies how to process single
- input records. A rule consists of a "pattern" and an "action".
- `awk' reads an input record; then, for each rule, if the input
- record satisfies the rule's pattern, `awk' executes the rule's
- action. Otherwise, the rule does nothing for that input record.
-
-Rvalue
- A value that can appear on the right side of an assignment
- operator. In `awk', essentially every expression has a value.
- These values are rvalues.
-
-Scalar
- A single value, be it a number or a string. Regular variables are
- scalars; arrays and functions are not.
-
-Search Path
- In `gawk', a list of directories to search for `awk' program
- source files. In the shell, a list of directories to search for
- executable programs.
-
-Seed
- The initial value, or starting point, for a sequence of random
- numbers.
-
-`sed'
- See "Stream Editor."
-
-Shell
- The command interpreter for Unix and POSIX-compliant systems. The
- shell works both interactively, and as a programming language for
- batch files, or shell scripts.
-
-Short-Circuit
- The nature of the `awk' logical operators `&&' and `||'. If the
- value of the entire expression is determinable from evaluating just
- the lefthand side of these operators, the righthand side is not
- evaluated. (*Note Boolean Ops::.)
-
-Side Effect
- A side effect occurs when an expression has an effect aside from
- merely producing a value. Assignment expressions, increment and
- decrement expressions, and function calls have side effects.
- (*Note Assignment Ops::.)
-
-Single-Precision
- An internal representation of numbers that can have fractional
- parts. Single-precision numbers keep track of fewer digits than
- do double-precision numbers, but operations on them are sometimes
- less expensive in terms of CPU time. This is the type used by
- some very old versions of `awk' to store numeric values. It is
- the C type `float'.
-
-Space
- The character generated by hitting the space bar on the keyboard.
-
-Special File
- A file name interpreted internally by `gawk', instead of being
- handed directly to the underlying operating system--for example,
- `/dev/stderr'. (*Note Special Files::.)
-
-Stream Editor
- A program that reads records from an input stream and processes
- them one or more at a time. This is in contrast with batch
- programs, which may expect to read their input files in entirety
- before starting to do anything, as well as with interactive
- programs which require input from the user.
-
-String
- A datum consisting of a sequence of characters, such as `I am a
- string'. Constant strings are written with double quotes in the
- `awk' language and may contain escape sequences. (*Note Escape
- Sequences::.)
-
-Tab
- The character generated by hitting the `TAB' key on the keyboard.
- It usually expands to up to eight spaces upon output.
-
-Text Domain
- A unique name that identifies an application. Used for grouping
- messages that are translated at runtime into the local language.
-
-Timestamp
- A value in the "seconds since the epoch" format used by Unix and
- POSIX systems. Used for the `gawk' functions `mktime',
- `strftime', and `systime'. See also "Epoch" and "UTC."
-
-Unix
- A computer operating system originally developed in the early
- 1970's at AT&T Bell Laboratories. It initially became popular in
- universities around the world and later moved into commercial
- environments as a software development system and network server
- system. There are many commercial versions of Unix, as well as
- several work-alike systems whose source code is freely available
- (such as GNU/Linux, NetBSD, FreeBSD, and OpenBSD).
-
-UTC
- The accepted abbreviation for "Universal Coordinated Time." This
- is standard time in Greenwich, England, which is used as a
- reference time for day and date calculations. See also "Epoch"
- and "GMT."
-
-Whitespace
- A sequence of space, TAB, or newline characters occurring inside
- an input record or a string.
-
-GNU General Public License
-**************************
-
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-Preamble
-========
-
-The licenses for most software are designed to take away your freedom
-to share and change it. By contrast, the GNU General Public License is
-intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it in
-new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software,
-and (2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- 0. This License applies to any program or other work which contains a
- notice placed by the copyright holder saying it may be distributed
- under the terms of this General Public License. The "Program",
- below, refers to any such program or work, and a "work based on
- the Program" means either the Program or any derivative work under
- copyright law: that is to say, a work containing the Program or a
- portion of it, either verbatim or with modifications and/or
- translated into another language. (Hereinafter, translation is
- included without limitation in the term "modification".) Each
- licensee is addressed as "you".
-
- Activities other than copying, distribution and modification are
- not covered by this License; they are outside its scope. The act
- of running the Program is not restricted, and the output from the
- Program is covered only if its contents constitute a work based on
- the Program (independent of having been made by running the
- Program). Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
- source code as you receive it, in any medium, provided that you
- conspicuously and appropriately publish on each copy an appropriate
- copyright notice and disclaimer of warranty; keep intact all the
- notices that refer to this License and to the absence of any
- warranty; and give any other recipients of the Program a copy of
- this License along with the Program.
-
- You may charge a fee for the physical act of transferring a copy,
- and you may at your option offer warranty protection in exchange
- for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
- of it, thus forming a work based on the Program, and copy and
- distribute such modifications or work under the terms of Section 1
- above, provided that you also meet all of these conditions:
-
- a. You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b. You must cause any work that you distribute or publish, that
- in whole or in part contains or is derived from the Program
- or any part thereof, to be licensed as a whole at no charge
- to all third parties under the terms of this License.
-
- c. If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display
- an announcement including an appropriate copyright notice and
- a notice that there is no warranty (or else, saying that you
- provide a warranty) and that users may redistribute the
- program under these conditions, and telling the user how to
- view a copy of this License. (Exception: if the Program
- itself is interactive but does not normally print such an
- announcement, your work based on the Program is not required
- to print an announcement.)
-
- These requirements apply to the modified work as a whole. If
- identifiable sections of that work are not derived from the
- Program, and can be reasonably considered independent and separate
- works in themselves, then this License, and its terms, do not
- apply to those sections when you distribute them as separate
- works. But when you distribute the same sections as part of a
- whole which is a work based on the Program, the distribution of
- the whole must be on the terms of this License, whose permissions
- for other licensees extend to the entire whole, and thus to each
- and every part regardless of who wrote it.
-
- Thus, it is not the intent of this section to claim rights or
- contest your rights to work written entirely by you; rather, the
- intent is to exercise the right to control the distribution of
- derivative or collective works based on the Program.
-
- In addition, mere aggregation of another work not based on the
- Program with the Program (or with a work based on the Program) on
- a volume of a storage or distribution medium does not bring the
- other work under the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
- under Section 2) in object code or executable form under the terms
- of Sections 1 and 2 above provided that you also do one of the
- following:
-
- a. Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of
- Sections 1 and 2 above on a medium customarily used for
- software interchange; or,
-
- b. Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a
- medium customarily used for software interchange; or,
-
- c. Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with
- such an offer, in accord with Subsection b above.)
-
- The source code for a work means the preferred form of the work for
- making modifications to it. For an executable work, complete
- source code means all the source code for all modules it contains,
- plus any associated interface definition files, plus the scripts
- used to control compilation and installation of the executable.
- However, as a special exception, the source code distributed need
- not include anything that is normally distributed (in either
- source or binary form) with the major components (compiler,
- kernel, and so on) of the operating system on which the executable
- runs, unless that component itself accompanies the executable.
-
- If distribution of executable or object code is made by offering
- access to copy from a designated place, then offering equivalent
- access to copy the source code from the same place counts as
- distribution of the source code, even though third parties are not
- compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
- except as expressly provided under this License. Any attempt
- otherwise to copy, modify, sublicense or distribute the Program is
- void, and will automatically terminate your rights under this
- License. However, parties who have received copies, or rights,
- from you under this License will not have their licenses
- terminated so long as such parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
- signed it. However, nothing else grants you permission to modify
- or distribute the Program or its derivative works. These actions
- are prohibited by law if you do not accept this License.
- Therefore, by modifying or distributing the Program (or any work
- based on the Program), you indicate your acceptance of this
- License to do so, and all its terms and conditions for copying,
- distributing or modifying the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
- Program), the recipient automatically receives a license from the
- original licensor to copy, distribute or modify the Program
- subject to these terms and conditions. You may not impose any
- further restrictions on the recipients' exercise of the rights
- granted herein. You are not responsible for enforcing compliance
- by third parties to this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
- infringement or for any other reason (not limited to patent
- issues), conditions are imposed on you (whether by court order,
- agreement or otherwise) that contradict the conditions of this
- License, they do not excuse you from the conditions of this
- License. If you cannot distribute so as to satisfy simultaneously
- your obligations under this License and any other pertinent
- obligations, then as a consequence you may not distribute the
- Program at all. For example, if a patent license would not permit
- royalty-free redistribution of the Program by all those who
- receive copies directly or indirectly through you, then the only
- way you could satisfy both it and this License would be to refrain
- entirely from distribution of the Program.
-
- If any portion of this section is held invalid or unenforceable
- under any particular circumstance, the balance of the section is
- intended to apply and the section as a whole is intended to apply
- in other circumstances.
-
- It is not the purpose of this section to induce you to infringe any
- patents or other property right claims or to contest validity of
- any such claims; this section has the sole purpose of protecting
- the integrity of the free software distribution system, which is
- implemented by public license practices. Many people have made
- generous contributions to the wide range of software distributed
- through that system in reliance on consistent application of that
- system; it is up to the author/donor to decide if he or she is
- willing to distribute software through any other system and a
- licensee cannot impose that choice.
-
- This section is intended to make thoroughly clear what is believed
- to be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
- certain countries either by patents or by copyrighted interfaces,
- the original copyright holder who places the Program under this
- License may add an explicit geographical distribution limitation
- excluding those countries, so that distribution is permitted only
- in or among countries not thus excluded. In such case, this
- License incorporates the limitation as if written in the body of
- this License.
-
- 9. The Free Software Foundation may publish revised and/or new
- versions of the General Public License from time to time. Such
- new versions will be similar in spirit to the present version, but
- may differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
- Program specifies a version number of this License which applies
- to it and "any later version", you have the option of following
- the terms and conditions either of that version or of any later
- version published by the Free Software Foundation. If the Program
- does not specify a version number of this License, you may choose
- any version ever published by the Free Software Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
- programs whose distribution conditions are different, write to the
- author to ask for permission. For software which is copyrighted
- by the Free Software Foundation, write to the Free Software
- Foundation; we sometimes make exceptions for this. Our decision
- will be guided by the two goals of preserving the free status of
- all derivatives of our free software and of promoting the sharing
- and reuse of software generally.
-
- NO WARRANTY
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
- WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
- LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
- WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
- NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE
- QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
- SERVICING, REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
- WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
- MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
- LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
- INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
- INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
- OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
- OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
- ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-How to Apply These Terms to Your New Programs
-=============================================
-
-If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- ONE LINE TO GIVE THE PROGRAM'S NAME AND AN IDEA OF WHAT IT DOES.
- Copyright (C) YEAR NAME OF AUTHOR
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
-
- Also add information on how to contact you by electronic and paper
-mail.
-
- If the program is interactive, make it output a short notice like
-this when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) YEAR NAME OF AUTHOR
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
- type `show w'. This is free software, and you are welcome
- to redistribute it under certain conditions; type `show c'
- for details.
-
- The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
-
- You should also get your employer (if you work as a programmer) or
-your school, if any, to sign a "copyright disclaimer" for the program,
-if necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright
- interest in the program `Gnomovision'
- (which makes passes at compilers) written
- by James Hacker.
-
- SIGNATURE OF TY COON, 1 April 1989
- Ty Coon, President of Vice
-
- This General Public License does not permit incorporating your
-program into proprietary programs. If your program is a subroutine
-library, you may consider it more useful to permit linking proprietary
-applications with the library. If this is what you want to do, use the
-GNU Lesser General Public License instead of this License.
-
-GNU Free Documentation License
-******************************
-
- Version 1.2, November 2002
-
- Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- 0. PREAMBLE
-
- The purpose of this License is to make a manual, textbook, or other
- functional and useful document "free" in the sense of freedom: to
- assure everyone the effective freedom to copy and redistribute it,
- with or without modifying it, either commercially or
- noncommercially. Secondarily, this License preserves for the
- author and publisher a way to get credit for their work, while not
- being considered responsible for modifications made by others.
-
- This License is a kind of "copyleft", which means that derivative
- works of the document must themselves be free in the same sense.
- It complements the GNU General Public License, which is a copyleft
- license designed for free software.
-
- We have designed this License in order to use it for manuals for
- free software, because free software needs free documentation: a
- free program should come with manuals providing the same freedoms
- that the software does. But this License is not limited to
- software manuals; it can be used for any textual work, regardless
- of subject matter or whether it is published as a printed book.
- We recommend this License principally for works whose purpose is
- instruction or reference.
-
- 1. APPLICABILITY AND DEFINITIONS
-
- This License applies to any manual or other work, in any medium,
- that contains a notice placed by the copyright holder saying it
- can be distributed under the terms of this License. Such a notice
- grants a world-wide, royalty-free license, unlimited in duration,
- to use that work under the conditions stated herein. The
- "Document", below, refers to any such manual or work. Any member
- of the public is a licensee, and is addressed as "you". You
- accept the license if you copy, modify or distribute the work in a
- way requiring permission under copyright law.
-
- A "Modified Version" of the Document means any work containing the
- Document or a portion of it, either copied verbatim, or with
- modifications and/or translated into another language.
-
- A "Secondary Section" is a named appendix or a front-matter section
- of the Document that deals exclusively with the relationship of the
- publishers or authors of the Document to the Document's overall
- subject (or to related matters) and contains nothing that could
- fall directly within that overall subject. (Thus, if the Document
- is in part a textbook of mathematics, a Secondary Section may not
- explain any mathematics.) The relationship could be a matter of
- historical connection with the subject or with related matters, or
- of legal, commercial, philosophical, ethical or political position
- regarding them.
-
- The "Invariant Sections" are certain Secondary Sections whose
- titles are designated, as being those of Invariant Sections, in
- the notice that says that the Document is released under this
- License. If a section does not fit the above definition of
- Secondary then it is not allowed to be designated as Invariant.
- The Document may contain zero Invariant Sections. If the Document
- does not identify any Invariant Sections then there are none.
-
- The "Cover Texts" are certain short passages of text that are
- listed, as Front-Cover Texts or Back-Cover Texts, in the notice
- that says that the Document is released under this License. A
- Front-Cover Text may be at most 5 words, and a Back-Cover Text may
- be at most 25 words.
-
- A "Transparent" copy of the Document means a machine-readable copy,
- represented in a format whose specification is available to the
- general public, that is suitable for revising the document
- straightforwardly with generic text editors or (for images
- composed of pixels) generic paint programs or (for drawings) some
- widely available drawing editor, and that is suitable for input to
- text formatters or for automatic translation to a variety of
- formats suitable for input to text formatters. A copy made in an
- otherwise Transparent file format whose markup, or absence of
- markup, has been arranged to thwart or discourage subsequent
- modification by readers is not Transparent. An image format is
- not Transparent if used for any substantial amount of text. A
- copy that is not "Transparent" is called "Opaque".
-
- Examples of suitable formats for Transparent copies include plain
- ASCII without markup, Texinfo input format, LaTeX input format,
- SGML or XML using a publicly available DTD, and
- standard-conforming simple HTML, PostScript or PDF designed for
- human modification. Examples of transparent image formats include
- PNG, XCF and JPG. Opaque formats include proprietary formats that
- can be read and edited only by proprietary word processors, SGML or
- XML for which the DTD and/or processing tools are not generally
- available, and the machine-generated HTML, PostScript or PDF
- produced by some word processors for output purposes only.
-
- The "Title Page" means, for a printed book, the title page itself,
- plus such following pages as are needed to hold, legibly, the
- material this License requires to appear in the title page. For
- works in formats which do not have any title page as such, "Title
- Page" means the text near the most prominent appearance of the
- work's title, preceding the beginning of the body of the text.
-
- A section "Entitled XYZ" means a named subunit of the Document
- whose title either is precisely XYZ or contains XYZ in parentheses
- following text that translates XYZ in another language. (Here XYZ
- stands for a specific section name mentioned below, such as
- "Acknowledgements", "Dedications", "Endorsements", or "History".)
- To "Preserve the Title" of such a section when you modify the
- Document means that it remains a section "Entitled XYZ" according
- to this definition.
-
- The Document may include Warranty Disclaimers next to the notice
- which states that this License applies to the Document. These
- Warranty Disclaimers are considered to be included by reference in
- this License, but only as regards disclaiming warranties: any other
- implication that these Warranty Disclaimers may have is void and
- has no effect on the meaning of this License.
-
- 2. VERBATIM COPYING
-
- You may copy and distribute the Document in any medium, either
- commercially or noncommercially, provided that this License, the
- copyright notices, and the license notice saying this License
- applies to the Document are reproduced in all copies, and that you
- add no other conditions whatsoever to those of this License. You
- may not use technical measures to obstruct or control the reading
- or further copying of the copies you make or distribute. However,
- you may accept compensation in exchange for copies. If you
- distribute a large enough number of copies you must also follow
- the conditions in section 3.
-
- You may also lend copies, under the same conditions stated above,
- and you may publicly display copies.
-
- 3. COPYING IN QUANTITY
-
- If you publish printed copies (or copies in media that commonly
- have printed covers) of the Document, numbering more than 100, and
- the Document's license notice requires Cover Texts, you must
- enclose the copies in covers that carry, clearly and legibly, all
- these Cover Texts: Front-Cover Texts on the front cover, and
- Back-Cover Texts on the back cover. Both covers must also clearly
- and legibly identify you as the publisher of these copies. The
- front cover must present the full title with all words of the
- title equally prominent and visible. You may add other material
- on the covers in addition. Copying with changes limited to the
- covers, as long as they preserve the title of the Document and
- satisfy these conditions, can be treated as verbatim copying in
- other respects.
-
- If the required texts for either cover are too voluminous to fit
- legibly, you should put the first ones listed (as many as fit
- reasonably) on the actual cover, and continue the rest onto
- adjacent pages.
-
- If you publish or distribute Opaque copies of the Document
- numbering more than 100, you must either include a
- machine-readable Transparent copy along with each Opaque copy, or
- state in or with each Opaque copy a computer-network location from
- which the general network-using public has access to download
- using public-standard network protocols a complete Transparent
- copy of the Document, free of added material. If you use the
- latter option, you must take reasonably prudent steps, when you
- begin distribution of Opaque copies in quantity, to ensure that
- this Transparent copy will remain thus accessible at the stated
- location until at least one year after the last time you
- distribute an Opaque copy (directly or through your agents or
- retailers) of that edition to the public.
-
- It is requested, but not required, that you contact the authors of
- the Document well before redistributing any large number of
- copies, to give them a chance to provide you with an updated
- version of the Document.
-
- 4. MODIFICATIONS
-
- You may copy and distribute a Modified Version of the Document
- under the conditions of sections 2 and 3 above, provided that you
- release the Modified Version under precisely this License, with
- the Modified Version filling the role of the Document, thus
- licensing distribution and modification of the Modified Version to
- whoever possesses a copy of it. In addition, you must do these
- things in the Modified Version:
-
- A. Use in the Title Page (and on the covers, if any) a title
- distinct from that of the Document, and from those of
- previous versions (which should, if there were any, be listed
- in the History section of the Document). You may use the
- same title as a previous version if the original publisher of
- that version gives permission.
-
- B. List on the Title Page, as authors, one or more persons or
- entities responsible for authorship of the modifications in
- the Modified Version, together with at least five of the
- principal authors of the Document (all of its principal
- authors, if it has fewer than five), unless they release you
- from this requirement.
-
- C. State on the Title page the name of the publisher of the
- Modified Version, as the publisher.
-
- D. Preserve all the copyright notices of the Document.
-
- E. Add an appropriate copyright notice for your modifications
- adjacent to the other copyright notices.
-
- F. Include, immediately after the copyright notices, a license
- notice giving the public permission to use the Modified
- Version under the terms of this License, in the form shown in
- the Addendum below.
-
- G. Preserve in that license notice the full lists of Invariant
- Sections and required Cover Texts given in the Document's
- license notice.
-
- H. Include an unaltered copy of this License.
-
- I. Preserve the section Entitled "History", Preserve its Title,
- and add to it an item stating at least the title, year, new
- authors, and publisher of the Modified Version as given on
- the Title Page. If there is no section Entitled "History" in
- the Document, create one stating the title, year, authors,
- and publisher of the Document as given on its Title Page,
- then add an item describing the Modified Version as stated in
- the previous sentence.
-
- J. Preserve the network location, if any, given in the Document
- for public access to a Transparent copy of the Document, and
- likewise the network locations given in the Document for
- previous versions it was based on. These may be placed in
- the "History" section. You may omit a network location for a
- work that was published at least four years before the
- Document itself, or if the original publisher of the version
- it refers to gives permission.
-
- K. For any section Entitled "Acknowledgements" or "Dedications",
- Preserve the Title of the section, and preserve in the
- section all the substance and tone of each of the contributor
- acknowledgements and/or dedications given therein.
-
- L. Preserve all the Invariant Sections of the Document,
- unaltered in their text and in their titles. Section numbers
- or the equivalent are not considered part of the section
- titles.
-
- M. Delete any section Entitled "Endorsements". Such a section
- may not be included in the Modified Version.
-
- N. Do not retitle any existing section to be Entitled
- "Endorsements" or to conflict in title with any Invariant
- Section.
-
- O. Preserve any Warranty Disclaimers.
-
- If the Modified Version includes new front-matter sections or
- appendices that qualify as Secondary Sections and contain no
- material copied from the Document, you may at your option
- designate some or all of these sections as invariant. To do this,
- add their titles to the list of Invariant Sections in the Modified
- Version's license notice. These titles must be distinct from any
- other section titles.
-
- You may add a section Entitled "Endorsements", provided it contains
- nothing but endorsements of your Modified Version by various
- parties--for example, statements of peer review or that the text
- has been approved by an organization as the authoritative
- definition of a standard.
-
- You may add a passage of up to five words as a Front-Cover Text,
- and a passage of up to 25 words as a Back-Cover Text, to the end
- of the list of Cover Texts in the Modified Version. Only one
- passage of Front-Cover Text and one of Back-Cover Text may be
- added by (or through arrangements made by) any one entity. If the
- Document already includes a cover text for the same cover,
- previously added by you or by arrangement made by the same entity
- you are acting on behalf of, you may not add another; but you may
- replace the old one, on explicit permission from the previous
- publisher that added the old one.
-
- The author(s) and publisher(s) of the Document do not by this
- License give permission to use their names for publicity for or to
- assert or imply endorsement of any Modified Version.
-
- 5. COMBINING DOCUMENTS
-
- You may combine the Document with other documents released under
- this License, under the terms defined in section 4 above for
- modified versions, provided that you include in the combination
- all of the Invariant Sections of all of the original documents,
- unmodified, and list them all as Invariant Sections of your
- combined work in its license notice, and that you preserve all
- their Warranty Disclaimers.
-
- The combined work need only contain one copy of this License, and
- multiple identical Invariant Sections may be replaced with a single
- copy. If there are multiple Invariant Sections with the same name
- but different contents, make the title of each such section unique
- by adding at the end of it, in parentheses, the name of the
- original author or publisher of that section if known, or else a
- unique number. Make the same adjustment to the section titles in
- the list of Invariant Sections in the license notice of the
- combined work.
-
- In the combination, you must combine any sections Entitled
- "History" in the various original documents, forming one section
- Entitled "History"; likewise combine any sections Entitled
- "Acknowledgements", and any sections Entitled "Dedications". You
- must delete all sections Entitled "Endorsements."
-
- 6. COLLECTIONS OF DOCUMENTS
-
- You may make a collection consisting of the Document and other
- documents released under this License, and replace the individual
- copies of this License in the various documents with a single copy
- that is included in the collection, provided that you follow the
- rules of this License for verbatim copying of each of the
- documents in all other respects.
-
- You may extract a single document from such a collection, and
- distribute it individually under this License, provided you insert
- a copy of this License into the extracted document, and follow
- this License in all other respects regarding verbatim copying of
- that document.
-
- 7. AGGREGATION WITH INDEPENDENT WORKS
-
- A compilation of the Document or its derivatives with other
- separate and independent documents or works, in or on a volume of
- a storage or distribution medium, is called an "aggregate" if the
- copyright resulting from the compilation is not used to limit the
- legal rights of the compilation's users beyond what the individual
- works permit. When the Document is included an aggregate, this
- License does not apply to the other works in the aggregate which
- are not themselves derivative works of the Document.
-
- If the Cover Text requirement of section 3 is applicable to these
- copies of the Document, then if the Document is less than one half
- of the entire aggregate, the Document's Cover Texts may be placed
- on covers that bracket the Document within the aggregate, or the
- electronic equivalent of covers if the Document is in electronic
- form. Otherwise they must appear on printed covers that bracket
- the whole aggregate.
-
- 8. TRANSLATION
-
- Translation is considered a kind of modification, so you may
- distribute translations of the Document under the terms of section
- 4. Replacing Invariant Sections with translations requires special
- permission from their copyright holders, but you may include
- translations of some or all Invariant Sections in addition to the
- original versions of these Invariant Sections. You may include a
- translation of this License, and all the license notices in the
- Document, and any Warrany Disclaimers, provided that you also
- include the original English version of this License and the
- original versions of those notices and disclaimers. In case of a
- disagreement between the translation and the original version of
- this License or a notice or disclaimer, the original version will
- prevail.
-
- If a section in the Document is Entitled "Acknowledgements",
- "Dedications", or "History", the requirement (section 4) to
- Preserve its Title (section 1) will typically require changing the
- actual title.
-
- 9. TERMINATION
-
- You may not copy, modify, sublicense, or distribute the Document
- except as expressly provided for under this License. Any other
- attempt to copy, modify, sublicense or distribute the Document is
- void, and will automatically terminate your rights under this
- License. However, parties who have received copies, or rights,
- from you under this License will not have their licenses
- terminated so long as such parties remain in full compliance.
-
- 10. FUTURE REVISIONS OF THIS LICENSE
-
- The Free Software Foundation may publish new, revised versions of
- the GNU Free Documentation License from time to time. Such new
- versions will be similar in spirit to the present version, but may
- differ in detail to address new problems or concerns. See
- `http://www.gnu.org/copyleft/'.
-
- Each version of the License is given a distinguishing version
- number. If the Document specifies that a particular numbered
- version of this License "or any later version" applies to it, you
- have the option of following the terms and conditions either of
- that specified version or of any later version that has been
- published (not as a draft) by the Free Software Foundation. If
- the Document does not specify a version number of this License,
- you may choose any version ever published (not as a draft) by the
- Free Software Foundation.
-
-ADDENDUM: How to use this License for your documents
-====================================================
-
-To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and license
-notices just after the title page:
-
- Copyright (C) YEAR YOUR NAME.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
- A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-
- If you have Invariant Sections, Front-Cover Texts and Back-Cover
-Texts, replace the "with...Texts." line with this:
-
- with the Invariant Sections being LIST THEIR TITLES, with
- the Front-Cover Texts being LIST, and with the Back-Cover Texts
- being LIST.
-
- If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
- If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License, to
-permit their use in free software.
-
-Index
-*****
-
-! (exclamation point), ! operator: See 5.11. (line 5957)
-! (exclamation point), ! operator <1>: See 13.2.2. (line 13599)
-! (exclamation point), ! operator: See 5.14. (line 6124)
-! (exclamation point), != operator <1>: See 5.14. (line 6137)
-! (exclamation point), != operator: See 5.10. (line 5786)
-! (exclamation point), !~ operator <1>: See 6.1.2. (line 6248)
-! (exclamation point), !~ operator <2>: See 5.14. (line 6153)
-! (exclamation point), !~ operator <3>: See 5.10. (line 5786)
-! (exclamation point), !~ operator <4>: See 5.1.3. (line 5021)
-! (exclamation point), !~ operator <5>: See 2.8. (line 2384)
-! (exclamation point), !~ operator <6>: See 2.6. (line 2302)
-! (exclamation point), !~ operator: See 2.1. (line 1749)
-! operator <1>: See 13.2.2. (line 13607)
-! operator: See 6.1.3. (line 6349)
-" (double quote) <1>: See 1.1.6. (line 1173)
-" (double quote): See 1.1.2. (line 971)
-" (double quote), regexp constants: See 2.8. (line 2406)
-# (number sign), #! (executable scripts): See 1.1.4. (line 1035)
-# (number sign), #! (executable scripts), portability issues with:See 1.1.4.
- (line 1035)
-# (number sign), commenting: See 1.1.5. (line 1095)
-$ (dollar sign): See 2.3. (line 1964)
-$ (dollar sign), $ field operator <1>: See 5.14. (line 6115)
-$ (dollar sign), $ field operator: See 3.2. (line 2726)
-$ (dollar sign), incrementing fields and arrays:See 5.8. (line 5633)
-$ field operator: See 3.2. (line 2726)
-% (percent sign), % operator: See 5.14. (line 6127)
-% (percent sign), %= operator <1>: See 5.14. (line 6168)
-% (percent sign), %= operator: See 5.7. (line 5570)
-& (ampersand), && operator <1>: See 5.14. (line 6159)
-& (ampersand), && operator: See 5.11. (line 5947)
-& (ampersand), gsub/gensub/sub functions and: See 8.1.3.1. (line 8838)
-' (single quote) <1>: See 1.1.6. (line 1167)
-' (single quote) <2>: See 1.1.3. (line 1027)
-' (single quote): See 1.1.1. (line 935)
-' (single quote), vs. apostrophe: See 1.1.5. (line 1116)
-' (single quote), with double quotes: See 1.1.6. (line 1189)
-() (parentheses): See 2.3. (line 2007)
-() (parentheses), pgawk program: See 10.5. (line 10972)
-* (asterisk), * operator, as multiplication operator:See 5.14.
- (line 6127)
-* (asterisk), * operator, as regexp operator: See 2.3. (line 2015)
-* (asterisk), * operator, null strings, matching:See 8.1.3.1.
- (line 8992)
-* (asterisk), ** operator <1>: See 11.2. (line 11247)
-* (asterisk), ** operator <2>: See 5.14. (line 6121)
-* (asterisk), ** operator: See 5.5. (line 5362)
-* (asterisk), **= operator <1>: See 11.2. (line 11247)
-* (asterisk), **= operator <2>: See 5.14. (line 6168)
-* (asterisk), **= operator: See 5.7. (line 5570)
-* (asterisk), *= operator <1>: See 5.14. (line 6168)
-* (asterisk), *= operator: See 5.7. (line 5570)
-+ (plus sign): See 2.3. (line 2030)
-+ (plus sign), + operator: See 5.14. (line 6124)
-+ (plus sign), ++ operator <1>: See 5.14. (line 6118)
-+ (plus sign), ++ operator: See 5.8. (line 5643)
-+ (plus sign), += operator <1>: See 5.14. (line 6168)
-+ (plus sign), += operator: See 5.7. (line 5523)
-+ (plus sign), decrement/increment operators: See 5.8. (line 5614)
-, (comma), in range patterns: See 6.1.3. (line 6307)
-- (hyphen), - operator: See 5.14. (line 6124)
-- (hyphen), -- (decrement/increment) operator: See 5.14. (line 6118)
-- (hyphen), -- operator: See 5.8. (line 5651)
-- (hyphen), -= operator <1>: See 5.14. (line 6168)
-- (hyphen), -= operator: See 5.7. (line 5570)
-- (hyphen), filenames beginning with: See 11.2. (line 11148)
-- (hyphen), in character lists: See 2.4. (line 2115)
---assign option: See 11.2. (line 11111)
---compat option: See 11.2. (line 11160)
---copyleft option: See 11.2. (line 11173)
---copyright option: See 11.2. (line 11168)
---disable-lint configuration option: See B.2.2. (line 16270)
---disable-nls configuration option: See B.2.2. (line 16285)
---dump-variables option <1>: See 12.1. (line 11604)
---dump-variables option: See 11.2. (line 11176)
---enable-portals configuration option <1>: See B.2.2. (line 16256)
---enable-portals configuration option: See 10.4. (line 10822)
---enable-switch configuration option: See B.2.2. (line 16260)
---field-separator option: See 11.2. (line 11102)
---file option: See 11.2. (line 11106)
---gen-po option <1>: See 11.2. (line 11192)
---gen-po option: See 9.4.1. (line 10303)
---help option: See 11.2. (line 11201)
---lint option <1>: See 11.2. (line 11206)
---lint option: See 11.1. (line 11080)
---lint-old option: See 11.2. (line 11218)
---non-decimal-data option <1>: See 11.2. (line 11223)
---non-decimal-data option: See 10.1. (line 10585)
---non-decimal-data option, strtonum function and:See 10.1. (line 10615)
---posix option: See 11.2. (line 11231)
---posix option, --traditional option and: See 11.2. (line 11258)
---profile option <1>: See 11.2. (line 11264)
---profile option: See 10.5. (line 10843)
---re-interval option: See 11.2. (line 11276)
---source option: See 11.2. (line 11283)
---traditional option: See 11.2. (line 11160)
---traditional option, --posix option and: See 11.2. (line 11258)
---usage option: See 11.2. (line 11201)
---version option: See 11.2. (line 11291)
---with-included-gettext configuration option <1>:See B.2.2. (line 16264)
---with-included-gettext configuration option: See 9.6. (line 10557)
---with-included-gettext configuration option, configuring gawk with:See B.2.2.
- (line 16264)
--f option: See 11.2. (line 11106)
--F option <1>: See 11.2. (line 11102)
--F option: See 3.5.3. (line 3103)
--f option: See 1.1.3. (line 1006)
--F option, -Ft sets FS to TAB: See 11.2. (line 11299)
--f option, on command line: See 11.2. (line 11304)
--F option, troubleshooting: See 11.7. (line 11496)
--mf/-mr options: See 11.2. (line 11126)
--v option: See 11.2. (line 11111)
--v option, variables, assigning: See 5.3.2. (line 5147)
--W option: See 11.2. (line 11136)
-. (period): See 2.3. (line 1972)
-.mo files: See 9.2. (line 10095)
-.mo files, converting from .po: See 9.5. (line 10517)
-.mo files, specifying directory of <1>: See 9.3. (line 10228)
-.mo files, specifying directory of: See 9.2. (line 10107)
-.po files <1>: See 9.4. (line 10291)
-.po files: See 9.2. (line 10092)
-.po files, converting to .mo: See 9.5. (line 10517)
-/ (forward slash): See 2. (line 1724)
-/ (forward slash), / operator: See 5.14. (line 6127)
-/ (forward slash), /= operator <1>: See 5.14. (line 6168)
-/ (forward slash), /= operator: See 5.7. (line 5570)
-/ (forward slash), /= operator, vs. /=.../ regexp constant:See 5.7.
- (line 5589)
-/ (forward slash), patterns and: See 6.1.2. (line 6248)
-/= operator vs. /=.../ regexp constant: See 5.7. (line 5589)
-/dev/... special files (gawk): See 4.7.1. (line 4599)
-/inet/ files (gawk): See 10.3. (line 10758)
-/p files (gawk): See 10.4. (line 10822)
-; (semicolon): See 1.6. (line 1637)
-; (semicolon), AWKPATH variable and: See B.3.3.4. (line 16604)
-; (semicolon), separating statements in actions <1>:See 6.4.
- (line 6596)
-; (semicolon), separating statements in actions:See 6.3. (line 6549)
-< (left angle bracket), < operator <1>: See 5.14. (line 6137)
-< (left angle bracket), < operator: See 5.10. (line 5786)
-< (left angle bracket), < operator (I/O): See 3.8.3. (line 3619)
-< (left angle bracket), <= operator <1>: See 5.14. (line 6137)
-< (left angle bracket), <= operator: See 5.10. (line 5786)
-= (equals sign), = operator: See 5.7. (line 5447)
-= (equals sign), == operator <1>: See 5.14. (line 6137)
-= (equals sign), == operator: See 5.10. (line 5786)
-> (right angle bracket), > operator <1>: See 5.14. (line 6137)
-> (right angle bracket), > operator: See 5.10. (line 5786)
-> (right angle bracket), > operator (I/O): See 4.6. (line 4422)
-> (right angle bracket), >= operator <1>: See 5.14. (line 6137)
-> (right angle bracket), >= operator: See 5.10. (line 5786)
-> (right angle bracket), >> operator (I/O) <1>:See 5.14. (line 6137)
-> (right angle bracket), >> operator (I/O): See 4.6. (line 4450)
-? (question mark) <1>: See 2.5. (line 2242)
-? (question mark): See 2.3. (line 2039)
-? (question mark), ?: operator: See 5.14. (line 6165)
-[] (square brackets): See 2.3. (line 1984)
-\ (backslash) <1>: See 2.3. (line 1947)
-\ (backslash) <2>: See 1.1.6. (line 1167)
-\ (backslash) <3>: See 1.1.5. (line 1139)
-\ (backslash): See 1.1.2. (line 971)
-\ (backslash), \" escape sequence: See 2.2. (line 1865)
-\ (backslash), \' operator (gawk): See 2.5. (line 2239)
-\ (backslash), \/ escape sequence: See 2.2. (line 1858)
-\ (backslash), \< operator (gawk): See 2.5. (line 2213)
-\ (backslash), \> operator (gawk): See 2.5. (line 2217)
-\ (backslash), \` operator (gawk): See 2.5. (line 2237)
-\ (backslash), \a escape sequence: See 2.2. (line 1823)
-\ (backslash), \b escape sequence: See 2.2. (line 1827)
-\ (backslash), \B operator (gawk): See 2.5. (line 2226)
-\ (backslash), \f escape sequence: See 2.2. (line 1830)
-\ (backslash), \n escape sequence: See 2.2. (line 1833)
-\ (backslash), \NNN escape sequence: See 2.2. (line 1845)
-\ (backslash), \r escape sequence: See 2.2. (line 1836)
-\ (backslash), \t escape sequence: See 2.2. (line 1839)
-\ (backslash), \v escape sequence: See 2.2. (line 1842)
-\ (backslash), \W operator (gawk): See 2.5. (line 2209)
-\ (backslash), \w operator (gawk): See 2.5. (line 2204)
-\ (backslash), \x escape sequence: See 2.2. (line 1850)
-\ (backslash), \y operator (gawk): See 2.5. (line 2221)
-\ (backslash), as field separators: See 3.5.3. (line 3124)
-\ (backslash), continuing lines and <1>: See 13.2.2. (line 13657)
-\ (backslash), continuing lines and: See 1.6. (line 1566)
-\ (backslash), continuing lines and, comments and:See 1.6. (line 1622)
-\ (backslash), continuing lines and, in csh <1>:See 1.6. (line 1591)
-\ (backslash), continuing lines and, in csh: See 1.5. (line 1494)
-\ (backslash), gsub/gensub/sub functions and: See 8.1.3.1. (line 8838)
-\ (backslash), in character lists: See 2.4. (line 2115)
-\ (backslash), in escape sequences: See 2.2. (line 1795)
-\ (backslash), in escape sequences, POSIX and: See 2.2. (line 1902)
-\ (backslash), regexp constants: See 2.8. (line 2406)
-^ (caret) <1>: See 2.5. (line 2242)
-^ (caret): See 2.3. (line 1951)
-^ (caret), ^ operator <1>: See 11.2. (line 11247)
-^ (caret), ^ operator: See 5.14. (line 6121)
-^ (caret), ^= operator <1>: See 11.2. (line 11247)
-^ (caret), ^= operator <2>: See 5.14. (line 6168)
-^ (caret), ^= operator: See 5.7. (line 5570)
-^ (caret), in character lists: See 2.4. (line 2115)
-_ (underscore), _ C macro: See 9.2. (line 10124)
-_ (underscore), in names of private variables: See 12.1. (line 11588)
-_ (underscore), translatable string: See 9.3. (line 10250)
-_gr_init user-defined function: See 12.6. (line 12992)
-_pw_init user-defined function: See 12.5. (line 12780)
-accessing fields: See 3.2. (line 2713)
-account information <1>: See 12.6. (line 12918)
-account information: See 12.5. (line 12705)
-actions: See 6.3. (line 6536)
-actions, control statements in: See 6.4. (line 6592)
-actions, default: See 1.3. (line 1351)
-actions, empty: See 1.3. (line 1356)
-adding, features to gawk: See C.2.1. (line 17214)
-adding, fields: See 3.4. (line 2871)
-adding, functions to gawk: See C.3. (line 17426)
-advanced features, buffering: See 8.1.4. (line 9097)
-advanced features, close function: See 4.8. (line 4856)
-advanced features, constants, values of: See 5.1.2. (line 5010)
-advanced features, data files as single record:See 3.1. (line 2681)
-advanced features, fixed-width data: See 3.6. (line 3275)
-advanced features, FNR/NR variables: See 6.5.2. (line 7452)
-advanced features, gawk: See 10. (line 10565)
-advanced features, gawk, BSD portals: See 10.4. (line 10822)
-advanced features, gawk, network programming: See 10.3. (line 10758)
-advanced features, gawk, nondecimal input data:See 10.1. (line 10585)
-advanced features, gawk, processes, communicating with:See 10.2.
- (line 10641)
-advanced features, network connections, See Also networks, connections:See 10.
- (line 10565)
-advanced features, null strings, matching: See 8.1.3.1. (line 8992)
-advanced features, operators, precedence: See 5.8. (line 5664)
-advanced features, piping into sh: See 4.6. (line 4539)
-advanced features, regexp constants: See 5.7. (line 5589)
-Aho, Alfred <1>: See A.6. (line 15891)
-Aho, Alfred:
- See ``History of awk and gawk''. (line 503)
-alarm clock example program: See 13.3.2. (line 14363)
-alarm.awk program: See 13.3.2. (line 14381)
-algorithms: See D.1. (line 18172)
-Alpha (DEC):
- See ``The GNU Project and This Book''. (line 739)
-amazing awk assembler (aaa):
- See ``Glossary''. (line 18397)
-amazingly workable formatter (awf):
- See ``Glossary''. (line 18405)
-ambiguity, syntactic: /= operator vs. /=.../ regexp constant:See 5.7.
- (line 5589)
-amiga: See B.3.1. (line 16342)
-ampersand (&), && operator: See 5.11. (line 5947)
-ampersand (&), &&operator: See 5.14. (line 6159)
-ampersand (&), gsub/gensub/sub functions and: See 8.1.3.1. (line 8838)
-AND bitwise operation: See 8.1.6. (line 9501)
-and Boolean-logic operator: See 5.11. (line 5896)
-and function (gawk): See 8.1.6. (line 9534)
-ANSI:
- See ``Glossary''. (line 18416)
-archeologists: See B.5. (line 17011)
-ARGC/ARGV variables <1>: See 6.5.3. (line 7481)
-ARGC/ARGV variables: See 6.5.2. (line 7276)
-ARGC/ARGV variables, command-line arguments: See 11.3. (line 11364)
-ARGC/ARGV variables, portability and: See 1.1.4. (line 1072)
-ARGIND variable: See 6.5.2. (line 7305)
-ARGIND variable, command-line arguments: See 11.3. (line 11364)
-arguments, command-line <1>: See 11.3. (line 11358)
-arguments, command-line <2>: See 6.5.3. (line 7481)
-arguments, command-line: See 6.5.2. (line 7276)
-arguments, command-line, invoking awk: See 11.1. (line 11066)
-arguments, in function calls: See 5.13. (line 6031)
-arguments, processing: See 12.4. (line 12414)
-arguments, retrieving: See C.3.1. (line 17555)
-arithmetic operators: See 5.5. (line 5287)
-arrays: See 7. (line 7574)
-arrays, as parameters to functions: See 8.2.3. (line 9879)
-arrays, associative: See 7.1. (line 7632)
-arrays, associative, clearing: See C.3.1. (line 17500)
-arrays, associative, library functions and: See 12.1. (line 11616)
-arrays, deleting entire contents: See 7.6. (line 7879)
-arrays, elements, assigning: See 7.3. (line 7730)
-arrays, elements, deleting: See 7.6. (line 7846)
-arrays, elements, installing: See C.3.1. (line 17504)
-arrays, elements, order of: See 7.5. (line 7835)
-arrays, elements, referencing: See 7.2. (line 7686)
-arrays, elements, retrieving number of: See 8.1.3. (line 8387)
-arrays, for statement and: See 7.5. (line 7808)
-arrays, IGNORECASE variable and: See 7.1. (line 7674)
-arrays, indexing: See 7.1. (line 7632)
-arrays, merging into strings: See 12.2.7. (line 12052)
-arrays, multidimensional: See 7.9. (line 8006)
-arrays, multidimensional, scanning: See 7.10. (line 8090)
-arrays, names of: See 7. (line 7585)
-arrays, scanning: See 7.5. (line 7794)
-arrays, sorting: See 7.11. (line 8122)
-arrays, sorting, IGNORECASE variable and: See 7.11. (line 8202)
-arrays, sparse: See 7.1. (line 7653)
-arrays, subscripts: See 7.7. (line 7914)
-arrays, subscripts, uninitialized variables as:See 7.8. (line 7962)
-artificial intelligence, gawk and: See B.1.3. (line 16091)
-ASCII: See 12.2.6. (line 12002)
-asort function (gawk) <1>: See 8.1.3. (line 8387)
-asort function (gawk): See 7.11. (line 8122)
-asort function (gawk), arrays, sorting: See 7.11. (line 8122)
-asorti function (gawk): See 8.1.3. (line 8416)
-assert function (C library): See 12.2.3. (line 11812)
-assert user-defined function: See 12.2.3. (line 11834)
-assertions: See 12.2.3. (line 11812)
-assignment operators: See 5.7. (line 5447)
-assignment operators, evaluation order: See 5.7. (line 5552)
-assignment operators, lvalues/rvalues: See 5.7. (line 5473)
-assignments as filenames: See 12.3.5. (line 12375)
-assoc_clear internal function: See C.3.1. (line 17500)
-assoc_lookup internal function: See C.3.1. (line 17504)
-associative arrays: See 7.1. (line 7632)
-asterisk (*), * operator, as multiplication operator:See 5.14.
- (line 6127)
-asterisk (*), * operator, as regexp operator: See 2.3. (line 2015)
-asterisk (*), * operator, null strings, matching:See 8.1.3.1.
- (line 8992)
-asterisk (*), ** operator <1>: See 11.2. (line 11247)
-asterisk (*), ** operator <2>: See 5.14. (line 6121)
-asterisk (*), ** operator: See 5.5. (line 5362)
-asterisk (*), **= operator <1>: See 11.2. (line 11247)
-asterisk (*), **= operator <2>: See 5.14. (line 6168)
-asterisk (*), **= operator: See 5.7. (line 5570)
-asterisk (*), *= operator <1>: See 5.14. (line 6168)
-asterisk (*), *= operator: See 5.7. (line 5570)
-atan2 function: See 8.1.2. (line 8302)
-atari: See B.4.1. (line 16873)
-awf (amazingly workable formatter) program:
- See ``Glossary''. (line 18405)
-awk language, POSIX version: See 5.7. (line 5577)
-awk programs <1>: See 1.4. (line 1436)
-awk programs <2>: See 1.1.4. (line 1035)
-awk programs: See 1. (line 882)
-awk programs, complex: See 1.8. (line 1701)
-awk programs, documenting <1>: See 12.1. (line 11565)
-awk programs, documenting: See 1.1.5. (line 1095)
-awk programs, examples of: See 13. (line 13147)
-awk programs, execution of: See 6.4.8. (line 6972)
-awk programs, internationalizing <1>: See 9.3. (line 10189)
-awk programs, internationalizing: See 8.1.7. (line 9620)
-awk programs, lengthy: See 1.1.3. (line 1000)
-awk programs, lengthy, assertions: See 12.2.3. (line 11812)
-awk programs, location of: See 11.2. (line 11106)
-awk programs, one-line examples: See 1.3. (line 1362)
-awk programs, profiling: See 10.5. (line 10834)
-awk programs, profiling, enabling: See 11.2. (line 11264)
-awk programs, running <1>: See 1.1.3. (line 1000)
-awk programs, running: See 1.1. (line 909)
-awk programs, running, from shell scripts: See 1.1.1. (line 942)
-awk programs, running, without input files: See 1.1.2. (line 963)
-awk programs, shell variables in: See 6.2. (line 6488)
-awk, function of: See 1. (line 876)
-awk, gawk and <1>:
- See ``Using This Book''. (line 575)
-awk, gawk and:
- See ``Preface''. (line 447)
-awk, history of:
- See ``History of awk and gawk''. (line 503)
-awk, implementation issues, pipes: See 4.6. (line 4531)
-awk, implementations: See B.6. (line 17078)
-awk, implementations, limits: See 3.8.9. (line 3815)
-awk, invoking: See 11.1. (line 11066)
-awk, new vs. old:
- See ``A Rose by Any Other Name''. (line 537)
-awk, new vs. old, OFMT variable: See 5.4. (line 5234)
-awk, POSIX and:
- See ``Preface''. (line 447)
-awk, POSIX and, See Also POSIX awk:
- See ``Preface''. (line 447)
-awk, regexp constants and: See 5.10. (line 5877)
-awk, See Also gawk:
- See ``Preface''. (line 460)
-awk, terms describing:
- See ``Using This Book''. (line 568)
-awk, uses for <1>: See 1.8. (line 1677)
-awk, uses for <2>: See 1. (line 882)
-awk, uses for:
- See ``Preface''. (line 447)
-awk, versions of <1>: See A.1. (line 15514)
-awk, versions of:
- See ``A Rose by Any Other Name''. (line 541)
-awk, versions of, changes between SVR3.1 and SVR4:See A.2. (line 15570)
-awk, versions of, changes between SVR4 and POSIX awk:See A.3.
- (line 15608)
-awk, versions of, changes between V7 and SVR3.1:See A.1. (line 15514)
-awk, versions of, See Also Bell Laboratories awk:See A.4. (line 15650)
-awk.h file (internal): See C.3.1. (line 17449)
-awka compiler for awk: See B.6. (line 17148)
-AWKNUM internal type: See C.3.1. (line 17453)
-AWKPATH environment variable <1>: See B.3.3.4. (line 16604)
-AWKPATH environment variable: See 11.4. (line 11411)
-awkprof.out file: See 10.5. (line 10838)
-awksed.awk program: See 13.3.8. (line 15059)
-awkvars.out file: See 11.2. (line 11176)
-backslash (\) <1>: See 2.3. (line 1947)
-backslash (\) <2>: See 1.1.6. (line 1167)
-backslash (\) <3>: See 1.1.5. (line 1139)
-backslash (\): See 1.1.2. (line 971)
-backslash (\), \" escape sequence: See 2.2. (line 1865)
-backslash (\), \' operator (gawk): See 2.5. (line 2239)
-backslash (\), \/ escape sequence: See 2.2. (line 1858)
-backslash (\), \< operator (gawk): See 2.5. (line 2213)
-backslash (\), \> operator (gawk): See 2.5. (line 2217)
-backslash (\), \` operator (gawk): See 2.5. (line 2237)
-backslash (\), \a escape sequence: See 2.2. (line 1823)
-backslash (\), \b escape sequence: See 2.2. (line 1827)
-backslash (\), \B operator (gawk): See 2.5. (line 2226)
-backslash (\), \f escape sequence: See 2.2. (line 1830)
-backslash (\), \n escape sequence: See 2.2. (line 1833)
-backslash (\), \NNN escape sequence: See 2.2. (line 1845)
-backslash (\), \r escape sequence: See 2.2. (line 1836)
-backslash (\), \t escape sequence: See 2.2. (line 1839)
-backslash (\), \v escape sequence: See 2.2. (line 1842)
-backslash (\), \W operator (gawk): See 2.5. (line 2209)
-backslash (\), \w operator (gawk): See 2.5. (line 2204)
-backslash (\), \x escape sequence: See 2.2. (line 1850)
-backslash (\), \y operator (gawk): See 2.5. (line 2221)
-backslash (\), as field separators: See 3.5.3. (line 3124)
-backslash (\), continuing lines and <1>: See 13.2.2. (line 13657)
-backslash (\), continuing lines and: See 1.6. (line 1566)
-backslash (\), continuing lines and, comments and:See 1.6. (line 1622)
-backslash (\), continuing lines and, in csh <1>:See 1.6. (line 1591)
-backslash (\), continuing lines and, in csh: See 1.5. (line 1494)
-backslash (\), gsub/gensub/sub functions and: See 8.1.3.1. (line 8838)
-backslash (\), in character lists: See 2.4. (line 2115)
-backslash (\), in escape sequences: See 2.2. (line 1795)
-backslash (\), in escape sequences, POSIX and: See 2.2. (line 1902)
-backslash (\), regexp constants: See 2.8. (line 2406)
-BBS-list file: See 1.2. (line 1256)
-Beebe, Nelson:
- See ``Acknowledgments''. (line 842)
-Beebe, Nelson H.F.: See B.6. (line 17160)
-BEGIN pattern <1>: See 6.1.4. (line 6371)
-BEGIN pattern <2>: See 3.5. (line 2984)
-BEGIN pattern: See 3.1. (line 2548)
-BEGIN pattern, assert user-defined function and:See 12.2.3. (line 11888)
-BEGIN pattern, Boolean patterns and: See 6.1.2. (line 6297)
-BEGIN pattern, exit statement and: See 6.4.10. (line 7064)
-BEGIN pattern, getline and: See 3.8.9. (line 3820)
-BEGIN pattern, headings, adding: See 4.2. (line 3939)
-BEGIN pattern, next/nextfile statements and <1>:See 6.4.8. (line 6995)
-BEGIN pattern, next/nextfile statements and: See 6.1.4.2. (line 6468)
-BEGIN pattern, OFS/ORS variables, assigning values to:See 4.3.
- (line 3993)
-BEGIN pattern, operators and: See 6.1.4.1. (line 6393)
-BEGIN pattern, pgawk program: See 10.5. (line 10897)
-BEGIN pattern, print statement and: See 6.1.4.2. (line 6448)
-BEGIN pattern, pwcat program: See 12.5. (line 12814)
-BEGIN pattern, running awk programs and: See 13.2.1. (line 13254)
-BEGIN pattern, TEXTDOMAIN variable and: See 9.3. (line 10241)
-beginfile user-defined function: See 12.3.1. (line 12234)
-Bell Laboratories awk extensions: See A.4. (line 15650)
-Benzinger, Michael: See A.6. (line 15964)
-BeOS: See B.3.2. (line 16372)
-Berry, Karl:
- See ``Acknowledgments''. (line 819)
-binary input/output: See 6.5.1. (line 7124)
-bindtextdomain function (C library): See 9.2. (line 10103)
-bindtextdomain function (gawk) <1>: See 9.3. (line 10228)
-bindtextdomain function (gawk): See 8.1.7. (line 9640)
-bindtextdomain function (gawk), portability and:See 9.4.3. (line 10426)
-BINMODE variable <1>: See B.3.3.4. (line 16633)
-BINMODE variable: See 6.5.1. (line 7124)
-bits2str user-defined function: See 8.1.6. (line 9555)
-bitwise, complement: See 8.1.6. (line 9520)
-bitwise, operations: See 8.1.6. (line 9501)
-bitwise, shift: See 8.1.6. (line 9527)
-body, in actions: See 6.4. (line 6596)
-body, in loops: See 6.4.2. (line 6651)
-Boolean expressions: See 5.11. (line 5896)
-Boolean expressions, as patterns: See 6.1.2. (line 6265)
-Boolean operators, See Boolean expressions: See 5.11. (line 5896)
-Bourne shell, quoting rules for: See 1.1.6. (line 1154)
-braces ({}), actions and: See 6.3. (line 6549)
-braces ({}), pgawk program: See 10.5. (line 10968)
-braces ({}), statements, grouping: See 6.4. (line 6596)
-bracket expressions, See character lists: See 2.3. (line 1984)
-break statement: See 6.4.6. (line 6858)
-Brennan, Michael <1>: See B.6. (line 17078)
-Brennan, Michael <2>: See 13.3.8. (line 15059)
-Brennan, Michael <3>: See 10.2. (line 10624)
-Brennan, Michael: See 7.6. (line 7891)
-Broder, Alan J.: See A.6. (line 15955)
-Brown, Martin <1>: See B.5. (line 17062)
-Brown, Martin <2>: See A.6. (line 15950)
-Brown, Martin:
- See ``Acknowledgments''. (line 842)
-BSD portals: See 10.4. (line 10822)
-BSD-based operating systems:
- See ``Glossary''. (line 18964)
-Buening, Andreas <1>: See A.6. (line 15959)
-Buening, Andreas:
- See ``Acknowledgments''. (line 842)
-buffering, input/output <1>: See 10.2. (line 10689)
-buffering, input/output: See 8.1.4. (line 9129)
-buffering, interactive vs. noninteractive: See 8.1.4. (line 9097)
-buffers, flushing: See 8.1.4. (line 9031)
-buffers, operators for: See 2.5. (line 2231)
-bug reports, email address, address@hidden: See B.5. (line 17032)
address@hidden bug reporting address: See B.5. (line 17032)
-built-in functions: See 8. (line 8210)
-built-in functions, evaluation order: See 8.1.1. (line 8254)
-built-in variables: See 6.5. (line 7105)
-built-in variables, -v option, setting with: See 11.2. (line 11119)
-built-in variables, conveying information: See 6.5.2. (line 7271)
-built-in variables, user-modifiable: See 6.5.1. (line 7120)
-call by reference: See 8.2.3. (line 9879)
-call by value: See 8.2.3. (line 9850)
-caret (^) <1>: See 2.5. (line 2242)
-caret (^): See 2.3. (line 1951)
-caret (^), ^ operator <1>: See 11.2. (line 11247)
-caret (^), ^ operator: See 5.14. (line 6121)
-caret (^), ^= operator <1>: See 11.2. (line 11247)
-caret (^), ^= operator <2>: See 5.14. (line 6168)
-caret (^), ^= operator: See 5.7. (line 5570)
-caret (^), in character lists: See 2.4. (line 2115)
-case keyword: See 6.4.5. (line 6800)
-case sensitivity, array indices and: See 7.1. (line 7674)
-case sensitivity, converting case: See 8.1.3. (line 8810)
-case sensitivity, example programs: See 12. (line 11545)
-case sensitivity, gawk: See 2.6. (line 2302)
-case sensitivity, regexps and <1>: See 6.5.1. (line 7182)
-case sensitivity, regexps and: See 2.6. (line 2282)
-case sensitivity, string comparisons and: See 6.5.1. (line 7182)
-character encodings: See 12.2.6. (line 12002)
-character lists <1>: See 2.4. (line 2104)
-character lists: See 2.3. (line 1984)
-character lists, character classes: See 2.4. (line 2128)
-character lists, collating elements: See 2.4. (line 2169)
-character lists, collating symbols: See 2.4. (line 2176)
-character lists, complemented: See 2.3. (line 1991)
-character lists, equivalence classes: See 2.4. (line 2182)
-character lists, non-ASCII: See 2.4. (line 2169)
-character lists, range expressions: See 2.4. (line 2104)
-character sets: See 12.2.6. (line 12002)
-character sets (machine character encodings):
- See ``Glossary''. (line 18523)
-character sets, See Also character lists: See 2.3. (line 1984)
-characters, counting: See 13.2.7. (line 14171)
-characters, transliterating: See 13.3.3. (line 14483)
-characters, values of as numbers: See 12.2.6. (line 11964)
-Chassell, Robert J.:
- See ``Acknowledgments''. (line 819)
-chdir function, implementing in gawk: See C.3.2. (line 17645)
-chem utility:
- See ``Glossary''. (line 18531)
-chr user-defined function: See 12.2.6. (line 11974)
-Cliff random numbers: See 12.2.5. (line 11936)
-cliff_rand user-defined function: See 12.2.5. (line 11941)
-close function <1>: See 8.1.4. (line 9012)
-close function <2>: See 4.8. (line 4744)
-close function <3>: See 3.8.5. (line 3703)
-close function: See 3.8.4. (line 3673)
-close function, return values: See 4.8. (line 4856)
-close function, two-way pipes and: See 10.2. (line 10696)
-Close, Diane <1>: See A.6. (line 15900)
-Close, Diane:
- See ``The GNU Project and This Book''. (line 751)
-collating elements: See 2.4. (line 2169)
-collating symbols: See 2.4. (line 2176)
-columns, aligning: See 4.2. (line 3966)
-columns, cutting: See 13.2.1. (line 13194)
-comma (,), in range patterns: See 6.1.3. (line 6307)
-command line, arguments <1>: See 11.3. (line 11358)
-command line, arguments <2>: See 6.5.3. (line 7481)
-command line, arguments: See 6.5.2. (line 7276)
-command line, formats: See 1.1. (line 915)
-command line, FS on, setting: See 3.5.3. (line 3103)
-command line, invoking awk from: See 11.1. (line 11066)
-command line, options <1>: See 11.2. (line 11087)
-command line, options <2>: See 3.5.3. (line 3103)
-command line, options: See 1.1.3. (line 1006)
-command line, options, end of: See 11.2. (line 11143)
-command line, variables, assigning on: See 5.3.2. (line 5141)
-command-line options, processing: See 12.4. (line 12414)
-command-line options, string extraction: See 9.4.1. (line 10303)
-commenting: See 1.1.5. (line 1095)
-commenting, backslash continuation and: See 1.6. (line 1622)
-comp.lang.awk newsgroup: See B.5. (line 17042)
-comparison expressions: See 5.10. (line 5720)
-comparison expressions, as patterns: See 6.1.2. (line 6238)
-comparison expressions, string vs. regexp: See 5.10. (line 5854)
-compatibility mode (gawk), extensions: See A.5. (line 15690)
-compatibility mode (gawk), file names: See 4.7.4. (line 4703)
-compatibility mode (gawk), hexadecimal numbers:See 5.1.2. (line 5003)
-compatibility mode (gawk), octal numbers: See 5.1.2. (line 5003)
-compatibility mode (gawk), specifying: See 11.2. (line 11160)
-compiled programs <1>:
- See ``Glossary''. (line 18541)
-compiled programs: See D.1. (line 18120)
-compl function (gawk): See 8.1.6. (line 9538)
-complement, bitwise: See 8.1.6. (line 9520)
-compound statements, control statements and: See 6.4. (line 6596)
-concatenating: See 5.6. (line 5372)
-conditional expressions: See 5.12. (line 5984)
-configuration option, --disable-lint: See B.2.2. (line 16270)
-configuration option, --disable-nls: See B.2.2. (line 16285)
-configuration option, --enable-portals: See B.2.2. (line 16256)
-configuration option, --enable-switch: See B.2.2. (line 16260)
-configuration option, --with-included-gettext <1>:See B.2.2.
- (line 16264)
-configuration option, --with-included-gettext: See 9.6. (line 10557)
-configuration options, gawk: See B.2.2. (line 16253)
-constants, nondecimal: See 10.1. (line 10585)
-constants, types of: See 5.1. (line 4909)
-continue statement: See 6.4.7. (line 6912)
-control statements: See 6.4. (line 6592)
-converting, case: See 8.1.3. (line 8810)
-converting, dates to timestamps: See 8.1.5. (line 9240)
-converting, during subscripting: See 7.7. (line 7939)
-converting, numbers: See 5.4. (line 5186)
-converting, numbers, to strings: See 8.1.6. (line 9594)
-converting, strings to numbers: See 5.4. (line 5186)
-CONVFMT variable <1>: See 6.5.1. (line 7140)
-CONVFMT variable: See 5.4. (line 5209)
-CONVFMT variable, array subscripts and: See 7.7. (line 7914)
-coprocesses <1>: See 10.2. (line 10662)
-coprocesses: See 4.6. (line 4502)
-coprocesses, closing: See 4.8. (line 4732)
-coprocesses, getline from: See 3.8.7. (line 3765)
-cos function: See 8.1.2. (line 8299)
-counting: See 13.2.7. (line 14171)
-csh utility: See 1.6. (line 1591)
-csh utility, backslash continuation and: See 1.5. (line 1494)
-csh utility, POSIXLY_CORRECT environment variable:See 11.2. (line 11342)
-csh utility, |& operator, comparison with: See 10.2. (line 10662)
-ctime user-defined function: See 8.2.2. (line 9815)
-currency symbols, localization: See 9.2. (line 10155)
-custom.h file: See B.2.3. (line 16317)
-cut utility: See 13.2.1. (line 13194)
-cut.awk program: See 13.2.1. (line 13232)
-d.c., See dark corner:
- See ``Dark Corners''. (line 705)
-dark corner <1>:
- See ``Glossary''. (line 18573)
-dark corner <2>: See 5.9. (line 5710)
-dark corner <3>: See 5.7. (line 5589)
-dark corner <4>: See 4.5.3. (line 4231)
-dark corner:
- See ``Dark Corners''. (line 705)
-dark corner, array subscripts: See 7.8. (line 7998)
-dark corner, break statement: See 6.4.6. (line 6899)
-dark corner, close function: See 4.8. (line 4856)
-dark corner, command-line arguments: See 5.3.2. (line 5178)
-dark corner, continue statement: See 6.4.7. (line 6949)
-dark corner, CONVFMT variable: See 5.4. (line 5220)
-dark corner, escape sequences: See 11.3. (line 11383)
-dark corner, escape sequences, for metacharacters:See 2.2. (line 1925)
-dark corner, exit statement: See 6.4.10. (line 7081)
-dark corner, field separators: See 3.5.4. (line 3228)
-dark corner, FILENAME variable <1>: See 6.5.2. (line 7353)
-dark corner, FILENAME variable: See 3.8.9. (line 3820)
-dark corner, FNR/NR variables: See 6.5.2. (line 7452)
-dark corner, format-control characters: See 4.5.2. (line 4168)
-dark corner, FS as null string: See 3.5.2. (line 3094)
-dark corner, input files: See 3.1. (line 2617)
-dark corner, invoking awk: See 11.1. (line 11076)
-dark corner, multiline records: See 3.7. (line 3402)
-dark corner, NF variable, decrementing: See 3.4. (line 2925)
-dark corner, OFMT variable: See 4.4. (line 4038)
-dark corner, regexp constants: See 5.2. (line 5030)
-dark corner, regexp constants, /= operator and:See 5.7. (line 5589)
-dark corner, regexp constants, as arguments to user-defined functions:See 5.2.
- (line 5068)
-dark corner, split function: See 8.1.3. (line 8580)
-dark corner, strings, storing: See 3.1. (line 2697)
-data, fixed-width: See 3.6. (line 3275)
-data-driven languages: See D.1. (line 18189)
-database, group, reading: See 12.6. (line 12918)
-database, users, reading: See 12.5. (line 12695)
-date utility, GNU: See 8.1.5. (line 9188)
-date utility, POSIX: See 8.1.5. (line 9435)
-dates, converting to timestamps: See 8.1.5. (line 9240)
-dates, information related to, localization: See 9.2. (line 10167)
-Davies, Stephen <1>: See B.5. (line 17067)
-Davies, Stephen: See A.6. (line 15947)
-dcgettext function (gawk) <1>: See 9.3. (line 10202)
-dcgettext function (gawk): See 8.1.7. (line 9626)
-dcgettext function (gawk), portability and: See 9.4.3. (line 10426)
-dcngettext function (gawk) <1>: See 9.3. (line 10218)
-dcngettext function (gawk): See 8.1.7. (line 9632)
-dcngettext function (gawk), portability and: See 9.4.3. (line 10426)
-deadlocks: See 10.2. (line 10689)
-debugging gawk: See 11.7. (line 11496)
-debugging gawk, bug reports: See B.5. (line 17014)
-decrement operators: See 5.8. (line 5638)
-default keyword: See 6.4.5. (line 6800)
-Deifik, Scott <1>: See B.5. (line 17063)
-Deifik, Scott <2>: See A.6. (line 15931)
-Deifik, Scott:
- See ``Acknowledgments''. (line 842)
-delete statement: See 7.6. (line 7846)
-deleting elements in arrays: See 7.6. (line 7846)
-deleting entire arrays: See 7.6. (line 7879)
-differences in awk and gawk, ARGC/ARGV variables:See 6.5.3. (line 7560)
-differences in awk and gawk, ARGIND variable: See 6.5.2. (line 7305)
-differences in awk and gawk, array elements, deleting:See 7.6.
- (line 7879)
-differences in awk and gawk, AWKPATH environment variable:See 11.4.
- (line 11411)
-differences in awk and gawk, BEGIN/END patterns:See 6.1.4.2.
- (line 6448)
-differences in awk and gawk, BINMODE variable <1>:See B.3.3.4.
- (line 16633)
-differences in awk and gawk, BINMODE variable: See 6.5.1. (line 7135)
-differences in awk and gawk, close function: See 4.8. (line 4807)
-differences in awk and gawk, ERRNO variable: See 6.5.2. (line 7337)
-differences in awk and gawk, error messages: See 4.7.1. (line 4573)
-differences in awk and gawk, FIELDWIDTHS variable:See 6.5.1.
- (line 7147)
-differences in awk and gawk, function arguments (gawk):See 8.1.1.
- (line 8240)
-differences in awk and gawk, getline command: See 3.8. (line 3521)
-differences in awk and gawk, IGNORECASE variable:See 6.5.1. (line 7182)
-differences in awk and gawk, implementation limitations <1>:See 4.6.
- (line 4531)
-differences in awk and gawk, implementation limitations:See 3.8.9.
- (line 3815)
-differences in awk and gawk, input/output operators <1>:See 4.6.
- (line 4502)
-differences in awk and gawk, input/output operators:See 3.8.7.
- (line 3765)
-differences in awk and gawk, line continuations:See 5.12. (line 6012)
-differences in awk and gawk, LINT variable: See 6.5.1. (line 7197)
-differences in awk and gawk, match function: See 8.1.3. (line 8511)
-differences in awk and gawk, next/nextfile statements:See 6.4.9.
- (line 7008)
-differences in awk and gawk, print/printf statements:See 4.5.3.
- (line 4185)
-differences in awk and gawk, PROCINFO array: See 6.5.2. (line 7384)
-differences in awk and gawk, record separators:See 3.1. (line 2631)
-differences in awk and gawk, regexp constants: See 5.2. (line 5068)
-differences in awk and gawk, regular expressions:See 2.6. (line 2302)
-differences in awk and gawk, RS/RT variables: See 3.1. (line 2673)
-differences in awk and gawk, RT variable: See 6.5.2. (line 7441)
-differences in awk and gawk, single-character fields:See 3.5.2.
- (line 3080)
-differences in awk and gawk, split function: See 8.1.3. (line 8569)
-differences in awk and gawk, strings: See 5.1.1. (line 4934)
-differences in awk and gawk, strings, storing: See 3.1. (line 2693)
-differences in awk and gawk, strtonum function (gawk):See 8.1.3.
- (line 8607)
-differences in awk and gawk, TEXTDOMAIN variable:See 6.5.1. (line 7252)
-differences in awk and gawk, trunc-mod operation:See 5.5. (line 5347)
-directories, changing: See C.3.2. (line 17645)
-directories, searching <1>: See 13.3.9. (line 15469)
-directories, searching: See 11.4. (line 11411)
-division: See 5.5. (line 5325)
-do-while statement <1>: See 6.4.3. (line 6687)
-do-while statement: See 2.1. (line 1749)
-documentation, of awk programs: See 12.1. (line 11565)
-documentation, online:
- See ``The GNU Project and This Book''. (line 722)
-documents, searching: See 13.3.1. (line 14315)
-dollar sign ($): See 2.3. (line 1964)
-dollar sign ($), $ field operator <1>: See 5.14. (line 6115)
-dollar sign ($), $ field operator: See 3.2. (line 2726)
-dollar sign ($), incrementing fields and arrays:See 5.8. (line 5633)
-double quote (") <1>: See 1.1.6. (line 1173)
-double quote ("): See 1.1.2. (line 971)
-double quote ("), regexp constants: See 2.8. (line 2406)
-double-precision floating-point: See D.2. (line 18232)
-Drepper, Ulrich:
- See ``Acknowledgments''. (line 838)
-dupnode internal function: See C.3.1. (line 17531)
-dupword.awk program: See 13.3.1. (line 14340)
-EBCDIC: See 12.2.6. (line 12002)
-egrep utility <1>: See 13.2.2. (line 13445)
-egrep utility: See 2.4. (line 2122)
-egrep.awk program: See 13.2.2. (line 13493)
-elements in arrays: See 7.2. (line 7686)
-elements in arrays, assigning: See 7.3. (line 7730)
-elements in arrays, deleting: See 7.6. (line 7846)
-elements in arrays, order of: See 7.5. (line 7835)
-elements in arrays, scanning: See 7.5. (line 7794)
-email address for bug reports, address@hidden:See B.5. (line 17032)
-EMISTERED: See 10.3. (line 10758)
-empty pattern: See 6.1.5. (line 6478)
-empty strings, See null strings: See 3.5.1. (line 3061)
-END pattern: See 6.1.4. (line 6371)
-END pattern, assert user-defined function and: See 12.2.3. (line 11880)
-END pattern, backslash continuation and: See 13.2.2. (line 13657)
-END pattern, Boolean patterns and: See 6.1.2. (line 6297)
-END pattern, exit statement and: See 6.4.10. (line 7064)
-END pattern, next/nextfile statements and <1>: See 6.4.8. (line 6995)
-END pattern, next/nextfile statements and: See 6.1.4.2. (line 6468)
-END pattern, operators and: See 6.1.4.1. (line 6393)
-END pattern, pgawk program: See 10.5. (line 10897)
-END pattern, print statement and: See 6.1.4.2. (line 6448)
-endfile user-defined function: See 12.3.1. (line 12234)
-endgrent function (C library): See 12.6. (line 13125)
-endgrent user-defined function: See 12.6. (line 13128)
-endpwent function (C library): See 12.5. (line 12881)
-endpwent user-defined function: See 12.5. (line 12884)
-ENVIRON variable: See 6.5.2. (line 7325)
-environment variables: See 6.5.2. (line 7325)
-epoch, definition of:
- See ``Glossary''. (line 18615)
-equals sign (=), = operator: See 5.7. (line 5447)
-equals sign (=), == operator <1>: See 5.14. (line 6137)
-equals sign (=), == operator: See 5.10. (line 5786)
-EREs (Extended Regular Expressions): See 2.4. (line 2122)
-ERRNO variable <1>: See C.3.1. (line 17586)
-ERRNO variable <2>: See 6.5.2. (line 7337)
-ERRNO variable: See 3.8. (line 3521)
-error handling: See 4.7.1. (line 4573)
-error handling, ERRNO variable and: See 6.5.2. (line 7337)
-error output: See 4.7.1. (line 4564)
-escape processing, gsub/gensub/sub functions: See 8.1.3.1. (line 8838)
-escape sequences: See 2.2. (line 1795)
-escape sequences, unrecognized: See 11.2. (line 11235)
-evaluation order: See 5.8. (line 5664)
-evaluation order, concatenation: See 5.6. (line 5404)
-evaluation order, functions: See 8.1.1. (line 8254)
-examining fields: See 3.2. (line 2713)
-exclamation point (!), ! operator <1>: See 13.2.2. (line 13599)
-exclamation point (!), ! operator <2>: See 5.14. (line 6124)
-exclamation point (!), ! operator: See 5.11. (line 5957)
-exclamation point (!), != operator <1>: See 5.14. (line 6137)
-exclamation point (!), != operator: See 5.10. (line 5786)
-exclamation point (!), !~ operator <1>: See 6.1.2. (line 6248)
-exclamation point (!), !~ operator <2>: See 5.14. (line 6153)
-exclamation point (!), !~ operator <3>: See 5.10. (line 5786)
-exclamation point (!), !~ operator <4>: See 5.1.3. (line 5021)
-exclamation point (!), !~ operator <5>: See 2.8. (line 2384)
-exclamation point (!), !~ operator <6>: See 2.6. (line 2302)
-exclamation point (!), !~ operator: See 2.1. (line 1749)
-exit statement: See 6.4.10. (line 7058)
-exp function: See 8.1.2. (line 8287)
-expand utility: See 1.3. (line 1386)
-expressions: See 5. (line 4894)
-expressions, as patterns: See 6.1.2. (line 6230)
-expressions, assignment: See 5.7. (line 5447)
-expressions, Boolean: See 5.11. (line 5896)
-expressions, comparison: See 5.10. (line 5720)
-expressions, conditional: See 5.12. (line 5984)
-expressions, matching, See comparison expressions:See 5.10. (line 5720)
-expressions, selecting: See 5.12. (line 5984)
-Extended Regular Expressions (EREs): See 2.4. (line 2122)
-extension function (gawk): See C.3.2.3. (line 17950)
-extensions, Bell Laboratories awk: See A.4. (line 15650)
-extensions, in gawk, not in POSIX awk: See A.5. (line 15690)
-extensions, mawk: See B.6. (line 17118)
-extract.awk program: See 13.3.7. (line 14922)
-extraction, of marked strings (internationalization):See 9.4.1.
- (line 10303)
-false, logical: See 5.9. (line 5692)
-FDL (Free Documentation License):
- See ``GNU Free Documentation License''. (line 19344)
-features, adding to gawk: See C.2.1. (line 17214)
-features, advanced, See advanced features: See 11.5. (line 11468)
-features, deprecated: See 11.5. (line 11468)
-features, undocumented: See 11.6. (line 11488)
-Fenlason, Jay <1>: See A.6. (line 15898)
-Fenlason, Jay:
- See ``History of awk and gawk''. (line 516)
-fflush function: See 8.1.4. (line 9027)
-fflush function, unsupported: See 11.2. (line 11255)
-field numbers: See 3.3. (line 2781)
-field operator $: See 3.2. (line 2726)
-field operators, dollar sign as: See 3.2. (line 2726)
-field separators <1>: See 6.5.1. (line 7157)
-field separators: See 3.5. (line 2955)
-field separators, choice of: See 3.5. (line 2990)
-field separators, FIELDWIDTHS variable and: See 6.5.1. (line 7147)
-field separators, in multiline records: See 3.7. (line 3408)
-field separators, on command line: See 3.5.3. (line 3103)
-field separators, POSIX and <1>: See 3.5.4. (line 3222)
-field separators, POSIX and: See 3.2. (line 2713)
-field separators, regular expressions as <1>: See 3.5.1. (line 3024)
-field separators, regular expressions as: See 3.5. (line 2990)
-field separators, See Also OFS: See 3.4. (line 2882)
-field separators, spaces as: See 13.2.1. (line 13294)
-fields <1>: See D.1. (line 18177)
-fields <2>: See 3.2. (line 2713)
-fields: See 3. (line 2511)
-fields, adding: See 3.4. (line 2871)
-fields, changing contents of: See 3.4. (line 2824)
-fields, cutting: See 13.2.1. (line 13194)
-fields, examining: See 3.2. (line 2713)
-fields, number of: See 3.2. (line 2740)
-fields, numbers: See 3.3. (line 2781)
-fields, printing: See 4.2. (line 3917)
-fields, separating: See 3.5. (line 2955)
-fields, single-character: See 3.5.2. (line 3080)
-FIELDWIDTHS variable <1>: See 6.5.1. (line 7147)
-FIELDWIDTHS variable: See 3.6. (line 3288)
-file descriptors: See 4.7.1. (line 4564)
-file names, distinguishing: See 6.5.2. (line 7317)
-file names, in compatibility mode: See 4.7.4. (line 4703)
-file names, standard streams in gawk: See 4.7.1. (line 4599)
-FILENAME variable <1>: See 6.5.2. (line 7353)
-FILENAME variable: See 3. (line 2503)
-FILENAME variable, getline, setting with: See 3.8.9. (line 3820)
-filenames, assignments as: See 12.3.5. (line 12375)
-files, .mo: See 9.2. (line 10095)
-files, .mo, converting from .po: See 9.5. (line 10517)
-files, .mo, specifying directory of <1>: See 9.3. (line 10228)
-files, .mo, specifying directory of: See 9.2. (line 10107)
-files, .po <1>: See 9.4. (line 10291)
-files, .po: See 9.2. (line 10092)
-files, .po, converting to .mo: See 9.5. (line 10517)
-files, /dev/... special files: See 4.7.1. (line 4599)
-files, /inet/ (gawk): See 10.3. (line 10758)
-files, /p (gawk): See 10.4. (line 10822)
-files, as single records: See 3.1. (line 2702)
-files, awk programs in: See 1.1.3. (line 1000)
-files, awkprof.out: See 10.5. (line 10838)
-files, awkvars.out: See 11.2. (line 11176)
-files, closing: See 8.1.4. (line 9012)
-files, descriptors, See file descriptors: See 4.7.1. (line 4564)
-files, for process information: See 4.7.2. (line 4628)
-files, group: See 12.6. (line 12918)
-files, information about, retrieving: See C.3.2. (line 17645)
-files, initialization and cleanup: See 12.3.1. (line 12180)
-files, input, See input files: See 1.1.2. (line 963)
-files, log, timestamps in: See 8.1.5. (line 9177)
-files, managing: See 12.3. (line 12174)
-files, managing, data file boundaries: See 12.3.1. (line 12180)
-files, message object: See 9.2. (line 10095)
-files, message object, converting from portable object files:See 9.5.
- (line 10517)
-files, message object, specifying directory of <1>:See 9.3. (line 10228)
-files, message object, specifying directory of:See 9.2. (line 10107)
-files, multiple passes over: See 11.3. (line 11401)
-files, multiple, duplicating output into: See 13.2.5. (line 13876)
-files, output, See output files: See 4.8. (line 4732)
-files, password: See 12.5. (line 12705)
-files, portable object <1>: See 9.4. (line 10291)
-files, portable object: See 9.2. (line 10092)
-files, portable object, converting to message object files:See 9.5.
- (line 10517)
-files, portable object, generating: See 11.2. (line 11192)
-files, portal: See 10.4. (line 10822)
-files, processing, ARGIND variable and: See 6.5.2. (line 7312)
-files, reading: See 12.3.2. (line 12258)
-files, reading, multiline records: See 3.7. (line 3373)
-files, searching for regular expressions: See 13.2.2. (line 13445)
-files, skipping: See 12.3.3. (line 12297)
-files, source, search path for: See 13.3.9. (line 15469)
-files, splitting: See 13.2.4. (line 13776)
-files, Texinfo, extracting programs from: See 13.3.7. (line 14851)
-Fish, Fred <1>: See B.5. (line 17062)
-Fish, Fred: See A.6. (line 15929)
-fixed-width data: See 3.6. (line 3275)
-flag variables <1>: See 13.2.5. (line 13890)
-flag variables: See 5.11. (line 5957)
-floating-point: See D.3. (line 18339)
-floating-point, numbers: See D.2. (line 18220)
-floating-point, numbers, AWKNUM internal type: See C.3.1. (line 17453)
-FNR variable <1>: See 6.5.2. (line 7363)
-FNR variable: See 3.1. (line 2525)
-FNR variable, changing: See 6.5.2. (line 7452)
-for statement: See 6.4.4. (line 6720)
-for statement, in arrays: See 7.5. (line 7808)
-force_number internal function: See C.3.1. (line 17461)
-force_string internal function: See C.3.1. (line 17466)
-format specifiers, mixing regular with positional specifiers:See 9.4.2.
- (line 10377)
-format specifiers, printf statement: See 4.5.2. (line 4094)
-format specifiers, strftime function (gawk): See 8.1.5. (line 9253)
-format strings: See 4.5.1. (line 4065)
-formats, numeric output: See 4.4. (line 4017)
-formatting output: See 4.5. (line 4045)
-forward slash (/): See 2. (line 1724)
-forward slash (/), / operator: See 5.14. (line 6127)
-forward slash (/), /= operator <1>: See 5.14. (line 6168)
-forward slash (/), /= operator: See 5.7. (line 5570)
-forward slash (/), /= operator, vs. /=.../ regexp constant:See 5.7.
- (line 5589)
-forward slash (/), patterns and: See 6.1.2. (line 6248)
-Free Documentation License (FDL):
- See ``GNU Free Documentation License''. (line 19344)
-Free Software Foundation (FSF) <1>:
- See ``Glossary''. (line 18669)
-Free Software Foundation (FSF) <2>: See B.1.1. (line 15996)
-Free Software Foundation (FSF):
- See ``The GNU Project and This Book''. (line 717)
-free_temp internal macro: See C.3.1. (line 17536)
-FreeBSD:
- See ``Glossary''. (line 18964)
-FS variable <1>: See 6.5.1. (line 7157)
-FS variable: See 3.5. (line 2955)
-FS variable, --field-separator option and: See 11.2. (line 11102)
-FS variable, as null string: See 3.5.2. (line 3094)
-FS variable, as TAB character: See 11.2. (line 11251)
-FS variable, changing value of <1>: See 11.7. (line 11496)
-FS variable, changing value of: See 3.5. (line 2974)
-FS variable, running awk programs and: See 13.2.1. (line 13254)
-FS variable, setting from command line: See 3.5.3. (line 3103)
-FSF (Free Software Foundation) <1>:
- See ``Glossary''. (line 18669)
-FSF (Free Software Foundation) <2>: See B.1.1. (line 15996)
-FSF (Free Software Foundation):
- See ``The GNU Project and This Book''. (line 717)
-function calls: See 5.13. (line 6021)
-functions, arrays as parameters to: See 8.2.3. (line 9879)
-functions, built-in <1>: See 8. (line 8210)
-functions, built-in: See 5.13. (line 6025)
-functions, built-in, adding to gawk: See C.3. (line 17426)
-functions, built-in, evaluation order: See 8.1.1. (line 8254)
-functions, defining: See 8.2.1. (line 9661)
-functions, library: See 12. (line 11508)
-functions, library, assertions: See 12.2.3. (line 11812)
-functions, library, associative arrays and: See 12.1. (line 11616)
-functions, library, C library: See 12.4. (line 12414)
-functions, library, character values as numbers:See 12.2.6. (line 11964)
-functions, library, Cliff random numbers: See 12.2.5. (line 11936)
-functions, library, command-line options: See 12.4. (line 12414)
-functions, library, example program for using: See 13.3.9. (line 15117)
-functions, library, group database, reading: See 12.6. (line 12918)
-functions, library, managing data files: See 12.3. (line 12174)
-functions, library, managing time: See 12.2.8. (line 12095)
-functions, library, merging arrays into strings:See 12.2.7. (line 12052)
-functions, library, nextfile statement: See 12.2.1. (line 11648)
-functions, library, rounding numbers: See 12.2.4. (line 11894)
-functions, library, user database, reading: See 12.5. (line 12695)
-functions, names of <1>: See 8.2.1. (line 9675)
-functions, names of: See 7. (line 7585)
-functions, recursive: See 8.2.1. (line 9723)
-functions, return values, setting: See C.3.1. (line 17580)
-functions, string-translation: See 8.1.7. (line 9620)
-functions, undefined: See 8.2.3. (line 9903)
-functions, user-defined: See 8.2. (line 9653)
-functions, user-defined, calling: See 8.2.3. (line 9830)
-functions, user-defined, counts: See 10.5. (line 10963)
-functions, user-defined, library of: See 12. (line 11508)
-functions, user-defined, next/nextfile statements and <1>:See 6.4.9.
- (line 7041)
-functions, user-defined, next/nextfile statements and:See 6.4.8.
- (line 6995)
-G-d:
- See ``Acknowledgments''. (line 859)
-Garfinkle, Scott: See A.6. (line 15916)
-gawk, awk and <1>:
- See ``Using This Book''. (line 575)
-gawk, awk and:
- See ``Preface''. (line 447)
-gawk, bitwise operations in: See 8.1.6. (line 9534)
-gawk, break statement in: See 6.4.6. (line 6899)
-gawk, built-in variables and: See 6.5. (line 7113)
-gawk, character classes and: See 2.4. (line 2190)
-gawk, coding style in: See C.2.1. (line 17240)
-gawk, command-line options: See 2.5. (line 2253)
-gawk, comparison operators and: See 5.10. (line 5825)
-gawk, configuring: See B.2.3. (line 16294)
-gawk, configuring, options: See B.2.2. (line 16253)
-gawk, continue statement in: See 6.4.7. (line 6949)
-gawk, debugging: See 11.7. (line 11496)
-gawk, distribution: See B.1.3. (line 16050)
-gawk, escape sequences: See 2.2. (line 1914)
-gawk, extensions, disabling: See 11.2. (line 11231)
-gawk, features, adding: See C.2.1. (line 17214)
-gawk, features, advanced: See 10. (line 10565)
-gawk, fflush function in: See 8.1.4. (line 9047)
-gawk, field separators and: See 6.5.1. (line 7177)
-gawk, FIELDWIDTHS variable in: See 6.5.1. (line 7153)
-gawk, file names in: See 4.7. (line 4557)
-gawk, format-control characters: See 4.5.2. (line 4168)
-gawk, function arguments and: See 8.1.1. (line 8240)
-gawk, functions, adding: See C.3. (line 17426)
-gawk, hexadecimal numbers and: See 5.1.2. (line 4985)
-gawk, IGNORECASE variable in: See 6.5.1. (line 7193)
-gawk, implementation issues: See Appendix C.
- (line 17176)
-gawk, implementation issues, debugging: See C.1. (line 17183)
-gawk, implementation issues, downward compatibility:See C.1.
- (line 17183)
-gawk, implementation issues, limits: See 3.8.9. (line 3815)
-gawk, implementation issues, pipes: See 4.6. (line 4531)
-gawk, installing: See Appendix B.
- (line 15977)
-gawk, internals: See C.3.1. (line 17440)
-gawk, internationalization and, See internationalization:See 9.
- (line 10038)
-gawk, interpreter, adding code to <1>: See C.4. (line 18086)
-gawk, interpreter, adding code to: See C.3.2.3. (line 17941)
-gawk, interval expressions and: See 2.3. (line 2067)
-gawk, line continuation in: See 5.12. (line 6012)
-gawk, LINT variable in: See 6.5.1. (line 7206)
-gawk, list of contributors to: See A.6. (line 15885)
-gawk, MS-DOS version of: See B.3.3.4. (line 16604)
-gawk, newlines in: See 1.6. (line 1559)
-gawk, next file statement in: See 6.4.9. (line 7048)
-gawk, nextfile statement in <1>: See 12.2.1. (line 11648)
-gawk, nextfile statement in: See 6.4.9. (line 7048)
-gawk, octal numbers and: See 5.1.2. (line 4985)
-gawk, OS/2 version of: See B.3.3.4. (line 16604)
-gawk, regexp constants and: See 5.2. (line 5052)
-gawk, regular expressions, case sensitivity: See 2.6. (line 2302)
-gawk, regular expressions, operators: See 2.5. (line 2197)
-gawk, regular expressions, precedence: See 2.3. (line 2083)
-gawk, See Also awk:
- See ``Preface''. (line 460)
-gawk, source code, obtaining: See B.1.1. (line 15992)
-gawk, splitting fields and: See 3.6. (line 3353)
-gawk, string-translation functions: See 8.1.7. (line 9620)
-gawk, timestamps: See 8.1.5. (line 9177)
-gawk, uses for:
- See ``Preface''. (line 460)
-gawk, versions of, information about, printing:See 11.2. (line 11291)
-gawk, word-boundary operator: See 2.5. (line 2246)
-General Public License (GPL):
- See ``Glossary''. (line 18678)
-General Public License, See GPL:
- See ``The GNU Project and This Book''. (line 722)
-gensub function (gawk) <1>: See 8.1.3. (line 8718)
-gensub function (gawk): See 5.2. (line 5068)
-gensub function (gawk), escape processing: See 8.1.3.1. (line 8838)
-get_actual_argument internal function: See C.3.1. (line 17560)
-get_argument internal function: See C.3.1. (line 17555)
-get_array_argument internal macro: See C.3.1. (line 17575)
-get_curfunc_arg_count internal function: See C.3.1. (line 17471)
-get_scalar_argument internal macro: See C.3.1. (line 17570)
-getgrent function (C library): See 12.6. (line 12918)
-getgrent user-defined function: See 12.6. (line 12918)
-getgrgid function (C library): See 12.6. (line 13092)
-getgrgid user-defined function: See 12.6. (line 13095)
-getgrnam function (C library): See 12.6. (line 13080)
-getgrnam user-defined function: See 12.6. (line 13084)
-getgruser function (C library): See 12.6. (line 13103)
-getgruser function, user-defined: See 12.6. (line 13106)
-getline command: See 3. (line 2517)
-getline command, _gr_init user-defined function:See 12.6. (line 12992)
-getline command, _pw_init function: See 12.5. (line 12825)
-getline command, coprocesses, using from <1>: See 4.8. (line 4732)
-getline command, coprocesses, using from: See 3.8.7. (line 3765)
-getline command, deadlock and: See 10.2. (line 10689)
-getline command, explicit input with: See 3.8. (line 3508)
-getline command, FILENAME variable and: See 3.8.9. (line 3820)
-getline command, return values: See 3.8. (line 3521)
-getline command, variants: See 3.8.10. (line 3838)
-getopt function (C library): See 12.4. (line 12423)
-getopt user-defined function: See 12.4. (line 12514)
-getpwent function (C library): See 12.5. (line 12705)
-getpwent user-defined function: See 12.5. (line 12705)
-getpwnam function (C library): See 12.5. (line 12845)
-getpwnam user-defined function: See 12.5. (line 12849)
-getpwuid function (C library): See 12.5. (line 12857)
-getpwuid user-defined function: See 12.5. (line 12861)
-getservbyname function (C library): See 10.3. (line 10786)
-gettext function (C library): See 9.2. (line 10116)
-gettext library: See 9.2. (line 10062)
-gettext library, locale categories: See 9.2. (line 10134)
-gettimeofday user-defined function: See 12.2.8. (line 12105)
-GNITS mailing list:
- See ``Acknowledgments''. (line 838)
-GNU awk, See gawk:
- See ``Preface''. (line 473)
-GNU Free Documentation License:
- See ``GNU Free Documentation License''. (line 19344)
-GNU General Public License:
- See ``Glossary''. (line 18678)
-GNU Lesser General Public License:
- See ``Glossary''. (line 18755)
-GNU long options <1>: See 11.2. (line 11087)
-GNU long options: See 11.1. (line 11073)
-GNU long options, printing list of: See 11.2. (line 11201)
-GNU Project <1>:
- See ``Glossary''. (line 18687)
-GNU Project:
- See ``The GNU Project and This Book''. (line 722)
-GNU/Linux <1>:
- See ``Glossary''. (line 18964)
-GNU/Linux <2>: See B.4.1.1. (line 16902)
-GNU/Linux <3>: See B.2.2. (line 16264)
-GNU/Linux <4>: See 9.5. (line 10510)
-GNU/Linux:
- See ``The GNU Project and This Book''. (line 739)
-GPL (General Public License) <1>:
- See ``Glossary''. (line 18678)
-GPL (General Public License):
- See ``The GNU Project and This Book''. (line 722)
-GPL (General Public License), printing: See 11.2. (line 11168)
-grcat program: See 12.6. (line 12927)
-Grigera, Juan <1>: See B.5. (line 17064)
-Grigera, Juan: See A.6. (line 15933)
-group database, reading: See 12.6. (line 12918)
-group file: See 12.6. (line 12918)
-groups, information about: See 12.6. (line 12918)
-gsub function <1>: See 8.1.3. (line 8702)
-gsub function: See 5.2. (line 5068)
-gsub function, arguments of: See 8.1.3. (line 8682)
-gsub function, escape processing: See 8.1.3.1. (line 8838)
-Hankerson, Darrel <1>: See B.5. (line 17063)
-Hankerson, Darrel <2>: See A.6. (line 15935)
-Hankerson, Darrel:
- See ``Acknowledgments''. (line 842)
-Hartholz, Elaine:
- See ``Acknowledgments''. (line 824)
-Hartholz, Marshall:
- See ``Acknowledgments''. (line 824)
-Hasegawa, Isamu <1>: See A.6. (line 15961)
-Hasegawa, Isamu:
- See ``Acknowledgments''. (line 842)
-hexadecimal numbers: See 5.1.2. (line 4949)
-hexadecimal values, enabling interpretation of:See 11.2. (line 11223)
-histsort.awk program: See 13.3.6. (line 14827)
-Hughes, Phil:
- See ``Acknowledgments''. (line 829)
-HUP signal: See 10.5. (line 11038)
-hyphen (-), - operator: See 5.14. (line 6124)
-hyphen (-), -- (decrement/increment) operators:See 5.14. (line 6118)
-hyphen (-), -- operator: See 5.8. (line 5651)
-hyphen (-), -= operator <1>: See 5.14. (line 6168)
-hyphen (-), -= operator: See 5.7. (line 5570)
-hyphen (-), filenames beginning with: See 11.2. (line 11148)
-hyphen (-), in character lists: See 2.4. (line 2115)
-id utility: See 13.2.3. (line 13672)
-id.awk program: See 13.2.3. (line 13696)
-if statement <1>: See 6.4.1. (line 6607)
-if statement: See 2.1. (line 1749)
-if statement, actions, changing: See 6.1.3. (line 6326)
-igawk.sh program: See 13.3.9. (line 15229)
-IGNORECASE variable <1>: See 6.5.1. (line 7182)
-IGNORECASE variable: See 2.6. (line 2302)
-IGNORECASE variable, array sorting and: See 7.11. (line 8202)
-IGNORECASE variable, array subscripts and: See 7.1. (line 7674)
-IGNORECASE variable, in example programs: See 12. (line 11545)
-implementation issues, gawk: See Appendix C.
- (line 17176)
-implementation issues, gawk, debugging: See C.1. (line 17183)
-implementation issues, gawk, limits <1>: See 4.6. (line 4531)
-implementation issues, gawk, limits: See 3.8.9. (line 3815)
-in operator <1>: See 13.2.3. (line 13759)
-in operator <2>: See 6.4.4. (line 6788)
-in operator <3>: See 5.14. (line 6156)
-in operator: See 5.10. (line 5786)
-in operator, arrays and <1>: See 7.5. (line 7805)
-in operator, arrays and: See 7.2. (line 7705)
-increment operators: See 5.8. (line 5609)
-index function: See 8.1.3. (line 8429)
-indexing arrays: See 7.1. (line 7632)
-initialization, automatic: See 1.5. (line 1517)
-input files: See 3. (line 2503)
-input files, closing: See 4.8. (line 4732)
-input files, counting elements in: See 13.2.7. (line 14171)
-input files, examples: See 1.2. (line 1256)
-input files, reading: See 3. (line 2503)
-input files, running awk without: See 1.1.2. (line 952)
-input files, skipping: See 12.2.1. (line 11648)
-input files, variable assignments and: See 11.3. (line 11371)
-input pipeline: See 3.8.5. (line 3685)
-input redirection: See 3.8.3. (line 3619)
-input, data, nondecimal: See 10.1. (line 10585)
-input, explicit: See 3.8. (line 3508)
-input, files, See input files: See 3.7. (line 3373)
-input, multiline records: See 3.7. (line 3373)
-input, splitting into records: See 3.1. (line 2525)
-input, standard <1>: See 4.7.1. (line 4564)
-input, standard: See 1.1.2. (line 952)
-input/output, binary: See 6.5.1. (line 7124)
-input/output, from BEGIN and END: See 6.1.4.2. (line 6438)
-input/output, two-way: See 10.2. (line 10662)
-insomnia, cure for: See 13.3.2. (line 14360)
-installation, amiga: See B.3.1. (line 16342)
-installation, atari: See B.4.1. (line 16873)
-installation, beos: See B.3.2. (line 16372)
-installation, tandem: See B.4.2. (line 16977)
-installation, vms: See B.3.4. (line 16721)
-installing gawk: See Appendix B.
- (line 15977)
-int function: See 8.1.2. (line 8276)
-INT signal (MS-DOS): See 10.5. (line 11041)
-integers: See D.2. (line 18220)
-integers, unsigned: See D.2. (line 18227)
-interacting with other programs: See 8.1.4. (line 9065)
-internationalization <1>: See 9.1. (line 10050)
-internationalization: See 8.1.7. (line 9620)
-internationalization, localization <1>: See 9. (line 10038)
-internationalization, localization: See 6.5.1. (line 7252)
-internationalization, localization, character classes:See 2.4.
- (line 2190)
-internationalization, localization, gawk and: See 9. (line 10038)
-internationalization, localization, locale categories:See 9.2.
- (line 10134)
-internationalization, localization, marked strings:See 9.3. (line 10197)
-internationalization, localization, portability and:See 9.4.3.
- (line 10400)
-internationalizing a program: See 9.2. (line 10062)
-interpreted programs <1>:
- See ``Glossary''. (line 18727)
-interpreted programs: See D.1. (line 18120)
-interval expressions: See 2.3. (line 2044)
-inventory-shipped file: See 1.2. (line 1282)
-ISO:
- See ``Glossary''. (line 18738)
-ISO 8859-1:
- See ``Glossary''. (line 18523)
-ISO Latin-1:
- See ``Glossary''. (line 18523)
-Jacobs, Andrew: See 12.5. (line 12765)
-Jaegermann, Michal <1>: See A.6. (line 15924)
-Jaegermann, Michal:
- See ``Acknowledgments''. (line 842)
-Jedi knights: See 11.6. (line 11488)
-join user-defined function: See 12.2.7. (line 12064)
-Kahrs, Ju"rgen <1>: See A.6. (line 15943)
-Kahrs, Ju"rgen:
- See ``Acknowledgments''. (line 842)
-Kenobi, Obi-Wan: See 11.6. (line 11488)
-Kernighan, Brian <1>: See D.2. (line 18270)
-Kernighan, Brian <2>: See B.6. (line 17085)
-Kernighan, Brian <3>: See A.6. (line 15891)
-Kernighan, Brian <4>: See A.4. (line 15650)
-Kernighan, Brian <5>: See 5.6. (line 5369)
-Kernighan, Brian <6>:
- See ``Acknowledgments''. (line 849)
-Kernighan, Brian <7>:
- See ``Dark Corners''. (line 701)
-Kernighan, Brian:
- See ``History of awk and gawk''. (line 503)
-kill command, dynamic profiling: See 10.5. (line 11016)
-Knights, jedi: See 11.6. (line 11488)
-Kwok, Conrad: See A.6. (line 15916)
-labels.awk program: See 13.3.4. (line 14645)
-languages, data-driven: See D.1. (line 18189)
-LC_ALL locale category: See 9.2. (line 10172)
-LC_COLLATE locale category: See 9.2. (line 10145)
-LC_CTYPE locale category: See 9.2. (line 10149)
-LC_MESSAGES locale category: See 9.2. (line 10139)
-LC_MESSAGES locale category, bindtextdomain function (gawk):See 9.3.
- (line 10269)
-LC_MONETARY locale category: See 9.2. (line 10155)
-LC_NUMERIC locale category: See 9.2. (line 10159)
-LC_RESPONSE locale category: See 9.2. (line 10163)
-LC_TIME locale category: See 9.2. (line 10167)
-left angle bracket (<), < operator <1>: See 5.14. (line 6137)
-left angle bracket (<), < operator: See 5.10. (line 5786)
-left angle bracket (<), < operator (I/O): See 3.8.3. (line 3619)
-left angle bracket (<), <= operator <1>: See 5.14. (line 6137)
-left angle bracket (<), <= operator: See 5.10. (line 5786)
-left shift, bitwise: See 8.1.6. (line 9527)
-leftmost longest match: See 3.7. (line 3393)
-length function: See 8.1.3. (line 8440)
-Lesser General Public License (LGPL):
- See ``Glossary''. (line 18755)
-LGPL (Lesser General Public License):
- See ``Glossary''. (line 18755)
-libraries of awk functions: See 12. (line 11508)
-libraries of awk functions, assertions: See 12.2.3. (line 11812)
-libraries of awk functions, associative arrays and:See 12.1.
- (line 11616)
-libraries of awk functions, character values as numbers:See 12.2.6.
- (line 11964)
-libraries of awk functions, command-line options:See 12.4. (line 12414)
-libraries of awk functions, example program for using:See 13.3.9.
- (line 15117)
-libraries of awk functions, group database, reading:See 12.6.
- (line 12918)
-libraries of awk functions, managing, data files:See 12.3. (line 12174)
-libraries of awk functions, managing, time: See 12.2.8. (line 12095)
-libraries of awk functions, merging arrays into strings:See 12.2.7.
- (line 12052)
-libraries of awk functions, nextfile statement:See 12.2.1. (line 11648)
-libraries of awk functions, rounding numbers: See 12.2.4. (line 11894)
-libraries of awk functions, user database, reading:See 12.5.
- (line 12695)
-line breaks: See 1.6. (line 1553)
-line continuations: See 5.11. (line 5952)
-line continuations, gawk: See 5.12. (line 6012)
-line continuations, in print statement: See 4.2. (line 3972)
-line continuations, with C shell: See 1.5. (line 1509)
-lines, blank, printing: See 4.1. (line 3891)
-lines, counting: See 13.2.7. (line 14171)
-lines, duplicate, removing: See 13.3.6. (line 14808)
-lines, matching ranges of: See 6.1.3. (line 6307)
-lines, skipping between markers: See 6.1.3. (line 6344)
-lint checking: See 6.5.1. (line 7197)
-lint checking, array elements: See 7.6. (line 7874)
-lint checking, array subscripts: See 7.8. (line 7998)
-lint checking, empty programs: See 11.1. (line 11076)
-lint checking, issuing warnings: See 11.2. (line 11206)
-lint checking, POSIXLY_CORRECT environment variable:See 11.2.
- (line 11329)
-lint checking, undefined functions: See 8.2.3. (line 9920)
-LINT variable: See 6.5.1. (line 7197)
-Linux <1>:
- See ``Glossary''. (line 18964)
-Linux <2>: See B.4.1.1. (line 16902)
-Linux <3>: See B.2.2. (line 16264)
-Linux <4>: See 9.5. (line 10510)
-Linux:
- See ``The GNU Project and This Book''. (line 739)
-locale categories: See 9.2. (line 10134)
-localization: See 9.1. (line 10050)
-localization, See internationalization, localization:See 9.1.
- (line 10050)
-log files, timestamps in: See 8.1.5. (line 9177)
-log function: See 8.1.2. (line 8292)
-logical false/true: See 5.9. (line 5692)
-logical operators, See Boolean expressions: See 5.11. (line 5896)
-login information: See 12.5. (line 12705)
-long options: See 11.1. (line 11073)
-loops: See 6.4.2. (line 6643)
-loops, continue statements and: See 6.4.4. (line 6777)
-loops, count for header: See 10.5. (line 10957)
-loops, exiting: See 6.4.6. (line 6858)
-loops, See Also while statement: See 6.4.2. (line 6643)
-Lost In Space: See C.3. (line 17422)
-ls utility: See 1.5. (line 1494)
-lshift function (gawk): See 8.1.6. (line 9540)
-lvalues/rvalues: See 5.7. (line 5473)
-mailing labels, printing: See 13.3.4. (line 14603)
-mailing list, GNITS:
- See ``Acknowledgments''. (line 838)
-make_builtin internal function: See C.3.1. (line 17541)
-make_number internal function: See C.3.1. (line 17516)
-make_string internal function: See C.3.1. (line 17511)
-mark parity: See 12.2.6. (line 12002)
-marked string extraction (internationalization):See 9.4.1. (line 10303)
-marked strings, extracting: See 9.4.1. (line 10303)
-Marx, Groucho: See 5.8. (line 5664)
-match function: See 8.1.3. (line 8458)
-match function, RSTART/RLENGTH variables: See 8.1.3. (line 8475)
-matching, expressions, See comparison expressions:See 5.10. (line 5720)
-matching, leftmost longest: See 3.7. (line 3393)
-matching, null strings: See 8.1.3.1. (line 8992)
-mawk program: See B.6. (line 17105)
-McPhee, Patrick: See A.6. (line 15967)
-memory, releasing: See C.3.1. (line 17536)
-memory, setting limits: See 11.2. (line 11126)
-message object files: See 9.2. (line 10095)
-message object files, converting from portable object files:See 9.5.
- (line 10517)
-message object files, specifying directory of <1>:See 9.3. (line 10228)
-message object files, specifying directory of: See 9.2. (line 10107)
-metacharacters, escape sequences for: See 2.2. (line 1921)
-mktime function (gawk): See 8.1.5. (line 9201)
-modifiers, in format specifiers: See 4.5.3. (line 4178)
-monetary information, localization: See 9.2. (line 10155)
-msgfmt utility: See 9.5. (line 10517)
-names, arrays/variables <1>: See 12.1. (line 11565)
-names, arrays/variables: See 7. (line 7585)
-names, functions <1>: See 12.1. (line 11565)
-names, functions: See 8.2.1. (line 9675)
-namespace issues <1>: See 12.1. (line 11565)
-namespace issues: See 7. (line 7585)
-namespace issues, functions: See 8.2.1. (line 9675)
-nawk utility:
- See ``A Rose by Any Other Name''. (line 548)
-negative zero: See D.3. (line 18361)
-NetBSD:
- See ``Glossary''. (line 18964)
-networks, programming: See 10.3. (line 10758)
-networks, support for: See 4.7.3. (line 4684)
-newlines <1>: See 11.2. (line 11238)
-newlines <2>: See 5.11. (line 5957)
-newlines: See 1.6. (line 1553)
-newlines, as field separators: See 3.5. (line 3004)
-newlines, as record separators: See 3.1. (line 2539)
-newlines, in dynamic regexps: See 2.8. (line 2437)
-newlines, in regexp constants: See 2.8. (line 2447)
-newlines, printing: See 4.2. (line 3908)
-newlines, separating statements in actions <1>:See 6.4. (line 6596)
-newlines, separating statements in actions: See 6.3. (line 6549)
-next file statement: See A.5. (line 15839)
-next file statement, deprecated: See 11.5. (line 11473)
-next file statement, in gawk: See 6.4.9. (line 7048)
-next statement <1>: See 6.4.8. (line 6962)
-next statement: See 5.11. (line 5975)
-next statement, BEGIN/END patterns and: See 6.1.4.2. (line 6468)
-next statement, user-defined functions and: See 6.4.8. (line 6995)
-nextfile statement: See 6.4.9. (line 7008)
-nextfile statement, BEGIN/END patterns and: See 6.1.4.2. (line 6468)
-nextfile statement, implementing: See 12.2.1. (line 11648)
-nextfile statement, in gawk: See 6.4.9. (line 7048)
-nextfile statement, next file statement and: See 11.5. (line 11473)
-nextfile statement, user-defined functions and:See 6.4.9. (line 7041)
-nextfile user-defined function: See 12.2.1. (line 11680)
-NF variable <1>: See 6.5.2. (line 7368)
-NF variable: See 3.2. (line 2740)
-NF variable, decrementing: See 3.4. (line 2925)
-noassign.awk program: See 12.3.5. (line 12384)
-NODE internal type: See C.3.1. (line 17457)
-nodes, duplicating: See C.3.1. (line 17531)
-not Boolean-logic operator: See 5.11. (line 5896)
-NR variable <1>: See 6.5.2. (line 7379)
-NR variable: See 3.1. (line 2525)
-NR variable, changing: See 6.5.2. (line 7452)
-null strings <1>: See D.2. (line 18246)
-null strings <2>: See 5.9. (line 5692)
-null strings <3>: See 3.5.1. (line 3061)
-null strings: See 3.1. (line 2621)
-null strings, array elements and: See 7.6. (line 7867)
-null strings, as array subscripts: See 7.8. (line 7998)
-null strings, converting numbers to strings: See 5.4. (line 5201)
-null strings, matching: See 8.1.3.1. (line 8992)
-null strings, quoting and: See 1.1.6. (line 1198)
-number sign (#), #! (executable scripts): See 1.1.4. (line 1035)
-number sign (#), #! (executable scripts), portability issues with:See 1.1.4.
- (line 1035)
-number sign (#), commenting: See 1.1.5. (line 1095)
-numbers: See C.3.1. (line 17516)
-numbers, as array subscripts: See 7.7. (line 7914)
-numbers, as values of characters: See 12.2.6. (line 11964)
-numbers, Cliff random: See 12.2.5. (line 11936)
-numbers, converting: See 5.4. (line 5186)
-numbers, converting, to strings <1>: See 8.1.6. (line 9594)
-numbers, converting, to strings: See 6.5.1. (line 7140)
-numbers, floating-point: See D.2. (line 18220)
-numbers, floating-point, AWKNUM internal type: See C.3.1. (line 17453)
-numbers, hexadecimal: See 5.1.2. (line 4949)
-numbers, NODE internal type: See C.3.1. (line 17457)
-numbers, octal: See 5.1.2. (line 4949)
-numbers, random: See 8.1.2. (line 8335)
-numbers, rounding: See 12.2.4. (line 11894)
-numeric, constants: See 5.1.1. (line 4920)
-numeric, output format: See 4.4. (line 4017)
-numeric, strings: See 5.10. (line 5724)
-numeric, values: See C.3.1. (line 17461)
-oawk utility:
- See ``A Rose by Any Other Name''. (line 548)
-obsolete features: See 11.5. (line 11468)
-octal numbers: See 5.1.2. (line 4949)
-octal values, enabling interpretation of: See 11.2. (line 11223)
-OFMT variable <1>: See 6.5.1. (line 7214)
-OFMT variable <2>: See 5.4. (line 5234)
-OFMT variable: See 4.4. (line 4026)
-OFMT variable, POSIX awk and: See 4.4. (line 4038)
-OFS variable <1>: See 6.5.1. (line 7223)
-OFS variable <2>: See 4.3. (line 3979)
-OFS variable: See 3.4. (line 2882)
-OpenBSD:
- See ``Glossary''. (line 18964)
-operating systems, BSD-based <1>: See 10.4. (line 10822)
-operating systems, BSD-based:
- See ``The GNU Project and This Book''. (line 739)
-operating systems, PC, gawk on: See B.3.3.4. (line 16599)
-operating systems, PC, gawk on, installing: See B.3.3. (line 16401)
-operating systems, porting gawk to: See C.2.2. (line 17344)
-operating systems, See Also GNU/Linux, PC operating systems, Unix:See Appendix
B.
- (line 15977)
-operations, bitwise: See 8.1.6. (line 9501)
-operators, arithmetic: See 5.5. (line 5287)
-operators, assignment: See 5.7. (line 5447)
-operators, assignment, evaluation order: See 5.7. (line 5552)
-operators, Boolean, See Boolean expressions: See 5.11. (line 5896)
-operators, decrement/increment: See 5.8. (line 5609)
-operators, GNU-specific: See 2.5. (line 2197)
-operators, input/output <1>: See 5.14. (line 6137)
-operators, input/output <2>: See 4.6. (line 4422)
-operators, input/output <3>: See 3.8.7. (line 3765)
-operators, input/output <4>: See 3.8.5. (line 3685)
-operators, input/output: See 3.8.3. (line 3619)
-operators, logical, See Boolean expressions: See 5.11. (line 5896)
-operators, precedence <1>: See 5.14. (line 6083)
-operators, precedence: See 5.8. (line 5664)
-operators, relational, See operators, comparison:See 5.10. (line 5720)
-operators, short-circuit: See 5.11. (line 5947)
-operators, string: See 5.6. (line 5372)
-operators, string-matching: See 2.1. (line 1749)
-operators, string-matching, for buffers: See 2.5. (line 2231)
-operators, word-boundary (gawk): See 2.5. (line 2246)
-options, command-line <1>: See 11.2. (line 11087)
-options, command-line <2>: See 3.5.3. (line 3103)
-options, command-line: See 1.1.3. (line 1006)
-options, command-line, end of: See 11.2. (line 11143)
-options, command-line, invoking awk: See 11.1. (line 11066)
-options, command-line, processing: See 12.4. (line 12414)
-options, deprecated: See 11.5. (line 11468)
-options, long <1>: See 11.2. (line 11087)
-options, long: See 11.1. (line 11073)
-options, printing list of: See 11.2. (line 11201)
-OR bitwise operation: See 8.1.6. (line 9501)
-or Boolean-logic operator: See 5.11. (line 5896)
-or function (gawk): See 8.1.6. (line 9534)
-ord user-defined function: See 12.2.6. (line 11974)
-order of evaluation, concatenation: See 5.6. (line 5404)
-ORS variable <1>: See 6.5.1. (line 7228)
-ORS variable: See 4.3. (line 3993)
-output field separator, See OFS variable: See 3.4. (line 2882)
-output record separator, See ORS variable: See 4.3. (line 3993)
-output redirection: See 4.6. (line 4409)
-output, buffering: See 8.1.4. (line 9031)
-output, duplicating into files: See 13.2.5. (line 13876)
-output, files, closing: See 4.8. (line 4732)
-output, format specifier, OFMT: See 4.4. (line 4026)
-output, formatted: See 4.5. (line 4045)
-output, pipes: See 4.6. (line 4457)
-output, printing, See printing: See 4. (line 3857)
-output, records: See 4.3. (line 3993)
-output, standard: See 4.7.1. (line 4564)
-P1003.2 POSIX standard:
- See ``Glossary''. (line 18808)
-param_cnt internal variable: See C.3.1. (line 17480)
-parameters, number of: See C.3.1. (line 17480)
-parentheses (): See 2.3. (line 2007)
-parentheses (), pgawk program: See 10.5. (line 10972)
-password file: See 12.5. (line 12705)
-patterns: See 6. (line 6178)
-patterns, comparison expressions as: See 6.1.2. (line 6238)
-patterns, counts: See 10.5. (line 10944)
-patterns, default: See 1.3. (line 1351)
-patterns, empty: See 6.1.5. (line 6478)
-patterns, expressions as: See 6.1.1. (line 6219)
-patterns, ranges in: See 6.1.3. (line 6307)
-patterns, regexp constants as: See 6.1.2. (line 6260)
-patterns, types of: See 6.1. (line 6191)
-pawk profiling Bell Labs awk: See B.6. (line 17160)
-PC operating systems, gawk on: See B.3.3.4. (line 16599)
-PC operating systems, gawk on, installing: See B.3.3. (line 16401)
-percent sign (%), % operator: See 5.14. (line 6127)
-percent sign (%), %= operator <1>: See 5.14. (line 6168)
-percent sign (%), %= operator: See 5.7. (line 5570)
-period (.): See 2.3. (line 1972)
-PERL: See C.4. (line 17998)
-Peters, Arno: See A.6. (line 15952)
-Peterson, Hal: See A.6. (line 15919)
-pgawk program: See 10.5. (line 10834)
-pgawk program, awkprof.out file: See 10.5. (line 10838)
-pgawk program, dynamic profiling: See 10.5. (line 11008)
-pipes, closing: See 4.8. (line 4732)
-pipes, input: See 3.8.5. (line 3685)
-pipes, output: See 4.6. (line 4457)
-plus sign (+): See 2.3. (line 2030)
-plus sign (+), + operator: See 5.14. (line 6124)
-plus sign (+), ++ operator <1>: See 5.14. (line 6118)
-plus sign (+), ++ operator: See 5.8. (line 5643)
-plus sign (+), += operator <1>: See 5.14. (line 6168)
-plus sign (+), += operator: See 5.7. (line 5523)
-plus sign (+), decrement/increment operators: See 5.8. (line 5614)
-portability: See 2.2. (line 1883)
-portability, #! (executable scripts): See 1.1.4. (line 1063)
-portability, ** operator and: See 5.5. (line 5362)
-portability, **= operator and: See 5.7. (line 5583)
-portability, ARGV variable: See 1.1.4. (line 1072)
-portability, backslash continuation and: See 1.6. (line 1577)
-portability, backslash in escape sequences: See 2.2. (line 1902)
-portability, close function and: See 4.8. (line 4807)
-portability, data files as single record: See 3.1. (line 2681)
-portability, deleting array elements: See 7.6. (line 7891)
-portability, example programs: See 12. (line 11533)
-portability, fflush function and: See 8.1.4. (line 9031)
-portability, functions, defining: See 8.2.1. (line 9743)
-portability, gawk: See C.2.2. (line 17344)
-portability, gettext library and: See 9.2. (line 10066)
-portability, internationalization and: See 9.4.3. (line 10400)
-portability, length function: See 8.1.3. (line 8449)
-portability, new awk vs. old awk: See 5.4. (line 5234)
-portability, next statement in user-defined functions:See 8.2.3.
- (line 9923)
-portability, NF variable, decrementing: See 3.4. (line 2933)
-portability, operators: See 5.8. (line 5664)
-portability, operators, not in POSIX awk: See 5.14. (line 6172)
-portability, POSIXLY_CORRECT environment variable:See 11.2. (line 11347)
-portability, substr function: See 8.1.3. (line 8800)
-portable object files <1>: See 9.4. (line 10291)
-portable object files: See 9.2. (line 10092)
-portable object files, converting to message object files:See 9.5.
- (line 10517)
-portable object files, generating: See 11.2. (line 11192)
-portal files: See 10.4. (line 10822)
-porting gawk: See C.2.2. (line 17344)
-positional specifiers, printf statement <1>: See 9.4.2. (line 10326)
-positional specifiers, printf statement: See 4.5.3. (line 4185)
-positional specifiers, printf statement, mixing with regular formats:See 9.4.2.
- (line 10377)
-positive zero: See D.3. (line 18361)
-POSIX awk <1>: See 5.7. (line 5577)
-POSIX awk:
- See ``Using This Book''. (line 575)
-POSIX awk, **= operator and: See 5.7. (line 5583)
-POSIX awk, < operator and: See 3.8.3. (line 3639)
-POSIX awk, arithmetic operators and: See 5.5. (line 5317)
-POSIX awk, backslashes in string constants: See 2.2. (line 1902)
-POSIX awk, BEGIN/END patterns: See 6.1.4.2. (line 6448)
-POSIX awk, break statement and: See 6.4.6. (line 6899)
-POSIX awk, changes in awk versions: See A.3. (line 15608)
-POSIX awk, character lists and: See 2.4. (line 2122)
-POSIX awk, character lists and, character classes:See 2.4. (line 2128)
-POSIX awk, continue statement and: See 6.4.7. (line 6949)
-POSIX awk, CONVFMT variable and: See 6.5.1. (line 7140)
-POSIX awk, date utility and: See 8.1.5. (line 9435)
-POSIX awk, field separators and <1>: See 3.5.4. (line 3222)
-POSIX awk, field separators and: See 3.2. (line 2713)
-POSIX awk, FS variable and: See 6.5.1. (line 7166)
-POSIX awk, function keyword in: See 8.2.1. (line 9728)
-POSIX awk, functions and, gsub/sub: See 8.1.3.1. (line 8885)
-POSIX awk, functions and, length: See 8.1.3. (line 8449)
-POSIX awk, GNU long options and: See 11.2. (line 11096)
-POSIX awk, interval expressions in: See 2.3. (line 2063)
-POSIX awk, next/nextfile statements and: See 6.4.8. (line 6995)
-POSIX awk, numeric strings and: See 5.10. (line 5724)
-POSIX awk, OFMT variable and <1>: See 5.4. (line 5234)
-POSIX awk, OFMT variable and: See 4.4. (line 4038)
-POSIX awk, period (.), using: See 2.3. (line 1979)
-POSIX awk, printf format strings and: See 4.5.3. (line 4331)
-POSIX awk, regular expressions and: See 2.3. (line 2083)
-POSIX awk, timestamps and: See 8.1.5. (line 9177)
-POSIX awk, | I/O operator and: See 3.8.5. (line 3731)
-POSIX mode: See 11.2. (line 11231)
-POSIX, awk and:
- See ``Preface''. (line 447)
-POSIX, gawk extensions not included in: See A.5. (line 15690)
-POSIX, programs, implementing in awk: See 13.2. (line 13178)
-POSIXLY_CORRECT environment variable: See 11.2. (line 11329)
-precedence <1>: See 5.14. (line 6083)
-precedence: See 5.8. (line 5664)
-precedence, regexp operators: See 2.3. (line 2078)
-print statement: See 4. (line 3867)
-print statement, BEGIN/END patterns and: See 6.1.4.2. (line 6448)
-print statement, commas, omitting: See 4.2. (line 3927)
-print statement, I/O operators in: See 5.14. (line 6144)
-print statement, line continuations and: See 4.2. (line 3972)
-print statement, OFMT variable and: See 6.5.1. (line 7223)
-print statement, See Also redirection, of output:See 4.6. (line 4417)
-print statement, sprintf function and: See 12.2.4. (line 11894)
-printf statement <1>: See 4.5. (line 4045)
-printf statement: See 4. (line 3867)
-printf statement, columns, aligning: See 4.2. (line 3966)
-printf statement, format-control characters: See 4.5.2. (line 4094)
-printf statement, I/O operators in: See 5.14. (line 6144)
-printf statement, modifiers: See 4.5.3. (line 4178)
-printf statement, positional specifiers <1>: See 9.4.2. (line 10326)
-printf statement, positional specifiers: See 4.5.3. (line 4185)
-printf statement, positional specifiers, mixing with regular formats:See 9.4.2.
- (line 10377)
-printf statement, See Also redirection, of output:See 4.6. (line 4417)
-printf statement, sprintf function and: See 12.2.4. (line 11894)
-printf statement, syntax of: See 4.5.1. (line 4056)
-printing: See 4. (line 3857)
-printing, list of options: See 11.2. (line 11201)
-printing, mailing labels: See 13.3.4. (line 14603)
-printing, unduplicated lines of text: See 13.2.6. (line 13957)
-printing, user information: See 13.2.3. (line 13672)
-private variables: See 12.1. (line 11570)
-process information, files for: See 4.7.2. (line 4628)
-processes, two-way communications with: See 10.2. (line 10641)
-processing data: See D.1. (line 18112)
-PROCINFO array <1>: See 12.6. (line 12918)
-PROCINFO array <2>: See 12.5. (line 12695)
-PROCINFO array <3>: See 6.5.2. (line 7384)
-PROCINFO array: See 4.7.4. (line 4706)
-profiling awk programs: See 10.5. (line 10834)
-profiling awk programs, dynamically: See 10.5. (line 11008)
-profiling gawk, See pgawk program: See 10.5. (line 10834)
-program, definition of: See 1. (line 891)
-programmers, attractiveness of: See 10.2. (line 10624)
-programming conventions, --non-decimal-data option:See 10.1.
- (line 10615)
-programming conventions, ARGC/ARGV variables: See 6.5.2. (line 7296)
-programming conventions, exit statement: See 6.4.10. (line 7088)
-programming conventions, function parameters: See 8.2.4. (line 9963)
-programming conventions, functions, calling: See 8.1.1. (line 8234)
-programming conventions, functions, writing: See 8.2.1. (line 9705)
-programming conventions, gawk internals: See C.3.2.2. (line 17800)
-programming conventions, nextfile statement: See 12.2.1. (line 11662)
-programming conventions, private variable names:See 12.1. (line 11582)
-programming language, recipe for:
- See ``History of awk and gawk''. (line 492)
-programming languages, data-driven vs. procedural:See 1. (line 882)
-programming, basic steps: See D.1. (line 18125)
-programming, concepts: See Appendix D.
- (line 18102)
-pwcat program: See 12.5. (line 12712)
-question mark (?) <1>: See 2.5. (line 2242)
-question mark (?): See 2.3. (line 2039)
-question mark (?), ?: operator: See 5.14. (line 6165)
-QUIT signal (MS-DOS): See 10.5. (line 11041)
-quoting <1>: See 1.1.5. (line 1116)
-quoting <2>: See 1.1.3. (line 1020)
-quoting: See 1.1.2. (line 971)
-quoting, rules for: See 1.1.6. (line 1146)
-quoting, tricks for: See 1.1.6. (line 1207)
-Rakitzis, Byron: See 13.3.6. (line 14827)
-rand function: See 8.1.2. (line 8305)
-random numbers, Cliff: See 12.2.5. (line 11936)
-random numbers, rand/srand functions: See 8.1.2. (line 8305)
-random numbers, seed of: See 8.1.2. (line 8335)
-range expressions: See 2.4. (line 2104)
-range patterns: See 6.1.3. (line 6307)
-Rankin, Pat <1>: See B.5. (line 17069)
-Rankin, Pat <2>: See A.6. (line 15914)
-Rankin, Pat <3>: See 5.7. (line 5541)
-Rankin, Pat:
- See ``Acknowledgments''. (line 842)
-raw sockets: See 10.3. (line 10782)
-readable data files, checking: See 12.3.3. (line 12297)
-readable.awk program: See 12.3.3. (line 12302)
-recipe for a programming language:
- See ``History of awk and gawk''. (line 492)
-record separators <1>: See 6.5.1. (line 7233)
-record separators: See 3.1. (line 2533)
-record separators, changing: See 3.1. (line 2600)
-record separators, regular expressions as: See 3.1. (line 2631)
-record separators, with multiline records: See 3.7. (line 3377)
-records <1>: See D.1. (line 18177)
-records: See 3. (line 2511)
-records, multiline: See 3.7. (line 3373)
-records, printing: See 4.1. (line 3891)
-records, splitting input into: See 3.1. (line 2525)
-records, terminating: See 3.1. (line 2631)
-records, treating files as: See 3.1. (line 2702)
-recursive functions: See 8.2.1. (line 9723)
-redirection of input: See 3.8.3. (line 3619)
-redirection of output: See 4.6. (line 4409)
-reference counting, sorting arrays: See 7.11. (line 8195)
-regexp constants <1>: See 5.10. (line 5877)
-regexp constants <2>: See 5.1.3. (line 5021)
-regexp constants: See 2.1. (line 1788)
-regexp constants, /=.../, /= operator and: See 5.7. (line 5589)
-regexp constants, as patterns: See 6.1.2. (line 6260)
-regexp constants, in gawk: See 5.2. (line 5052)
-regexp constants, slashes vs. quotes: See 2.8. (line 2406)
-regexp constants, vs. string constants: See 2.8. (line 2416)
-regexp, See regular expressions: See 2. (line 1720)
-regular expressions: See 2. (line 1720)
-regular expressions as field separators: See 3.5. (line 2990)
-regular expressions, anchors in: See 2.3. (line 1951)
-regular expressions, as field separators: See 3.5.1. (line 3024)
-regular expressions, as patterns <1>: See 6.1.1. (line 6219)
-regular expressions, as patterns: See 2.1. (line 1736)
-regular expressions, as record separators: See 3.1. (line 2631)
-regular expressions, case sensitivity <1>: See 6.5.1. (line 7182)
-regular expressions, case sensitivity: See 2.6. (line 2282)
-regular expressions, computed: See 2.8. (line 2384)
-regular expressions, constants, See regexp constants:See 2.1.
- (line 1788)
-regular expressions, dynamic: See 2.8. (line 2384)
-regular expressions, dynamic, with embedded newlines:See 2.8.
- (line 2437)
-regular expressions, gawk, command-line options:See 2.5. (line 2253)
-regular expressions, interval expressions and: See 11.2. (line 11276)
-regular expressions, leftmost longest match: See 2.7. (line 2357)
-regular expressions, operators <1>: See 2.3. (line 1935)
-regular expressions, operators: See 2.1. (line 1749)
-regular expressions, operators, for buffers: See 2.5. (line 2231)
-regular expressions, operators, for words: See 2.5. (line 2197)
-regular expressions, operators, gawk: See 2.5. (line 2197)
-regular expressions, operators, precedence of: See 2.3. (line 2078)
-regular expressions, searching for: See 13.2.2. (line 13445)
-relational operators, See comparison operators:See 5.10. (line 5720)
-return statement, user-defined functions: See 8.2.4. (line 9930)
-return values, close function: See 4.8. (line 4856)
-rev user-defined function: See 8.2.2. (line 9795)
-rewind user-defined function: See 12.3.2. (line 12268)
-right angle bracket (>), > operator <1>: See 5.14. (line 6137)
-right angle bracket (>), > operator: See 5.10. (line 5786)
-right angle bracket (>), > operator (I/O): See 4.6. (line 4422)
-right angle bracket (>), >= operator <1>: See 5.14. (line 6137)
-right angle bracket (>), >= operator: See 5.10. (line 5786)
-right angle bracket (>), >> operator (I/O) <1>:See 5.14. (line 6137)
-right angle bracket (>), >> operator (I/O): See 4.6. (line 4450)
-right shift, bitwise: See 8.1.6. (line 9527)
-Ritchie, Dennis: See D.2. (line 18270)
-RLENGTH variable: See 6.5.2. (line 7428)
-RLENGTH variable, match function and: See 8.1.3. (line 8475)
-Robbins, Arnold <1>: See C.4. (line 17998)
-Robbins, Arnold <2>: See B.5. (line 17034)
-Robbins, Arnold <3>: See A.6. (line 15970)
-Robbins, Arnold <4>: See 13.3.2. (line 14360)
-Robbins, Arnold <5>: See 12.5. (line 12765)
-Robbins, Arnold <6>: See 3.8.5. (line 3715)
-Robbins, Arnold: See 3.5.3. (line 3177)
-Robbins, Bill: See 3.8.5. (line 3715)
-Robbins, Harry:
- See ``Acknowledgments''. (line 859)
-Robbins, Jean:
- See ``Acknowledgments''. (line 859)
-Robbins, Miriam <1>: See 12.5. (line 12765)
-Robbins, Miriam <2>: See 3.8.5. (line 3715)
-Robbins, Miriam:
- See ``Acknowledgments''. (line 859)
-Robinson, Will: See C.3. (line 17422)
-robot, the: See C.3. (line 17422)
-Rommel, Kai Uwe <1>: See A.6. (line 15921)
-Rommel, Kai Uwe:
- See ``Acknowledgments''. (line 842)
-round user-defined function: See 12.2.4. (line 11904)
-rounding: See 12.2.4. (line 11894)
-rounding numbers: See 12.2.4. (line 11894)
-RS variable <1>: See 6.5.1. (line 7233)
-RS variable: See 3.1. (line 2539)
-RS variable, multiline records and: See 3.7. (line 3384)
-rshift function (gawk): See 8.1.6. (line 9541)
-RSTART variable: See 6.5.2. (line 7434)
-RSTART variable, match function and: See 8.1.3. (line 8475)
-RT variable <1>: See 6.5.2. (line 7441)
-RT variable <2>: See 3.7. (line 3496)
-RT variable: See 3.1. (line 2631)
-Rubin, Paul <1>: See A.6. (line 15895)
-Rubin, Paul:
- See ``History of awk and gawk''. (line 516)
-rule, definition of: See 1. (line 891)
-rvalues/lvalues: See 5.7. (line 5473)
-scalar values: See D.2. (line 18212)
-Schreiber, Bert:
- See ``Acknowledgments''. (line 824)
-Schreiber, Rita:
- See ``Acknowledgments''. (line 824)
-search paths <1>: See B.3.4.3. (line 16827)
-search paths: See B.3.3.4. (line 16604)
-search paths, for source files <1>: See B.3.4.3. (line 16827)
-search paths, for source files <2>: See 13.3.9. (line 15469)
-search paths, for source files: See 11.4. (line 11411)
-searching: See 8.1.3. (line 8429)
-searching, files for regular expressions: See 13.2.2. (line 13445)
-searching, for words: See 13.3.1. (line 14315)
-sed utility <1>:
- See ``Glossary''. (line 18397)
-sed utility <2>: See 13.3.8. (line 15040)
-sed utility: See 3.5.4. (line 3228)
-semicolon (;): See 1.6. (line 1637)
-semicolon (;), AWKPATH variable and: See B.3.3.4. (line 16604)
-semicolon (;), separating statements in actions <1>:See 6.4.
- (line 6596)
-semicolon (;), separating statements in actions:See 6.3. (line 6549)
-separators, field: See 6.5.1. (line 7157)
-separators, field, FIELDWIDTHS variable and: See 6.5.1. (line 7147)
-separators, field, POSIX and: See 3.2. (line 2713)
-separators, for records: See 3.1. (line 2533)
-separators, for records, regular expressions as:See 3.1. (line 2631)
-separators, for statements in actions: See 6.3. (line 6549)
-separators, record: See 6.5.1. (line 7233)
-separators, subscript: See 6.5.1. (line 7246)
-set_value internal function: See C.3.1. (line 17580)
-shells, piping commands into: See 4.6. (line 4539)
-shells, quoting: See 6.2. (line 6494)
-shells, quoting, rules for: See 1.1.6. (line 1154)
-shells, scripts: See 1.1.1. (line 942)
-shells, variables: See 6.2. (line 6488)
-shift, bitwise: See 8.1.6. (line 9527)
-short-circuit operators: See 5.11. (line 5947)
-side effects <1>: See 5.8. (line 5614)
-side effects: See 5.6. (line 5404)
-side effects, array indexing: See 7.2. (line 7710)
-side effects, asort function: See 7.11. (line 8141)
-side effects, assignment expressions: See 5.7. (line 5464)
-side effects, Boolean operators: See 5.11. (line 5920)
-side effects, conditional expressions: See 5.12. (line 6000)
-side effects, decrement/increment operators: See 5.8. (line 5614)
-side effects, FILENAME variable: See 3.8.9. (line 3820)
-side effects, function calls: See 5.13. (line 6064)
-side effects, statements: See 6.3. (line 6562)
-signals, HUP/SIGHUP: See 10.5. (line 11038)
-signals, INT/SIGINT (MS-DOS): See 10.5. (line 11041)
-signals, QUIT/SIGQUIT (MS-DOS): See 10.5. (line 11041)
-signals, USR1/SIGUSR1: See 10.5. (line 11016)
-sin function: See 8.1.2. (line 8296)
-single quote (') <1>: See 1.1.6. (line 1167)
-single quote (') <2>: See 1.1.3. (line 1027)
-single quote ('): See 1.1.1. (line 935)
-single quote ('), vs. apostrophe: See 1.1.5. (line 1116)
-single quote ('), with double quotes: See 1.1.6. (line 1189)
-single-character fields: See 3.5.2. (line 3080)
-single-precision floating-point: See D.2. (line 18232)
-Skywalker, Luke: See 11.6. (line 11488)
-sleep utility: See 13.3.2. (line 14456)
-sockets: See 10.3. (line 10782)
-sort function, arrays, sorting: See 7.11. (line 8122)
-sort utility: See 13.3.5. (line 14753)
-sort utility, coprocesses and: See 10.2. (line 10702)
-sorting characters in different languages: See 9.2. (line 10145)
-source code, awka: See B.6. (line 17148)
-source code, Bell Laboratories awk: See B.6. (line 17085)
-source code, gawk: See B.1. (line 15986)
-source code, mawk: See B.6. (line 17105)
-source code, mixing: See 11.2. (line 11283)
-source files, search path for: See 13.3.9. (line 15469)
-sparse arrays: See 7.1. (line 7653)
-Spencer, Henry:
- See ``Glossary''. (line 18397)
-split function: See 8.1.3. (line 8546)
-split function, array elements, deleting: See 7.6. (line 7896)
-split utility: See 13.2.4. (line 13776)
-split.awk program: See 13.2.4. (line 13800)
-sprintf function <1>: See 8.1.3. (line 8599)
-sprintf function: See 4.4. (line 4026)
-sprintf function, OFMT variable and: See 6.5.1. (line 7223)
-sprintf function, print/printf statements and: See 12.2.4. (line 11894)
-sqrt function: See 8.1.2. (line 8283)
-square brackets ([]): See 2.3. (line 1984)
-srand function: See 8.1.2. (line 8345)
-Stallman, Richard <1>:
- See ``Glossary''. (line 18669)
-Stallman, Richard <2>: See A.6. (line 15903)
-Stallman, Richard <3>:
- See ``Acknowledgments''. (line 807)
-Stallman, Richard:
- See ``The GNU Project and This Book''. (line 717)
-standard input <1>: See 4.7.1. (line 4564)
-standard input: See 1.1.2. (line 952)
-standard output: See 4.7.1. (line 4564)
-stat function, implementing in gawk: See C.3.2. (line 17645)
-statements, compound, control statements and: See 6.4. (line 6596)
-statements, control, in actions: See 6.4. (line 6592)
-statements, multiple: See 1.6. (line 1637)
-stlen internal variable: See C.3.1. (line 17484)
-stptr internal variable: See C.3.1. (line 17484)
-stream editors <1>: See 13.3.8. (line 15040)
-stream editors: See 3.5.4. (line 3228)
-strftime function (gawk): See 8.1.5. (line 9224)
-string constants: See 5.1.1. (line 4929)
-string constants, vs. regexp constants: See 2.8. (line 2416)
-string extraction (internationalization): See 9.4.1. (line 10303)
-string operators: See 5.6. (line 5372)
-string-matching operators: See 2.1. (line 1749)
-strings: See C.3.1. (line 17511)
-strings, converting: See 5.4. (line 5186)
-strings, converting, numbers to <1>: See 8.1.6. (line 9594)
-strings, converting, numbers to: See 6.5.1. (line 7140)
-strings, empty, See null strings: See 3.1. (line 2621)
-strings, extracting: See 9.4.1. (line 10303)
-strings, for localization: See 9.3. (line 10197)
-strings, length of: See 5.1.1. (line 4934)
-strings, merging arrays into: See 12.2.7. (line 12052)
-strings, NODE internal type: See C.3.1. (line 17457)
-strings, null: See 3.5.1. (line 3061)
-strings, numeric: See 5.10. (line 5724)
-strings, splitting: See 8.1.3. (line 8560)
-strtonum function (gawk): See 8.1.3. (line 8607)
-strtonum function (gawk), --non-decimal-data option and:See 10.1.
- (line 10615)
-sub function <1>: See 8.1.3. (line 8625)
-sub function: See 5.2. (line 5068)
-sub function, arguments of: See 8.1.3. (line 8682)
-sub function, escape processing: See 8.1.3.1. (line 8838)
-subscript separators: See 6.5.1. (line 7246)
-subscripts in arrays, multidimensional: See 7.9. (line 8006)
-subscripts in arrays, multidimensional, scanning:See 7.10. (line 8090)
-subscripts in arrays, numbers as: See 7.7. (line 7914)
-subscripts in arrays, uninitialized variables as:See 7.8. (line 7962)
-SUBSEP variable: See 6.5.1. (line 7246)
-SUBSEP variable, multidimensional arrays: See 7.9. (line 8012)
-substr function: See 8.1.3. (line 8769)
-Sumner, Andrew: See B.6. (line 17148)
-switch statement: See 6.4.5. (line 6800)
-syntactic ambiguity: /= operator vs. /=.../ regexp constant:See 5.7.
- (line 5589)
-system function: See 8.1.4. (line 9065)
-systime function (gawk): See 8.1.5. (line 9195)
-tandem: See B.4.2. (line 16977)
-Tcl: See 12.1. (line 11616)
-TCP/IP: See 10.3. (line 10758)
-TCP/IP, support for: See 4.7.3. (line 4684)
-tee utility: See 13.2.5. (line 13876)
-tee.awk program: See 13.2.5. (line 13896)
-terminating records: See 3.1. (line 2631)
-testbits.awk program: See 8.1.6. (line 9555)
-Texinfo <1>: See C.2.1. (line 17307)
-Texinfo <2>: See B.1.3. (line 16112)
-Texinfo <3>: See 13.3.7. (line 14857)
-Texinfo <4>: See 13.3.1. (line 14326)
-Texinfo <5>: See 12. (line 11524)
-Texinfo <6>: See 1.2. (line 1316)
-Texinfo:
- See ``Typographical Conventions''. (line 674)
-Texinfo, chapter beginnings in files: See 2.3. (line 1951)
-Texinfo, extracting programs from source files:See 13.3.7. (line 14851)
-text, printing: See 4.1. (line 3891)
-text, printing, unduplicated lines of: See 13.2.6. (line 13957)
-textdomain function (C library): See 9.2. (line 10083)
-TEXTDOMAIN variable <1>: See 9.3. (line 10192)
-TEXTDOMAIN variable: See 6.5.1. (line 7252)
-TEXTDOMAIN variable, BEGIN pattern and: See 9.3. (line 10241)
-TEXTDOMAIN variable, portability and: See 9.4.3. (line 10414)
-tilde (~), ~ operator <1>: See 6.1.2. (line 6248)
-tilde (~), ~ operator <2>: See 5.14. (line 6153)
-tilde (~), ~ operator <3>: See 5.10. (line 5786)
-tilde (~), ~ operator <4>: See 5.1.3. (line 5021)
-tilde (~), ~ operator <5>: See 2.8. (line 2384)
-tilde (~), ~ operator <6>: See 2.6. (line 2302)
-tilde (~), ~ operator: See 2.1. (line 1749)
-time, alarm clock example program: See 13.3.2. (line 14363)
-time, localization and: See 9.2. (line 10167)
-time, managing: See 12.2.8. (line 12095)
-time, retrieving: See 8.1.5. (line 9188)
-timestamps: See 8.1.5. (line 9177)
-timestamps, converting dates to: See 8.1.5. (line 9240)
-timestamps, formatted: See 12.2.8. (line 12095)
-tmp_number internal function: See C.3.1. (line 17526)
-tmp_string internal function: See C.3.1. (line 17521)
-tolower function: See 8.1.3. (line 8811)
-toupper function: See 8.1.3. (line 8817)
-tr utility: See 13.3.3. (line 14483)
-translate.awk program: See 13.3.3. (line 14532)
-troubleshooting, --non-decimal-data option: See 11.2. (line 11226)
-troubleshooting, -F option: See 11.7. (line 11496)
-troubleshooting, == operator: See 5.10. (line 5812)
-troubleshooting, awk uses FS not IFS: See 3.5. (line 2969)
-troubleshooting, backslash before nonspecial character:See 2.2.
- (line 1902)
-troubleshooting, division: See 5.5. (line 5325)
-troubleshooting, fatal errors, field widths, specifying:See 3.6.
- (line 3288)
-troubleshooting, fatal errors, printf format strings:See 4.5.3.
- (line 4331)
-troubleshooting, fflush function: See 8.1.4. (line 9053)
-troubleshooting, function call syntax: See 5.13. (line 6043)
-troubleshooting, gawk <1>: See C.1. (line 17183)
-troubleshooting, gawk: See 11.7. (line 11496)
-troubleshooting, gawk, bug reports: See B.5. (line 17014)
-troubleshooting, gawk, fatal errors, function arguments:See 8.1.1.
- (line 8240)
-troubleshooting, getline function: See 12.3.3. (line 12315)
-troubleshooting, gsub/sub functions: See 8.1.3. (line 8692)
-troubleshooting, match function: See 8.1.3. (line 8541)
-troubleshooting, print statement, omitting commas:See 4.2. (line 3927)
-troubleshooting, printing: See 4.6. (line 4517)
-troubleshooting, quotes with file names: See 4.7.1. (line 4621)
-troubleshooting, readable data files: See 12.3.3. (line 12297)
-troubleshooting, regexp constants vs. string constants:See 2.8.
- (line 2416)
-troubleshooting, string concatenation: See 5.6. (line 5390)
-troubleshooting, substr function: See 8.1.3. (line 8787)
-troubleshooting, system function: See 8.1.4. (line 9089)
-troubleshooting, typographical errors, global variables:See 11.2.
- (line 11182)
-true, logical: See 5.9. (line 5692)
-Trueman, David <1>: See A.6. (line 15910)
-Trueman, David <2>:
- See ``Acknowledgments''. (line 833)
-Trueman, David:
- See ``History of awk and gawk''. (line 516)
-trunc-mod operation: See 5.5. (line 5347)
-truth values: See 5.9. (line 5692)
-type conversion: See 5.4. (line 5201)
-type internal variable: See C.3.1. (line 17492)
-undefined functions: See 8.2.3. (line 9903)
-underscore (_), _ C macro: See 9.2. (line 10124)
-underscore (_), in names of private variables: See 12.1. (line 11588)
-underscore (_), translatable string: See 9.3. (line 10250)
-undocumented features: See 11.6. (line 11488)
-uninitialized variables, as array subscripts: See 7.8. (line 7962)
-uniq utility: See 13.2.6. (line 13957)
-uniq.awk program: See 13.2.6. (line 14016)
-Unix:
- See ``Glossary''. (line 18964)
-Unix awk, backslashes in escape sequences: See 2.2. (line 1914)
-Unix awk, close function and: See 4.8. (line 4856)
-Unix awk, password files, field separators and:See 3.5.3. (line 3169)
-Unix, awk scripts and: See 1.1.4. (line 1035)
-unsigned integers: See D.2. (line 18227)
-update_ERRNO internal function: See C.3.1. (line 17586)
-user database, reading: See 12.5. (line 12695)
-user-defined, functions: See 8.2. (line 9653)
-user-defined, functions, counts: See 10.5. (line 10963)
-user-defined, variables: See 5.3. (line 5104)
-user-modifiable variables: See 6.5.1. (line 7120)
-users, information about, printing: See 13.2.3. (line 13672)
-users, information about, retrieving: See 12.5. (line 12705)
-USR1 signal: See 10.5. (line 11016)
-values, numeric: See D.2. (line 18212)
-values, string: See D.2. (line 18212)
-variable typing: See 5.10. (line 5720)
-variables <1>: See D.2. (line 18205)
-variables: See 1.7. (line 1660)
-variables, assigning on command line: See 5.3.2. (line 5141)
-variables, built-in <1>: See 6.5. (line 7105)
-variables, built-in: See 5.3.1. (line 5123)
-variables, built-in, -v option, setting with: See 11.2. (line 11119)
-variables, built-in, conveying information: See 6.5.2. (line 7271)
-variables, flag: See 5.11. (line 5957)
-variables, getline command into, using <1>: See 3.8.8. (line 3792)
-variables, getline command into, using <2>: See 3.8.6. (line 3741)
-variables, getline command into, using <3>: See 3.8.4. (line 3649)
-variables, getline command into, using: See 3.8.2. (line 3581)
-variables, global, for library functions: See 12.1. (line 11570)
-variables, global, printing list of: See 11.2. (line 11176)
-variables, initializing: See 5.3.1. (line 5123)
-variables, names of: See 7. (line 7585)
-variables, private: See 12.1. (line 11570)
-variables, setting: See 11.2. (line 11111)
-variables, shadowing: See 8.2.1. (line 9711)
-variables, types of: See 5.7. (line 5481)
-variables, types of, comparison expressions and:See 5.10. (line 5720)
-variables, uninitialized, as array subscripts: See 7.8. (line 7962)
-variables, user-defined: See 5.3. (line 5104)
-vertical bar (|): See 2.3. (line 1997)
-vertical bar (|), | operator (I/O) <1>: See 5.14. (line 6137)
-vertical bar (|), | operator (I/O): See 3.8.5. (line 3685)
-vertical bar (|), |& I/O operator (I/O): See 10.2. (line 10662)
-vertical bar (|), |& operator (I/O) <1>: See 5.14. (line 6137)
-vertical bar (|), |& operator (I/O): See 3.8.7. (line 3765)
-vertical bar (|), |& operator (I/O), two-way communications:See 10.4.
- (line 10826)
-vertical bar (|), || operator <1>: See 5.14. (line 6162)
-vertical bar (|), || operator: See 5.11. (line 5947)
-vname internal variable: See C.3.1. (line 17496)
-w utility: See 3.6. (line 3288)
-Wall, Larry: See C.4. (line 17998)
-warnings, issuing: See 11.2. (line 11206)
-wc utility: See 13.2.7. (line 14171)
-wc.awk program: See 13.2.7. (line 14210)
-Weinberger, Peter <1>: See A.6. (line 15891)
-Weinberger, Peter:
- See ``History of awk and gawk''. (line 503)
-while statement <1>: See 6.4.2. (line 6643)
-while statement: See 2.1. (line 1749)
-whitespace, as field separators: See 3.5. (line 3004)
-whitespace, functions, calling: See 8.1.1. (line 8234)
-whitespace, newlines as: See 11.2. (line 11238)
-Williams, Kent: See A.6. (line 15916)
-Woods, John: See A.6. (line 15907)
-word boundaries, matching: See 2.5. (line 2221)
-word, regexp definition of: See 2.5. (line 2197)
-word-boundary operator (gawk): See 2.5. (line 2246)
-wordfreq.awk program: See 13.3.5. (line 14759)
-words, counting: See 13.2.7. (line 14171)
-words, duplicate, searching for: See 13.3.1. (line 14315)
-words, usage counts, generating: See 13.3.5. (line 14705)
-xgettext utility: See 9.4.1. (line 10310)
-XOR bitwise operation: See 8.1.6. (line 9501)
-xor function (gawk): See 8.1.6. (line 9536)
-Zaretskii, Eli:
- See ``Acknowledgments''. (line 842)
-zero, negative vs. positive: See D.3. (line 18361)
-zerofile.awk program: See 12.3.4. (line 12337)
-Zoulas, Christos: See A.6. (line 15940)
-{} (braces), actions and: See 6.3. (line 6549)
-{} (braces), pgawk program: See 10.5. (line 10968)
-{} (braces), statements, grouping: See 6.4. (line 6596)
-| (vertical bar): See 2.3. (line 1997)
-| (vertical bar), | operator (I/O) <1>: See 5.14. (line 6137)
-| (vertical bar), | operator (I/O) <2>: See 4.6. (line 4457)
-| (vertical bar), | operator (I/O): See 3.8.5. (line 3685)
-| (vertical bar), |& operator (I/O) <1>: See 10.2. (line 10662)
-| (vertical bar), |& operator (I/O) <2>: See 5.14. (line 6137)
-| (vertical bar), |& operator (I/O) <3>: See 4.6. (line 4502)
-| (vertical bar), |& operator (I/O): See 3.8.7. (line 3765)
-| (vertical bar), |& operator (I/O), pipes, closing:See 4.8.
- (line 4843)
-| (vertical bar), |& operator (I/O), two-way communications:See 10.4.
- (line 10826)
-| (vertical bar), || operator <1>: See 5.14. (line 6162)
-| (vertical bar), || operator: See 5.11. (line 5947)
-~ (tilde), ~ operator <1>: See 6.1.2. (line 6248)
-~ (tilde), ~ operator <2>: See 5.14. (line 6153)
-~ (tilde), ~ operator <3>: See 5.10. (line 5786)
-~ (tilde), ~ operator <4>: See 5.1.3. (line 5021)
-~ (tilde), ~ operator <5>: See 2.8. (line 2384)
-~ (tilde), ~ operator: See 2.6. (line 2302)
Index: manual/gawk.txt.gz
===================================================================
RCS file: manual/gawk.txt.gz
diff -N manual/gawk.txt.gz
Binary files /tmp/cvs7WuC9Y and /dev/null differ
Index: manual/index.html
===================================================================
RCS file: manual/index.html
diff -N manual/index.html
--- manual/index.html 13 Oct 2006 19:23:50 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<!-- $Id: index.html,v 1.2 2006/10/13 19:23:50 johnsu01 Exp $ -->
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-
-<head>
-<title>Gawk: Effective AWK Programming - GNU Project - Free Software
Foundation (FSF)</title>
-<meta http-equiv="content-type" content='text/html; charset=utf-8' />
-<link rel="stylesheet" type="text/css" href="/gnu.css" />
-<link rev="made" href="address@hidden" />
-</head>
-
-<!-- This document is in XML, and xhtml 1.0 -->
-<!-- Please make sure to properly nest your tags -->
-<!-- and ensure that your final document validates -->
-<!-- consistent with W3C xhtml 1.0 and CSS standards -->
-<!-- See validator.w3.org -->
-
-<body>
-
-<h3>Gawk: Effective AWK Programming</h3>
-
-<address>Free Software Foundation</address>
-<address>last updated August 31, 2004</address>
-<p>
-<a href="/graphics/gnu-head.jpg">
- <img src="/graphics/gnu-head-sm.jpg"
- alt=" [image of the head of a GNU] "
- width="129" height="122" />
-</a>
-
-</p>
-<hr />
-
-<p>This manual (for gawk) is available in the following formats:</p>
-
-<ul>
- <li><a href="gawk.html">HTML
- (1740K characters)</a> - entirely on one web page.</li>
- <li><a href="html_node/index.html">HTML</a> - with one web page per
- node.</li>
- <li><a href="gawk.html.gz">HTML compressed
- (384K gzipped characters)</a> - entirely on
- one web page.</li>
- <li><a href="gawk.html_node.tar.gz">HTML compressed
- (464K gzipped tar file)</a> -
- with one web page per node.</li>
- <li><a href="gawk.info.tar.gz">Info document
- (296K characters gzipped tar file)</a>.</li>
- <li><a href="gawk.txt">ASCII text
- (944K characters)</a>.</li>
- <li><a href="gawk.txt.gz">ASCII text compressed
- (280K gzipped characters)</a>.</li>
- <li><a href="gawk.dvi.gz">TeX dvi file
- (432K characters gzipped)</a>.</li>
- <li><a href="gawk.ps.gz">PostScript file
- (1112K characters gzipped)</a>.</li>
- <li><a href="gawk.pdf">PDF file
- (2116K characters)</a>.</li>
- <li><a href="gawk.texi.tar.gz">Texinfo source
- (380K characters gzipped tar file)</a></li>
-</ul>
-
-<p>(This page generated by the <a
-href="http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs.sh">gendocs.sh</a>
script.)
-</p>
-
-<div class="copyright">
-<p>
-Return to the <a href="/home.html">GNU Project home page</a>.
-</p>
-
-<p>
-Please send FSF & GNU inquiries to
-<a href="mailto:address@hidden"><em>address@hidden</em></a>.
-There are also <a href="/home.html#ContactInfo">other ways to contact</a>
-the FSF.
-<br />
-Please send broken links and other corrections (or suggestions) to
-<a href="mailto:address@hidden"><em>address@hidden</em></a>.
-</p>
-
-<p>
-Copyright (C) 2004 Free Software Foundation, Inc.,
-59 Temple Place - Suite 330, Boston, MA 02111, USA
-<br />
-Verbatim copying and distribution of this entire article is
-permitted in any medium, provided this notice is preserved.
-</p>
-
-<p>
-Updated:
-<!-- timestamp start -->
-$Date: 2006/10/13 19:23:50 $ $Author: johnsu01 $
-<!-- timestamp end -->
-</p>
-</div>
-
-</body>
-</html>
Index: manual/gawkinet/gawkinet.dvi.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.dvi.gz
diff -N manual/gawkinet/gawkinet.dvi.gz
Binary files /tmp/cvs9eEud3 and /dev/null differ
Index: manual/gawkinet/gawkinet.html
===================================================================
RCS file: manual/gawkinet/gawkinet.html
diff -N manual/gawkinet/gawkinet.html
--- manual/gawkinet/gawkinet.html 29 Jun 2005 21:04:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,4733 +0,0 @@
-<html lang="en">
-<head>
-<title>TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="top" href="#Top">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<h1 class="settitle">TCP/IP Internetworking With `gawk'</h1>
-<div class="node">
-<p><hr>
-<a name="Top"></a>Next: <a rel="next" accesskey="n"
href="#Preface">Preface</a>,
-Previous: <a rel="previous" accesskey="p" href="#dir">(dir)</a>,
-Up: <a rel="up" accesskey="u" href="#dir">(dir)</a>
-<br>
-</div>
-
-<h2 class="unnumbered">General Introduction</h2>
-
-<!-- node-name, next, previous, up -->
-<p>This file documents the networking features in GNU Awk (<samp><span
class="command">gawk</span></samp>)
-version 3.1 and later.
-
- <p>This is Edition 1.1 of <cite>TCP/IP Internetworking With
<samp></cite><span class="command">gawk</span><cite></samp></cite>,
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
- <pre class="sp">
-
-
-</pre>
-Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
- <pre class="sp">
-
-
-</pre>
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being “GNU General Public License”, the
Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-“GNU Free Documentation License”.
-
- <ol type=a start=1>
-<li>“A GNU Manual”
-
- <li>“You have freedom to copy and modify this GNU Manual, like GNU
-software. Copies published by the Free Software Foundation raise
-funds for GNU development.”
- </ol>
-
-<ul class="menu">
-<li><a accesskey="1" href="#Preface">Preface</a>:
About this document.
-<li><a accesskey="2" href="#Introduction">Introduction</a>:
About networkiing.
-<li><a accesskey="3" href="#Using-Networking">Using Networking</a>:
Some examples.
-<li><a accesskey="4" href="#Some-Applications-and-Techniques">Some
Applications and Techniques</a>: More extended examples.
-<li><a accesskey="5" href="#Links">Links</a>:
Where to find the stuff mentioned in this
- document.
-<li><a accesskey="6" href="#GNU-Free-Documentation-License">GNU Free
Documentation License</a>: The license for this document.
-<li><a accesskey="7" href="#Index">Index</a>: The
index.
-
-<li><a accesskey="8" href="#Stream-Communications">Stream Communications</a>:
Sending data streams.
-<li><a accesskey="9" href="#Datagram-Communications">Datagram
Communications</a>: Sending self-contained messages.
-<li><a href="#The-TCP_002fIP-Protocols">The TCP/IP Protocols</a>:
How these models work in the Internet.
-<li><a href="#Basic-Protocols">Basic Protocols</a>: The basic
protocols.
-<li><a href="#Ports">Ports</a>: The idea behind
ports.
-<li><a href="#Making-Connections">Making Connections</a>: Making
TCP/IP connections.
-<li><a href="#Gawk-Special-Files">Gawk Special Files</a>: How to
do <samp><span class="command">gawk</span></samp> networking.
-<li><a href="#Special-File-Fields">Special File Fields</a>: The
fields in the special file name.
-<li><a href="#Comparing-Protocols">Comparing Protocols</a>:
Differences between the protocols.
-<li><a href="#File-_002finet_002ftcp">File /inet/tcp</a>: The
TCP special file.
-<li><a href="#File-_002finet_002fudp">File /inet/udp</a>: The
UDP special file.
-<li><a href="#File-_002finet_002fraw">File /inet/raw</a>: The
RAW special file.
-<li><a href="#TCP-Connecting">TCP Connecting</a>: Making a
TCP connection.
-<li><a href="#Troubleshooting">Troubleshooting</a>:
Troubleshooting TCP/IP connections.
-<li><a href="#Interacting">Interacting</a>: Interacting
with a service.
-<li><a href="#Setting-Up">Setting Up</a>: Setting up a
service.
-<li><a href="#Email">Email</a>: Reading email.
-<li><a href="#Web-page">Web page</a>: Reading a Web
page.
-<li><a href="#Primitive-Service">Primitive Service</a>: A
primitive Web service.
-<li><a href="#Interacting-Service">Interacting Service</a>: A Web
service with interaction.
-<li><a href="#CGI-Lib">CGI Lib</a>: A simple CGI
library.
-<li><a href="#Simple-Server">Simple Server</a>: A simple Web
server.
-<li><a href="#Caveats">Caveats</a>: Network
programming caveats.
-<li><a href="#Challenges">Challenges</a>: Where to go
from here.
-<li><a href="#PANIC">PANIC</a>: An Emergency Web
Server.
-<li><a href="#GETURL">GETURL</a>: Retrieving Web
Pages.
-<li><a href="#REMCONF">REMCONF</a>: Remote
Configuration Of Embedded Systems.
-<li><a href="#URLCHK">URLCHK</a>: Look For Changed
Web Pages.
-<li><a href="#WEBGRAB">WEBGRAB</a>: Extract Links From
A Page.
-<li><a href="#STATIST">STATIST</a>: Graphing A
Statistical Distribution.
-<li><a href="#MAZE">MAZE</a>: Walking Through A
Maze In Virtual Reality.
-<li><a href="#MOBAGWHO">MOBAGWHO</a>: A Simple Mobile
Agent.
-<li><a href="#STOXPRED">STOXPRED</a>: Stock Market
Prediction As A Service.
-<li><a href="#PROTBASE">PROTBASE</a>: Searching Through
A Protein Database.
-</ul>
-
- <div class="contents">
-<h2>Table of Contents</h2>
-<ul>
-<li><a name="toc_Top" href="#Top">General Introduction</a>
-<li><a name="toc_Preface" href="#Preface">Preface</a>
-<li><a name="toc_Introduction" href="#Introduction">1 Networking Concepts</a>
-<ul>
-<li><a href="#Stream-Communications">1.1 Reliable Byte-streams (Phone
Calls)</a>
-<li><a href="#Datagram-Communications">1.2 Best-effort Datagrams (Mailed
Letters)</a>
-<li><a href="#The-TCP_002fIP-Protocols">1.3 The Internet Protocols</a>
-<ul>
-<li><a href="#Basic-Protocols">1.3.1 The Basic Internet Protocols</a>
-<li><a href="#Ports">1.3.2 TCP and UDP Ports</a>
-</li></ul>
-<li><a href="#Making-Connections">1.4 Making TCP/IP Connections (And Some
Terminology)</a>
-</li></ul>
-<li><a name="toc_Using-Networking" href="#Using-Networking">2 Networking With
<samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="#Gawk-Special-Files">2.1 <samp><span
class="command">gawk</span></samp>'s Networking Mechanisms</a>
-<ul>
-<li><a href="#Special-File-Fields">2.1.1 The Fields of the Special File
Name</a>
-<li><a href="#Comparing-Protocols">2.1.2 Comparing Protocols</a>
-<ul>
-<li><a href="#File-_002finet_002ftcp">2.1.2.1 <samp><span
class="file">/inet/tcp</span></samp></a>
-<li><a href="#File-_002finet_002fudp">2.1.2.2 <samp><span
class="file">/inet/udp</span></samp></a>
-<li><a href="#File-_002finet_002fraw">2.1.2.3 <samp><span
class="file">/inet/raw</span></samp></a>
-</li></ul>
-</li></ul>
-<li><a href="#TCP-Connecting">2.2 Establishing a TCP Connection</a>
-<li><a href="#Troubleshooting">2.3 Troubleshooting Connection Problems</a>
-<li><a href="#Interacting">2.4 Interacting with a Network Service</a>
-<li><a href="#Setting-Up">2.5 Setting Up a Service</a>
-<li><a href="#Email">2.6 Reading Email</a>
-<li><a href="#Web-page">2.7 Reading a Web Page</a>
-<li><a href="#Primitive-Service">2.8 A Primitive Web Service</a>
-<li><a href="#Interacting-Service">2.9 A Web Service with Interaction</a>
-<ul>
-<li><a href="#CGI-Lib">2.9.1 A Simple CGI Library</a>
-</li></ul>
-<li><a href="#Simple-Server">2.10 A Simple Web Server</a>
-<li><a href="#Caveats">2.11 Network Programming Caveats</a>
-<li><a href="#Challenges">2.12 Where To Go From Here</a>
-</li></ul>
-<li><a name="toc_Some-Applications-and-Techniques"
href="#Some-Applications-and-Techniques">3 Some Applications and Techniques</a>
-<ul>
-<li><a href="#PANIC">3.1 PANIC: An Emergency Web Server</a>
-<li><a href="#GETURL">3.2 GETURL: Retrieving Web Pages</a>
-<li><a href="#REMCONF">3.3 REMCONF: Remote Configuration of Embedded
Systems</a>
-<li><a href="#URLCHK">3.4 URLCHK: Look for Changed Web Pages</a>
-<li><a href="#WEBGRAB">3.5 WEBGRAB: Extract Links from a Page</a>
-<li><a href="#STATIST">3.6 STATIST: Graphing a Statistical Distribution</a>
-<li><a href="#MAZE">3.7 MAZE: Walking Through a Maze In Virtual Reality</a>
-<li><a href="#MOBAGWHO">3.8 MOBAGWHO: a Simple Mobile Agent</a>
-<li><a href="#STOXPRED">3.9 STOXPRED: Stock Market Prediction As A Service</a>
-<li><a href="#PROTBASE">3.10 PROTBASE: Searching Through A Protein Database</a>
-</li></ul>
-<li><a name="toc_Links" href="#Links">4 Related Links</a>
-<li><a name="toc_GNU-Free-Documentation-License"
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>
-<ul>
-<li><a href="#GNU-Free-Documentation-License">ADDENDUM: How to use this
License for your documents</a>
-</li></ul>
-<li><a name="toc_Index" href="#Index">Index</a>
-</li></ul>
-</div>
-
-<div class="node">
-<p><hr>
-<a name="Preface"></a>Next: <a rel="next" accesskey="n"
href="#Introduction">Introduction</a>,
-Previous: <a rel="previous" accesskey="p" href="#Top">Top</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">Preface</h2>
-
-<p>In May of 1997, Jürgen Kahrs felt the need for network access
-from <samp><span class="command">awk</span></samp>, and, with a little help
from me, set about adding
-features to do this for <samp><span class="command">gawk</span></samp>. At
that time, he
-wrote the bulk of this web page.
-
- <p>The code and documentation were added to the <samp><span
class="command">gawk</span></samp> 3.1 development
-tree, and languished somewhat until I could finally get
-down to some serious work on that version of <samp><span
class="command">gawk</span></samp>.
-This finally happened in the middle of 2000.
-
- <p>Meantime, Jürgen wrote an article about the Internet special
-files and `<samp><span class="samp">|&</span></samp>' operator for
<cite>Linux Journal</cite>, and made a
-networking patch for the production versions of <samp><span
class="command">gawk</span></samp>
-available from his home page.
-In August of 2000 (for <samp><span class="command">gawk</span></samp> 3.0.6),
this patch
-also made it to the main GNU <samp><span class="command">ftp</span></samp>
distribution site.
-
- <p>For release with <samp><span class="command">gawk</span></samp>, I
edited Jürgen's prose
-for English grammar and style, as he is not a native English
-speaker. I also
-rearranged the material somewhat for what I felt was a better order of
-presentation, and (re)wrote some of the introductory material.
-
- <p>The majority of this document and the code are his work, and the
-high quality and interesting ideas speak for themselves. It is my
-hope that these features will be of significant value to the <samp><span
class="command">awk</span></samp>
-community.
-
- <pre class="sp">
-
-</pre>
-Arnold Robbins <br>
-Nof Ayalon, ISRAEL <br>
-March, 2001
-
-<div class="node">
-<p><hr>
-<a name="Introduction"></a>Next: <a rel="next" accesskey="n"
href="#Using-Networking">Using Networking</a>,
-Previous: <a rel="previous" accesskey="p" href="#Preface">Preface</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">1 Networking Concepts</h2>
-
-<p>This chapter provides a (necessarily) brief intoduction to
-computer networking concepts. For many applications of <samp><span
class="command">gawk</span></samp>
-to TCP/IP networking, we hope that this is enough. For more
-advanced tasks, you will need deeper background, and it may be necessary
-to switch to lower-level programming in C or C++.
-
- <p>There are two real-life models for the way computers send messages
-to each other over a network. While the analogies are not perfect,
-they are close enough to convey the major concepts.
-These two models are the phone system (reliable byte-stream communications),
-and the postal system (best-effort datagrams).
-
-<ul class="menu">
-<li><a accesskey="1" href="#Stream-Communications">Stream Communications</a>:
Sending data streams.
-<li><a accesskey="2" href="#Datagram-Communications">Datagram
Communications</a>: Sending self-contained messages.
-<li><a accesskey="3" href="#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>: How these models work in the Internet.
-<li><a accesskey="4" href="#Making-Connections">Making Connections</a>:
Making TCP/IP connections.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Stream-Communications"></a>Next: <a rel="next" accesskey="n"
href="#Datagram-Communications">Datagram Communications</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Introduction">Introduction</a>,
-Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a>
-<br>
-</div>
-
-<h3 class="section">1.1 Reliable Byte-streams (Phone Calls)</h3>
-
-<p>When you make a phone call, the following steps occur:
-
- <ol type=1 start=1>
-<li>You dial a number.
-
- <li>The phone system connects to the called party, telling
-them there is an incoming call. (Their phone rings.)
-
- <li>The other party answers the call, or, in the case of a
-computer network, refuses to answer the call.
-
- <li>Assuming the other party answers, the connection between
-you is now a <dfn>duplex</dfn> (two-way), <dfn>reliable</dfn> (no data lost),
-sequenced (data comes out in the order sent) data stream.
-
- <li>You and your friend may now talk freely, with the phone system
-moving the data (your voices) from one end to the other.
-From your point of view, you have a direct end-to-end
-connection with the person on the other end.
- </ol>
-
- <p>The same steps occur in a duplex reliable computer networking
connection.
-There is considerably more overhead in setting up the communications,
-but once it's done, data moves in both directions, reliably, in sequence.
-
-<div class="node">
-<p><hr>
-<a name="Datagram-Communications"></a>Next: <a rel="next" accesskey="n"
href="#The-TCP_002fIP-Protocols">The TCP/IP Protocols</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Stream-Communications">Stream Communications</a>,
-Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a>
-<br>
-</div>
-
-<h3 class="section">1.2 Best-effort Datagrams (Mailed Letters)</h3>
-
-<p>Suppose you mail three different documents to your office on the
-other side of the country on two different days. Doing so
-entails the following.
-
- <ol type=1 start=1>
-<li>Each document travels in its own envelope.
-
- <li>Each envelope contains both the sender and the
-recipient address.
-
- <li>Each envelope may travel a different route to its destination.
-
- <li>The envelopes may arrive in a different order from the one
-in which they were sent.
-
- <li>One or more may get lost in the mail.
-(Although, fortunately, this does not occur very often.)
-
- <li>In a computer network, one or more <dfn>packets</dfn>
-may also arrive multiple times. (This doesn't happen
-with the postal system!)
-
- </ol>
-
- <p>The important characteristics of datagram communications, like
-those of the postal system are thus:
-
- <ul>
-<li>Delivery is “best effort;” the data may never get there.
-
- <li>Each message is self-contained, including the source and
-destination addresses.
-
- <li>Delivery is <em>not</em> sequenced; packets may arrive out
-of order, and/or multiple times.
-
- <li>Unlike the phone system, overhead is considerably lower.
-It is not necessary to set up the call first.
-</ul>
-
- <p>The price the user pays for the lower overhead of datagram communications
-is exactly the lower reliability; it is often necessary for user-level
-protocols that use datagram communications to add their own reliability
-features on top of the basic communications.
-
-<div class="node">
-<p><hr>
-<a name="The-TCP_002fIP-Protocols"></a>Next: <a rel="next" accesskey="n"
href="#Making-Connections">Making Connections</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Datagram-Communications">Datagram Communications</a>,
-Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a>
-<br>
-</div>
-
-<h3 class="section">1.3 The Internet Protocols</h3>
-
-<p>The Internet Protocol Suite (usually referred to as just TCP/IP)<a
rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-consists of a number of different protocols at different levels or
“layers.”
-For our purposes, three protocols provide the fundamental communications
-mechanisms. All other defined protocols are referred to as user-level
-protocols (e.g., HTTP, used later in this web page).
-
-<ul class="menu">
-<li><a accesskey="1" href="#Basic-Protocols">Basic Protocols</a>:
The basic protocols.
-<li><a accesskey="2" href="#Ports">Ports</a>: The idea
behind ports.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Basic-Protocols"></a>Next: <a rel="next" accesskey="n"
href="#Ports">Ports</a>,
-Previous: <a rel="previous" accesskey="p"
href="#The-TCP_002fIP-Protocols">The TCP/IP Protocols</a>,
-Up: <a rel="up" accesskey="u" href="#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>
-<br>
-</div>
-
-<h4 class="subsection">1.3.1 The Basic Internet Protocols</h4>
-
- <dl>
-<dt>IP<dd>The Internet Protocol. This protocol is almost never used directly
by
-applications. It provides the basic packet delivery and routing infrastructure
-of the Internet. Much like the phone company's switching centers or the Post
-Office's trucks, it is not of much day-to-day interest to the regular user
-(or programmer).
-It happens to be a best effort datagram protocol.
-
- <br><dt>UDP<dd>The User Datagram Protocol. This is a best effort
datagram protocol.
-It provides a small amount of extra reliability over IP, and adds
-the notion of <dfn>ports</dfn>, described in <a href="#Ports">TCP and UDP
Ports</a>.
-
- <br><dt>TCP<dd>The Transmission Control Protocol. This is a duplex,
reliable, sequenced
-byte-stream protocol, again layered on top of IP, and also providing the
-notion of ports. This is the protocol that you will most likely use
-when using <samp><span class="command">gawk</span></samp> for network
programming.
-</dl>
-
- <p>All other user-level protocols use either TCP or UDP to do their basic
-communications. Examples are SMTP (Simple Mail Transfer Protocol),
-FTP (File Transfer Protocol), and HTTP (HyperText Transfer Protocol).
-<a name="index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-1"></a><a
name="index-FTP-_0028File-Transfer-Protocol_0029-2"></a><a
name="index-HTTP-_0028Hypertext-Transfer-Protocol_0029-3"></a>
-<div class="node">
-<p><hr>
-<a name="Ports"></a>Previous: <a rel="previous" accesskey="p"
href="#Basic-Protocols">Basic Protocols</a>,
-Up: <a rel="up" accesskey="u" href="#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>
-<br>
-</div>
-
-<h4 class="subsection">1.3.2 TCP and UDP Ports</h4>
-
-<p>In the postal system, the address on an envelope indicates a physical
-location, such as a residence or office building. But there may be
-more than one person at a location; thus you have to further quantify
-the recipient by putting a person or company name on the envelope.
-
- <p>In the phone system, one phone number may represent an entire company,
-in which case you need a person's extension number in order to
-reach that individual directly. Or, when you call a home, you have to
-say, “May I please speak to ...” before talking to the person
directly.
-
- <p>IP networking provides the concept of addressing. An IP address
represents
-a particular computer, but no more. In order to reach the mail service
-on a system, or the FTP or WWW service on a system, you must have some
-way to further specify which service you want. In the Internet Protocol suite,
-this is done with <dfn>port numbers</dfn>, which represent the services, much
-like an extension number used with a phone number.
-
- <p>Port numbers are 16-bit integers. Unix and Unix-like systems reserve
ports
-below 1024 for “well known” services, such as SMTP, FTP, and HTTP.
-Numbers 1024 and above may be used by any application, although there is no
-promise made that a particular port number is always available.
-
-<div class="node">
-<p><hr>
-<a name="Making-Connections"></a>Previous: <a rel="previous"
accesskey="p" href="#The-TCP_002fIP-Protocols">The TCP/IP Protocols</a>,
-Up: <a rel="up" accesskey="u" href="#Introduction">Introduction</a>
-<br>
-</div>
-
-<h3 class="section">1.4 Making TCP/IP Connections (And Some Terminology)</h3>
-
-<p>Two terms come up repeatedly when discussing networking:
-<dfn>client</dfn> and <dfn>server</dfn>. For now, we'll discuss these terms
-at the <dfn>connection level</dfn>, when first establishing connections
-between two processes on different systems over a network.
-(Once the connection is established, the higher level, or
-<dfn>application level</dfn> protocols,
-such as HTTP or FTP, determine who is the client and who is the
-server. Often, it turns out that the client and server are the
-same in both roles.)
-
- <p><a name="index-servers-4"></a>The <dfn>server</dfn> is the system
providing the service, such as the
-web server or email server. It is the <dfn>host</dfn> (system) which
-is <em>connected to</em> in a transaction.
-For this to work though, the server must be expecting connections.
-Much as there has to be someone at the office building to answer
-the phone<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>, the
-server process (usually) has to be started first and be waiting
-for a connection.
-
- <p><a name="index-clients-5"></a>The <dfn>client</dfn> is the system
requesting the service.
-It is the system <em>initiating the connection</em> in a transaction.
-(Just as when you pick up the phone to call an office or store.)
-
- <p>In the TCP/IP framework, each end of a connection is represented by a
pair
-of (<var>address</var>, <var>port</var>) pairs. For the duration of the
connection,
-the ports in use at each end are unique, and cannot be used simultaneously
-by other processes on the same system. (Only after closing a connection
-can a new one be built up on the same port. This is contrary to the usual
-behavior of fully developed web servers which have to avoid situations
-in which they are not reachable. We have to pay this price in order to
-enjoy the benefits of a simple communication paradigm in <samp><span
class="command">gawk</span></samp>.)
-
- <p><a name="index-blocking-6"></a><a
name="index-synchronous-communications-7"></a>Furthermore, once the connection
is established, communications are
-<dfn>synchronous</dfn>.<a rel="footnote" href="#fn-3"
name="fnd-3"><sup>3</sup></a> I.e.,
-each end waits on the other to finish transmitting, before replying. This
-is much like two people in a phone conversation. While both could talk
-simultaneously, doing so usually doesn't work too well.
-
- <p>In the case of TCP, the synchronicity is enforced by the protocol when
-sending data. Data writes <dfn>block</dfn> until the data have been received
on the
-other end. For both TCP and UDP, data reads block until there is incoming
-data waiting to be read. This is summarized in the following table,
-where an “X” indicates that the given action blocks.
-
- <p><table summary=""><tr align="left"><td valign="top">TCP </td><td
valign="top">X </td><td valign="top">X
-<br></td></tr><tr align="left"><td valign="top">UDP </td><td valign="top">X
</td><td valign="top">
-<br></td></tr><tr align="left"><td valign="top">RAW </td><td valign="top">X
</td><td valign="top">
- <br></td></tr></table>
-
-<div class="node">
-<p><hr>
-<a name="Using-Networking"></a>Next: <a rel="next" accesskey="n"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Introduction">Introduction</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h2 class="chapter">2 Networking With <samp><span
class="command">gawk</span></samp></h2>
-
-<!-- STARTOFRANGE netgawk -->
-<p><a name="index-networks_002c-_0040command_007bgawk_007d-and-8"></a><!--
STARTOFRANGE gawknet -->
-<a name="index-_0040command_007bgawk_007d_002c-networking-9"></a>The
<samp><span class="command">awk</span></samp> programming language was
originally developed as a
-pattern-matching language for writing short programs to perform
-data manipulation tasks.
-<samp><span class="command">awk</span></samp>'s strength is the manipulation
of textual data
-that is stored in files.
-It was never meant to be used for networking purposes.
-To exploit its features in a
-networking context, it's necessary to use an access mode for network
connections
-that resembles the access of files as closely as possible.
-
- <p><a name="index-Perl-10"></a><a name="index-Python-11"></a><a
name="index-Tcl_002fTk-12"></a><samp><span class="command">awk</span></samp> is
also meant to be a prototyping language. It is used
-to demonstrate feasibility and to play with features and user interfaces.
-This can be done with file-like handling of network
-connections.
-<samp><span class="command">gawk</span></samp> trades the lack
-of many of the advanced features of the TCP/IP family of protocols
-for the convenience of simple connection handling.
-The advanced
-features are available when programming in C or Perl. In fact, the
-network programming
-in this chapter
-is very similar to what is described in books such as
-<cite>Internet Programming with Python</cite>,
-<cite>Advanced Perl Programming</cite>,
-or
-<cite>Web Client Programming with Perl</cite>.
-
- <p><a
name="index-Perl_002c-_0040command_007bgawk_007d-networking-and-13"></a><a
name="index-Python_002c-_0040command_007bgawk_007d-networking-and-14"></a><a
name="index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-15"></a>However, you
can do the programming here without first having to learn object-oriented
-ideology; underlying languages such as Tcl/Tk, Perl, Python; or all of
-the libraries necessary to extend these languages before they are ready for
the Internet.
-
- <p><a name="index-Transmission-Control-Protocol_002c-See-TCP-16"></a><a
name="index-TCP-_0028Transmission-Control-Protocol_0029-17"></a>This chapter
demonstrates how to use the TCP protocol. The
-other protocols are much less important for most users (UDP) or even
-untractable (RAW).
-
-<ul class="menu">
-<li><a accesskey="1" href="#Gawk-Special-Files">Gawk Special Files</a>:
How to do <samp><span class="command">gawk</span></samp> networking.
-<li><a accesskey="2" href="#TCP-Connecting">TCP Connecting</a>:
Making a TCP connection.
-<li><a accesskey="3" href="#Troubleshooting">Troubleshooting</a>:
Troubleshooting TCP/IP connections.
-<li><a accesskey="4" href="#Interacting">Interacting</a>:
Interacting with a service.
-<li><a accesskey="5" href="#Setting-Up">Setting Up</a>:
Setting up a service.
-<li><a accesskey="6" href="#Email">Email</a>: Reading
email.
-<li><a accesskey="7" href="#Web-page">Web page</a>:
Reading a Web page.
-<li><a accesskey="8" href="#Primitive-Service">Primitive Service</a>:
A primitive Web service.
-<li><a accesskey="9" href="#Interacting-Service">Interacting Service</a>:
A Web service with interaction.
-<li><a href="#Simple-Server">Simple Server</a>: A simple Web
server.
-<li><a href="#Caveats">Caveats</a>: Network programming
caveats.
-<li><a href="#Challenges">Challenges</a>: Where to go from
here.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Gawk-Special-Files"></a>Next: <a rel="next" accesskey="n"
href="#TCP-Connecting">TCP Connecting</a>,
-Previous: <a rel="previous" accesskey="p" href="#Using-Networking">Using
Networking</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h3 class="section">2.1 <samp><span class="command">gawk</span></samp>'s
Networking Mechanisms</h3>
-
-<p>The `<samp><span class="samp">|&</span></samp>' operator introduced in
<samp><span class="command">gawk</span></samp> 3.1 for use in
-communicating with a <dfn>coprocess</dfn> is described in
-<a href="gawk.html#Two_002dway-I_002fO">Two-way Communications With Another
Process (GAWK: Effective AWK Programming)</a>.
-It shows how to do two-way I/O to a
-separate process, sending it data with <code>print</code> or
<code>printf</code> and
-reading data with <code>getline</code>. If you haven't read it already, you
should
-detour there to do so.
-
- <p><samp><span class="command">gawk</span></samp> transparently extends the
two-way I/O mechanism to simple networking through
-the use of special file names. When a “coprocess” that matches
-the special files we are about to describe
-is started, <samp><span class="command">gawk</span></samp> creates the
appropriate network
-connection, and then two-way I/O proceeds as usual.
-
-<!-- last comma is part of see-also -->
-<p><a
name="index-input_002foutput_002c-two_002dway_002c-See-Also-_0040command_007bgawk_007d_002c-networking-18"></a><a
name="index-TCP_002fIP_002c-sockets-and-19"></a>At the C, C++, and Perl level,
networking is accomplished
-via <dfn>sockets</dfn>, an Application Programming Interface (API) originally
-developed at the University of California at Berkeley that is now used
-almost universally for TCP/IP networking.
-Socket level programming, while fairly straightforward, requires paying
-attention to a number of details, as well as using binary data. It is not
-well-suited for use from a high-level language like <samp><span
class="command">awk</span></samp>.
-The special files provided in <samp><span class="command">gawk</span></samp>
hide the details from
-the programmer, making things much simpler and easier to use.
-<!-- Who sez we can't toot our own horn occasionally? -->
-
-<!-- STARTOFRANGE filenet -->
-<p><a name="index-filenames_002c-for-network-access-20"></a><!-- STARTOFRANGE
gawnetf -->
-<a
name="index-_0040command_007bgawk_007d_002c-networking_002c-filenames-21"></a><!--
STARTOFRANGE netgawf -->
-<a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-filenames-22"></a>The
special file name for network access is made up of several fields, all
-of which are mandatory:
-
-<pre class="example">
/inet/<var>protocol</var>/<var>localport</var>/<var>hostname</var>/<var>remoteport</var>
-</pre>
- <p><a
name="index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-23"></a><a
name="index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-24"></a><a
name="index-localport-field-25"></a><a
name="index-remoteport-field-26"></a>The <samp><span
class="file">/inet/</span></samp> field is, of course, constant when accessing
the network.
-The <var>localport</var> and <var>remoteport</var> fields do not have a meaning
-when used with <samp><span class="file">/inet/raw</span></samp> because
“ports” only apply to
-TCP and UDP. So, when using <samp><span class="file">/inet/raw</span></samp>,
the port fields always have
-to be `<samp><span class="samp">0</span></samp>'.
-
-<ul class="menu">
-<li><a accesskey="1" href="#Special-File-Fields">Special File Fields</a>:
The fields in the special file name.
-<li><a accesskey="2" href="#Comparing-Protocols">Comparing Protocols</a>:
Differences between the protocols.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Special-File-Fields"></a>Next: <a rel="next" accesskey="n"
href="#Comparing-Protocols">Comparing Protocols</a>,
-Previous: <a rel="previous" accesskey="p" href="#Gawk-Special-Files">Gawk
Special Files</a>,
-Up: <a rel="up" accesskey="u" href="#Gawk-Special-Files">Gawk Special
Files</a>
-<br>
-</div>
-
-<h4 class="subsection">2.1.1 The Fields of the Special File Name</h4>
-
-<p>This section explains the meaning of all the other fields,
-as well as the range of values and the defaults.
-All of the fields are mandatory. To let the system pick a value,
-or if the field doesn't apply to the protocol, specify it as `<samp><span
class="samp">0</span></samp>':
-
-
-<a name="index-protocol-field-27"></a>
-<dl><!-- last comma is part of secondary -->
-<a
name="index-TCP_002fIP_002c-protocols_002c-selecting-28"></a><dt><var>protocol</var><dd>Determines
which member of the TCP/IP
-family of protocols is selected to transport the data across the
-network. There are three possible values (always written in lowercase):
-`<samp><span class="samp">tcp</span></samp>', `<samp><span
class="samp">udp</span></samp>', and `<samp><span
class="samp">raw</span></samp>'. The exact meaning of each is
-explained later in this section.
-
- <br><dt><var>localport</var><dd><a
name="index-networks_002c-ports_002c-specifying-29"></a>Determines which port
on the local
-machine is used to communicate across the network. It has no meaning
-with <samp><span class="file">/inet/raw</span></samp> and must therefore be
`<samp><span class="samp">0</span></samp>'. Application-level clients
-usually use `<samp><span class="samp">0</span></samp>' to indicate they do not
care which local port is
-used—instead they specify a remote port to connect to. It is vital for
-application-level servers to use a number different from `<samp><span
class="samp">0</span></samp>' here
-because their service has to be available at a specific publicly known
-port number. It is possible to use a name from <samp><span
class="file">/etc/services</span></samp> here.
-
- <br><dt><var>hostname</var><dd><a name="index-hostname-field-30"></a><a
name="index-servers_002c-as-hosts-31"></a>Determines which remote host is to
-be at the other end of the connection. Application-level servers must fill
-this field with a `<samp><span class="samp">0</span></samp>' to indicate their
being open for all other hosts
-to connect to them and enforce connection level server behavior this way.
-It is not possible for an application-level server to restrict its
-availability to one remote host by entering a host name here.
-Application-level clients must enter a name different from `<samp><span
class="samp">0</span></samp>'.
-The name can be either symbolic
-(e.g., `<samp><span class="samp">jpl-devvax.jpl.nasa.gov</span></samp>') or
numeric (e.g., `<samp><span class="samp">128.149.1.143</span></samp>').
-
- <br><dt><var>remoteport</var><dd>Determines which port on the remote
-machine is used to communicate across the network. It has no meaning
-with <samp><span class="file">/inet/raw</span></samp> and must therefore be 0.
-For <samp><span class="file">/inet/tcp</span></samp> and <samp><span
class="file">/inet/udp</span></samp>,
-application-level clients <em>must</em> use a number
-other than `<samp><span class="samp">0</span></samp>' to indicate to which
port on the remote machine
-they want to connect. Application-level servers must not fill this field with
-a `<samp><span class="samp">0</span></samp>'. Instead they specify a local
port to which clients connect.
-It is possible to use a name from <samp><span
class="file">/etc/services</span></samp> here.
-</dl>
-
- <p><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-32"></a><a
name="index-_0040command_007bgawk_007d_002c-networking_002c-connections-33"></a>Experts
in network programming will notice that the usual
-client/server asymmetry found at the level of the socket API is not visible
-here. This is for the sake of simplicity of the high-level concept. If this
-asymmetry is necessary for your application,
-use another language.
-For <samp><span class="command">gawk</span></samp>, it is
-more important to enable users to write a client program with a minimum
-of code. What happens when first accessing a network connection is seen
-in the following pseudocode:
-
-<pre class="smallexample"> if ((name of remote host given) &&
(other side accepts connection)) {
- rendez-vous successful; transmit with getline or print
- } else {
- if ((other side did not accept) && (localport == 0))
- exit unsuccessful
- if (TCP) {
- set up a server accepting connections
- this means waiting for the client on the other side to connect
- } else
- ready
- }
-</pre>
- <p>The exact behavior of this algorithm depends on the values of the
-fields of the special file name. When in doubt, <a
href="#table_002dinet_002dcomponents">table-inet-components</a>
-gives you the combinations of values and their meaning. If this
-table is too complicated, focus on the three lines printed in
-<strong>bold</strong>. All the examples in
-<a href="#Using-Networking">Networking With <samp><span
class="command">gawk</span></samp></a>,
-use only the
-patterns printed in bold letters.
-
- <div class="float">
-<a name="table_002dinet_002dcomponents"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="15%"><span
class="sc">protocol</span> </th><th valign="top" width="15%"><span
class="sc">local port</span> </th><th valign="top" width="15%"><span
class="sc">host name</span>
-</th><th valign="top" width="15%"><span class="sc">remote port</span> </th><th
valign="top" width="40%"><span class="sc">Resulting connection-level
behavior</span>
-<br></th></tr><tr align="left"><td valign="top"
width="15%"><strong>tcp</strong> </td><td valign="top"
width="15%"><strong>0</strong> </td><td valign="top"
width="15%"><strong>x</strong> </td><td valign="top"
width="15%"><strong>x</strong> </td><td valign="top" width="40%">
- <strong>Dedicated client, fails if immediately connecting to a
- server on the other side fails</strong>
-<br></td></tr><tr align="left"><td valign="top" width="15%">udp </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">x </td><td valign="top" width="40%">Dedicated client
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Dedicated client,
works only as <code>root</code>
-<br></td></tr><tr align="left"><td valign="top" width="15%"><strong>tcp,
udp</strong> </td><td valign="top" width="15%"><strong>x</strong> </td><td
valign="top" width="15%"><strong>x</strong> </td><td valign="top"
width="15%"><strong>x</strong> </td><td valign="top" width="40%">
- <strong>Client, switches to dedicated server if necessary</strong>
-<br></td></tr><tr align="left"><td valign="top" width="15%"><strong>tcp,
udp</strong> </td><td valign="top" width="15%"><strong>x</strong> </td><td
valign="top" width="15%"><strong>0</strong> </td><td valign="top"
width="15%"><strong>0</strong> </td><td valign="top" width="40%">
- <strong>Dedicated server</strong>
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">0 </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Dedicated server,
works only as <code>root</code>
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp, raw
</td><td valign="top" width="15%">x </td><td valign="top" width="15%">x
</td><td valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp, raw
</td><td valign="top" width="15%">0 </td><td valign="top" width="15%">0
</td><td valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp, raw
</td><td valign="top" width="15%">x </td><td valign="top" width="15%">0
</td><td valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">0 </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">x </td><td valign="top" width="15%">0 </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">x </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
- <br></td></tr></table>
-<p><strong class="float-caption">Table 2.1: /inet Special File
Components</strong></p></div>
-
- <p>In general, TCP is the preferred mechanism to use. It is the simplest
-protocol to understand and to use. Use the others only if circumstances
-demand low-overhead.
-
-<div class="node">
-<p><hr>
-<a name="Comparing-Protocols"></a>Previous: <a rel="previous"
accesskey="p" href="#Special-File-Fields">Special File Fields</a>,
-Up: <a rel="up" accesskey="u" href="#Gawk-Special-Files">Gawk Special
Files</a>
-<br>
-</div>
-
-<h4 class="subsection">2.1.2 Comparing Protocols</h4>
-
-<p>This section develops a pair of programs (sender and receiver)
-that do nothing but send a timestamp from one machine to another. The
-sender and the receiver are implemented with each of the three protocols
-available and demonstrate the differences between them.
-
-<ul class="menu">
-<li><a accesskey="1" href="#File-_002finet_002ftcp">File /inet/tcp</a>:
The TCP special file.
-<li><a accesskey="2" href="#File-_002finet_002fudp">File /inet/udp</a>:
The UDP special file.
-<li><a accesskey="3" href="#File-_002finet_002fraw">File /inet/raw</a>:
The RAW special file.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="File-_002finet_002ftcp"></a>Next: <a rel="next" accesskey="n"
href="#File-_002finet_002fudp">File /inet/udp</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Comparing-Protocols">Comparing Protocols</a>,
-Up: <a rel="up" accesskey="u" href="#Comparing-Protocols">Comparing
Protocols</a>
-<br>
-</div>
-
-<h5 class="subsubsection">2.1.2.1 <samp><span
class="file">/inet/tcp</span></samp></h5>
-
-<p><a
name="index-_0040code_007b_002finet_002ftcp_007d-special-files-_0028_0040command_007bgawk_007d_0029-34"></a><a
name="index-files_002c-_0040code_007b_002finet_002ftcp_007d-_0028_0040command_007bgawk_007d_0029-35"></a><a
name="index-TCP-_0028Transmission-Control-Protocol_0029-36"></a>Once again,
always use TCP.
-(Use UDP when low overhead is a necessity, and use RAW for
-network experimentation.)
-The first example is the sender
-program:
-
-<pre class="example"> # Server
- BEGIN {
- print strftime() |& "/inet/tcp/8888/0/0"
- close("/inet/tcp/8888/0/0")
- }
-</pre>
- <p>The receiver is very simple:
-
-<pre class="example"> # Client
- BEGIN {
- "/inet/tcp/0/localhost/8888" |& getline
- print $0
- close("/inet/tcp/0/localhost/8888")
- }
-</pre>
- <p>TCP guarantees that the bytes arrive at the receiving end in exactly
-the same order that they were sent. No byte is lost
-(except for broken connections), doubled, or out of order. Some
-overhead is necessary to accomplish this, but this is the price to pay for
-a reliable service.
-It does matter which side starts first. The sender/server has to be started
-first, and it waits for the receiver to read a line.
-
-<div class="node">
-<p><hr>
-<a name="File-_002finet_002fudp"></a>Next: <a rel="next" accesskey="n"
href="#File-_002finet_002fraw">File /inet/raw</a>,
-Previous: <a rel="previous" accesskey="p"
href="#File-_002finet_002ftcp">File /inet/tcp</a>,
-Up: <a rel="up" accesskey="u" href="#Comparing-Protocols">Comparing
Protocols</a>
-<br>
-</div>
-
-<h5 class="subsubsection">2.1.2.2 <samp><span
class="file">/inet/udp</span></samp></h5>
-
-<p><a
name="index-_0040code_007b_002finet_002fudp_007d-special-files-_0028_0040command_007bgawk_007d_0029-37"></a><a
name="index-files_002c-_0040code_007b_002finet_002fudp_007d-_0028_0040command_007bgawk_007d_0029-38"></a><a
name="index-UDP-_0028User-Datagram-Protocol_0029-39"></a><a
name="index-User-Datagram-Protocol_002c-See-UDP-40"></a>The server and client
programs that use UDP are almost identical to their TCP counterparts;
-only the <var>protocol</var> has changed. As before, it does matter which side
-starts first. The receiving side blocks and waits for the sender.
-In this case, the receiver/client has to be started first:
-
-<pre class="example"> # Server
- BEGIN {
- print strftime() |& "/inet/udp/8888/0/0"
- close("/inet/udp/8888/0/0")
- }
-</pre>
- <p>The receiver is almost identical to the TCP receiver:
-
-<pre class="example"> # Client
- BEGIN {
- "/inet/udp/0/localhost/8888" |& getline
- print $0
- close("/inet/udp/0/localhost/8888")
- }
-</pre>
- <p>UDP cannot guarantee that the datagrams at the receiving end will arrive
in exactly
-the same order they were sent. Some datagrams could be
-lost, some doubled, and some out of order. But no overhead is necessary to
-accomplish this. This unreliable behavior is good enough for tasks
-such as data acquisition, logging, and even stateless services like NFS.
-
-<div class="node">
-<p><hr>
-<a name="File-_002finet_002fraw"></a>Previous: <a rel="previous"
accesskey="p" href="#File-_002finet_002fudp">File /inet/udp</a>,
-Up: <a rel="up" accesskey="u" href="#Comparing-Protocols">Comparing
Protocols</a>
-<br>
-</div>
-
-<h5 class="subsubsection">2.1.2.3 <samp><span
class="file">/inet/raw</span></samp></h5>
-
-<p><a
name="index-_0040code_007b_002finet_002fraw_007d-special-files-_0028_0040command_007bgawk_007d_0029-41"></a><a
name="index-files_002c-_0040code_007b_002finet_002fraw_007d-_0028_0040command_007bgawk_007d_0029-42"></a><a
name="index-RAW-protocol-43"></a>
-This is an IP-level protocol. Only <code>root</code> is allowed to access this
-special file. It is meant to be the basis for implementing
-and experimenting with transport-level protocols.<a rel="footnote"
href="#fn-4" name="fnd-4"><sup>4</sup></a>
-In the most general case,
-the sender has to supply the encapsulating header bytes in front of the
-packet and the receiver has to strip the additional bytes from the message.
-
- <p><a name="index-dark-corner_002c-RAW-protocol-44"></a>RAW receivers
cannot receive packets sent with TCP or UDP because the
-operating system does not deliver the packets to a RAW receiver. The
-operating system knows about some of the protocols on top of IP
-and decides on its own which packet to deliver to which process.
-(d.c.)
-Therefore, the UDP receiver must be used for receiving UDP
-datagrams sent with the RAW sender. This is a dark corner, not only of
-<samp><span class="command">gawk</span></samp>, but also of TCP/IP.
-
- <p><a name="index-SPAK-utility-45"></a>For extended experimentation with
protocols, look into
-the approach implemented in a tool called SPAK.
-This tool reflects the hierarchical layering of protocols (encapsulation)
-in the way data streams are piped out of one program into the next one.
-It shows which protocol is based on which other (lower-level) protocol
-by looking at the command-line ordering of the program calls.
-Cleverly thought out, SPAK is much better than <samp><span
class="command">gawk</span></samp>'s
-<samp><span class="file">/inet</span></samp> for learning the meaning of each
and every bit in the
-protocol headers.
-
- <p>The next example uses the RAW protocol to emulate
-the behavior of UDP. The sender program is the same as above, but with some
-additional bytes that fill the places of the UDP fields:
-
-<pre class="example"> BEGIN {
- Message = "Hello world\n"
- SourcePort = 0
- DestinationPort = 8888
- MessageLength = length(Message)+8
- RawService = "/inet/raw/0/localhost/0"
- printf("%c%c%c%c%c%c%c%c%s",
- SourcePort/256, SourcePort%256,
- DestinationPort/256, DestinationPort%256,
- MessageLength/256, MessageLength%256,
- 0, 0, Message) |& RawService
- fflush(RawService)
- close(RawService)
- }
-</pre>
- <p>Since this program tries
-to emulate the behavior of UDP, it checks if
-the RAW sender is understood by the UDP receiver but not if the RAW receiver
-can understand the UDP sender. In a real network, the
-RAW receiver is hardly
-of any use because it gets every IP packet that
-comes across the network. There are usually so many packets that
-<samp><span class="command">gawk</span></samp> would be too slow for
processing them.
-Only on a network with little
-traffic can the IP-level receiver program be tested. Programs for analyzing
-IP traffic on modem or ISDN channels should be possible.
-
- <p>Port numbers do not have a meaning when using <samp><span
class="file">/inet/raw</span></samp>. Their fields
-have to be `<samp><span class="samp">0</span></samp>'. Only TCP and UDP use
ports. Receiving data from
-<samp><span class="file">/inet/raw</span></samp> is difficult, not only
because of processing speed but also
-because data is usually binary and not restricted to ASCII. This
-implies that line separation with <code>RS</code> does not work as usual.
-
-<div class="node">
-<p><hr>
-<a name="TCP-Connecting"></a>Next: <a rel="next" accesskey="n"
href="#Troubleshooting">Troubleshooting</a>,
-Previous: <a rel="previous" accesskey="p" href="#Gawk-Special-Files">Gawk
Special Files</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.2 Establishing a TCP Connection</h3>
-
-<!-- STARTOFRANGE tcpcon -->
-<p><a
name="index-TCP-_0028Transmission-Control-Protocol_0029_002c-connection_002c-establishing-46"></a><!--
STARTOFRANGE netcon -->
-<a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-47"></a><!--
STARTOFRANGE gawcon -->
-<a
name="index-_0040command_007bgawk_007d_002c-networking_002c-connections-48"></a>Let's
observe a network connection at work. Type in the following program
-and watch the output. Within a second, it connects via TCP (<samp><span
class="file">/inet/tcp</span></samp>)
-to the machine it is running on (`<samp><span
class="samp">localhost</span></samp>') and asks the service
-`<samp><span class="samp">daytime</span></samp>' on the machine what time it
is:
-
- <p><a name="index-_0040code_007bgetline_007d-command-49"></a>
-<pre class="example"> BEGIN {
- "/inet/tcp/0/localhost/daytime" |& getline
- print $0
- close("/inet/tcp/0/localhost/daytime")
- }
-</pre>
- <p>Even experienced <samp><span class="command">awk</span></samp> users
will find the second line strange in two
-respects:
-
- <ul>
-<li>A special file is used as a shell command that pipes its output
-into <code>getline</code>. One would rather expect to see the special file
-being read like any other file (`<samp><span class="samp">getline <
-"/inet/tcp/0/localhost/daytime")</span></samp>'.
-
- <li><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-50"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-51"></a>The
operator `<samp><span class="samp">|&</span></samp>' has not been part of
any <samp><span class="command">awk</span></samp>
-implementation (until now).
-It is actually the only extension of the <samp><span
class="command">awk</span></samp>
-language needed (apart from the special files) to introduce network access.
-</ul>
-
- <p><a name="index-pipes_002c-networking-and-52"></a>The `<samp><span
class="samp">|&</span></samp>' operator was introduced in <samp><span
class="command">gawk</span></samp> 3.1 in order to
-overcome the crucial restriction that access to files and pipes in
-<samp><span class="command">awk</span></samp> is always unidirectional. It was
formerly impossible to use
-both access modes on the same file or pipe. Instead of changing the whole
-concept of file access, the `<samp><span class="samp">|&</span></samp>'
operator
-behaves exactly like the usual pipe operator except for two additions:
-
- <ul>
-<li>Normal shell commands connected to their <samp><span
class="command">gawk</span></samp> program with a `<samp><span
class="samp">|&</span></samp>'
-pipe can be accessed bidirectionally. The `<samp><span
class="samp">|&</span></samp>' turns out to be a quite
-general, useful, and natural extension of <samp><span
class="command">awk</span></samp>.
-
- <li>Pipes that consist of a special file name for network connections are
not
-executed as shell commands. Instead, they can be read and written to, just
-like a full-duplex network connection.
-</ul>
-
- <p>In the earlier example, the `<samp><span
class="samp">|&</span></samp>' operator tells <code>getline</code>
-to read a line from the special file <samp><span
class="file">/inet/tcp/0/localhost/daytime</span></samp>.
-We could also have printed a line into the special file. But instead we just
-read a line with the time, printed it, and closed the connection.
-(While we could just let <samp><span class="command">gawk</span></samp> close
the connection by finishing
-the program, in this web page
-we are pedantic and always explicitly close the connections.)
-
-<div class="node">
-<p><hr>
-<a name="Troubleshooting"></a>Next: <a rel="next" accesskey="n"
href="#Interacting">Interacting</a>,
-Previous: <a rel="previous" accesskey="p" href="#TCP-Connecting">TCP
Connecting</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.3 Troubleshooting Connection Problems</h3>
-
-<p><a name="index-advanced-features_002c-network-connections-53"></a><!-- last
comma is part of secondary -->
-<a name="index-troubleshooting_002c-networks_002c-connections-54"></a>It may
well be that for some reason the program shown in the previous example does not
run on your
-machine. When looking at possible reasons for this, you will learn much
-about typical problems that arise in network programming. First of all,
-your implementation of <samp><span class="command">gawk</span></samp> may not
support network access
-because it is
-a pre-3.1 version or you do not have a network interface in your machine.
-Perhaps your machine uses some other protocol, such as
-DECnet or Novell's IPX. For the rest of this chapter,
-we will assume
-you work on a Unix machine that supports TCP/IP. If the previous example
program does
-not run on your machine, it may help to replace the name
-`<samp><span class="samp">localhost</span></samp>' with the name of your
machine or its IP address. If it
-does, you could replace `<samp><span class="samp">localhost</span></samp>'
with the name of another machine
-in your vicinity—this way, the program connects to another machine.
-Now you should see the date and time being printed by the program,
-otherwise your machine may not support the `<samp><span
class="samp">daytime</span></samp>' service.
-Try changing the service to `<samp><span class="samp">chargen</span></samp>'
or `<samp><span class="samp">ftp</span></samp>'. This way, the program
-connects to other services that should give you some response. If you are
-curious, you should have a look at your <samp><span
class="file">/etc/services</span></samp> file. It could
-look like this:
-
-<pre class="smallexample"> # /etc/services:
- #
- # Network services, Internet style
- #
- # Name Number/Protcol Alternate name # Comments
-
- echo 7/tcp
- echo 7/udp
- discard 9/tcp sink null
- discard 9/udp sink null
- daytime 13/tcp
- daytime 13/udp
- chargen 19/tcp ttytst source
- chargen 19/udp ttytst source
- ftp 21/tcp
- telnet 23/tcp
- smtp 25/tcp mail
- finger 79/tcp
- www 80/tcp http # WorldWideWeb HTTP
- www 80/udp # HyperText Transfer Protocol
- pop-2 109/tcp postoffice # POP version 2
- pop-2 109/udp
- pop-3 110/tcp # POP version 3
- pop-3 110/udp
- nntp 119/tcp readnews untp # USENET News
- irc 194/tcp # Internet Relay Chat
- irc 194/udp
- ...
-</pre>
- <p><a name="index-Linux-55"></a><a name="index-GNU_002fLinux-56"></a><a
name="index-Microsoft-Windows_002c-networking-57"></a>Here, you find a list of
services that traditional Unix machines usually
-support. If your GNU/Linux machine does not do so, it may be that these
-services are switched off in some startup script. Systems running some
-flavor of Microsoft Windows usually do <em>not</em> support these services.
-Nevertheless, it <em>is</em> possible to do networking with <samp><span
class="command">gawk</span></samp> on
-Microsoft
-Windows.<a rel="footnote" href="#fn-5" name="fnd-5"><sup>5</sup></a>
-The first column of the file gives the name of the service, and
-the second column gives a unique number and the protocol that one can use to
connect to
-this service.
-The rest of the line is treated as a comment.
-You see that some services (`<samp><span class="samp">echo</span></samp>')
support TCP as
-well as UDP.
-
-<div class="node">
-<p><hr>
-<a name="Interacting"></a>Next: <a rel="next" accesskey="n"
href="#Setting-Up">Setting Up</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Troubleshooting">Troubleshooting</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.4 Interacting with a Network Service</h3>
-
-<p>The next program makes use of the possibility to really interact with a
-network service by printing something into the special file. It asks the
-so-called <samp><span class="command">finger</span></samp> service if a user
of the machine is logged in. When
-testing this program, try to change `<samp><span
class="samp">localhost</span></samp>' to
-some other machine name in your local network:
-
-<!-- system if test ! -d eg ; then mkdir eg ; fi -->
-<!-- system if test ! -d eg/network ; then mkdir eg/network ; fi -->
-<pre class="example"> <!-- file eg/network/fingerclient.awk -->
- BEGIN {
- NetService = "/inet/tcp/0/localhost/finger"
- print "<var>name</var>" |& NetService
- while ((NetService |& getline) > 0)
- print $0
- close(NetService)
- }
- <!-- endfile -->
-</pre>
- <p>After telling the service on the machine which user to look for,
-the program repeatedly reads lines that come as a reply. When no more
-lines are coming (because the service has closed the connection), the
-program also closes the connection. Try replacing
<code>"</code><var>name</var><code>"</code> with your
-login name (or the name of someone else logged in). For a list
-of all users currently logged in, replace <var>name</var> with an empty string
-(<code>""</code>).
-
- <p><a name="index-Linux-58"></a><a name="index-GNU_002fLinux-59"></a>The
final <code>close</code> command could be safely deleted from
-the above script, because the operating system closes any open connection
-by default when a script reaches the end of execution. In order to avoid
-portability problems, it is best to always close connections explicitly.
-With the Linux kernel,
-for example, proper closing results in flushing of buffers. Letting
-the close happen by default may result in discarding buffers.
-
- <p>When looking at <samp><span class="file">/etc/services</span></samp> you
may have noticed that the
-`<samp><span class="samp">daytime</span></samp>' service is also available
with `<samp><span class="samp">udp</span></samp>'. In the earlier
-example, change `<samp><span class="samp">tcp</span></samp>' to `<samp><span
class="samp">udp</span></samp>',
-and change `<samp><span class="samp">finger</span></samp>' to `<samp><span
class="samp">daytime</span></samp>'.
-After starting the modified program, you see the expected day and time
message.
-The program then hangs, because it waits for more lines coming from the
-service. However, they never come. This behavior is a consequence of the
-differences between TCP and UDP. When using UDP, neither party is
-automatically informed about the other closing the connection.
-Continuing to experiment this way reveals many other subtle
-differences between TCP and UDP. To avoid such trouble, one should always
-remember the advice Douglas E. Comer and David Stevens give in
-Volume III of their series <cite>Internetworking With TCP</cite>
-(page 14):
-
- <p><a
name="index-TCP-_0028Transmission-Control-Protocol_0029_002c-UDP-and-60"></a><a
name="index-UDP-_0028User-Datagram-Protocol_0029_002c-TCP-and-61"></a><a
name="index-Internet_002c-See-networks-62"></a><blockquote>
-When designing client-server applications, beginners are strongly
-advised to use TCP because it provides reliable, connection-oriented
-communication. Programs only use UDP if the application protocol handles
-reliability, the application requires hardware broadcast or multicast,
-or the application cannot tolerate virtual circuit overhead.
-</blockquote>
-
-<div class="node">
-<p><hr>
-<a name="Setting-Up"></a>Next: <a rel="next" accesskey="n"
href="#Email">Email</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Interacting">Interacting</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.5 Setting Up a Service</h3>
-
-<!-- last comma is part of tertiary -->
-<p><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-service_002c-establishing-63"></a><!--
last comma is part of tertiary -->
-<a
name="index-_0040command_007bgawk_007d_002c-networking_002c-service_002c-establishing-64"></a>The
preceding programs behaved as clients that connect to a server somewhere
-on the Internet and request a particular service. Now we set up such a
-service to mimic the behavior of the `<samp><span
class="samp">daytime</span></samp>' service.
-Such a server does not know in advance who is going to connect to it over
-the network. Therefore, we cannot insert a name for the host to connect to
-in our special file name.
-
- <p>Start the following program in one window. Notice that the service does
-not have the name `<samp><span class="samp">daytime</span></samp>', but the
number `<samp><span class="samp">8888</span></samp>'.
-From looking at <samp><span class="file">/etc/services</span></samp>, you know
that names like `<samp><span class="samp">daytime</span></samp>'
-are just mnemonics for predetermined 16-bit integers.
-Only the system administrator (<code>root</code>) could enter
-our new service into <samp><span class="file">/etc/services</span></samp> with
an appropriate name.
-Also notice that the service name has to be entered into a different field
-of the special file name because we are setting up a server, not a client:
-
- <p><a name="index-_0040command_007bfinger_007d-utility-65"></a><a
name="index-servers-66"></a>
-<pre class="example"> BEGIN {
- print strftime() |& "/inet/tcp/8888/0/0"
- close("/inet/tcp/8888/0/0")
- }
-</pre>
- <p>Now open another window on the same machine.
-Copy the client program given as the first example
-(see <a href="#TCP-Connecting">Establishing a TCP Connection</a>)
-to a new file and edit it, changing the name `<samp><span
class="samp">daytime</span></samp>' to
-`<samp><span class="samp">8888</span></samp>'. Then start the modified
client. You should get a reply
-like this:
-
-<pre class="example"> Sat Sep 27 19:08:16 CEST 1997
-</pre>
- <p class="noindent">Both programs explicitly close the connection.
-
-<!-- first comma is part of primary -->
-<p><a name="index-Microsoft-Windows_002c-networking_002c-ports-67"></a><a
name="index-networks_002c-ports_002c-reserved-68"></a><a
name="index-Unix_002c-network-ports-and-69"></a>Now we will intentionally make
a mistake to see what happens when the name
-`<samp><span class="samp">8888</span></samp>' (the so-called port) is already
used by another service.
-Start the server
-program in both windows. The first one works, but the second one
-complains that it could not open the connection. Each port on a single
-machine can only be used by one server program at a time. Now terminate the
-server program and change the name `<samp><span
class="samp">8888</span></samp>' to `<samp><span
class="samp">echo</span></samp>'. After restarting it,
-the server program does not run any more, and you know why: there is already
-an `<samp><span class="samp">echo</span></samp>' service running on your
machine. But even if this isn't true,
-you would not get
-your own `<samp><span class="samp">echo</span></samp>' server running on a
Unix machine,
-because the ports with numbers smaller
-than 1024 (`<samp><span class="samp">echo</span></samp>' is at port 7) are
reserved for <code>root</code>.
-On machines running some flavor of Microsoft Windows, there is no restriction
-that reserves ports 1 to 1024 for a privileged user; hence, you can start
-an `<samp><span class="samp">echo</span></samp>' server there.
-
- <p>Turning this short server program into something really useful is
simple.
-Imagine a server that first reads a file name from the client through the
-network connection, then does something with the file and
-sends a result back to the client. The server-side processing
-could be:
-
-<pre class="example"> BEGIN {
- NetService = "/inet/tcp/8888/0/0"
- NetService |& getline
- CatPipe = ("cat " $1) # sets $0 and the fields
- while ((CatPipe | getline) > 0)
- print $0 |& NetService
- close(NetService)
- }
-</pre>
- <p class="noindent">and we would
-have a remote copying facility. Such a server reads the name of a file
-from any client that connects to it and transmits the contents of the
-named file across the net. The server-side processing could also be
-the execution of a command that is transmitted across the network. From this
-example, you can see how simple it is to open up a security hole on your
-machine. If you allow clients to connect to your machine and
-execute arbitrary commands, anyone would be free to do `<samp><span
class="samp">rm -rf *</span></samp>'.
-
-<div class="node">
-<p><hr>
-<a name="Email"></a>Next: <a rel="next" accesskey="n"
href="#Web-page">Web page</a>,
-Previous: <a rel="previous" accesskey="p" href="#Setting-Up">Setting
Up</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.6 Reading Email</h3>
-
-<!-- @cindex RFC 1939 -->
-<!-- @cindex RFC 821 -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-networking_002c-See-Also-email-70"></a><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-See-Also-email-71"></a><a
name="index-POP-_0028Post-Office-Protocol_0029-72"></a><a
name="index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-73"></a><a
name="index-Post-Office-Protocol-_0028POP_0029-74"></a><a
name="index-Simple-Mail-Transfer-Protocol-_0028SMTP_0029-75"></a>The
distribution of email is usually done by dedicated email servers that
-communicate with your machine using special protocols. To receive email, we
-will use the Post Office Protocol (POP). Sending can be done with the much
-older Simple Mail Transfer Protocol (SMTP).
-
- <p><a name="index-email-76"></a>When you type in the following program,
replace the <var>emailhost</var> by the
-name of your local email server. Ask your administrator if the server has a
-POP service, and then use its name or number in the program below.
-Now the program is ready to connect to your email server, but it will not
-succeed in retrieving your mail because it does not yet know your login
-name or password. Replace them in the program and it
-shows you the first email the server has in store:
-
-<pre class="example"> BEGIN {
- POPService = "/inet/tcp/0/<var>emailhost</var>/pop3"
- RS = ORS = "\r\n"
- print "user <var>name</var>" |& POPService
- POPService |& getline
- print "pass <var>password</var>" |& POPService
- POPService |& getline
- print "retr 1" |& POPService
- POPService |& getline
- if ($1 != "+OK") exit
- print "quit" |& POPService
- RS = "\r\n\\.\r\n"
- POPService |& getline
- print $0
- close(POPService)
- }
-</pre>
- <!-- @cindex RFC 1939 -->
-<p><a name="index-record-separators_002c-POP-and-77"></a><a
name="index-_0040code_007bRS_007d-variable_002c-POP-and-78"></a><a
name="index-_0040code_007bORS_007d-variable_002c-POP-and-79"></a><a
name="index-POP-_0028Post-Office-Protocol_0029-80"></a>The record separators
<code>RS</code> and <code>ORS</code> are redefined because the
-protocol (POP) requires CR-LF to separate lines. After identifying
-yourself to the email service, the command `<samp><span class="samp">retr
1</span></samp>' instructs the
-service to send the first of all your email messages in line. If the service
-replies with something other than `<samp><span
class="samp">+OK</span></samp>', the program exits; maybe there
-is no email. Otherwise, the program first announces that it intends to finish
-reading email, and then redefines <code>RS</code> in order to read the entire
-email as multiline input in one record. From the POP RFC, we know that the body
-of the email always ends with a single line containing a single dot.
-The program looks for this using `<samp><span class="samp">RS =
"\r\n\\.\r\n"</span></samp>'.
-When it finds this sequence in the mail message, it quits.
-You can invoke this program as often as you like; it does not delete the
-message it reads, but instead leaves it on the server.
-
-<div class="node">
-<p><hr>
-<a name="Web-page"></a>Next: <a rel="next" accesskey="n"
href="#Primitive-Service">Primitive Service</a>,
-Previous: <a rel="previous" accesskey="p" href="#Email">Email</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.7 Reading a Web Page</h3>
-
-<p><a name="index-web-pages-81"></a><a
name="index-HTTP-_0028Hypertext-Transfer-Protocol_0029-82"></a><a
name="index-Hypertext-Transfer-Protocol_002c-See-HTTP-83"></a><!-- @cindex RFC
2068 -->
-<!-- @cindex RFC 2616 -->
-
- <p>Retrieving a web page from a web server is as simple as
-retrieving email from an email server. We only have to use a
-similar, but not identical, protocol and a different port. The name of the
-protocol is HyperText Transfer Protocol (HTTP) and the port number is usually
-80. As in the preceding section, ask your administrator about the
-name of your local web server or proxy web server and its port number
-for HTTP requests.
-
- <p>The following program employs a rather crude approach toward retrieving a
-web page. It uses the prehistoric syntax of HTTP 0.9, which almost all
-web servers still support. The most noticeable thing about it is that the
-program directs the request to the local proxy server whose name you insert
-in the special file name (which in turn calls `<samp><span
class="samp">www.yahoo.com</span></samp>'):
-
-<pre class="example"> BEGIN {
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/0/<var>proxy</var>/80"
- print "GET http://www.yahoo.com" |& HttpService
- while ((HttpService |& getline) > 0)
- print $0
- close(HttpService)
- }
-</pre>
- <!-- @cindex RFC 1945 -->
-<p><a name="index-record-separators_002c-HTTP-and-84"></a><a
name="index-_0040code_007bRS_007d-variable_002c-HTTP-and-85"></a><a
name="index-_0040code_007bORS_007d-variable_002c-HTTP-and-86"></a><a
name="index-HTTP-_0028Hypertext-Transfer-Protocol_0029_002c-record-separators-and-87"></a><a
name="index-HTML-_0028Hypertext-Markup-Language_0029-88"></a><a
name="index-Hypertext-Markup-Language-_0028HTML_0029-89"></a>Again, lines are
separated by a redefined <code>RS</code> and <code>ORS</code>.
-The <code>GET</code> request that we send to the server is the only kind of
-HTTP request that existed when the web was created in the early 1990s.
-HTTP calls this <code>GET</code> request a “method,” which tells
the
-service to transmit a web page (here the home page of the Yahoo! search
-engine). Version 1.0 added the request methods <code>HEAD</code> and
-<code>POST</code>. The current version of HTTP is 1.1,<a rel="footnote"
href="#fn-6" name="fnd-6"><sup>6</sup></a> and knows the additional request
-methods <code>OPTIONS</code>, <code>PUT</code>, <code>DELETE</code>, and
<code>TRACE</code>.
-You can fill in any valid web address, and the program prints the
-HTML code of that page to your screen.
-
- <p>Notice the similarity between the responses of the POP and HTTP
-services. First, you get a header that is terminated by an empty line, and
-then you get the body of the page in HTML. The lines of the headers also
-have the same form as in POP. There is the name of a parameter,
-then a colon, and finally the value of that parameter.
-
- <p><a
name="index-CGI-_0028Common-Gateway-Interface_0029_002c-dynamic-web-pages-and-90"></a><a
name="index-Common-Gateway-Interface_002c-See-CGI-91"></a><a
name="index-GIF-image-format-92"></a><a name="index-PNG-image-format-93"></a><a
name="index-images_002c-retrieving-over-networks-94"></a>Images (<samp><span
class="file">.png</span></samp> or <samp><span class="file">.gif</span></samp>
files) can also be retrieved this way,
-but then you
-get binary data that should be redirected into a file. Another
-application is calling a CGI (Common Gateway Interface) script on some
-server. CGI scripts are used when the contents of a web page are not
-constant, but generated instantly at the moment you send a request
-for the page. For example, to get a detailed report about the current
-quotes of Motorola stock shares, call a CGI script at Yahoo! with
-the following:
-
-<pre class="example"> get = "GET http://quote.yahoo.com/q?s=MOT&d=t"
- print get |& HttpService
-</pre>
- <p>You can also request weather reports this way.
-
-<div class="node">
-<p><hr>
-<a name="Primitive-Service"></a>Next: <a rel="next" accesskey="n"
href="#Interacting-Service">Interacting Service</a>,
-Previous: <a rel="previous" accesskey="p" href="#Web-page">Web page</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.8 A Primitive Web Service</h3>
-
-<!-- STARTOFRANGE webser -->
-<p><a name="index-web-service-95"></a>Now we know enough about HTTP to set up
a primitive web service that just
-says <code>"Hello, world"</code> when someone connects to it with a browser.
-Compared
-to the situation in the preceding section, our program changes the role. It
-tries to behave just like the server we have observed. Since we are setting
-up a server here, we have to insert the port number in the `<samp><span
class="samp">localport</span></samp>'
-field of the special file name. The other two fields (<var>hostname</var> and
-<var>remoteport</var>) have to contain a `<samp><span
class="samp">0</span></samp>' because we do not know in
-advance which host will connect to our service.
-
- <p>In the early 1990s, all a server had to do was send an HTML document and
-close the connection. Here, we adhere to the modern syntax of HTTP.
-The steps are as follows:
-
- <ol type=1 start=1>
-<li>Send a status line telling the web browser that everything
-is okay.
-
- <li>Send a line to tell the browser how many bytes follow in the
-body of the message. This was not necessary earlier because both
-parties knew that the document ended when the connection closed. Nowadays
-it is possible to stay connected after the transmission of one web page.
-This is to avoid the network traffic necessary for repeatedly establishing
-TCP connections for requesting several images. Thus, there is the need to tell
-the receiving party how many bytes will be sent. The header is terminated
-as usual with an empty line.
-
- <li>Send the <code>"Hello, world"</code> body
-in HTML.
-The useless <code>while</code> loop swallows the request of the browser.
-We could actually omit the loop, and on most machines the program would still
-work.
-First, start the following program:
- </ol>
-
-<pre class="example"> <!-- file eg/network/hello-serv.awk -->
- BEGIN {
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/8080/0/0"
- Hello = "<HTML><HEAD>" \
- "<TITLE>A Famous Greeting</TITLE></HEAD>" \
- "<BODY><H1>Hello,
world</H1></BODY></HTML>"
- Len = length(Hello) + length(ORS)
- print "HTTP/1.0 200 OK" |& HttpService
- print "Content-Length: " Len ORS |& HttpService
- print Hello |& HttpService
- while ((HttpService |& getline) > 0)
- continue;
- close(HttpService)
- }
- <!-- endfile -->
-</pre>
- <p>Now, on the same machine, start your favorite browser and let it point to
-<a href="http://localhost:8080">http://localhost:8080</a> (the browser needs
to know on which port
-our server is listening for requests). If this does not work, the browser
-probably tries to connect to a proxy server that does not know your machine.
-If so, change the browser's configuration so that the browser does not try to
-use a proxy to connect to your machine.
-
-<div class="node">
-<p><hr>
-<a name="Interacting-Service"></a>Next: <a rel="next" accesskey="n"
href="#Simple-Server">Simple Server</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Primitive-Service">Primitive Service</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.9 A Web Service with Interaction</h3>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-web-and_002c-See-web-service-96"></a><a
name="index-web-browsers_002c-See-web-service-97"></a><!-- comma is part of
primary -->
-<a name="index-HTTP-server_002c-core-logic-98"></a><a
name="index-servers_002c-HTTP-99"></a>
-
-<ul class="menu">
-<li><a accesskey="1" href="#CGI-Lib">CGI Lib</a>: A
simple CGI library.
-</ul>
-
- <p>Setting up a web service that allows user interaction is more difficult
and
-shows us the limits of network access in <samp><span
class="command">gawk</span></samp>. In this section,
-we develop a main program (a <code>BEGIN</code> pattern and its action)
-that will become the core of event-driven execution controlled by a
-graphical user interface (GUI).
-Each HTTP event that the user triggers by some action within the browser
-is received in this central procedure. Parameters and menu choices are
-extracted from this request, and an appropriate measure is taken according to
-the user's choice.
-For example:
-
- <p><a name="index-HTTP-server_002c-core-logic-100"></a>
-<pre class="example"> BEGIN {
- if (MyHost == "") {
- "uname -n" | getline MyHost
- close("uname -n")
- }
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- MyPrefix = "http://" MyHost ":" MyPort
- SetUpServer()
- while ("awk" != "complex") {
- # header lines are terminated this way
- RS = ORS = "\r\n"
- Status = 200 # this means OK
- Reason = "OK"
- Header = TopHeader
- Document = TopDoc
- Footer = TopFooter
- if (GETARG["Method"] == "GET") {
- HandleGET()
- } else if (GETARG["Method"] == "HEAD") {
- # not yet implemented
- } else if (GETARG["Method"] != "") {
- print "bad method", GETARG["Method"]
- }
- Prompt = Header Document Footer
- print "HTTP/1.0", Status, Reason |& HttpService
- print "Connection: Close" |& HttpService
- print "Pragma: no-cache" |& HttpService
- len = length(Prompt) + length(ORS)
- print "Content-length:", len |& HttpService
- print ORS Prompt |& HttpService
- # ignore all the header lines
- while ((HttpService |& getline) > 0)
- ;
- # stop talking to this client
- close(HttpService)
- # wait for new client request
- HttpService |& getline
- # do some logging
- print systime(), strftime(), $0
- # read request parameters
- CGI_setup($1, $2, $3)
- }
- }
-</pre>
- <p>This web server presents menu choices in the form of HTML links.
-Therefore, it has to tell the browser the name of the host it is
-residing on. When starting the server, the user may supply the name
-of the host from the command line with `<samp><span class="samp">gawk -v
MyHost="Rumpelstilzchen"</span></samp>'.
-If the user does not do this, the server looks up the name of the host it is
-running on for later use as a web address in HTML documents. The same
-applies to the port number. These values are inserted later into the
-HTML content of the web pages to refer to the home system.
-
- <p>Each server that is built around this core has to initialize some
-application-dependent variables (such as the default home page) in a procedure
-<code>SetUpServer</code>, which is called immediately before entering the
-infinite loop of the server. For now, we will write an instance that
-initiates a trivial interaction. With this home page, the client user
-can click on two possible choices, and receive the current date either
-in human-readable format or in seconds since 1970:
-
-<pre class="example"> function SetUpServer() {
- TopHeader = "<HTML><HEAD>"
- TopHeader = TopHeader \
- "<title>My name is GAWK, GNU AWK</title></HEAD>"
- TopDoc = "<BODY><h2>\
- Do you prefer your date <A HREF=" MyPrefix \
- "/human>human</A> or \
- <A HREF=" MyPrefix "/POSIX>POSIXed</A>?</h2>" ORS
ORS
- TopFooter = "</BODY></HTML>"
- }
-</pre>
- <p>On the first run through the main loop, the default line terminators are
-set and the default home page is copied to the actual home page. Since this
-is the first run, <code>GETARG["Method"]</code> is not initialized yet, hence
the
-case selection over the method does nothing. Now that the home page is
-initialized, the server can start communicating to a client browser.
-
-<!-- @cindex RFC 2068 -->
-<p>It does so by printing the HTTP header into the network connection
-(`<samp><span class="samp">print ... |& HttpService</span></samp>'). This
command blocks execution of
-the server script until a client connects. If this server
-script is compared with the primitive one we wrote before, you will notice
-two additional lines in the header. The first instructs the browser
-to close the connection after each request. The second tells the
-browser that it should never try to <em>remember</em> earlier requests
-that had identical web addresses (no caching). Otherwise, it could happen
-that the browser retrieves the time of day in the previous example just once,
-and later it takes the web page from the cache, always displaying the same
-time of day although time advances each second.
-
- <p>Having supplied the initial home page to the browser with a valid
document
-stored in the parameter <code>Prompt</code>, it closes the connection and waits
-for the next request. When the request comes, a log line is printed that
-allows us to see which request the server receives. The final step in the
-loop is to call the function <code>CGI_setup</code>, which reads all the lines
-of the request (coming from the browser), processes them, and stores the
-transmitted parameters in the array <code>PARAM</code>. The complete
-text of these application-independent functions can be found in
-<a href="#CGI-Lib">A Simple CGI Library</a>.
-For now, we use a simplified version of <code>CGI_setup</code>:
-
-<pre class="example"> function CGI_setup( method, uri, version, i) {
- delete GETARG; delete MENU; delete PARAM
- GETARG["Method"] = $1
- GETARG["URI"] = $2
- GETARG["Version"] = $3
- i = index($2, "?")
- # is there a "?" indicating a CGI request?
- if (i > 0) {
- split(substr($2, 1, i-1), MENU, "[/:]")
- split(substr($2, i+1), PARAM, "&")
- for (i in PARAM) {
- j = index(PARAM[i], "=")
- GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
- }
- } else { # there is no "?", no need for splitting PARAMs
- split($2, MENU, "[/:]")
- }
- }
-</pre>
- <p>At first, the function clears all variables used for
-global storage of request parameters. The rest of the function serves
-the purpose of filling the global parameters with the extracted new values.
-To accomplish this, the name of the requested resource is split into
-parts and stored for later evaluation. If the request contains a `<samp><span
class="samp">?</span></samp>',
-then the request has CGI variables seamlessly appended to the web address.
-Everything in front of the `<samp><span class="samp">?</span></samp>' is split
up into menu items, and
-everything behind the `<samp><span class="samp">?</span></samp>' is a list of
`<samp><var>variable</var><span class="samp">=</span><var>value</var></samp>'
pairs
-(separated by `<samp><span class="samp">&</span></samp>') that also need
splitting. This way, CGI variables are
-isolated and stored. This procedure lacks recognition of special characters
-that are transmitted in coded form<a rel="footnote" href="#fn-7"
name="fnd-7"><sup>7</sup></a>. Here, any
-optional request header and body parts are ignored. We do not need
-header parameters and the request body. However, when refining our approach or
-working with the <code>POST</code> and <code>PUT</code> methods, reading the
header
-and body
-becomes inevitable. Header parameters should then be stored in a global
-array as well as the body.
-
- <p>On each subsequent run through the main loop, one request from a browser
is
-received, evaluated, and answered according to the user's choice. This can be
-done by letting the value of the HTTP method guide the main loop into
-execution of the procedure <code>HandleGET</code>, which evaluates the user's
-choice. In this case, we have only one hierarchical level of menus,
-but in the general case,
-menus are nested.
-The menu choices at each level are
-separated by `<samp><span class="samp">/</span></samp>', just as in file
names. Notice how simple it is to
-construct menus of arbitrary depth:
-
-<pre class="example"> function HandleGET() {
- if ( MENU[2] == "human") {
- Footer = strftime() TopFooter
- } else if (MENU[2] == "POSIX") {
- Footer = systime() TopFooter
- }
- }
-</pre>
- <p>The disadvantage of this approach is that our server is slow and can
-handle only one request at a time. Its main advantage, however, is that
-the server
-consists of just one <samp><span class="command">gawk</span></samp> program.
No need for installing an
-<samp><span class="command">httpd</span></samp>, and no need for static
separate HTML files, CGI scripts, or
-<code>root</code> privileges. This is rapid prototyping.
-This program can be started on the same host that runs your browser.
-Then let your browser point to <a
href="http://localhost:8080">http://localhost:8080</a>.
-
- <p><a name="index-XBM-image-format-101"></a><a
name="index-images_002c-in-web-pages-102"></a><a
name="index-web-pages_002c-images-in-103"></a><a
name="index-GNUPlot-utility-104"></a>It is also possible to include images into
the HTML pages.
-Most browsers support the not very well-known
-<samp><span class="file">.xbm</span></samp> format,
-which may contain only
-monochrome pictures but is an ASCII format. Binary images are possible but
-not so easy to handle. Another way of including images is to generate them
-with a tool such as GNUPlot,
-by calling the tool with the <code>system</code> function or through a pipe.
-
-<div class="node">
-<p><hr>
-<a name="CGI-Lib"></a>Previous: <a rel="previous" accesskey="p"
href="#Interacting-Service">Interacting Service</a>,
-Up: <a rel="up" accesskey="u" href="#Interacting-Service">Interacting
Service</a>
-<br>
-</div>
-
-<h4 class="subsection">2.9.1 A Simple CGI Library</h4>
-
-<blockquote>
-<i>HTTP is like being married: you have to be able to handle whatever
-you're given, while being very careful what you send back.</i><br>
-Phil Smith III,<br>
-<a
href="http://www.netfunny.com/rhf/jokes/99/Mar/http.html">http://www.netfunny.com/rhf/jokes/99/Mar/http.html</a>
-</blockquote>
-
-<!-- STARTOFRANGE cgilib -->
-<p><a
name="index-CGI-_0028Common-Gateway-Interface_0029_002c-library-105"></a>In <a
href="#Interacting-Service">A Web Service with Interaction</a>,
-we saw the function <code>CGI_setup</code> as part of the web server
-“core logic” framework. The code presented there handles almost
-everything necessary for CGI requests.
-One thing it doesn't do is handle encoded characters in the requests.
-For example, an `<samp><span class="samp">&</span></samp>' is encoded as a
percent sign followed by
-the hexadecimal value: `<samp><span class="samp">%26</span></samp>'. These
encoded values should be
-decoded.
-Following is a simple library to perform these tasks.
-This code is used for all web server examples
-used throughout the rest of this web page.
-If you want to use it for your own web server, store the source code
-into a file named <samp><span class="file">inetlib.awk</span></samp>. Then you
can include
-these functions into your code by placing the following statement
-into your program
-(on the first line of your script):
-
-<pre class="example"> @include inetlib.awk
-</pre>
- <p class="noindent">But beware, this mechanism is
-only possible if you invoke your web server script with <samp><span
class="command">igawk</span></samp>
-instead of the usual <samp><span class="command">awk</span></samp> or
<samp><span class="command">gawk</span></samp>.
-Here is the code:
-
-<pre class="example"> <!-- file eg/network/coreserv.awk -->
- # CGI Library and core of a web server
- <!-- endfile -->
- <!-- file eg/network/coreserv.awk -->
- # Global arrays
- # GETARG --- arguments to CGI GET command
- # MENU --- menu items (path names)
- # PARAM --- parameters of form x=y
-
- # Optional variable MyHost contains host address
- # Optional variable MyPort contains port number
- # Needs TopHeader, TopDoc, TopFooter
- # Sets MyPrefix, HttpService, Status, Reason
-
- BEGIN {
- if (MyHost == "") {
- "uname -n" | getline MyHost
- close("uname -n")
- }
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- MyPrefix = "http://" MyHost ":" MyPort
- SetUpServer()
- while ("awk" != "complex") {
- # header lines are terminated this way
- RS = ORS = "\r\n"
- Status = 200 # this means OK
- Reason = "OK"
- Header = TopHeader
- Document = TopDoc
- Footer = TopFooter
- if (GETARG["Method"] == "GET") {
- HandleGET()
- } else if (GETARG["Method"] == "HEAD") {
- # not yet implemented
- } else if (GETARG["Method"] != "") {
- print "bad method", GETARG["Method"]
- }
- Prompt = Header Document Footer
- print "HTTP/1.0", Status, Reason |& HttpService
- print "Connection: Close" |& HttpService
- print "Pragma: no-cache" |& HttpService
- len = length(Prompt) + length(ORS)
- print "Content-length:", len |& HttpService
- print ORS Prompt |& HttpService
- # ignore all the header lines
- while ((HttpService |& getline) > 0)
- continue
- # stop talking to this client
- close(HttpService)
- # wait for new client request
- HttpService |& getline
- # do some logging
- print systime(), strftime(), $0
- CGI_setup($1, $2, $3)
- }
- }
-
- function CGI_setup( method, uri, version, i)
- {
- delete GETARG
- delete MENU
- delete PARAM
- GETARG["Method"] = method
- GETARG["URI"] = uri
- GETARG["Version"] = version
-
- i = index(uri, "?")
- if (i > 0) { # is there a "?" indicating a CGI request?
- split(substr(uri, 1, i-1), MENU, "[/:]")
- split(substr(uri, i+1), PARAM, "&")
- for (i in PARAM) {
- PARAM[i] = _CGI_decode(PARAM[i])
- j = index(PARAM[i], "=")
- GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
- }
- } else { # there is no "?", no need for splitting PARAMs
- split(uri, MENU, "[/:]")
- }
- for (i in MENU) # decode characters in path
- if (i > 4) # but not those in host name
- MENU[i] = _CGI_decode(MENU[i])
- }
- <!-- endfile -->
-</pre>
- <p>This isolates details in a single function, <code>CGI_setup</code>.
-Decoding of encoded characters is pushed off to a helper function,
-<code>_CGI_decode</code>. The use of the leading underscore (`<samp><span
class="samp">_</span></samp>') in
-the function name is intended to indicate that it is an “internal”
-function, although there is nothing to enforce this:
-
-<pre class="example"> <!-- file eg/network/coreserv.awk -->
- function _CGI_decode(str, hexdigs, i, pre, code1, code2,
- val, result)
- {
- hexdigs = "123456789abcdef"
-
- i = index(str, "%")
- if (i == 0) # no work to do
- return str
-
- do {
- pre = substr(str, 1, i-1) # part before %xx
- code1 = substr(str, i+1, 1) # first hex digit
- code2 = substr(str, i+2, 1) # second hex digit
- str = substr(str, i+3) # rest of string
-
- code1 = tolower(code1)
- code2 = tolower(code2)
- val = index(hexdigs, code1) * 16 \
- + index(hexdigs, code2)
-
- result = result pre sprintf("%c", val)
- i = index(str, "%")
- } while (i != 0)
- if (length(str) > 0)
- result = result str
- return result
- }
- <!-- endfile -->
-</pre>
- <p>This works by splitting the string apart around an encoded character.
-The two digits are converted to lowercase characters and looked up in a string
-of hex digits. Note that <code>0</code> is not in the string on purpose;
-<code>index</code> returns zero when it's not found, automatically giving
-the correct value! Once the hexadecimal value is converted from
-characters in a string into a numerical value, <code>sprintf</code>
-converts the value back into a real character.
-The following is a simple test harness for the above functions:
-
-<pre class="example"> <!-- file eg/network/testserv.awk -->
- BEGIN {
- CGI_setup("GET",
- "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \
- "&percent=a %25 sign",
- "1.0")
- for (i in MENU)
- printf "MENU[\"%s\"] = %s\n", i, MENU[i]
- for (i in PARAM)
- printf "PARAM[\"%s\"] = %s\n", i, PARAM[i]
- for (i in GETARG)
- printf "GETARG[\"%s\"] = %s\n", i, GETARG[i]
- }
- <!-- endfile -->
-</pre>
- <p>And this is the result when we run it:
-
-<!-- artificial line wrap in last output line -->
-<pre class="example"> $ gawk -f testserv.awk
- -| MENU["4"] = www.gnu.org
- -| MENU["5"] = cgi-bin
- -| MENU["6"] = foo
- -| MENU["1"] = http
- -| MENU["2"] =
- -| MENU["3"] =
- -| PARAM["1"] = p1=stuff
- -| PARAM["2"] = p2=stuff&junk
- -| PARAM["3"] = percent=a % sign
- -| GETARG["p1"] = stuff
- -| GETARG["percent"] = a % sign
- -| GETARG["p2"] = stuff&junk
- -| GETARG["Method"] = GET
- -| GETARG["Version"] = 1.0
- -| GETARG["URI"] = http://www.gnu.org/cgi-bin/foo?p1=stuff&
- p2=stuff%26junk&percent=a %25 sign
-</pre>
- <div class="node">
-<p><hr>
-<a name="Simple-Server"></a>Next: <a rel="next" accesskey="n"
href="#Caveats">Caveats</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Interacting-Service">Interacting Service</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.10 A Simple Web Server</h3>
-
-<!-- STARTOFRANGE webserx -->
-<p><a name="index-web-servers-106"></a><!-- STARTOFRANGE serweb -->
-<a name="index-servers_002c-web-107"></a>In the preceding section, we built
the core logic for event-driven GUIs.
-In this section, we finally extend the core to a real application.
-No one would actually write a commercial web server in <samp><span
class="command">gawk</span></samp>, but
-it is instructive to see that it is feasible in principle.
-
- <p><a name="index-ELIZA-program-108"></a><a
name="index-Weizenbaum_002c-Joseph-109"></a>The application is ELIZA, the
famous program by Joseph Weizenbaum that
-mimics the behavior of a professional psychotherapist when talking to you.
-Weizenbaum would certainly object to this description, but this is part of
-the legend around ELIZA.
-Take the site-independent core logic and append the following code:
-
-<pre class="example"> <!-- file eg/network/eliza.awk -->
- function SetUpServer() {
- SetUpEliza()
- TopHeader = \
- "<HTML><title>An HTTP-based System with
GAWK</title>\
- <HEAD><META HTTP-EQUIV=\"Content-Type\"\
- CONTENT=\"text/html; charset=iso-8859-1\"></HEAD>\
- <BODY BGCOLOR=\"#ffffff\" TEXT=\"#000000\"\
- LINK=\"#0000ff\" VLINK=\"#0000ff\"\
- ALINK=\"#0000ff\"> <A NAME=\"top\">"
- TopDoc = "\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI>\
- <A HREF=" MyPrefix "/AboutServer>About this server</A>\
- </LI><LI>\
- <A HREF=" MyPrefix "/AboutELIZA>About Eliza</A></LI>\
- <LI>\
- <A HREF=" MyPrefix \
- "/StartELIZA>Start talking to
Eliza</A></LI></UL>"
- TopFooter = "</BODY></HTML>"
- }
- <!-- endfile -->
-</pre>
- <p><code>SetUpServer</code> is similar to the previous example,
-except for calling another function, <code>SetUpEliza</code>.
-This approach can be used to implement other kinds of servers.
-The only changes needed to do so are hidden in the functions
-<code>SetUpServer</code> and <code>HandleGET</code>. Perhaps it might be
necessary to
-implement other HTTP methods.
-The <samp><span class="command">igawk</span></samp> program that comes with
<samp><span class="command">gawk</span></samp>
-may be useful for this process.
-
- <p>When extending this example to a complete application, the first
-thing to do is to implement the function <code>SetUpServer</code> to
-initialize the HTML pages and some variables. These initializations
-determine the way your HTML pages look (colors, titles, menu
-items, etc.).
-
- <p>The function <code>HandleGET</code> is a nested case selection that
decides
-which page the user wants to see next. Each nesting level refers to a menu
-level of the GUI. Each case implements a certain action of the menu. On the
-deepest level of case selection, the handler essentially knows what the
-user wants and stores the answer into the variable that holds the HTML
-page contents:
-
-<pre class="smallexample"> <!-- file eg/network/eliza.awk -->
- function HandleGET() {
- # A real HTTP server would treat some parts of the URI as a file name.
- # We take parts of the URI as menu choices and go on accordingly.
- if(MENU[2] == "AboutServer") {
- Document = "This is not a CGI script.\
- This is an httpd, an HTML file, and a CGI script all \
- in one GAWK script. It needs no separate www-server, \
- no installation, and no root privileges.\
- <p>To run it, do this:</p><ul>\
- <li> start this script with \"gawk -f
httpserver.awk\",</li>\
- <li> and on the same host let your www browser open location\
- \"http://localhost:8080\"</li>\
- </ul>\<p>\ Details of HTTP come
from:</p><ul>\
- <li>Hethmon: Illustrated Guide to HTTP</p>\
- <li>RFC 2068</li></ul><p>JK
14.9.1997</p>"
- } else if (MENU[2] == "AboutELIZA") {
- Document = "This is an implementation of the famous ELIZA\
- program by Joseph Weizenbaum. It is written in GAWK and\
- /bin/sh: expad: command not found
- } else if (MENU[2] == "StartELIZA") {
- gsub(/\+/, " ", GETARG["YouSay"])
- # Here we also have to substitute coded special characters
- Document = "<form method=GET>" \
- "<h3>" ElizaSays(GETARG["YouSay"]) "</h3>\
- <p><input type=text name=YouSay value=\"\" size=60>\
- <br><input type=submit value=\"Tell her about
it\"></p></form>"
- }
- }
- <!-- endfile -->
-</pre>
- <p>Now we are down to the heart of ELIZA, so you can see how it works.
-Initially the user does not say anything; then ELIZA resets its money
-counter and asks the user to tell what comes to mind open heartedly.
-The subsequent answers are converted to uppercase characters and stored for
-later comparison. ELIZA presents the bill when being confronted with
-a sentence that contains the phrase “shut up.” Otherwise, it looks
for
-keywords in the sentence, conjugates the rest of the sentence, remembers
-the keyword for later use, and finally selects an answer from the set of
-possible answers:
-
-<pre class="smallexample"> <!-- file eg/network/eliza.awk -->
- function ElizaSays(YouSay) {
- if (YouSay == "") {
- cost = 0
- answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM"
- } else {
- q = toupper(YouSay)
- gsub("'", "", q)
- if(q == qold) {
- answer = "PLEASE DONT REPEAT YOURSELF !"
- } else {
- if (index(q, "SHUT UP") > 0) {
- answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\
- int(100*rand()+30+cost/100)
- } else {
- qold = q
- w = "-" # no keyword recognized yet
- for (i in k) { # search for keywords
- if (index(q, i) > 0) {
- w = i
- break
- }
- }
- if (w == "-") { # no keyword, take old subject
- w = wold
- subj = subjold
- } else { # find subject
- subj = substr(q, index(q, w) + length(w)+1)
- wold = w
- subjold = subj # remember keyword and subject
- }
- for (i in conj)
- gsub(i, conj[i], q) # conjugation
- # from all answers to this keyword, select one randomly
- answer = r[indices[int(split(k[w], indices) * rand()) + 1]]
- # insert subject into answer
- gsub("_", subj, answer)
- }
- }
- }
- cost += length(answer) # for later payment : 1 cent per character
- return answer
- }
- <!-- endfile -->
-</pre>
- <p>In the long but simple function <code>SetUpEliza</code>, you can see
tables
-for conjugation, keywords, and answers.<a rel="footnote" href="#fn-8"
name="fnd-8"><sup>8</sup></a> The associative array <code>k</code>
-contains indices into the array of answers <code>r</code>. To choose an
-answer, ELIZA just picks an index randomly:
-
-<pre class="example"> <!-- file eg/network/eliza.awk -->
- function SetUpEliza() {
- srand()
- wold = "-"
- subjold = " "
-
- # table for conjugation
- conj[" ARE " ] = " AM "
- conj["WERE " ] = "WAS "
- conj[" YOU " ] = " I "
- conj["YOUR " ] = "MY "
- conj[" IVE " ] =\
- conj[" I HAVE " ] = " YOU HAVE "
- conj[" YOUVE " ] =\
- conj[" YOU HAVE "] = " I HAVE "
- conj[" IM " ] =\
- conj[" I AM " ] = " YOU ARE "
- conj[" YOURE " ] =\
- conj[" YOU ARE " ] = " I AM "
-
- # table of all answers
- r[1] = "DONT YOU BELIEVE THAT I CAN _"
- r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?"
- <!-- endfile -->
- ...
-</pre>
- <pre class="example"> <!-- file eg/network/eliza.awk -->
- # table for looking up answers that
- # fit to a certain keyword
- k["CAN YOU"] = "1 2 3"
- k["CAN I"] = "4 5"
- k["YOU ARE"] =\
- k["YOURE"] = "6 7 8 9"
- <!-- endfile -->
- ...
-</pre>
- <pre class="example"> <!-- file eg/network/eliza.awk -->
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-Humphrys_002c-Mark-110"></a><a
name="index-ELIZA-program-111"></a>Some interesting remarks and details
(including the original source code
-of ELIZA) are found on Mark Humphrys' home page. Yahoo! also has a
-page with a collection of ELIZA-like programs. Many of them are written
-in Java, some of them disclosing the Java source code, and a few even
-explain how to modify the Java source code.
-
-<div class="node">
-<p><hr>
-<a name="Caveats"></a>Next: <a rel="next" accesskey="n"
href="#Challenges">Challenges</a>,
-Previous: <a rel="previous" accesskey="p" href="#Simple-Server">Simple
Server</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.11 Network Programming Caveats</h3>
-
-<p><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-troubleshooting-112"></a><a
name="index-_0040command_007bgawk_007d_002c-networking_002c-troubleshooting-113"></a><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d_002c-networks-114"></a>By
now it should be clear
-that debugging a networked application is more
-complicated than debugging a single-process single-hosted application.
-The behavior of a networked application sometimes looks noncausal because
-it is not reproducible in a strong sense. Whether a network application
-works or not sometimes depends on the following:
-
- <ul>
-<li>How crowded the underlying network is
-
- <li>If the party at the other end is running or not
-
- <li>The state of the party at the other end
-</ul>
-
- <p><a name="index-troubleshooting_002c-networks_002c-timeouts-115"></a>The
most difficult problems for a beginner arise from the hidden states of the
-underlying network. After closing a TCP connection, it's often necessary to
wait
-a short while before reopening the connection. Even more difficult is the
-establishment of a connection that previously ended with a “broken
pipe.”
-Those connections have to “time out” for a minute or so
-before they can reopen.
-Check this with the command `<samp><span class="samp">netstat
-a</span></samp>', which
-provides a list of still “active” connections.
-
-<div class="node">
-<p><hr>
-<a name="Challenges"></a>Previous: <a rel="previous" accesskey="p"
href="#Caveats">Caveats</a>,
-Up: <a rel="up" accesskey="u" href="#Using-Networking">Using
Networking</a>
-<br>
-</div>
-
-<h3 class="section">2.12 Where To Go From Here</h3>
-
-<p><a name="index-Loebner_002c-Hugh-116"></a><a
name="index-contest-117"></a>Now, you have learned enough to build your own
application. You could,
-for example, take part in the
-Loebner Contest
-to win $100,000. The Loebner Prize is the first formal instantiation of
-a Turing Test. Hugh Loebner agreed with The Cambridge Center for Behavioral
-Studies to underwrite a contest designed to implement the Turing Test.
-Dr. Loebner pledged a Grand Prize of $100,000 for the first computer whose
-responses were indistinguishable from a human's. Each year an annual prize
-of $2000 and a bronze medal is awarded to the <em>most</em> human computer.
-The winner of the annual contest is the best entry relative to other entries
-that year, irrespective of how good it is in an absolute sense. Here is
-an example of a conversation with the winning program of 1997:
-
-<pre class="smallexample"> (c)1997 Cambridge Center For Behavioral Studies
all rights reserved [CONVERSE]
- [Intelligent Research Ltd.] Start at: [1997/04/29 08:59:40]
- PROGRAM[10:39:20]Hi, my name is Catherine, what's yours?
- JUDGE02[10:39:36]My name is Nathan.
- PROGRAM[10:39:37]Well, it's nice to meet you, Nathan.
- PROGRAM[10:39:45]Did you see that story on CNN last night about the
lesbian
- PROGRAM[10:40:03]couple who came out at a White House party on Sunday?
- JUDGE02[10:40:45]No. I'm sorry I missed that. How did the Prez take it?
- PROGRAM[10:40:47]Ellen Degeneres was one of them - she was kissing her
lover
- PROGRAM[10:41:08]in front of Bill Clinton. Do you think he was very
- PROGRAM[10:41:21]embarrassed?
- JUDGE02[10:41:37]You tell me. I didn't see it.
- PROGRAM[10:41:38]Are you still a Friend of Bill Clinton?
- JUDGE02[10:42:22]Yes. I would like to talk about something else. Do you
know anything about sculpture.
- PROGRAM[10:42:24]Well, I suppose he's doing his best like most of us, but
he
- PROGRAM[10:42:35]does seem to attract an UNUSUAL amount of bad publicity,
- PROGRAM[10:42:51]wouldnt you say--can it all be bad luck?
- JUDGE02[10:43:20]I asked you if you knew anything about sculpture.
- PROGRAM[10:43:21]OK, but what happens now--does it all drift on, with
- PROGRAM[10:43:36]everyone waiting to see how much his friends have said
about
- PROGRAM[10:43:47]him under threat of lots and lots of jail-or will
something
- PROGRAM[10:44:01]dramatic actually happen?
- JUDGE02[10:44:19]Do you know what sculpture is?
- PROGRAM[10:44:20]Well, youre more a fan of his than I am I guess---though
I
- PROGRAM[10:44:34]cant SWEAR what Id have done in that locked hotel room, I
- PROGRAM[10:44:51]must say.
- JUDGE02[10:45:26]Have you ever been to the Salmagundi Club?
- PROGRAM[10:45:29]Never. to go back to the original discussion Time to get
- PROGRAM[10:45:43]off this one I think and onto something more down to
earth!
- JUDGE02[10:46:20]What is more down to earth than art?
- PROGRAM[10:46:21]I don't know what -- to be honest. -
- PROGRAM[10:46:30]I suppose it depends on where you're coming from, but as
the
- PROGRAM[10:46:46]song goes in My Fair Lady, "Why can't a woman be more
like a
- PROGRAM[10:47:03]man? "
- JUDGE02[10:47:52]I liked that song but I prefer "Why can't children be
more like we are"
- JUDGE02[10:48:10]from another play the name of which I cannot remember.
- PROGRAM[10:48:12]What, if anything, do you enjoy about being a man?
- JUDGE02[10:49:01]I would enjoy all aspects of life no matter what my
gender.
- PROGRAM[10:49:02]Do you think of yourself as being attractive?
-</pre>
- <p><a name="index-Clinton_002c-Bill-118"></a>This program insists on always
speaking about the same story around Bill
-Clinton. You see, even a program with a rather narrow mind can behave so
-much like a human being that it can win this prize. It is quite common to
-let these programs talk to each other via network connections. But during the
-competition itself, the program and its computer have to be present at the
-place the competition is held. We all would love to see a <samp><span
class="command">gawk</span></samp>
-program win in such an event. Maybe it is up to you to accomplish this?
-
- <p>Some other ideas for useful networked applications:
- <ul>
-<li>Read the file <samp><span class="file">doc/awkforai.txt</span></samp> in
the <samp><span class="command">gawk</span></samp> distribution.
-It was written by Ronald P. Loui (Associate Professor of
-Computer Science, at Washington University in St. Louis,
-<a href="mailto:address@hidden">address@hidden</a>) and summarizes why
-he teaches <samp><span class="command">gawk</span></samp> to students of
Artificial Intelligence. Here are
-some passages from the text:
-
- <p><a name="index-AI-119"></a><a name="index-PROLOG-120"></a><a
name="index-Loui_002c-Ronald-121"></a><a name="index-agent-122"></a><blockquote>
-The GAWK manual can
-be consumed in a single lab session and the language can be mastered by
-the next morning by the average student. GAWK's automatic
-initialization, implicit coercion, I/O support and lack of pointers
-forgive many of the mistakes that young programmers are likely to make.
-Those who have seen C but not mastered it are happy to see that GAWK
-retains some of the same sensibilities while adding what must be
-regarded as spoonsful of syntactic sugar.<br>
-<small class="dots">...</small><br>
-<a name="index-robot-123"></a>There are further simple answers. Probably the
best is the fact that
-increasingly, undergraduate AI programming is involving the Web. Oren
-Etzioni (University of Washington, Seattle) has for a while been arguing
-that the “softbot” is replacing the mechanical engineers' robot as
the
-most glamorous AI testbed. If the artifact whose behavior needs to be
-controlled in an intelligent way is the software agent, then a language
-that is well-suited to controlling the software environment is the
-appropriate language. That would imply a scripting language. If the
-robot is KAREL, then the right language is “turn left; turn
right.” If
-the robot is Netscape, then the right language is something that can
-generate `<samp><span class="samp">netscape -remote
'openURL(http://cs.wustl.edu/~loui)'</span></samp>' with
-elan.<br>
-<small class="dots">...</small><br>
-AI programming requires high-level thinking. There have always been a few
-gifted programmers who can write high-level programs in assembly language.
-Most however need the ambient abstraction to have a higher floor.<br>
-<small class="dots">...</small><br>
-Second, inference is merely the expansion of notation. No matter whether
-the logic that underlies an AI program is fuzzy, probabilistic, deontic,
-defeasible, or deductive, the logic merely defines how strings can be
-transformed into other strings. A language that provides the best
-support for string processing in the end provides the best support for
-logic, for the exploration of various logics, and for most forms of
-symbolic processing that AI might choose to call “reasoning”
instead of
-“logic.” The implication is that PROLOG, which saves the AI
programmer
-from having to write a unifier, saves perhaps two dozen lines of GAWK
-code at the expense of strongly biasing the logic and representational
-expressiveness of any approach.
-</blockquote>
-
- <p>Now that <samp><span class="command">gawk</span></samp> itself can
connect to the Internet, it should be obvious
-that it is suitable for writing intelligent web agents.
-
- <li><samp><span class="command">awk</span></samp> is strong at pattern
recognition and string processing.
-So, it is well suited to the classic problem of language translation.
-A first try could be a program that knows the 100 most frequent English
-words and their counterparts in German or French. The service could be
-implemented by regularly reading email with the program above, replacing
-each word by its translation and sending the translation back via SMTP.
-Users would send English email to their translation service and get
-back a translated email message in return. As soon as this works,
-more effort can be spent on a real translation program.
-
- <li>Another dialogue-oriented application (on the verge
-of ridicule) is the email “support service.” Troubled customers
write an
-email to an automatic <samp><span class="command">gawk</span></samp> service
that reads the email. It looks
-for keywords in the mail and assembles a reply email accordingly. By carefully
-investigating the email header, and repeating these keywords through the
-reply email, it is rather simple to give the customer a feeling that
-someone cares. Ideally, such a service would search a database of previous
-cases for solutions. If none exists, the database could, for example, consist
-of all the newsgroups, mailing lists and FAQs on the Internet.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="Some-Applications-and-Techniques"></a>Next: <a rel="next"
accesskey="n" href="#Links">Links</a>,
-Previous: <a rel="previous" accesskey="p" href="#Using-Networking">Using
Networking</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h2 class="chapter">3 Some Applications and Techniques</h2>
-
-<p>In this chapter, we look at a number of self-contained
-scripts, with an emphasis on concise networking. Along the way, we
-work towards creating building blocks that encapsulate often needed
-functions of the networking world, show new techniques that
-broaden the scope of problems that can be solved with <samp><span
class="command">gawk</span></samp>, and
-explore leading edge technology that may shape the future of networking.
-
- <p>We often refer to the site-independent core of the server that
-we built in
-<a href="#Simple-Server">A Simple Web Server</a>.
-When building new and nontrivial servers, we
-always copy this building block and append new instances of the two
-functions <code>SetUpServer</code> and <code>HandleGET</code>.
-
- <p>This makes a lot of sense, since
-this scheme of event-driven
-execution provides <samp><span class="command">gawk</span></samp> with an
interface to the most widely
-accepted standard for GUIs: the web browser. Now, <samp><span
class="command">gawk</span></samp> can rival even
-Tcl/Tk.
-
- <p><a
name="index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-124"></a>Tcl and
<samp><span class="command">gawk</span></samp> have much in common. Both are
simple scripting languages
-that allow us to quickly solve problems with short programs. But Tcl has Tk
-on top of it, and <samp><span class="command">gawk</span></samp> had nothing
comparable up to now. While Tcl
-needs a large and ever-changing library (Tk, which was bound to the X Window
-System until recently), <samp><span class="command">gawk</span></samp> needs
just the networking interface
-and some kind of browser on the client's side. Besides better portability,
-the most important advantage of this approach (embracing well-established
-standards such HTTP and HTML) is that <em>we do not need to change the
-language</em>. We let others do the work of fighting over protocols and
standards.
-We can use HTML, JavaScript, VRML, or whatever else comes along to do our work.
-
-<ul class="menu">
-<li><a accesskey="1" href="#PANIC">PANIC</a>: An
Emergency Web Server.
-<li><a accesskey="2" href="#GETURL">GETURL</a>:
Retrieving Web Pages.
-<li><a accesskey="3" href="#REMCONF">REMCONF</a>: Remote
Configuration Of Embedded Systems.
-<li><a accesskey="4" href="#URLCHK">URLCHK</a>: Look For
Changed Web Pages.
-<li><a accesskey="5" href="#WEBGRAB">WEBGRAB</a>: Extract
Links From A Page.
-<li><a accesskey="6" href="#STATIST">STATIST</a>:
Graphing A Statistical Distribution.
-<li><a accesskey="7" href="#MAZE">MAZE</a>: Walking
Through A Maze In Virtual Reality.
-<li><a accesskey="8" href="#MOBAGWHO">MOBAGWHO</a>: A
Simple Mobile Agent.
-<li><a accesskey="9" href="#STOXPRED">STOXPRED</a>: Stock
Market Prediction As A Service.
-<li><a href="#PROTBASE">PROTBASE</a>: Searching Through A
Protein Database.
-</ul>
-
-<div class="node">
-<p><hr>
-<a name="PANIC"></a>Next: <a rel="next" accesskey="n"
href="#GETURL">GETURL</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.1 PANIC: An Emergency Web Server</h3>
-
-<p><a name="index-PANIC-program-125"></a><a
name="index-networks_002c-See-Also-web-pages-126"></a><a
name="index-web-service-127"></a>At first glance, the <code>"Hello,
world"</code> example in
-<a href="#Primitive-Service">A Primitive Web Service</a>,
-seems useless. By adding just a few lines, we can turn it into something
useful.
-
- <p>The PANIC program tells everyone who connects that the local
-site is not working. When a web server breaks down, it makes a difference
-if customers get a strange “network unreachable” message, or a
short message
-telling them that the server has a problem. In such an emergency,
-the hard disk and everything on it (including the regular web service) may
-be unavailable. Rebooting the web server off a diskette makes sense in this
-setting.
-
- <p>To use the PANIC program as an emergency web server, all you need are the
-<samp><span class="command">gawk</span></samp> executable and the program
below on a diskette. By default,
-it connects to port 8080. A different value may be supplied on the
-command line:
-
-<pre class="example"> <!-- file eg/network/panic.awk -->
- BEGIN {
- RS = ORS = "\r\n"
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- Hello = "<HTML><HEAD><TITLE>Out Of
Service</TITLE>" \
- "</HEAD><BODY><H1>" \
- "This site is temporarily out of service." \
- "</H1></BODY></HTML>"
- Len = length(Hello) + length(ORS)
- while ("awk" != "complex") {
- print "HTTP/1.0 200 OK" |& HttpService
- print "Content-Length: " Len ORS |& HttpService
- print Hello |& HttpService
- while ((HttpService |& getline) > 0)
- continue;
- close(HttpService)
- }
- }
- <!-- endfile -->
-</pre>
- <div class="node">
-<p><hr>
-<a name="GETURL"></a>Next: <a rel="next" accesskey="n"
href="#REMCONF">REMCONF</a>,
-Previous: <a rel="previous" accesskey="p" href="#PANIC">PANIC</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.2 GETURL: Retrieving Web Pages</h3>
-
-<p><a name="index-GETURL-program-128"></a><a
name="index-web-pages_002c-retrieving-129"></a>GETURL is a versatile building
block for shell scripts that need to retrieve
-files from the Internet. It takes a web address as a command-line parameter and
-tries to retrieve the contents of this address. The contents are printed
-to standard output, while the header is printed to <samp><span
class="file">/dev/stderr</span></samp>.
-A surrounding shell script
-could analyze the contents and extract the text or the links. An ASCII
-browser could be written around GETURL. But more interestingly, web robots are
-straightforward to write on top of GETURL. On the Internet, you can find
-several programs of the same name that do the same job. They are usually
-much more complex internally and at least 10 times longer.
-
- <p>At first, GETURL checks if it was called with exactly one web address.
-Then, it checks if the user chose to use a special proxy server whose name
-is handed over in a variable. By default, it is assumed that the local
-machine serves as proxy. GETURL uses the <code>GET</code> method by default
-to access the web page. By handing over the name of a different method
-(such as <code>HEAD</code>), it is possible to choose a different behavior.
With
-the <code>HEAD</code> method, the user does not receive the body of the page
-content, but does receive the header:
-
-<pre class="example"> <!-- file eg/network/geturl.awk -->
- BEGIN {
- if (ARGC != 2) {
- print "GETURL - retrieve Web page via HTTP 1.0"
- print "IN:\n the URL as a command-line parameter"
- print "PARAM(S):\n -v Proxy=MyProxy"
- print "OUT:\n the page content on stdout"
- print " the page header on stderr"
- print "JK 16.05.1997"
- print "ADR 13.08.2000"
- exit
- }
- URL = ARGV[1]; ARGV[1] = ""
- if (Proxy == "") Proxy = "127.0.0.1"
- if (ProxyPort == 0) ProxyPort = 80
- if (Method == "") Method = "GET"
- HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort
- ORS = RS = "\r\n\r\n"
- print Method " " URL " HTTP/1.0" |& HttpService
- HttpService |& getline Header
- print Header > "/dev/stderr"
- while ((HttpService |& getline) > 0)
- printf "%s", $0
- close(HttpService)
- }
- <!-- endfile -->
-</pre>
- <p>This program can be changed as needed, but be careful with the last
lines.
-Make sure transmission of binary data is not corrupted by additional line
-breaks. Even as it is now, the byte sequence <code>"\r\n\r\n"</code> would
-disappear if it were contained in binary data. Don't get caught in a
-trap when trying a quick fix on this one.
-
-<div class="node">
-<p><hr>
-<a name="REMCONF"></a>Next: <a rel="next" accesskey="n"
href="#URLCHK">URLCHK</a>,
-Previous: <a rel="previous" accesskey="p" href="#GETURL">GETURL</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.3 REMCONF: Remote Configuration of Embedded Systems</h3>
-
-<p><a name="index-REMCONF-program-130"></a><a name="index-Linux-131"></a><a
name="index-GNU_002fLinux-132"></a><a name="index-Yahoo_0021-133"></a>Today,
you often find powerful processors in embedded systems. Dedicated
-network routers and controllers for all kinds of machinery are examples
-of embedded systems. Processors like the Intel 80x86 or the AMD Elan are
-able to run multitasking operating systems, such as XINU or GNU/Linux
-in embedded PCs. These systems are small and usually do not have
-a keyboard or a display. Therefore it is difficult to set up their
-configuration. There are several widespread ways to set them up:
-
- <ul>
-<li>DIP switches
-
- <li>Read Only Memories such as EPROMs
-
- <li>Serial lines or some kind of keyboard
-
- <li>Network connections via <samp><span
class="command">telnet</span></samp> or SNMP
-
- <li>HTTP connections with HTML GUIs
-</ul>
-
- <p>In this section, we look at a solution that uses HTTP connections
-to control variables of an embedded system that are stored in a file.
-Since embedded systems have tight limits on resources like memory,
-it is difficult to employ advanced techniques such as SNMP and HTTP
-servers. <samp><span class="command">gawk</span></samp> fits in quite nicely
with its single executable
-which needs just a short script to start working.
-The following program stores the variables in a file, and a concurrent
-process in the embedded system may read the file. The program uses the
-site-independent part of the simple web server that we developed in
-<a href="#Interacting-Service">A Web Service with Interaction</a>.
-As mentioned there, all we have to do is to write two new procedures
-<code>SetUpServer</code> and <code>HandleGET</code>:
-
-<pre class="smallexample"> <!-- file eg/network/remconf.awk -->
- function SetUpServer() {
- TopHeader = "<HTML><title>Remote
Configuration</title>"
- TopDoc = "<BODY>\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this
server</A></LI>\
- <LI><A HREF=" MyPrefix "/ReadConfig>Read
Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/CheckConfig>Check
Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/ChangeConfig>Change
Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/SaveConfig>Save
Configuration</A></LI>\
- </UL>"
- TopFooter = "</BODY></HTML>"
- if (ConfigFile == "") ConfigFile = "config.asc"
- }
- <!-- endfile -->
-</pre>
- <p>The function <code>SetUpServer</code> initializes the top level HTML
texts
-as usual. It also initializes the name of the file that contains the
-configuration parameters and their values. In case the user supplies
-a name from the command line, that name is used. The file is expected to
-contain one parameter per line, with the name of the parameter in
-column one and the value in column two.
-
- <p>The function <code>HandleGET</code> reflects the structure of the menu
-tree as usual. The first menu choice tells the user what this is all
-about. The second choice reads the configuration file line by line
-and stores the parameters and their values. Notice that the record
-separator for this file is <code>"\n"</code>, in contrast to the record
separator
-for HTTP. The third menu choice builds an HTML table to show
-the contents of the configuration file just read. The fourth choice
-does the real work of changing parameters, and the last one just saves
-the configuration into a file:
-
-<pre class="smallexample"> <!-- file eg/network/remconf.awk -->
- function HandleGET() {
- if(MENU[2] == "AboutServer") {
- Document = "This is a GUI for remote configuration of an\
- embedded system. It is is implemented as one GAWK script."
- } else if (MENU[2] == "ReadConfig") {
- RS = "\n"
- while ((getline < ConfigFile) > 0)
- config[$1] = $2;
- close(ConfigFile)
- RS = "\r\n"
- Document = "Configuration has been read."
- } else if (MENU[2] == "CheckConfig") {
- Document = "<TABLE BORDER=1 CELLPADDING=5>"
- for (i in config)
- Document = Document "<TR><TD>" i "</TD>" \
- "<TD>" config[i] "</TD></TR>"
- Document = Document "</TABLE>"
- } else if (MENU[2] == "ChangeConfig") {
- if ("Param" in GETARG) { # any parameter to set?
- if (GETARG["Param"] in config) { # is parameter valid?
- config[GETARG["Param"]] = GETARG["Value"]
- Document = (GETARG["Param"] " = " GETARG["Value"] ".")
- } else {
- Document = "Parameter <b>" GETARG["Param"] "</b> is
invalid."
- }
- } else {
- Document = "<FORM method=GET><h4>Change one
parameter</h4>\
- <TABLE BORDER CELLPADDING=5>\
-
<TR><TD>Parameter</TD><TD>Value</TD></TR>\
- <TR><TD><input type=text name=Param value=\"\"
size=20></TD>\
- <TD><input type=text name=Value value=\"\"
size=40></TD>\
- </TR></TABLE><input type=submit
value=\"Set\"></FORM>"
- }
- } else if (MENU[2] == "SaveConfig") {
- for (i in config)
- printf("%s %s\n", i, config[i]) > ConfigFile
- close(ConfigFile)
- Document = "Configuration has been saved."
- }
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-MiniSQL-134"></a>We could also view the configuration
file as a database. From this
-point of view, the previous program acts like a primitive database server.
-Real SQL database systems also make a service available by providing
-a TCP port that clients can connect to. But the application level protocols
-they use are usually proprietary and also change from time to time.
-This is also true for the protocol that
-MiniSQL uses.
-
-<div class="node">
-<p><hr>
-<a name="URLCHK"></a>Next: <a rel="next" accesskey="n"
href="#WEBGRAB">WEBGRAB</a>,
-Previous: <a rel="previous" accesskey="p" href="#REMCONF">REMCONF</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.4 URLCHK: Look for Changed Web Pages</h3>
-
-<p><a name="index-URLCHK-program-135"></a>Most people who make heavy use of
Internet resources have a large
-bookmark file with pointers to interesting web sites. It is impossible
-to regularly check by hand if any of these sites have changed. A program
-is needed to automatically look at the headers of web pages and tell
-which ones have changed. URLCHK does the comparison after using GETURL
-with the <code>HEAD</code> method to retrieve the header.
-
- <p>Like GETURL, this program first checks that it is called with exactly
-one command-line parameter. URLCHK also takes the same command-line variables
-<code>Proxy</code> and <code>ProxyPort</code> as GETURL,
-because these variables are handed over to GETURL for each URL
-that gets checked. The one and only parameter is the name of a file that
-contains one line for each URL. In the first column, we find the URL, and
-the second and third columns hold the length of the URL's body when checked
-for the two last times. Now, we follow this plan:
-
- <ol type=1 start=1>
-<li>Read the URLs from the file and remember their most recent lengths
-
- <li>Delete the contents of the file
-
- <li>For each URL, check its new length and write it into the file
-
- <li>If the most recent and the new length differ, tell the user
- </ol>
-
- <p>It may seem a bit peculiar to read the URLs from a file together
-with their two most recent lengths, but this approach has several
-advantages. You can call the program again and again with the same
-file. After running the program, you can regenerate the changed URLs
-by extracting those lines that differ in their second and third columns:
-
-<!-- inspired by URLCHK in iX 5/97 166. -->
-<pre class="smallexample"> <!-- file eg/network/urlchk.awk -->
- BEGIN {
- if (ARGC != 2) {
- print "URLCHK - check if URLs have changed"
- print "IN:\n the file with URLs as a command-line parameter"
- print " file contains URL, old length, new length"
- print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080"
- print "OUT:\n same as file with URLs"
- print "JK 02.03.1998"
- exit
- }
- URLfile = ARGV[1]; ARGV[1] = ""
- if (Proxy != "") Proxy = " -v Proxy=" Proxy
- if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort
- while ((getline < URLfile) > 0)
- Length[$1] = $3 + 0
- close(URLfile) # now, URLfile is read in and can be updated
- GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk "
- for (i in Length) {
- GetThisHeader = GetHeader i " 2>&1"
- while ((GetThisHeader | getline) > 0)
- if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0
- close(GetThisHeader)
- print i, Length[i], NewLength > URLfile
- if (Length[i] != NewLength) # report only changed URLs
- print i, Length[i], NewLength
- }
- close(URLfile)
- }
- <!-- endfile -->
-</pre>
- <p>Another thing that may look strange is the way GETURL is called.
-Before calling GETURL, we have to check if the proxy variables need
-to be passed on. If so, we prepare strings that will become part
-of the command line later. In <code>GetHeader</code>, we store these strings
-together with the longest part of the command line. Later, in the loop
-over the URLs, <code>GetHeader</code> is appended with the URL and a
redirection
-operator to form the command that reads the URL's header over the Internet.
-GETURL always produces the headers over <samp><span
class="file">/dev/stderr</span></samp>. That is
-the reason why we need the redirection operator to have the header
-piped in.
-
- <p>This program is not perfect because it assumes that changing URLs
-results in changed lengths, which is not necessarily true. A more
-advanced approach is to look at some other header line that
-holds time information. But, as always when things get a bit more
-complicated, this is left as an exercise to the reader.
-
-<div class="node">
-<p><hr>
-<a name="WEBGRAB"></a>Next: <a rel="next" accesskey="n"
href="#STATIST">STATIST</a>,
-Previous: <a rel="previous" accesskey="p" href="#URLCHK">URLCHK</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.5 WEBGRAB: Extract Links from a Page</h3>
-
-<p><a name="index-WEBGRAB-program-136"></a><!-- Inspired by iX 1/98 157. -->
-<a name="index-robot-137"></a>Sometimes it is necessary to extract links from
web pages.
-Browsers do it, web robots do it, and sometimes even humans do it.
-Since we have a tool like GETURL at hand, we can solve this problem with
-some help from the Bourne shell:
-
-<pre class="example"> <!-- file eg/network/webgrab.awk -->
- BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" }
- RT != "" {
- command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \
- " > doc" NR ".html")
- print command
- }
- <!-- endfile -->
-</pre>
- <p>Notice that the regular expression for URLs is rather crude. A precise
-regular expression is much more complex. But this one works
-rather well. One problem is that it is unable to find internal links of
-an HTML document. Another problem is that
-`<samp><span class="samp">ftp</span></samp>', `<samp><span
class="samp">telnet</span></samp>', `<samp><span
class="samp">news</span></samp>', `<samp><span
class="samp">mailto</span></samp>', and other kinds
-of links are missing in the regular expression.
-However, it is straightforward to add them, if doing so is necessary for other
tasks.
-
- <p>This program reads an HTML file and prints all the HTTP links that it
finds.
-It relies on <samp><span class="command">gawk</span></samp>'s ability to use
regular expressions as record
-separators. With <code>RS</code> set to a regular expression that matches
links,
-the second action is executed each time a non-empty link is found.
-We can find the matching link itself in <code>RT</code>.
-
- <p>The action could use the <code>system</code> function to let another
GETURL
-retrieve the page, but here we use a different approach.
-This simple program prints shell commands that can be piped into <samp><span
class="command">sh</span></samp>
-for execution. This way it is possible to first extract
-the links, wrap shell commands around them, and pipe all the shell commands
-into a file. After editing the file, execution of the file retrieves
-exactly those files that we really need. In case we do not want to edit,
-we can retrieve all the pages like this:
-
-<pre class="smallexample"> gawk -f geturl.awk http://www.suse.de | gawk -f
webgrab.awk | sh
-</pre>
- <p><a name="index-Microsoft-Windows-138"></a>After this, you will find the
contents of all referenced documents in
-files named <samp><span class="file">doc*.html</span></samp> even if they do
not contain HTML code.
-The most annoying thing is that we always have to pass the proxy to
-GETURL. If you do not like to see the headers of the web pages
-appear on the screen, you can redirect them to <samp><span
class="file">/dev/null</span></samp>.
-Watching the headers appear can be quite interesting, because
-it reveals
-interesting details such as which web server the companies use.
-Now, it is clear how the clever marketing people
-use web robots to determine the
-market shares
-of Microsoft and Netscape in the web server market.
-
- <p>Port 80 of any web server is like a small hole in a repellent firewall.
-After attaching a browser to port 80, we usually catch a glimpse
-of the bright side of the server (its home page). With a tool like GETURL
-at hand, we are able to discover some of the more concealed
-or even “indecent” services (i.e., lacking conformity to standards
of quality).
-It can be exciting to see the fancy CGI scripts that lie
-there, revealing the inner workings of the server, ready to be called:
-
- <ul>
-<li>With a command such as:
-
- <pre class="example"> gawk -f geturl.awk
http://any.host.on.the.net/cgi-bin/
- </pre>
- <p>some servers give you a directory listing of the CGI files.
-Knowing the names, you can try to call some of them and watch
-for useful results. Sometimes there are executables in such directories
-(such as Perl interpreters) that you may call remotely. If there are
-subdirectories with configuration data of the web server, this can also
-be quite interesting to read.
-
- <li><a name="index-apache-139"></a>The well-known Apache web server
usually has its CGI files in the
-directory <samp><span class="file">/cgi-bin</span></samp>. There you can often
find the scripts
-<samp><span class="file">test-cgi</span></samp> and <samp><span
class="file">printenv</span></samp>. Both tell you some things
-about the current connection and the installation of the web server.
-Just call:
-
- <pre class="smallexample"> gawk -f geturl.awk
http://any.host.on.the.net/cgi-bin/test-cgi
- gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/printenv
- </pre>
- <li>Sometimes it is even possible to retrieve system files like the web
-server's log file—possibly containing customer data—or even the
file
-<samp><span class="file">/etc/passwd</span></samp>.
-(We don't recommend this!)
-</ul>
-
- <p><strong>Caution:</strong>
-Although this may sound funny or simply irrelevant, we are talking about
-severe security holes. Try to explore your own system this way and make
-sure that none of the above reveals too much information about your system.
-
-<div class="node">
-<p><hr>
-<a name="STATIST"></a>Next: <a rel="next" accesskey="n"
href="#MAZE">MAZE</a>,
-Previous: <a rel="previous" accesskey="p" href="#WEBGRAB">WEBGRAB</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.6 STATIST: Graphing a Statistical Distribution</h3>
-
-<p><a name="index-STATIST-program-140"></a>
-<a name="index-GNUPlot-utility-141"></a><a
name="index-image-format-142"></a><a name="index-GIF-image-format-143"></a><a
name="index-PNG-image-format-144"></a><a
name="index-PS-image-format-145"></a><a
name="index-Boutell_002c-Thomas-146"></a>In the HTTP server examples we've
shown thus far, we never present an image
-to the browser and its user. Presenting images is one task. Generating
-images that reflect some user input and presenting these dynamically
-generated images is another. In this section, we use GNUPlot
-for generating <samp><span class="file">.png</span></samp>, <samp><span
class="file">.ps</span></samp>, or <samp><span class="file">.gif</span></samp>
-files.<a rel="footnote" href="#fn-9" name="fnd-9"><sup>9</sup></a>
-
- <p>The program we develop takes the statistical parameters of two samples
-and computes the t-test statistics. As a result, we get the probabilities
-that the means and the variances of both samples are the same. In order to
-let the user check plausibility, the program presents an image of the
-distributions. The statistical computation follows
-<cite>Numerical Recipes in C: The Art of Scientific Computing</cite>
-by William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P.
Flannery.
-Since <samp><span class="command">gawk</span></samp> does not have a built-in
function
-for the computation of the beta function, we use the <code>ibeta</code>
function
-of GNUPlot. As a side effect, we learn how to use GNUPlot as a
-sophisticated calculator. The comparison of means is done as in
<code>tutest</code>,
-paragraph 14.2, page 613, and the comparison of variances is done as in
<code>ftest</code>,
-page 611 in <cite>Numerical Recipes</cite>.
-<a name="index-Numerical-Recipes-147"></a>
-As usual, we take the site-independent code for servers and append
-our own functions <code>SetUpServer</code> and <code>HandleGET</code>:
-
-<pre class="smallexample"> <!-- file eg/network/statist.awk -->
- function SetUpServer() {
- TopHeader = "<HTML><title>Statistics with
GAWK</title>"
- TopDoc = "<BODY>\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this
server</A></LI>\
- <LI><A HREF=" MyPrefix "/EnterParameters>Enter
Parameters</A></LI>\
- </UL>"
- TopFooter = "</BODY></HTML>"
- GnuPlot = "gnuplot 2>&1"
- m1=m2=0; v1=v2=1; n1=n2=10
- }
- <!-- endfile -->
-</pre>
- <p>Here, you see the menu structure that the user sees. Later, we
-will see how the program structure of the <code>HandleGET</code> function
-reflects the menu structure. What is missing here is the link for the
-image we generate. In an event-driven environment, request,
-generation, and delivery of images are separated.
-
- <p>Notice the way we initialize the <code>GnuPlot</code> command string for
-the pipe. By default,
-GNUPlot outputs the generated image via standard output, as well as
-the results of <code>print</code>(ed) calculations via standard error.
-The redirection causes standard error to be mixed into standard
-output, enabling us to read results of calculations with <code>getline</code>.
-By initializing the statistical parameters with some meaningful
-defaults, we make sure the user gets an image the first time
-he uses the program.
-
- <p><a name="index-JavaScript-148"></a>Following is the rather long function
<code>HandleGET</code>, which
-implements the contents of this service by reacting to the different
-kinds of requests from the browser. Before you start playing with
-this script, make sure that your browser supports JavaScript and that it also
-has this option switched on. The script uses a short snippet of
-JavaScript code for delayed opening of a window with an image.
-A more detailed explanation follows:
-
-<pre class="smallexample"> <!-- file eg/network/statist.awk -->
- function HandleGET() {
- if(MENU[2] == "AboutServer") {
- Document = "This is a GUI for a statistical computation.\
- It compares means and variances of two distributions.\
- It is implemented as one GAWK script and uses GNUPLOT."
- } else if (MENU[2] == "EnterParameters") {
- Document = ""
- if ("m1" in GETARG) { # are there parameters to compare?
- Document = Document "<SCRIPT LANGUAGE=\"JavaScript\">\
- setTimeout(\"window.open(\\\"" MyPrefix "/Image" systime()\
- "\\\",\\\"dist\\\", \\\"status=no\\\");\", 1000);
</SCRIPT>"
- m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"]
- m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"]
- t = (m1-m2)/sqrt(v1/n1+v2/n2)
- df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \
- + (v2/n2)*(v2/n2) /(n2-1))
- if (v1>v2) {
- f = v1/v2
- df1 = n1 - 1
- df2 = n2 - 1
- } else {
- f = v2/v1
- df1 = n2 - 1
- df2 = n1 - 1
- }
- print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot
- print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \
- df2/(df2+df1*f) ")" |& GnuPlot
- print "print pt, pF" |& GnuPlot
- RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF
- print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot
- print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot
- print "set term png small color" |& GnuPlot
- #print "set term postscript color" |& GnuPlot
- #print "set term gif medium size 320,240" |& GnuPlot
- print "set yrange[-0.3:]" |& GnuPlot
- print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot
- print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot
- print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\
- mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot
- print "quit" |& GnuPlot
- GnuPlot |& getline Image
- while ((GnuPlot |& getline) > 0)
- Image = Image RS $0
- close(GnuPlot)
- }
- Document = Document "\
- <h3>Do these samples have the same Gaussian
distribution?</h3>\
- <FORM METHOD=GET> <TABLE BORDER CELLPADDING=5>\
- <TR>\
- <TD>1. Mean </TD>
- <TD><input type=text name=m1 value=" m1 "
size=8></TD>\
- <TD>1. Variance</TD>
- <TD><input type=text name=v1 value=" v1 "
size=8></TD>\
- <TD>1. Count </TD>
- <TD><input type=text name=n1 value=" n1 "
size=8></TD>\
- </TR><TR>\
- <TD>2. Mean </TD>
- <TD><input type=text name=m2 value=" m2 "
size=8></TD>\
- <TD>2. Variance</TD>
- <TD><input type=text name=v2 value=" v2 "
size=8></TD>\
- <TD>2. Count </TD>
- <TD><input type=text name=n2 value=" n2 "
size=8></TD>\
- </TR> <input type=submit
value=\"Compute\">\
- </TABLE></FORM><BR>"
- } else if (MENU[2] ~ "Image") {
- Reason = "OK" ORS "Content-type: image/png"
- #Reason = "OK" ORS "Content-type: application/x-postscript"
- #Reason = "OK" ORS "Content-type: image/gif"
- Header = Footer = ""
- Document = Image
- }
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-PostScript-149"></a>As usual, we give a short description
of the service in the first
-menu choice. The third menu choice shows us that generation and
-presentation of an image are two separate actions. While the latter
-takes place quite instantly in the third menu choice, the former
-takes place in the much longer second choice. Image data passes from the
-generating action to the presenting action via the variable <code>Image</code>
-that contains a complete <samp><span class="file">.png</span></samp> image,
which is otherwise stored
-in a file. If you prefer <samp><span class="file">.ps</span></samp> or
<samp><span class="file">.gif</span></samp> images over the
-default <samp><span class="file">.png</span></samp> images, you may select
these options by uncommenting
-the appropriate lines. But remember to do so in two places: when
-telling GNUPlot which kind of images to generate, and when transmitting the
-image at the end of the program.
-
- <p>Looking at the end of the program,
-the way we pass the `<samp><span class="samp">Content-type</span></samp>' to
the browser is a bit unusual.
-It is appended to the `<samp><span class="samp">OK</span></samp>' of the first
header line
-to make sure the type information becomes part of the header.
-The other variables that get transmitted across the network are
-made empty, because in this case we do not have an HTML document to
-transmit, but rather raw image data to contain in the body.
-
- <p>Most of the work is done in the second menu choice. It starts with a
-strange JavaScript code snippet. When first implementing this server,
-we used a short <code>"<IMG SRC="<!-- /@w --> MyPrefix
"/Image>"</code> here. But then
-browsers got smarter and tried to improve on speed by requesting the
-image and the HTML code at the same time. When doing this, the browser
-tries to build up a connection for the image request while the request for
-the HTML text is not yet completed. The browser tries to connect
-to the <samp><span class="command">gawk</span></samp> server on port 8080
while port 8080 is still in use for
-transmission of the HTML text. The connection for the image cannot be
-built up, so the image appears as “broken” in the browser window.
-We solved this problem by telling the browser to open a separate window
-for the image, but only after a delay of 1000 milliseconds.
-By this time, the server should be ready for serving the next request.
-
- <p>But there is one more subtlety in the JavaScript code.
-Each time the JavaScript code opens a window for the image, the
-name of the image is appended with a timestamp (<code>systime</code>).
-Why this constant change of name for the image? Initially, we always named
-the image <code>Image</code>, but then the Netscape browser noticed the name
-had <em>not</em> changed since the previous request and displayed the
-previous image (caching behavior). The server core
-is implemented so that browsers are told <em>not</em> to cache anything.
-Obviously HTTP requests do not always work as expected. One way to
-circumvent the cache of such overly smart browsers is to change the
-name of the image with each request. These three lines of JavaScript
-caused us a lot of trouble.
-
- <p>The rest can be broken
-down into two phases. At first, we check if there are statistical
-parameters. When the program is first started, there usually are no
-parameters because it enters the page coming from the top menu.
-Then, we only have to present the user a form that he can use to change
-statistical parameters and submit them. Subsequently, the submission of
-the form causes the execution of the first phase because <em>now</em>
-there <em>are</em> parameters to handle.
-
- <p>Now that we have parameters, we know there will be an image available.
-Therefore we insert the JavaScript code here to initiate the opening
-of the image in a separate window. Then,
-we prepare some variables that will be passed to GNUPlot for calculation
-of the probabilities. Prior to reading the results, we must temporarily
-change <code>RS</code> because GNUPlot separates lines with newlines.
-After instructing GNUPlot to generate a <samp><span
class="file">.png</span></samp> (or <samp><span class="file">.ps</span></samp>
or
-<samp><span class="file">.gif</span></samp>) image, we initiate the insertion
of some text,
-explaining the resulting probabilities. The final `<samp><span
class="samp">plot</span></samp>' command
-actually generates the image data. This raw binary has to be read in carefully
-without adding, changing, or deleting a single byte. Hence the unusual
-initialization of <code>Image</code> and completion with a <code>while</code>
loop.
-
- <p>When using this server, it soon becomes clear that it is far from being
-perfect. It mixes source code of six scripting languages or protocols:
-
- <ul>
-<li>GNU <samp><span class="command">awk</span></samp> implements a server for
the protocol:
-<li>HTTP which transmits:
-<li>HTML text which contains a short piece of:
-<li>JavaScript code opening a separate window.
-<li>A Bourne shell script is used for piping commands into:
-<li>GNUPlot to generate the image to be opened.
-</ul>
-
- <p>After all this work, the GNUPlot image opens in the JavaScript window
-where it can be viewed by the user.
-
- <p>It is probably better not to mix up so many different languages.
-The result is not very readable. Furthermore, the
-statistical part of the server does not take care of invalid input.
-Among others, using negative variances will cause invalid results.
-
-<div class="node">
-<p><hr>
-<a name="MAZE"></a>Next: <a rel="next" accesskey="n"
href="#MOBAGWHO">MOBAGWHO</a>,
-Previous: <a rel="previous" accesskey="p" href="#STATIST">STATIST</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.7 MAZE: Walking Through a Maze In Virtual Reality</h3>
-
-<p><a name="index-MAZE-150"></a><a name="index-VRML-151"></a><!-- VRML in iX
11/96 134. -->
-<blockquote>
-<a name="index-Perlis_002c-Alan-152"></a><i>In the long run, every program
becomes rococo, and then rubble.</i><br>
-Alan Perlis
-</blockquote>
-
- <p>By now, we know how to present arbitrary `<samp><span
class="samp">Content-type</span></samp>'s to a browser.
-In this section, our server will present a 3D world to our browser.
-The 3D world is described in a scene description language (VRML,
-Virtual Reality Modeling Language) that allows us to travel through a
-perspective view of a 2D maze with our browser. Browsers with a
-VRML plugin enable exploration of this technology. We could do
-one of those boring `<samp><span class="samp">Hello world</span></samp>'
examples here, that are usually
-presented when introducing novices to
-VRML. If you have never written
-any VRML code, have a look at
-the VRML FAQ.
-Presenting a static VRML scene is a bit trivial; in order to expose
-<samp><span class="command">gawk</span></samp>'s new capabilities, we will
present a dynamically generated
-VRML scene. The function <code>SetUpServer</code> is very simple because it
-only sets the default HTML page and initializes the random number
-generator. As usual, the surrounding server lets you browse the maze.
-
-<pre class="smallexample"> <!-- file eg/network/maze.awk -->
- function SetUpServer() {
- TopHeader = "<HTML><title>Walk through a maze</title>"
- TopDoc = "\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this
server</A>\
- <LI><A HREF=" MyPrefix "/VRMLtest>Watch a simple VRML
scene</A>\
- </UL>"
- TopFooter = "</HTML>"
- srand()
- }
- <!-- endfile -->
-</pre>
- <p>The function <code>HandleGET</code> is a bit longer because it first
computes
-the maze and afterwards generates the VRML code that is sent across
-the network. As shown in the STATIST example
-(see <a href="#STATIST">STATIST</a>),
-we set the type of the
-content to VRML and then store the VRML representation of the maze as the
-page content. We assume that the maze is stored in a 2D array. Initially,
-the maze consists of walls only. Then, we add an entry and an exit to the
-maze and let the rest of the work be done by the function
<code>MakeMaze</code>.
-Now, only the wall fields are left in the maze. By iterating over the these
-fields, we generate one line of VRML code for each wall field.
-
-<pre class="smallexample"> <!-- file eg/network/maze.awk -->
- function HandleGET() {
- if (MENU[2] == "AboutServer") {
- Document = "If your browser has a VRML 2 plugin,\
- this server shows you a simple VRML scene."
- } else if (MENU[2] == "VRMLtest") {
- XSIZE = YSIZE = 11 # initially, everything is wall
- for (y = 0; y < YSIZE; y++)
- for (x = 0; x < XSIZE; x++)
- Maze[x, y] = "#"
- delete Maze[0, 1] # entry is not wall
- delete Maze[XSIZE-1, YSIZE-2] # exit is not wall
- MakeMaze(1, 1)
- Document = "\
- #VRML V2.0 utf8\n\
- Group {\n\
- children [\n\
- PointLight {\n\
- ambientIntensity 0.2\n\
- color 0.7 0.7 0.7\n\
- location 0.0 8.0 10.0\n\
- }\n\
- DEF B1 Background {\n\
- skyColor [0 0 0, 1.0 1.0 1.0 ]\n\
- skyAngle 1.6\n\
- groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\
- groundAngle [ 1.2 1.57 ]\n\
- }\n\
- DEF Wall Shape {\n\
- geometry Box {size 1 1 1}\n\
- appearance Appearance { material Material { diffuseColor 0 0 1 }
}\n\
- }\n\
- DEF Entry Viewpoint {\n\
- position 0.5 1.0 5.0\n\
- orientation 0.0 0.0 -1.0 0.52\n\
- }\n"
- for (i in Maze) {
- split(i, t, SUBSEP)
- Document = Document " Transform { translation "
- Document = Document t[1] " 0 -" t[2] " children USE Wall }\n"
- }
- Document = Document " ] # end of group for world\n}"
- Reason = "OK" ORS "Content-type: model/vrml"
- Header = Footer = ""
- }
- }
- <!-- endfile -->
-</pre>
- <p>Finally, we have a look at <code>MakeMaze</code>, the function that
generates
-the <code>Maze</code> array. When entered, this function assumes that the array
-has been initialized so that each element represents a wall element and
-the maze is initially full of wall elements. Only the entrance and the exit
-of the maze should have been left free. The parameters of the function tell
-us which element must be marked as not being a wall. After this, we take
-a look at the four neighbouring elements and remember which we have already
-treated. Of all the neighbouring elements, we take one at random and
-walk in that direction. Therefore, the wall element in that direction has
-to be removed and then, we call the function recursively for that element.
-The maze is only completed if we iterate the above procedure for
-<em>all</em> neighbouring elements (in random order) and for our present
-element by recursively calling the function for the present element. This
-last iteration could have been done in a loop,
-but it is done much simpler recursively.
-
- <p>Notice that elements with coordinates that are both odd are assumed to be
-on our way through the maze and the generating process cannot terminate
-as long as there is such an element not being <code>delete</code>d. All other
-elements are potentially part of the wall.
-
-<pre class="smallexample"> <!-- file eg/network/maze.awk -->
- function MakeMaze(x, y) {
- delete Maze[x, y] # here we are, we have no wall here
- p = 0 # count unvisited fields in all directions
- if (x-2 SUBSEP y in Maze) d[p++] = "-x"
- if (x SUBSEP y-2 in Maze) d[p++] = "-y"
- if (x+2 SUBSEP y in Maze) d[p++] = "+x"
- if (x SUBSEP y+2 in Maze) d[p++] = "+y"
- if (p>0) { # if there are univisited fields, go there
- p = int(p*rand()) # choose one unvisited field at random
- if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y)
- } else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2)
- } else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y)
- } else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2)
- } # we are back from recursion
- MakeMaze(x, y); # try again while there are unvisited fields
- }
- }
- <!-- endfile -->
-</pre>
- <div class="node">
-<p><hr>
-<a name="MOBAGWHO"></a>Next: <a rel="next" accesskey="n"
href="#STOXPRED">STOXPRED</a>,
-Previous: <a rel="previous" accesskey="p" href="#MAZE">MAZE</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.8 MOBAGWHO: a Simple Mobile Agent</h3>
-
-<p><a name="index-MOBAGWHO-program-153"></a><a
name="index-agent-154"></a><blockquote>
-<a name="index-Hoare_002c-C_002eA_002eR_002e-155"></a><i>There are two ways of
constructing a software design: One way is to
-make it so simple that there are obviously no deficiencies, and the
-other way is to make it so complicated that there are no obvious
-deficiencies.</i> <br>
-C. A. R. Hoare
-</blockquote>
-
- <p>A <dfn>mobile agent</dfn> is a program that can be dispatched from a
computer and
-transported to a remote server for execution. This is called
<dfn>migration</dfn>,
-which means that a process on another system is started that is independent
-from its originator. Ideally, it wanders through
-a network while working for its creator or owner. In places like
-the UMBC Agent Web,
-people are quite confident that (mobile) agents are a software engineering
-paradigm that enables us to significantly increase the efficiency
-of our work. Mobile agents could become the mediators between users and
-the networking world. For an unbiased view at this technology,
-see the remarkable paper <cite>Mobile Agents: Are they a good
-idea?</cite>.<a rel="footnote" href="#fn-10" name="fnd-10"><sup>10</sup></a>
-
- <p>When trying to migrate a process from one system to another,
-a server process is needed on the receiving side. Depending on the kind
-of server process, several ways of implementation come to mind.
-How the process is implemented depends upon the kind of server process:
-
- <ul>
-<li>HTTP can be used as the protocol for delivery of the migrating
-process. In this case, we use a common web
-server as the receiving server process. A universal CGI script
-mediates between migrating process and web server.
-Each server willing to accept migrating agents makes this universal
-service available. HTTP supplies the <code>POST</code> method to transfer
-some data to a file on the web server. When a CGI script is called
-remotely with the <code>POST</code> method instead of the usual
<code>GET</code> method,
-data is transmitted from the client process to the standard input
-of the server's CGI script. So, to implement a mobile agent,
-we must not only write the agent program to start on the client
-side, but also the CGI script to receive the agent on the server side.
-
- <p><a name="index-CGI-_0028Common-Gateway-Interface_0029-156"></a><a
name="index-apache-157"></a><li>The <code>PUT</code> method can also be used
for migration. HTTP does not
-require a CGI script for migration via <code>PUT</code>. However, with common
web
-servers there is no advantage to this solution, because web servers such as
-Apache
-require explicit activation of a special <code>PUT</code> script.
-
- <li><cite>Agent Tcl</cite> pursues a different course; it relies on a
dedicated server
-process with a dedicated protocol specialized for receiving mobile agents.
-</ul>
-
- <p>Our agent example abuses a common web server as a migration tool. So, it
needs a
-universal CGI script on the receiving side (the web server). The receiving
script is
-activated with a <code>POST</code> request when placed into a location like
-<samp><span class="file">/httpd/cgi-bin/PostAgent.sh</span></samp>. Make sure
that the server system uses a
-version of <samp><span class="command">gawk</span></samp> that supports
network access (Version 3.1 or later;
-verify with `<samp><span class="samp">gawk --version</span></samp>').
-
-<pre class="example"> <!-- file eg/network/PostAgent.sh -->
- #!/bin/sh
- MobAg=/tmp/MobileAgent.$$
- # direct script to mobile agent file
- cat > $MobAg
- # execute agent concurrently
- gawk -f $MobAg $MobAg > /dev/null &
- # HTTP header, terminator and body
- gawk 'BEGIN { print "\r\nAgent started" }'
- rm $MobAg # delete script file of agent
- <!-- endfile -->
-</pre>
- <p>By making its process id (<code>$$</code>) part of the unique file name,
the
-script avoids conflicts between concurrent instances of the script.
-First, all lines
-from standard input (the mobile agent's source code) are copied into
-this unique file. Then, the agent is started as a concurrent process
-and a short message reporting this fact is sent to the submitting client.
-Finally, the script file of the mobile agent is removed because it is
-no longer needed. Although it is a short script, there are several noteworthy
-points:
-
- <dl>
-<dt>Security<dd><em>There is none</em>. In fact, the CGI script should never
-be made available on a server that is part of the Internet because everyone
-would be allowed to execute arbitrary commands with it. This behavior is
-acceptable only when performing rapid prototyping.
-
- <br><dt>Self-Reference<dd>Each migrating instance of an agent is started
-in a way that enables it to read its own source code from standard input
-and use the code for subsequent
-migrations. This is necessary because it needs to treat the agent's code
-as data to transmit. <samp><span class="command">gawk</span></samp> is not the
ideal language for such
-a job. Lisp and Tcl are more suitable because they do not make a distinction
-between program code and data.
-
- <br><dt>Independence<dd>After migration, the agent is not linked to its
-former home in any way. By reporting `<samp><span class="samp">Agent
started</span></samp>', it waves
-“Goodbye” to its origin. The originator may choose to terminate or
not.
-</dl>
-
- <p><a name="index-Lisp-158"></a>The originating agent itself is started
just like any other command-line
-script, and reports the results on standard output. By letting the name
-of the original host migrate with the agent, the agent that migrates
-to a host far away from its origin can report the result back home.
-Having arrived at the end of the journey, the agent establishes
-a connection and reports the results. This is the reason for
-determining the name of the host with `<samp><span class="samp">uname
-n</span></samp>' and storing it
-in <code>MyOrigin</code> for later use. We may also set variables with the
-<samp><span class="option">-v</span></samp> option from the command line. This
interactivity is only
-of importance in the context of starting a mobile agent; therefore this
-<code>BEGIN</code> pattern and its action do not take part in migration:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- BEGIN {
- if (ARGC != 2) {
- print "MOBAG - a simple mobile agent"
- print "CALL:\n gawk -f mobag.awk mobag.awk"
- print "IN:\n the name of this script as a command-line parameter"
- print "PARAM:\n -v MyOrigin=myhost.com"
- print "OUT:\n the result on stdout"
- print "JK 29.03.1998 01.04.1998"
- exit
- }
- if (MyOrigin == "") {
- "uname -n" | getline MyOrigin
- close("uname -n")
- }
- }
- <!-- endfile -->
-</pre>
- <p>Since <samp><span class="command">gawk</span></samp> cannot manipulate
and transmit parts of the program
-directly, the source code is read and stored in strings.
-Therefore, the program scans itself for
-the beginning and the ending of functions.
-Each line in between is appended to the code string until the end of
-the function has been reached. A special case is this part of the program
-itself. It is not a function.
-Placing a similar framework around it causes it to be treated
-like a function. Notice that this mechanism works for all the
-functions of the source code, but it cannot guarantee that the order
-of the functions is preserved during migration:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- #ReadMySelf
- /^function / { FUNC = $2 }
- /^END/ || /^#ReadMySelf/ { FUNC = $1 }
- FUNC != "" { MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 }
- (FUNC != "") && (/^}/ || /^#EndOfMySelf/) \
- { FUNC = "" }
- #EndOfMySelf
- <!-- endfile -->
-</pre>
- <p>The web server code in
-<a href="#Interacting-Service">A Web Service with Interaction</a>,
-was first developed as a site-independent core. Likewise, the
-<samp><span class="command">gawk</span></samp>-based mobile agent
-starts with an agent-independent core, to which can be appended
-application-dependent functions. What follows is the only
-application-independent function needed for the mobile agent:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- function migrate(Destination, MobCode, Label) {
- MOBVAR["Label"] = Label
- MOBVAR["Destination"] = Destination
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/0/" Destination
- for (i in MOBFUN)
- MobCode = (MobCode "\n" MOBFUN[i])
- MobCode = MobCode "\n\nBEGIN {"
- for (i in MOBVAR)
- MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"")
- MobCode = MobCode "\n}\n"
- print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService
- print "Content-length:", length(MobCode) ORS |& HttpService
- printf "%s", MobCode |& HttpService
- while ((HttpService |& getline) > 0)
- print $0
- close(HttpService)
- }
- <!-- endfile -->
-</pre>
- <p>The <code>migrate</code> function prepares the
-aforementioned strings containing the program code and transmits them to a
-server. A consequence of this modular approach is that the <code>migrate</code>
-function takes some parameters that aren't needed in this application,
-but that will be in future ones. Its mandatory parameter
<code>Destination</code> holds the
-name (or IP address) of the server that the agent wants as a host for its
-code. The optional parameter <code>MobCode</code> may contain some <samp><span
class="command">gawk</span></samp>
-code that is inserted during migration in front of all other code.
-The optional parameter <code>Label</code> may contain
-a string that tells the agent what to do in program execution after
-arrival at its new home site. One of the serious obstacles in implementing
-a framework for mobile agents is that it does not suffice to migrate the
-code. It is also necessary to migrate the state of execution of the agent. In
-contrast to <cite>Agent Tcl</cite>, this program does not try to migrate the
complete set
-of variables. The following conventions are used:
-
- <ul>
-<li>Each variable in an agent program is local to the current host and does
-<em>not</em> migrate.
-
- <li>The array <code>MOBFUN</code> shown above is an exception. It is
handled
-by the function <code>migrate</code> and does migrate with the application.
-
- <li>The other exception is the array <code>MOBVAR</code>. Each variable
that
-takes part in migration has to be an element of this array.
-<code>migrate</code> also takes care of this.
-</ul>
-
- <p>Now it's clear what happens to the <code>Label</code> parameter of the
-function <code>migrate</code>. It is copied into <code>MOBVAR["Label"]</code>
and
-travels alongside the other data. Since travelling takes place via HTTP,
-records must be separated with <code>"\r\n"</code> in <code>RS</code> and
-<code>ORS</code> as usual. The code assembly for migration takes place in
-three steps:
-
- <ul>
-<li>Iterate over <code>MOBFUN</code> to collect all functions verbatim.
-
- <li>Prepare a <code>BEGIN</code> pattern and put assignments to mobile
-variables into the action part.
-
- <li>Transmission itself resembles GETURL: the header with the request
-and the <code>Content-length</code> is followed by the body. In case there is
-any reply over the network, it is read completely and echoed to
-standard output to avoid irritating the server.
-</ul>
-
- <p>The application-independent framework is now almost complete. What
follows
-is the <code>END</code> pattern that is executed when the mobile agent has
-finished reading its own code. First, it checks whether it is already
-running on a remote host or not. In case initialization has not yet taken
-place, it starts <code>MyInit</code>. Otherwise (later, on a remote host), it
-starts <code>MyJob</code>:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- END {
- if (ARGC != 2) exit # stop when called with wrong parameters
- if (MyOrigin != "") # is this the originating host?
- MyInit() # if so, initialize the application
- else # we are on a host with migrated data
- MyJob() # so we do our job
- }
- <!-- endfile -->
-</pre>
- <p>All that's left to extend the framework into a complete application
-is to write two application-specific functions: <code>MyInit</code> and
-<code>MyJob</code>. Keep in mind that the former is executed once on the
-originating host, while the latter is executed after each migration:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- function MyInit() {
- MOBVAR["MyOrigin"] = MyOrigin
- MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80"
- split(MOBVAR["Machines"], Machines) # which host is the first?
- migrate(Machines[1], "", "") # go to the first host
- while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result
- print $0 # print result
- close("/inet/tcp/8080/0/0")
- }
- <!-- endfile -->
-</pre>
- <p>As mentioned earlier, this agent takes the name of its origin
-(<code>MyOrigin</code>) with it. Then, it takes the name of its first
-destination and goes there for further work. Notice that this name has
-the port number of the web server appended to the name of the server,
-because the function <code>migrate</code> needs it this way to create
-the <code>HttpService</code> variable. Finally, it waits for the result to
arrive.
-The <code>MyJob</code> function runs on the remote host:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- function MyJob() {
- # forget this host
- sub(MOBVAR["Destination"], "", MOBVAR["Machines"])
- MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"]
":"
- while (("who" | getline) > 0) # who is logged in?
- MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0
- close("who")
- if (index(MOBVAR["Machines"], "/") > 0) { # any more machines to
visit?
- split(MOBVAR["Machines"], Machines) # which host is next?
- migrate(Machines[1], "", "") # go there
- } else { # no more machines
- gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin
- print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"]
"/8080"
- close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080")
- }
- }
- <!-- endfile -->
-</pre>
- <p>After migrating, the first thing to do in <code>MyJob</code> is to delete
-the name of the current host from the list of hosts to visit. Now, it
-is time to start the real work by appending the host's name to the
-result string, and reading line by line who is logged in on this host.
-A very annoying circumstance is the fact that the elements of
-<code>MOBVAR</code> cannot hold the newline character (<code>"\n"</code>). If
they
-did, migration of this string did not work because the string didn't
-obey the syntax rule for a string in <samp><span
class="command">gawk</span></samp>.
-<code>SUBSEP</code> is used as a temporary replacement.
-If the list of hosts to visit holds
-at least one more entry, the agent migrates to that place to go on
-working there. Otherwise, we replace the <code>SUBSEP</code>s
-with a newline character in the resulting string, and report it to
-the originating host, whose name is stored in <code>MOBVAR["MyOrigin"]</code>.
-
-<div class="node">
-<p><hr>
-<a name="STOXPRED"></a>Next: <a rel="next" accesskey="n"
href="#PROTBASE">PROTBASE</a>,
-Previous: <a rel="previous" accesskey="p" href="#MOBAGWHO">MOBAGWHO</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.9 STOXPRED: Stock Market Prediction As A Service</h3>
-
-<p><a name="index-STOXPRED-program-159"></a><a
name="index-Yahoo_0021-160"></a><blockquote>
-<i>Far out in the uncharted backwaters of the unfashionable end of
-the Western Spiral arm of the Galaxy lies a small unregarded yellow sun.</i>
-
- <p><i>Orbiting this at a distance of roughly ninety-two million miles
is an
-utterly insignificant little blue-green planet whose ape-descendent life
-forms are so amazingly primitive that they still think digital watches are
-a pretty neat idea.</i>
-
- <p><i>This planet has — or rather had — a problem, which
was this:
-most of the people living on it were unhappy for pretty much of the time.
-Many solutions were suggested for this problem, but most of these were
-largely concerned with the movements of small green pieces of paper,
-which is odd because it wasn't the small green pieces of paper that
-were unhappy.</i> <br>
-Douglas Adams, <cite>The Hitch Hiker's Guide to the Galaxy</cite>
-</blockquote>
-
- <p><a name="index-_0040command_007bcron_007d-utility-161"></a>Valuable
services on the Internet are usually <em>not</em> implemented
-as mobile agents. There are much simpler ways of implementing services.
-All Unix systems provide, for example, the <samp><span
class="command">cron</span></samp> service.
-Unix system users can write a list of tasks to be done each day, each
-week, twice a day, or just once. The list is entered into a file named
-<samp><span class="file">crontab</span></samp>. For example, to distribute a
newsletter on a daily
-basis this way, use <samp><span class="command">cron</span></samp> for calling
a script each day early
-in the morning.
-
-<pre class="example"> # run at 8 am on weekdays, distribute the newsletter
- 0 8 * * 1-5 $HOME/bin/daily.job >> $HOME/log/newsletter
2>&1
-</pre>
- <p>The script first looks for interesting information on the Internet,
-assembles it in a nice form and sends the results via email to
-the customers.
-
- <p>The following is an example of a primitive
-newsletter on stock market prediction. It is a report which first
-tries to predict the change of each share in the Dow Jones Industrial
-Index for the particular day. Then it mentions some especially
-promising shares as well as some shares which look remarkably bad
-on that day. The report ends with the usual disclaimer which tells
-every child <em>not</em> to try this at home and hurt anybody.
-<a name="index-Dow-Jones-Industrial-Index-162"></a>
-<pre class="smallexample"> Good morning Uncle Scrooge,
-
- This is your daily stock market report for Monday, October 16, 2000.
- Here are the predictions for today:
-
- AA neutral
- GE up
- JNJ down
- MSFT neutral
- ...
- UTX up
- DD down
- IBM up
- MO down
- WMT up
- DIS up
- INTC up
- MRK down
- XOM down
- EK down
- IP down
-
- The most promising shares for today are these:
-
- INTC http://biz.yahoo.com/n/i/intc.html
-
- The stock shares to avoid today are these:
-
- EK http://biz.yahoo.com/n/e/ek.html
- IP http://biz.yahoo.com/n/i/ip.html
- DD http://biz.yahoo.com/n/d/dd.html
- ...
-</pre>
- <p>The script as a whole is rather long. In order to ease the pain of
-studying other people's source code, we have broken the script
-up into meaningful parts which are invoked one after the other.
-The basic structure of the script is as follows:
-
-<pre class="example"> <!-- file eg/network/stoxpred.awk -->
- BEGIN {
- Init()
- ReadQuotes()
- CleanUp()
- Prediction()
- Report()
- SendMail()
- }
- <!-- endfile -->
-</pre>
- <p>The earlier parts store data into variables and arrays which are
-subsequently used by later parts of the script. The <code>Init</code> function
-first checks if the script is invoked correctly (without any parameters).
-If not, it informs the user of the correct usage. What follows are preparations
-for the retrieval of the historical quote data. The names of the 30 stock
-shares are stored in an array <code>name</code> along with the current date
-in <code>day</code>, <code>month</code>, and <code>year</code>.
-
- <p>All users who are separated
-from the Internet by a firewall and have to direct their Internet accesses
-to a proxy must supply the name of the proxy to this script with the
-`<samp><span class="samp">-v Proxy=</span><var>name</var></samp>' option. For
most users, the default proxy and
-port number should suffice.
-
-<pre class="example"> <!-- file eg/network/stoxpred.awk -->
- function Init() {
- if (ARGC != 1) {
- print "STOXPRED - daily stock share prediction"
- print "IN:\n no parameters, nothing on stdin"
- print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80"
- print "OUT:\n commented predictions as email"
- print "JK 09.10.2000"
- exit
- }
- # Remember ticker symbols from Dow Jones Industrial Index
- StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \
- SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \
- MRK XOM EK IP", name);
- # Remember the current date as the end of the time series
- day = strftime("%d")
- month = strftime("%m")
- year = strftime("%Y")
- if (Proxy == "") Proxy = "chart.yahoo.com"
- if (ProxyPort == 0) ProxyPort = 80
- YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-CSV-format-163"></a>There are two really interesting
parts in the script. One is the
-function which reads the historical stock quotes from an Internet
-server. The other is the one that does the actual prediction. In
-the following function we see how the quotes are read from the
-Yahoo server. The data which comes from the server is in
-CSV format (comma-separated values):
-
-<pre class="example"> <!-- file eg/network/stoxdata.txt -->
- Date,Open,High,Low,Close,Volume
- 9-Oct-00,22.75,22.75,21.375,22.375,7888500
- 6-Oct-00,23.8125,24.9375,21.5625,22,10701100
- 5-Oct-00,24.4375,24.625,23.125,23.50,5810300
- <!-- endfile -->
-</pre>
- <p>Lines contain values of the same time instant, whereas columns are
-separated by commas and contain the kind of data that is described
-in the header (first) line. At first, <samp><span
class="command">gawk</span></samp> is instructed to
-separate columns by commas (`<samp><span class="samp">FS =
","</span></samp>'). In the loop that follows,
-a connection to the Yahoo server is first opened, then a download takes
-place, and finally the connection is closed. All this happens once for
-each ticker symbol. In the body of this loop, an Internet address is
-built up as a string according to the rules of the Yahoo server. The
-starting and ending date are chosen to be exactly the same, but one year
-apart in the past. All the action is initiated within the <code>printf</code>
-command which transmits the request for data to the Yahoo server.
-
- <p>In the inner loop, the server's data is first read and then scanned
-line by line. Only lines which have six columns and the name of a month
-in the first column contain relevant data. This data is stored
-in the two-dimensional array <code>quote</code>; one dimension
-being time, the other being the ticker symbol. During retrieval of the
-first stock's data, the calendar names of the time instances are stored
-in the array <code>day</code> because we need them later.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function ReadQuotes() {
- # Retrieve historical data for each ticker symbol
- FS = ","
- for (stock = 1; stock <= StockCount; stock++) {
- URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \
- "&a=" month "&b=" day "&c=" year-1 \
- "&d=" month "&e=" day "&f=" year \
- "g=d&q=q&y=0&z=" name[stock] "&x=.csv"
- printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData
- while ((YahooData |& getline) > 0) {
- if (NF == 6 && $1 ~
/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) {
- if (stock == 1)
- days[++daycount] = $1;
- quote[$1, stock] = $5
- }
- }
- close(YahooData)
- }
- FS = " "
- }
- <!-- endfile -->
-</pre>
- <p>Now that we <em>have</em> the data, it can be checked once again to make
sure
-that no individual stock is missing or invalid, and that all the stock quotes
are
-aligned correctly. Furthermore, we renumber the time instances. The
-most recent day gets day number 1 and all other days get consecutive
-numbers. All quotes are rounded toward the nearest whole number in US Dollars.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function CleanUp() {
- # clean up time series; eliminate incomplete data sets
- for (d = 1; d <= daycount; d++) {
- for (stock = 1; stock <= StockCount; stock++)
- if (! ((days[d], stock) in quote))
- stock = StockCount + 10
- if (stock > StockCount + 1)
- continue
- datacount++
- for (stock = 1; stock <= StockCount; stock++)
- data[datacount, stock] = int(0.5 + quote[days[d], stock])
- }
- delete quote
- delete days
- }
- <!-- endfile -->
-</pre>
- <p>Now we have arrived at the second really interesting part of the whole
affair.
-What we present here is a very primitive prediction algorithm:
-<em>If a stock fell yesterday, assume it will also fall today; if
-it rose yesterday, assume it will rise today</em>. (Feel free to replace this
-algorithm with a smarter one.) If a stock changed in the same direction
-on two consecutive days, this is an indication which should be highlighted.
-Two-day advances are stored in <code>hot</code> and two-day declines in
-<code>avoid</code>.
-
- <p>The rest of the function is a sanity check. It counts the number of
-correct predictions in relation to the total number of predictions
-one could have made in the year before.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function Prediction() {
- # Predict each ticker symbol by prolonging yesterday's trend
- for (stock = 1; stock <= StockCount; stock++) {
- if (data[1, stock] > data[2, stock]) {
- predict[stock] = "up"
- } else if (data[1, stock] < data[2, stock]) {
- predict[stock] = "down"
- } else {
- predict[stock] = "neutral"
- }
- if ((data[1, stock] > data[2, stock]) && (data[2, stock]
> data[3, stock]))
- hot[stock] = 1
- if ((data[1, stock] < data[2, stock]) && (data[2, stock]
< data[3, stock]))
- avoid[stock] = 1
- }
- # Do a plausibility check: how many predictions proved correct?
- for (s = 1; s <= StockCount; s++) {
- for (d = 1; d <= datacount-2; d++) {
- if (data[d+1, s] > data[d+2, s]) {
- UpCount++
- } else if (data[d+1, s] < data[d+2, s]) {
- DownCount++
- } else {
- NeutralCount++
- }
- if (((data[d, s] > data[d+1, s]) && (data[d+1, s] >
data[d+2, s])) ||
- ((data[d, s] < data[d+1, s]) && (data[d+1, s] <
data[d+2, s])) ||
- ((data[d, s] == data[d+1, s]) && (data[d+1, s] ==
data[d+2, s])))
- CorrectCount++
- }
- }
- }
- <!-- endfile -->
-</pre>
- <p>At this point the hard work has been done: the array <code>predict</code>
-contains the predictions for all the ticker symbols. It is up to the
-function <code>Report</code> to find some nice words to introduce the
-desired information.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function Report() {
- # Generate report
- report = "\nThis is your daily "
- report = report "stock market report for "strftime("%A, %B %d, %Y")".\n"
- report = report "Here are the predictions for today:\n\n"
- for (stock = 1; stock <= StockCount; stock++)
- report = report "\t" name[stock] "\t" predict[stock] "\n"
- for (stock in hot) {
- if (HotCount++ == 0)
- report = report "\nThe most promising shares for today are
these:\n\n"
- report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
- tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock])
".html\n"
- }
- for (stock in avoid) {
- if (AvoidCount++ == 0)
- report = report "\nThe stock shares to avoid today are these:\n\n"
- report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
- tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock])
".html\n"
- }
- report = report "\nThis sums up to " HotCount+0 " winners and "
AvoidCount+0
- report = report " losers. When using this kind\nof prediction scheme
for"
- report = report " the 12 months which lie behind us,\nwe get " UpCount
- report = report " 'ups' and " DownCount " 'downs' and " NeutralCount
- report = report " 'neutrals'. Of all\nthese "
UpCount+DownCount+NeutralCount
- report = report " predictions " CorrectCount " proved correct next
day.\n"
- report = report "A success rate of "\
- int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n"
- report = report "Random choice would have produced a 33% success
rate.\n"
- report = report "Disclaimer: Like every other prediction of the stock\n"
- report = report "market, this report is, of course, complete
nonsense.\n"
- report = report "If you are stupid enough to believe these
predictions\n"
- report = report "you should visit a doctor who can treat your ailment."
- }
- <!-- endfile -->
-</pre>
- <p>The function <code>SendMail</code> goes through the list of customers
and opens
-a pipe to the <code>mail</code> command for each of them. Each one receives an
-email message with a proper subject heading and is addressed with his full
name.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function SendMail() {
- # send report to customers
- customer["address@hidden"] = "Uncle Scrooge"
- customer["address@hidden" ] = "Sir Thomas More"
- customer["address@hidden" ] = "Baruch de Spinoza"
- customer["address@hidden" ] = "Karl Marx"
- customer["address@hidden" ] = "John Maynard Keynes"
- customer["address@hidden" ] = "Ambrose Bierce"
- customer["address@hidden" ] = "Pierre Simon de Laplace"
- for (c in customer) {
- MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c
- print "Good morning " customer[c] "," | MailPipe
- print report "\n.\n" | MailPipe
- close(MailPipe)
- }
- }
- <!-- endfile -->
-</pre>
- <p>Be patient when running the script by hand.
-Retrieving the data for all the ticker symbols and sending the emails
-may take several minutes to complete, depending upon network traffic
-and the speed of the available Internet link.
-The quality of the prediction algorithm is likely to be disappointing.
-Try to find a better one.
-Should you find one with a success rate of more than 50%, please tell
-us about it! It is only for the sake of curiosity, of course. <code>:-)</code>
-
-<div class="node">
-<p><hr>
-<a name="PROTBASE"></a>Previous: <a rel="previous" accesskey="p"
href="#STOXPRED">STOXPRED</a>,
-Up: <a rel="up" accesskey="u"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>
-<br>
-</div>
-
-<h3 class="section">3.10 PROTBASE: Searching Through A Protein Database</h3>
-
-<p><a name="index-PROTBASE-164"></a><a
name="index-NCBI_002c-National-Center-for-Biotechnology-Information-165"></a><a
name="index-BLAST_002c-Basic-Local-Alignment-Search-Tool-166"></a><a
name="index-Hoare_002c-C_002eA_002eR_002e-167"></a><blockquote>
-<i>Hoare's Law of Large Problems: Inside every large problem is a small
- problem struggling to get out.</i>
-</blockquote>
-
- <p>Yahoo's database of stock market data is just one among the many large
-databases on the Internet. Another one is located at NCBI
-(National Center for Biotechnology
-Information). Established in 1988 as a national resource for molecular
-biology information, NCBI creates public databases, conducts research
-in computational biology, develops software tools for analyzing genome
-data, and disseminates biomedical information. In this section, we
-look at one of NCBI's public services, which is called BLAST
-(Basic Local Alignment Search Tool).
-
- <p>You probably know that the information necessary for reproducing living
-cells is encoded in the genetic material of the cells. The genetic material
-is a very long chain of four base nucleotides. It is the order of
-appearance (the sequence) of nucleotides which contains the information
-about the substance to be produced. Scientists in biotechnology often
-find a specific fragment, determine the nucleotide sequence, and need
-to know where the sequence at hand comes from. This is where the large
-databases enter the game. At NCBI, databases store the knowledge
-about which sequences have ever been found and where they have been found.
-When the scientist sends his sequence to the BLAST service, the server
-looks for regions of genetic material in its database which
-look the most similar to the delivered nucleotide sequence. After a
-search time of some seconds or minutes the server sends an answer to
-the scientist. In order to make access simple, NCBI chose to offer
-their database service through popular Internet protocols. There are
-four basic ways to use the so-called BLAST services:
-
- <ul>
-<li>The easiest way to use BLAST is through the web. Users may simply point
-their browsers at the NCBI home page
-and link to the BLAST pages.
-NCBI provides a stable URL that may be used to perform BLAST searches
-without interactive use of a web browser. This is what we will do later
-in this section.
-A demonstration client
-and a <samp><span class="file">README</span></samp> file demonstrate how to
access this URL.
-
- <li>Currently,
-<samp><span class="command">blastcl3</span></samp> is the standard network
BLAST client.
-You can download <samp><span class="command">blastcl3</span></samp> from the
-anonymous FTP location.
-
- <li>BLAST 2.0 can be run locally as a full executable and can be used to
run
-BLAST searches against private local databases, or downloaded copies of the
-NCBI databases. BLAST 2.0 executables may be found on the NCBI
-anonymous FTP server.
-
- <li>The NCBI BLAST Email server is the best option for people without
convenient
-access to the web. A similarity search can be performed by sending a properly
-formatted mail message containing the nucleotide or protein query sequence to
-<a href="mailto:address@hidden">address@hidden</a>. The query sequence is
compared against the
-specified database using the BLAST algorithm and the results are returned in
-an email message. For more information on formulating email BLAST searches,
-you can send a message consisting of the word “HELP” to the same
address,
-<a href="mailto:address@hidden">address@hidden</a>.
-</ul>
-
- <p>Our starting point is the demonstration client mentioned in the first
option.
-The <samp><span class="file">README</span></samp> file that comes along with
the client explains the whole
-process in a nutshell. In the rest of this section, we first show
-what such requests look like. Then we show how to use <samp><span
class="command">gawk</span></samp> to
-implement a client in about 10 lines of code. Finally, we show how to
-interpret the result returned from the service.
-
- <p>Sequences are expected to be represented in the standard
-IUB/IUPAC amino acid and nucleic acid codes,
-with these exceptions: lower-case letters are accepted and are mapped
-into upper-case; a single hyphen or dash can be used to represent a gap
-of indeterminate length; and in amino acid sequences, `<samp><span
class="samp">U</span></samp>' and `<samp><span class="samp">*</span></samp>'
-are acceptable letters (see below). Before submitting a request, any numerical
-digits in the query sequence should either be removed or replaced by
-appropriate letter codes (e.g., `<samp><span class="samp">N</span></samp>' for
unknown nucleic acid residue
-or `<samp><span class="samp">X</span></samp>' for unknown amino acid residue).
-The nucleic acid codes supported are:
-
-<pre class="example"> A --> adenosine M --> A C (amino)
- C --> cytidine S --> G C (strong)
- G --> guanine W --> A T (weak)
- T --> thymidine B --> G T C
- U --> uridine D --> G A T
- R --> G A (purine) H --> A C T
- Y --> T C (pyrimidine) V --> G C A
- K --> G T (keto) N --> A G C T (any)
- - gap of indeterminate length
-</pre>
- <p>Now you know the alphabet of nucleotide sequences. The last two lines
-of the following example query show you such a sequence, which is obviously
-made up only of elements of the alphabet just described. Store this example
-query into a file named <samp><span
class="file">protbase.request</span></samp>. You are now ready to send
-it to the server with the demonstration client.
-
-<pre class="example"> <!-- file eg/network/protbase.request -->
- PROGRAM blastn
- DATALIB month
- EXPECT 0.75
- BEGIN
- >GAWK310 the gawking gene GNU AWK
- tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat
- caccaccatggacagcaaa
- <!-- endfile -->
-</pre>
- <p><a name="index-FASTA_002fPearson-format-168"></a>The actual search
request begins with the mandatory parameter `<samp><span
class="samp">PROGRAM</span></samp>'
-in the first column followed by the value `<samp><span
class="samp">blastn</span></samp>' (the name of the
-program) for searching nucleic acids. The next line contains the mandatory
-search parameter `<samp><span class="samp">DATALIB</span></samp>' with the
value `<samp><span class="samp">month</span></samp>' for the newest
-nucleic acid sequences. The third line contains an optional `<samp><span
class="samp">EXPECT</span></samp>'
-parameter and the value desired for it. The fourth line contains the
-mandatory `<samp><span class="samp">BEGIN</span></samp>' directive, followed
by the query sequence in
-FASTA/Pearson format.
-Each line of information must be less than 80 characters in length.
-
- <p>The “month” database contains all new or revised sequences
released in the
-last 30 days and is useful for searching against new sequences.
-There are five different blast programs, <samp><span
class="command">blastn</span></samp> being the one that
-compares a nucleotide query sequence against a nucleotide sequence database.
-
- <p>The last server directive that must appear in every request is the
-`<samp><span class="samp">BEGIN</span></samp>' directive. The query sequence
should immediately follow the
-`<samp><span class="samp">BEGIN</span></samp>' directive and must appear in
FASTA/Pearson format.
-A sequence in
-FASTA/Pearson format begins with a single-line description.
-The description line, which is required, is distinguished from the lines of
-sequence data that follow it by having a greater-than (`<samp><span
class="samp">></span></samp>') symbol
-in the first column. For the purposes of the BLAST server, the text of
-the description is arbitrary.
-
- <p>If you prefer to use a client written in <samp><span
class="command">gawk</span></samp>, just store the following
-10 lines of code into a file named <samp><span
class="file">protbase.awk</span></samp> and use this client
-instead. Invoke it with `<samp><span class="samp">gawk -f protbase.awk
protbase.request</span></samp>'.
-Then wait a minute and watch the result coming in. In order to replicate
-the demonstration client's behaviour as closely as possible, this client
-does not use a proxy server. We could also have extended the client program
-in <a href="#GETURL">Retrieving Web Pages</a>, to implement the client request
from
-<samp><span class="file">protbase.awk</span></samp> as a special case.
-
-<pre class="smallexample"> <!-- file eg/network/protbase.awk -->
- { request = request "\n" $0 }
-
- END {
- BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80"
- printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |&
BLASTService
- printf "Content-Length: " length(request) "\n\n" |&
BLASTService
- printf request |&
BLASTService
- while ((BLASTService |& getline) > 0)
- print $0
- close(BLASTService)
- }
- <!-- endfile -->
-</pre>
- <p>The demonstration client from NCBI is 214 lines long (written in C) and
-it is not immediately obvious what it does. Our client is so short that
-it <em>is</em> obvious what it does. First it loops over all lines of the
-query and stores the whole query into a variable. Then the script
-establishes an Internet connection to the NCBI server and transmits the
-query by framing it with a proper HTTP request. Finally it receives
-and prints the complete result coming from the server.
-
- <p>Now, let us look at the result. It begins with an HTTP header, which you
-can ignore. Then there are some comments about the query having been
-filtered to avoid spuriously high scores. After this, there is a reference
-to the paper that describes the software being used for searching the data
-base. After a repitition of the original query's description we find the
-list of significant alignments:
-
-<pre class="smallexample"> <!-- file eg/network/protbase.result -->
- Sequences producing significant alignments: (bits)
Value
-
- gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38
0.20
- gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38
0.20
- emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38
0.20
- emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38
0.20
- emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38
0.20
- emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38
0.20
- gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38
0.20
- <!-- endfile -->
-</pre>
- <p>This means that the query sequence was found in seven human chromosomes.
-But the value 0.20 (20%) means that the probability of an accidental match
-is rather high (20%) in all cases and should be taken into account.
-You may wonder what the first column means. It is a key to the specific
-database in which this occurence was found. The unique sequence identifiers
-reported in the search results can be used as sequence retrieval keys
-via the NCBI server. The syntax of sequence header lines used by the NCBI
-BLAST server depends on the database from which each sequence was obtained.
-The table below lists the identifiers for the databases from which the
-sequences were derived.
-
- <p><table summary=""><tr align="left"><td valign="top">GenBank </td><td
valign="top"><code>gb|accession|locus</code>
-<br></td></tr><tr align="left"><td valign="top">EMBL Data Library </td><td
valign="top"><code>emb|accession|locus</code>
-<br></td></tr><tr align="left"><td valign="top">DDBJ, DNA Database of Japan
</td><td valign="top"><code>dbj|accession|locus</code>
-<br></td></tr><tr align="left"><td valign="top">NBRF PIR </td><td
valign="top"><code>pir||entry</code>
-<br></td></tr><tr align="left"><td valign="top">Protein Research Foundation
</td><td valign="top"><code>prf||name</code>
-<br></td></tr><tr align="left"><td valign="top">SWISS-PROT </td><td
valign="top"><code>sp|accession|entry name<!-- /@w --></code>
-<br></td></tr><tr align="left"><td valign="top">Brookhaven Protein Data Bank
</td><td valign="top"><code>pdb|entry|chain</code>
-<br></td></tr><tr align="left"><td valign="top">Kabat's Sequences of
Immuno<small class="dots">...</small> </td><td
valign="top"><code>gnl|kabat|identifier</code>
-<br></td></tr><tr align="left"><td valign="top">Patents </td><td
valign="top"><code>pat|country|number</code>
-<br></td></tr><tr align="left"><td valign="top">GenInfo Backbone Id </td><td
valign="top"><code>bbs|number</code>
- <br></td></tr></table>
-
- <p>For example, an identifier might be `<samp><span
class="samp">gb|AC021182.14|AC021182</span></samp>', where the
-`<samp><span class="samp">gb</span></samp>' tag indicates that the identifier
refers to a GenBank sequence,
-`<samp><span class="samp">AC021182.14</span></samp>' is its GenBank ACCESSION,
and `<samp><span class="samp">AC021182</span></samp>' is the GenBank LOCUS.
-The identifier contains no spaces, so that a space indicates the end of the
-identifier.
-
- <p>Let us continue in the result listing. Each of the seven alignments
mentioned
-above is subsequently described in detail. We will have a closer look at
-the first of them.
-
-<pre class="smallexample"> >gb|AC021182.14|AC021182 Homo sapiens
chromosome 7 clone RP11-733N23, WORKING DRAFT SEQUENCE, 4
- unordered pieces
- Length = 176383
-
- Score = 38.2 bits (19), Expect = 0.20
- Identities = 19/19 (100%)
- Strand = Plus / Plus
-
- Query: 35 tggtgaagtgtgtttcttg 53
- |||||||||||||||||||
- Sbjct: 69786 tggtgaagtgtgtttcttg 69804
-</pre>
- <p>This alignment was located on the human chromosome 7. The fragment on
which
-part of the query was found had a total length of 176383. Only 19 of the
-nucleotides matched and the matching sequence ran from character 35 to 53
-in the query sequence and from 69786 to 69804 in the fragment on chromosome 7.
-If you are still reading at this point, you are probably interested in finding
-out more about Computational Biology and you might appreciate the following
-hints.
-
- <p><a name="index-Computational-Biology-169"></a><a
name="index-Bioinformatics-170"></a>
- <ol type=1 start=1>
-<li>There is a book called <cite>Introduction to Computational Biology</cite>
-by Michael S. Waterman, which is worth reading if you are seriously
-interested. You can find a good
-book review
-on the Internet.
-
- <li>While Waterman's book can explain to you the algorithms employed
internally
-in the database search engines, most practicioners prefer to approach
-the subject differently. The applied side of Computational Biology is
-called Bioinformatics, and emphasizes the tools available for day-to-day
-work as well as how to actually <em>use</em> them. One of the very few
affordable
-books on Bioinformatics is
-<cite>Developing Bioinformatics Computer Skills</cite>.
-
- <li>The sequences <em>gawk</em> and <em>gnuawk</em> are in widespread use
in
-the genetic material of virtually every earthly living being. Let us
-take this as a clear indication that the divine creator has intended
-<code>gawk</code> to prevail over other scripting languages such as
<code>perl</code>,
-<code>tcl</code>, or <code>python</code> which are not even proper sequences.
(:-)
- </ol>
-
-<div class="node">
-<p><hr>
-<a name="Links"></a>Next: <a rel="next" accesskey="n"
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
-Previous: <a rel="previous" accesskey="p"
href="#Some-Applications-and-Techniques">Some Applications and Techniques</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="chapter">4 Related Links</h2>
-
-<p>This section lists the URLs for various items discussed in this chapter.
-They are presented in the order in which they appear.
-
- <dl>
-<dt><cite>Internet Programming with Python</cite><dd><a
href="http://www.fsbassociates.com/books/python.htm">http://www.fsbassociates.com/books/python.htm</a>
-
- <br><dt><cite>Advanced Perl Programming</cite><dd><a
href="http://www.oreilly.com/catalog/advperl">http://www.oreilly.com/catalog/advperl</a>
-
- <br><dt><cite>Web Client Programming with Perl</cite><dd><a
href="http://www.oreilly.com/catalog/webclient">http://www.oreilly.com/catalog/webclient</a>
-
- <br><dt>Richard Stevens's home page and book<dd><a
href="http://www.kohala.com/~rstevens">http://www.kohala.com/~rstevens</a>
-
- <br><dt>The SPAK home page<dd><a
href="http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html">http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html</a>
-
- <br><dt>Volume III of <cite>Internetworking with TCP/IP</cite>, by Comer
and Stevens<dd><a
href="http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html">http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html</a>
-
- <br><dt>XBM Graphics File Format<dd><a
href="http://www.wotsit.org/download.asp?f=xbm">http://www.wotsit.org/download.asp?f=xbm</a>
-
- <br><dt>GNUPlot<dd><a
href="http://www.cs.dartmouth.edu/gnuplot_info.html">http://www.cs.dartmouth.edu/gnuplot_info.html</a>
-
- <br><dt>Mark Humphrys' Eliza page<dd><a
href="http://www.compapp.dcu.ie/~humphrys/eliza.html">http://www.compapp.dcu.ie/~humphrys/eliza.html</a>
-
- <br><dt>Yahoo! Eliza Information<dd><a
href="http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence">http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence</a>
-
- <br><dt>Java versions of Eliza<dd><a
href="http://www.tjhsst.edu/Psych/ch1/eliza.html">http://www.tjhsst.edu/Psych/ch1/eliza.html</a>
-
- <br><dt>Java versions of Eliza with source code<dd><a
href="http://home.adelphia.net/~lifeisgood/eliza/eliza.htm">http://home.adelphia.net/~lifeisgood/eliza/eliza.htm</a>
-
- <br><dt>Eliza Programs with Explanations<dd><a
href="http://chayden.net/chayden/eliza/Eliza.shtml">http://chayden.net/chayden/eliza/Eliza.shtml</a>
-
- <br><dt>Loebner Contest<dd><a
href="http://acm.org/~loebner/loebner-prize.htmlx">http://acm.org/~loebner/loebner-prize.htmlx</a>
-
- <br><dt>Tck/Tk Information<dd><a
href="http://www.scriptics.com/">http://www.scriptics.com/</a>
-
- <br><dt>Intel 80x86 Processors<dd><a
href="http://developer.intel.com/design/platform/embedpc/what_is.htm">http://developer.intel.com/design/platform/embedpc/what_is.htm</a>
-
- <br><dt>AMD Elan Processors<dd><a
href="http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html">http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html</a>
-
- <br><dt>XINU<dd><a
href="http://willow.canberra.edu.au/~chrisc/xinu.html">http://willow.canberra.edu.au/~chrisc/xinu.html</a>
-
- <br><dt>GNU/Linux<dd><a
href="http://uclinux.lineo.com/">http://uclinux.lineo.com/</a>
-
- <br><dt>Embedded PCs<dd><a
href="http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/">http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/</a>
-
- <br><dt>MiniSQL<dd><a
href="http://www.hughes.com.au/library/">http://www.hughes.com.au/library/</a>
-
- <br><dt>Market Share Surveys<dd><a
href="http://www.netcraft.com/survey">http://www.netcraft.com/survey</a>
-
- <br><dt><cite>Numerical Recipes in C: The Art of Scientific
Computing</cite><dd><a href="http://www.nr.com">http://www.nr.com</a>
-
- <br><dt>VRML<dd><a href="http://www.vrml.org">http://www.vrml.org</a>
-
- <br><dt>The VRML FAQ<dd><a
href="http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ">http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ</a>
-
- <br><dt>The UMBC Agent Web<dd><a
href="http://www.cs.umbc.edu/agents">http://www.cs.umbc.edu/agents</a>
-
- <br><dt>Apache Web Server<dd><a
href="http://www.apache.org">http://www.apache.org</a>
-
- <br><dt>National Center for Biotechnology Information (NCBI)<dd><a
href="http://www.ncbi.nlm.nih.gov">http://www.ncbi.nlm.nih.gov</a>
-
- <br><dt>Basic Local Alignment Search Tool (BLAST)<dd><a
href="http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html">http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html</a>
-
- <br><dt>NCBI Home Page<dd><a
href="http://www.ncbi.nlm.nih.gov">http://www.ncbi.nlm.nih.gov</a>
-
- <br><dt>BLAST Pages<dd><a
href="http://www.ncbi.nlm.nih.gov/BLAST">http://www.ncbi.nlm.nih.gov/BLAST</a>
-
- <br><dt>BLAST Demonstration Client<dd><a
href="ftp://ncbi.nlm.nih.gov/blast/blasturl/">ftp://ncbi.nlm.nih.gov/blast/blasturl/</a>
-
- <br><dt>BLAST anonymous FTP location<dd><a
href="ftp://ncbi.nlm.nih.gov/blast/network/netblast/">ftp://ncbi.nlm.nih.gov/blast/network/netblast/</a>
-
- <br><dt>BLAST 2.0 Executables<dd><a
href="ftp://ncbi.nlm.nih.gov/blast/executables/">ftp://ncbi.nlm.nih.gov/blast/executables/</a>
-
- <br><dt>IUB/IUPAC Amino Acid and Nucleic Acid Codes<dd><a
href="http://www.uthscsa.edu/geninfo/blastmail.html#item6">http://www.uthscsa.edu/geninfo/blastmail.html#item6</a>
-
- <br><dt>FASTA/Pearson Format<dd><a
href="http://www.ncbi.nlm.nih.gov/BLAST/fasta.html">http://www.ncbi.nlm.nih.gov/BLAST/fasta.html</a>
-
- <br><dt>Fasta/Pearson Sequence in Java<dd><a
href="http://www.kazusa.or.jp/java/codon_table_java/">http://www.kazusa.or.jp/java/codon_table_java/</a>
-
- <br><dt>Book Review of <cite>Introduction to Computational
Biology</cite><dd><a
href="http://www.acm.org/crossroads/xrds5-1/introcb.html">http://www.acm.org/crossroads/xrds5-1/introcb.html</a>
-
- <br><dt><cite>Developing Bioinformatics Computer Skills</cite><dd><a
href="http://www.oreilly.com/catalog/bioskills/">http://www.oreilly.com/catalog/bioskills/</a>
-
- </dl>
-
-<div class="node">
-<p><hr>
-<a name="GNU-Free-Documentation-License"></a>Next: <a rel="next"
accesskey="n" href="#Index">Index</a>,
-Previous: <a rel="previous" accesskey="p" href="#Links">Links</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<h2 class="unnumbered">GNU Free Documentation License</h2>
-
-<p><a name="index-FDL-_0028Free-Documentation-License_0029-171"></a><a
name="index-Free-Documentation-License-_0028FDL_0029-172"></a><a
name="index-GNU-Free-Documentation-License-173"></a><div align="center">Version
1.2, November 2002</div>
-
-<pre class="display"> Copyright © 2000,2001,2002 Free Software
Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-</pre>
- <ol type=1 start=0>
-<li>PREAMBLE
-
- <p>The purpose of this License is to make a manual, textbook, or other
-functional and useful document <dfn>free</dfn> in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
- <p>This License is a kind of “copyleft”, which means that
derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
- <p>We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
- <li>APPLICABILITY AND DEFINITIONS
-
- <p>This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The “Document”, below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as “you”. You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
- <p>A “Modified Version” of the Document means any work
containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
- <p>A “Secondary Section” is a named appendix or a
front-matter section
-of the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
- <p>The “Invariant Sections” are certain Secondary Sections
whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
- <p>The “Cover Texts” are certain short passages of text that
are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
- <p>A “Transparent” copy of the Document means a
machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not “Transparent” is called
“Opaque”.
-
- <p>Examples of suitable formats for Transparent copies include plain
-<span class="sc">ascii</span> without markup, Texinfo input format, LaTeX input
-format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly
available
-<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> designed for human modification. Examples
-of transparent image formats include <acronym>PNG</acronym>,
<acronym>XCF</acronym> and
-<acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
-read and edited only by proprietary word processors, <acronym>SGML</acronym> or
-<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing
tools are
-not generally available, and the machine-generated <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> produced by some word processors for
-output purposes only.
-
- <p>The “Title Page” means, for a printed book, the title page
itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, “Title Page”
means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
- <p>A section “Entitled XYZ” means a named subunit of the
Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as “Acknowledgements”,
-“Dedications”, “Endorsements”, or
“History”.) To “Preserve the Title”
-of such a section when you modify the Document means that it remains a
-section “Entitled XYZ” according to this definition.
-
- <p>The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
- <li>VERBATIM COPYING
-
- <p>You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no other
-conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
- <p>You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
- <li>COPYING IN QUANTITY
-
- <p>If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
- <p>If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
- <p>If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
- <p>It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to give
-them a chance to provide you with an updated version of the Document.
-
- <li>MODIFICATIONS
-
- <p>You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
- <ol type=A start=1>
-<li>Use in the Title Page (and on the covers, if any) a title distinct
-from that of the Document, and from those of previous versions
-(which should, if there were any, be listed in the History section
-of the Document). You may use the same title as a previous version
-if the original publisher of that version gives permission.
-
- <li>List on the Title Page, as authors, one or more persons or
entities
-responsible for authorship of the modifications in the Modified
-Version, together with at least five of the principal authors of the
-Document (all of its principal authors, if it has fewer than five),
-unless they release you from this requirement.
-
- <li>State on the Title page the name of the publisher of the
-Modified Version, as the publisher.
-
- <li>Preserve all the copyright notices of the Document.
-
- <li>Add an appropriate copyright notice for your modifications
-adjacent to the other copyright notices.
-
- <li>Include, immediately after the copyright notices, a license
notice
-giving the public permission to use the Modified Version under the
-terms of this License, in the form shown in the Addendum below.
-
- <li>Preserve in that license notice the full lists of Invariant
Sections
-and required Cover Texts given in the Document's license notice.
-
- <li>Include an unaltered copy of this License.
-
- <li>Preserve the section Entitled “History”, Preserve
its Title, and add
-to it an item stating at least the title, year, new authors, and
-publisher of the Modified Version as given on the Title Page. If
-there is no section Entitled “History” in the Document, create one
-stating the title, year, authors, and publisher of the Document as
-given on its Title Page, then add an item describing the Modified
-Version as stated in the previous sentence.
-
- <li>Preserve the network location, if any, given in the Document for
-public access to a Transparent copy of the Document, and likewise
-the network locations given in the Document for previous versions
-it was based on. These may be placed in the “History” section.
-You may omit a network location for a work that was published at
-least four years before the Document itself, or if the original
-publisher of the version it refers to gives permission.
-
- <li>For any section Entitled “Acknowledgements” or
“Dedications”, Preserve
-the Title of the section, and preserve in the section all the
-substance and tone of each of the contributor acknowledgements and/or
-dedications given therein.
-
- <li>Preserve all the Invariant Sections of the Document,
-unaltered in their text and in their titles. Section numbers
-or the equivalent are not considered part of the section titles.
-
- <li>Delete any section Entitled “Endorsements”. Such a
section
-may not be included in the Modified Version.
-
- <li>Do not retitle any existing section to be Entitled
“Endorsements” or
-to conflict in title with any Invariant Section.
-
- <li>Preserve any Warranty Disclaimers.
- </ol>
-
- <p>If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
- <p>You may add a section Entitled “Endorsements”, provided it
contains
-nothing but endorsements of your Modified Version by various
-parties—for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
- <p>You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
- <p>The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
- <li>COMBINING DOCUMENTS
-
- <p>You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
- <p>The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
- <p>In the combination, you must combine any sections Entitled
“History”
-in the various original documents, forming one section Entitled
-“History”; likewise combine any sections Entitled
“Acknowledgements”,
-and any sections Entitled “Dedications”. You must delete all
-sections Entitled “Endorsements.”
-
- <li>COLLECTIONS OF DOCUMENTS
-
- <p>You may make a collection consisting of the Document and other
documents
-released under this License, and replace the individual copies of this
-License in the various documents with a single copy that is included in
-the collection, provided that you follow the rules of this License for
-verbatim copying of each of the documents in all other respects.
-
- <p>You may extract a single document from such a collection, and
distribute
-it individually under this License, provided you insert a copy of this
-License into the extracted document, and follow this License in all
-other respects regarding verbatim copying of that document.
-
- <li>AGGREGATION WITH INDEPENDENT WORKS
-
- <p>A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an “aggregate” if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
- <p>If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
- <li>TRANSLATION
-
- <p>Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warrany Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
- <p>If a section in the Document is Entitled
“Acknowledgements”,
-“Dedications”, or “History”, the requirement (section
4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
- <li>TERMINATION
-
- <p>You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License. Any other attempt to
-copy, modify, sublicense or distribute the Document is void, and will
-automatically terminate your rights under this License. However,
-parties who have received copies, or rights, from you under this
-License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- <li>FUTURE REVISIONS OF THIS LICENSE
-
- <p>The Free Software Foundation may publish new, revised versions
-of the GNU Free Documentation License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns. See
-<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
-
- <p>Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License “or any later version” applies to it, you have the option
of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation.
- </ol>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">ADDENDUM: How to use this License for your
documents</h3>
-
-<p>To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
-<pre class="smallexample"> Copyright (C) <var>year</var> <var>your
name</var>.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
- A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-</pre>
- <p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the “with...Texts.” line with this:
-
-<pre class="smallexample"> with the Invariant Sections being <var>list
their titles</var>, with
- the Front-Cover Texts being <var>list</var>, and with the Back-Cover
Texts
- being <var>list</var>.
-</pre>
- <p>If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
- <p>If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
-
-<!-- Local Variables: -->
-<!-- ispell-local-pdict: "ispell-dict" -->
-<!-- End: -->
-<div class="node">
-<p><hr>
-<a name="Index"></a>Previous: <a rel="previous" accesskey="p"
href="#GNU-Free-Documentation-License">GNU Free Documentation License</a>,
-Up: <a rel="up" accesskey="u" href="#Top">Top</a>
-<br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h2 class="unnumbered">Index</h2>
-
-<ul class="index-cp" compact>
-<li><a
href="#index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-23"><code>/inet/</code>
files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="#index-_0040code_007b_002finet_002fraw_007d-special-files-_0028_0040command_007bgawk_007d_0029-41"><code>/inet/raw</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#File-_002finet_002fraw">File /inet/raw</a></li>
-<li><a
href="#index-_0040code_007b_002finet_002ftcp_007d-special-files-_0028_0040command_007bgawk_007d_0029-34"><code>/inet/tcp</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#File-_002finet_002ftcp">File /inet/tcp</a></li>
-<li><a
href="#index-_0040code_007b_002finet_002fudp_007d-special-files-_0028_0040command_007bgawk_007d_0029-37"><code>/inet/udp</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#File-_002finet_002fudp">File /inet/udp</a></li>
-<li><a href="#index-advanced-features_002c-network-connections-53">advanced
features, network connections</a>: <a
href="#Troubleshooting">Troubleshooting</a></li>
-<li><a href="#index-agent-154">agent</a>: <a href="#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="#index-agent-122">agent</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a href="#index-AI-119">AI</a>: <a href="#Challenges">Challenges</a></li>
-<li><a href="#index-apache-157">apache</a>: <a
href="#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="#index-apache-139">apache</a>: <a href="#WEBGRAB">WEBGRAB</a></li>
-<li><a href="#index-Bioinformatics-170">Bioinformatics</a>: <a
href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-BLAST_002c-Basic-Local-Alignment-Search-Tool-166">BLAST,
Basic Local Alignment Search Tool</a>: <a href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-blocking-6">blocking</a>: <a
href="#Making-Connections">Making Connections</a></li>
-<li><a href="#index-Boutell_002c-Thomas-146">Boutell, Thomas</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-CGI-_0028Common-Gateway-Interface_0029-156">CGI (Common
Gateway Interface)</a>: <a href="#MOBAGWHO">MOBAGWHO</a></li>
-<li><a
href="#index-CGI-_0028Common-Gateway-Interface_0029_002c-dynamic-web-pages-and-90">CGI
(Common Gateway Interface), dynamic web pages and</a>: <a href="#Web-page">Web
page</a></li>
-<li><a
href="#index-CGI-_0028Common-Gateway-Interface_0029_002c-library-105">CGI
(Common Gateway Interface), library</a>: <a href="#CGI-Lib">CGI Lib</a></li>
-<li><a href="#index-clients-5">clients</a>: <a
href="#Making-Connections">Making Connections</a></li>
-<li><a href="#index-Clinton_002c-Bill-118">Clinton, Bill</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a href="#index-Common-Gateway-Interface_002c-See-CGI-91">Common Gateway
Interface, See CGI</a>: <a href="#Web-page">Web page</a></li>
-<li><a href="#index-Computational-Biology-169">Computational Biology</a>: <a
href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-contest-117">contest</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a href="#index-_0040command_007bcron_007d-utility-161"><samp><span
class="command">cron</span></samp> utility</a>: <a
href="#STOXPRED">STOXPRED</a></li>
-<li><a href="#index-CSV-format-163">CSV format</a>: <a
href="#STOXPRED">STOXPRED</a></li>
-<li><a href="#index-dark-corner_002c-RAW-protocol-44">dark corner, RAW
protocol</a>: <a href="#File-_002finet_002fraw">File /inet/raw</a></li>
-<li><a href="#index-Dow-Jones-Industrial-Index-162">Dow Jones Industrial
Index</a>: <a href="#STOXPRED">STOXPRED</a></li>
-<li><a href="#index-ELIZA-program-108">ELIZA program</a>: <a
href="#Simple-Server">Simple Server</a></li>
-<li><a href="#index-email-76">email</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-FASTA_002fPearson-format-168">FASTA/Pearson format</a>: <a
href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-FDL-_0028Free-Documentation-License_0029-171">FDL (Free
Documentation License)</a>: <a href="#GNU-Free-Documentation-License">GNU Free
Documentation License</a></li>
-<li><a href="#index-filenames_002c-for-network-access-20">filenames, for
network access</a>: <a href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-24">files,
<code>/inet/</code> (<samp><span class="command">gawk</span></samp>)</a>: <a
href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002finet_002fraw_007d-_0028_0040command_007bgawk_007d_0029-42">files,
<code>/inet/raw</code> (<samp><span class="command">gawk</span></samp>)</a>:
<a href="#File-_002finet_002fraw">File /inet/raw</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002finet_002ftcp_007d-_0028_0040command_007bgawk_007d_0029-35">files,
<code>/inet/tcp</code> (<samp><span class="command">gawk</span></samp>)</a>:
<a href="#File-_002finet_002ftcp">File /inet/tcp</a></li>
-<li><a
href="#index-files_002c-_0040code_007b_002finet_002fudp_007d-_0028_0040command_007bgawk_007d_0029-38">files,
<code>/inet/udp</code> (<samp><span class="command">gawk</span></samp>)</a>:
<a href="#File-_002finet_002fudp">File /inet/udp</a></li>
-<li><a href="#index-_0040command_007bfinger_007d-utility-65"><samp><span
class="command">finger</span></samp> utility</a>: <a href="#Setting-Up">Setting
Up</a></li>
-<li><a href="#index-Free-Documentation-License-_0028FDL_0029-172">Free
Documentation License (FDL)</a>: <a href="#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a href="#index-FTP-_0028File-Transfer-Protocol_0029-2">FTP (File Transfer
Protocol)</a>: <a href="#Basic-Protocols">Basic Protocols</a></li>
-<li><a href="#index-_0040command_007bgawk_007d_002c-networking-9"><samp><span
class="command">gawk</span></samp>, networking</a>: <a
href="#Using-Networking">Using Networking</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-networking_002c-connections-48"><samp><span
class="command">gawk</span></samp>, networking, connections</a>: <a
href="#TCP-Connecting">TCP Connecting</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-networking_002c-connections-33"><samp><span
class="command">gawk</span></samp>, networking, connections</a>: <a
href="#Special-File-Fields">Special File Fields</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-networking_002c-filenames-21"><samp><span
class="command">gawk</span></samp>, networking, filenames</a>: <a
href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-networking_002c-See-Also-email-70"><samp><span
class="command">gawk</span></samp>, networking, See Also email</a>: <a
href="#Email">Email</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-networking_002c-service_002c-establishing-64"><samp><span
class="command">gawk</span></samp>, networking, service, establishing</a>: <a
href="#Setting-Up">Setting Up</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-networking_002c-troubleshooting-113"><samp><span
class="command">gawk</span></samp>, networking, troubleshooting</a>: <a
href="#Caveats">Caveats</a></li>
-<li><a
href="#index-_0040command_007bgawk_007d_002c-web-and_002c-See-web-service-96"><samp><span
class="command">gawk</span></samp>, web and, See web service</a>: <a
href="#Interacting-Service">Interacting Service</a></li>
-<li><a
href="#index-_0040code_007bgetline_007d-command-49"><code>getline</code>
command</a>: <a href="#TCP-Connecting">TCP Connecting</a></li>
-<li><a href="#index-GETURL-program-128">GETURL program</a>: <a
href="#GETURL">GETURL</a></li>
-<li><a href="#index-GIF-image-format-143">GIF image format</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-GIF-image-format-92">GIF image format</a>: <a
href="#Web-page">Web page</a></li>
-<li><a href="#index-GNU-Free-Documentation-License-173">GNU Free Documentation
License</a>: <a href="#GNU-Free-Documentation-License">GNU Free Documentation
License</a></li>
-<li><a href="#index-GNU_002fLinux-132">GNU/Linux</a>: <a
href="#REMCONF">REMCONF</a></li>
-<li><a href="#index-GNU_002fLinux-59">GNU/Linux</a>: <a
href="#Interacting">Interacting</a></li>
-<li><a href="#index-GNU_002fLinux-56">GNU/Linux</a>: <a
href="#Troubleshooting">Troubleshooting</a></li>
-<li><a href="#index-GNUPlot-utility-141">GNUPlot utility</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-GNUPlot-utility-104">GNUPlot utility</a>: <a
href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-Hoare_002c-C_002eA_002eR_002e-167">Hoare, C.A.R.</a>: <a
href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-Hoare_002c-C_002eA_002eR_002e-155">Hoare, C.A.R.</a>: <a
href="#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="#index-hostname-field-30">hostname field</a>: <a
href="#Special-File-Fields">Special File Fields</a></li>
-<li><a href="#index-HTML-_0028Hypertext-Markup-Language_0029-88">HTML
(Hypertext Markup Language)</a>: <a href="#Web-page">Web page</a></li>
-<li><a href="#index-HTTP-_0028Hypertext-Transfer-Protocol_0029-82">HTTP
(Hypertext Transfer Protocol)</a>: <a href="#Web-page">Web page</a></li>
-<li><a href="#index-HTTP-_0028Hypertext-Transfer-Protocol_0029-3">HTTP
(Hypertext Transfer Protocol)</a>: <a href="#Basic-Protocols">Basic
Protocols</a></li>
-<li><a
href="#index-HTTP-_0028Hypertext-Transfer-Protocol_0029_002c-record-separators-and-87">HTTP
(Hypertext Transfer Protocol), record separators and</a>: <a
href="#Web-page">Web page</a></li>
-<li><a href="#index-HTTP-server_002c-core-logic-98">HTTP server, core
logic</a>: <a href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-Humphrys_002c-Mark-110">Humphrys, Mark</a>: <a
href="#Simple-Server">Simple Server</a></li>
-<li><a href="#index-Hypertext-Markup-Language-_0028HTML_0029-89">Hypertext
Markup Language (HTML)</a>: <a href="#Web-page">Web page</a></li>
-<li><a href="#index-Hypertext-Transfer-Protocol_002c-See-HTTP-83">Hypertext
Transfer Protocol, See HTTP</a>: <a href="#Web-page">Web page</a></li>
-<li><a href="#index-image-format-142">image format</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-images_002c-in-web-pages-102">images, in web pages</a>: <a
href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-images_002c-retrieving-over-networks-94">images,
retrieving over networks</a>: <a href="#Web-page">Web page</a></li>
-<li><a
href="#index-input_002foutput_002c-two_002dway_002c-See-Also-_0040command_007bgawk_007d_002c-networking-18">input/output,
two-way, See Also <samp><span class="command">gawk</span></samp>,
networking</a>: <a href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a href="#index-Internet_002c-See-networks-62">Internet, See networks</a>:
<a href="#Interacting">Interacting</a></li>
-<li><a href="#index-JavaScript-148">JavaScript</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-Linux-131">Linux</a>: <a href="#REMCONF">REMCONF</a></li>
-<li><a href="#index-Linux-58">Linux</a>: <a
href="#Interacting">Interacting</a></li>
-<li><a href="#index-Linux-55">Linux</a>: <a
href="#Troubleshooting">Troubleshooting</a></li>
-<li><a href="#index-Lisp-158">Lisp</a>: <a href="#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="#index-localport-field-25">localport field</a>: <a
href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a href="#index-Loebner_002c-Hugh-116">Loebner, Hugh</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a href="#index-Loui_002c-Ronald-121">Loui, Ronald</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a href="#index-MAZE-150">MAZE</a>: <a href="#MAZE">MAZE</a></li>
-<li><a href="#index-Microsoft-Windows-138">Microsoft Windows</a>: <a
href="#WEBGRAB">WEBGRAB</a></li>
-<li><a href="#index-Microsoft-Windows_002c-networking-57">Microsoft Windows,
networking</a>: <a href="#Troubleshooting">Troubleshooting</a></li>
-<li><a href="#index-Microsoft-Windows_002c-networking_002c-ports-67">Microsoft
Windows, networking, ports</a>: <a href="#Setting-Up">Setting Up</a></li>
-<li><a href="#index-MiniSQL-134">MiniSQL</a>: <a
href="#REMCONF">REMCONF</a></li>
-<li><a href="#index-MOBAGWHO-program-153">MOBAGWHO program</a>: <a
href="#MOBAGWHO">MOBAGWHO</a></li>
-<li><a
href="#index-NCBI_002c-National-Center-for-Biotechnology-Information-165">NCBI,
National Center for Biotechnology Information</a>: <a
href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-networks_002c-_0040command_007bgawk_007d-and-8">networks,
<samp><span class="command">gawk</span></samp> and</a>: <a
href="#Using-Networking">Using Networking</a></li>
-<li><a
href="#index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-47">networks,
<samp><span class="command">gawk</span></samp> and, connections</a>: <a
href="#TCP-Connecting">TCP Connecting</a></li>
-<li><a
href="#index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-32">networks,
<samp><span class="command">gawk</span></samp> and, connections</a>: <a
href="#Special-File-Fields">Special File Fields</a></li>
-<li><a
href="#index-networks_002c-_0040command_007bgawk_007d-and_002c-filenames-22">networks,
<samp><span class="command">gawk</span></samp> and, filenames</a>: <a
href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="#index-networks_002c-_0040command_007bgawk_007d-and_002c-See-Also-email-71">networks,
<samp><span class="command">gawk</span></samp> and, See Also email</a>: <a
href="#Email">Email</a></li>
-<li><a
href="#index-networks_002c-_0040command_007bgawk_007d-and_002c-service_002c-establishing-63">networks,
<samp><span class="command">gawk</span></samp> and, service, establishing</a>:
<a href="#Setting-Up">Setting Up</a></li>
-<li><a
href="#index-networks_002c-_0040command_007bgawk_007d-and_002c-troubleshooting-112">networks,
<samp><span class="command">gawk</span></samp> and, troubleshooting</a>: <a
href="#Caveats">Caveats</a></li>
-<li><a href="#index-networks_002c-ports_002c-reserved-68">networks, ports,
reserved</a>: <a href="#Setting-Up">Setting Up</a></li>
-<li><a href="#index-networks_002c-ports_002c-specifying-29">networks, ports,
specifying</a>: <a href="#Special-File-Fields">Special File Fields</a></li>
-<li><a href="#index-networks_002c-See-Also-web-pages-126">networks, See Also
web pages</a>: <a href="#PANIC">PANIC</a></li>
-<li><a href="#index-Numerical-Recipes-147">Numerical Recipes</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a
href="#index-_0040code_007bORS_007d-variable_002c-HTTP-and-86"><code>ORS</code>
variable, HTTP and</a>: <a href="#Web-page">Web page</a></li>
-<li><a
href="#index-_0040code_007bORS_007d-variable_002c-POP-and-79"><code>ORS</code>
variable, POP and</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-PANIC-program-125">PANIC program</a>: <a
href="#PANIC">PANIC</a></li>
-<li><a href="#index-Perl-10">Perl</a>: <a href="#Using-Networking">Using
Networking</a></li>
-<li><a
href="#index-Perl_002c-_0040command_007bgawk_007d-networking-and-13">Perl,
<samp><span class="command">gawk</span></samp> networking and</a>: <a
href="#Using-Networking">Using Networking</a></li>
-<li><a href="#index-Perlis_002c-Alan-152">Perlis, Alan</a>: <a
href="#MAZE">MAZE</a></li>
-<li><a href="#index-pipes_002c-networking-and-52">pipes, networking and</a>:
<a href="#TCP-Connecting">TCP Connecting</a></li>
-<li><a href="#index-PNG-image-format-144">PNG image format</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-PNG-image-format-93">PNG image format</a>: <a
href="#Web-page">Web page</a></li>
-<li><a href="#index-POP-_0028Post-Office-Protocol_0029-72">POP (Post Office
Protocol)</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-Post-Office-Protocol-_0028POP_0029-74">Post Office
Protocol (POP)</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-PostScript-149">PostScript</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-PROLOG-120">PROLOG</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a href="#index-PROTBASE-164">PROTBASE</a>: <a
href="#PROTBASE">PROTBASE</a></li>
-<li><a href="#index-protocol-field-27">protocol field</a>: <a
href="#Special-File-Fields">Special File Fields</a></li>
-<li><a href="#index-PS-image-format-145">PS image format</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-Python-11">Python</a>: <a href="#Using-Networking">Using
Networking</a></li>
-<li><a
href="#index-Python_002c-_0040command_007bgawk_007d-networking-and-14">Python,
<samp><span class="command">gawk</span></samp> networking and</a>: <a
href="#Using-Networking">Using Networking</a></li>
-<li><a href="#index-RAW-protocol-43">RAW protocol</a>: <a
href="#File-_002finet_002fraw">File /inet/raw</a></li>
-<li><a href="#index-record-separators_002c-HTTP-and-84">record separators,
HTTP and</a>: <a href="#Web-page">Web page</a></li>
-<li><a href="#index-record-separators_002c-POP-and-77">record separators, POP
and</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-REMCONF-program-130">REMCONF program</a>: <a
href="#REMCONF">REMCONF</a></li>
-<li><a href="#index-remoteport-field-26">remoteport field</a>: <a
href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a href="#index-robot-137">robot</a>: <a href="#WEBGRAB">WEBGRAB</a></li>
-<li><a href="#index-robot-123">robot</a>: <a
href="#Challenges">Challenges</a></li>
-<li><a
href="#index-_0040code_007bRS_007d-variable_002c-HTTP-and-85"><code>RS</code>
variable, HTTP and</a>: <a href="#Web-page">Web page</a></li>
-<li><a
href="#index-_0040code_007bRS_007d-variable_002c-POP-and-78"><code>RS</code>
variable, POP and</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-servers-66">servers</a>: <a href="#Setting-Up">Setting
Up</a></li>
-<li><a href="#index-servers-4">servers</a>: <a
href="#Making-Connections">Making Connections</a></li>
-<li><a href="#index-servers_002c-as-hosts-31">servers, as hosts</a>: <a
href="#Special-File-Fields">Special File Fields</a></li>
-<li><a href="#index-servers_002c-HTTP-99">servers, HTTP</a>: <a
href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-servers_002c-web-107">servers, web</a>: <a
href="#Simple-Server">Simple Server</a></li>
-<li><a href="#index-Simple-Mail-Transfer-Protocol-_0028SMTP_0029-75">Simple
Mail Transfer Protocol (SMTP)</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-73">SMTP
(Simple Mail Transfer Protocol)</a>: <a href="#Email">Email</a></li>
-<li><a href="#index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-1">SMTP
(Simple Mail Transfer Protocol)</a>: <a href="#Basic-Protocols">Basic
Protocols</a></li>
-<li><a href="#index-SPAK-utility-45">SPAK utility</a>: <a
href="#File-_002finet_002fraw">File /inet/raw</a></li>
-<li><a href="#index-STATIST-program-140">STATIST program</a>: <a
href="#STATIST">STATIST</a></li>
-<li><a href="#index-STOXPRED-program-159">STOXPRED program</a>: <a
href="#STOXPRED">STOXPRED</a></li>
-<li><a href="#index-synchronous-communications-7">synchronous
communications</a>: <a href="#Making-Connections">Making Connections</a></li>
-<li><a href="#index-Tcl_002fTk-12">Tcl/Tk</a>: <a
href="#Using-Networking">Using Networking</a></li>
-<li><a
href="#index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-124">Tcl/Tk,
<samp><span class="command">gawk</span></samp> and</a>: <a
href="#Some-Applications-and-Techniques">Some Applications and
Techniques</a></li>
-<li><a href="#index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-15">Tcl/Tk,
<samp><span class="command">gawk</span></samp> and</a>: <a
href="#Using-Networking">Using Networking</a></li>
-<li><a href="#index-TCP-_0028Transmission-Control-Protocol_0029-36">TCP
(Transmission Control Protocol)</a>: <a href="#File-_002finet_002ftcp">File
/inet/tcp</a></li>
-<li><a href="#index-TCP-_0028Transmission-Control-Protocol_0029-17">TCP
(Transmission Control Protocol)</a>: <a href="#Using-Networking">Using
Networking</a></li>
-<li><a
href="#index-TCP-_0028Transmission-Control-Protocol_0029_002c-connection_002c-establishing-46">TCP
(Transmission Control Protocol), connection, establishing</a>: <a
href="#TCP-Connecting">TCP Connecting</a></li>
-<li><a
href="#index-TCP-_0028Transmission-Control-Protocol_0029_002c-UDP-and-60">TCP
(Transmission Control Protocol), UDP and</a>: <a
href="#Interacting">Interacting</a></li>
-<li><a href="#index-TCP_002fIP_002c-protocols_002c-selecting-28">TCP/IP,
protocols, selecting</a>: <a href="#Special-File-Fields">Special File
Fields</a></li>
-<li><a href="#index-TCP_002fIP_002c-sockets-and-19">TCP/IP, sockets and</a>:
<a href="#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="#index-Transmission-Control-Protocol_002c-See-TCP-16">Transmission
Control Protocol, See TCP</a>: <a href="#Using-Networking">Using
Networking</a></li>
-<li><a
href="#index-troubleshooting_002c-_0040command_007bgawk_007d_002c-networks-114">troubleshooting,
<samp><span class="command">gawk</span></samp>, networks</a>: <a
href="#Caveats">Caveats</a></li>
-<li><a
href="#index-troubleshooting_002c-networks_002c-connections-54">troubleshooting,
networks, connections</a>: <a href="#Troubleshooting">Troubleshooting</a></li>
-<li><a
href="#index-troubleshooting_002c-networks_002c-timeouts-115">troubleshooting,
networks, timeouts</a>: <a href="#Caveats">Caveats</a></li>
-<li><a href="#index-UDP-_0028User-Datagram-Protocol_0029-39">UDP (User
Datagram Protocol)</a>: <a href="#File-_002finet_002fudp">File
/inet/udp</a></li>
-<li><a href="#index-UDP-_0028User-Datagram-Protocol_0029_002c-TCP-and-61">UDP
(User Datagram Protocol), TCP and</a>: <a
href="#Interacting">Interacting</a></li>
-<li><a href="#index-Unix_002c-network-ports-and-69">Unix, network ports
and</a>: <a href="#Setting-Up">Setting Up</a></li>
-<li><a href="#index-URLCHK-program-135">URLCHK program</a>: <a
href="#URLCHK">URLCHK</a></li>
-<li><a href="#index-User-Datagram-Protocol_002c-See-UDP-40">User Datagram
Protocol, See UDP</a>: <a href="#File-_002finet_002fudp">File /inet/udp</a></li>
-<li><a
href="#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-51">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O)</a>: <a
href="#TCP-Connecting">TCP Connecting</a></li>
-<li><a href="#index-VRML-151">VRML</a>: <a href="#MAZE">MAZE</a></li>
-<li><a href="#index-web-browsers_002c-See-web-service-97">web browsers, See
web service</a>: <a href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-web-pages-81">web pages</a>: <a href="#Web-page">Web
page</a></li>
-<li><a href="#index-web-pages_002c-images-in-103">web pages, images in</a>: <a
href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-web-pages_002c-retrieving-129">web pages, retrieving</a>:
<a href="#GETURL">GETURL</a></li>
-<li><a href="#index-web-servers-106">web servers</a>: <a
href="#Simple-Server">Simple Server</a></li>
-<li><a href="#index-web-service-127">web service</a>: <a
href="#PANIC">PANIC</a></li>
-<li><a href="#index-web-service-95">web service</a>: <a
href="#Primitive-Service">Primitive Service</a></li>
-<li><a href="#index-WEBGRAB-program-136">WEBGRAB program</a>: <a
href="#WEBGRAB">WEBGRAB</a></li>
-<li><a href="#index-Weizenbaum_002c-Joseph-109">Weizenbaum, Joseph</a>: <a
href="#Simple-Server">Simple Server</a></li>
-<li><a href="#index-XBM-image-format-101">XBM image format</a>: <a
href="#Interacting-Service">Interacting Service</a></li>
-<li><a href="#index-Yahoo_0021-160">Yahoo!</a>: <a
href="#STOXPRED">STOXPRED</a></li>
-<li><a href="#index-Yahoo_0021-133">Yahoo!</a>: <a
href="#REMCONF">REMCONF</a></li>
-<li><a
href="#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-50"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="#TCP-Connecting">TCP Connecting</a></li>
- </ul><div class="footnote">
-<hr>
-<a name="texinfo-footnotes-in-document"></a><h4>Footnotes</h4><p
class="footnote"><small>[<a name="fn-1" href="#fnd-1">1</a>]</small>
-It should be noted that although the Internet seems to have conquered the
-world, there are other networking protocol suites in existence and in use.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> In
the days before voice mail systems!</p>
-
- <p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small> For
the technically savvy, data reads
-block—if there's no incoming data, the program is made to wait until
-there is, instead of receiving a “there's no data” error
return.</p>
-
- <p class="footnote"><small>[<a name="fn-4" href="#fnd-4">4</a>]</small>
This special file
-is reserved, but not otherwise currently implemented.</p>
-
- <p class="footnote"><small>[<a name="fn-5" href="#fnd-5">5</a>]</small>
Microsoft prefered to ignore the TCP/IP
-family of protocols until 1995. Then came the rise of the Netscape browser
-as a landmark “killer application.” Microsoft added TCP/IP support
and
-their own browser to Microsoft Windows 95 at the last minute. They even
back-ported
-their TCP/IP implementation to Microsoft Windows for Workgroups 3.11, but it
was
-a rather rudimentary and half-hearted implementation. Nevertheless,
-the equivalent of <samp><span class="file">/etc/services</span></samp> resides
under
-<samp><span class="file">C:\WINNT\system32\drivers\etc\services</span></samp>
on Microsoft Windows 2000.</p>
-
- <p class="footnote"><small>[<a name="fn-6" href="#fnd-6">6</a>]</small>
Version 1.0 of
-HTTP was defined in RFC 1945. HTTP 1.1 was initially specified in RFC
-2068. In June 1999, RFC 2068 was made obsolete by RFC 2616, an update
-without any substantial changes.</p>
-
- <p class="footnote"><small>[<a name="fn-7" href="#fnd-7">7</a>]</small> As
defined in RFC 2068.</p>
-
- <p class="footnote"><small>[<a name="fn-8" href="#fnd-8">8</a>]</small> The
version shown
-here is abbreviated. The full version comes with the <samp><span
class="command">gawk</span></samp>
-distribution.</p>
-
- <p class="footnote"><small>[<a name="fn-9" href="#fnd-9">9</a>]</small> Due
to licensing problems, the default
-installation of GNUPlot disables the generation of <samp><span
class="file">.gif</span></samp> files.
-If your installed version does not accept `<samp><span class="samp">set term
gif</span></samp>',
-just download and install the most recent version of GNUPlot and the
-<a href="http://www.boutell.com/gd/">GD library</a>
-by Thomas Boutell.
-Otherwise you still have the chance to generate some
-ASCII-art style images with GNUPlot by using `<samp><span class="samp">set
term dumb</span></samp>'.
-(We tried it and it worked.)</p>
-
- <p class="footnote"><small>[<a name="fn-10" href="#fnd-10">10</a>]</small>
<a
href="http://www.research.ibm.com/massive/mobag.ps">http://www.research.ibm.com/massive/mobag.ps</a></p>
-
- <p><hr></div>
-
-</body></html>
-
Index: manual/gawkinet/gawkinet.html.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.html.gz
diff -N manual/gawkinet/gawkinet.html.gz
Binary files /tmp/cvsFQ8Tg4 and /dev/null differ
Index: manual/gawkinet/gawkinet.html_node.tar.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.html_node.tar.gz
diff -N manual/gawkinet/gawkinet.html_node.tar.gz
Binary files /tmp/cvsuWxzE4 and /dev/null differ
Index: manual/gawkinet/gawkinet.info.tar.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.info.tar.gz
diff -N manual/gawkinet/gawkinet.info.tar.gz
Binary files /tmp/cvsxBodQ7 and /dev/null differ
Index: manual/gawkinet/gawkinet.pdf
===================================================================
RCS file: manual/gawkinet/gawkinet.pdf
diff -N manual/gawkinet/gawkinet.pdf
Binary files /tmp/cvsMs2kc8 and /dev/null differ
Index: manual/gawkinet/gawkinet.ps.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.ps.gz
diff -N manual/gawkinet/gawkinet.ps.gz
Binary files /tmp/cvs4GIPda and /dev/null differ
Index: manual/gawkinet/gawkinet.texi.tar.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.texi.tar.gz
diff -N manual/gawkinet/gawkinet.texi.tar.gz
Binary files /tmp/cvsTOKQG9 and /dev/null differ
Index: manual/gawkinet/gawkinet.txt
===================================================================
RCS file: manual/gawkinet/gawkinet.txt
diff -N manual/gawkinet/gawkinet.txt
--- manual/gawkinet/gawkinet.txt 29 Jun 2005 21:04:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,4133 +0,0 @@
-This file documents the networking features in GNU `awk'.
-
- This is Edition 1.1 of `TCP/IP Internetworking With `gawk'', for the
-3.1.4 (or later) version of the GNU implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being "GNU General Public License", the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-"GNU Free Documentation License".
-
- a. "A GNU Manual"
-
- b. "You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development."
-
-General Introduction
-********************
-
-This file documents the networking features in GNU Awk (`gawk') version
-3.1 and later.
-
- This is Edition 1.1 of `TCP/IP Internetworking With `gawk'', for the
-3.1.4 (or later) version of the GNU implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being "GNU General Public License", the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-"GNU Free Documentation License".
-
- a. "A GNU Manual"
-
- b. "You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development."
-
-Table of Contents
-*****************
-
-General Introduction
-Preface
-1 Networking Concepts
- 1.1 Reliable Byte-streams (Phone Calls)
- 1.2 Best-effort Datagrams (Mailed Letters)
- 1.3 The Internet Protocols
- 1.3.1 The Basic Internet Protocols
- 1.3.2 TCP and UDP Ports
- 1.4 Making TCP/IP Connections (And Some Terminology)
-2 Networking With `gawk'
- 2.1 `gawk''s Networking Mechanisms
- 2.1.1 The Fields of the Special File Name
- 2.1.2 Comparing Protocols
- 2.1.2.1 `/inet/tcp'
- 2.1.2.2 `/inet/udp'
- 2.1.2.3 `/inet/raw'
- 2.2 Establishing a TCP Connection
- 2.3 Troubleshooting Connection Problems
- 2.4 Interacting with a Network Service
- 2.5 Setting Up a Service
- 2.6 Reading Email
- 2.7 Reading a Web Page
- 2.8 A Primitive Web Service
- 2.9 A Web Service with Interaction
- 2.9.1 A Simple CGI Library
- 2.10 A Simple Web Server
- 2.11 Network Programming Caveats
- 2.12 Where To Go From Here
-3 Some Applications and Techniques
- 3.1 PANIC: An Emergency Web Server
- 3.2 GETURL: Retrieving Web Pages
- 3.3 REMCONF: Remote Configuration of Embedded Systems
- 3.4 URLCHK: Look for Changed Web Pages
- 3.5 WEBGRAB: Extract Links from a Page
- 3.6 STATIST: Graphing a Statistical Distribution
- 3.7 MAZE: Walking Through a Maze In Virtual Reality
- 3.8 MOBAGWHO: a Simple Mobile Agent
- 3.9 STOXPRED: Stock Market Prediction As A Service
- 3.10 PROTBASE: Searching Through A Protein Database
-4 Related Links
-GNU Free Documentation License
- ADDENDUM: How to use this License for your documents
-Index
-
-
-Preface
-*******
-
-In May of 1997, Ju"rgen Kahrs felt the need for network access from
-`awk', and, with a little help from me, set about adding features to do
-this for `gawk'. At that time, he wrote the bulk of this Info file.
-
- The code and documentation were added to the `gawk' 3.1 development
-tree, and languished somewhat until I could finally get down to some
-serious work on that version of `gawk'. This finally happened in the
-middle of 2000.
-
- Meantime, Ju"rgen wrote an article about the Internet special files
-and `|&' operator for `Linux Journal', and made a networking patch for
-the production versions of `gawk' available from his home page. In
-August of 2000 (for `gawk' 3.0.6), this patch also made it to the main
-GNU `ftp' distribution site.
-
- For release with `gawk', I edited Ju"rgen's prose for English
-grammar and style, as he is not a native English speaker. I also
-rearranged the material somewhat for what I felt was a better order of
-presentation, and (re)wrote some of the introductory material.
-
- The majority of this document and the code are his work, and the
-high quality and interesting ideas speak for themselves. It is my hope
-that these features will be of significant value to the `awk' community.
-
-
-Arnold Robbins
-Nof Ayalon, ISRAEL
-March, 2001
-
-1 Networking Concepts
-*********************
-
-This major node provides a (necessarily) brief intoduction to computer
-networking concepts. For many applications of `gawk' to TCP/IP
-networking, we hope that this is enough. For more advanced tasks, you
-will need deeper background, and it may be necessary to switch to
-lower-level programming in C or C++.
-
- There are two real-life models for the way computers send messages
-to each other over a network. While the analogies are not perfect,
-they are close enough to convey the major concepts. These two models
-are the phone system (reliable byte-stream communications), and the
-postal system (best-effort datagrams).
-
-1.1 Reliable Byte-streams (Phone Calls)
-=======================================
-
-When you make a phone call, the following steps occur:
-
- 1. You dial a number.
-
- 2. The phone system connects to the called party, telling them there
- is an incoming call. (Their phone rings.)
-
- 3. The other party answers the call, or, in the case of a computer
- network, refuses to answer the call.
-
- 4. Assuming the other party answers, the connection between you is
- now a "duplex" (two-way), "reliable" (no data lost), sequenced
- (data comes out in the order sent) data stream.
-
- 5. You and your friend may now talk freely, with the phone system
- moving the data (your voices) from one end to the other. From
- your point of view, you have a direct end-to-end connection with
- the person on the other end.
-
- The same steps occur in a duplex reliable computer networking
-connection. There is considerably more overhead in setting up the
-communications, but once it's done, data moves in both directions,
-reliably, in sequence.
-
-1.2 Best-effort Datagrams (Mailed Letters)
-==========================================
-
-Suppose you mail three different documents to your office on the other
-side of the country on two different days. Doing so entails the
-following.
-
- 1. Each document travels in its own envelope.
-
- 2. Each envelope contains both the sender and the recipient address.
-
- 3. Each envelope may travel a different route to its destination.
-
- 4. The envelopes may arrive in a different order from the one in
- which they were sent.
-
- 5. One or more may get lost in the mail. (Although, fortunately,
- this does not occur very often.)
-
- 6. In a computer network, one or more "packets" may also arrive
- multiple times. (This doesn't happen with the postal system!)
-
-
- The important characteristics of datagram communications, like those
-of the postal system are thus:
-
- * Delivery is "best effort;" the data may never get there.
-
- * Each message is self-contained, including the source and
- destination addresses.
-
- * Delivery is _not_ sequenced; packets may arrive out of order,
- and/or multiple times.
-
- * Unlike the phone system, overhead is considerably lower. It is
- not necessary to set up the call first.
-
- The price the user pays for the lower overhead of datagram
-communications is exactly the lower reliability; it is often necessary
-for user-level protocols that use datagram communications to add their
-own reliability features on top of the basic communications.
-
-1.3 The Internet Protocols
-==========================
-
-The Internet Protocol Suite (usually referred to as just TCP/IP)(1)
-consists of a number of different protocols at different levels or
-"layers." For our purposes, three protocols provide the fundamental
-communications mechanisms. All other defined protocols are referred to
-as user-level protocols (e.g., HTTP, used later in this Info file).
-
- ---------- Footnotes ----------
-
- (1) It should be noted that although the Internet seems to have
-conquered the world, there are other networking protocol suites in
-existence and in use.
-
-1.3.1 The Basic Internet Protocols
-----------------------------------
-
-IP
- The Internet Protocol. This protocol is almost never used
- directly by applications. It provides the basic packet delivery
- and routing infrastructure of the Internet. Much like the phone
- company's switching centers or the Post Office's trucks, it is not
- of much day-to-day interest to the regular user (or programmer).
- It happens to be a best effort datagram protocol.
-
-UDP
- The User Datagram Protocol. This is a best effort datagram
- protocol. It provides a small amount of extra reliability over
- IP, and adds the notion of "ports", described in *Note TCP and UDP
- Ports: Ports.
-
-TCP
- The Transmission Control Protocol. This is a duplex, reliable,
- sequenced byte-stream protocol, again layered on top of IP, and
- also providing the notion of ports. This is the protocol that you
- will most likely use when using `gawk' for network programming.
-
- All other user-level protocols use either TCP or UDP to do their
-basic communications. Examples are SMTP (Simple Mail Transfer
-Protocol), FTP (File Transfer Protocol), and HTTP (HyperText Transfer
-Protocol).
-
-1.3.2 TCP and UDP Ports
------------------------
-
-In the postal system, the address on an envelope indicates a physical
-location, such as a residence or office building. But there may be
-more than one person at a location; thus you have to further quantify
-the recipient by putting a person or company name on the envelope.
-
- In the phone system, one phone number may represent an entire
-company, in which case you need a person's extension number in order to
-reach that individual directly. Or, when you call a home, you have to
-say, "May I please speak to ..." before talking to the person directly.
-
- IP networking provides the concept of addressing. An IP address
-represents a particular computer, but no more. In order to reach the
-mail service on a system, or the FTP or WWW service on a system, you
-must have some way to further specify which service you want. In the
-Internet Protocol suite, this is done with "port numbers", which
-represent the services, much like an extension number used with a phone
-number.
-
- Port numbers are 16-bit integers. Unix and Unix-like systems
-reserve ports below 1024 for "well known" services, such as SMTP, FTP,
-and HTTP. Numbers 1024 and above may be used by any application,
-although there is no promise made that a particular port number is
-always available.
-
-1.4 Making TCP/IP Connections (And Some Terminology)
-====================================================
-
-Two terms come up repeatedly when discussing networking: "client" and
-"server". For now, we'll discuss these terms at the "connection
-level", when first establishing connections between two processes on
-different systems over a network. (Once the connection is established,
-the higher level, or "application level" protocols, such as HTTP or
-FTP, determine who is the client and who is the server. Often, it
-turns out that the client and server are the same in both roles.)
-
- The "server" is the system providing the service, such as the web
-server or email server. It is the "host" (system) which is _connected
-to_ in a transaction. For this to work though, the server must be
-expecting connections. Much as there has to be someone at the office
-building to answer the phone(1), the server process (usually) has to be
-started first and be waiting for a connection.
-
- The "client" is the system requesting the service. It is the system
-_initiating the connection_ in a transaction. (Just as when you pick
-up the phone to call an office or store.)
-
- In the TCP/IP framework, each end of a connection is represented by
-a pair of (ADDRESS, PORT) pairs. For the duration of the connection,
-the ports in use at each end are unique, and cannot be used
-simultaneously by other processes on the same system. (Only after
-closing a connection can a new one be built up on the same port. This
-is contrary to the usual behavior of fully developed web servers which
-have to avoid situations in which they are not reachable. We have to
-pay this price in order to enjoy the benefits of a simple communication
-paradigm in `gawk'.)
-
- Furthermore, once the connection is established, communications are
-"synchronous".(2) I.e., each end waits on the other to finish
-transmitting, before replying. This is much like two people in a phone
-conversation. While both could talk simultaneously, doing so usually
-doesn't work too well.
-
- In the case of TCP, the synchronicity is enforced by the protocol
-when sending data. Data writes "block" until the data have been
-received on the other end. For both TCP and UDP, data reads block
-until there is incoming data waiting to be read. This is summarized in
-the following table, where an "X" indicates that the given action
-blocks.
-
-TCP X X
-UDP X
-RAW X
-
- ---------- Footnotes ----------
-
- (1) In the days before voice mail systems!
-
- (2) For the technically savvy, data reads block--if there's no
-incoming data, the program is made to wait until there is, instead of
-receiving a "there's no data" error return.
-
-2 Networking With `gawk'
-************************
-
-The `awk' programming language was originally developed as a
-pattern-matching language for writing short programs to perform data
-manipulation tasks. `awk''s strength is the manipulation of textual
-data that is stored in files. It was never meant to be used for
-networking purposes. To exploit its features in a networking context,
-it's necessary to use an access mode for network connections that
-resembles the access of files as closely as possible.
-
- `awk' is also meant to be a prototyping language. It is used to
-demonstrate feasibility and to play with features and user interfaces.
-This can be done with file-like handling of network connections.
-`gawk' trades the lack of many of the advanced features of the TCP/IP
-family of protocols for the convenience of simple connection handling.
-The advanced features are available when programming in C or Perl. In
-fact, the network programming in this major node is very similar to
-what is described in books such as `Internet Programming with Python',
-`Advanced Perl Programming', or `Web Client Programming with Perl'.
-
- However, you can do the programming here without first having to
-learn object-oriented ideology; underlying languages such as Tcl/Tk,
-Perl, Python; or all of the libraries necessary to extend these
-languages before they are ready for the Internet.
-
- This major node demonstrates how to use the TCP protocol. The other
-protocols are much less important for most users (UDP) or even
-untractable (RAW).
-
-2.1 `gawk''s Networking Mechanisms
-==================================
-
-The `|&' operator introduced in `gawk' 3.1 for use in communicating
-with a "coprocess" is described in *Note Two-way Communications With
-Another Process: (gawk)Two-way I/O. It shows how to do two-way I/O to a
-separate process, sending it data with `print' or `printf' and reading
-data with `getline'. If you haven't read it already, you should detour
-there to do so.
-
- `gawk' transparently extends the two-way I/O mechanism to simple
-networking through the use of special file names. When a "coprocess"
-that matches the special files we are about to describe is started,
-`gawk' creates the appropriate network connection, and then two-way I/O
-proceeds as usual.
-
- At the C, C++, and Perl level, networking is accomplished via
-"sockets", an Application Programming Interface (API) originally
-developed at the University of California at Berkeley that is now used
-almost universally for TCP/IP networking. Socket level programming,
-while fairly straightforward, requires paying attention to a number of
-details, as well as using binary data. It is not well-suited for use
-from a high-level language like `awk'. The special files provided in
-`gawk' hide the details from the programmer, making things much simpler
-and easier to use.
-
- The special file name for network access is made up of several
-fields, all of which are mandatory:
-
- /inet/PROTOCOL/LOCALPORT/HOSTNAME/REMOTEPORT
-
- The `/inet/' field is, of course, constant when accessing the
-network. The LOCALPORT and REMOTEPORT fields do not have a meaning
-when used with `/inet/raw' because "ports" only apply to TCP and UDP.
-So, when using `/inet/raw', the port fields always have to be `0'.
-
-2.1.1 The Fields of the Special File Name
------------------------------------------
-
-This node explains the meaning of all the other fields, as well as the
-range of values and the defaults. All of the fields are mandatory. To
-let the system pick a value, or if the field doesn't apply to the
-protocol, specify it as `0':
-
-PROTOCOL
- Determines which member of the TCP/IP family of protocols is
- selected to transport the data across the network. There are three
- possible values (always written in lowercase): `tcp', `udp', and
- `raw'. The exact meaning of each is explained later in this node.
-
-LOCALPORT
- Determines which port on the local machine is used to communicate
- across the network. It has no meaning with `/inet/raw' and must
- therefore be `0'. Application-level clients usually use `0' to
- indicate they do not care which local port is used--instead they
- specify a remote port to connect to. It is vital for
- application-level servers to use a number different from `0' here
- because their service has to be available at a specific publicly
- known port number. It is possible to use a name from
- `/etc/services' here.
-
-HOSTNAME
- Determines which remote host is to be at the other end of the
- connection. Application-level servers must fill this field with a
- `0' to indicate their being open for all other hosts to connect to
- them and enforce connection level server behavior this way. It is
- not possible for an application-level server to restrict its
- availability to one remote host by entering a host name here.
- Application-level clients must enter a name different from `0'.
- The name can be either symbolic (e.g., `jpl-devvax.jpl.nasa.gov')
- or numeric (e.g., `128.149.1.143').
-
-REMOTEPORT
- Determines which port on the remote machine is used to communicate
- across the network. It has no meaning with `/inet/raw' and must
- therefore be 0. For `/inet/tcp' and `/inet/udp',
- application-level clients _must_ use a number other than `0' to
- indicate to which port on the remote machine they want to connect.
- Application-level servers must not fill this field with a `0'.
- Instead they specify a local port to which clients connect. It is
- possible to use a name from `/etc/services' here.
-
- Experts in network programming will notice that the usual
-client/server asymmetry found at the level of the socket API is not
-visible here. This is for the sake of simplicity of the high-level
-concept. If this asymmetry is necessary for your application, use
-another language. For `gawk', it is more important to enable users to
-write a client program with a minimum of code. What happens when first
-accessing a network connection is seen in the following pseudocode:
-
- if ((name of remote host given) && (other side accepts connection)) {
- rendez-vous successful; transmit with getline or print
- } else {
- if ((other side did not accept) && (localport == 0))
- exit unsuccessful
- if (TCP) {
- set up a server accepting connections
- this means waiting for the client on the other side to connect
- } else
- ready
- }
-
- The exact behavior of this algorithm depends on the values of the
-fields of the special file name. When in doubt, *Note
-table-inet-components:: gives you the combinations of values and their
-meaning. If this table is too complicated, focus on the three lines
-printed in *bold*. All the examples in *Note Networking With `gawk':
-Using Networking, use only the patterns printed in bold letters.
-
-PROTOCOL LOCAL PORT HOST NAME REMOTE RESULTING CONNECTION-LEVEL
- PORT BEHAVIOR
-------------------------------------------------------------------------------
-*tcp* *0* *x* *x* *Dedicated client, fails if
- immediately connecting to a
- server on the
- other side fails*
-udp 0 x x Dedicated client
-raw 0 x 0 Dedicated client, works only
- as `root'
-*tcp, udp* *x* *x* *x* *Client, switches to
- dedicated server if
- necessary*
-*tcp, udp* *x* *0* *0* *Dedicated server*
-raw 0 0 0 Dedicated server, works only
- as `root'
-tcp, udp, x x 0 Invalid
-raw
-tcp, udp, 0 0 x Invalid
-raw
-tcp, udp, x 0 x Invalid
-raw
-tcp, udp 0 0 0 Invalid
-tcp, udp 0 x 0 Invalid
-raw x 0 0 Invalid
-raw 0 x x Invalid
-raw x x x Invalid
-
-Table 2.1: /inet Special File Components
-
- In general, TCP is the preferred mechanism to use. It is the
-simplest protocol to understand and to use. Use the others only if
-circumstances demand low-overhead.
-
-2.1.2 Comparing Protocols
--------------------------
-
-This node develops a pair of programs (sender and receiver) that do
-nothing but send a timestamp from one machine to another. The sender
-and the receiver are implemented with each of the three protocols
-available and demonstrate the differences between them.
-
-2.1.2.1 `/inet/tcp'
-...................
-
-Once again, always use TCP. (Use UDP when low overhead is a necessity,
-and use RAW for network experimentation.) The first example is the
-sender program:
-
- # Server
- BEGIN {
- print strftime() |& "/inet/tcp/8888/0/0"
- close("/inet/tcp/8888/0/0")
- }
-
- The receiver is very simple:
-
- # Client
- BEGIN {
- "/inet/tcp/0/localhost/8888" |& getline
- print $0
- close("/inet/tcp/0/localhost/8888")
- }
-
- TCP guarantees that the bytes arrive at the receiving end in exactly
-the same order that they were sent. No byte is lost (except for broken
-connections), doubled, or out of order. Some overhead is necessary to
-accomplish this, but this is the price to pay for a reliable service.
-It does matter which side starts first. The sender/server has to be
-started first, and it waits for the receiver to read a line.
-
-2.1.2.2 `/inet/udp'
-...................
-
-The server and client programs that use UDP are almost identical to
-their TCP counterparts; only the PROTOCOL has changed. As before, it
-does matter which side starts first. The receiving side blocks and
-waits for the sender. In this case, the receiver/client has to be
-started first:
-
- # Server
- BEGIN {
- print strftime() |& "/inet/udp/8888/0/0"
- close("/inet/udp/8888/0/0")
- }
-
- The receiver is almost identical to the TCP receiver:
-
- # Client
- BEGIN {
- "/inet/udp/0/localhost/8888" |& getline
- print $0
- close("/inet/udp/0/localhost/8888")
- }
-
- UDP cannot guarantee that the datagrams at the receiving end will
-arrive in exactly the same order they were sent. Some datagrams could be
-lost, some doubled, and some out of order. But no overhead is necessary
-to accomplish this. This unreliable behavior is good enough for tasks
-such as data acquisition, logging, and even stateless services like NFS.
-
-2.1.2.3 `/inet/raw'
-...................
-
-This is an IP-level protocol. Only `root' is allowed to access this
-special file. It is meant to be the basis for implementing and
-experimenting with transport-level protocols.(1) In the most general
-case, the sender has to supply the encapsulating header bytes in front
-of the packet and the receiver has to strip the additional bytes from
-the message.
-
- RAW receivers cannot receive packets sent with TCP or UDP because the
-operating system does not deliver the packets to a RAW receiver. The
-operating system knows about some of the protocols on top of IP and
-decides on its own which packet to deliver to which process. (d.c.)
-Therefore, the UDP receiver must be used for receiving UDP datagrams
-sent with the RAW sender. This is a dark corner, not only of `gawk',
-but also of TCP/IP.
-
- For extended experimentation with protocols, look into the approach
-implemented in a tool called SPAK. This tool reflects the hierarchical
-layering of protocols (encapsulation) in the way data streams are piped
-out of one program into the next one. It shows which protocol is based
-on which other (lower-level) protocol by looking at the command-line
-ordering of the program calls. Cleverly thought out, SPAK is much
-better than `gawk''s `/inet' for learning the meaning of each and every
-bit in the protocol headers.
-
- The next example uses the RAW protocol to emulate the behavior of
-UDP. The sender program is the same as above, but with some additional
-bytes that fill the places of the UDP fields:
-
- BEGIN {
- Message = "Hello world\n"
- SourcePort = 0
- DestinationPort = 8888
- MessageLength = length(Message)+8
- RawService = "/inet/raw/0/localhost/0"
- printf("%c%c%c%c%c%c%c%c%s",
- SourcePort/256, SourcePort%256,
- DestinationPort/256, DestinationPort%256,
- MessageLength/256, MessageLength%256,
- 0, 0, Message) |& RawService
- fflush(RawService)
- close(RawService)
- }
-
- Since this program tries to emulate the behavior of UDP, it checks if
-the RAW sender is understood by the UDP receiver but not if the RAW
-receiver can understand the UDP sender. In a real network, the RAW
-receiver is hardly of any use because it gets every IP packet that
-comes across the network. There are usually so many packets that `gawk'
-would be too slow for processing them. Only on a network with little
-traffic can the IP-level receiver program be tested. Programs for
-analyzing IP traffic on modem or ISDN channels should be possible.
-
- Port numbers do not have a meaning when using `/inet/raw'. Their
-fields have to be `0'. Only TCP and UDP use ports. Receiving data from
-`/inet/raw' is difficult, not only because of processing speed but also
-because data is usually binary and not restricted to ASCII. This
-implies that line separation with `RS' does not work as usual.
-
- ---------- Footnotes ----------
-
- (1) This special file is reserved, but not otherwise currently
-implemented.
-
-2.2 Establishing a TCP Connection
-=================================
-
-Let's observe a network connection at work. Type in the following
-program and watch the output. Within a second, it connects via TCP
-(`/inet/tcp') to the machine it is running on (`localhost') and asks
-the service `daytime' on the machine what time it is:
-
- BEGIN {
- "/inet/tcp/0/localhost/daytime" |& getline
- print $0
- close("/inet/tcp/0/localhost/daytime")
- }
-
- Even experienced `awk' users will find the second line strange in two
-respects:
-
- * A special file is used as a shell command that pipes its output
- into `getline'. One would rather expect to see the special file
- being read like any other file (`getline <
- "/inet/tcp/0/localhost/daytime")'.
-
- * The operator `|&' has not been part of any `awk' implementation
- (until now). It is actually the only extension of the `awk'
- language needed (apart from the special files) to introduce
- network access.
-
- The `|&' operator was introduced in `gawk' 3.1 in order to overcome
-the crucial restriction that access to files and pipes in `awk' is
-always unidirectional. It was formerly impossible to use both access
-modes on the same file or pipe. Instead of changing the whole concept
-of file access, the `|&' operator behaves exactly like the usual pipe
-operator except for two additions:
-
- * Normal shell commands connected to their `gawk' program with a `|&'
- pipe can be accessed bidirectionally. The `|&' turns out to be a
- quite general, useful, and natural extension of `awk'.
-
- * Pipes that consist of a special file name for network connections
- are not executed as shell commands. Instead, they can be read and
- written to, just like a full-duplex network connection.
-
- In the earlier example, the `|&' operator tells `getline' to read a
-line from the special file `/inet/tcp/0/localhost/daytime'. We could
-also have printed a line into the special file. But instead we just
-read a line with the time, printed it, and closed the connection.
-(While we could just let `gawk' close the connection by finishing the
-program, in this Info file we are pedantic and always explicitly close
-the connections.)
-
-2.3 Troubleshooting Connection Problems
-=======================================
-
-It may well be that for some reason the program shown in the previous
-example does not run on your machine. When looking at possible reasons
-for this, you will learn much about typical problems that arise in
-network programming. First of all, your implementation of `gawk' may
-not support network access because it is a pre-3.1 version or you do
-not have a network interface in your machine. Perhaps your machine
-uses some other protocol, such as DECnet or Novell's IPX. For the rest
-of this major node, we will assume you work on a Unix machine that
-supports TCP/IP. If the previous example program does not run on your
-machine, it may help to replace the name `localhost' with the name of
-your machine or its IP address. If it does, you could replace
-`localhost' with the name of another machine in your vicinity--this
-way, the program connects to another machine. Now you should see the
-date and time being printed by the program, otherwise your machine may
-not support the `daytime' service. Try changing the service to
-`chargen' or `ftp'. This way, the program connects to other services
-that should give you some response. If you are curious, you should have
-a look at your `/etc/services' file. It could look like this:
-
- # /etc/services:
- #
- # Network services, Internet style
- #
- # Name Number/Protcol Alternate name # Comments
-
- echo 7/tcp
- echo 7/udp
- discard 9/tcp sink null
- discard 9/udp sink null
- daytime 13/tcp
- daytime 13/udp
- chargen 19/tcp ttytst source
- chargen 19/udp ttytst source
- ftp 21/tcp
- telnet 23/tcp
- smtp 25/tcp mail
- finger 79/tcp
- www 80/tcp http # WorldWideWeb HTTP
- www 80/udp # HyperText Transfer Protocol
- pop-2 109/tcp postoffice # POP version 2
- pop-2 109/udp
- pop-3 110/tcp # POP version 3
- pop-3 110/udp
- nntp 119/tcp readnews untp # USENET News
- irc 194/tcp # Internet Relay Chat
- irc 194/udp
- ...
-
- Here, you find a list of services that traditional Unix machines
-usually support. If your GNU/Linux machine does not do so, it may be
-that these services are switched off in some startup script. Systems
-running some flavor of Microsoft Windows usually do _not_ support these
-services. Nevertheless, it _is_ possible to do networking with `gawk'
-on Microsoft Windows.(1) The first column of the file gives the name of
-the service, and the second column gives a unique number and the
-protocol that one can use to connect to this service. The rest of the
-line is treated as a comment. You see that some services (`echo')
-support TCP as well as UDP.
-
- ---------- Footnotes ----------
-
- (1) Microsoft prefered to ignore the TCP/IP family of protocols
-until 1995. Then came the rise of the Netscape browser as a landmark
-"killer application." Microsoft added TCP/IP support and their own
-browser to Microsoft Windows 95 at the last minute. They even
-back-ported their TCP/IP implementation to Microsoft Windows for
-Workgroups 3.11, but it was a rather rudimentary and half-hearted
-implementation. Nevertheless, the equivalent of `/etc/services' resides
-under `C:\WINNT\system32\drivers\etc\services' on Microsoft Windows
-2000.
-
-2.4 Interacting with a Network Service
-======================================
-
-The next program makes use of the possibility to really interact with a
-network service by printing something into the special file. It asks the
-so-called `finger' service if a user of the machine is logged in. When
-testing this program, try to change `localhost' to some other machine
-name in your local network:
-
- BEGIN {
- NetService = "/inet/tcp/0/localhost/finger"
- print "NAME" |& NetService
- while ((NetService |& getline) > 0)
- print $0
- close(NetService)
- }
-
- After telling the service on the machine which user to look for, the
-program repeatedly reads lines that come as a reply. When no more lines
-are coming (because the service has closed the connection), the program
-also closes the connection. Try replacing `"NAME"' with your login name
-(or the name of someone else logged in). For a list of all users
-currently logged in, replace NAME with an empty string (`""').
-
- The final `close' command could be safely deleted from the above
-script, because the operating system closes any open connection by
-default when a script reaches the end of execution. In order to avoid
-portability problems, it is best to always close connections explicitly.
-With the Linux kernel, for example, proper closing results in flushing
-of buffers. Letting the close happen by default may result in
-discarding buffers.
-
- When looking at `/etc/services' you may have noticed that the
-`daytime' service is also available with `udp'. In the earlier example,
-change `tcp' to `udp', and change `finger' to `daytime'. After
-starting the modified program, you see the expected day and time
-message. The program then hangs, because it waits for more lines
-coming from the service. However, they never come. This behavior is a
-consequence of the differences between TCP and UDP. When using UDP,
-neither party is automatically informed about the other closing the
-connection. Continuing to experiment this way reveals many other subtle
-differences between TCP and UDP. To avoid such trouble, one should
-always remember the advice Douglas E. Comer and David Stevens give in
-Volume III of their series `Internetworking With TCP' (page 14):
-
- When designing client-server applications, beginners are strongly
- advised to use TCP because it provides reliable,
- connection-oriented communication. Programs only use UDP if the
- application protocol handles reliability, the application requires
- hardware broadcast or multicast, or the application cannot
- tolerate virtual circuit overhead.
-
-2.5 Setting Up a Service
-========================
-
-The preceding programs behaved as clients that connect to a server
-somewhere on the Internet and request a particular service. Now we set
-up such a service to mimic the behavior of the `daytime' service. Such
-a server does not know in advance who is going to connect to it over
-the network. Therefore, we cannot insert a name for the host to connect
-to in our special file name.
-
- Start the following program in one window. Notice that the service
-does not have the name `daytime', but the number `8888'. From looking
-at `/etc/services', you know that names like `daytime' are just
-mnemonics for predetermined 16-bit integers. Only the system
-administrator (`root') could enter our new service into `/etc/services'
-with an appropriate name. Also notice that the service name has to be
-entered into a different field of the special file name because we are
-setting up a server, not a client:
-
- BEGIN {
- print strftime() |& "/inet/tcp/8888/0/0"
- close("/inet/tcp/8888/0/0")
- }
-
- Now open another window on the same machine. Copy the client
-program given as the first example (*note Establishing a TCP
-Connection: TCP Connecting.) to a new file and edit it, changing the
-name `daytime' to `8888'. Then start the modified client. You should
-get a reply like this:
-
- Sat Sep 27 19:08:16 CEST 1997
-
-Both programs explicitly close the connection.
-
- Now we will intentionally make a mistake to see what happens when
-the name `8888' (the so-called port) is already used by another service.
-Start the server program in both windows. The first one works, but the
-second one complains that it could not open the connection. Each port
-on a single machine can only be used by one server program at a time.
-Now terminate the server program and change the name `8888' to `echo'.
-After restarting it, the server program does not run any more, and you
-know why: there is already an `echo' service running on your machine.
-But even if this isn't true, you would not get your own `echo' server
-running on a Unix machine, because the ports with numbers smaller than
-1024 (`echo' is at port 7) are reserved for `root'. On machines
-running some flavor of Microsoft Windows, there is no restriction that
-reserves ports 1 to 1024 for a privileged user; hence, you can start an
-`echo' server there.
-
- Turning this short server program into something really useful is
-simple. Imagine a server that first reads a file name from the client
-through the network connection, then does something with the file and
-sends a result back to the client. The server-side processing could be:
-
- BEGIN {
- NetService = "/inet/tcp/8888/0/0"
- NetService |& getline
- CatPipe = ("cat " $1) # sets $0 and the fields
- while ((CatPipe | getline) > 0)
- print $0 |& NetService
- close(NetService)
- }
-
-and we would have a remote copying facility. Such a server reads the
-name of a file from any client that connects to it and transmits the
-contents of the named file across the net. The server-side processing
-could also be the execution of a command that is transmitted across the
-network. From this example, you can see how simple it is to open up a
-security hole on your machine. If you allow clients to connect to your
-machine and execute arbitrary commands, anyone would be free to do `rm
--rf *'.
-
-2.6 Reading Email
-=================
-
-The distribution of email is usually done by dedicated email servers
-that communicate with your machine using special protocols. To receive
-email, we will use the Post Office Protocol (POP). Sending can be done
-with the much older Simple Mail Transfer Protocol (SMTP).
-
- When you type in the following program, replace the EMAILHOST by the
-name of your local email server. Ask your administrator if the server
-has a POP service, and then use its name or number in the program below.
-Now the program is ready to connect to your email server, but it will
-not succeed in retrieving your mail because it does not yet know your
-login name or password. Replace them in the program and it shows you
-the first email the server has in store:
-
- BEGIN {
- POPService = "/inet/tcp/0/EMAILHOST/pop3"
- RS = ORS = "\r\n"
- print "user NAME" |& POPService
- POPService |& getline
- print "pass PASSWORD" |& POPService
- POPService |& getline
- print "retr 1" |& POPService
- POPService |& getline
- if ($1 != "+OK") exit
- print "quit" |& POPService
- RS = "\r\n\\.\r\n"
- POPService |& getline
- print $0
- close(POPService)
- }
-
- The record separators `RS' and `ORS' are redefined because the
-protocol (POP) requires CR-LF to separate lines. After identifying
-yourself to the email service, the command `retr 1' instructs the
-service to send the first of all your email messages in line. If the
-service replies with something other than `+OK', the program exits;
-maybe there is no email. Otherwise, the program first announces that it
-intends to finish reading email, and then redefines `RS' in order to
-read the entire email as multiline input in one record. From the POP
-RFC, we know that the body of the email always ends with a single line
-containing a single dot. The program looks for this using `RS =
-"\r\n\\.\r\n"'. When it finds this sequence in the mail message, it
-quits. You can invoke this program as often as you like; it does not
-delete the message it reads, but instead leaves it on the server.
-
-2.7 Reading a Web Page
-======================
-
-Retrieving a web page from a web server is as simple as retrieving
-email from an email server. We only have to use a similar, but not
-identical, protocol and a different port. The name of the protocol is
-HyperText Transfer Protocol (HTTP) and the port number is usually 80.
-As in the preceding node, ask your administrator about the name of your
-local web server or proxy web server and its port number for HTTP
-requests.
-
- The following program employs a rather crude approach toward
-retrieving a web page. It uses the prehistoric syntax of HTTP 0.9,
-which almost all web servers still support. The most noticeable thing
-about it is that the program directs the request to the local proxy
-server whose name you insert in the special file name (which in turn
-calls `www.yahoo.com'):
-
- BEGIN {
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/0/PROXY/80"
- print "GET http://www.yahoo.com" |& HttpService
- while ((HttpService |& getline) > 0)
- print $0
- close(HttpService)
- }
-
- Again, lines are separated by a redefined `RS' and `ORS'. The `GET'
-request that we send to the server is the only kind of HTTP request
-that existed when the web was created in the early 1990s. HTTP calls
-this `GET' request a "method," which tells the service to transmit a
-web page (here the home page of the Yahoo! search engine). Version 1.0
-added the request methods `HEAD' and `POST'. The current version of
-HTTP is 1.1,(1) and knows the additional request methods `OPTIONS',
-`PUT', `DELETE', and `TRACE'. You can fill in any valid web address,
-and the program prints the HTML code of that page to your screen.
-
- Notice the similarity between the responses of the POP and HTTP
-services. First, you get a header that is terminated by an empty line,
-and then you get the body of the page in HTML. The lines of the
-headers also have the same form as in POP. There is the name of a
-parameter, then a colon, and finally the value of that parameter.
-
- Images (`.png' or `.gif' files) can also be retrieved this way, but
-then you get binary data that should be redirected into a file. Another
-application is calling a CGI (Common Gateway Interface) script on some
-server. CGI scripts are used when the contents of a web page are not
-constant, but generated instantly at the moment you send a request for
-the page. For example, to get a detailed report about the current
-quotes of Motorola stock shares, call a CGI script at Yahoo! with the
-following:
-
- get = "GET http://quote.yahoo.com/q?s=MOT&d=t"
- print get |& HttpService
-
- You can also request weather reports this way.
-
- ---------- Footnotes ----------
-
- (1) Version 1.0 of HTTP was defined in RFC 1945. HTTP 1.1 was
-initially specified in RFC 2068. In June 1999, RFC 2068 was made
-obsolete by RFC 2616, an update without any substantial changes.
-
-2.8 A Primitive Web Service
-===========================
-
-Now we know enough about HTTP to set up a primitive web service that
-just says `"Hello, world"' when someone connects to it with a browser.
-Compared to the situation in the preceding node, our program changes
-the role. It tries to behave just like the server we have observed.
-Since we are setting up a server here, we have to insert the port
-number in the `localport' field of the special file name. The other two
-fields (HOSTNAME and REMOTEPORT) have to contain a `0' because we do
-not know in advance which host will connect to our service.
-
- In the early 1990s, all a server had to do was send an HTML document
-and close the connection. Here, we adhere to the modern syntax of HTTP.
-The steps are as follows:
-
- 1. Send a status line telling the web browser that everything is okay.
-
- 2. Send a line to tell the browser how many bytes follow in the body
- of the message. This was not necessary earlier because both
- parties knew that the document ended when the connection closed.
- Nowadays it is possible to stay connected after the transmission
- of one web page. This is to avoid the network traffic necessary
- for repeatedly establishing TCP connections for requesting several
- images. Thus, there is the need to tell the receiving party how
- many bytes will be sent. The header is terminated as usual with an
- empty line.
-
- 3. Send the `"Hello, world"' body in HTML. The useless `while' loop
- swallows the request of the browser. We could actually omit the
- loop, and on most machines the program would still work. First,
- start the following program:
-
- BEGIN {
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/8080/0/0"
- Hello = "<HTML><HEAD>" \
- "<TITLE>A Famous Greeting</TITLE></HEAD>" \
- "<BODY><H1>Hello, world</H1></BODY></HTML>"
- Len = length(Hello) + length(ORS)
- print "HTTP/1.0 200 OK" |& HttpService
- print "Content-Length: " Len ORS |& HttpService
- print Hello |& HttpService
- while ((HttpService |& getline) > 0)
- continue;
- close(HttpService)
- }
-
- Now, on the same machine, start your favorite browser and let it
-point to `http://localhost:8080' (the browser needs to know on which
-port our server is listening for requests). If this does not work, the
-browser probably tries to connect to a proxy server that does not know
-your machine. If so, change the browser's configuration so that the
-browser does not try to use a proxy to connect to your machine.
-
-2.9 A Web Service with Interaction
-==================================
-
-This node shows how to set up a simple web server. The subnode is a
-library file that we will use with all the examples in *Note Some
-Applications and Techniques::.
-
-Setting up a web service that allows user interaction is more difficult
-and shows us the limits of network access in `gawk'. In this node, we
-develop a main program (a `BEGIN' pattern and its action) that will
-become the core of event-driven execution controlled by a graphical
-user interface (GUI). Each HTTP event that the user triggers by some
-action within the browser is received in this central procedure.
-Parameters and menu choices are extracted from this request, and an
-appropriate measure is taken according to the user's choice. For
-example:
-
- BEGIN {
- if (MyHost == "") {
- "uname -n" | getline MyHost
- close("uname -n")
- }
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- MyPrefix = "http://" MyHost ":" MyPort
- SetUpServer()
- while ("awk" != "complex") {
- # header lines are terminated this way
- RS = ORS = "\r\n"
- Status = 200 # this means OK
- Reason = "OK"
- Header = TopHeader
- Document = TopDoc
- Footer = TopFooter
- if (GETARG["Method"] == "GET") {
- HandleGET()
- } else if (GETARG["Method"] == "HEAD") {
- # not yet implemented
- } else if (GETARG["Method"] != "") {
- print "bad method", GETARG["Method"]
- }
- Prompt = Header Document Footer
- print "HTTP/1.0", Status, Reason |& HttpService
- print "Connection: Close" |& HttpService
- print "Pragma: no-cache" |& HttpService
- len = length(Prompt) + length(ORS)
- print "Content-length:", len |& HttpService
- print ORS Prompt |& HttpService
- # ignore all the header lines
- while ((HttpService |& getline) > 0)
- ;
- # stop talking to this client
- close(HttpService)
- # wait for new client request
- HttpService |& getline
- # do some logging
- print systime(), strftime(), $0
- # read request parameters
- CGI_setup($1, $2, $3)
- }
- }
-
- This web server presents menu choices in the form of HTML links.
-Therefore, it has to tell the browser the name of the host it is
-residing on. When starting the server, the user may supply the name of
-the host from the command line with `gawk -v MyHost="Rumpelstilzchen"'.
-If the user does not do this, the server looks up the name of the host
-it is running on for later use as a web address in HTML documents. The
-same applies to the port number. These values are inserted later into
-the HTML content of the web pages to refer to the home system.
-
- Each server that is built around this core has to initialize some
-application-dependent variables (such as the default home page) in a
-procedure `SetUpServer', which is called immediately before entering the
-infinite loop of the server. For now, we will write an instance that
-initiates a trivial interaction. With this home page, the client user
-can click on two possible choices, and receive the current date either
-in human-readable format or in seconds since 1970:
-
- function SetUpServer() {
- TopHeader = "<HTML><HEAD>"
- TopHeader = TopHeader \
- "<title>My name is GAWK, GNU AWK</title></HEAD>"
- TopDoc = "<BODY><h2>\
- Do you prefer your date <A HREF=" MyPrefix \
- "/human>human</A> or \
- <A HREF=" MyPrefix "/POSIX>POSIXed</A>?</h2>" ORS ORS
- TopFooter = "</BODY></HTML>"
- }
-
- On the first run through the main loop, the default line terminators
-are set and the default home page is copied to the actual home page.
-Since this is the first run, `GETARG["Method"]' is not initialized yet,
-hence the case selection over the method does nothing. Now that the
-home page is initialized, the server can start communicating to a
-client browser.
-
- It does so by printing the HTTP header into the network connection
-(`print ... |& HttpService'). This command blocks execution of the
-server script until a client connects. If this server script is
-compared with the primitive one we wrote before, you will notice two
-additional lines in the header. The first instructs the browser to
-close the connection after each request. The second tells the browser
-that it should never try to _remember_ earlier requests that had
-identical web addresses (no caching). Otherwise, it could happen that
-the browser retrieves the time of day in the previous example just once,
-and later it takes the web page from the cache, always displaying the
-same time of day although time advances each second.
-
- Having supplied the initial home page to the browser with a valid
-document stored in the parameter `Prompt', it closes the connection and
-waits for the next request. When the request comes, a log line is
-printed that allows us to see which request the server receives. The
-final step in the loop is to call the function `CGI_setup', which reads
-all the lines of the request (coming from the browser), processes them,
-and stores the transmitted parameters in the array `PARAM'. The complete
-text of these application-independent functions can be found in *Note A
-Simple CGI Library: CGI Lib. For now, we use a simplified version of
-`CGI_setup':
-
- function CGI_setup( method, uri, version, i) {
- delete GETARG; delete MENU; delete PARAM
- GETARG["Method"] = $1
- GETARG["URI"] = $2
- GETARG["Version"] = $3
- i = index($2, "?")
- # is there a "?" indicating a CGI request?
- if (i > 0) {
- split(substr($2, 1, i-1), MENU, "[/:]")
- split(substr($2, i+1), PARAM, "&")
- for (i in PARAM) {
- j = index(PARAM[i], "=")
- GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
- }
- } else { # there is no "?", no need for splitting PARAMs
- split($2, MENU, "[/:]")
- }
- }
-
- At first, the function clears all variables used for global storage
-of request parameters. The rest of the function serves the purpose of
-filling the global parameters with the extracted new values. To
-accomplish this, the name of the requested resource is split into parts
-and stored for later evaluation. If the request contains a `?', then
-the request has CGI variables seamlessly appended to the web address.
-Everything in front of the `?' is split up into menu items, and
-everything behind the `?' is a list of `VARIABLE=VALUE' pairs
-(separated by `&') that also need splitting. This way, CGI variables are
-isolated and stored. This procedure lacks recognition of special
-characters that are transmitted in coded form(1). Here, any optional
-request header and body parts are ignored. We do not need header
-parameters and the request body. However, when refining our approach or
-working with the `POST' and `PUT' methods, reading the header and body
-becomes inevitable. Header parameters should then be stored in a global
-array as well as the body.
-
- On each subsequent run through the main loop, one request from a
-browser is received, evaluated, and answered according to the user's
-choice. This can be done by letting the value of the HTTP method guide
-the main loop into execution of the procedure `HandleGET', which
-evaluates the user's choice. In this case, we have only one
-hierarchical level of menus, but in the general case, menus are nested.
-The menu choices at each level are separated by `/', just as in file
-names. Notice how simple it is to construct menus of arbitrary depth:
-
- function HandleGET() {
- if ( MENU[2] == "human") {
- Footer = strftime() TopFooter
- } else if (MENU[2] == "POSIX") {
- Footer = systime() TopFooter
- }
- }
-
- The disadvantage of this approach is that our server is slow and can
-handle only one request at a time. Its main advantage, however, is that
-the server consists of just one `gawk' program. No need for installing
-an `httpd', and no need for static separate HTML files, CGI scripts, or
-`root' privileges. This is rapid prototyping. This program can be
-started on the same host that runs your browser. Then let your browser
-point to `http://localhost:8080'.
-
- It is also possible to include images into the HTML pages. Most
-browsers support the not very well-known `.xbm' format, which may
-contain only monochrome pictures but is an ASCII format. Binary images
-are possible but not so easy to handle. Another way of including images
-is to generate them with a tool such as GNUPlot, by calling the tool
-with the `system' function or through a pipe.
-
- ---------- Footnotes ----------
-
- (1) As defined in RFC 2068.
-
-2.9.1 A Simple CGI Library
---------------------------
-
- HTTP is like being married: you have to be able to handle whatever
- you're given, while being very careful what you send back.
- Phil Smith III,
- `http://www.netfunny.com/rhf/jokes/99/Mar/http.html'
-
- In *Note A Web Service with Interaction: Interacting Service, we saw
-the function `CGI_setup' as part of the web server "core logic"
-framework. The code presented there handles almost everything necessary
-for CGI requests. One thing it doesn't do is handle encoded characters
-in the requests. For example, an `&' is encoded as a percent sign
-followed by the hexadecimal value: `%26'. These encoded values should
-be decoded. Following is a simple library to perform these tasks.
-This code is used for all web server examples used throughout the rest
-of this Info file. If you want to use it for your own web server,
-store the source code into a file named `inetlib.awk'. Then you can
-include these functions into your code by placing the following
-statement into your program (on the first line of your script):
-
- @include inetlib.awk
-
-But beware, this mechanism is only possible if you invoke your web
-server script with `igawk' instead of the usual `awk' or `gawk'. Here
-is the code:
-
- # CGI Library and core of a web server
- # Global arrays
- # GETARG --- arguments to CGI GET command
- # MENU --- menu items (path names)
- # PARAM --- parameters of form x=y
-
- # Optional variable MyHost contains host address
- # Optional variable MyPort contains port number
- # Needs TopHeader, TopDoc, TopFooter
- # Sets MyPrefix, HttpService, Status, Reason
-
- BEGIN {
- if (MyHost == "") {
- "uname -n" | getline MyHost
- close("uname -n")
- }
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- MyPrefix = "http://" MyHost ":" MyPort
- SetUpServer()
- while ("awk" != "complex") {
- # header lines are terminated this way
- RS = ORS = "\r\n"
- Status = 200 # this means OK
- Reason = "OK"
- Header = TopHeader
- Document = TopDoc
- Footer = TopFooter
- if (GETARG["Method"] == "GET") {
- HandleGET()
- } else if (GETARG["Method"] == "HEAD") {
- # not yet implemented
- } else if (GETARG["Method"] != "") {
- print "bad method", GETARG["Method"]
- }
- Prompt = Header Document Footer
- print "HTTP/1.0", Status, Reason |& HttpService
- print "Connection: Close" |& HttpService
- print "Pragma: no-cache" |& HttpService
- len = length(Prompt) + length(ORS)
- print "Content-length:", len |& HttpService
- print ORS Prompt |& HttpService
- # ignore all the header lines
- while ((HttpService |& getline) > 0)
- continue
- # stop talking to this client
- close(HttpService)
- # wait for new client request
- HttpService |& getline
- # do some logging
- print systime(), strftime(), $0
- CGI_setup($1, $2, $3)
- }
- }
-
- function CGI_setup( method, uri, version, i)
- {
- delete GETARG
- delete MENU
- delete PARAM
- GETARG["Method"] = method
- GETARG["URI"] = uri
- GETARG["Version"] = version
-
- i = index(uri, "?")
- if (i > 0) { # is there a "?" indicating a CGI request?
- split(substr(uri, 1, i-1), MENU, "[/:]")
- split(substr(uri, i+1), PARAM, "&")
- for (i in PARAM) {
- PARAM[i] = _CGI_decode(PARAM[i])
- j = index(PARAM[i], "=")
- GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
- }
- } else { # there is no "?", no need for splitting PARAMs
- split(uri, MENU, "[/:]")
- }
- for (i in MENU) # decode characters in path
- if (i > 4) # but not those in host name
- MENU[i] = _CGI_decode(MENU[i])
- }
-
- This isolates details in a single function, `CGI_setup'. Decoding
-of encoded characters is pushed off to a helper function,
-`_CGI_decode'. The use of the leading underscore (`_') in the function
-name is intended to indicate that it is an "internal" function,
-although there is nothing to enforce this:
-
- function _CGI_decode(str, hexdigs, i, pre, code1, code2,
- val, result)
- {
- hexdigs = "123456789abcdef"
-
- i = index(str, "%")
- if (i == 0) # no work to do
- return str
-
- do {
- pre = substr(str, 1, i-1) # part before %xx
- code1 = substr(str, i+1, 1) # first hex digit
- code2 = substr(str, i+2, 1) # second hex digit
- str = substr(str, i+3) # rest of string
-
- code1 = tolower(code1)
- code2 = tolower(code2)
- val = index(hexdigs, code1) * 16 \
- + index(hexdigs, code2)
-
- result = result pre sprintf("%c", val)
- i = index(str, "%")
- } while (i != 0)
- if (length(str) > 0)
- result = result str
- return result
- }
-
- This works by splitting the string apart around an encoded character.
-The two digits are converted to lowercase characters and looked up in a
-string of hex digits. Note that `0' is not in the string on purpose;
-`index' returns zero when it's not found, automatically giving the
-correct value! Once the hexadecimal value is converted from characters
-in a string into a numerical value, `sprintf' converts the value back
-into a real character. The following is a simple test harness for the
-above functions:
-
- BEGIN {
- CGI_setup("GET",
- "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \
- "&percent=a %25 sign",
- "1.0")
- for (i in MENU)
- printf "MENU[\"%s\"] = %s\n", i, MENU[i]
- for (i in PARAM)
- printf "PARAM[\"%s\"] = %s\n", i, PARAM[i]
- for (i in GETARG)
- printf "GETARG[\"%s\"] = %s\n", i, GETARG[i]
- }
-
- And this is the result when we run it:
-
- $ gawk -f testserv.awk
- -| MENU["4"] = www.gnu.org
- -| MENU["5"] = cgi-bin
- -| MENU["6"] = foo
- -| MENU["1"] = http
- -| MENU["2"] =
- -| MENU["3"] =
- -| PARAM["1"] = p1=stuff
- -| PARAM["2"] = p2=stuff&junk
- -| PARAM["3"] = percent=a % sign
- -| GETARG["p1"] = stuff
- -| GETARG["percent"] = a % sign
- -| GETARG["p2"] = stuff&junk
- -| GETARG["Method"] = GET
- -| GETARG["Version"] = 1.0
- -| GETARG["URI"] = http://www.gnu.org/cgi-bin/foo?p1=stuff&
- p2=stuff%26junk&percent=a %25 sign
-
-2.10 A Simple Web Server
-========================
-
-In the preceding node, we built the core logic for event-driven GUIs.
-In this node, we finally extend the core to a real application. No one
-would actually write a commercial web server in `gawk', but it is
-instructive to see that it is feasible in principle.
-
- The application is ELIZA, the famous program by Joseph Weizenbaum
-that mimics the behavior of a professional psychotherapist when talking
-to you. Weizenbaum would certainly object to this description, but
-this is part of the legend around ELIZA. Take the site-independent
-core logic and append the following code:
-
- function SetUpServer() {
- SetUpEliza()
- TopHeader = \
- "<HTML><title>An HTTP-based System with GAWK</title>\
- <HEAD><META HTTP-EQUIV=\"Content-Type\"\
- CONTENT=\"text/html; charset=iso-8859-1\"></HEAD>\
- <BODY BGCOLOR=\"#ffffff\" TEXT=\"#000000\"\
- LINK=\"#0000ff\" VLINK=\"#0000ff\"\
- ALINK=\"#0000ff\"> <A NAME=\"top\">"
- TopDoc = "\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI>\
- <A HREF=" MyPrefix "/AboutServer>About this server</A>\
- </LI><LI>\
- <A HREF=" MyPrefix "/AboutELIZA>About Eliza</A></LI>\
- <LI>\
- <A HREF=" MyPrefix \
- "/StartELIZA>Start talking to Eliza</A></LI></UL>"
- TopFooter = "</BODY></HTML>"
- }
-
- `SetUpServer' is similar to the previous example, except for calling
-another function, `SetUpEliza'. This approach can be used to implement
-other kinds of servers. The only changes needed to do so are hidden in
-the functions `SetUpServer' and `HandleGET'. Perhaps it might be
-necessary to implement other HTTP methods. The `igawk' program that
-comes with `gawk' may be useful for this process.
-
- When extending this example to a complete application, the first
-thing to do is to implement the function `SetUpServer' to initialize
-the HTML pages and some variables. These initializations determine the
-way your HTML pages look (colors, titles, menu items, etc.).
-
- The function `HandleGET' is a nested case selection that decides
-which page the user wants to see next. Each nesting level refers to a
-menu level of the GUI. Each case implements a certain action of the
-menu. On the deepest level of case selection, the handler essentially
-knows what the user wants and stores the answer into the variable that
-holds the HTML page contents:
-
- function HandleGET() {
- # A real HTTP server would treat some parts of the URI as a file name.
- # We take parts of the URI as menu choices and go on accordingly.
- if(MENU[2] == "AboutServer") {
- Document = "This is not a CGI script.\
- This is an httpd, an HTML file, and a CGI script all \
- in one GAWK script. It needs no separate www-server, \
- no installation, and no root privileges.\
- <p>To run it, do this:</p><ul>\
- <li> start this script with \"gawk -f httpserver.awk\",</li>\
- <li> and on the same host let your www browser open location\
- \"http://localhost:8080\"</li>\
- </ul>\<p>\ Details of HTTP come from:</p><ul>\
- <li>Hethmon: Illustrated Guide to HTTP</p>\
- <li>RFC 2068</li></ul><p>JK 14.9.1997</p>"
- } else if (MENU[2] == "AboutELIZA") {
- Document = "This is an implementation of the famous ELIZA\
- program by Joseph Weizenbaum. It is written in GAWK and\
- /bin/sh: expad: command not found
- } else if (MENU[2] == "StartELIZA") {
- gsub(/\+/, " ", GETARG["YouSay"])
- # Here we also have to substitute coded special characters
- Document = "<form method=GET>" \
- "<h3>" ElizaSays(GETARG["YouSay"]) "</h3>\
- <p><input type=text name=YouSay value=\"\" size=60>\
- <br><input type=submit value=\"Tell her about it\"></p></form>"
- }
- }
-
- Now we are down to the heart of ELIZA, so you can see how it works.
-Initially the user does not say anything; then ELIZA resets its money
-counter and asks the user to tell what comes to mind open heartedly.
-The subsequent answers are converted to uppercase characters and stored
-for later comparison. ELIZA presents the bill when being confronted with
-a sentence that contains the phrase "shut up." Otherwise, it looks for
-keywords in the sentence, conjugates the rest of the sentence, remembers
-the keyword for later use, and finally selects an answer from the set of
-possible answers:
-
- function ElizaSays(YouSay) {
- if (YouSay == "") {
- cost = 0
- answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM"
- } else {
- q = toupper(YouSay)
- gsub("'", "", q)
- if(q == qold) {
- answer = "PLEASE DONT REPEAT YOURSELF !"
- } else {
- if (index(q, "SHUT UP") > 0) {
- answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\
- int(100*rand()+30+cost/100)
- } else {
- qold = q
- w = "-" # no keyword recognized yet
- for (i in k) { # search for keywords
- if (index(q, i) > 0) {
- w = i
- break
- }
- }
- if (w == "-") { # no keyword, take old subject
- w = wold
- subj = subjold
- } else { # find subject
- subj = substr(q, index(q, w) + length(w)+1)
- wold = w
- subjold = subj # remember keyword and subject
- }
- for (i in conj)
- gsub(i, conj[i], q) # conjugation
- # from all answers to this keyword, select one randomly
- answer = r[indices[int(split(k[w], indices) * rand()) + 1]]
- # insert subject into answer
- gsub("_", subj, answer)
- }
- }
- }
- cost += length(answer) # for later payment : 1 cent per character
- return answer
- }
-
- In the long but simple function `SetUpEliza', you can see tables for
-conjugation, keywords, and answers.(1) The associative array `k'
-contains indices into the array of answers `r'. To choose an answer,
-ELIZA just picks an index randomly:
-
- function SetUpEliza() {
- srand()
- wold = "-"
- subjold = " "
-
- # table for conjugation
- conj[" ARE " ] = " AM "
- conj["WERE " ] = "WAS "
- conj[" YOU " ] = " I "
- conj["YOUR " ] = "MY "
- conj[" IVE " ] =\
- conj[" I HAVE " ] = " YOU HAVE "
- conj[" YOUVE " ] =\
- conj[" YOU HAVE "] = " I HAVE "
- conj[" IM " ] =\
- conj[" I AM " ] = " YOU ARE "
- conj[" YOURE " ] =\
- conj[" YOU ARE " ] = " I AM "
-
- # table of all answers
- r[1] = "DONT YOU BELIEVE THAT I CAN _"
- r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?"
- ...
-
- # table for looking up answers that
- # fit to a certain keyword
- k["CAN YOU"] = "1 2 3"
- k["CAN I"] = "4 5"
- k["YOU ARE"] =\
- k["YOURE"] = "6 7 8 9"
- ...
-
- }
-
- Some interesting remarks and details (including the original source
-code of ELIZA) are found on Mark Humphrys' home page. Yahoo! also has
-a page with a collection of ELIZA-like programs. Many of them are
-written in Java, some of them disclosing the Java source code, and a
-few even explain how to modify the Java source code.
-
- ---------- Footnotes ----------
-
- (1) The version shown here is abbreviated. The full version comes
-with the `gawk' distribution.
-
-2.11 Network Programming Caveats
-================================
-
-By now it should be clear that debugging a networked application is more
-complicated than debugging a single-process single-hosted application.
-The behavior of a networked application sometimes looks noncausal
-because it is not reproducible in a strong sense. Whether a network
-application works or not sometimes depends on the following:
-
- * How crowded the underlying network is
-
- * If the party at the other end is running or not
-
- * The state of the party at the other end
-
- The most difficult problems for a beginner arise from the hidden
-states of the underlying network. After closing a TCP connection, it's
-often necessary to wait a short while before reopening the connection.
-Even more difficult is the establishment of a connection that
-previously ended with a "broken pipe." Those connections have to "time
-out" for a minute or so before they can reopen. Check this with the
-command `netstat -a', which provides a list of still "active"
-connections.
-
-2.12 Where To Go From Here
-==========================
-
-Now, you have learned enough to build your own application. You could,
-for example, take part in the Loebner Contest to win $100,000. The
-Loebner Prize is the first formal instantiation of a Turing Test. Hugh
-Loebner agreed with The Cambridge Center for Behavioral Studies to
-underwrite a contest designed to implement the Turing Test. Dr.
-Loebner pledged a Grand Prize of $100,000 for the first computer whose
-responses were indistinguishable from a human's. Each year an annual
-prize of $2000 and a bronze medal is awarded to the _most_ human
-computer. The winner of the annual contest is the best entry relative
-to other entries that year, irrespective of how good it is in an
-absolute sense. Here is an example of a conversation with the winning
-program of 1997:
-
- (c)1997 Cambridge Center For Behavioral Studies all rights reserved
[CONVERSE]
- [Intelligent Research Ltd.] Start at: [1997/04/29 08:59:40]
- PROGRAM[10:39:20]Hi, my name is Catherine, what's yours?
- JUDGE02[10:39:36]My name is Nathan.
- PROGRAM[10:39:37]Well, it's nice to meet you, Nathan.
- PROGRAM[10:39:45]Did you see that story on CNN last night about the
lesbian
- PROGRAM[10:40:03]couple who came out at a White House party on Sunday?
- JUDGE02[10:40:45]No. I'm sorry I missed that. How did the Prez take it?
- PROGRAM[10:40:47]Ellen Degeneres was one of them - she was kissing her
lover
- PROGRAM[10:41:08]in front of Bill Clinton. Do you think he was very
- PROGRAM[10:41:21]embarrassed?
- JUDGE02[10:41:37]You tell me. I didn't see it.
- PROGRAM[10:41:38]Are you still a Friend of Bill Clinton?
- JUDGE02[10:42:22]Yes. I would like to talk about something else. Do you
know anything about sculpture.
- PROGRAM[10:42:24]Well, I suppose he's doing his best like most of us, but
he
- PROGRAM[10:42:35]does seem to attract an UNUSUAL amount of bad publicity,
- PROGRAM[10:42:51]wouldnt you say--can it all be bad luck?
- JUDGE02[10:43:20]I asked you if you knew anything about sculpture.
- PROGRAM[10:43:21]OK, but what happens now--does it all drift on, with
- PROGRAM[10:43:36]everyone waiting to see how much his friends have said
about
- PROGRAM[10:43:47]him under threat of lots and lots of jail-or will
something
- PROGRAM[10:44:01]dramatic actually happen?
- JUDGE02[10:44:19]Do you know what sculpture is?
- PROGRAM[10:44:20]Well, youre more a fan of his than I am I guess---though
I
- PROGRAM[10:44:34]cant SWEAR what Id have done in that locked hotel room, I
- PROGRAM[10:44:51]must say.
- JUDGE02[10:45:26]Have you ever been to the Salmagundi Club?
- PROGRAM[10:45:29]Never. to go back to the original discussion Time to get
- PROGRAM[10:45:43]off this one I think and onto something more down to
earth!
- JUDGE02[10:46:20]What is more down to earth than art?
- PROGRAM[10:46:21]I don't know what -- to be honest. -
- PROGRAM[10:46:30]I suppose it depends on where you're coming from, but as
the
- PROGRAM[10:46:46]song goes in My Fair Lady, "Why can't a woman be more
like a
- PROGRAM[10:47:03]man? "
- JUDGE02[10:47:52]I liked that song but I prefer "Why can't children be
more like we are"
- JUDGE02[10:48:10]from another play the name of which I cannot remember.
- PROGRAM[10:48:12]What, if anything, do you enjoy about being a man?
- JUDGE02[10:49:01]I would enjoy all aspects of life no matter what my
gender.
- PROGRAM[10:49:02]Do you think of yourself as being attractive?
-
- This program insists on always speaking about the same story around
-Bill Clinton. You see, even a program with a rather narrow mind can
-behave so much like a human being that it can win this prize. It is
-quite common to let these programs talk to each other via network
-connections. But during the competition itself, the program and its
-computer have to be present at the place the competition is held. We
-all would love to see a `gawk' program win in such an event. Maybe it
-is up to you to accomplish this?
-
- Some other ideas for useful networked applications:
- * Read the file `doc/awkforai.txt' in the `gawk' distribution. It
- was written by Ronald P. Loui (Associate Professor of Computer
- Science, at Washington University in St. Louis,
- <address@hidden>) and summarizes why he teaches `gawk' to
- students of Artificial Intelligence. Here are some passages from
- the text:
-
- The GAWK manual can be consumed in a single lab session and
- the language can be mastered by the next morning by the
- average student. GAWK's automatic initialization, implicit
- coercion, I/O support and lack of pointers forgive many of
- the mistakes that young programmers are likely to make.
- Those who have seen C but not mastered it are happy to see
- that GAWK retains some of the same sensibilities while adding
- what must be regarded as spoonsful of syntactic sugar.
- ...
- There are further simple answers. Probably the best is the
- fact that increasingly, undergraduate AI programming is
- involving the Web. Oren Etzioni (University of Washington,
- Seattle) has for a while been arguing that the "softbot" is
- replacing the mechanical engineers' robot as the most
- glamorous AI testbed. If the artifact whose behavior needs
- to be controlled in an intelligent way is the software agent,
- then a language that is well-suited to controlling the
- software environment is the appropriate language. That would
- imply a scripting language. If the robot is KAREL, then the
- right language is "turn left; turn right." If the robot is
- Netscape, then the right language is something that can
- generate `netscape -remote
- 'openURL(http://cs.wustl.edu/~loui)'' with elan.
- ...
- AI programming requires high-level thinking. There have
- always been a few gifted programmers who can write high-level
- programs in assembly language. Most however need the ambient
- abstraction to have a higher floor.
- ...
- Second, inference is merely the expansion of notation. No
- matter whether the logic that underlies an AI program is
- fuzzy, probabilistic, deontic, defeasible, or deductive, the
- logic merely defines how strings can be transformed into
- other strings. A language that provides the best support for
- string processing in the end provides the best support for
- logic, for the exploration of various logics, and for most
- forms of symbolic processing that AI might choose to call
- "reasoning" instead of "logic." The implication is that
- PROLOG, which saves the AI programmer from having to write a
- unifier, saves perhaps two dozen lines of GAWK code at the
- expense of strongly biasing the logic and representational
- expressiveness of any approach.
-
- Now that `gawk' itself can connect to the Internet, it should be
- obvious that it is suitable for writing intelligent web agents.
-
- * `awk' is strong at pattern recognition and string processing. So,
- it is well suited to the classic problem of language translation.
- A first try could be a program that knows the 100 most frequent
- English words and their counterparts in German or French. The
- service could be implemented by regularly reading email with the
- program above, replacing each word by its translation and sending
- the translation back via SMTP. Users would send English email to
- their translation service and get back a translated email message
- in return. As soon as this works, more effort can be spent on a
- real translation program.
-
- * Another dialogue-oriented application (on the verge of ridicule)
- is the email "support service." Troubled customers write an email
- to an automatic `gawk' service that reads the email. It looks for
- keywords in the mail and assembles a reply email accordingly. By
- carefully investigating the email header, and repeating these
- keywords through the reply email, it is rather simple to give the
- customer a feeling that someone cares. Ideally, such a service
- would search a database of previous cases for solutions. If none
- exists, the database could, for example, consist of all the
- newsgroups, mailing lists and FAQs on the Internet.
-
-3 Some Applications and Techniques
-**********************************
-
-In this major node, we look at a number of self-contained scripts, with
-an emphasis on concise networking. Along the way, we work towards
-creating building blocks that encapsulate often needed functions of the
-networking world, show new techniques that broaden the scope of
-problems that can be solved with `gawk', and explore leading edge
-technology that may shape the future of networking.
-
- We often refer to the site-independent core of the server that we
-built in *Note A Simple Web Server: Simple Server. When building new
-and nontrivial servers, we always copy this building block and append
-new instances of the two functions `SetUpServer' and `HandleGET'.
-
- This makes a lot of sense, since this scheme of event-driven
-execution provides `gawk' with an interface to the most widely accepted
-standard for GUIs: the web browser. Now, `gawk' can rival even Tcl/Tk.
-
- Tcl and `gawk' have much in common. Both are simple scripting
-languages that allow us to quickly solve problems with short programs.
-But Tcl has Tk on top of it, and `gawk' had nothing comparable up to
-now. While Tcl needs a large and ever-changing library (Tk, which was
-bound to the X Window System until recently), `gawk' needs just the
-networking interface and some kind of browser on the client's side.
-Besides better portability, the most important advantage of this
-approach (embracing well-established standards such HTTP and HTML) is
-that _we do not need to change the language_. We let others do the work
-of fighting over protocols and standards. We can use HTML, JavaScript,
-VRML, or whatever else comes along to do our work.
-
-3.1 PANIC: An Emergency Web Server
-==================================
-
-At first glance, the `"Hello, world"' example in *Note A Primitive Web
-Service: Primitive Service, seems useless. By adding just a few lines,
-we can turn it into something useful.
-
- The PANIC program tells everyone who connects that the local site is
-not working. When a web server breaks down, it makes a difference if
-customers get a strange "network unreachable" message, or a short
-message telling them that the server has a problem. In such an
-emergency, the hard disk and everything on it (including the regular
-web service) may be unavailable. Rebooting the web server off a
-diskette makes sense in this setting.
-
- To use the PANIC program as an emergency web server, all you need
-are the `gawk' executable and the program below on a diskette. By
-default, it connects to port 8080. A different value may be supplied on
-the command line:
-
- BEGIN {
- RS = ORS = "\r\n"
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- Hello = "<HTML><HEAD><TITLE>Out Of Service</TITLE>" \
- "</HEAD><BODY><H1>" \
- "This site is temporarily out of service." \
- "</H1></BODY></HTML>"
- Len = length(Hello) + length(ORS)
- while ("awk" != "complex") {
- print "HTTP/1.0 200 OK" |& HttpService
- print "Content-Length: " Len ORS |& HttpService
- print Hello |& HttpService
- while ((HttpService |& getline) > 0)
- continue;
- close(HttpService)
- }
- }
-
-3.2 GETURL: Retrieving Web Pages
-================================
-
-GETURL is a versatile building block for shell scripts that need to
-retrieve files from the Internet. It takes a web address as a
-command-line parameter and tries to retrieve the contents of this
-address. The contents are printed to standard output, while the header
-is printed to `/dev/stderr'. A surrounding shell script could analyze
-the contents and extract the text or the links. An ASCII browser could
-be written around GETURL. But more interestingly, web robots are
-straightforward to write on top of GETURL. On the Internet, you can find
-several programs of the same name that do the same job. They are usually
-much more complex internally and at least 10 times longer.
-
- At first, GETURL checks if it was called with exactly one web
-address. Then, it checks if the user chose to use a special proxy
-server whose name is handed over in a variable. By default, it is
-assumed that the local machine serves as proxy. GETURL uses the `GET'
-method by default to access the web page. By handing over the name of a
-different method (such as `HEAD'), it is possible to choose a different
-behavior. With the `HEAD' method, the user does not receive the body of
-the page content, but does receive the header:
-
- BEGIN {
- if (ARGC != 2) {
- print "GETURL - retrieve Web page via HTTP 1.0"
- print "IN:\n the URL as a command-line parameter"
- print "PARAM(S):\n -v Proxy=MyProxy"
- print "OUT:\n the page content on stdout"
- print " the page header on stderr"
- print "JK 16.05.1997"
- print "ADR 13.08.2000"
- exit
- }
- URL = ARGV[1]; ARGV[1] = ""
- if (Proxy == "") Proxy = "127.0.0.1"
- if (ProxyPort == 0) ProxyPort = 80
- if (Method == "") Method = "GET"
- HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort
- ORS = RS = "\r\n\r\n"
- print Method " " URL " HTTP/1.0" |& HttpService
- HttpService |& getline Header
- print Header > "/dev/stderr"
- while ((HttpService |& getline) > 0)
- printf "%s", $0
- close(HttpService)
- }
-
- This program can be changed as needed, but be careful with the last
-lines. Make sure transmission of binary data is not corrupted by
-additional line breaks. Even as it is now, the byte sequence
-`"\r\n\r\n"' would disappear if it were contained in binary data. Don't
-get caught in a trap when trying a quick fix on this one.
-
-3.3 REMCONF: Remote Configuration of Embedded Systems
-=====================================================
-
-Today, you often find powerful processors in embedded systems.
-Dedicated network routers and controllers for all kinds of machinery
-are examples of embedded systems. Processors like the Intel 80x86 or
-the AMD Elan are able to run multitasking operating systems, such as
-XINU or GNU/Linux in embedded PCs. These systems are small and usually
-do not have a keyboard or a display. Therefore it is difficult to set
-up their configuration. There are several widespread ways to set them
-up:
-
- * DIP switches
-
- * Read Only Memories such as EPROMs
-
- * Serial lines or some kind of keyboard
-
- * Network connections via `telnet' or SNMP
-
- * HTTP connections with HTML GUIs
-
- In this node, we look at a solution that uses HTTP connections to
-control variables of an embedded system that are stored in a file.
-Since embedded systems have tight limits on resources like memory, it
-is difficult to employ advanced techniques such as SNMP and HTTP
-servers. `gawk' fits in quite nicely with its single executable which
-needs just a short script to start working. The following program
-stores the variables in a file, and a concurrent process in the
-embedded system may read the file. The program uses the
-site-independent part of the simple web server that we developed in
-*Note A Web Service with Interaction: Interacting Service. As
-mentioned there, all we have to do is to write two new procedures
-`SetUpServer' and `HandleGET':
-
- function SetUpServer() {
- TopHeader = "<HTML><title>Remote Configuration</title>"
- TopDoc = "<BODY>\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this server</A></LI>\
- <LI><A HREF=" MyPrefix "/ReadConfig>Read Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/CheckConfig>Check Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/ChangeConfig>Change Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/SaveConfig>Save Configuration</A></LI>\
- </UL>"
- TopFooter = "</BODY></HTML>"
- if (ConfigFile == "") ConfigFile = "config.asc"
- }
-
- The function `SetUpServer' initializes the top level HTML texts as
-usual. It also initializes the name of the file that contains the
-configuration parameters and their values. In case the user supplies a
-name from the command line, that name is used. The file is expected to
-contain one parameter per line, with the name of the parameter in
-column one and the value in column two.
-
- The function `HandleGET' reflects the structure of the menu tree as
-usual. The first menu choice tells the user what this is all about. The
-second choice reads the configuration file line by line and stores the
-parameters and their values. Notice that the record separator for this
-file is `"\n"', in contrast to the record separator for HTTP. The third
-menu choice builds an HTML table to show the contents of the
-configuration file just read. The fourth choice does the real work of
-changing parameters, and the last one just saves the configuration into
-a file:
-
- function HandleGET() {
- if(MENU[2] == "AboutServer") {
- Document = "This is a GUI for remote configuration of an\
- embedded system. It is is implemented as one GAWK script."
- } else if (MENU[2] == "ReadConfig") {
- RS = "\n"
- while ((getline < ConfigFile) > 0)
- config[$1] = $2;
- close(ConfigFile)
- RS = "\r\n"
- Document = "Configuration has been read."
- } else if (MENU[2] == "CheckConfig") {
- Document = "<TABLE BORDER=1 CELLPADDING=5>"
- for (i in config)
- Document = Document "<TR><TD>" i "</TD>" \
- "<TD>" config[i] "</TD></TR>"
- Document = Document "</TABLE>"
- } else if (MENU[2] == "ChangeConfig") {
- if ("Param" in GETARG) { # any parameter to set?
- if (GETARG["Param"] in config) { # is parameter valid?
- config[GETARG["Param"]] = GETARG["Value"]
- Document = (GETARG["Param"] " = " GETARG["Value"] ".")
- } else {
- Document = "Parameter <b>" GETARG["Param"] "</b> is invalid."
- }
- } else {
- Document = "<FORM method=GET><h4>Change one parameter</h4>\
- <TABLE BORDER CELLPADDING=5>\
- <TR><TD>Parameter</TD><TD>Value</TD></TR>\
- <TR><TD><input type=text name=Param value=\"\" size=20></TD>\
- <TD><input type=text name=Value value=\"\" size=40></TD>\
- </TR></TABLE><input type=submit value=\"Set\"></FORM>"
- }
- } else if (MENU[2] == "SaveConfig") {
- for (i in config)
- printf("%s %s\n", i, config[i]) > ConfigFile
- close(ConfigFile)
- Document = "Configuration has been saved."
- }
- }
-
- We could also view the configuration file as a database. From this
-point of view, the previous program acts like a primitive database
-server. Real SQL database systems also make a service available by
-providing a TCP port that clients can connect to. But the application
-level protocols they use are usually proprietary and also change from
-time to time. This is also true for the protocol that MiniSQL uses.
-
-3.4 URLCHK: Look for Changed Web Pages
-======================================
-
-Most people who make heavy use of Internet resources have a large
-bookmark file with pointers to interesting web sites. It is impossible
-to regularly check by hand if any of these sites have changed. A program
-is needed to automatically look at the headers of web pages and tell
-which ones have changed. URLCHK does the comparison after using GETURL
-with the `HEAD' method to retrieve the header.
-
- Like GETURL, this program first checks that it is called with exactly
-one command-line parameter. URLCHK also takes the same command-line
-variables `Proxy' and `ProxyPort' as GETURL, because these variables
-are handed over to GETURL for each URL that gets checked. The one and
-only parameter is the name of a file that contains one line for each
-URL. In the first column, we find the URL, and the second and third
-columns hold the length of the URL's body when checked for the two last
-times. Now, we follow this plan:
-
- 1. Read the URLs from the file and remember their most recent lengths
-
- 2. Delete the contents of the file
-
- 3. For each URL, check its new length and write it into the file
-
- 4. If the most recent and the new length differ, tell the user
-
- It may seem a bit peculiar to read the URLs from a file together
-with their two most recent lengths, but this approach has several
-advantages. You can call the program again and again with the same
-file. After running the program, you can regenerate the changed URLs by
-extracting those lines that differ in their second and third columns:
-
- BEGIN {
- if (ARGC != 2) {
- print "URLCHK - check if URLs have changed"
- print "IN:\n the file with URLs as a command-line parameter"
- print " file contains URL, old length, new length"
- print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080"
- print "OUT:\n same as file with URLs"
- print "JK 02.03.1998"
- exit
- }
- URLfile = ARGV[1]; ARGV[1] = ""
- if (Proxy != "") Proxy = " -v Proxy=" Proxy
- if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort
- while ((getline < URLfile) > 0)
- Length[$1] = $3 + 0
- close(URLfile) # now, URLfile is read in and can be updated
- GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk "
- for (i in Length) {
- GetThisHeader = GetHeader i " 2>&1"
- while ((GetThisHeader | getline) > 0)
- if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0
- close(GetThisHeader)
- print i, Length[i], NewLength > URLfile
- if (Length[i] != NewLength) # report only changed URLs
- print i, Length[i], NewLength
- }
- close(URLfile)
- }
-
- Another thing that may look strange is the way GETURL is called.
-Before calling GETURL, we have to check if the proxy variables need to
-be passed on. If so, we prepare strings that will become part of the
-command line later. In `GetHeader', we store these strings together
-with the longest part of the command line. Later, in the loop over the
-URLs, `GetHeader' is appended with the URL and a redirection operator
-to form the command that reads the URL's header over the Internet.
-GETURL always produces the headers over `/dev/stderr'. That is the
-reason why we need the redirection operator to have the header piped in.
-
- This program is not perfect because it assumes that changing URLs
-results in changed lengths, which is not necessarily true. A more
-advanced approach is to look at some other header line that holds time
-information. But, as always when things get a bit more complicated,
-this is left as an exercise to the reader.
-
-3.5 WEBGRAB: Extract Links from a Page
-======================================
-
-Sometimes it is necessary to extract links from web pages. Browsers do
-it, web robots do it, and sometimes even humans do it. Since we have a
-tool like GETURL at hand, we can solve this problem with some help from
-the Bourne shell:
-
- BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" }
- RT != "" {
- command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \
- " > doc" NR ".html")
- print command
- }
-
- Notice that the regular expression for URLs is rather crude. A
-precise regular expression is much more complex. But this one works
-rather well. One problem is that it is unable to find internal links of
-an HTML document. Another problem is that `ftp', `telnet', `news',
-`mailto', and other kinds of links are missing in the regular
-expression. However, it is straightforward to add them, if doing so is
-necessary for other tasks.
-
- This program reads an HTML file and prints all the HTTP links that
-it finds. It relies on `gawk''s ability to use regular expressions as
-record separators. With `RS' set to a regular expression that matches
-links, the second action is executed each time a non-empty link is
-found. We can find the matching link itself in `RT'.
-
- The action could use the `system' function to let another GETURL
-retrieve the page, but here we use a different approach. This simple
-program prints shell commands that can be piped into `sh' for
-execution. This way it is possible to first extract the links, wrap
-shell commands around them, and pipe all the shell commands into a
-file. After editing the file, execution of the file retrieves exactly
-those files that we really need. In case we do not want to edit, we can
-retrieve all the pages like this:
-
- gawk -f geturl.awk http://www.suse.de | gawk -f webgrab.awk | sh
-
- After this, you will find the contents of all referenced documents in
-files named `doc*.html' even if they do not contain HTML code. The
-most annoying thing is that we always have to pass the proxy to GETURL.
-If you do not like to see the headers of the web pages appear on the
-screen, you can redirect them to `/dev/null'. Watching the headers
-appear can be quite interesting, because it reveals interesting details
-such as which web server the companies use. Now, it is clear how the
-clever marketing people use web robots to determine the market shares
-of Microsoft and Netscape in the web server market.
-
- Port 80 of any web server is like a small hole in a repellent
-firewall. After attaching a browser to port 80, we usually catch a
-glimpse of the bright side of the server (its home page). With a tool
-like GETURL at hand, we are able to discover some of the more concealed
-or even "indecent" services (i.e., lacking conformity to standards of
-quality). It can be exciting to see the fancy CGI scripts that lie
-there, revealing the inner workings of the server, ready to be called:
-
- * With a command such as:
-
- gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/
-
- some servers give you a directory listing of the CGI files.
- Knowing the names, you can try to call some of them and watch for
- useful results. Sometimes there are executables in such directories
- (such as Perl interpreters) that you may call remotely. If there
- are subdirectories with configuration data of the web server, this
- can also be quite interesting to read.
-
- * The well-known Apache web server usually has its CGI files in the
- directory `/cgi-bin'. There you can often find the scripts
- `test-cgi' and `printenv'. Both tell you some things about the
- current connection and the installation of the web server. Just
- call:
-
- gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/test-cgi
- gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/printenv
-
- * Sometimes it is even possible to retrieve system files like the web
- server's log file--possibly containing customer data--or even the
- file `/etc/passwd'. (We don't recommend this!)
-
- *Caution:* Although this may sound funny or simply irrelevant, we
-are talking about severe security holes. Try to explore your own system
-this way and make sure that none of the above reveals too much
-information about your system.
-
-3.6 STATIST: Graphing a Statistical Distribution
-================================================
-
-In the HTTP server examples we've shown thus far, we never present an
-image to the browser and its user. Presenting images is one task.
-Generating images that reflect some user input and presenting these
-dynamically generated images is another. In this node, we use GNUPlot
-for generating `.png', `.ps', or `.gif' files.(1)
-
- The program we develop takes the statistical parameters of two
-samples and computes the t-test statistics. As a result, we get the
-probabilities that the means and the variances of both samples are the
-same. In order to let the user check plausibility, the program presents
-an image of the distributions. The statistical computation follows
-`Numerical Recipes in C: The Art of Scientific Computing' by William H.
-Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery.
-Since `gawk' does not have a built-in function for the computation of
-the beta function, we use the `ibeta' function of GNUPlot. As a side
-effect, we learn how to use GNUPlot as a sophisticated calculator. The
-comparison of means is done as in `tutest', paragraph 14.2, page 613,
-and the comparison of variances is done as in `ftest', page 611 in
-`Numerical Recipes'.
-
- As usual, we take the site-independent code for servers and append
-our own functions `SetUpServer' and `HandleGET':
-
- function SetUpServer() {
- TopHeader = "<HTML><title>Statistics with GAWK</title>"
- TopDoc = "<BODY>\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this server</A></LI>\
- <LI><A HREF=" MyPrefix "/EnterParameters>Enter Parameters</A></LI>\
- </UL>"
- TopFooter = "</BODY></HTML>"
- GnuPlot = "gnuplot 2>&1"
- m1=m2=0; v1=v2=1; n1=n2=10
- }
-
- Here, you see the menu structure that the user sees. Later, we will
-see how the program structure of the `HandleGET' function reflects the
-menu structure. What is missing here is the link for the image we
-generate. In an event-driven environment, request, generation, and
-delivery of images are separated.
-
- Notice the way we initialize the `GnuPlot' command string for the
-pipe. By default, GNUPlot outputs the generated image via standard
-output, as well as the results of `print'(ed) calculations via standard
-error. The redirection causes standard error to be mixed into standard
-output, enabling us to read results of calculations with `getline'. By
-initializing the statistical parameters with some meaningful defaults,
-we make sure the user gets an image the first time he uses the program.
-
- Following is the rather long function `HandleGET', which implements
-the contents of this service by reacting to the different kinds of
-requests from the browser. Before you start playing with this script,
-make sure that your browser supports JavaScript and that it also has
-this option switched on. The script uses a short snippet of JavaScript
-code for delayed opening of a window with an image. A more detailed
-explanation follows:
-
- function HandleGET() {
- if(MENU[2] == "AboutServer") {
- Document = "This is a GUI for a statistical computation.\
- It compares means and variances of two distributions.\
- It is implemented as one GAWK script and uses GNUPLOT."
- } else if (MENU[2] == "EnterParameters") {
- Document = ""
- if ("m1" in GETARG) { # are there parameters to compare?
- Document = Document "<SCRIPT LANGUAGE=\"JavaScript\">\
- setTimeout(\"window.open(\\\"" MyPrefix "/Image" systime()\
- "\\\",\\\"dist\\\", \\\"status=no\\\");\", 1000); </SCRIPT>"
- m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"]
- m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"]
- t = (m1-m2)/sqrt(v1/n1+v2/n2)
- df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \
- + (v2/n2)*(v2/n2) /(n2-1))
- if (v1>v2) {
- f = v1/v2
- df1 = n1 - 1
- df2 = n2 - 1
- } else {
- f = v2/v1
- df1 = n2 - 1
- df2 = n1 - 1
- }
- print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot
- print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \
- df2/(df2+df1*f) ")" |& GnuPlot
- print "print pt, pF" |& GnuPlot
- RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF
- print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot
- print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot
- print "set term png small color" |& GnuPlot
- #print "set term postscript color" |& GnuPlot
- #print "set term gif medium size 320,240" |& GnuPlot
- print "set yrange[-0.3:]" |& GnuPlot
- print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot
- print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot
- print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\
- mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot
- print "quit" |& GnuPlot
- GnuPlot |& getline Image
- while ((GnuPlot |& getline) > 0)
- Image = Image RS $0
- close(GnuPlot)
- }
- Document = Document "\
- <h3>Do these samples have the same Gaussian distribution?</h3>\
- <FORM METHOD=GET> <TABLE BORDER CELLPADDING=5>\
- <TR>\
- <TD>1. Mean </TD>
- <TD><input type=text name=m1 value=" m1 " size=8></TD>\
- <TD>1. Variance</TD>
- <TD><input type=text name=v1 value=" v1 " size=8></TD>\
- <TD>1. Count </TD>
- <TD><input type=text name=n1 value=" n1 " size=8></TD>\
- </TR><TR>\
- <TD>2. Mean </TD>
- <TD><input type=text name=m2 value=" m2 " size=8></TD>\
- <TD>2. Variance</TD>
- <TD><input type=text name=v2 value=" v2 " size=8></TD>\
- <TD>2. Count </TD>
- <TD><input type=text name=n2 value=" n2 " size=8></TD>\
- </TR> <input type=submit value=\"Compute\">\
- </TABLE></FORM><BR>"
- } else if (MENU[2] ~ "Image") {
- Reason = "OK" ORS "Content-type: image/png"
- #Reason = "OK" ORS "Content-type: application/x-postscript"
- #Reason = "OK" ORS "Content-type: image/gif"
- Header = Footer = ""
- Document = Image
- }
- }
-
- As usual, we give a short description of the service in the first
-menu choice. The third menu choice shows us that generation and
-presentation of an image are two separate actions. While the latter
-takes place quite instantly in the third menu choice, the former takes
-place in the much longer second choice. Image data passes from the
-generating action to the presenting action via the variable `Image'
-that contains a complete `.png' image, which is otherwise stored in a
-file. If you prefer `.ps' or `.gif' images over the default `.png'
-images, you may select these options by uncommenting the appropriate
-lines. But remember to do so in two places: when telling GNUPlot which
-kind of images to generate, and when transmitting the image at the end
-of the program.
-
- Looking at the end of the program, the way we pass the
-`Content-type' to the browser is a bit unusual. It is appended to the
-`OK' of the first header line to make sure the type information becomes
-part of the header. The other variables that get transmitted across
-the network are made empty, because in this case we do not have an HTML
-document to transmit, but rather raw image data to contain in the body.
-
- Most of the work is done in the second menu choice. It starts with a
-strange JavaScript code snippet. When first implementing this server,
-we used a short `"<IMG SRC=" MyPrefix "/Image>"' here. But then
-browsers got smarter and tried to improve on speed by requesting the
-image and the HTML code at the same time. When doing this, the browser
-tries to build up a connection for the image request while the request
-for the HTML text is not yet completed. The browser tries to connect to
-the `gawk' server on port 8080 while port 8080 is still in use for
-transmission of the HTML text. The connection for the image cannot be
-built up, so the image appears as "broken" in the browser window. We
-solved this problem by telling the browser to open a separate window
-for the image, but only after a delay of 1000 milliseconds. By this
-time, the server should be ready for serving the next request.
-
- But there is one more subtlety in the JavaScript code. Each time
-the JavaScript code opens a window for the image, the name of the image
-is appended with a timestamp (`systime'). Why this constant change of
-name for the image? Initially, we always named the image `Image', but
-then the Netscape browser noticed the name had _not_ changed since the
-previous request and displayed the previous image (caching behavior).
-The server core is implemented so that browsers are told _not_ to cache
-anything. Obviously HTTP requests do not always work as expected. One
-way to circumvent the cache of such overly smart browsers is to change
-the name of the image with each request. These three lines of JavaScript
-caused us a lot of trouble.
-
- The rest can be broken down into two phases. At first, we check if
-there are statistical parameters. When the program is first started,
-there usually are no parameters because it enters the page coming from
-the top menu. Then, we only have to present the user a form that he
-can use to change statistical parameters and submit them. Subsequently,
-the submission of the form causes the execution of the first phase
-because _now_ there _are_ parameters to handle.
-
- Now that we have parameters, we know there will be an image
-available. Therefore we insert the JavaScript code here to initiate
-the opening of the image in a separate window. Then, we prepare some
-variables that will be passed to GNUPlot for calculation of the
-probabilities. Prior to reading the results, we must temporarily change
-`RS' because GNUPlot separates lines with newlines. After instructing
-GNUPlot to generate a `.png' (or `.ps' or `.gif') image, we initiate
-the insertion of some text, explaining the resulting probabilities. The
-final `plot' command actually generates the image data. This raw binary
-has to be read in carefully without adding, changing, or deleting a
-single byte. Hence the unusual initialization of `Image' and completion
-with a `while' loop.
-
- When using this server, it soon becomes clear that it is far from
-being perfect. It mixes source code of six scripting languages or
-protocols:
-
- * GNU `awk' implements a server for the protocol:
-
- * HTTP which transmits:
-
- * HTML text which contains a short piece of:
-
- * JavaScript code opening a separate window.
-
- * A Bourne shell script is used for piping commands into:
-
- * GNUPlot to generate the image to be opened.
-
- After all this work, the GNUPlot image opens in the JavaScript window
-where it can be viewed by the user.
-
- It is probably better not to mix up so many different languages.
-The result is not very readable. Furthermore, the statistical part of
-the server does not take care of invalid input. Among others, using
-negative variances will cause invalid results.
-
- ---------- Footnotes ----------
-
- (1) Due to licensing problems, the default installation of GNUPlot
-disables the generation of `.gif' files. If your installed version
-does not accept `set term gif', just download and install the most
-recent version of GNUPlot and the GD library
-(http://www.boutell.com/gd/) by Thomas Boutell. Otherwise you still
-have the chance to generate some ASCII-art style images with GNUPlot by
-using `set term dumb'. (We tried it and it worked.)
-
-3.7 MAZE: Walking Through a Maze In Virtual Reality
-===================================================
-
- In the long run, every program becomes rococo, and then rubble.
- Alan Perlis
-
- By now, we know how to present arbitrary `Content-type's to a
-browser. In this node, our server will present a 3D world to our
-browser. The 3D world is described in a scene description language
-(VRML, Virtual Reality Modeling Language) that allows us to travel
-through a perspective view of a 2D maze with our browser. Browsers with
-a VRML plugin enable exploration of this technology. We could do one of
-those boring `Hello world' examples here, that are usually presented
-when introducing novices to VRML. If you have never written any VRML
-code, have a look at the VRML FAQ. Presenting a static VRML scene is a
-bit trivial; in order to expose `gawk''s new capabilities, we will
-present a dynamically generated VRML scene. The function `SetUpServer'
-is very simple because it only sets the default HTML page and
-initializes the random number generator. As usual, the surrounding
-server lets you browse the maze.
-
- function SetUpServer() {
- TopHeader = "<HTML><title>Walk through a maze</title>"
- TopDoc = "\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this server</A>\
- <LI><A HREF=" MyPrefix "/VRMLtest>Watch a simple VRML scene</A>\
- </UL>"
- TopFooter = "</HTML>"
- srand()
- }
-
- The function `HandleGET' is a bit longer because it first computes
-the maze and afterwards generates the VRML code that is sent across the
-network. As shown in the STATIST example (*note STATIST::), we set the
-type of the content to VRML and then store the VRML representation of
-the maze as the page content. We assume that the maze is stored in a 2D
-array. Initially, the maze consists of walls only. Then, we add an
-entry and an exit to the maze and let the rest of the work be done by
-the function `MakeMaze'. Now, only the wall fields are left in the
-maze. By iterating over the these fields, we generate one line of VRML
-code for each wall field.
-
- function HandleGET() {
- if (MENU[2] == "AboutServer") {
- Document = "If your browser has a VRML 2 plugin,\
- this server shows you a simple VRML scene."
- } else if (MENU[2] == "VRMLtest") {
- XSIZE = YSIZE = 11 # initially, everything is wall
- for (y = 0; y < YSIZE; y++)
- for (x = 0; x < XSIZE; x++)
- Maze[x, y] = "#"
- delete Maze[0, 1] # entry is not wall
- delete Maze[XSIZE-1, YSIZE-2] # exit is not wall
- MakeMaze(1, 1)
- Document = "\
- #VRML V2.0 utf8\n\
- Group {\n\
- children [\n\
- PointLight {\n\
- ambientIntensity 0.2\n\
- color 0.7 0.7 0.7\n\
- location 0.0 8.0 10.0\n\
- }\n\
- DEF B1 Background {\n\
- skyColor [0 0 0, 1.0 1.0 1.0 ]\n\
- skyAngle 1.6\n\
- groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\
- groundAngle [ 1.2 1.57 ]\n\
- }\n\
- DEF Wall Shape {\n\
- geometry Box {size 1 1 1}\n\
- appearance Appearance { material Material { diffuseColor 0 0 1 }
}\n\
- }\n\
- DEF Entry Viewpoint {\n\
- position 0.5 1.0 5.0\n\
- orientation 0.0 0.0 -1.0 0.52\n\
- }\n"
- for (i in Maze) {
- split(i, t, SUBSEP)
- Document = Document " Transform { translation "
- Document = Document t[1] " 0 -" t[2] " children USE Wall }\n"
- }
- Document = Document " ] # end of group for world\n}"
- Reason = "OK" ORS "Content-type: model/vrml"
- Header = Footer = ""
- }
- }
-
- Finally, we have a look at `MakeMaze', the function that generates
-the `Maze' array. When entered, this function assumes that the array
-has been initialized so that each element represents a wall element and
-the maze is initially full of wall elements. Only the entrance and the
-exit of the maze should have been left free. The parameters of the
-function tell us which element must be marked as not being a wall.
-After this, we take a look at the four neighbouring elements and
-remember which we have already treated. Of all the neighbouring
-elements, we take one at random and walk in that direction. Therefore,
-the wall element in that direction has to be removed and then, we call
-the function recursively for that element. The maze is only completed
-if we iterate the above procedure for _all_ neighbouring elements (in
-random order) and for our present element by recursively calling the
-function for the present element. This last iteration could have been
-done in a loop, but it is done much simpler recursively.
-
- Notice that elements with coordinates that are both odd are assumed
-to be on our way through the maze and the generating process cannot
-terminate as long as there is such an element not being `delete'd. All
-other elements are potentially part of the wall.
-
- function MakeMaze(x, y) {
- delete Maze[x, y] # here we are, we have no wall here
- p = 0 # count unvisited fields in all directions
- if (x-2 SUBSEP y in Maze) d[p++] = "-x"
- if (x SUBSEP y-2 in Maze) d[p++] = "-y"
- if (x+2 SUBSEP y in Maze) d[p++] = "+x"
- if (x SUBSEP y+2 in Maze) d[p++] = "+y"
- if (p>0) { # if there are univisited fields, go there
- p = int(p*rand()) # choose one unvisited field at random
- if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y)
- } else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2)
- } else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y)
- } else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2)
- } # we are back from recursion
- MakeMaze(x, y); # try again while there are unvisited fields
- }
- }
-
-3.8 MOBAGWHO: a Simple Mobile Agent
-===================================
-
- There are two ways of constructing a software design: One way is to
- make it so simple that there are obviously no deficiencies, and the
- other way is to make it so complicated that there are no obvious
- deficiencies.
- C. A. R. Hoare
-
- A "mobile agent" is a program that can be dispatched from a computer
-and transported to a remote server for execution. This is called
-"migration", which means that a process on another system is started
-that is independent from its originator. Ideally, it wanders through a
-network while working for its creator or owner. In places like the UMBC
-Agent Web, people are quite confident that (mobile) agents are a
-software engineering paradigm that enables us to significantly increase
-the efficiency of our work. Mobile agents could become the mediators
-between users and the networking world. For an unbiased view at this
-technology, see the remarkable paper `Mobile Agents: Are they a good
-idea?'.(1)
-
- When trying to migrate a process from one system to another, a
-server process is needed on the receiving side. Depending on the kind
-of server process, several ways of implementation come to mind. How
-the process is implemented depends upon the kind of server process:
-
- * HTTP can be used as the protocol for delivery of the migrating
- process. In this case, we use a common web server as the receiving
- server process. A universal CGI script mediates between migrating
- process and web server. Each server willing to accept migrating
- agents makes this universal service available. HTTP supplies the
- `POST' method to transfer some data to a file on the web server.
- When a CGI script is called remotely with the `POST' method
- instead of the usual `GET' method, data is transmitted from the
- client process to the standard input of the server's CGI script.
- So, to implement a mobile agent, we must not only write the agent
- program to start on the client side, but also the CGI script to
- receive the agent on the server side.
-
- * The `PUT' method can also be used for migration. HTTP does not
- require a CGI script for migration via `PUT'. However, with common
- web servers there is no advantage to this solution, because web
- servers such as Apache require explicit activation of a special
- `PUT' script.
-
- * `Agent Tcl' pursues a different course; it relies on a dedicated
- server process with a dedicated protocol specialized for receiving
- mobile agents.
-
- Our agent example abuses a common web server as a migration tool.
-So, it needs a universal CGI script on the receiving side (the web
-server). The receiving script is activated with a `POST' request when
-placed into a location like `/httpd/cgi-bin/PostAgent.sh'. Make sure
-that the server system uses a version of `gawk' that supports network
-access (Version 3.1 or later; verify with `gawk --version').
-
- #!/bin/sh
- MobAg=/tmp/MobileAgent.$$
- # direct script to mobile agent file
- cat > $MobAg
- # execute agent concurrently
- gawk -f $MobAg $MobAg > /dev/null &
- # HTTP header, terminator and body
- gawk 'BEGIN { print "\r\nAgent started" }'
- rm $MobAg # delete script file of agent
-
- By making its process id (`$$') part of the unique file name, the
-script avoids conflicts between concurrent instances of the script.
-First, all lines from standard input (the mobile agent's source code)
-are copied into this unique file. Then, the agent is started as a
-concurrent process and a short message reporting this fact is sent to
-the submitting client. Finally, the script file of the mobile agent is
-removed because it is no longer needed. Although it is a short script,
-there are several noteworthy points:
-
-Security
- _There is none_. In fact, the CGI script should never be made
- available on a server that is part of the Internet because everyone
- would be allowed to execute arbitrary commands with it. This
- behavior is acceptable only when performing rapid prototyping.
-
-Self-Reference
- Each migrating instance of an agent is started in a way that
- enables it to read its own source code from standard input and use
- the code for subsequent migrations. This is necessary because it
- needs to treat the agent's code as data to transmit. `gawk' is not
- the ideal language for such a job. Lisp and Tcl are more suitable
- because they do not make a distinction between program code and
- data.
-
-Independence
- After migration, the agent is not linked to its former home in any
- way. By reporting `Agent started', it waves "Goodbye" to its
- origin. The originator may choose to terminate or not.
-
- The originating agent itself is started just like any other
-command-line script, and reports the results on standard output. By
-letting the name of the original host migrate with the agent, the agent
-that migrates to a host far away from its origin can report the result
-back home. Having arrived at the end of the journey, the agent
-establishes a connection and reports the results. This is the reason
-for determining the name of the host with `uname -n' and storing it in
-`MyOrigin' for later use. We may also set variables with the `-v'
-option from the command line. This interactivity is only of importance
-in the context of starting a mobile agent; therefore this `BEGIN'
-pattern and its action do not take part in migration:
-
- BEGIN {
- if (ARGC != 2) {
- print "MOBAG - a simple mobile agent"
- print "CALL:\n gawk -f mobag.awk mobag.awk"
- print "IN:\n the name of this script as a command-line parameter"
- print "PARAM:\n -v MyOrigin=myhost.com"
- print "OUT:\n the result on stdout"
- print "JK 29.03.1998 01.04.1998"
- exit
- }
- if (MyOrigin == "") {
- "uname -n" | getline MyOrigin
- close("uname -n")
- }
- }
-
- Since `gawk' cannot manipulate and transmit parts of the program
-directly, the source code is read and stored in strings. Therefore,
-the program scans itself for the beginning and the ending of functions.
-Each line in between is appended to the code string until the end of
-the function has been reached. A special case is this part of the
-program itself. It is not a function. Placing a similar framework
-around it causes it to be treated like a function. Notice that this
-mechanism works for all the functions of the source code, but it cannot
-guarantee that the order of the functions is preserved during migration:
-
- #ReadMySelf
- /^function / { FUNC = $2 }
- /^END/ || /^#ReadMySelf/ { FUNC = $1 }
- FUNC != "" { MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 }
- (FUNC != "") && (/^}/ || /^#EndOfMySelf/) \
- { FUNC = "" }
- #EndOfMySelf
-
- The web server code in *Note A Web Service with Interaction:
-Interacting Service, was first developed as a site-independent core.
-Likewise, the `gawk'-based mobile agent starts with an
-agent-independent core, to which can be appended application-dependent
-functions. What follows is the only application-independent function
-needed for the mobile agent:
-
- function migrate(Destination, MobCode, Label) {
- MOBVAR["Label"] = Label
- MOBVAR["Destination"] = Destination
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/0/" Destination
- for (i in MOBFUN)
- MobCode = (MobCode "\n" MOBFUN[i])
- MobCode = MobCode "\n\nBEGIN {"
- for (i in MOBVAR)
- MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"")
- MobCode = MobCode "\n}\n"
- print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService
- print "Content-length:", length(MobCode) ORS |& HttpService
- printf "%s", MobCode |& HttpService
- while ((HttpService |& getline) > 0)
- print $0
- close(HttpService)
- }
-
- The `migrate' function prepares the aforementioned strings
-containing the program code and transmits them to a server. A
-consequence of this modular approach is that the `migrate' function
-takes some parameters that aren't needed in this application, but that
-will be in future ones. Its mandatory parameter `Destination' holds the
-name (or IP address) of the server that the agent wants as a host for
-its code. The optional parameter `MobCode' may contain some `gawk' code
-that is inserted during migration in front of all other code. The
-optional parameter `Label' may contain a string that tells the agent
-what to do in program execution after arrival at its new home site. One
-of the serious obstacles in implementing a framework for mobile agents
-is that it does not suffice to migrate the code. It is also necessary
-to migrate the state of execution of the agent. In contrast to `Agent
-Tcl', this program does not try to migrate the complete set of
-variables. The following conventions are used:
-
- * Each variable in an agent program is local to the current host and
- does _not_ migrate.
-
- * The array `MOBFUN' shown above is an exception. It is handled by
- the function `migrate' and does migrate with the application.
-
- * The other exception is the array `MOBVAR'. Each variable that
- takes part in migration has to be an element of this array.
- `migrate' also takes care of this.
-
- Now it's clear what happens to the `Label' parameter of the function
-`migrate'. It is copied into `MOBVAR["Label"]' and travels alongside
-the other data. Since travelling takes place via HTTP, records must be
-separated with `"\r\n"' in `RS' and `ORS' as usual. The code assembly
-for migration takes place in three steps:
-
- * Iterate over `MOBFUN' to collect all functions verbatim.
-
- * Prepare a `BEGIN' pattern and put assignments to mobile variables
- into the action part.
-
- * Transmission itself resembles GETURL: the header with the request
- and the `Content-length' is followed by the body. In case there is
- any reply over the network, it is read completely and echoed to
- standard output to avoid irritating the server.
-
- The application-independent framework is now almost complete. What
-follows is the `END' pattern that is executed when the mobile agent has
-finished reading its own code. First, it checks whether it is already
-running on a remote host or not. In case initialization has not yet
-taken place, it starts `MyInit'. Otherwise (later, on a remote host), it
-starts `MyJob':
-
- END {
- if (ARGC != 2) exit # stop when called with wrong parameters
- if (MyOrigin != "") # is this the originating host?
- MyInit() # if so, initialize the application
- else # we are on a host with migrated data
- MyJob() # so we do our job
- }
-
- All that's left to extend the framework into a complete application
-is to write two application-specific functions: `MyInit' and `MyJob'.
-Keep in mind that the former is executed once on the originating host,
-while the latter is executed after each migration:
-
- function MyInit() {
- MOBVAR["MyOrigin"] = MyOrigin
- MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80"
- split(MOBVAR["Machines"], Machines) # which host is the first?
- migrate(Machines[1], "", "") # go to the first host
- while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result
- print $0 # print result
- close("/inet/tcp/8080/0/0")
- }
-
- As mentioned earlier, this agent takes the name of its origin
-(`MyOrigin') with it. Then, it takes the name of its first destination
-and goes there for further work. Notice that this name has the port
-number of the web server appended to the name of the server, because
-the function `migrate' needs it this way to create the `HttpService'
-variable. Finally, it waits for the result to arrive. The `MyJob'
-function runs on the remote host:
-
- function MyJob() {
- # forget this host
- sub(MOBVAR["Destination"], "", MOBVAR["Machines"])
- MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"]
":"
- while (("who" | getline) > 0) # who is logged in?
- MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0
- close("who")
- if (index(MOBVAR["Machines"], "/") > 0) { # any more machines to
visit?
- split(MOBVAR["Machines"], Machines) # which host is next?
- migrate(Machines[1], "", "") # go there
- } else { # no more machines
- gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin
- print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080"
- close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080")
- }
- }
-
- After migrating, the first thing to do in `MyJob' is to delete the
-name of the current host from the list of hosts to visit. Now, it is
-time to start the real work by appending the host's name to the result
-string, and reading line by line who is logged in on this host. A very
-annoying circumstance is the fact that the elements of `MOBVAR' cannot
-hold the newline character (`"\n"'). If they did, migration of this
-string did not work because the string didn't obey the syntax rule for
-a string in `gawk'. `SUBSEP' is used as a temporary replacement. If
-the list of hosts to visit holds at least one more entry, the agent
-migrates to that place to go on working there. Otherwise, we replace
-the `SUBSEP's with a newline character in the resulting string, and
-report it to the originating host, whose name is stored in
-`MOBVAR["MyOrigin"]'.
-
- ---------- Footnotes ----------
-
- (1) `http://www.research.ibm.com/massive/mobag.ps'
-
-3.9 STOXPRED: Stock Market Prediction As A Service
-==================================================
-
- Far out in the uncharted backwaters of the unfashionable end of
- the Western Spiral arm of the Galaxy lies a small unregarded
- yellow sun.
-
- Orbiting this at a distance of roughly ninety-two million miles is
- an utterly insignificant little blue-green planet whose
- ape-descendent life forms are so amazingly primitive that they
- still think digital watches are a pretty neat idea.
-
- This planet has -- or rather had -- a problem, which was this:
- most of the people living on it were unhappy for pretty much of
- the time. Many solutions were suggested for this problem, but
- most of these were largely concerned with the movements of small
- green pieces of paper, which is odd because it wasn't the small
- green pieces of paper that were unhappy.
- Douglas Adams, `The Hitch Hiker's Guide to the Galaxy'
-
- Valuable services on the Internet are usually _not_ implemented as
-mobile agents. There are much simpler ways of implementing services.
-All Unix systems provide, for example, the `cron' service. Unix system
-users can write a list of tasks to be done each day, each week, twice a
-day, or just once. The list is entered into a file named `crontab'.
-For example, to distribute a newsletter on a daily basis this way, use
-`cron' for calling a script each day early in the morning.
-
- # run at 8 am on weekdays, distribute the newsletter
- 0 8 * * 1-5 $HOME/bin/daily.job >> $HOME/log/newsletter 2>&1
-
- The script first looks for interesting information on the Internet,
-assembles it in a nice form and sends the results via email to the
-customers.
-
- The following is an example of a primitive newsletter on stock
-market prediction. It is a report which first tries to predict the
-change of each share in the Dow Jones Industrial Index for the
-particular day. Then it mentions some especially promising shares as
-well as some shares which look remarkably bad on that day. The report
-ends with the usual disclaimer which tells every child _not_ to try
-this at home and hurt anybody.
-
- Good morning Uncle Scrooge,
-
- This is your daily stock market report for Monday, October 16, 2000.
- Here are the predictions for today:
-
- AA neutral
- GE up
- JNJ down
- MSFT neutral
- ...
- UTX up
- DD down
- IBM up
- MO down
- WMT up
- DIS up
- INTC up
- MRK down
- XOM down
- EK down
- IP down
-
- The most promising shares for today are these:
-
- INTC http://biz.yahoo.com/n/i/intc.html
-
- The stock shares to avoid today are these:
-
- EK http://biz.yahoo.com/n/e/ek.html
- IP http://biz.yahoo.com/n/i/ip.html
- DD http://biz.yahoo.com/n/d/dd.html
- ...
-
- The script as a whole is rather long. In order to ease the pain of
-studying other people's source code, we have broken the script up into
-meaningful parts which are invoked one after the other. The basic
-structure of the script is as follows:
-
- BEGIN {
- Init()
- ReadQuotes()
- CleanUp()
- Prediction()
- Report()
- SendMail()
- }
-
- The earlier parts store data into variables and arrays which are
-subsequently used by later parts of the script. The `Init' function
-first checks if the script is invoked correctly (without any
-parameters). If not, it informs the user of the correct usage. What
-follows are preparations for the retrieval of the historical quote
-data. The names of the 30 stock shares are stored in an array `name'
-along with the current date in `day', `month', and `year'.
-
- All users who are separated from the Internet by a firewall and have
-to direct their Internet accesses to a proxy must supply the name of
-the proxy to this script with the `-v Proxy=NAME' option. For most
-users, the default proxy and port number should suffice.
-
- function Init() {
- if (ARGC != 1) {
- print "STOXPRED - daily stock share prediction"
- print "IN:\n no parameters, nothing on stdin"
- print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80"
- print "OUT:\n commented predictions as email"
- print "JK 09.10.2000"
- exit
- }
- # Remember ticker symbols from Dow Jones Industrial Index
- StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \
- SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \
- MRK XOM EK IP", name);
- # Remember the current date as the end of the time series
- day = strftime("%d")
- month = strftime("%m")
- year = strftime("%Y")
- if (Proxy == "") Proxy = "chart.yahoo.com"
- if (ProxyPort == 0) ProxyPort = 80
- YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort
- }
-
- There are two really interesting parts in the script. One is the
-function which reads the historical stock quotes from an Internet
-server. The other is the one that does the actual prediction. In the
-following function we see how the quotes are read from the Yahoo
-server. The data which comes from the server is in CSV format
-(comma-separated values):
-
- Date,Open,High,Low,Close,Volume
- 9-Oct-00,22.75,22.75,21.375,22.375,7888500
- 6-Oct-00,23.8125,24.9375,21.5625,22,10701100
- 5-Oct-00,24.4375,24.625,23.125,23.50,5810300
-
- Lines contain values of the same time instant, whereas columns are
-separated by commas and contain the kind of data that is described in
-the header (first) line. At first, `gawk' is instructed to separate
-columns by commas (`FS = ","'). In the loop that follows, a connection
-to the Yahoo server is first opened, then a download takes place, and
-finally the connection is closed. All this happens once for each ticker
-symbol. In the body of this loop, an Internet address is built up as a
-string according to the rules of the Yahoo server. The starting and
-ending date are chosen to be exactly the same, but one year apart in
-the past. All the action is initiated within the `printf' command which
-transmits the request for data to the Yahoo server.
-
- In the inner loop, the server's data is first read and then scanned
-line by line. Only lines which have six columns and the name of a month
-in the first column contain relevant data. This data is stored in the
-two-dimensional array `quote'; one dimension being time, the other
-being the ticker symbol. During retrieval of the first stock's data,
-the calendar names of the time instances are stored in the array `day'
-because we need them later.
-
- function ReadQuotes() {
- # Retrieve historical data for each ticker symbol
- FS = ","
- for (stock = 1; stock <= StockCount; stock++) {
- URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \
- "&a=" month "&b=" day "&c=" year-1 \
- "&d=" month "&e=" day "&f=" year \
- "g=d&q=q&y=0&z=" name[stock] "&x=.csv"
- printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData
- while ((YahooData |& getline) > 0) {
- if (NF == 6 && $1 ~
/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) {
- if (stock == 1)
- days[++daycount] = $1;
- quote[$1, stock] = $5
- }
- }
- close(YahooData)
- }
- FS = " "
- }
-
- Now that we _have_ the data, it can be checked once again to make
-sure that no individual stock is missing or invalid, and that all the
-stock quotes are aligned correctly. Furthermore, we renumber the time
-instances. The most recent day gets day number 1 and all other days get
-consecutive numbers. All quotes are rounded toward the nearest whole
-number in US Dollars.
-
- function CleanUp() {
- # clean up time series; eliminate incomplete data sets
- for (d = 1; d <= daycount; d++) {
- for (stock = 1; stock <= StockCount; stock++)
- if (! ((days[d], stock) in quote))
- stock = StockCount + 10
- if (stock > StockCount + 1)
- continue
- datacount++
- for (stock = 1; stock <= StockCount; stock++)
- data[datacount, stock] = int(0.5 + quote[days[d], stock])
- }
- delete quote
- delete days
- }
-
- Now we have arrived at the second really interesting part of the
-whole affair. What we present here is a very primitive prediction
-algorithm: _If a stock fell yesterday, assume it will also fall today;
-if it rose yesterday, assume it will rise today_. (Feel free to
-replace this algorithm with a smarter one.) If a stock changed in the
-same direction on two consecutive days, this is an indication which
-should be highlighted. Two-day advances are stored in `hot' and
-two-day declines in `avoid'.
-
- The rest of the function is a sanity check. It counts the number of
-correct predictions in relation to the total number of predictions one
-could have made in the year before.
-
- function Prediction() {
- # Predict each ticker symbol by prolonging yesterday's trend
- for (stock = 1; stock <= StockCount; stock++) {
- if (data[1, stock] > data[2, stock]) {
- predict[stock] = "up"
- } else if (data[1, stock] < data[2, stock]) {
- predict[stock] = "down"
- } else {
- predict[stock] = "neutral"
- }
- if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3,
stock]))
- hot[stock] = 1
- if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3,
stock]))
- avoid[stock] = 1
- }
- # Do a plausibility check: how many predictions proved correct?
- for (s = 1; s <= StockCount; s++) {
- for (d = 1; d <= datacount-2; d++) {
- if (data[d+1, s] > data[d+2, s]) {
- UpCount++
- } else if (data[d+1, s] < data[d+2, s]) {
- DownCount++
- } else {
- NeutralCount++
- }
- if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2,
s])) ||
- ((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2,
s])) ||
- ((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2,
s])))
- CorrectCount++
- }
- }
- }
-
- At this point the hard work has been done: the array `predict'
-contains the predictions for all the ticker symbols. It is up to the
-function `Report' to find some nice words to introduce the desired
-information.
-
- function Report() {
- # Generate report
- report = "\nThis is your daily "
- report = report "stock market report for "strftime("%A, %B %d, %Y")".\n"
- report = report "Here are the predictions for today:\n\n"
- for (stock = 1; stock <= StockCount; stock++)
- report = report "\t" name[stock] "\t" predict[stock] "\n"
- for (stock in hot) {
- if (HotCount++ == 0)
- report = report "\nThe most promising shares for today are
these:\n\n"
- report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
- tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock])
".html\n"
- }
- for (stock in avoid) {
- if (AvoidCount++ == 0)
- report = report "\nThe stock shares to avoid today are these:\n\n"
- report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
- tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock])
".html\n"
- }
- report = report "\nThis sums up to " HotCount+0 " winners and "
AvoidCount+0
- report = report " losers. When using this kind\nof prediction scheme
for"
- report = report " the 12 months which lie behind us,\nwe get " UpCount
- report = report " 'ups' and " DownCount " 'downs' and " NeutralCount
- report = report " 'neutrals'. Of all\nthese "
UpCount+DownCount+NeutralCount
- report = report " predictions " CorrectCount " proved correct next
day.\n"
- report = report "A success rate of "\
- int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n"
- report = report "Random choice would have produced a 33% success
rate.\n"
- report = report "Disclaimer: Like every other prediction of the stock\n"
- report = report "market, this report is, of course, complete
nonsense.\n"
- report = report "If you are stupid enough to believe these
predictions\n"
- report = report "you should visit a doctor who can treat your ailment."
- }
-
- The function `SendMail' goes through the list of customers and opens
-a pipe to the `mail' command for each of them. Each one receives an
-email message with a proper subject heading and is addressed with his
-full name.
-
- function SendMail() {
- # send report to customers
- customer["address@hidden"] = "Uncle Scrooge"
- customer["address@hidden" ] = "Sir Thomas More"
- customer["address@hidden" ] = "Baruch de Spinoza"
- customer["address@hidden" ] = "Karl Marx"
- customer["address@hidden" ] = "John Maynard Keynes"
- customer["address@hidden" ] = "Ambrose Bierce"
- customer["address@hidden" ] = "Pierre Simon de Laplace"
- for (c in customer) {
- MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c
- print "Good morning " customer[c] "," | MailPipe
- print report "\n.\n" | MailPipe
- close(MailPipe)
- }
- }
-
- Be patient when running the script by hand. Retrieving the data for
-all the ticker symbols and sending the emails may take several minutes
-to complete, depending upon network traffic and the speed of the
-available Internet link. The quality of the prediction algorithm is
-likely to be disappointing. Try to find a better one. Should you find
-one with a success rate of more than 50%, please tell us about it! It
-is only for the sake of curiosity, of course. `:-)'
-
-3.10 PROTBASE: Searching Through A Protein Database
-===================================================
-
- Hoare's Law of Large Problems: Inside every large problem is a
- small problem struggling to get out.
-
- Yahoo's database of stock market data is just one among the many
-large databases on the Internet. Another one is located at NCBI
-(National Center for Biotechnology Information). Established in 1988 as
-a national resource for molecular biology information, NCBI creates
-public databases, conducts research in computational biology, develops
-software tools for analyzing genome data, and disseminates biomedical
-information. In this section, we look at one of NCBI's public services,
-which is called BLAST (Basic Local Alignment Search Tool).
-
- You probably know that the information necessary for reproducing
-living cells is encoded in the genetic material of the cells. The
-genetic material is a very long chain of four base nucleotides. It is
-the order of appearance (the sequence) of nucleotides which contains
-the information about the substance to be produced. Scientists in
-biotechnology often find a specific fragment, determine the nucleotide
-sequence, and need to know where the sequence at hand comes from. This
-is where the large databases enter the game. At NCBI, databases store
-the knowledge about which sequences have ever been found and where they
-have been found. When the scientist sends his sequence to the BLAST
-service, the server looks for regions of genetic material in its
-database which look the most similar to the delivered nucleotide
-sequence. After a search time of some seconds or minutes the server
-sends an answer to the scientist. In order to make access simple, NCBI
-chose to offer their database service through popular Internet
-protocols. There are four basic ways to use the so-called BLAST
-services:
-
- * The easiest way to use BLAST is through the web. Users may simply
- point their browsers at the NCBI home page and link to the BLAST
- pages. NCBI provides a stable URL that may be used to perform
- BLAST searches without interactive use of a web browser. This is
- what we will do later in this section. A demonstration client and
- a `README' file demonstrate how to access this URL.
-
- * Currently, `blastcl3' is the standard network BLAST client. You
- can download `blastcl3' from the anonymous FTP location.
-
- * BLAST 2.0 can be run locally as a full executable and can be used
- to run BLAST searches against private local databases, or
- downloaded copies of the NCBI databases. BLAST 2.0 executables may
- be found on the NCBI anonymous FTP server.
-
- * The NCBI BLAST Email server is the best option for people without
- convenient access to the web. A similarity search can be performed
- by sending a properly formatted mail message containing the
- nucleotide or protein query sequence to <address@hidden>.
- The query sequence is compared against the specified database
- using the BLAST algorithm and the results are returned in an email
- message. For more information on formulating email BLAST searches,
- you can send a message consisting of the word "HELP" to the same
- address, <address@hidden>.
-
- Our starting point is the demonstration client mentioned in the
-first option. The `README' file that comes along with the client
-explains the whole process in a nutshell. In the rest of this section,
-we first show what such requests look like. Then we show how to use
-`gawk' to implement a client in about 10 lines of code. Finally, we
-show how to interpret the result returned from the service.
-
- Sequences are expected to be represented in the standard IUB/IUPAC
-amino acid and nucleic acid codes, with these exceptions: lower-case
-letters are accepted and are mapped into upper-case; a single hyphen or
-dash can be used to represent a gap of indeterminate length; and in
-amino acid sequences, `U' and `*' are acceptable letters (see below).
-Before submitting a request, any numerical digits in the query sequence
-should either be removed or replaced by appropriate letter codes (e.g.,
-`N' for unknown nucleic acid residue or `X' for unknown amino acid
-residue). The nucleic acid codes supported are:
-
- A --> adenosine M --> A C (amino)
- C --> cytidine S --> G C (strong)
- G --> guanine W --> A T (weak)
- T --> thymidine B --> G T C
- U --> uridine D --> G A T
- R --> G A (purine) H --> A C T
- Y --> T C (pyrimidine) V --> G C A
- K --> G T (keto) N --> A G C T (any)
- - gap of indeterminate length
-
- Now you know the alphabet of nucleotide sequences. The last two lines
-of the following example query show you such a sequence, which is
-obviously made up only of elements of the alphabet just described.
-Store this example query into a file named `protbase.request'. You are
-now ready to send it to the server with the demonstration client.
-
- PROGRAM blastn
- DATALIB month
- EXPECT 0.75
- BEGIN
- >GAWK310 the gawking gene GNU AWK
- tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat
- caccaccatggacagcaaa
-
- The actual search request begins with the mandatory parameter
-`PROGRAM' in the first column followed by the value `blastn' (the name
-of the program) for searching nucleic acids. The next line contains
-the mandatory search parameter `DATALIB' with the value `month' for the
-newest nucleic acid sequences. The third line contains an optional
-`EXPECT' parameter and the value desired for it. The fourth line
-contains the mandatory `BEGIN' directive, followed by the query
-sequence in FASTA/Pearson format. Each line of information must be
-less than 80 characters in length.
-
- The "month" database contains all new or revised sequences released
-in the last 30 days and is useful for searching against new sequences.
-There are five different blast programs, `blastn' being the one that
-compares a nucleotide query sequence against a nucleotide sequence
-database.
-
- The last server directive that must appear in every request is the
-`BEGIN' directive. The query sequence should immediately follow the
-`BEGIN' directive and must appear in FASTA/Pearson format. A sequence
-in FASTA/Pearson format begins with a single-line description. The
-description line, which is required, is distinguished from the lines of
-sequence data that follow it by having a greater-than (`>') symbol in
-the first column. For the purposes of the BLAST server, the text of
-the description is arbitrary.
-
- If you prefer to use a client written in `gawk', just store the
-following 10 lines of code into a file named `protbase.awk' and use
-this client instead. Invoke it with `gawk -f protbase.awk
-protbase.request'. Then wait a minute and watch the result coming in.
-In order to replicate the demonstration client's behaviour as closely
-as possible, this client does not use a proxy server. We could also
-have extended the client program in *Note Retrieving Web Pages: GETURL,
-to implement the client request from `protbase.awk' as a special case.
-
- { request = request "\n" $0 }
-
- END {
- BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80"
- printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService
- printf "Content-Length: " length(request) "\n\n" |& BLASTService
- printf request |& BLASTService
- while ((BLASTService |& getline) > 0)
- print $0
- close(BLASTService)
- }
-
- The demonstration client from NCBI is 214 lines long (written in C)
-and it is not immediately obvious what it does. Our client is so short
-that it _is_ obvious what it does. First it loops over all lines of the
-query and stores the whole query into a variable. Then the script
-establishes an Internet connection to the NCBI server and transmits the
-query by framing it with a proper HTTP request. Finally it receives and
-prints the complete result coming from the server.
-
- Now, let us look at the result. It begins with an HTTP header, which
-you can ignore. Then there are some comments about the query having been
-filtered to avoid spuriously high scores. After this, there is a
-reference to the paper that describes the software being used for
-searching the data base. After a repitition of the original query's
-description we find the list of significant alignments:
-
- Sequences producing significant alignments: (bits)
Value
-
- gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38
0.20
- gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38
0.20
- emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38
0.20
- emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38
0.20
- emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38
0.20
- emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38
0.20
- gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38
0.20
-
- This means that the query sequence was found in seven human
-chromosomes. But the value 0.20 (20%) means that the probability of an
-accidental match is rather high (20%) in all cases and should be taken
-into account. You may wonder what the first column means. It is a key
-to the specific database in which this occurence was found. The unique
-sequence identifiers reported in the search results can be used as
-sequence retrieval keys via the NCBI server. The syntax of sequence
-header lines used by the NCBI BLAST server depends on the database from
-which each sequence was obtained. The table below lists the
-identifiers for the databases from which the sequences were derived.
-
- Database Name Identifier Syntax
- ============================ ========================
- GenBank gb|accession|locus
- EMBL Data Library emb|accession|locus
- DDBJ, DNA Database of Japan dbj|accession|locus
- NBRF PIR pir||entry
- Protein Research Foundation prf||name
- SWISS-PROT sp|accession|entry name
- Brookhaven Protein Data Bank pdb|entry|chain
- Kabat's Sequences of Immuno... gnl|kabat|identifier
- Patents pat|country|number
- GenInfo Backbone Id bbs|number
-
- For example, an identifier might be `gb|AC021182.14|AC021182', where
-the `gb' tag indicates that the identifier refers to a GenBank sequence,
-`AC021182.14' is its GenBank ACCESSION, and `AC021182' is the GenBank
-LOCUS. The identifier contains no spaces, so that a space indicates
-the end of the identifier.
-
- Let us continue in the result listing. Each of the seven alignments
-mentioned above is subsequently described in detail. We will have a
-closer look at the first of them.
-
- >gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733N23,
WORKING DRAFT SEQUENCE, 4
- unordered pieces
- Length = 176383
-
- Score = 38.2 bits (19), Expect = 0.20
- Identities = 19/19 (100%)
- Strand = Plus / Plus
-
- Query: 35 tggtgaagtgtgtttcttg 53
- |||||||||||||||||||
- Sbjct: 69786 tggtgaagtgtgtttcttg 69804
-
- This alignment was located on the human chromosome 7. The fragment
-on which part of the query was found had a total length of 176383. Only
-19 of the nucleotides matched and the matching sequence ran from
-character 35 to 53 in the query sequence and from 69786 to 69804 in the
-fragment on chromosome 7. If you are still reading at this point, you
-are probably interested in finding out more about Computational Biology
-and you might appreciate the following hints.
-
- 1. There is a book called `Introduction to Computational Biology' by
- Michael S. Waterman, which is worth reading if you are seriously
- interested. You can find a good book review on the Internet.
-
- 2. While Waterman's book can explain to you the algorithms employed
- internally in the database search engines, most practicioners
- prefer to approach the subject differently. The applied side of
- Computational Biology is called Bioinformatics, and emphasizes the
- tools available for day-to-day work as well as how to actually
- _use_ them. One of the very few affordable books on Bioinformatics
- is `Developing Bioinformatics Computer Skills'.
-
- 3. The sequences _gawk_ and _gnuawk_ are in widespread use in the
- genetic material of virtually every earthly living being. Let us
- take this as a clear indication that the divine creator has
- intended `gawk' to prevail over other scripting languages such as
- `perl', `tcl', or `python' which are not even proper sequences.
- (:-)
-
-4 Related Links
-***************
-
-This section lists the URLs for various items discussed in this major
-node. They are presented in the order in which they appear.
-
-`Internet Programming with Python'
- `http://www.fsbassociates.com/books/python.htm'
-
-`Advanced Perl Programming'
- `http://www.oreilly.com/catalog/advperl'
-
-`Web Client Programming with Perl'
- `http://www.oreilly.com/catalog/webclient'
-
-Richard Stevens's home page and book
- `http://www.kohala.com/~rstevens'
-
-The SPAK home page
-
`http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html'
-
-Volume III of `Internetworking with TCP/IP', by Comer and Stevens
- `http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html'
-
-XBM Graphics File Format
- `http://www.wotsit.org/download.asp?f=xbm'
-
-GNUPlot
- `http://www.cs.dartmouth.edu/gnuplot_info.html'
-
-Mark Humphrys' Eliza page
- `http://www.compapp.dcu.ie/~humphrys/eliza.html'
-
-Yahoo! Eliza Information
-
`http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence'
-
-Java versions of Eliza
- `http://www.tjhsst.edu/Psych/ch1/eliza.html'
-
-Java versions of Eliza with source code
- `http://home.adelphia.net/~lifeisgood/eliza/eliza.htm'
-
-Eliza Programs with Explanations
- `http://chayden.net/chayden/eliza/Eliza.shtml'
-
-Loebner Contest
- `http://acm.org/~loebner/loebner-prize.htmlx'
-
-Tck/Tk Information
- `http://www.scriptics.com/'
-
-Intel 80x86 Processors
- `http://developer.intel.com/design/platform/embedpc/what_is.htm'
-
-AMD Elan Processors
-
`http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html'
-
-XINU
- `http://willow.canberra.edu.au/~chrisc/xinu.html'
-
-GNU/Linux
- `http://uclinux.lineo.com/'
-
-Embedded PCs
-
`http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/'
-
-MiniSQL
- `http://www.hughes.com.au/library/'
-
-Market Share Surveys
- `http://www.netcraft.com/survey'
-
-`Numerical Recipes in C: The Art of Scientific Computing'
- `http://www.nr.com'
-
-VRML
- `http://www.vrml.org'
-
-The VRML FAQ
- `http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ'
-
-The UMBC Agent Web
- `http://www.cs.umbc.edu/agents'
-
-Apache Web Server
- `http://www.apache.org'
-
-National Center for Biotechnology Information (NCBI)
- `http://www.ncbi.nlm.nih.gov'
-
-Basic Local Alignment Search Tool (BLAST)
- `http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html'
-
-NCBI Home Page
- `http://www.ncbi.nlm.nih.gov'
-
-BLAST Pages
- `http://www.ncbi.nlm.nih.gov/BLAST'
-
-BLAST Demonstration Client
- `ftp://ncbi.nlm.nih.gov/blast/blasturl/'
-
-BLAST anonymous FTP location
- `ftp://ncbi.nlm.nih.gov/blast/network/netblast/'
-
-BLAST 2.0 Executables
- `ftp://ncbi.nlm.nih.gov/blast/executables/'
-
-IUB/IUPAC Amino Acid and Nucleic Acid Codes
- `http://www.uthscsa.edu/geninfo/blastmail.html#item6'
-
-FASTA/Pearson Format
- `http://www.ncbi.nlm.nih.gov/BLAST/fasta.html'
-
-Fasta/Pearson Sequence in Java
- `http://www.kazusa.or.jp/java/codon_table_java/'
-
-Book Review of `Introduction to Computational Biology'
- `http://www.acm.org/crossroads/xrds5-1/introcb.html'
-
-`Developing Bioinformatics Computer Skills'
- `http://www.oreilly.com/catalog/bioskills/'
-
-
-GNU Free Documentation License
-******************************
-
- Version 1.2, November 2002
-
- Copyright (C) 2000,2001,2002 Free Software Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- 0. PREAMBLE
-
- The purpose of this License is to make a manual, textbook, or other
- functional and useful document "free" in the sense of freedom: to
- assure everyone the effective freedom to copy and redistribute it,
- with or without modifying it, either commercially or
- noncommercially. Secondarily, this License preserves for the
- author and publisher a way to get credit for their work, while not
- being considered responsible for modifications made by others.
-
- This License is a kind of "copyleft", which means that derivative
- works of the document must themselves be free in the same sense.
- It complements the GNU General Public License, which is a copyleft
- license designed for free software.
-
- We have designed this License in order to use it for manuals for
- free software, because free software needs free documentation: a
- free program should come with manuals providing the same freedoms
- that the software does. But this License is not limited to
- software manuals; it can be used for any textual work, regardless
- of subject matter or whether it is published as a printed book.
- We recommend this License principally for works whose purpose is
- instruction or reference.
-
- 1. APPLICABILITY AND DEFINITIONS
-
- This License applies to any manual or other work, in any medium,
- that contains a notice placed by the copyright holder saying it
- can be distributed under the terms of this License. Such a notice
- grants a world-wide, royalty-free license, unlimited in duration,
- to use that work under the conditions stated herein. The
- "Document", below, refers to any such manual or work. Any member
- of the public is a licensee, and is addressed as "you". You
- accept the license if you copy, modify or distribute the work in a
- way requiring permission under copyright law.
-
- A "Modified Version" of the Document means any work containing the
- Document or a portion of it, either copied verbatim, or with
- modifications and/or translated into another language.
-
- A "Secondary Section" is a named appendix or a front-matter section
- of the Document that deals exclusively with the relationship of the
- publishers or authors of the Document to the Document's overall
- subject (or to related matters) and contains nothing that could
- fall directly within that overall subject. (Thus, if the Document
- is in part a textbook of mathematics, a Secondary Section may not
- explain any mathematics.) The relationship could be a matter of
- historical connection with the subject or with related matters, or
- of legal, commercial, philosophical, ethical or political position
- regarding them.
-
- The "Invariant Sections" are certain Secondary Sections whose
- titles are designated, as being those of Invariant Sections, in
- the notice that says that the Document is released under this
- License. If a section does not fit the above definition of
- Secondary then it is not allowed to be designated as Invariant.
- The Document may contain zero Invariant Sections. If the Document
- does not identify any Invariant Sections then there are none.
-
- The "Cover Texts" are certain short passages of text that are
- listed, as Front-Cover Texts or Back-Cover Texts, in the notice
- that says that the Document is released under this License. A
- Front-Cover Text may be at most 5 words, and a Back-Cover Text may
- be at most 25 words.
-
- A "Transparent" copy of the Document means a machine-readable copy,
- represented in a format whose specification is available to the
- general public, that is suitable for revising the document
- straightforwardly with generic text editors or (for images
- composed of pixels) generic paint programs or (for drawings) some
- widely available drawing editor, and that is suitable for input to
- text formatters or for automatic translation to a variety of
- formats suitable for input to text formatters. A copy made in an
- otherwise Transparent file format whose markup, or absence of
- markup, has been arranged to thwart or discourage subsequent
- modification by readers is not Transparent. An image format is
- not Transparent if used for any substantial amount of text. A
- copy that is not "Transparent" is called "Opaque".
-
- Examples of suitable formats for Transparent copies include plain
- ASCII without markup, Texinfo input format, LaTeX input format,
- SGML or XML using a publicly available DTD, and
- standard-conforming simple HTML, PostScript or PDF designed for
- human modification. Examples of transparent image formats include
- PNG, XCF and JPG. Opaque formats include proprietary formats that
- can be read and edited only by proprietary word processors, SGML or
- XML for which the DTD and/or processing tools are not generally
- available, and the machine-generated HTML, PostScript or PDF
- produced by some word processors for output purposes only.
-
- The "Title Page" means, for a printed book, the title page itself,
- plus such following pages as are needed to hold, legibly, the
- material this License requires to appear in the title page. For
- works in formats which do not have any title page as such, "Title
- Page" means the text near the most prominent appearance of the
- work's title, preceding the beginning of the body of the text.
-
- A section "Entitled XYZ" means a named subunit of the Document
- whose title either is precisely XYZ or contains XYZ in parentheses
- following text that translates XYZ in another language. (Here XYZ
- stands for a specific section name mentioned below, such as
- "Acknowledgements", "Dedications", "Endorsements", or "History".)
- To "Preserve the Title" of such a section when you modify the
- Document means that it remains a section "Entitled XYZ" according
- to this definition.
-
- The Document may include Warranty Disclaimers next to the notice
- which states that this License applies to the Document. These
- Warranty Disclaimers are considered to be included by reference in
- this License, but only as regards disclaiming warranties: any other
- implication that these Warranty Disclaimers may have is void and
- has no effect on the meaning of this License.
-
- 2. VERBATIM COPYING
-
- You may copy and distribute the Document in any medium, either
- commercially or noncommercially, provided that this License, the
- copyright notices, and the license notice saying this License
- applies to the Document are reproduced in all copies, and that you
- add no other conditions whatsoever to those of this License. You
- may not use technical measures to obstruct or control the reading
- or further copying of the copies you make or distribute. However,
- you may accept compensation in exchange for copies. If you
- distribute a large enough number of copies you must also follow
- the conditions in section 3.
-
- You may also lend copies, under the same conditions stated above,
- and you may publicly display copies.
-
- 3. COPYING IN QUANTITY
-
- If you publish printed copies (or copies in media that commonly
- have printed covers) of the Document, numbering more than 100, and
- the Document's license notice requires Cover Texts, you must
- enclose the copies in covers that carry, clearly and legibly, all
- these Cover Texts: Front-Cover Texts on the front cover, and
- Back-Cover Texts on the back cover. Both covers must also clearly
- and legibly identify you as the publisher of these copies. The
- front cover must present the full title with all words of the
- title equally prominent and visible. You may add other material
- on the covers in addition. Copying with changes limited to the
- covers, as long as they preserve the title of the Document and
- satisfy these conditions, can be treated as verbatim copying in
- other respects.
-
- If the required texts for either cover are too voluminous to fit
- legibly, you should put the first ones listed (as many as fit
- reasonably) on the actual cover, and continue the rest onto
- adjacent pages.
-
- If you publish or distribute Opaque copies of the Document
- numbering more than 100, you must either include a
- machine-readable Transparent copy along with each Opaque copy, or
- state in or with each Opaque copy a computer-network location from
- which the general network-using public has access to download
- using public-standard network protocols a complete Transparent
- copy of the Document, free of added material. If you use the
- latter option, you must take reasonably prudent steps, when you
- begin distribution of Opaque copies in quantity, to ensure that
- this Transparent copy will remain thus accessible at the stated
- location until at least one year after the last time you
- distribute an Opaque copy (directly or through your agents or
- retailers) of that edition to the public.
-
- It is requested, but not required, that you contact the authors of
- the Document well before redistributing any large number of
- copies, to give them a chance to provide you with an updated
- version of the Document.
-
- 4. MODIFICATIONS
-
- You may copy and distribute a Modified Version of the Document
- under the conditions of sections 2 and 3 above, provided that you
- release the Modified Version under precisely this License, with
- the Modified Version filling the role of the Document, thus
- licensing distribution and modification of the Modified Version to
- whoever possesses a copy of it. In addition, you must do these
- things in the Modified Version:
-
- A. Use in the Title Page (and on the covers, if any) a title
- distinct from that of the Document, and from those of
- previous versions (which should, if there were any, be listed
- in the History section of the Document). You may use the
- same title as a previous version if the original publisher of
- that version gives permission.
-
- B. List on the Title Page, as authors, one or more persons or
- entities responsible for authorship of the modifications in
- the Modified Version, together with at least five of the
- principal authors of the Document (all of its principal
- authors, if it has fewer than five), unless they release you
- from this requirement.
-
- C. State on the Title page the name of the publisher of the
- Modified Version, as the publisher.
-
- D. Preserve all the copyright notices of the Document.
-
- E. Add an appropriate copyright notice for your modifications
- adjacent to the other copyright notices.
-
- F. Include, immediately after the copyright notices, a license
- notice giving the public permission to use the Modified
- Version under the terms of this License, in the form shown in
- the Addendum below.
-
- G. Preserve in that license notice the full lists of Invariant
- Sections and required Cover Texts given in the Document's
- license notice.
-
- H. Include an unaltered copy of this License.
-
- I. Preserve the section Entitled "History", Preserve its Title,
- and add to it an item stating at least the title, year, new
- authors, and publisher of the Modified Version as given on
- the Title Page. If there is no section Entitled "History" in
- the Document, create one stating the title, year, authors,
- and publisher of the Document as given on its Title Page,
- then add an item describing the Modified Version as stated in
- the previous sentence.
-
- J. Preserve the network location, if any, given in the Document
- for public access to a Transparent copy of the Document, and
- likewise the network locations given in the Document for
- previous versions it was based on. These may be placed in
- the "History" section. You may omit a network location for a
- work that was published at least four years before the
- Document itself, or if the original publisher of the version
- it refers to gives permission.
-
- K. For any section Entitled "Acknowledgements" or "Dedications",
- Preserve the Title of the section, and preserve in the
- section all the substance and tone of each of the contributor
- acknowledgements and/or dedications given therein.
-
- L. Preserve all the Invariant Sections of the Document,
- unaltered in their text and in their titles. Section numbers
- or the equivalent are not considered part of the section
- titles.
-
- M. Delete any section Entitled "Endorsements". Such a section
- may not be included in the Modified Version.
-
- N. Do not retitle any existing section to be Entitled
- "Endorsements" or to conflict in title with any Invariant
- Section.
-
- O. Preserve any Warranty Disclaimers.
-
- If the Modified Version includes new front-matter sections or
- appendices that qualify as Secondary Sections and contain no
- material copied from the Document, you may at your option
- designate some or all of these sections as invariant. To do this,
- add their titles to the list of Invariant Sections in the Modified
- Version's license notice. These titles must be distinct from any
- other section titles.
-
- You may add a section Entitled "Endorsements", provided it contains
- nothing but endorsements of your Modified Version by various
- parties--for example, statements of peer review or that the text
- has been approved by an organization as the authoritative
- definition of a standard.
-
- You may add a passage of up to five words as a Front-Cover Text,
- and a passage of up to 25 words as a Back-Cover Text, to the end
- of the list of Cover Texts in the Modified Version. Only one
- passage of Front-Cover Text and one of Back-Cover Text may be
- added by (or through arrangements made by) any one entity. If the
- Document already includes a cover text for the same cover,
- previously added by you or by arrangement made by the same entity
- you are acting on behalf of, you may not add another; but you may
- replace the old one, on explicit permission from the previous
- publisher that added the old one.
-
- The author(s) and publisher(s) of the Document do not by this
- License give permission to use their names for publicity for or to
- assert or imply endorsement of any Modified Version.
-
- 5. COMBINING DOCUMENTS
-
- You may combine the Document with other documents released under
- this License, under the terms defined in section 4 above for
- modified versions, provided that you include in the combination
- all of the Invariant Sections of all of the original documents,
- unmodified, and list them all as Invariant Sections of your
- combined work in its license notice, and that you preserve all
- their Warranty Disclaimers.
-
- The combined work need only contain one copy of this License, and
- multiple identical Invariant Sections may be replaced with a single
- copy. If there are multiple Invariant Sections with the same name
- but different contents, make the title of each such section unique
- by adding at the end of it, in parentheses, the name of the
- original author or publisher of that section if known, or else a
- unique number. Make the same adjustment to the section titles in
- the list of Invariant Sections in the license notice of the
- combined work.
-
- In the combination, you must combine any sections Entitled
- "History" in the various original documents, forming one section
- Entitled "History"; likewise combine any sections Entitled
- "Acknowledgements", and any sections Entitled "Dedications". You
- must delete all sections Entitled "Endorsements."
-
- 6. COLLECTIONS OF DOCUMENTS
-
- You may make a collection consisting of the Document and other
- documents released under this License, and replace the individual
- copies of this License in the various documents with a single copy
- that is included in the collection, provided that you follow the
- rules of this License for verbatim copying of each of the
- documents in all other respects.
-
- You may extract a single document from such a collection, and
- distribute it individually under this License, provided you insert
- a copy of this License into the extracted document, and follow
- this License in all other respects regarding verbatim copying of
- that document.
-
- 7. AGGREGATION WITH INDEPENDENT WORKS
-
- A compilation of the Document or its derivatives with other
- separate and independent documents or works, in or on a volume of
- a storage or distribution medium, is called an "aggregate" if the
- copyright resulting from the compilation is not used to limit the
- legal rights of the compilation's users beyond what the individual
- works permit. When the Document is included an aggregate, this
- License does not apply to the other works in the aggregate which
- are not themselves derivative works of the Document.
-
- If the Cover Text requirement of section 3 is applicable to these
- copies of the Document, then if the Document is less than one half
- of the entire aggregate, the Document's Cover Texts may be placed
- on covers that bracket the Document within the aggregate, or the
- electronic equivalent of covers if the Document is in electronic
- form. Otherwise they must appear on printed covers that bracket
- the whole aggregate.
-
- 8. TRANSLATION
-
- Translation is considered a kind of modification, so you may
- distribute translations of the Document under the terms of section
- 4. Replacing Invariant Sections with translations requires special
- permission from their copyright holders, but you may include
- translations of some or all Invariant Sections in addition to the
- original versions of these Invariant Sections. You may include a
- translation of this License, and all the license notices in the
- Document, and any Warrany Disclaimers, provided that you also
- include the original English version of this License and the
- original versions of those notices and disclaimers. In case of a
- disagreement between the translation and the original version of
- this License or a notice or disclaimer, the original version will
- prevail.
-
- If a section in the Document is Entitled "Acknowledgements",
- "Dedications", or "History", the requirement (section 4) to
- Preserve its Title (section 1) will typically require changing the
- actual title.
-
- 9. TERMINATION
-
- You may not copy, modify, sublicense, or distribute the Document
- except as expressly provided for under this License. Any other
- attempt to copy, modify, sublicense or distribute the Document is
- void, and will automatically terminate your rights under this
- License. However, parties who have received copies, or rights,
- from you under this License will not have their licenses
- terminated so long as such parties remain in full compliance.
-
- 10. FUTURE REVISIONS OF THIS LICENSE
-
- The Free Software Foundation may publish new, revised versions of
- the GNU Free Documentation License from time to time. Such new
- versions will be similar in spirit to the present version, but may
- differ in detail to address new problems or concerns. See
- `http://www.gnu.org/copyleft/'.
-
- Each version of the License is given a distinguishing version
- number. If the Document specifies that a particular numbered
- version of this License "or any later version" applies to it, you
- have the option of following the terms and conditions either of
- that specified version or of any later version that has been
- published (not as a draft) by the Free Software Foundation. If
- the Document does not specify a version number of this License,
- you may choose any version ever published (not as a draft) by the
- Free Software Foundation.
-
-ADDENDUM: How to use this License for your documents
-====================================================
-
-To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and license
-notices just after the title page:
-
- Copyright (C) YEAR YOUR NAME.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
- A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-
- If you have Invariant Sections, Front-Cover Texts and Back-Cover
-Texts, replace the "with...Texts." line with this:
-
- with the Invariant Sections being LIST THEIR TITLES, with
- the Front-Cover Texts being LIST, and with the Back-Cover Texts
- being LIST.
-
- If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
- If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License, to
-permit their use in free software.
-
-Index
-*****
-
-/inet/ files (gawk): See 2.1. (line 403)
-/inet/raw special files (gawk): See 2.1.2.3. (line 585)
-/inet/tcp special files (gawk): See 2.1.2.1. (line 526)
-/inet/udp special files (gawk): See 2.1.2.2. (line 555)
-advanced features, network connections: See 2.3. (line 701)
-agent <1>: See 3.8. (line 2563)
-agent: See 2.12. (line 1723)
-AI: See 2.12. (line 1723)
-apache <1>: See 3.8. (line 2599)
-apache: See 3.5. (line 2177)
-Bioinformatics: See 3.10. (line 3382)
-BLAST, Basic Local Alignment Search Tool: See 3.10. (line 3161)
-blocking: See 1.4. (line 317)
-Boutell, Thomas: See 3.6. (line 2198)
-CGI (Common Gateway Interface): See 3.8. (line 2599)
-CGI (Common Gateway Interface), dynamic web pages and:See 2.7.
- (line 986)
-CGI (Common Gateway Interface), library: See 2.9.1. (line 1262)
-clients: See 1.4. (line 303)
-Clinton, Bill: See 2.12. (line 1706)
-Common Gateway Interface, See CGI: See 2.7. (line 986)
-Computational Biology: See 3.10. (line 3382)
-contest: See 2.12. (line 1653)
-cron utility: See 3.9. (line 2862)
-CSV format: See 3.9. (line 2967)
-dark corner, RAW protocol: See 2.1.2.3. (line 592)
-Dow Jones Industrial Index: See 3.9. (line 2883)
-ELIZA program: See 2.10. (line 1447)
-email: See 2.6. (line 904)
-FASTA/Pearson format: See 3.10. (line 3257)
-FDL (Free Documentation License):
- See ``GNU Free Documentation License''. (line 3528)
-filenames, for network access: See 2.1. (line 398)
-files, /inet/ (gawk): See 2.1. (line 403)
-files, /inet/raw (gawk): See 2.1.2.3. (line 585)
-files, /inet/tcp (gawk): See 2.1.2.1. (line 526)
-files, /inet/udp (gawk): See 2.1.2.2. (line 555)
-finger utility: See 2.5. (line 843)
-Free Documentation License (FDL):
- See ``GNU Free Documentation License''. (line 3528)
-FTP (File Transfer Protocol): See 1.3.1. (line 256)
-gawk, networking: See 2. (line 345)
-gawk, networking, connections <1>: See 2.2. (line 651)
-gawk, networking, connections: See 2.1.1. (line 454)
-gawk, networking, filenames: See 2.1. (line 398)
-gawk, networking, See Also email: See 2.6. (line 899)
-gawk, networking, service, establishing: See 2.5. (line 827)
-gawk, networking, troubleshooting: See 2.11. (line 1629)
-gawk, web and, See web service: See 2.9. (line 1064)
-getline command: See 2.2. (line 656)
-GETURL program: See 3.2. (line 1864)
-GIF image format <1>: See 3.6. (line 2198)
-GIF image format: See 2.7. (line 986)
-GNU Free Documentation License:
- See ``GNU Free Documentation License''. (line 3528)
-GNU/Linux <1>: See 3.3. (line 1918)
-GNU/Linux <2>: See 2.4. (line 796)
-GNU/Linux: See 2.3. (line 749)
-GNUPlot utility <1>: See 3.6. (line 2198)
-GNUPlot utility: See 2.9. (line 1243)
-Hoare, C.A.R. <1>: See 3.10. (line 3161)
-Hoare, C.A.R.: See 3.8. (line 2563)
-hostname field: See 2.1.1. (line 434)
-HTML (Hypertext Markup Language): See 2.7. (line 970)
-HTTP (Hypertext Transfer Protocol) <1>: See 2.7. (line 946)
-HTTP (Hypertext Transfer Protocol): See 1.3.1. (line 256)
-HTTP (Hypertext Transfer Protocol), record separators and:See 2.7.
- (line 970)
-HTTP server, core logic: See 2.9. (line 1064)
-Humphrys, Mark: See 2.10. (line 1615)
-Hypertext Markup Language (HTML): See 2.7. (line 970)
-Hypertext Transfer Protocol, See HTTP: See 2.7. (line 946)
-image format: See 3.6. (line 2198)
-images, in web pages: See 2.9. (line 1243)
-images, retrieving over networks: See 2.7. (line 986)
-input/output, two-way, See Also gawk, networking:See 2.1. (line 388)
-Internet, See networks: See 2.4. (line 817)
-JavaScript: See 3.6. (line 2248)
-Linux <1>: See 3.3. (line 1918)
-Linux <2>: See 2.4. (line 796)
-Linux: See 2.3. (line 749)
-Lisp: See 3.8. (line 2655)
-localport field: See 2.1. (line 403)
-Loebner, Hugh: See 2.12. (line 1653)
-Loui, Ronald: See 2.12. (line 1723)
-MAZE: See 3.7. (line 2434)
-Microsoft Windows: See 3.5. (line 2148)
-Microsoft Windows, networking: See 2.3. (line 749)
-Microsoft Windows, networking, ports: See 2.5. (line 858)
-MiniSQL: See 3.3. (line 2023)
-MOBAGWHO program: See 3.8. (line 2563)
-NCBI, National Center for Biotechnology Information:See 3.10.
- (line 3161)
-networks, gawk and: See 2. (line 345)
-networks, gawk and, connections <1>: See 2.2. (line 651)
-networks, gawk and, connections: See 2.1.1. (line 454)
-networks, gawk and, filenames: See 2.1. (line 398)
-networks, gawk and, See Also email: See 2.6. (line 899)
-networks, gawk and, service, establishing: See 2.5. (line 827)
-networks, gawk and, troubleshooting: See 2.11. (line 1629)
-networks, ports, reserved: See 2.5. (line 858)
-networks, ports, specifying: See 2.1.1. (line 423)
-networks, See Also web pages: See 3.1. (line 1825)
-Numerical Recipes: See 3.6. (line 2216)
-ORS variable, HTTP and: See 2.7. (line 970)
-ORS variable, POP and: See 2.6. (line 929)
-PANIC program: See 3.1. (line 1825)
-Perl: See 2. (line 353)
-Perl, gawk networking and: See 2. (line 363)
-Perlis, Alan: See 3.7. (line 2434)
-pipes, networking and: See 2.2. (line 675)
-PNG image format <1>: See 3.6. (line 2198)
-PNG image format: See 2.7. (line 986)
-POP (Post Office Protocol): See 2.6. (line 899)
-Post Office Protocol (POP): See 2.6. (line 899)
-PostScript: See 3.6. (line 2330)
-PROLOG: See 2.12. (line 1723)
-PROTBASE: See 3.10. (line 3161)
-protocol field: See 2.1.1. (line 416)
-PS image format: See 3.6. (line 2198)
-Python: See 2. (line 353)
-Python, gawk networking and: See 2. (line 363)
-RAW protocol: See 2.1.2.3. (line 585)
-record separators, HTTP and: See 2.7. (line 970)
-record separators, POP and: See 2.6. (line 929)
-REMCONF program: See 3.3. (line 1918)
-remoteport field: See 2.1. (line 403)
-robot <1>: See 3.5. (line 2111)
-robot: See 2.12. (line 1732)
-RS variable, HTTP and: See 2.7. (line 970)
-RS variable, POP and: See 2.6. (line 929)
-servers <1>: See 2.5. (line 843)
-servers: See 1.4. (line 296)
-servers, as hosts: See 2.1.1. (line 434)
-servers, HTTP: See 2.9. (line 1064)
-servers, web: See 2.10. (line 1442)
-Simple Mail Transfer Protocol (SMTP): See 2.6. (line 899)
-SMTP (Simple Mail Transfer Protocol) <1>: See 2.6. (line 899)
-SMTP (Simple Mail Transfer Protocol): See 1.3.1. (line 256)
-SPAK utility: See 2.1.2.3. (line 600)
-STATIST program: See 3.6. (line 2198)
-STOXPRED program: See 3.9. (line 2845)
-synchronous communications: See 1.4. (line 317)
-Tcl/Tk: See 2. (line 353)
-Tcl/Tk, gawk and <1>: See 3. (line 1810)
-Tcl/Tk, gawk and: See 2. (line 363)
-TCP (Transmission Control Protocol) <1>: See 2.1.2.1. (line 526)
-TCP (Transmission Control Protocol): See 2. (line 368)
-TCP (Transmission Control Protocol), connection, establishing:See 2.2.
- (line 651)
-TCP (Transmission Control Protocol), UDP and: See 2.4. (line 817)
-TCP/IP, protocols, selecting: See 2.1.1. (line 416)
-TCP/IP, sockets and: See 2.1. (line 388)
-Transmission Control Protocol, See TCP: See 2. (line 368)
-troubleshooting, gawk, networks: See 2.11. (line 1629)
-troubleshooting, networks, connections: See 2.3. (line 701)
-troubleshooting, networks, timeouts: See 2.11. (line 1641)
-UDP (User Datagram Protocol): See 2.1.2.2. (line 555)
-UDP (User Datagram Protocol), TCP and: See 2.4. (line 817)
-Unix, network ports and: See 2.5. (line 858)
-URLCHK program: See 3.4. (line 2033)
-User Datagram Protocol, See UDP: See 2.1.2.2. (line 555)
-vertical bar (|), |& operator (I/O): See 2.2. (line 670)
-VRML: See 3.7. (line 2434)
-web browsers, See web service: See 2.9. (line 1064)
-web pages: See 2.7. (line 946)
-web pages, images in: See 2.9. (line 1243)
-web pages, retrieving: See 3.2. (line 1864)
-web servers: See 2.10. (line 1442)
-web service <1>: See 3.1. (line 1825)
-web service: See 2.8. (line 1009)
-WEBGRAB program: See 3.5. (line 2111)
-Weizenbaum, Joseph: See 2.10. (line 1447)
-XBM image format: See 2.9. (line 1243)
-Yahoo! <1>: See 3.9. (line 2845)
-Yahoo!: See 3.3. (line 1918)
-| (vertical bar), |& operator (I/O): See 2.2. (line 670)
Index: manual/gawkinet/gawkinet.txt.gz
===================================================================
RCS file: manual/gawkinet/gawkinet.txt.gz
diff -N manual/gawkinet/gawkinet.txt.gz
Binary files /tmp/cvsHSt4Q3 and /dev/null differ
Index: manual/gawkinet/index.html
===================================================================
RCS file: manual/gawkinet/index.html
diff -N manual/gawkinet/index.html
--- manual/gawkinet/index.html 13 Oct 2006 19:23:53 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<!-- $Id: index.html,v 1.2 2006/10/13 19:23:53 johnsu01 Exp $ -->
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-
-<head>
-<title>Gawkinet: TCP/IP Internetworking with gawk - GNU Project - Free
Software Foundation (FSF)</title>
-<meta http-equiv="content-type" content='text/html; charset=utf-8' />
-<link rel="stylesheet" type="text/css" href="/gnu.css" />
-<link rev="made" href="address@hidden" />
-</head>
-
-<!-- This document is in XML, and xhtml 1.0 -->
-<!-- Please make sure to properly nest your tags -->
-<!-- and ensure that your final document validates -->
-<!-- consistent with W3C xhtml 1.0 and CSS standards -->
-<!-- See validator.w3.org -->
-
-<body>
-
-<h3>Gawkinet: TCP/IP Internetworking with gawk</h3>
-
-<address>Free Software Foundation</address>
-<address>last updated August 31, 2004</address>
-<p>
-<a href="/graphics/gnu-head.jpg">
- <img src="/graphics/gnu-head-sm.jpg"
- alt=" [image of the head of a GNU] "
- width="129" height="122" />
-</a>
-
-</p>
-<hr />
-
-<p>This manual (for gawkinet) is available in the following formats:</p>
-
-<ul>
- <li><a href="gawkinet.html">HTML
- (268K characters)</a> - entirely on one web page.</li>
- <li><a href="html_node/index.html">HTML</a> - with one web page per
- node.</li>
- <li><a href="gawkinet.html.gz">HTML compressed
- (80K gzipped characters)</a> - entirely on
- one web page.</li>
- <li><a href="gawkinet.html_node.tar.gz">HTML compressed
- (92K gzipped tar file)</a> -
- with one web page per node.</li>
- <li><a href="gawkinet.info.tar.gz">Info document
- (72K characters gzipped tar file)</a>.</li>
- <li><a href="gawkinet.txt">ASCII text
- (200K characters)</a>.</li>
- <li><a href="gawkinet.txt.gz">ASCII text compressed
- (68K gzipped characters)</a>.</li>
- <li><a href="gawkinet.dvi.gz">TeX dvi file
- (104K characters gzipped)</a>.</li>
- <li><a href="gawkinet.ps.gz">PostScript file
- (536K characters gzipped)</a>.</li>
- <li><a href="gawkinet.pdf">PDF file
- (452K characters)</a>.</li>
- <li><a href="gawkinet.texi.tar.gz">Texinfo source
- (380K characters gzipped tar file)</a></li>
-</ul>
-
-<p>(This page generated by the <a
-href="http://savannah.gnu.org/cgi-bin/viewcvs/texinfo/texinfo/util/gendocs.sh">gendocs.sh</a>
script.)
-</p>
-
-<div class="copyright">
-<p>
-Return to the <a href="/home.html">GNU Project home page</a>.
-</p>
-
-<p>
-Please send FSF & GNU inquiries to
-<a href="mailto:address@hidden"><em>address@hidden</em></a>.
-There are also <a href="/home.html#ContactInfo">other ways to contact</a>
-the FSF.
-<br />
-Please send broken links and other corrections (or suggestions) to
-<a href="mailto:address@hidden"><em>address@hidden</em></a>.
-</p>
-
-<p>
-Copyright (C) 2004 Free Software Foundation, Inc.,
-59 Temple Place - Suite 330, Boston, MA 02111, USA
-<br />
-Verbatim copying and distribution of this entire article is
-permitted in any medium, provided this notice is preserved.
-</p>
-
-<p>
-Updated:
-<!-- timestamp start -->
-$Date: 2006/10/13 19:23:53 $ $Author: johnsu01 $
-<!-- timestamp end -->
-</p>
-</div>
-
-</body>
-</html>
Index: manual/gawkinet/html_node/Basic-Protocols.html
===================================================================
RCS file: manual/gawkinet/html_node/Basic-Protocols.html
diff -N manual/gawkinet/html_node/Basic-Protocols.html
--- manual/gawkinet/html_node/Basic-Protocols.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-<html lang="en">
-<head>
-<title>Basic Protocols - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols"
title="The TCP/IP Protocols">
-<link rel="prev" href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols"
title="The TCP/IP Protocols">
-<link rel="next" href="Ports.html#Ports" title="Ports">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Basic-Protocols"></a>Next: <a rel="next" accesskey="n"
href="Ports.html#Ports">Ports</a>,
-Previous: <a rel="previous" accesskey="p"
href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>,
-Up: <a rel="up" accesskey="u"
href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.3.1 The Basic Internet Protocols</h4>
-
- <dl>
-<dt>IP<dd>The Internet Protocol. This protocol is almost never used directly
by
-applications. It provides the basic packet delivery and routing infrastructure
-of the Internet. Much like the phone company's switching centers or the Post
-Office's trucks, it is not of much day-to-day interest to the regular user
-(or programmer).
-It happens to be a best effort datagram protocol.
-
- <br><dt>UDP<dd>The User Datagram Protocol. This is a best effort
datagram protocol.
-It provides a small amount of extra reliability over IP, and adds
-the notion of <dfn>ports</dfn>, described in <a href="Ports.html#Ports">TCP
and UDP Ports</a>.
-
- <br><dt>TCP<dd>The Transmission Control Protocol. This is a duplex,
reliable, sequenced
-byte-stream protocol, again layered on top of IP, and also providing the
-notion of ports. This is the protocol that you will most likely use
-when using <samp><span class="command">gawk</span></samp> for network
programming.
-</dl>
-
- <p>All other user-level protocols use either TCP or UDP to do their basic
-communications. Examples are SMTP (Simple Mail Transfer Protocol),
-FTP (File Transfer Protocol), and HTTP (HyperText Transfer Protocol).
-<a name="index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-1"></a><a
name="index-FTP-_0028File-Transfer-Protocol_0029-2"></a><a
name="index-HTTP-_0028Hypertext-Transfer-Protocol_0029-3"></a>
-
- </body></html>
-
Index: manual/gawkinet/html_node/CGI-Lib.html
===================================================================
RCS file: manual/gawkinet/html_node/CGI-Lib.html
diff -N manual/gawkinet/html_node/CGI-Lib.html
--- manual/gawkinet/html_node/CGI-Lib.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,255 +0,0 @@
-<html lang="en">
-<head>
-<title>CGI Lib - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Interacting-Service.html#Interacting-Service"
title="Interacting Service">
-<link rel="prev" href="Interacting-Service.html#Interacting-Service"
title="Interacting Service">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="CGI-Lib"></a>Previous: <a rel="previous" accesskey="p"
href="Interacting-Service.html#Interacting-Service">Interacting Service</a>,
-Up: <a rel="up" accesskey="u"
href="Interacting-Service.html#Interacting-Service">Interacting Service</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">2.9.1 A Simple CGI Library</h4>
-
-<blockquote>
-<i>HTTP is like being married: you have to be able to handle whatever
-you're given, while being very careful what you send back.</i><br>
-Phil Smith III,<br>
-<a
href="http://www.netfunny.com/rhf/jokes/99/Mar/http.html">http://www.netfunny.com/rhf/jokes/99/Mar/http.html</a>
-</blockquote>
-
-<!-- STARTOFRANGE cgilib -->
-<p><a
name="index-CGI-_0028Common-Gateway-Interface_0029_002c-library-105"></a>In <a
href="Interacting-Service.html#Interacting-Service">A Web Service with
Interaction</a>,
-we saw the function <code>CGI_setup</code> as part of the web server
-“core logic” framework. The code presented there handles almost
-everything necessary for CGI requests.
-One thing it doesn't do is handle encoded characters in the requests.
-For example, an `<samp><span class="samp">&</span></samp>' is encoded as a
percent sign followed by
-the hexadecimal value: `<samp><span class="samp">%26</span></samp>'. These
encoded values should be
-decoded.
-Following is a simple library to perform these tasks.
-This code is used for all web server examples
-used throughout the rest of this web page.
-If you want to use it for your own web server, store the source code
-into a file named <samp><span class="file">inetlib.awk</span></samp>. Then you
can include
-these functions into your code by placing the following statement
-into your program
-(on the first line of your script):
-
-<pre class="example"> @include inetlib.awk
-</pre>
- <p class="noindent">But beware, this mechanism is
-only possible if you invoke your web server script with <samp><span
class="command">igawk</span></samp>
-instead of the usual <samp><span class="command">awk</span></samp> or
<samp><span class="command">gawk</span></samp>.
-Here is the code:
-
-<pre class="example"> <!-- file eg/network/coreserv.awk -->
- # CGI Library and core of a web server
- <!-- endfile -->
- <!-- file eg/network/coreserv.awk -->
- # Global arrays
- # GETARG --- arguments to CGI GET command
- # MENU --- menu items (path names)
- # PARAM --- parameters of form x=y
-
- # Optional variable MyHost contains host address
- # Optional variable MyPort contains port number
- # Needs TopHeader, TopDoc, TopFooter
- # Sets MyPrefix, HttpService, Status, Reason
-
- BEGIN {
- if (MyHost == "") {
- "uname -n" | getline MyHost
- close("uname -n")
- }
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- MyPrefix = "http://" MyHost ":" MyPort
- SetUpServer()
- while ("awk" != "complex") {
- # header lines are terminated this way
- RS = ORS = "\r\n"
- Status = 200 # this means OK
- Reason = "OK"
- Header = TopHeader
- Document = TopDoc
- Footer = TopFooter
- if (GETARG["Method"] == "GET") {
- HandleGET()
- } else if (GETARG["Method"] == "HEAD") {
- # not yet implemented
- } else if (GETARG["Method"] != "") {
- print "bad method", GETARG["Method"]
- }
- Prompt = Header Document Footer
- print "HTTP/1.0", Status, Reason |& HttpService
- print "Connection: Close" |& HttpService
- print "Pragma: no-cache" |& HttpService
- len = length(Prompt) + length(ORS)
- print "Content-length:", len |& HttpService
- print ORS Prompt |& HttpService
- # ignore all the header lines
- while ((HttpService |& getline) > 0)
- continue
- # stop talking to this client
- close(HttpService)
- # wait for new client request
- HttpService |& getline
- # do some logging
- print systime(), strftime(), $0
- CGI_setup($1, $2, $3)
- }
- }
-
- function CGI_setup( method, uri, version, i)
- {
- delete GETARG
- delete MENU
- delete PARAM
- GETARG["Method"] = method
- GETARG["URI"] = uri
- GETARG["Version"] = version
-
- i = index(uri, "?")
- if (i > 0) { # is there a "?" indicating a CGI request?
- split(substr(uri, 1, i-1), MENU, "[/:]")
- split(substr(uri, i+1), PARAM, "&")
- for (i in PARAM) {
- PARAM[i] = _CGI_decode(PARAM[i])
- j = index(PARAM[i], "=")
- GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
- }
- } else { # there is no "?", no need for splitting PARAMs
- split(uri, MENU, "[/:]")
- }
- for (i in MENU) # decode characters in path
- if (i > 4) # but not those in host name
- MENU[i] = _CGI_decode(MENU[i])
- }
- <!-- endfile -->
-</pre>
- <p>This isolates details in a single function, <code>CGI_setup</code>.
-Decoding of encoded characters is pushed off to a helper function,
-<code>_CGI_decode</code>. The use of the leading underscore (`<samp><span
class="samp">_</span></samp>') in
-the function name is intended to indicate that it is an “internal”
-function, although there is nothing to enforce this:
-
-<pre class="example"> <!-- file eg/network/coreserv.awk -->
- function _CGI_decode(str, hexdigs, i, pre, code1, code2,
- val, result)
- {
- hexdigs = "123456789abcdef"
-
- i = index(str, "%")
- if (i == 0) # no work to do
- return str
-
- do {
- pre = substr(str, 1, i-1) # part before %xx
- code1 = substr(str, i+1, 1) # first hex digit
- code2 = substr(str, i+2, 1) # second hex digit
- str = substr(str, i+3) # rest of string
-
- code1 = tolower(code1)
- code2 = tolower(code2)
- val = index(hexdigs, code1) * 16 \
- + index(hexdigs, code2)
-
- result = result pre sprintf("%c", val)
- i = index(str, "%")
- } while (i != 0)
- if (length(str) > 0)
- result = result str
- return result
- }
- <!-- endfile -->
-</pre>
- <p>This works by splitting the string apart around an encoded character.
-The two digits are converted to lowercase characters and looked up in a string
-of hex digits. Note that <code>0</code> is not in the string on purpose;
-<code>index</code> returns zero when it's not found, automatically giving
-the correct value! Once the hexadecimal value is converted from
-characters in a string into a numerical value, <code>sprintf</code>
-converts the value back into a real character.
-The following is a simple test harness for the above functions:
-
-<pre class="example"> <!-- file eg/network/testserv.awk -->
- BEGIN {
- CGI_setup("GET",
- "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \
- "&percent=a %25 sign",
- "1.0")
- for (i in MENU)
- printf "MENU[\"%s\"] = %s\n", i, MENU[i]
- for (i in PARAM)
- printf "PARAM[\"%s\"] = %s\n", i, PARAM[i]
- for (i in GETARG)
- printf "GETARG[\"%s\"] = %s\n", i, GETARG[i]
- }
- <!-- endfile -->
-</pre>
- <p>And this is the result when we run it:
-
-<!-- artificial line wrap in last output line -->
-<pre class="example"> $ gawk -f testserv.awk
- -| MENU["4"] = www.gnu.org
- -| MENU["5"] = cgi-bin
- -| MENU["6"] = foo
- -| MENU["1"] = http
- -| MENU["2"] =
- -| MENU["3"] =
- -| PARAM["1"] = p1=stuff
- -| PARAM["2"] = p2=stuff&junk
- -| PARAM["3"] = percent=a % sign
- -| GETARG["p1"] = stuff
- -| GETARG["percent"] = a % sign
- -| GETARG["p2"] = stuff&junk
- -| GETARG["Method"] = GET
- -| GETARG["Version"] = 1.0
- -| GETARG["URI"] = http://www.gnu.org/cgi-bin/foo?p1=stuff&
- p2=stuff%26junk&percent=a %25 sign
-</pre>
- </body></html>
-
Index: manual/gawkinet/html_node/Caveats.html
===================================================================
RCS file: manual/gawkinet/html_node/Caveats.html
diff -N manual/gawkinet/html_node/Caveats.html
--- manual/gawkinet/html_node/Caveats.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-<html lang="en">
-<head>
-<title>Caveats - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Simple-Server.html#Simple-Server" title="Simple Server">
-<link rel="next" href="Challenges.html#Challenges" title="Challenges">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Caveats"></a>Next: <a rel="next" accesskey="n"
href="Challenges.html#Challenges">Challenges</a>,
-Previous: <a rel="previous" accesskey="p"
href="Simple-Server.html#Simple-Server">Simple Server</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.11 Network Programming Caveats</h3>
-
-<p><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-troubleshooting-112"></a><a
name="index-_0040command_007bgawk_007d_002c-networking_002c-troubleshooting-113"></a><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d_002c-networks-114"></a>By
now it should be clear
-that debugging a networked application is more
-complicated than debugging a single-process single-hosted application.
-The behavior of a networked application sometimes looks noncausal because
-it is not reproducible in a strong sense. Whether a network application
-works or not sometimes depends on the following:
-
- <ul>
-<li>How crowded the underlying network is
-
- <li>If the party at the other end is running or not
-
- <li>The state of the party at the other end
-</ul>
-
- <p><a name="index-troubleshooting_002c-networks_002c-timeouts-115"></a>The
most difficult problems for a beginner arise from the hidden states of the
-underlying network. After closing a TCP connection, it's often necessary to
wait
-a short while before reopening the connection. Even more difficult is the
-establishment of a connection that previously ended with a “broken
pipe.”
-Those connections have to “time out” for a minute or so
-before they can reopen.
-Check this with the command `<samp><span class="samp">netstat
-a</span></samp>', which
-provides a list of still “active” connections.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Challenges.html
===================================================================
RCS file: manual/gawkinet/html_node/Challenges.html
diff -N manual/gawkinet/html_node/Challenges.html
--- manual/gawkinet/html_node/Challenges.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,190 +0,0 @@
-<html lang="en">
-<head>
-<title>Challenges - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Caveats.html#Caveats" title="Caveats">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Challenges"></a>Previous: <a rel="previous" accesskey="p"
href="Caveats.html#Caveats">Caveats</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.12 Where To Go From Here</h3>
-
-<p><a name="index-Loebner_002c-Hugh-116"></a><a
name="index-contest-117"></a>Now, you have learned enough to build your own
application. You could,
-for example, take part in the
-Loebner Contest
-to win $100,000. The Loebner Prize is the first formal instantiation of
-a Turing Test. Hugh Loebner agreed with The Cambridge Center for Behavioral
-Studies to underwrite a contest designed to implement the Turing Test.
-Dr. Loebner pledged a Grand Prize of $100,000 for the first computer whose
-responses were indistinguishable from a human's. Each year an annual prize
-of $2000 and a bronze medal is awarded to the <em>most</em> human computer.
-The winner of the annual contest is the best entry relative to other entries
-that year, irrespective of how good it is in an absolute sense. Here is
-an example of a conversation with the winning program of 1997:
-
-<pre class="smallexample"> (c)1997 Cambridge Center For Behavioral Studies
all rights reserved [CONVERSE]
- [Intelligent Research Ltd.] Start at: [1997/04/29 08:59:40]
- PROGRAM[10:39:20]Hi, my name is Catherine, what's yours?
- JUDGE02[10:39:36]My name is Nathan.
- PROGRAM[10:39:37]Well, it's nice to meet you, Nathan.
- PROGRAM[10:39:45]Did you see that story on CNN last night about the
lesbian
- PROGRAM[10:40:03]couple who came out at a White House party on Sunday?
- JUDGE02[10:40:45]No. I'm sorry I missed that. How did the Prez take it?
- PROGRAM[10:40:47]Ellen Degeneres was one of them - she was kissing her
lover
- PROGRAM[10:41:08]in front of Bill Clinton. Do you think he was very
- PROGRAM[10:41:21]embarrassed?
- JUDGE02[10:41:37]You tell me. I didn't see it.
- PROGRAM[10:41:38]Are you still a Friend of Bill Clinton?
- JUDGE02[10:42:22]Yes. I would like to talk about something else. Do you
know anything about sculpture.
- PROGRAM[10:42:24]Well, I suppose he's doing his best like most of us, but
he
- PROGRAM[10:42:35]does seem to attract an UNUSUAL amount of bad publicity,
- PROGRAM[10:42:51]wouldnt you say--can it all be bad luck?
- JUDGE02[10:43:20]I asked you if you knew anything about sculpture.
- PROGRAM[10:43:21]OK, but what happens now--does it all drift on, with
- PROGRAM[10:43:36]everyone waiting to see how much his friends have said
about
- PROGRAM[10:43:47]him under threat of lots and lots of jail-or will
something
- PROGRAM[10:44:01]dramatic actually happen?
- JUDGE02[10:44:19]Do you know what sculpture is?
- PROGRAM[10:44:20]Well, youre more a fan of his than I am I guess---though
I
- PROGRAM[10:44:34]cant SWEAR what Id have done in that locked hotel room, I
- PROGRAM[10:44:51]must say.
- JUDGE02[10:45:26]Have you ever been to the Salmagundi Club?
- PROGRAM[10:45:29]Never. to go back to the original discussion Time to get
- PROGRAM[10:45:43]off this one I think and onto something more down to
earth!
- JUDGE02[10:46:20]What is more down to earth than art?
- PROGRAM[10:46:21]I don't know what -- to be honest. -
- PROGRAM[10:46:30]I suppose it depends on where you're coming from, but as
the
- PROGRAM[10:46:46]song goes in My Fair Lady, "Why can't a woman be more
like a
- PROGRAM[10:47:03]man? "
- JUDGE02[10:47:52]I liked that song but I prefer "Why can't children be
more like we are"
- JUDGE02[10:48:10]from another play the name of which I cannot remember.
- PROGRAM[10:48:12]What, if anything, do you enjoy about being a man?
- JUDGE02[10:49:01]I would enjoy all aspects of life no matter what my
gender.
- PROGRAM[10:49:02]Do you think of yourself as being attractive?
-</pre>
- <p><a name="index-Clinton_002c-Bill-118"></a>This program insists on always
speaking about the same story around Bill
-Clinton. You see, even a program with a rather narrow mind can behave so
-much like a human being that it can win this prize. It is quite common to
-let these programs talk to each other via network connections. But during the
-competition itself, the program and its computer have to be present at the
-place the competition is held. We all would love to see a <samp><span
class="command">gawk</span></samp>
-program win in such an event. Maybe it is up to you to accomplish this?
-
- <p>Some other ideas for useful networked applications:
- <ul>
-<li>Read the file <samp><span class="file">doc/awkforai.txt</span></samp> in
the <samp><span class="command">gawk</span></samp> distribution.
-It was written by Ronald P. Loui (Associate Professor of
-Computer Science, at Washington University in St. Louis,
-<a href="mailto:address@hidden">address@hidden</a>) and summarizes why
-he teaches <samp><span class="command">gawk</span></samp> to students of
Artificial Intelligence. Here are
-some passages from the text:
-
- <p><a name="index-AI-119"></a><a name="index-PROLOG-120"></a><a
name="index-Loui_002c-Ronald-121"></a><a name="index-agent-122"></a><blockquote>
-The GAWK manual can
-be consumed in a single lab session and the language can be mastered by
-the next morning by the average student. GAWK's automatic
-initialization, implicit coercion, I/O support and lack of pointers
-forgive many of the mistakes that young programmers are likely to make.
-Those who have seen C but not mastered it are happy to see that GAWK
-retains some of the same sensibilities while adding what must be
-regarded as spoonsful of syntactic sugar.<br>
-<small class="dots">...</small><br>
-<a name="index-robot-123"></a>There are further simple answers. Probably the
best is the fact that
-increasingly, undergraduate AI programming is involving the Web. Oren
-Etzioni (University of Washington, Seattle) has for a while been arguing
-that the “softbot” is replacing the mechanical engineers' robot as
the
-most glamorous AI testbed. If the artifact whose behavior needs to be
-controlled in an intelligent way is the software agent, then a language
-that is well-suited to controlling the software environment is the
-appropriate language. That would imply a scripting language. If the
-robot is KAREL, then the right language is “turn left; turn
right.” If
-the robot is Netscape, then the right language is something that can
-generate `<samp><span class="samp">netscape -remote
'openURL(http://cs.wustl.edu/~loui)'</span></samp>' with
-elan.<br>
-<small class="dots">...</small><br>
-AI programming requires high-level thinking. There have always been a few
-gifted programmers who can write high-level programs in assembly language.
-Most however need the ambient abstraction to have a higher floor.<br>
-<small class="dots">...</small><br>
-Second, inference is merely the expansion of notation. No matter whether
-the logic that underlies an AI program is fuzzy, probabilistic, deontic,
-defeasible, or deductive, the logic merely defines how strings can be
-transformed into other strings. A language that provides the best
-support for string processing in the end provides the best support for
-logic, for the exploration of various logics, and for most forms of
-symbolic processing that AI might choose to call “reasoning”
instead of
-“logic.” The implication is that PROLOG, which saves the AI
programmer
-from having to write a unifier, saves perhaps two dozen lines of GAWK
-code at the expense of strongly biasing the logic and representational
-expressiveness of any approach.
-</blockquote>
-
- <p>Now that <samp><span class="command">gawk</span></samp> itself can
connect to the Internet, it should be obvious
-that it is suitable for writing intelligent web agents.
-
- <li><samp><span class="command">awk</span></samp> is strong at pattern
recognition and string processing.
-So, it is well suited to the classic problem of language translation.
-A first try could be a program that knows the 100 most frequent English
-words and their counterparts in German or French. The service could be
-implemented by regularly reading email with the program above, replacing
-each word by its translation and sending the translation back via SMTP.
-Users would send English email to their translation service and get
-back a translated email message in return. As soon as this works,
-more effort can be spent on a real translation program.
-
- <li>Another dialogue-oriented application (on the verge
-of ridicule) is the email “support service.” Troubled customers
write an
-email to an automatic <samp><span class="command">gawk</span></samp> service
that reads the email. It looks
-for keywords in the mail and assembles a reply email accordingly. By carefully
-investigating the email header, and repeating these keywords through the
-reply email, it is rather simple to give the customer a feeling that
-someone cares. Ideally, such a service would search a database of previous
-cases for solutions. If none exists, the database could, for example, consist
-of all the newsgroups, mailing lists and FAQs on the Internet.
-</ul>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Comparing-Protocols.html
===================================================================
RCS file: manual/gawkinet/html_node/Comparing-Protocols.html
diff -N manual/gawkinet/html_node/Comparing-Protocols.html
--- manual/gawkinet/html_node/Comparing-Protocols.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<html lang="en">
-<head>
-<title>Comparing Protocols - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Gawk-Special-Files.html#Gawk-Special-Files" title="Gawk
Special Files">
-<link rel="prev" href="Special-File-Fields.html#Special-File-Fields"
title="Special File Fields">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Comparing-Protocols"></a>Previous: <a rel="previous"
accesskey="p" href="Special-File-Fields.html#Special-File-Fields">Special File
Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">2.1.2 Comparing Protocols</h4>
-
-<p>This section develops a pair of programs (sender and receiver)
-that do nothing but send a timestamp from one machine to another. The
-sender and the receiver are implemented with each of the three protocols
-available and demonstrate the differences between them.
-
-<ul class="menu">
-<li><a accesskey="1"
href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">File /inet/tcp</a>:
The TCP special file.
-<li><a accesskey="2"
href="File-_002finet_002fudp.html#File-_002finet_002fudp">File /inet/udp</a>:
The UDP special file.
-<li><a accesskey="3"
href="File-_002finet_002fraw.html#File-_002finet_002fraw">File /inet/raw</a>:
The RAW special file.
-</ul>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Datagram-Communications.html
===================================================================
RCS file: manual/gawkinet/html_node/Datagram-Communications.html
diff -N manual/gawkinet/html_node/Datagram-Communications.html
--- manual/gawkinet/html_node/Datagram-Communications.html 31 Aug 2004
22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,103 +0,0 @@
-<html lang="en">
-<head>
-<title>Datagram Communications - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Introduction.html#Introduction" title="Introduction">
-<link rel="prev" href="Stream-Communications.html#Stream-Communications"
title="Stream Communications">
-<link rel="next" href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols"
title="The TCP/IP Protocols">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Datagram-Communications"></a>Next: <a rel="next" accesskey="n"
href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>,
-Previous: <a rel="previous" accesskey="p"
href="Stream-Communications.html#Stream-Communications">Stream
Communications</a>,
-Up: <a rel="up" accesskey="u"
href="Introduction.html#Introduction">Introduction</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.2 Best-effort Datagrams (Mailed Letters)</h3>
-
-<p>Suppose you mail three different documents to your office on the
-other side of the country on two different days. Doing so
-entails the following.
-
- <ol type=1 start=1>
-<li>Each document travels in its own envelope.
-
- <li>Each envelope contains both the sender and the
-recipient address.
-
- <li>Each envelope may travel a different route to its destination.
-
- <li>The envelopes may arrive in a different order from the one
-in which they were sent.
-
- <li>One or more may get lost in the mail.
-(Although, fortunately, this does not occur very often.)
-
- <li>In a computer network, one or more <dfn>packets</dfn>
-may also arrive multiple times. (This doesn't happen
-with the postal system!)
-
- </ol>
-
- <p>The important characteristics of datagram communications, like
-those of the postal system are thus:
-
- <ul>
-<li>Delivery is “best effort;” the data may never get there.
-
- <li>Each message is self-contained, including the source and
-destination addresses.
-
- <li>Delivery is <em>not</em> sequenced; packets may arrive out
-of order, and/or multiple times.
-
- <li>Unlike the phone system, overhead is considerably lower.
-It is not necessary to set up the call first.
-</ul>
-
- <p>The price the user pays for the lower overhead of datagram communications
-is exactly the lower reliability; it is often necessary for user-level
-protocols that use datagram communications to add their own reliability
-features on top of the basic communications.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Email.html
===================================================================
RCS file: manual/gawkinet/html_node/Email.html
diff -N manual/gawkinet/html_node/Email.html
--- manual/gawkinet/html_node/Email.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-<html lang="en">
-<head>
-<title>Email - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Setting-Up.html#Setting-Up" title="Setting Up">
-<link rel="next" href="Web-page.html#Web-page" title="Web page">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Email"></a>Next: <a rel="next" accesskey="n"
href="Web-page.html#Web-page">Web page</a>,
-Previous: <a rel="previous" accesskey="p"
href="Setting-Up.html#Setting-Up">Setting Up</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.6 Reading Email</h3>
-
-<!-- @cindex RFC 1939 -->
-<!-- @cindex RFC 821 -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-networking_002c-See-Also-email-70"></a><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-See-Also-email-71"></a><a
name="index-POP-_0028Post-Office-Protocol_0029-72"></a><a
name="index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-73"></a><a
name="index-Post-Office-Protocol-_0028POP_0029-74"></a><a
name="index-Simple-Mail-Transfer-Protocol-_0028SMTP_0029-75"></a>The
distribution of email is usually done by dedicated email servers that
-communicate with your machine using special protocols. To receive email, we
-will use the Post Office Protocol (POP). Sending can be done with the much
-older Simple Mail Transfer Protocol (SMTP).
-
- <p><a name="index-email-76"></a>When you type in the following program,
replace the <var>emailhost</var> by the
-name of your local email server. Ask your administrator if the server has a
-POP service, and then use its name or number in the program below.
-Now the program is ready to connect to your email server, but it will not
-succeed in retrieving your mail because it does not yet know your login
-name or password. Replace them in the program and it
-shows you the first email the server has in store:
-
-<pre class="example"> BEGIN {
- POPService = "/inet/tcp/0/<var>emailhost</var>/pop3"
- RS = ORS = "\r\n"
- print "user <var>name</var>" |& POPService
- POPService |& getline
- print "pass <var>password</var>" |& POPService
- POPService |& getline
- print "retr 1" |& POPService
- POPService |& getline
- if ($1 != "+OK") exit
- print "quit" |& POPService
- RS = "\r\n\\.\r\n"
- POPService |& getline
- print $0
- close(POPService)
- }
-</pre>
- <!-- @cindex RFC 1939 -->
-<p><a name="index-record-separators_002c-POP-and-77"></a><a
name="index-_0040code_007bRS_007d-variable_002c-POP-and-78"></a><a
name="index-_0040code_007bORS_007d-variable_002c-POP-and-79"></a><a
name="index-POP-_0028Post-Office-Protocol_0029-80"></a>The record separators
<code>RS</code> and <code>ORS</code> are redefined because the
-protocol (POP) requires CR-LF to separate lines. After identifying
-yourself to the email service, the command `<samp><span class="samp">retr
1</span></samp>' instructs the
-service to send the first of all your email messages in line. If the service
-replies with something other than `<samp><span
class="samp">+OK</span></samp>', the program exits; maybe there
-is no email. Otherwise, the program first announces that it intends to finish
-reading email, and then redefines <code>RS</code> in order to read the entire
-email as multiline input in one record. From the POP RFC, we know that the body
-of the email always ends with a single line containing a single dot.
-The program looks for this using `<samp><span class="samp">RS =
"\r\n\\.\r\n"</span></samp>'.
-When it finds this sequence in the mail message, it quits.
-You can invoke this program as often as you like; it does not delete the
-message it reads, but instead leaves it on the server.
-
- </body></html>
-
Index: manual/gawkinet/html_node/File-_002finet_002fraw.html
===================================================================
RCS file: manual/gawkinet/html_node/File-_002finet_002fraw.html
diff -N manual/gawkinet/html_node/File-_002finet_002fraw.html
--- manual/gawkinet/html_node/File-_002finet_002fraw.html 31 Aug 2004
22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,127 +0,0 @@
-<html lang="en">
-<head>
-<title>File /inet/raw - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Comparing-Protocols.html#Comparing-Protocols"
title="Comparing Protocols">
-<link rel="prev" href="File-_002finet_002fudp.html#File-_002finet_002fudp"
title="File /inet/udp">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="File-_002finet_002fraw"></a>Previous: <a rel="previous"
accesskey="p" href="File-_002finet_002fudp.html#File-_002finet_002fudp">File
/inet/udp</a>,
-Up: <a rel="up" accesskey="u"
href="Comparing-Protocols.html#Comparing-Protocols">Comparing Protocols</a>
-<hr><br>
-</div>
-
-<h5 class="subsubsection">2.1.2.3 <samp><span
class="file">/inet/raw</span></samp></h5>
-
-<p><a
name="index-_0040code_007b_002finet_002fraw_007d-special-files-_0028_0040command_007bgawk_007d_0029-41"></a><a
name="index-files_002c-_0040code_007b_002finet_002fraw_007d-_0028_0040command_007bgawk_007d_0029-42"></a><a
name="index-RAW-protocol-43"></a>
-This is an IP-level protocol. Only <code>root</code> is allowed to access this
-special file. It is meant to be the basis for implementing
-and experimenting with transport-level protocols.<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a>
-In the most general case,
-the sender has to supply the encapsulating header bytes in front of the
-packet and the receiver has to strip the additional bytes from the message.
-
- <p><a name="index-dark-corner_002c-RAW-protocol-44"></a>RAW receivers
cannot receive packets sent with TCP or UDP because the
-operating system does not deliver the packets to a RAW receiver. The
-operating system knows about some of the protocols on top of IP
-and decides on its own which packet to deliver to which process.
-(d.c.)
-Therefore, the UDP receiver must be used for receiving UDP
-datagrams sent with the RAW sender. This is a dark corner, not only of
-<samp><span class="command">gawk</span></samp>, but also of TCP/IP.
-
- <p><a name="index-SPAK-utility-45"></a>For extended experimentation with
protocols, look into
-the approach implemented in a tool called SPAK.
-This tool reflects the hierarchical layering of protocols (encapsulation)
-in the way data streams are piped out of one program into the next one.
-It shows which protocol is based on which other (lower-level) protocol
-by looking at the command-line ordering of the program calls.
-Cleverly thought out, SPAK is much better than <samp><span
class="command">gawk</span></samp>'s
-<samp><span class="file">/inet</span></samp> for learning the meaning of each
and every bit in the
-protocol headers.
-
- <p>The next example uses the RAW protocol to emulate
-the behavior of UDP. The sender program is the same as above, but with some
-additional bytes that fill the places of the UDP fields:
-
-<pre class="example"> BEGIN {
- Message = "Hello world\n"
- SourcePort = 0
- DestinationPort = 8888
- MessageLength = length(Message)+8
- RawService = "/inet/raw/0/localhost/0"
- printf("%c%c%c%c%c%c%c%c%s",
- SourcePort/256, SourcePort%256,
- DestinationPort/256, DestinationPort%256,
- MessageLength/256, MessageLength%256,
- 0, 0, Message) |& RawService
- fflush(RawService)
- close(RawService)
- }
-</pre>
- <p>Since this program tries
-to emulate the behavior of UDP, it checks if
-the RAW sender is understood by the UDP receiver but not if the RAW receiver
-can understand the UDP sender. In a real network, the
-RAW receiver is hardly
-of any use because it gets every IP packet that
-comes across the network. There are usually so many packets that
-<samp><span class="command">gawk</span></samp> would be too slow for
processing them.
-Only on a network with little
-traffic can the IP-level receiver program be tested. Programs for analyzing
-IP traffic on modem or ISDN channels should be possible.
-
- <p>Port numbers do not have a meaning when using <samp><span
class="file">/inet/raw</span></samp>. Their fields
-have to be `<samp><span class="samp">0</span></samp>'. Only TCP and UDP use
ports. Receiving data from
-<samp><span class="file">/inet/raw</span></samp> is difficult, not only
because of processing speed but also
-because data is usually binary and not restricted to ASCII. This
-implies that line separation with <code>RS</code> does not work as usual.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This special file
-is reserved, but not otherwise currently implemented.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/File-_002finet_002ftcp.html
===================================================================
RCS file: manual/gawkinet/html_node/File-_002finet_002ftcp.html
diff -N manual/gawkinet/html_node/File-_002finet_002ftcp.html
--- manual/gawkinet/html_node/File-_002finet_002ftcp.html 31 Aug 2004
22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-<html lang="en">
-<head>
-<title>File /inet/tcp - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Comparing-Protocols.html#Comparing-Protocols"
title="Comparing Protocols">
-<link rel="prev" href="Comparing-Protocols.html#Comparing-Protocols"
title="Comparing Protocols">
-<link rel="next" href="File-_002finet_002fudp.html#File-_002finet_002fudp"
title="File /inet/udp">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="File-_002finet_002ftcp"></a>Next: <a rel="next" accesskey="n"
href="File-_002finet_002fudp.html#File-_002finet_002fudp">File /inet/udp</a>,
-Previous: <a rel="previous" accesskey="p"
href="Comparing-Protocols.html#Comparing-Protocols">Comparing Protocols</a>,
-Up: <a rel="up" accesskey="u"
href="Comparing-Protocols.html#Comparing-Protocols">Comparing Protocols</a>
-<hr><br>
-</div>
-
-<h5 class="subsubsection">2.1.2.1 <samp><span
class="file">/inet/tcp</span></samp></h5>
-
-<p><a
name="index-_0040code_007b_002finet_002ftcp_007d-special-files-_0028_0040command_007bgawk_007d_0029-34"></a><a
name="index-files_002c-_0040code_007b_002finet_002ftcp_007d-_0028_0040command_007bgawk_007d_0029-35"></a><a
name="index-TCP-_0028Transmission-Control-Protocol_0029-36"></a>Once again,
always use TCP.
-(Use UDP when low overhead is a necessity, and use RAW for
-network experimentation.)
-The first example is the sender
-program:
-
-<pre class="example"> # Server
- BEGIN {
- print strftime() |& "/inet/tcp/8888/0/0"
- close("/inet/tcp/8888/0/0")
- }
-</pre>
- <p>The receiver is very simple:
-
-<pre class="example"> # Client
- BEGIN {
- "/inet/tcp/0/localhost/8888" |& getline
- print $0
- close("/inet/tcp/0/localhost/8888")
- }
-</pre>
- <p>TCP guarantees that the bytes arrive at the receiving end in exactly
-the same order that they were sent. No byte is lost
-(except for broken connections), doubled, or out of order. Some
-overhead is necessary to accomplish this, but this is the price to pay for
-a reliable service.
-It does matter which side starts first. The sender/server has to be started
-first, and it waits for the receiver to read a line.
-
- </body></html>
-
Index: manual/gawkinet/html_node/File-_002finet_002fudp.html
===================================================================
RCS file: manual/gawkinet/html_node/File-_002finet_002fudp.html
diff -N manual/gawkinet/html_node/File-_002finet_002fudp.html
--- manual/gawkinet/html_node/File-_002finet_002fudp.html 31 Aug 2004
22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-<html lang="en">
-<head>
-<title>File /inet/udp - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Comparing-Protocols.html#Comparing-Protocols"
title="Comparing Protocols">
-<link rel="prev" href="File-_002finet_002ftcp.html#File-_002finet_002ftcp"
title="File /inet/tcp">
-<link rel="next" href="File-_002finet_002fraw.html#File-_002finet_002fraw"
title="File /inet/raw">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="File-_002finet_002fudp"></a>Next: <a rel="next" accesskey="n"
href="File-_002finet_002fraw.html#File-_002finet_002fraw">File /inet/raw</a>,
-Previous: <a rel="previous" accesskey="p"
href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">File /inet/tcp</a>,
-Up: <a rel="up" accesskey="u"
href="Comparing-Protocols.html#Comparing-Protocols">Comparing Protocols</a>
-<hr><br>
-</div>
-
-<h5 class="subsubsection">2.1.2.2 <samp><span
class="file">/inet/udp</span></samp></h5>
-
-<p><a
name="index-_0040code_007b_002finet_002fudp_007d-special-files-_0028_0040command_007bgawk_007d_0029-37"></a><a
name="index-files_002c-_0040code_007b_002finet_002fudp_007d-_0028_0040command_007bgawk_007d_0029-38"></a><a
name="index-UDP-_0028User-Datagram-Protocol_0029-39"></a><a
name="index-User-Datagram-Protocol_002c-See-UDP-40"></a>The server and client
programs that use UDP are almost identical to their TCP counterparts;
-only the <var>protocol</var> has changed. As before, it does matter which side
-starts first. The receiving side blocks and waits for the sender.
-In this case, the receiver/client has to be started first:
-
-<pre class="example"> # Server
- BEGIN {
- print strftime() |& "/inet/udp/8888/0/0"
- close("/inet/udp/8888/0/0")
- }
-</pre>
- <p>The receiver is almost identical to the TCP receiver:
-
-<pre class="example"> # Client
- BEGIN {
- "/inet/udp/0/localhost/8888" |& getline
- print $0
- close("/inet/udp/0/localhost/8888")
- }
-</pre>
- <p>UDP cannot guarantee that the datagrams at the receiving end will arrive
in exactly
-the same order they were sent. Some datagrams could be
-lost, some doubled, and some out of order. But no overhead is necessary to
-accomplish this. This unreliable behavior is good enough for tasks
-such as data acquisition, logging, and even stateless services like NFS.
-
- </body></html>
-
Index: manual/gawkinet/html_node/GETURL.html
===================================================================
RCS file: manual/gawkinet/html_node/GETURL.html
diff -N manual/gawkinet/html_node/GETURL.html
--- manual/gawkinet/html_node/GETURL.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-<html lang="en">
-<head>
-<title>GETURL - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="PANIC.html#PANIC" title="PANIC">
-<link rel="next" href="REMCONF.html#REMCONF" title="REMCONF">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="GETURL"></a>Next: <a rel="next" accesskey="n"
href="REMCONF.html#REMCONF">REMCONF</a>,
-Previous: <a rel="previous" accesskey="p"
href="PANIC.html#PANIC">PANIC</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.2 GETURL: Retrieving Web Pages</h3>
-
-<p><a name="index-GETURL-program-128"></a><a
name="index-web-pages_002c-retrieving-129"></a>GETURL is a versatile building
block for shell scripts that need to retrieve
-files from the Internet. It takes a web address as a command-line parameter and
-tries to retrieve the contents of this address. The contents are printed
-to standard output, while the header is printed to <samp><span
class="file">/dev/stderr</span></samp>.
-A surrounding shell script
-could analyze the contents and extract the text or the links. An ASCII
-browser could be written around GETURL. But more interestingly, web robots are
-straightforward to write on top of GETURL. On the Internet, you can find
-several programs of the same name that do the same job. They are usually
-much more complex internally and at least 10 times longer.
-
- <p>At first, GETURL checks if it was called with exactly one web address.
-Then, it checks if the user chose to use a special proxy server whose name
-is handed over in a variable. By default, it is assumed that the local
-machine serves as proxy. GETURL uses the <code>GET</code> method by default
-to access the web page. By handing over the name of a different method
-(such as <code>HEAD</code>), it is possible to choose a different behavior.
With
-the <code>HEAD</code> method, the user does not receive the body of the page
-content, but does receive the header:
-
-<pre class="example"> <!-- file eg/network/geturl.awk -->
- BEGIN {
- if (ARGC != 2) {
- print "GETURL - retrieve Web page via HTTP 1.0"
- print "IN:\n the URL as a command-line parameter"
- print "PARAM(S):\n -v Proxy=MyProxy"
- print "OUT:\n the page content on stdout"
- print " the page header on stderr"
- print "JK 16.05.1997"
- print "ADR 13.08.2000"
- exit
- }
- URL = ARGV[1]; ARGV[1] = ""
- if (Proxy == "") Proxy = "127.0.0.1"
- if (ProxyPort == 0) ProxyPort = 80
- if (Method == "") Method = "GET"
- HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort
- ORS = RS = "\r\n\r\n"
- print Method " " URL " HTTP/1.0" |& HttpService
- HttpService |& getline Header
- print Header > "/dev/stderr"
- while ((HttpService |& getline) > 0)
- printf "%s", $0
- close(HttpService)
- }
- <!-- endfile -->
-</pre>
- <p>This program can be changed as needed, but be careful with the last
lines.
-Make sure transmission of binary data is not corrupted by additional line
-breaks. Even as it is now, the byte sequence <code>"\r\n\r\n"</code> would
-disappear if it were contained in binary data. Don't get caught in a
-trap when trying a quick fix on this one.
-
- </body></html>
-
Index: manual/gawkinet/html_node/GNU-Free-Documentation-License.html
===================================================================
RCS file: manual/gawkinet/html_node/GNU-Free-Documentation-License.html
diff -N manual/gawkinet/html_node/GNU-Free-Documentation-License.html
--- manual/gawkinet/html_node/GNU-Free-Documentation-License.html 29 Jun
2005 21:04:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,467 +0,0 @@
-<html lang="en">
-<head>
-<title>GNU Free Documentation License - TCP/IP Internetworking With
`gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Links.html#Links" title="Links">
-<link rel="next" href="Index.html#Index" title="Index">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="GNU-Free-Documentation-License"></a>Next: <a rel="next"
accesskey="n" href="Index.html#Index">Index</a>,
-Previous: <a rel="previous" accesskey="p"
href="Links.html#Links">Links</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">GNU Free Documentation License</h2>
-
-<p><a name="index-FDL-_0028Free-Documentation-License_0029-171"></a><a
name="index-Free-Documentation-License-_0028FDL_0029-172"></a><a
name="index-GNU-Free-Documentation-License-173"></a><div align="center">Version
1.2, November 2002</div>
-
-<pre class="display"> Copyright © 2000,2001,2002 Free Software
Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-</pre>
- <ol type=1 start=0>
-<li>PREAMBLE
-
- <p>The purpose of this License is to make a manual, textbook, or other
-functional and useful document <dfn>free</dfn> in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
- <p>This License is a kind of “copyleft”, which means that
derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
- <p>We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
- <li>APPLICABILITY AND DEFINITIONS
-
- <p>This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The “Document”, below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as “you”. You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
- <p>A “Modified Version” of the Document means any work
containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
- <p>A “Secondary Section” is a named appendix or a
front-matter section
-of the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
- <p>The “Invariant Sections” are certain Secondary Sections
whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
- <p>The “Cover Texts” are certain short passages of text that
are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
- <p>A “Transparent” copy of the Document means a
machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not “Transparent” is called
“Opaque”.
-
- <p>Examples of suitable formats for Transparent copies include plain
-<span class="sc">ascii</span> without markup, Texinfo input format, LaTeX input
-format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly
available
-<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> designed for human modification. Examples
-of transparent image formats include <acronym>PNG</acronym>,
<acronym>XCF</acronym> and
-<acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
-read and edited only by proprietary word processors, <acronym>SGML</acronym> or
-<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing
tools are
-not generally available, and the machine-generated <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> produced by some word processors for
-output purposes only.
-
- <p>The “Title Page” means, for a printed book, the title page
itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, “Title Page”
means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
- <p>A section “Entitled XYZ” means a named subunit of the
Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as “Acknowledgements”,
-“Dedications”, “Endorsements”, or
“History”.) To “Preserve the Title”
-of such a section when you modify the Document means that it remains a
-section “Entitled XYZ” according to this definition.
-
- <p>The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
- <li>VERBATIM COPYING
-
- <p>You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no other
-conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
- <p>You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
- <li>COPYING IN QUANTITY
-
- <p>If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
- <p>If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
- <p>If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
- <p>It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to give
-them a chance to provide you with an updated version of the Document.
-
- <li>MODIFICATIONS
-
- <p>You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
- <ol type=A start=1>
-<li>Use in the Title Page (and on the covers, if any) a title distinct
-from that of the Document, and from those of previous versions
-(which should, if there were any, be listed in the History section
-of the Document). You may use the same title as a previous version
-if the original publisher of that version gives permission.
-
- <li>List on the Title Page, as authors, one or more persons or
entities
-responsible for authorship of the modifications in the Modified
-Version, together with at least five of the principal authors of the
-Document (all of its principal authors, if it has fewer than five),
-unless they release you from this requirement.
-
- <li>State on the Title page the name of the publisher of the
-Modified Version, as the publisher.
-
- <li>Preserve all the copyright notices of the Document.
-
- <li>Add an appropriate copyright notice for your modifications
-adjacent to the other copyright notices.
-
- <li>Include, immediately after the copyright notices, a license
notice
-giving the public permission to use the Modified Version under the
-terms of this License, in the form shown in the Addendum below.
-
- <li>Preserve in that license notice the full lists of Invariant
Sections
-and required Cover Texts given in the Document's license notice.
-
- <li>Include an unaltered copy of this License.
-
- <li>Preserve the section Entitled “History”, Preserve
its Title, and add
-to it an item stating at least the title, year, new authors, and
-publisher of the Modified Version as given on the Title Page. If
-there is no section Entitled “History” in the Document, create one
-stating the title, year, authors, and publisher of the Document as
-given on its Title Page, then add an item describing the Modified
-Version as stated in the previous sentence.
-
- <li>Preserve the network location, if any, given in the Document for
-public access to a Transparent copy of the Document, and likewise
-the network locations given in the Document for previous versions
-it was based on. These may be placed in the “History” section.
-You may omit a network location for a work that was published at
-least four years before the Document itself, or if the original
-publisher of the version it refers to gives permission.
-
- <li>For any section Entitled “Acknowledgements” or
“Dedications”, Preserve
-the Title of the section, and preserve in the section all the
-substance and tone of each of the contributor acknowledgements and/or
-dedications given therein.
-
- <li>Preserve all the Invariant Sections of the Document,
-unaltered in their text and in their titles. Section numbers
-or the equivalent are not considered part of the section titles.
-
- <li>Delete any section Entitled “Endorsements”. Such a
section
-may not be included in the Modified Version.
-
- <li>Do not retitle any existing section to be Entitled
“Endorsements” or
-to conflict in title with any Invariant Section.
-
- <li>Preserve any Warranty Disclaimers.
- </ol>
-
- <p>If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
- <p>You may add a section Entitled “Endorsements”, provided it
contains
-nothing but endorsements of your Modified Version by various
-parties—for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
- <p>You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
- <p>The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
- <li>COMBINING DOCUMENTS
-
- <p>You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
- <p>The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
- <p>In the combination, you must combine any sections Entitled
“History”
-in the various original documents, forming one section Entitled
-“History”; likewise combine any sections Entitled
“Acknowledgements”,
-and any sections Entitled “Dedications”. You must delete all
-sections Entitled “Endorsements.”
-
- <li>COLLECTIONS OF DOCUMENTS
-
- <p>You may make a collection consisting of the Document and other
documents
-released under this License, and replace the individual copies of this
-License in the various documents with a single copy that is included in
-the collection, provided that you follow the rules of this License for
-verbatim copying of each of the documents in all other respects.
-
- <p>You may extract a single document from such a collection, and
distribute
-it individually under this License, provided you insert a copy of this
-License into the extracted document, and follow this License in all
-other respects regarding verbatim copying of that document.
-
- <li>AGGREGATION WITH INDEPENDENT WORKS
-
- <p>A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an “aggregate” if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
- <p>If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
- <li>TRANSLATION
-
- <p>Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warrany Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
- <p>If a section in the Document is Entitled
“Acknowledgements”,
-“Dedications”, or “History”, the requirement (section
4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
- <li>TERMINATION
-
- <p>You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License. Any other attempt to
-copy, modify, sublicense or distribute the Document is void, and will
-automatically terminate your rights under this License. However,
-parties who have received copies, or rights, from you under this
-License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- <li>FUTURE REVISIONS OF THIS LICENSE
-
- <p>The Free Software Foundation may publish new, revised versions
-of the GNU Free Documentation License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns. See
-<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
-
- <p>Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License “or any later version” applies to it, you have the option
of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation.
- </ol>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">ADDENDUM: How to use this License for your
documents</h3>
-
-<p>To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
-<pre class="smallexample"> Copyright (C) <var>year</var> <var>your
name</var>.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
- A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-</pre>
- <p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the “with...Texts.” line with this:
-
-<pre class="smallexample"> with the Invariant Sections being <var>list
their titles</var>, with
- the Front-Cover Texts being <var>list</var>, and with the Back-Cover
Texts
- being <var>list</var>.
-</pre>
- <p>If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
- <p>If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
-
-<!-- Local Variables: -->
-<!-- ispell-local-pdict: "ispell-dict" -->
-<!-- End: -->
-</body></html>
-
Index: manual/gawkinet/html_node/Gawk-Special-Files.html
===================================================================
RCS file: manual/gawkinet/html_node/Gawk-Special-Files.html
diff -N manual/gawkinet/html_node/Gawk-Special-Files.html
--- manual/gawkinet/html_node/Gawk-Special-Files.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,104 +0,0 @@
-<html lang="en">
-<head>
-<title>Gawk Special Files - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="next" href="TCP-Connecting.html#TCP-Connecting" title="TCP
Connecting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Gawk-Special-Files"></a>Next: <a rel="next" accesskey="n"
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a>,
-Previous: <a rel="previous" accesskey="p"
href="Using-Networking.html#Using-Networking">Using Networking</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h3 class="section">2.1 <samp><span class="command">gawk</span></samp>'s
Networking Mechanisms</h3>
-
-<p>The `<samp><span class="samp">|&</span></samp>' operator introduced in
<samp><span class="command">gawk</span></samp> 3.1 for use in
-communicating with a <dfn>coprocess</dfn> is described in
-<a href="../gawk/Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way
Communications With Another Process (GAWK: Effective AWK Programming)</a>.
-It shows how to do two-way I/O to a
-separate process, sending it data with <code>print</code> or
<code>printf</code> and
-reading data with <code>getline</code>. If you haven't read it already, you
should
-detour there to do so.
-
- <p><samp><span class="command">gawk</span></samp> transparently extends the
two-way I/O mechanism to simple networking through
-the use of special file names. When a “coprocess” that matches
-the special files we are about to describe
-is started, <samp><span class="command">gawk</span></samp> creates the
appropriate network
-connection, and then two-way I/O proceeds as usual.
-
-<!-- last comma is part of see-also -->
-<p><a
name="index-input_002foutput_002c-two_002dway_002c-See-Also-_0040command_007bgawk_007d_002c-networking-18"></a><a
name="index-TCP_002fIP_002c-sockets-and-19"></a>At the C, C++, and Perl level,
networking is accomplished
-via <dfn>sockets</dfn>, an Application Programming Interface (API) originally
-developed at the University of California at Berkeley that is now used
-almost universally for TCP/IP networking.
-Socket level programming, while fairly straightforward, requires paying
-attention to a number of details, as well as using binary data. It is not
-well-suited for use from a high-level language like <samp><span
class="command">awk</span></samp>.
-The special files provided in <samp><span class="command">gawk</span></samp>
hide the details from
-the programmer, making things much simpler and easier to use.
-<!-- Who sez we can't toot our own horn occasionally? -->
-
-<!-- STARTOFRANGE filenet -->
-<p><a name="index-filenames_002c-for-network-access-20"></a><!-- STARTOFRANGE
gawnetf -->
-<a
name="index-_0040command_007bgawk_007d_002c-networking_002c-filenames-21"></a><!--
STARTOFRANGE netgawf -->
-<a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-filenames-22"></a>The
special file name for network access is made up of several fields, all
-of which are mandatory:
-
-<pre class="example">
/inet/<var>protocol</var>/<var>localport</var>/<var>hostname</var>/<var>remoteport</var>
-</pre>
- <p><a
name="index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-23"></a><a
name="index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-24"></a><a
name="index-localport-field-25"></a><a
name="index-remoteport-field-26"></a>The <samp><span
class="file">/inet/</span></samp> field is, of course, constant when accessing
the network.
-The <var>localport</var> and <var>remoteport</var> fields do not have a meaning
-when used with <samp><span class="file">/inet/raw</span></samp> because
“ports” only apply to
-TCP and UDP. So, when using <samp><span class="file">/inet/raw</span></samp>,
the port fields always have
-to be `<samp><span class="samp">0</span></samp>'.
-
-<ul class="menu">
-<li><a accesskey="1"
href="Special-File-Fields.html#Special-File-Fields">Special File Fields</a>:
The fields in the special file name.
-<li><a accesskey="2"
href="Comparing-Protocols.html#Comparing-Protocols">Comparing Protocols</a>:
Differences between the protocols.
-</ul>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Index.html
===================================================================
RCS file: manual/gawkinet/html_node/Index.html
diff -N manual/gawkinet/html_node/Index.html
--- manual/gawkinet/html_node/Index.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,227 +0,0 @@
-<html lang="en">
-<head>
-<title>Index - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License"
title="GNU Free Documentation License">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Index"></a>Previous: <a rel="previous" accesskey="p"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h2 class="unnumbered">Index</h2>
-
-<ul class="index-cp" compact>
-<li><a
href="Gawk-Special-Files.html#index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-23"><code>/inet/</code>
files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="File-_002finet_002fraw.html#index-_0040code_007b_002finet_002fraw_007d-special-files-_0028_0040command_007bgawk_007d_0029-41"><code>/inet/raw</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="File-_002finet_002fraw.html#File-_002finet_002fraw">File
/inet/raw</a></li>
-<li><a
href="File-_002finet_002ftcp.html#index-_0040code_007b_002finet_002ftcp_007d-special-files-_0028_0040command_007bgawk_007d_0029-34"><code>/inet/tcp</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">File
/inet/tcp</a></li>
-<li><a
href="File-_002finet_002fudp.html#index-_0040code_007b_002finet_002fudp_007d-special-files-_0028_0040command_007bgawk_007d_0029-37"><code>/inet/udp</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="File-_002finet_002fudp.html#File-_002finet_002fudp">File
/inet/udp</a></li>
-<li><a
href="Troubleshooting.html#index-advanced-features_002c-network-connections-53">advanced
features, network connections</a>: <a
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a></li>
-<li><a href="MOBAGWHO.html#index-agent-154">agent</a>: <a
href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="Challenges.html#index-agent-122">agent</a>: <a
href="Challenges.html#Challenges">Challenges</a></li>
-<li><a href="Challenges.html#index-AI-119">AI</a>: <a
href="Challenges.html#Challenges">Challenges</a></li>
-<li><a href="MOBAGWHO.html#index-apache-157">apache</a>: <a
href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="WEBGRAB.html#index-apache-139">apache</a>: <a
href="WEBGRAB.html#WEBGRAB">WEBGRAB</a></li>
-<li><a href="PROTBASE.html#index-Bioinformatics-170">Bioinformatics</a>: <a
href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a
href="PROTBASE.html#index-BLAST_002c-Basic-Local-Alignment-Search-Tool-166">BLAST,
Basic Local Alignment Search Tool</a>: <a
href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a href="Making-Connections.html#index-blocking-6">blocking</a>: <a
href="Making-Connections.html#Making-Connections">Making Connections</a></li>
-<li><a href="STATIST.html#index-Boutell_002c-Thomas-146">Boutell, Thomas</a>:
<a href="STATIST.html#STATIST">STATIST</a></li>
-<li><a
href="MOBAGWHO.html#index-CGI-_0028Common-Gateway-Interface_0029-156">CGI
(Common Gateway Interface)</a>: <a
href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a></li>
-<li><a
href="Web-page.html#index-CGI-_0028Common-Gateway-Interface_0029_002c-dynamic-web-pages-and-90">CGI
(Common Gateway Interface), dynamic web pages and</a>: <a
href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="CGI-Lib.html#index-CGI-_0028Common-Gateway-Interface_0029_002c-library-105">CGI
(Common Gateway Interface), library</a>: <a href="CGI-Lib.html#CGI-Lib">CGI
Lib</a></li>
-<li><a href="Making-Connections.html#index-clients-5">clients</a>: <a
href="Making-Connections.html#Making-Connections">Making Connections</a></li>
-<li><a href="Challenges.html#index-Clinton_002c-Bill-118">Clinton, Bill</a>:
<a href="Challenges.html#Challenges">Challenges</a></li>
-<li><a
href="Web-page.html#index-Common-Gateway-Interface_002c-See-CGI-91">Common
Gateway Interface, See CGI</a>: <a href="Web-page.html#Web-page">Web
page</a></li>
-<li><a href="PROTBASE.html#index-Computational-Biology-169">Computational
Biology</a>: <a href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a href="Challenges.html#index-contest-117">contest</a>: <a
href="Challenges.html#Challenges">Challenges</a></li>
-<li><a
href="STOXPRED.html#index-_0040command_007bcron_007d-utility-161"><samp><span
class="command">cron</span></samp> utility</a>: <a
href="STOXPRED.html#STOXPRED">STOXPRED</a></li>
-<li><a href="STOXPRED.html#index-CSV-format-163">CSV format</a>: <a
href="STOXPRED.html#STOXPRED">STOXPRED</a></li>
-<li><a
href="File-_002finet_002fraw.html#index-dark-corner_002c-RAW-protocol-44">dark
corner, RAW protocol</a>: <a
href="File-_002finet_002fraw.html#File-_002finet_002fraw">File
/inet/raw</a></li>
-<li><a href="STOXPRED.html#index-Dow-Jones-Industrial-Index-162">Dow Jones
Industrial Index</a>: <a href="STOXPRED.html#STOXPRED">STOXPRED</a></li>
-<li><a href="Simple-Server.html#index-ELIZA-program-108">ELIZA program</a>: <a
href="Simple-Server.html#Simple-Server">Simple Server</a></li>
-<li><a href="Email.html#index-email-76">email</a>: <a
href="Email.html#Email">Email</a></li>
-<li><a href="PROTBASE.html#index-FASTA_002fPearson-format-168">FASTA/Pearson
format</a>: <a href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a
href="GNU-Free-Documentation-License.html#index-FDL-_0028Free-Documentation-License_0029-171">FDL
(Free Documentation License)</a>: <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a
href="Gawk-Special-Files.html#index-filenames_002c-for-network-access-20">filenames,
for network access</a>: <a
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="Gawk-Special-Files.html#index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-24">files,
<code>/inet/</code> (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="File-_002finet_002fraw.html#index-files_002c-_0040code_007b_002finet_002fraw_007d-_0028_0040command_007bgawk_007d_0029-42">files,
<code>/inet/raw</code> (<samp><span class="command">gawk</span></samp>)</a>:
<a href="File-_002finet_002fraw.html#File-_002finet_002fraw">File
/inet/raw</a></li>
-<li><a
href="File-_002finet_002ftcp.html#index-files_002c-_0040code_007b_002finet_002ftcp_007d-_0028_0040command_007bgawk_007d_0029-35">files,
<code>/inet/tcp</code> (<samp><span class="command">gawk</span></samp>)</a>:
<a href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">File
/inet/tcp</a></li>
-<li><a
href="File-_002finet_002fudp.html#index-files_002c-_0040code_007b_002finet_002fudp_007d-_0028_0040command_007bgawk_007d_0029-38">files,
<code>/inet/udp</code> (<samp><span class="command">gawk</span></samp>)</a>:
<a href="File-_002finet_002fudp.html#File-_002finet_002fudp">File
/inet/udp</a></li>
-<li><a
href="Setting-Up.html#index-_0040command_007bfinger_007d-utility-65"><samp><span
class="command">finger</span></samp> utility</a>: <a
href="Setting-Up.html#Setting-Up">Setting Up</a></li>
-<li><a
href="GNU-Free-Documentation-License.html#index-Free-Documentation-License-_0028FDL_0029-172">Free
Documentation License (FDL)</a>: <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a
href="Basic-Protocols.html#index-FTP-_0028File-Transfer-Protocol_0029-2">FTP
(File Transfer Protocol)</a>: <a
href="Basic-Protocols.html#Basic-Protocols">Basic Protocols</a></li>
-<li><a
href="Using-Networking.html#index-_0040command_007bgawk_007d_002c-networking-9"><samp><span
class="command">gawk</span></samp>, networking</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="TCP-Connecting.html#index-_0040command_007bgawk_007d_002c-networking_002c-connections-48"><samp><span
class="command">gawk</span></samp>, networking, connections</a>: <a
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a></li>
-<li><a
href="Special-File-Fields.html#index-_0040command_007bgawk_007d_002c-networking_002c-connections-33"><samp><span
class="command">gawk</span></samp>, networking, connections</a>: <a
href="Special-File-Fields.html#Special-File-Fields">Special File Fields</a></li>
-<li><a
href="Gawk-Special-Files.html#index-_0040command_007bgawk_007d_002c-networking_002c-filenames-21"><samp><span
class="command">gawk</span></samp>, networking, filenames</a>: <a
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="Email.html#index-_0040command_007bgawk_007d_002c-networking_002c-See-Also-email-70"><samp><span
class="command">gawk</span></samp>, networking, See Also email</a>: <a
href="Email.html#Email">Email</a></li>
-<li><a
href="Setting-Up.html#index-_0040command_007bgawk_007d_002c-networking_002c-service_002c-establishing-64"><samp><span
class="command">gawk</span></samp>, networking, service, establishing</a>: <a
href="Setting-Up.html#Setting-Up">Setting Up</a></li>
-<li><a
href="Caveats.html#index-_0040command_007bgawk_007d_002c-networking_002c-troubleshooting-113"><samp><span
class="command">gawk</span></samp>, networking, troubleshooting</a>: <a
href="Caveats.html#Caveats">Caveats</a></li>
-<li><a
href="Interacting-Service.html#index-_0040command_007bgawk_007d_002c-web-and_002c-See-web-service-96"><samp><span
class="command">gawk</span></samp>, web and, See web service</a>: <a
href="Interacting-Service.html#Interacting-Service">Interacting Service</a></li>
-<li><a
href="TCP-Connecting.html#index-_0040code_007bgetline_007d-command-49"><code>getline</code>
command</a>: <a href="TCP-Connecting.html#TCP-Connecting">TCP
Connecting</a></li>
-<li><a href="GETURL.html#index-GETURL-program-128">GETURL program</a>: <a
href="GETURL.html#GETURL">GETURL</a></li>
-<li><a href="STATIST.html#index-GIF-image-format-143">GIF image format</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="Web-page.html#index-GIF-image-format-92">GIF image format</a>: <a
href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="GNU-Free-Documentation-License.html#index-GNU-Free-Documentation-License-173">GNU
Free Documentation License</a>: <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a href="REMCONF.html#index-GNU_002fLinux-132">GNU/Linux</a>: <a
href="REMCONF.html#REMCONF">REMCONF</a></li>
-<li><a href="Interacting.html#index-GNU_002fLinux-59">GNU/Linux</a>: <a
href="Interacting.html#Interacting">Interacting</a></li>
-<li><a href="Troubleshooting.html#index-GNU_002fLinux-56">GNU/Linux</a>: <a
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a></li>
-<li><a href="STATIST.html#index-GNUPlot-utility-141">GNUPlot utility</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="Interacting-Service.html#index-GNUPlot-utility-104">GNUPlot
utility</a>: <a href="Interacting-Service.html#Interacting-Service">Interacting
Service</a></li>
-<li><a href="PROTBASE.html#index-Hoare_002c-C_002eA_002eR_002e-167">Hoare,
C.A.R.</a>: <a href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a href="MOBAGWHO.html#index-Hoare_002c-C_002eA_002eR_002e-155">Hoare,
C.A.R.</a>: <a href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="Special-File-Fields.html#index-hostname-field-30">hostname
field</a>: <a href="Special-File-Fields.html#Special-File-Fields">Special File
Fields</a></li>
-<li><a
href="Web-page.html#index-HTML-_0028Hypertext-Markup-Language_0029-88">HTML
(Hypertext Markup Language)</a>: <a href="Web-page.html#Web-page">Web
page</a></li>
-<li><a
href="Web-page.html#index-HTTP-_0028Hypertext-Transfer-Protocol_0029-82">HTTP
(Hypertext Transfer Protocol)</a>: <a href="Web-page.html#Web-page">Web
page</a></li>
-<li><a
href="Basic-Protocols.html#index-HTTP-_0028Hypertext-Transfer-Protocol_0029-3">HTTP
(Hypertext Transfer Protocol)</a>: <a
href="Basic-Protocols.html#Basic-Protocols">Basic Protocols</a></li>
-<li><a
href="Web-page.html#index-HTTP-_0028Hypertext-Transfer-Protocol_0029_002c-record-separators-and-87">HTTP
(Hypertext Transfer Protocol), record separators and</a>: <a
href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="Interacting-Service.html#index-HTTP-server_002c-core-logic-98">HTTP
server, core logic</a>: <a
href="Interacting-Service.html#Interacting-Service">Interacting Service</a></li>
-<li><a href="Simple-Server.html#index-Humphrys_002c-Mark-110">Humphrys,
Mark</a>: <a href="Simple-Server.html#Simple-Server">Simple Server</a></li>
-<li><a
href="Web-page.html#index-Hypertext-Markup-Language-_0028HTML_0029-89">Hypertext
Markup Language (HTML)</a>: <a href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="Web-page.html#index-Hypertext-Transfer-Protocol_002c-See-HTTP-83">Hypertext
Transfer Protocol, See HTTP</a>: <a href="Web-page.html#Web-page">Web
page</a></li>
-<li><a href="STATIST.html#index-image-format-142">image format</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a
href="Interacting-Service.html#index-images_002c-in-web-pages-102">images, in
web pages</a>: <a
href="Interacting-Service.html#Interacting-Service">Interacting Service</a></li>
-<li><a
href="Web-page.html#index-images_002c-retrieving-over-networks-94">images,
retrieving over networks</a>: <a href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="Gawk-Special-Files.html#index-input_002foutput_002c-two_002dway_002c-See-Also-_0040command_007bgawk_007d_002c-networking-18">input/output,
two-way, See Also <samp><span class="command">gawk</span></samp>,
networking</a>: <a href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk
Special Files</a></li>
-<li><a href="Interacting.html#index-Internet_002c-See-networks-62">Internet,
See networks</a>: <a href="Interacting.html#Interacting">Interacting</a></li>
-<li><a href="STATIST.html#index-JavaScript-148">JavaScript</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="REMCONF.html#index-Linux-131">Linux</a>: <a
href="REMCONF.html#REMCONF">REMCONF</a></li>
-<li><a href="Interacting.html#index-Linux-58">Linux</a>: <a
href="Interacting.html#Interacting">Interacting</a></li>
-<li><a href="Troubleshooting.html#index-Linux-55">Linux</a>: <a
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a></li>
-<li><a href="MOBAGWHO.html#index-Lisp-158">Lisp</a>: <a
href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a></li>
-<li><a href="Gawk-Special-Files.html#index-localport-field-25">localport
field</a>: <a href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special
Files</a></li>
-<li><a href="Challenges.html#index-Loebner_002c-Hugh-116">Loebner, Hugh</a>:
<a href="Challenges.html#Challenges">Challenges</a></li>
-<li><a href="Challenges.html#index-Loui_002c-Ronald-121">Loui, Ronald</a>: <a
href="Challenges.html#Challenges">Challenges</a></li>
-<li><a href="MAZE.html#index-MAZE-150">MAZE</a>: <a
href="MAZE.html#MAZE">MAZE</a></li>
-<li><a href="WEBGRAB.html#index-Microsoft-Windows-138">Microsoft Windows</a>:
<a href="WEBGRAB.html#WEBGRAB">WEBGRAB</a></li>
-<li><a
href="Troubleshooting.html#index-Microsoft-Windows_002c-networking-57">Microsoft
Windows, networking</a>: <a
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a></li>
-<li><a
href="Setting-Up.html#index-Microsoft-Windows_002c-networking_002c-ports-67">Microsoft
Windows, networking, ports</a>: <a href="Setting-Up.html#Setting-Up">Setting
Up</a></li>
-<li><a href="REMCONF.html#index-MiniSQL-134">MiniSQL</a>: <a
href="REMCONF.html#REMCONF">REMCONF</a></li>
-<li><a href="MOBAGWHO.html#index-MOBAGWHO-program-153">MOBAGWHO program</a>:
<a href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a></li>
-<li><a
href="PROTBASE.html#index-NCBI_002c-National-Center-for-Biotechnology-Information-165">NCBI,
National Center for Biotechnology Information</a>: <a
href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a
href="Using-Networking.html#index-networks_002c-_0040command_007bgawk_007d-and-8">networks,
<samp><span class="command">gawk</span></samp> and</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="TCP-Connecting.html#index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-47">networks,
<samp><span class="command">gawk</span></samp> and, connections</a>: <a
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a></li>
-<li><a
href="Special-File-Fields.html#index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-32">networks,
<samp><span class="command">gawk</span></samp> and, connections</a>: <a
href="Special-File-Fields.html#Special-File-Fields">Special File Fields</a></li>
-<li><a
href="Gawk-Special-Files.html#index-networks_002c-_0040command_007bgawk_007d-and_002c-filenames-22">networks,
<samp><span class="command">gawk</span></samp> and, filenames</a>: <a
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a></li>
-<li><a
href="Email.html#index-networks_002c-_0040command_007bgawk_007d-and_002c-See-Also-email-71">networks,
<samp><span class="command">gawk</span></samp> and, See Also email</a>: <a
href="Email.html#Email">Email</a></li>
-<li><a
href="Setting-Up.html#index-networks_002c-_0040command_007bgawk_007d-and_002c-service_002c-establishing-63">networks,
<samp><span class="command">gawk</span></samp> and, service, establishing</a>:
<a href="Setting-Up.html#Setting-Up">Setting Up</a></li>
-<li><a
href="Caveats.html#index-networks_002c-_0040command_007bgawk_007d-and_002c-troubleshooting-112">networks,
<samp><span class="command">gawk</span></samp> and, troubleshooting</a>: <a
href="Caveats.html#Caveats">Caveats</a></li>
-<li><a
href="Setting-Up.html#index-networks_002c-ports_002c-reserved-68">networks,
ports, reserved</a>: <a href="Setting-Up.html#Setting-Up">Setting Up</a></li>
-<li><a
href="Special-File-Fields.html#index-networks_002c-ports_002c-specifying-29">networks,
ports, specifying</a>: <a
href="Special-File-Fields.html#Special-File-Fields">Special File Fields</a></li>
-<li><a href="PANIC.html#index-networks_002c-See-Also-web-pages-126">networks,
See Also web pages</a>: <a href="PANIC.html#PANIC">PANIC</a></li>
-<li><a href="STATIST.html#index-Numerical-Recipes-147">Numerical Recipes</a>:
<a href="STATIST.html#STATIST">STATIST</a></li>
-<li><a
href="Web-page.html#index-_0040code_007bORS_007d-variable_002c-HTTP-and-86"><code>ORS</code>
variable, HTTP and</a>: <a href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="Email.html#index-_0040code_007bORS_007d-variable_002c-POP-and-79"><code>ORS</code>
variable, POP and</a>: <a href="Email.html#Email">Email</a></li>
-<li><a href="PANIC.html#index-PANIC-program-125">PANIC program</a>: <a
href="PANIC.html#PANIC">PANIC</a></li>
-<li><a href="Using-Networking.html#index-Perl-10">Perl</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="Using-Networking.html#index-Perl_002c-_0040command_007bgawk_007d-networking-and-13">Perl,
<samp><span class="command">gawk</span></samp> networking and</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a href="MAZE.html#index-Perlis_002c-Alan-152">Perlis, Alan</a>: <a
href="MAZE.html#MAZE">MAZE</a></li>
-<li><a href="TCP-Connecting.html#index-pipes_002c-networking-and-52">pipes,
networking and</a>: <a href="TCP-Connecting.html#TCP-Connecting">TCP
Connecting</a></li>
-<li><a href="STATIST.html#index-PNG-image-format-144">PNG image format</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="Web-page.html#index-PNG-image-format-93">PNG image format</a>: <a
href="Web-page.html#Web-page">Web page</a></li>
-<li><a href="Email.html#index-POP-_0028Post-Office-Protocol_0029-72">POP (Post
Office Protocol)</a>: <a href="Email.html#Email">Email</a></li>
-<li><a href="Email.html#index-Post-Office-Protocol-_0028POP_0029-74">Post
Office Protocol (POP)</a>: <a href="Email.html#Email">Email</a></li>
-<li><a href="STATIST.html#index-PostScript-149">PostScript</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="Challenges.html#index-PROLOG-120">PROLOG</a>: <a
href="Challenges.html#Challenges">Challenges</a></li>
-<li><a href="PROTBASE.html#index-PROTBASE-164">PROTBASE</a>: <a
href="PROTBASE.html#PROTBASE">PROTBASE</a></li>
-<li><a href="Special-File-Fields.html#index-protocol-field-27">protocol
field</a>: <a href="Special-File-Fields.html#Special-File-Fields">Special File
Fields</a></li>
-<li><a href="STATIST.html#index-PS-image-format-145">PS image format</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="Using-Networking.html#index-Python-11">Python</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="Using-Networking.html#index-Python_002c-_0040command_007bgawk_007d-networking-and-14">Python,
<samp><span class="command">gawk</span></samp> networking and</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a href="File-_002finet_002fraw.html#index-RAW-protocol-43">RAW
protocol</a>: <a href="File-_002finet_002fraw.html#File-_002finet_002fraw">File
/inet/raw</a></li>
-<li><a href="Web-page.html#index-record-separators_002c-HTTP-and-84">record
separators, HTTP and</a>: <a href="Web-page.html#Web-page">Web page</a></li>
-<li><a href="Email.html#index-record-separators_002c-POP-and-77">record
separators, POP and</a>: <a href="Email.html#Email">Email</a></li>
-<li><a href="REMCONF.html#index-REMCONF-program-130">REMCONF program</a>: <a
href="REMCONF.html#REMCONF">REMCONF</a></li>
-<li><a href="Gawk-Special-Files.html#index-remoteport-field-26">remoteport
field</a>: <a href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special
Files</a></li>
-<li><a href="WEBGRAB.html#index-robot-137">robot</a>: <a
href="WEBGRAB.html#WEBGRAB">WEBGRAB</a></li>
-<li><a href="Challenges.html#index-robot-123">robot</a>: <a
href="Challenges.html#Challenges">Challenges</a></li>
-<li><a
href="Web-page.html#index-_0040code_007bRS_007d-variable_002c-HTTP-and-85"><code>RS</code>
variable, HTTP and</a>: <a href="Web-page.html#Web-page">Web page</a></li>
-<li><a
href="Email.html#index-_0040code_007bRS_007d-variable_002c-POP-and-78"><code>RS</code>
variable, POP and</a>: <a href="Email.html#Email">Email</a></li>
-<li><a href="Setting-Up.html#index-servers-66">servers</a>: <a
href="Setting-Up.html#Setting-Up">Setting Up</a></li>
-<li><a href="Making-Connections.html#index-servers-4">servers</a>: <a
href="Making-Connections.html#Making-Connections">Making Connections</a></li>
-<li><a href="Special-File-Fields.html#index-servers_002c-as-hosts-31">servers,
as hosts</a>: <a href="Special-File-Fields.html#Special-File-Fields">Special
File Fields</a></li>
-<li><a href="Interacting-Service.html#index-servers_002c-HTTP-99">servers,
HTTP</a>: <a href="Interacting-Service.html#Interacting-Service">Interacting
Service</a></li>
-<li><a href="Simple-Server.html#index-servers_002c-web-107">servers, web</a>:
<a href="Simple-Server.html#Simple-Server">Simple Server</a></li>
-<li><a
href="Email.html#index-Simple-Mail-Transfer-Protocol-_0028SMTP_0029-75">Simple
Mail Transfer Protocol (SMTP)</a>: <a href="Email.html#Email">Email</a></li>
-<li><a
href="Email.html#index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-73">SMTP
(Simple Mail Transfer Protocol)</a>: <a href="Email.html#Email">Email</a></li>
-<li><a
href="Basic-Protocols.html#index-SMTP-_0028Simple-Mail-Transfer-Protocol_0029-1">SMTP
(Simple Mail Transfer Protocol)</a>: <a
href="Basic-Protocols.html#Basic-Protocols">Basic Protocols</a></li>
-<li><a href="File-_002finet_002fraw.html#index-SPAK-utility-45">SPAK
utility</a>: <a href="File-_002finet_002fraw.html#File-_002finet_002fraw">File
/inet/raw</a></li>
-<li><a href="STATIST.html#index-STATIST-program-140">STATIST program</a>: <a
href="STATIST.html#STATIST">STATIST</a></li>
-<li><a href="STOXPRED.html#index-STOXPRED-program-159">STOXPRED program</a>:
<a href="STOXPRED.html#STOXPRED">STOXPRED</a></li>
-<li><a
href="Making-Connections.html#index-synchronous-communications-7">synchronous
communications</a>: <a href="Making-Connections.html#Making-Connections">Making
Connections</a></li>
-<li><a href="Using-Networking.html#index-Tcl_002fTk-12">Tcl/Tk</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="Some-Applications-and-Techniques.html#index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-124">Tcl/Tk,
<samp><span class="command">gawk</span></samp> and</a>: <a
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a></li>
-<li><a
href="Using-Networking.html#index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-15">Tcl/Tk,
<samp><span class="command">gawk</span></samp> and</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="File-_002finet_002ftcp.html#index-TCP-_0028Transmission-Control-Protocol_0029-36">TCP
(Transmission Control Protocol)</a>: <a
href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">File
/inet/tcp</a></li>
-<li><a
href="Using-Networking.html#index-TCP-_0028Transmission-Control-Protocol_0029-17">TCP
(Transmission Control Protocol)</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="TCP-Connecting.html#index-TCP-_0028Transmission-Control-Protocol_0029_002c-connection_002c-establishing-46">TCP
(Transmission Control Protocol), connection, establishing</a>: <a
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a></li>
-<li><a
href="Interacting.html#index-TCP-_0028Transmission-Control-Protocol_0029_002c-UDP-and-60">TCP
(Transmission Control Protocol), UDP and</a>: <a
href="Interacting.html#Interacting">Interacting</a></li>
-<li><a
href="Special-File-Fields.html#index-TCP_002fIP_002c-protocols_002c-selecting-28">TCP/IP,
protocols, selecting</a>: <a
href="Special-File-Fields.html#Special-File-Fields">Special File Fields</a></li>
-<li><a
href="Gawk-Special-Files.html#index-TCP_002fIP_002c-sockets-and-19">TCP/IP,
sockets and</a>: <a href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk
Special Files</a></li>
-<li><a
href="Using-Networking.html#index-Transmission-Control-Protocol_002c-See-TCP-16">Transmission
Control Protocol, See TCP</a>: <a
href="Using-Networking.html#Using-Networking">Using Networking</a></li>
-<li><a
href="Caveats.html#index-troubleshooting_002c-_0040command_007bgawk_007d_002c-networks-114">troubleshooting,
<samp><span class="command">gawk</span></samp>, networks</a>: <a
href="Caveats.html#Caveats">Caveats</a></li>
-<li><a
href="Troubleshooting.html#index-troubleshooting_002c-networks_002c-connections-54">troubleshooting,
networks, connections</a>: <a
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a></li>
-<li><a
href="Caveats.html#index-troubleshooting_002c-networks_002c-timeouts-115">troubleshooting,
networks, timeouts</a>: <a href="Caveats.html#Caveats">Caveats</a></li>
-<li><a
href="File-_002finet_002fudp.html#index-UDP-_0028User-Datagram-Protocol_0029-39">UDP
(User Datagram Protocol)</a>: <a
href="File-_002finet_002fudp.html#File-_002finet_002fudp">File
/inet/udp</a></li>
-<li><a
href="Interacting.html#index-UDP-_0028User-Datagram-Protocol_0029_002c-TCP-and-61">UDP
(User Datagram Protocol), TCP and</a>: <a
href="Interacting.html#Interacting">Interacting</a></li>
-<li><a href="Setting-Up.html#index-Unix_002c-network-ports-and-69">Unix,
network ports and</a>: <a href="Setting-Up.html#Setting-Up">Setting Up</a></li>
-<li><a href="URLCHK.html#index-URLCHK-program-135">URLCHK program</a>: <a
href="URLCHK.html#URLCHK">URLCHK</a></li>
-<li><a
href="File-_002finet_002fudp.html#index-User-Datagram-Protocol_002c-See-UDP-40">User
Datagram Protocol, See UDP</a>: <a
href="File-_002finet_002fudp.html#File-_002finet_002fudp">File
/inet/udp</a></li>
-<li><a
href="TCP-Connecting.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-51">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O)</a>: <a
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a></li>
-<li><a href="MAZE.html#index-VRML-151">VRML</a>: <a
href="MAZE.html#MAZE">MAZE</a></li>
-<li><a
href="Interacting-Service.html#index-web-browsers_002c-See-web-service-97">web
browsers, See web service</a>: <a
href="Interacting-Service.html#Interacting-Service">Interacting Service</a></li>
-<li><a href="Web-page.html#index-web-pages-81">web pages</a>: <a
href="Web-page.html#Web-page">Web page</a></li>
-<li><a href="Interacting-Service.html#index-web-pages_002c-images-in-103">web
pages, images in</a>: <a
href="Interacting-Service.html#Interacting-Service">Interacting Service</a></li>
-<li><a href="GETURL.html#index-web-pages_002c-retrieving-129">web pages,
retrieving</a>: <a href="GETURL.html#GETURL">GETURL</a></li>
-<li><a href="Simple-Server.html#index-web-servers-106">web servers</a>: <a
href="Simple-Server.html#Simple-Server">Simple Server</a></li>
-<li><a href="PANIC.html#index-web-service-127">web service</a>: <a
href="PANIC.html#PANIC">PANIC</a></li>
-<li><a href="Primitive-Service.html#index-web-service-95">web service</a>: <a
href="Primitive-Service.html#Primitive-Service">Primitive Service</a></li>
-<li><a href="WEBGRAB.html#index-WEBGRAB-program-136">WEBGRAB program</a>: <a
href="WEBGRAB.html#WEBGRAB">WEBGRAB</a></li>
-<li><a href="Simple-Server.html#index-Weizenbaum_002c-Joseph-109">Weizenbaum,
Joseph</a>: <a href="Simple-Server.html#Simple-Server">Simple Server</a></li>
-<li><a href="Interacting-Service.html#index-XBM-image-format-101">XBM image
format</a>: <a href="Interacting-Service.html#Interacting-Service">Interacting
Service</a></li>
-<li><a href="STOXPRED.html#index-Yahoo_0021-160">Yahoo!</a>: <a
href="STOXPRED.html#STOXPRED">STOXPRED</a></li>
-<li><a href="REMCONF.html#index-Yahoo_0021-133">Yahoo!</a>: <a
href="REMCONF.html#REMCONF">REMCONF</a></li>
-<li><a
href="TCP-Connecting.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-50"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a></li>
- </ul></body></html>
-
Index: manual/gawkinet/html_node/Interacting-Service.html
===================================================================
RCS file: manual/gawkinet/html_node/Interacting-Service.html
diff -N manual/gawkinet/html_node/Interacting-Service.html
--- manual/gawkinet/html_node/Interacting-Service.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,261 +0,0 @@
-<html lang="en">
-<head>
-<title>Interacting Service - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Primitive-Service.html#Primitive-Service"
title="Primitive Service">
-<link rel="next" href="Simple-Server.html#Simple-Server" title="Simple Server">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Interacting-Service"></a>Next: <a rel="next" accesskey="n"
href="Simple-Server.html#Simple-Server">Simple Server</a>,
-Previous: <a rel="previous" accesskey="p"
href="Primitive-Service.html#Primitive-Service">Primitive Service</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.9 A Web Service with Interaction</h3>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-web-and_002c-See-web-service-96"></a><a
name="index-web-browsers_002c-See-web-service-97"></a><!-- comma is part of
primary -->
-<a name="index-HTTP-server_002c-core-logic-98"></a><a
name="index-servers_002c-HTTP-99"></a>
-
-<ul class="menu">
-<li><a accesskey="1" href="CGI-Lib.html#CGI-Lib">CGI Lib</a>:
A simple CGI library.
-</ul>
-
- <p>Setting up a web service that allows user interaction is more difficult
and
-shows us the limits of network access in <samp><span
class="command">gawk</span></samp>. In this section,
-we develop a main program (a <code>BEGIN</code> pattern and its action)
-that will become the core of event-driven execution controlled by a
-graphical user interface (GUI).
-Each HTTP event that the user triggers by some action within the browser
-is received in this central procedure. Parameters and menu choices are
-extracted from this request, and an appropriate measure is taken according to
-the user's choice.
-For example:
-
- <p><a name="index-HTTP-server_002c-core-logic-100"></a>
-<pre class="example"> BEGIN {
- if (MyHost == "") {
- "uname -n" | getline MyHost
- close("uname -n")
- }
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- MyPrefix = "http://" MyHost ":" MyPort
- SetUpServer()
- while ("awk" != "complex") {
- # header lines are terminated this way
- RS = ORS = "\r\n"
- Status = 200 # this means OK
- Reason = "OK"
- Header = TopHeader
- Document = TopDoc
- Footer = TopFooter
- if (GETARG["Method"] == "GET") {
- HandleGET()
- } else if (GETARG["Method"] == "HEAD") {
- # not yet implemented
- } else if (GETARG["Method"] != "") {
- print "bad method", GETARG["Method"]
- }
- Prompt = Header Document Footer
- print "HTTP/1.0", Status, Reason |& HttpService
- print "Connection: Close" |& HttpService
- print "Pragma: no-cache" |& HttpService
- len = length(Prompt) + length(ORS)
- print "Content-length:", len |& HttpService
- print ORS Prompt |& HttpService
- # ignore all the header lines
- while ((HttpService |& getline) > 0)
- ;
- # stop talking to this client
- close(HttpService)
- # wait for new client request
- HttpService |& getline
- # do some logging
- print systime(), strftime(), $0
- # read request parameters
- CGI_setup($1, $2, $3)
- }
- }
-</pre>
- <p>This web server presents menu choices in the form of HTML links.
-Therefore, it has to tell the browser the name of the host it is
-residing on. When starting the server, the user may supply the name
-of the host from the command line with `<samp><span class="samp">gawk -v
MyHost="Rumpelstilzchen"</span></samp>'.
-If the user does not do this, the server looks up the name of the host it is
-running on for later use as a web address in HTML documents. The same
-applies to the port number. These values are inserted later into the
-HTML content of the web pages to refer to the home system.
-
- <p>Each server that is built around this core has to initialize some
-application-dependent variables (such as the default home page) in a procedure
-<code>SetUpServer</code>, which is called immediately before entering the
-infinite loop of the server. For now, we will write an instance that
-initiates a trivial interaction. With this home page, the client user
-can click on two possible choices, and receive the current date either
-in human-readable format or in seconds since 1970:
-
-<pre class="example"> function SetUpServer() {
- TopHeader = "<HTML><HEAD>"
- TopHeader = TopHeader \
- "<title>My name is GAWK, GNU AWK</title></HEAD>"
- TopDoc = "<BODY><h2>\
- Do you prefer your date <A HREF=" MyPrefix \
- "/human>human</A> or \
- <A HREF=" MyPrefix "/POSIX>POSIXed</A>?</h2>" ORS
ORS
- TopFooter = "</BODY></HTML>"
- }
-</pre>
- <p>On the first run through the main loop, the default line terminators are
-set and the default home page is copied to the actual home page. Since this
-is the first run, <code>GETARG["Method"]</code> is not initialized yet, hence
the
-case selection over the method does nothing. Now that the home page is
-initialized, the server can start communicating to a client browser.
-
-<!-- @cindex RFC 2068 -->
-<p>It does so by printing the HTTP header into the network connection
-(`<samp><span class="samp">print ... |& HttpService</span></samp>'). This
command blocks execution of
-the server script until a client connects. If this server
-script is compared with the primitive one we wrote before, you will notice
-two additional lines in the header. The first instructs the browser
-to close the connection after each request. The second tells the
-browser that it should never try to <em>remember</em> earlier requests
-that had identical web addresses (no caching). Otherwise, it could happen
-that the browser retrieves the time of day in the previous example just once,
-and later it takes the web page from the cache, always displaying the same
-time of day although time advances each second.
-
- <p>Having supplied the initial home page to the browser with a valid
document
-stored in the parameter <code>Prompt</code>, it closes the connection and waits
-for the next request. When the request comes, a log line is printed that
-allows us to see which request the server receives. The final step in the
-loop is to call the function <code>CGI_setup</code>, which reads all the lines
-of the request (coming from the browser), processes them, and stores the
-transmitted parameters in the array <code>PARAM</code>. The complete
-text of these application-independent functions can be found in
-<a href="CGI-Lib.html#CGI-Lib">A Simple CGI Library</a>.
-For now, we use a simplified version of <code>CGI_setup</code>:
-
-<pre class="example"> function CGI_setup( method, uri, version, i) {
- delete GETARG; delete MENU; delete PARAM
- GETARG["Method"] = $1
- GETARG["URI"] = $2
- GETARG["Version"] = $3
- i = index($2, "?")
- # is there a "?" indicating a CGI request?
- if (i > 0) {
- split(substr($2, 1, i-1), MENU, "[/:]")
- split(substr($2, i+1), PARAM, "&")
- for (i in PARAM) {
- j = index(PARAM[i], "=")
- GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
- }
- } else { # there is no "?", no need for splitting PARAMs
- split($2, MENU, "[/:]")
- }
- }
-</pre>
- <p>At first, the function clears all variables used for
-global storage of request parameters. The rest of the function serves
-the purpose of filling the global parameters with the extracted new values.
-To accomplish this, the name of the requested resource is split into
-parts and stored for later evaluation. If the request contains a `<samp><span
class="samp">?</span></samp>',
-then the request has CGI variables seamlessly appended to the web address.
-Everything in front of the `<samp><span class="samp">?</span></samp>' is split
up into menu items, and
-everything behind the `<samp><span class="samp">?</span></samp>' is a list of
`<samp><var>variable</var><span class="samp">=</span><var>value</var></samp>'
pairs
-(separated by `<samp><span class="samp">&</span></samp>') that also need
splitting. This way, CGI variables are
-isolated and stored. This procedure lacks recognition of special characters
-that are transmitted in coded form<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>. Here, any
-optional request header and body parts are ignored. We do not need
-header parameters and the request body. However, when refining our approach or
-working with the <code>POST</code> and <code>PUT</code> methods, reading the
header
-and body
-becomes inevitable. Header parameters should then be stored in a global
-array as well as the body.
-
- <p>On each subsequent run through the main loop, one request from a browser
is
-received, evaluated, and answered according to the user's choice. This can be
-done by letting the value of the HTTP method guide the main loop into
-execution of the procedure <code>HandleGET</code>, which evaluates the user's
-choice. In this case, we have only one hierarchical level of menus,
-but in the general case,
-menus are nested.
-The menu choices at each level are
-separated by `<samp><span class="samp">/</span></samp>', just as in file
names. Notice how simple it is to
-construct menus of arbitrary depth:
-
-<pre class="example"> function HandleGET() {
- if ( MENU[2] == "human") {
- Footer = strftime() TopFooter
- } else if (MENU[2] == "POSIX") {
- Footer = systime() TopFooter
- }
- }
-</pre>
- <p>The disadvantage of this approach is that our server is slow and can
-handle only one request at a time. Its main advantage, however, is that
-the server
-consists of just one <samp><span class="command">gawk</span></samp> program.
No need for installing an
-<samp><span class="command">httpd</span></samp>, and no need for static
separate HTML files, CGI scripts, or
-<code>root</code> privileges. This is rapid prototyping.
-This program can be started on the same host that runs your browser.
-Then let your browser point to <a
href="http://localhost:8080">http://localhost:8080</a>.
-
- <p><a name="index-XBM-image-format-101"></a><a
name="index-images_002c-in-web-pages-102"></a><a
name="index-web-pages_002c-images-in-103"></a><a
name="index-GNUPlot-utility-104"></a>It is also possible to include images into
the HTML pages.
-Most browsers support the not very well-known
-<samp><span class="file">.xbm</span></samp> format,
-which may contain only
-monochrome pictures but is an ASCII format. Binary images are possible but
-not so easy to handle. Another way of including images is to generate them
-with a tool such as GNUPlot,
-by calling the tool with the <code>system</code> function or through a pipe.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> As defined in RFC 2068.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Interacting.html
===================================================================
RCS file: manual/gawkinet/html_node/Interacting.html
diff -N manual/gawkinet/html_node/Interacting.html
--- manual/gawkinet/html_node/Interacting.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,115 +0,0 @@
-<html lang="en">
-<head>
-<title>Interacting - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Troubleshooting.html#Troubleshooting"
title="Troubleshooting">
-<link rel="next" href="Setting-Up.html#Setting-Up" title="Setting Up">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Interacting"></a>Next: <a rel="next" accesskey="n"
href="Setting-Up.html#Setting-Up">Setting Up</a>,
-Previous: <a rel="previous" accesskey="p"
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.4 Interacting with a Network Service</h3>
-
-<p>The next program makes use of the possibility to really interact with a
-network service by printing something into the special file. It asks the
-so-called <samp><span class="command">finger</span></samp> service if a user
of the machine is logged in. When
-testing this program, try to change `<samp><span
class="samp">localhost</span></samp>' to
-some other machine name in your local network:
-
-<!-- system if test ! -d eg ; then mkdir eg ; fi -->
-<!-- system if test ! -d eg/network ; then mkdir eg/network ; fi -->
-<pre class="example"> <!-- file eg/network/fingerclient.awk -->
- BEGIN {
- NetService = "/inet/tcp/0/localhost/finger"
- print "<var>name</var>" |& NetService
- while ((NetService |& getline) > 0)
- print $0
- close(NetService)
- }
- <!-- endfile -->
-</pre>
- <p>After telling the service on the machine which user to look for,
-the program repeatedly reads lines that come as a reply. When no more
-lines are coming (because the service has closed the connection), the
-program also closes the connection. Try replacing
<code>"</code><var>name</var><code>"</code> with your
-login name (or the name of someone else logged in). For a list
-of all users currently logged in, replace <var>name</var> with an empty string
-(<code>""</code>).
-
- <p><a name="index-Linux-58"></a><a name="index-GNU_002fLinux-59"></a>The
final <code>close</code> command could be safely deleted from
-the above script, because the operating system closes any open connection
-by default when a script reaches the end of execution. In order to avoid
-portability problems, it is best to always close connections explicitly.
-With the Linux kernel,
-for example, proper closing results in flushing of buffers. Letting
-the close happen by default may result in discarding buffers.
-
- <p>When looking at <samp><span class="file">/etc/services</span></samp> you
may have noticed that the
-`<samp><span class="samp">daytime</span></samp>' service is also available
with `<samp><span class="samp">udp</span></samp>'. In the earlier
-example, change `<samp><span class="samp">tcp</span></samp>' to `<samp><span
class="samp">udp</span></samp>',
-and change `<samp><span class="samp">finger</span></samp>' to `<samp><span
class="samp">daytime</span></samp>'.
-After starting the modified program, you see the expected day and time
message.
-The program then hangs, because it waits for more lines coming from the
-service. However, they never come. This behavior is a consequence of the
-differences between TCP and UDP. When using UDP, neither party is
-automatically informed about the other closing the connection.
-Continuing to experiment this way reveals many other subtle
-differences between TCP and UDP. To avoid such trouble, one should always
-remember the advice Douglas E. Comer and David Stevens give in
-Volume III of their series <cite>Internetworking With TCP</cite>
-(page 14):
-
- <p><a
name="index-TCP-_0028Transmission-Control-Protocol_0029_002c-UDP-and-60"></a><a
name="index-UDP-_0028User-Datagram-Protocol_0029_002c-TCP-and-61"></a><a
name="index-Internet_002c-See-networks-62"></a><blockquote>
-When designing client-server applications, beginners are strongly
-advised to use TCP because it provides reliable, connection-oriented
-communication. Programs only use UDP if the application protocol handles
-reliability, the application requires hardware broadcast or multicast,
-or the application cannot tolerate virtual circuit overhead.
-</blockquote>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Introduction.html
===================================================================
RCS file: manual/gawkinet/html_node/Introduction.html
diff -N manual/gawkinet/html_node/Introduction.html
--- manual/gawkinet/html_node/Introduction.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-<html lang="en">
-<head>
-<title>Introduction - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Preface.html#Preface" title="Preface">
-<link rel="next" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Introduction"></a>Next: <a rel="next" accesskey="n"
href="Using-Networking.html#Using-Networking">Using Networking</a>,
-Previous: <a rel="previous" accesskey="p"
href="Preface.html#Preface">Preface</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">1 Networking Concepts</h2>
-
-<p>This chapter provides a (necessarily) brief intoduction to
-computer networking concepts. For many applications of <samp><span
class="command">gawk</span></samp>
-to TCP/IP networking, we hope that this is enough. For more
-advanced tasks, you will need deeper background, and it may be necessary
-to switch to lower-level programming in C or C++.
-
- <p>There are two real-life models for the way computers send messages
-to each other over a network. While the analogies are not perfect,
-they are close enough to convey the major concepts.
-These two models are the phone system (reliable byte-stream communications),
-and the postal system (best-effort datagrams).
-
-<ul class="menu">
-<li><a accesskey="1"
href="Stream-Communications.html#Stream-Communications">Stream
Communications</a>: Sending data streams.
-<li><a accesskey="2"
href="Datagram-Communications.html#Datagram-Communications">Datagram
Communications</a>: Sending self-contained messages.
-<li><a accesskey="3"
href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>: How these models work in the Internet.
-<li><a accesskey="4" href="Making-Connections.html#Making-Connections">Making
Connections</a>: Making TCP/IP connections.
-</ul>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Links.html
===================================================================
RCS file: manual/gawkinet/html_node/Links.html
diff -N manual/gawkinet/html_node/Links.html
--- manual/gawkinet/html_node/Links.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,141 +0,0 @@
-<html lang="en">
-<head>
-<title>Links - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="next"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License"
title="GNU Free Documentation License">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Links"></a>Next: <a rel="next" accesskey="n"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>,
-Previous: <a rel="previous" accesskey="p"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">4 Related Links</h2>
-
-<p>This section lists the URLs for various items discussed in this chapter.
-They are presented in the order in which they appear.
-
- <dl>
-<dt><cite>Internet Programming with Python</cite><dd><a
href="http://www.fsbassociates.com/books/python.htm">http://www.fsbassociates.com/books/python.htm</a>
-
- <br><dt><cite>Advanced Perl Programming</cite><dd><a
href="http://www.oreilly.com/catalog/advperl">http://www.oreilly.com/catalog/advperl</a>
-
- <br><dt><cite>Web Client Programming with Perl</cite><dd><a
href="http://www.oreilly.com/catalog/webclient">http://www.oreilly.com/catalog/webclient</a>
-
- <br><dt>Richard Stevens's home page and book<dd><a
href="http://www.kohala.com/~rstevens">http://www.kohala.com/~rstevens</a>
-
- <br><dt>The SPAK home page<dd><a
href="http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html">http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html</a>
-
- <br><dt>Volume III of <cite>Internetworking with TCP/IP</cite>, by Comer
and Stevens<dd><a
href="http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html">http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html</a>
-
- <br><dt>XBM Graphics File Format<dd><a
href="http://www.wotsit.org/download.asp?f=xbm">http://www.wotsit.org/download.asp?f=xbm</a>
-
- <br><dt>GNUPlot<dd><a
href="http://www.cs.dartmouth.edu/gnuplot_info.html">http://www.cs.dartmouth.edu/gnuplot_info.html</a>
-
- <br><dt>Mark Humphrys' Eliza page<dd><a
href="http://www.compapp.dcu.ie/~humphrys/eliza.html">http://www.compapp.dcu.ie/~humphrys/eliza.html</a>
-
- <br><dt>Yahoo! Eliza Information<dd><a
href="http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence">http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence</a>
-
- <br><dt>Java versions of Eliza<dd><a
href="http://www.tjhsst.edu/Psych/ch1/eliza.html">http://www.tjhsst.edu/Psych/ch1/eliza.html</a>
-
- <br><dt>Java versions of Eliza with source code<dd><a
href="http://home.adelphia.net/~lifeisgood/eliza/eliza.htm">http://home.adelphia.net/~lifeisgood/eliza/eliza.htm</a>
-
- <br><dt>Eliza Programs with Explanations<dd><a
href="http://chayden.net/chayden/eliza/Eliza.shtml">http://chayden.net/chayden/eliza/Eliza.shtml</a>
-
- <br><dt>Loebner Contest<dd><a
href="http://acm.org/~loebner/loebner-prize.htmlx">http://acm.org/~loebner/loebner-prize.htmlx</a>
-
- <br><dt>Tck/Tk Information<dd><a
href="http://www.scriptics.com/">http://www.scriptics.com/</a>
-
- <br><dt>Intel 80x86 Processors<dd><a
href="http://developer.intel.com/design/platform/embedpc/what_is.htm">http://developer.intel.com/design/platform/embedpc/what_is.htm</a>
-
- <br><dt>AMD Elan Processors<dd><a
href="http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html">http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html</a>
-
- <br><dt>XINU<dd><a
href="http://willow.canberra.edu.au/~chrisc/xinu.html">http://willow.canberra.edu.au/~chrisc/xinu.html</a>
-
- <br><dt>GNU/Linux<dd><a
href="http://uclinux.lineo.com/">http://uclinux.lineo.com/</a>
-
- <br><dt>Embedded PCs<dd><a
href="http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/">http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/</a>
-
- <br><dt>MiniSQL<dd><a
href="http://www.hughes.com.au/library/">http://www.hughes.com.au/library/</a>
-
- <br><dt>Market Share Surveys<dd><a
href="http://www.netcraft.com/survey">http://www.netcraft.com/survey</a>
-
- <br><dt><cite>Numerical Recipes in C: The Art of Scientific
Computing</cite><dd><a href="http://www.nr.com">http://www.nr.com</a>
-
- <br><dt>VRML<dd><a href="http://www.vrml.org">http://www.vrml.org</a>
-
- <br><dt>The VRML FAQ<dd><a
href="http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ">http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ</a>
-
- <br><dt>The UMBC Agent Web<dd><a
href="http://www.cs.umbc.edu/agents">http://www.cs.umbc.edu/agents</a>
-
- <br><dt>Apache Web Server<dd><a
href="http://www.apache.org">http://www.apache.org</a>
-
- <br><dt>National Center for Biotechnology Information (NCBI)<dd><a
href="http://www.ncbi.nlm.nih.gov">http://www.ncbi.nlm.nih.gov</a>
-
- <br><dt>Basic Local Alignment Search Tool (BLAST)<dd><a
href="http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html">http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html</a>
-
- <br><dt>NCBI Home Page<dd><a
href="http://www.ncbi.nlm.nih.gov">http://www.ncbi.nlm.nih.gov</a>
-
- <br><dt>BLAST Pages<dd><a
href="http://www.ncbi.nlm.nih.gov/BLAST">http://www.ncbi.nlm.nih.gov/BLAST</a>
-
- <br><dt>BLAST Demonstration Client<dd><a
href="ftp://ncbi.nlm.nih.gov/blast/blasturl/">ftp://ncbi.nlm.nih.gov/blast/blasturl/</a>
-
- <br><dt>BLAST anonymous FTP location<dd><a
href="ftp://ncbi.nlm.nih.gov/blast/network/netblast/">ftp://ncbi.nlm.nih.gov/blast/network/netblast/</a>
-
- <br><dt>BLAST 2.0 Executables<dd><a
href="ftp://ncbi.nlm.nih.gov/blast/executables/">ftp://ncbi.nlm.nih.gov/blast/executables/</a>
-
- <br><dt>IUB/IUPAC Amino Acid and Nucleic Acid Codes<dd><a
href="http://www.uthscsa.edu/geninfo/blastmail.html#item6">http://www.uthscsa.edu/geninfo/blastmail.html#item6</a>
-
- <br><dt>FASTA/Pearson Format<dd><a
href="http://www.ncbi.nlm.nih.gov/BLAST/fasta.html">http://www.ncbi.nlm.nih.gov/BLAST/fasta.html</a>
-
- <br><dt>Fasta/Pearson Sequence in Java<dd><a
href="http://www.kazusa.or.jp/java/codon_table_java/">http://www.kazusa.or.jp/java/codon_table_java/</a>
-
- <br><dt>Book Review of <cite>Introduction to Computational
Biology</cite><dd><a
href="http://www.acm.org/crossroads/xrds5-1/introcb.html">http://www.acm.org/crossroads/xrds5-1/introcb.html</a>
-
- <br><dt><cite>Developing Bioinformatics Computer Skills</cite><dd><a
href="http://www.oreilly.com/catalog/bioskills/">http://www.oreilly.com/catalog/bioskills/</a>
-
- </dl>
-
- </body></html>
-
Index: manual/gawkinet/html_node/MAZE.html
===================================================================
RCS file: manual/gawkinet/html_node/MAZE.html
diff -N manual/gawkinet/html_node/MAZE.html
--- manual/gawkinet/html_node/MAZE.html 31 Aug 2004 22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,196 +0,0 @@
-<html lang="en">
-<head>
-<title>MAZE - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="STATIST.html#STATIST" title="STATIST">
-<link rel="next" href="MOBAGWHO.html#MOBAGWHO" title="MOBAGWHO">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="MAZE"></a>Next: <a rel="next" accesskey="n"
href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a>,
-Previous: <a rel="previous" accesskey="p"
href="STATIST.html#STATIST">STATIST</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.7 MAZE: Walking Through a Maze In Virtual Reality</h3>
-
-<p><a name="index-MAZE-150"></a><a name="index-VRML-151"></a><!-- VRML in iX
11/96 134. -->
-<blockquote>
-<a name="index-Perlis_002c-Alan-152"></a><i>In the long run, every program
becomes rococo, and then rubble.</i><br>
-Alan Perlis
-</blockquote>
-
- <p>By now, we know how to present arbitrary `<samp><span
class="samp">Content-type</span></samp>'s to a browser.
-In this section, our server will present a 3D world to our browser.
-The 3D world is described in a scene description language (VRML,
-Virtual Reality Modeling Language) that allows us to travel through a
-perspective view of a 2D maze with our browser. Browsers with a
-VRML plugin enable exploration of this technology. We could do
-one of those boring `<samp><span class="samp">Hello world</span></samp>'
examples here, that are usually
-presented when introducing novices to
-VRML. If you have never written
-any VRML code, have a look at
-the VRML FAQ.
-Presenting a static VRML scene is a bit trivial; in order to expose
-<samp><span class="command">gawk</span></samp>'s new capabilities, we will
present a dynamically generated
-VRML scene. The function <code>SetUpServer</code> is very simple because it
-only sets the default HTML page and initializes the random number
-generator. As usual, the surrounding server lets you browse the maze.
-
-<pre class="smallexample"> <!-- file eg/network/maze.awk -->
- function SetUpServer() {
- TopHeader = "<HTML><title>Walk through a maze</title>"
- TopDoc = "\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this
server</A>\
- <LI><A HREF=" MyPrefix "/VRMLtest>Watch a simple VRML
scene</A>\
- </UL>"
- TopFooter = "</HTML>"
- srand()
- }
- <!-- endfile -->
-</pre>
- <p>The function <code>HandleGET</code> is a bit longer because it first
computes
-the maze and afterwards generates the VRML code that is sent across
-the network. As shown in the STATIST example
-(see <a href="STATIST.html#STATIST">STATIST</a>),
-we set the type of the
-content to VRML and then store the VRML representation of the maze as the
-page content. We assume that the maze is stored in a 2D array. Initially,
-the maze consists of walls only. Then, we add an entry and an exit to the
-maze and let the rest of the work be done by the function
<code>MakeMaze</code>.
-Now, only the wall fields are left in the maze. By iterating over the these
-fields, we generate one line of VRML code for each wall field.
-
-<pre class="smallexample"> <!-- file eg/network/maze.awk -->
- function HandleGET() {
- if (MENU[2] == "AboutServer") {
- Document = "If your browser has a VRML 2 plugin,\
- this server shows you a simple VRML scene."
- } else if (MENU[2] == "VRMLtest") {
- XSIZE = YSIZE = 11 # initially, everything is wall
- for (y = 0; y < YSIZE; y++)
- for (x = 0; x < XSIZE; x++)
- Maze[x, y] = "#"
- delete Maze[0, 1] # entry is not wall
- delete Maze[XSIZE-1, YSIZE-2] # exit is not wall
- MakeMaze(1, 1)
- Document = "\
- #VRML V2.0 utf8\n\
- Group {\n\
- children [\n\
- PointLight {\n\
- ambientIntensity 0.2\n\
- color 0.7 0.7 0.7\n\
- location 0.0 8.0 10.0\n\
- }\n\
- DEF B1 Background {\n\
- skyColor [0 0 0, 1.0 1.0 1.0 ]\n\
- skyAngle 1.6\n\
- groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\
- groundAngle [ 1.2 1.57 ]\n\
- }\n\
- DEF Wall Shape {\n\
- geometry Box {size 1 1 1}\n\
- appearance Appearance { material Material { diffuseColor 0 0 1 }
}\n\
- }\n\
- DEF Entry Viewpoint {\n\
- position 0.5 1.0 5.0\n\
- orientation 0.0 0.0 -1.0 0.52\n\
- }\n"
- for (i in Maze) {
- split(i, t, SUBSEP)
- Document = Document " Transform { translation "
- Document = Document t[1] " 0 -" t[2] " children USE Wall }\n"
- }
- Document = Document " ] # end of group for world\n}"
- Reason = "OK" ORS "Content-type: model/vrml"
- Header = Footer = ""
- }
- }
- <!-- endfile -->
-</pre>
- <p>Finally, we have a look at <code>MakeMaze</code>, the function that
generates
-the <code>Maze</code> array. When entered, this function assumes that the array
-has been initialized so that each element represents a wall element and
-the maze is initially full of wall elements. Only the entrance and the exit
-of the maze should have been left free. The parameters of the function tell
-us which element must be marked as not being a wall. After this, we take
-a look at the four neighbouring elements and remember which we have already
-treated. Of all the neighbouring elements, we take one at random and
-walk in that direction. Therefore, the wall element in that direction has
-to be removed and then, we call the function recursively for that element.
-The maze is only completed if we iterate the above procedure for
-<em>all</em> neighbouring elements (in random order) and for our present
-element by recursively calling the function for the present element. This
-last iteration could have been done in a loop,
-but it is done much simpler recursively.
-
- <p>Notice that elements with coordinates that are both odd are assumed to be
-on our way through the maze and the generating process cannot terminate
-as long as there is such an element not being <code>delete</code>d. All other
-elements are potentially part of the wall.
-
-<pre class="smallexample"> <!-- file eg/network/maze.awk -->
- function MakeMaze(x, y) {
- delete Maze[x, y] # here we are, we have no wall here
- p = 0 # count unvisited fields in all directions
- if (x-2 SUBSEP y in Maze) d[p++] = "-x"
- if (x SUBSEP y-2 in Maze) d[p++] = "-y"
- if (x+2 SUBSEP y in Maze) d[p++] = "+x"
- if (x SUBSEP y+2 in Maze) d[p++] = "+y"
- if (p>0) { # if there are univisited fields, go there
- p = int(p*rand()) # choose one unvisited field at random
- if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y)
- } else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2)
- } else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y)
- } else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2)
- } # we are back from recursion
- MakeMaze(x, y); # try again while there are unvisited fields
- }
- }
- <!-- endfile -->
-</pre>
- </body></html>
-
Index: manual/gawkinet/html_node/MOBAGWHO.html
===================================================================
RCS file: manual/gawkinet/html_node/MOBAGWHO.html
diff -N manual/gawkinet/html_node/MOBAGWHO.html
--- manual/gawkinet/html_node/MOBAGWHO.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,366 +0,0 @@
-<html lang="en">
-<head>
-<title>MOBAGWHO - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="MAZE.html#MAZE" title="MAZE">
-<link rel="next" href="STOXPRED.html#STOXPRED" title="STOXPRED">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="MOBAGWHO"></a>Next: <a rel="next" accesskey="n"
href="STOXPRED.html#STOXPRED">STOXPRED</a>,
-Previous: <a rel="previous" accesskey="p" href="MAZE.html#MAZE">MAZE</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.8 MOBAGWHO: a Simple Mobile Agent</h3>
-
-<p><a name="index-MOBAGWHO-program-153"></a><a
name="index-agent-154"></a><blockquote>
-<a name="index-Hoare_002c-C_002eA_002eR_002e-155"></a><i>There are two ways of
constructing a software design: One way is to
-make it so simple that there are obviously no deficiencies, and the
-other way is to make it so complicated that there are no obvious
-deficiencies.</i> <br>
-C. A. R. Hoare
-</blockquote>
-
- <p>A <dfn>mobile agent</dfn> is a program that can be dispatched from a
computer and
-transported to a remote server for execution. This is called
<dfn>migration</dfn>,
-which means that a process on another system is started that is independent
-from its originator. Ideally, it wanders through
-a network while working for its creator or owner. In places like
-the UMBC Agent Web,
-people are quite confident that (mobile) agents are a software engineering
-paradigm that enables us to significantly increase the efficiency
-of our work. Mobile agents could become the mediators between users and
-the networking world. For an unbiased view at this technology,
-see the remarkable paper <cite>Mobile Agents: Are they a good
-idea?</cite>.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p>When trying to migrate a process from one system to another,
-a server process is needed on the receiving side. Depending on the kind
-of server process, several ways of implementation come to mind.
-How the process is implemented depends upon the kind of server process:
-
- <ul>
-<li>HTTP can be used as the protocol for delivery of the migrating
-process. In this case, we use a common web
-server as the receiving server process. A universal CGI script
-mediates between migrating process and web server.
-Each server willing to accept migrating agents makes this universal
-service available. HTTP supplies the <code>POST</code> method to transfer
-some data to a file on the web server. When a CGI script is called
-remotely with the <code>POST</code> method instead of the usual
<code>GET</code> method,
-data is transmitted from the client process to the standard input
-of the server's CGI script. So, to implement a mobile agent,
-we must not only write the agent program to start on the client
-side, but also the CGI script to receive the agent on the server side.
-
- <p><a name="index-CGI-_0028Common-Gateway-Interface_0029-156"></a><a
name="index-apache-157"></a><li>The <code>PUT</code> method can also be used
for migration. HTTP does not
-require a CGI script for migration via <code>PUT</code>. However, with common
web
-servers there is no advantage to this solution, because web servers such as
-Apache
-require explicit activation of a special <code>PUT</code> script.
-
- <li><cite>Agent Tcl</cite> pursues a different course; it relies on a
dedicated server
-process with a dedicated protocol specialized for receiving mobile agents.
-</ul>
-
- <p>Our agent example abuses a common web server as a migration tool. So, it
needs a
-universal CGI script on the receiving side (the web server). The receiving
script is
-activated with a <code>POST</code> request when placed into a location like
-<samp><span class="file">/httpd/cgi-bin/PostAgent.sh</span></samp>. Make sure
that the server system uses a
-version of <samp><span class="command">gawk</span></samp> that supports
network access (Version 3.1 or later;
-verify with `<samp><span class="samp">gawk --version</span></samp>').
-
-<pre class="example"> <!-- file eg/network/PostAgent.sh -->
- #!/bin/sh
- MobAg=/tmp/MobileAgent.$$
- # direct script to mobile agent file
- cat > $MobAg
- # execute agent concurrently
- gawk -f $MobAg $MobAg > /dev/null &
- # HTTP header, terminator and body
- gawk 'BEGIN { print "\r\nAgent started" }'
- rm $MobAg # delete script file of agent
- <!-- endfile -->
-</pre>
- <p>By making its process id (<code>$$</code>) part of the unique file name,
the
-script avoids conflicts between concurrent instances of the script.
-First, all lines
-from standard input (the mobile agent's source code) are copied into
-this unique file. Then, the agent is started as a concurrent process
-and a short message reporting this fact is sent to the submitting client.
-Finally, the script file of the mobile agent is removed because it is
-no longer needed. Although it is a short script, there are several noteworthy
-points:
-
- <dl>
-<dt>Security<dd><em>There is none</em>. In fact, the CGI script should never
-be made available on a server that is part of the Internet because everyone
-would be allowed to execute arbitrary commands with it. This behavior is
-acceptable only when performing rapid prototyping.
-
- <br><dt>Self-Reference<dd>Each migrating instance of an agent is started
-in a way that enables it to read its own source code from standard input
-and use the code for subsequent
-migrations. This is necessary because it needs to treat the agent's code
-as data to transmit. <samp><span class="command">gawk</span></samp> is not the
ideal language for such
-a job. Lisp and Tcl are more suitable because they do not make a distinction
-between program code and data.
-
- <br><dt>Independence<dd>After migration, the agent is not linked to its
-former home in any way. By reporting `<samp><span class="samp">Agent
started</span></samp>', it waves
-“Goodbye” to its origin. The originator may choose to terminate or
not.
-</dl>
-
- <p><a name="index-Lisp-158"></a>The originating agent itself is started
just like any other command-line
-script, and reports the results on standard output. By letting the name
-of the original host migrate with the agent, the agent that migrates
-to a host far away from its origin can report the result back home.
-Having arrived at the end of the journey, the agent establishes
-a connection and reports the results. This is the reason for
-determining the name of the host with `<samp><span class="samp">uname
-n</span></samp>' and storing it
-in <code>MyOrigin</code> for later use. We may also set variables with the
-<samp><span class="option">-v</span></samp> option from the command line. This
interactivity is only
-of importance in the context of starting a mobile agent; therefore this
-<code>BEGIN</code> pattern and its action do not take part in migration:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- BEGIN {
- if (ARGC != 2) {
- print "MOBAG - a simple mobile agent"
- print "CALL:\n gawk -f mobag.awk mobag.awk"
- print "IN:\n the name of this script as a command-line parameter"
- print "PARAM:\n -v MyOrigin=myhost.com"
- print "OUT:\n the result on stdout"
- print "JK 29.03.1998 01.04.1998"
- exit
- }
- if (MyOrigin == "") {
- "uname -n" | getline MyOrigin
- close("uname -n")
- }
- }
- <!-- endfile -->
-</pre>
- <p>Since <samp><span class="command">gawk</span></samp> cannot manipulate
and transmit parts of the program
-directly, the source code is read and stored in strings.
-Therefore, the program scans itself for
-the beginning and the ending of functions.
-Each line in between is appended to the code string until the end of
-the function has been reached. A special case is this part of the program
-itself. It is not a function.
-Placing a similar framework around it causes it to be treated
-like a function. Notice that this mechanism works for all the
-functions of the source code, but it cannot guarantee that the order
-of the functions is preserved during migration:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- #ReadMySelf
- /^function / { FUNC = $2 }
- /^END/ || /^#ReadMySelf/ { FUNC = $1 }
- FUNC != "" { MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 }
- (FUNC != "") && (/^}/ || /^#EndOfMySelf/) \
- { FUNC = "" }
- #EndOfMySelf
- <!-- endfile -->
-</pre>
- <p>The web server code in
-<a href="Interacting-Service.html#Interacting-Service">A Web Service with
Interaction</a>,
-was first developed as a site-independent core. Likewise, the
-<samp><span class="command">gawk</span></samp>-based mobile agent
-starts with an agent-independent core, to which can be appended
-application-dependent functions. What follows is the only
-application-independent function needed for the mobile agent:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- function migrate(Destination, MobCode, Label) {
- MOBVAR["Label"] = Label
- MOBVAR["Destination"] = Destination
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/0/" Destination
- for (i in MOBFUN)
- MobCode = (MobCode "\n" MOBFUN[i])
- MobCode = MobCode "\n\nBEGIN {"
- for (i in MOBVAR)
- MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"")
- MobCode = MobCode "\n}\n"
- print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService
- print "Content-length:", length(MobCode) ORS |& HttpService
- printf "%s", MobCode |& HttpService
- while ((HttpService |& getline) > 0)
- print $0
- close(HttpService)
- }
- <!-- endfile -->
-</pre>
- <p>The <code>migrate</code> function prepares the
-aforementioned strings containing the program code and transmits them to a
-server. A consequence of this modular approach is that the <code>migrate</code>
-function takes some parameters that aren't needed in this application,
-but that will be in future ones. Its mandatory parameter
<code>Destination</code> holds the
-name (or IP address) of the server that the agent wants as a host for its
-code. The optional parameter <code>MobCode</code> may contain some <samp><span
class="command">gawk</span></samp>
-code that is inserted during migration in front of all other code.
-The optional parameter <code>Label</code> may contain
-a string that tells the agent what to do in program execution after
-arrival at its new home site. One of the serious obstacles in implementing
-a framework for mobile agents is that it does not suffice to migrate the
-code. It is also necessary to migrate the state of execution of the agent. In
-contrast to <cite>Agent Tcl</cite>, this program does not try to migrate the
complete set
-of variables. The following conventions are used:
-
- <ul>
-<li>Each variable in an agent program is local to the current host and does
-<em>not</em> migrate.
-
- <li>The array <code>MOBFUN</code> shown above is an exception. It is
handled
-by the function <code>migrate</code> and does migrate with the application.
-
- <li>The other exception is the array <code>MOBVAR</code>. Each variable
that
-takes part in migration has to be an element of this array.
-<code>migrate</code> also takes care of this.
-</ul>
-
- <p>Now it's clear what happens to the <code>Label</code> parameter of the
-function <code>migrate</code>. It is copied into <code>MOBVAR["Label"]</code>
and
-travels alongside the other data. Since travelling takes place via HTTP,
-records must be separated with <code>"\r\n"</code> in <code>RS</code> and
-<code>ORS</code> as usual. The code assembly for migration takes place in
-three steps:
-
- <ul>
-<li>Iterate over <code>MOBFUN</code> to collect all functions verbatim.
-
- <li>Prepare a <code>BEGIN</code> pattern and put assignments to mobile
-variables into the action part.
-
- <li>Transmission itself resembles GETURL: the header with the request
-and the <code>Content-length</code> is followed by the body. In case there is
-any reply over the network, it is read completely and echoed to
-standard output to avoid irritating the server.
-</ul>
-
- <p>The application-independent framework is now almost complete. What
follows
-is the <code>END</code> pattern that is executed when the mobile agent has
-finished reading its own code. First, it checks whether it is already
-running on a remote host or not. In case initialization has not yet taken
-place, it starts <code>MyInit</code>. Otherwise (later, on a remote host), it
-starts <code>MyJob</code>:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- END {
- if (ARGC != 2) exit # stop when called with wrong parameters
- if (MyOrigin != "") # is this the originating host?
- MyInit() # if so, initialize the application
- else # we are on a host with migrated data
- MyJob() # so we do our job
- }
- <!-- endfile -->
-</pre>
- <p>All that's left to extend the framework into a complete application
-is to write two application-specific functions: <code>MyInit</code> and
-<code>MyJob</code>. Keep in mind that the former is executed once on the
-originating host, while the latter is executed after each migration:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- function MyInit() {
- MOBVAR["MyOrigin"] = MyOrigin
- MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80"
- split(MOBVAR["Machines"], Machines) # which host is the first?
- migrate(Machines[1], "", "") # go to the first host
- while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result
- print $0 # print result
- close("/inet/tcp/8080/0/0")
- }
- <!-- endfile -->
-</pre>
- <p>As mentioned earlier, this agent takes the name of its origin
-(<code>MyOrigin</code>) with it. Then, it takes the name of its first
-destination and goes there for further work. Notice that this name has
-the port number of the web server appended to the name of the server,
-because the function <code>migrate</code> needs it this way to create
-the <code>HttpService</code> variable. Finally, it waits for the result to
arrive.
-The <code>MyJob</code> function runs on the remote host:
-
-<pre class="smallexample"> <!-- file eg/network/mobag.awk -->
- function MyJob() {
- # forget this host
- sub(MOBVAR["Destination"], "", MOBVAR["Machines"])
- MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"]
":"
- while (("who" | getline) > 0) # who is logged in?
- MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0
- close("who")
- if (index(MOBVAR["Machines"], "/") > 0) { # any more machines to
visit?
- split(MOBVAR["Machines"], Machines) # which host is next?
- migrate(Machines[1], "", "") # go there
- } else { # no more machines
- gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin
- print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"]
"/8080"
- close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080")
- }
- }
- <!-- endfile -->
-</pre>
- <p>After migrating, the first thing to do in <code>MyJob</code> is to delete
-the name of the current host from the list of hosts to visit. Now, it
-is time to start the real work by appending the host's name to the
-result string, and reading line by line who is logged in on this host.
-A very annoying circumstance is the fact that the elements of
-<code>MOBVAR</code> cannot hold the newline character (<code>"\n"</code>). If
they
-did, migration of this string did not work because the string didn't
-obey the syntax rule for a string in <samp><span
class="command">gawk</span></samp>.
-<code>SUBSEP</code> is used as a temporary replacement.
-If the list of hosts to visit holds
-at least one more entry, the agent migrates to that place to go on
-working there. Otherwise, we replace the <code>SUBSEP</code>s
-with a newline character in the resulting string, and report it to
-the originating host, whose name is stored in <code>MOBVAR["MyOrigin"]</code>.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <a
href="http://www.research.ibm.com/massive/mobag.ps">http://www.research.ibm.com/massive/mobag.ps</a></p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Making-Connections.html
===================================================================
RCS file: manual/gawkinet/html_node/Making-Connections.html
diff -N manual/gawkinet/html_node/Making-Connections.html
--- manual/gawkinet/html_node/Making-Connections.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,115 +0,0 @@
-<html lang="en">
-<head>
-<title>Making Connections - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Introduction.html#Introduction" title="Introduction">
-<link rel="prev" href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols"
title="The TCP/IP Protocols">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Making-Connections"></a>Previous: <a rel="previous"
accesskey="p" href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The
TCP/IP Protocols</a>,
-Up: <a rel="up" accesskey="u"
href="Introduction.html#Introduction">Introduction</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.4 Making TCP/IP Connections (And Some Terminology)</h3>
-
-<p>Two terms come up repeatedly when discussing networking:
-<dfn>client</dfn> and <dfn>server</dfn>. For now, we'll discuss these terms
-at the <dfn>connection level</dfn>, when first establishing connections
-between two processes on different systems over a network.
-(Once the connection is established, the higher level, or
-<dfn>application level</dfn> protocols,
-such as HTTP or FTP, determine who is the client and who is the
-server. Often, it turns out that the client and server are the
-same in both roles.)
-
- <p><a name="index-servers-4"></a>The <dfn>server</dfn> is the system
providing the service, such as the
-web server or email server. It is the <dfn>host</dfn> (system) which
-is <em>connected to</em> in a transaction.
-For this to work though, the server must be expecting connections.
-Much as there has to be someone at the office building to answer
-the phone<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>, the
-server process (usually) has to be started first and be waiting
-for a connection.
-
- <p><a name="index-clients-5"></a>The <dfn>client</dfn> is the system
requesting the service.
-It is the system <em>initiating the connection</em> in a transaction.
-(Just as when you pick up the phone to call an office or store.)
-
- <p>In the TCP/IP framework, each end of a connection is represented by a
pair
-of (<var>address</var>, <var>port</var>) pairs. For the duration of the
connection,
-the ports in use at each end are unique, and cannot be used simultaneously
-by other processes on the same system. (Only after closing a connection
-can a new one be built up on the same port. This is contrary to the usual
-behavior of fully developed web servers which have to avoid situations
-in which they are not reachable. We have to pay this price in order to
-enjoy the benefits of a simple communication paradigm in <samp><span
class="command">gawk</span></samp>.)
-
- <p><a name="index-blocking-6"></a><a
name="index-synchronous-communications-7"></a>Furthermore, once the connection
is established, communications are
-<dfn>synchronous</dfn>.<a rel="footnote" href="#fn-2"
name="fnd-2"><sup>2</sup></a> I.e.,
-each end waits on the other to finish transmitting, before replying. This
-is much like two people in a phone conversation. While both could talk
-simultaneously, doing so usually doesn't work too well.
-
- <p>In the case of TCP, the synchronicity is enforced by the protocol when
-sending data. Data writes <dfn>block</dfn> until the data have been received
on the
-other end. For both TCP and UDP, data reads block until there is incoming
-data waiting to be read. This is summarized in the following table,
-where an “X” indicates that the given action blocks.
-
- <p><table summary=""><tr align="left"><td valign="top">TCP </td><td
valign="top">X </td><td valign="top">X
-<br></td></tr><tr align="left"><td valign="top">UDP </td><td valign="top">X
</td><td valign="top">
-<br></td></tr><tr align="left"><td valign="top">RAW </td><td valign="top">X
</td><td valign="top">
- <br></td></tr></table>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> In the days before voice mail systems!</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> For
the technically savvy, data reads
-block—if there's no incoming data, the program is made to wait until
-there is, instead of receiving a “there's no data” error
return.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/PANIC.html
===================================================================
RCS file: manual/gawkinet/html_node/PANIC.html
diff -N manual/gawkinet/html_node/PANIC.html
--- manual/gawkinet/html_node/PANIC.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>PANIC - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="next" href="GETURL.html#GETURL" title="GETURL">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PANIC"></a>Next: <a rel="next" accesskey="n"
href="GETURL.html#GETURL">GETURL</a>,
-Previous: <a rel="previous" accesskey="p"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.1 PANIC: An Emergency Web Server</h3>
-
-<p><a name="index-PANIC-program-125"></a><a
name="index-networks_002c-See-Also-web-pages-126"></a><a
name="index-web-service-127"></a>At first glance, the <code>"Hello,
world"</code> example in
-<a href="Primitive-Service.html#Primitive-Service">A Primitive Web Service</a>,
-seems useless. By adding just a few lines, we can turn it into something
useful.
-
- <p>The PANIC program tells everyone who connects that the local
-site is not working. When a web server breaks down, it makes a difference
-if customers get a strange “network unreachable” message, or a
short message
-telling them that the server has a problem. In such an emergency,
-the hard disk and everything on it (including the regular web service) may
-be unavailable. Rebooting the web server off a diskette makes sense in this
-setting.
-
- <p>To use the PANIC program as an emergency web server, all you need are the
-<samp><span class="command">gawk</span></samp> executable and the program
below on a diskette. By default,
-it connects to port 8080. A different value may be supplied on the
-command line:
-
-<pre class="example"> <!-- file eg/network/panic.awk -->
- BEGIN {
- RS = ORS = "\r\n"
- if (MyPort == 0) MyPort = 8080
- HttpService = "/inet/tcp/" MyPort "/0/0"
- Hello = "<HTML><HEAD><TITLE>Out Of
Service</TITLE>" \
- "</HEAD><BODY><H1>" \
- "This site is temporarily out of service." \
- "</H1></BODY></HTML>"
- Len = length(Hello) + length(ORS)
- while ("awk" != "complex") {
- print "HTTP/1.0 200 OK" |& HttpService
- print "Content-Length: " Len ORS |& HttpService
- print Hello |& HttpService
- while ((HttpService |& getline) > 0)
- continue;
- close(HttpService)
- }
- }
- <!-- endfile -->
-</pre>
- </body></html>
-
Index: manual/gawkinet/html_node/PROTBASE.html
===================================================================
RCS file: manual/gawkinet/html_node/PROTBASE.html
diff -N manual/gawkinet/html_node/PROTBASE.html
--- manual/gawkinet/html_node/PROTBASE.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,313 +0,0 @@
-<html lang="en">
-<head>
-<title>PROTBASE - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="STOXPRED.html#STOXPRED" title="STOXPRED">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PROTBASE"></a>Previous: <a rel="previous" accesskey="p"
href="STOXPRED.html#STOXPRED">STOXPRED</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.10 PROTBASE: Searching Through A Protein Database</h3>
-
-<p><a name="index-PROTBASE-164"></a><a
name="index-NCBI_002c-National-Center-for-Biotechnology-Information-165"></a><a
name="index-BLAST_002c-Basic-Local-Alignment-Search-Tool-166"></a><a
name="index-Hoare_002c-C_002eA_002eR_002e-167"></a><blockquote>
-<i>Hoare's Law of Large Problems: Inside every large problem is a small
- problem struggling to get out.</i>
-</blockquote>
-
- <p>Yahoo's database of stock market data is just one among the many large
-databases on the Internet. Another one is located at NCBI
-(National Center for Biotechnology
-Information). Established in 1988 as a national resource for molecular
-biology information, NCBI creates public databases, conducts research
-in computational biology, develops software tools for analyzing genome
-data, and disseminates biomedical information. In this section, we
-look at one of NCBI's public services, which is called BLAST
-(Basic Local Alignment Search Tool).
-
- <p>You probably know that the information necessary for reproducing living
-cells is encoded in the genetic material of the cells. The genetic material
-is a very long chain of four base nucleotides. It is the order of
-appearance (the sequence) of nucleotides which contains the information
-about the substance to be produced. Scientists in biotechnology often
-find a specific fragment, determine the nucleotide sequence, and need
-to know where the sequence at hand comes from. This is where the large
-databases enter the game. At NCBI, databases store the knowledge
-about which sequences have ever been found and where they have been found.
-When the scientist sends his sequence to the BLAST service, the server
-looks for regions of genetic material in its database which
-look the most similar to the delivered nucleotide sequence. After a
-search time of some seconds or minutes the server sends an answer to
-the scientist. In order to make access simple, NCBI chose to offer
-their database service through popular Internet protocols. There are
-four basic ways to use the so-called BLAST services:
-
- <ul>
-<li>The easiest way to use BLAST is through the web. Users may simply point
-their browsers at the NCBI home page
-and link to the BLAST pages.
-NCBI provides a stable URL that may be used to perform BLAST searches
-without interactive use of a web browser. This is what we will do later
-in this section.
-A demonstration client
-and a <samp><span class="file">README</span></samp> file demonstrate how to
access this URL.
-
- <li>Currently,
-<samp><span class="command">blastcl3</span></samp> is the standard network
BLAST client.
-You can download <samp><span class="command">blastcl3</span></samp> from the
-anonymous FTP location.
-
- <li>BLAST 2.0 can be run locally as a full executable and can be used to
run
-BLAST searches against private local databases, or downloaded copies of the
-NCBI databases. BLAST 2.0 executables may be found on the NCBI
-anonymous FTP server.
-
- <li>The NCBI BLAST Email server is the best option for people without
convenient
-access to the web. A similarity search can be performed by sending a properly
-formatted mail message containing the nucleotide or protein query sequence to
-<a href="mailto:address@hidden">address@hidden</a>. The query sequence is
compared against the
-specified database using the BLAST algorithm and the results are returned in
-an email message. For more information on formulating email BLAST searches,
-you can send a message consisting of the word “HELP” to the same
address,
-<a href="mailto:address@hidden">address@hidden</a>.
-</ul>
-
- <p>Our starting point is the demonstration client mentioned in the first
option.
-The <samp><span class="file">README</span></samp> file that comes along with
the client explains the whole
-process in a nutshell. In the rest of this section, we first show
-what such requests look like. Then we show how to use <samp><span
class="command">gawk</span></samp> to
-implement a client in about 10 lines of code. Finally, we show how to
-interpret the result returned from the service.
-
- <p>Sequences are expected to be represented in the standard
-IUB/IUPAC amino acid and nucleic acid codes,
-with these exceptions: lower-case letters are accepted and are mapped
-into upper-case; a single hyphen or dash can be used to represent a gap
-of indeterminate length; and in amino acid sequences, `<samp><span
class="samp">U</span></samp>' and `<samp><span class="samp">*</span></samp>'
-are acceptable letters (see below). Before submitting a request, any numerical
-digits in the query sequence should either be removed or replaced by
-appropriate letter codes (e.g., `<samp><span class="samp">N</span></samp>' for
unknown nucleic acid residue
-or `<samp><span class="samp">X</span></samp>' for unknown amino acid residue).
-The nucleic acid codes supported are:
-
-<pre class="example"> A --> adenosine M --> A C (amino)
- C --> cytidine S --> G C (strong)
- G --> guanine W --> A T (weak)
- T --> thymidine B --> G T C
- U --> uridine D --> G A T
- R --> G A (purine) H --> A C T
- Y --> T C (pyrimidine) V --> G C A
- K --> G T (keto) N --> A G C T (any)
- - gap of indeterminate length
-</pre>
- <p>Now you know the alphabet of nucleotide sequences. The last two lines
-of the following example query show you such a sequence, which is obviously
-made up only of elements of the alphabet just described. Store this example
-query into a file named <samp><span
class="file">protbase.request</span></samp>. You are now ready to send
-it to the server with the demonstration client.
-
-<pre class="example"> <!-- file eg/network/protbase.request -->
- PROGRAM blastn
- DATALIB month
- EXPECT 0.75
- BEGIN
- >GAWK310 the gawking gene GNU AWK
- tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat
- caccaccatggacagcaaa
- <!-- endfile -->
-</pre>
- <p><a name="index-FASTA_002fPearson-format-168"></a>The actual search
request begins with the mandatory parameter `<samp><span
class="samp">PROGRAM</span></samp>'
-in the first column followed by the value `<samp><span
class="samp">blastn</span></samp>' (the name of the
-program) for searching nucleic acids. The next line contains the mandatory
-search parameter `<samp><span class="samp">DATALIB</span></samp>' with the
value `<samp><span class="samp">month</span></samp>' for the newest
-nucleic acid sequences. The third line contains an optional `<samp><span
class="samp">EXPECT</span></samp>'
-parameter and the value desired for it. The fourth line contains the
-mandatory `<samp><span class="samp">BEGIN</span></samp>' directive, followed
by the query sequence in
-FASTA/Pearson format.
-Each line of information must be less than 80 characters in length.
-
- <p>The “month” database contains all new or revised sequences
released in the
-last 30 days and is useful for searching against new sequences.
-There are five different blast programs, <samp><span
class="command">blastn</span></samp> being the one that
-compares a nucleotide query sequence against a nucleotide sequence database.
-
- <p>The last server directive that must appear in every request is the
-`<samp><span class="samp">BEGIN</span></samp>' directive. The query sequence
should immediately follow the
-`<samp><span class="samp">BEGIN</span></samp>' directive and must appear in
FASTA/Pearson format.
-A sequence in
-FASTA/Pearson format begins with a single-line description.
-The description line, which is required, is distinguished from the lines of
-sequence data that follow it by having a greater-than (`<samp><span
class="samp">></span></samp>') symbol
-in the first column. For the purposes of the BLAST server, the text of
-the description is arbitrary.
-
- <p>If you prefer to use a client written in <samp><span
class="command">gawk</span></samp>, just store the following
-10 lines of code into a file named <samp><span
class="file">protbase.awk</span></samp> and use this client
-instead. Invoke it with `<samp><span class="samp">gawk -f protbase.awk
protbase.request</span></samp>'.
-Then wait a minute and watch the result coming in. In order to replicate
-the demonstration client's behaviour as closely as possible, this client
-does not use a proxy server. We could also have extended the client program
-in <a href="GETURL.html#GETURL">Retrieving Web Pages</a>, to implement the
client request from
-<samp><span class="file">protbase.awk</span></samp> as a special case.
-
-<pre class="smallexample"> <!-- file eg/network/protbase.awk -->
- { request = request "\n" $0 }
-
- END {
- BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80"
- printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |&
BLASTService
- printf "Content-Length: " length(request) "\n\n" |&
BLASTService
- printf request |&
BLASTService
- while ((BLASTService |& getline) > 0)
- print $0
- close(BLASTService)
- }
- <!-- endfile -->
-</pre>
- <p>The demonstration client from NCBI is 214 lines long (written in C) and
-it is not immediately obvious what it does. Our client is so short that
-it <em>is</em> obvious what it does. First it loops over all lines of the
-query and stores the whole query into a variable. Then the script
-establishes an Internet connection to the NCBI server and transmits the
-query by framing it with a proper HTTP request. Finally it receives
-and prints the complete result coming from the server.
-
- <p>Now, let us look at the result. It begins with an HTTP header, which you
-can ignore. Then there are some comments about the query having been
-filtered to avoid spuriously high scores. After this, there is a reference
-to the paper that describes the software being used for searching the data
-base. After a repitition of the original query's description we find the
-list of significant alignments:
-
-<pre class="smallexample"> <!-- file eg/network/protbase.result -->
- Sequences producing significant alignments: (bits)
Value
-
- gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38
0.20
- gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38
0.20
- emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38
0.20
- emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38
0.20
- emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38
0.20
- emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38
0.20
- gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38
0.20
- <!-- endfile -->
-</pre>
- <p>This means that the query sequence was found in seven human chromosomes.
-But the value 0.20 (20%) means that the probability of an accidental match
-is rather high (20%) in all cases and should be taken into account.
-You may wonder what the first column means. It is a key to the specific
-database in which this occurence was found. The unique sequence identifiers
-reported in the search results can be used as sequence retrieval keys
-via the NCBI server. The syntax of sequence header lines used by the NCBI
-BLAST server depends on the database from which each sequence was obtained.
-The table below lists the identifiers for the databases from which the
-sequences were derived.
-
- <p><table summary=""><tr align="left"><td valign="top">GenBank </td><td
valign="top"><code>gb|accession|locus</code>
-<br></td></tr><tr align="left"><td valign="top">EMBL Data Library </td><td
valign="top"><code>emb|accession|locus</code>
-<br></td></tr><tr align="left"><td valign="top">DDBJ, DNA Database of Japan
</td><td valign="top"><code>dbj|accession|locus</code>
-<br></td></tr><tr align="left"><td valign="top">NBRF PIR </td><td
valign="top"><code>pir||entry</code>
-<br></td></tr><tr align="left"><td valign="top">Protein Research Foundation
</td><td valign="top"><code>prf||name</code>
-<br></td></tr><tr align="left"><td valign="top">SWISS-PROT </td><td
valign="top"><code>sp|accession|entry name<!-- /@w --></code>
-<br></td></tr><tr align="left"><td valign="top">Brookhaven Protein Data Bank
</td><td valign="top"><code>pdb|entry|chain</code>
-<br></td></tr><tr align="left"><td valign="top">Kabat's Sequences of
Immuno<small class="dots">...</small> </td><td
valign="top"><code>gnl|kabat|identifier</code>
-<br></td></tr><tr align="left"><td valign="top">Patents </td><td
valign="top"><code>pat|country|number</code>
-<br></td></tr><tr align="left"><td valign="top">GenInfo Backbone Id </td><td
valign="top"><code>bbs|number</code>
- <br></td></tr></table>
-
- <p>For example, an identifier might be `<samp><span
class="samp">gb|AC021182.14|AC021182</span></samp>', where the
-`<samp><span class="samp">gb</span></samp>' tag indicates that the identifier
refers to a GenBank sequence,
-`<samp><span class="samp">AC021182.14</span></samp>' is its GenBank ACCESSION,
and `<samp><span class="samp">AC021182</span></samp>' is the GenBank LOCUS.
-The identifier contains no spaces, so that a space indicates the end of the
-identifier.
-
- <p>Let us continue in the result listing. Each of the seven alignments
mentioned
-above is subsequently described in detail. We will have a closer look at
-the first of them.
-
-<pre class="smallexample"> >gb|AC021182.14|AC021182 Homo sapiens
chromosome 7 clone RP11-733N23, WORKING DRAFT SEQUENCE, 4
- unordered pieces
- Length = 176383
-
- Score = 38.2 bits (19), Expect = 0.20
- Identities = 19/19 (100%)
- Strand = Plus / Plus
-
- Query: 35 tggtgaagtgtgtttcttg 53
- |||||||||||||||||||
- Sbjct: 69786 tggtgaagtgtgtttcttg 69804
-</pre>
- <p>This alignment was located on the human chromosome 7. The fragment on
which
-part of the query was found had a total length of 176383. Only 19 of the
-nucleotides matched and the matching sequence ran from character 35 to 53
-in the query sequence and from 69786 to 69804 in the fragment on chromosome 7.
-If you are still reading at this point, you are probably interested in finding
-out more about Computational Biology and you might appreciate the following
-hints.
-
- <p><a name="index-Computational-Biology-169"></a><a
name="index-Bioinformatics-170"></a>
- <ol type=1 start=1>
-<li>There is a book called <cite>Introduction to Computational Biology</cite>
-by Michael S. Waterman, which is worth reading if you are seriously
-interested. You can find a good
-book review
-on the Internet.
-
- <li>While Waterman's book can explain to you the algorithms employed
internally
-in the database search engines, most practicioners prefer to approach
-the subject differently. The applied side of Computational Biology is
-called Bioinformatics, and emphasizes the tools available for day-to-day
-work as well as how to actually <em>use</em> them. One of the very few
affordable
-books on Bioinformatics is
-<cite>Developing Bioinformatics Computer Skills</cite>.
-
- <li>The sequences <em>gawk</em> and <em>gnuawk</em> are in widespread use
in
-the genetic material of virtually every earthly living being. Let us
-take this as a clear indication that the divine creator has intended
-<code>gawk</code> to prevail over other scripting languages such as
<code>perl</code>,
-<code>tcl</code>, or <code>python</code> which are not even proper sequences.
(:-)
- </ol>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Ports.html
===================================================================
RCS file: manual/gawkinet/html_node/Ports.html
diff -N manual/gawkinet/html_node/Ports.html
--- manual/gawkinet/html_node/Ports.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,78 +0,0 @@
-<html lang="en">
-<head>
-<title>Ports - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols"
title="The TCP/IP Protocols">
-<link rel="prev" href="Basic-Protocols.html#Basic-Protocols" title="Basic
Protocols">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Ports"></a>Previous: <a rel="previous" accesskey="p"
href="Basic-Protocols.html#Basic-Protocols">Basic Protocols</a>,
-Up: <a rel="up" accesskey="u"
href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The TCP/IP
Protocols</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.3.2 TCP and UDP Ports</h4>
-
-<p>In the postal system, the address on an envelope indicates a physical
-location, such as a residence or office building. But there may be
-more than one person at a location; thus you have to further quantify
-the recipient by putting a person or company name on the envelope.
-
- <p>In the phone system, one phone number may represent an entire company,
-in which case you need a person's extension number in order to
-reach that individual directly. Or, when you call a home, you have to
-say, “May I please speak to ...” before talking to the person
directly.
-
- <p>IP networking provides the concept of addressing. An IP address
represents
-a particular computer, but no more. In order to reach the mail service
-on a system, or the FTP or WWW service on a system, you must have some
-way to further specify which service you want. In the Internet Protocol suite,
-this is done with <dfn>port numbers</dfn>, which represent the services, much
-like an extension number used with a phone number.
-
- <p>Port numbers are 16-bit integers. Unix and Unix-like systems reserve
ports
-below 1024 for “well known” services, such as SMTP, FTP, and HTTP.
-Numbers 1024 and above may be used by any application, although there is no
-promise made that a particular port number is always available.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Preface.html
===================================================================
RCS file: manual/gawkinet/html_node/Preface.html
diff -N manual/gawkinet/html_node/Preface.html
--- manual/gawkinet/html_node/Preface.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-<html lang="en">
-<head>
-<title>Preface - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="index.html#Top" title="Top">
-<link rel="next" href="Introduction.html#Introduction" title="Introduction">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Preface"></a>Next: <a rel="next" accesskey="n"
href="Introduction.html#Introduction">Introduction</a>,
-Previous: <a rel="previous" accesskey="p" href="index.html#Top">Top</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">Preface</h2>
-
-<p>In May of 1997, Jürgen Kahrs felt the need for network access
-from <samp><span class="command">awk</span></samp>, and, with a little help
from me, set about adding
-features to do this for <samp><span class="command">gawk</span></samp>. At
that time, he
-wrote the bulk of this web page.
-
- <p>The code and documentation were added to the <samp><span
class="command">gawk</span></samp> 3.1 development
-tree, and languished somewhat until I could finally get
-down to some serious work on that version of <samp><span
class="command">gawk</span></samp>.
-This finally happened in the middle of 2000.
-
- <p>Meantime, Jürgen wrote an article about the Internet special
-files and `<samp><span class="samp">|&</span></samp>' operator for
<cite>Linux Journal</cite>, and made a
-networking patch for the production versions of <samp><span
class="command">gawk</span></samp>
-available from his home page.
-In August of 2000 (for <samp><span class="command">gawk</span></samp> 3.0.6),
this patch
-also made it to the main GNU <samp><span class="command">ftp</span></samp>
distribution site.
-
- <p>For release with <samp><span class="command">gawk</span></samp>, I
edited Jürgen's prose
-for English grammar and style, as he is not a native English
-speaker. I also
-rearranged the material somewhat for what I felt was a better order of
-presentation, and (re)wrote some of the introductory material.
-
- <p>The majority of this document and the code are his work, and the
-high quality and interesting ideas speak for themselves. It is my
-hope that these features will be of significant value to the <samp><span
class="command">awk</span></samp>
-community.
-
- <pre class="sp">
-
-</pre>
-Arnold Robbins <br>
-Nof Ayalon, ISRAEL <br>
-March, 2001
-
- </body></html>
-
Index: manual/gawkinet/html_node/Primitive-Service.html
===================================================================
RCS file: manual/gawkinet/html_node/Primitive-Service.html
diff -N manual/gawkinet/html_node/Primitive-Service.html
--- manual/gawkinet/html_node/Primitive-Service.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,118 +0,0 @@
-<html lang="en">
-<head>
-<title>Primitive Service - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Web-page.html#Web-page" title="Web page">
-<link rel="next" href="Interacting-Service.html#Interacting-Service"
title="Interacting Service">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Primitive-Service"></a>Next: <a rel="next" accesskey="n"
href="Interacting-Service.html#Interacting-Service">Interacting Service</a>,
-Previous: <a rel="previous" accesskey="p"
href="Web-page.html#Web-page">Web page</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.8 A Primitive Web Service</h3>
-
-<!-- STARTOFRANGE webser -->
-<p><a name="index-web-service-95"></a>Now we know enough about HTTP to set up
a primitive web service that just
-says <code>"Hello, world"</code> when someone connects to it with a browser.
-Compared
-to the situation in the preceding section, our program changes the role. It
-tries to behave just like the server we have observed. Since we are setting
-up a server here, we have to insert the port number in the `<samp><span
class="samp">localport</span></samp>'
-field of the special file name. The other two fields (<var>hostname</var> and
-<var>remoteport</var>) have to contain a `<samp><span
class="samp">0</span></samp>' because we do not know in
-advance which host will connect to our service.
-
- <p>In the early 1990s, all a server had to do was send an HTML document and
-close the connection. Here, we adhere to the modern syntax of HTTP.
-The steps are as follows:
-
- <ol type=1 start=1>
-<li>Send a status line telling the web browser that everything
-is okay.
-
- <li>Send a line to tell the browser how many bytes follow in the
-body of the message. This was not necessary earlier because both
-parties knew that the document ended when the connection closed. Nowadays
-it is possible to stay connected after the transmission of one web page.
-This is to avoid the network traffic necessary for repeatedly establishing
-TCP connections for requesting several images. Thus, there is the need to tell
-the receiving party how many bytes will be sent. The header is terminated
-as usual with an empty line.
-
- <li>Send the <code>"Hello, world"</code> body
-in HTML.
-The useless <code>while</code> loop swallows the request of the browser.
-We could actually omit the loop, and on most machines the program would still
-work.
-First, start the following program:
- </ol>
-
-<pre class="example"> <!-- file eg/network/hello-serv.awk -->
- BEGIN {
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/8080/0/0"
- Hello = "<HTML><HEAD>" \
- "<TITLE>A Famous Greeting</TITLE></HEAD>" \
- "<BODY><H1>Hello,
world</H1></BODY></HTML>"
- Len = length(Hello) + length(ORS)
- print "HTTP/1.0 200 OK" |& HttpService
- print "Content-Length: " Len ORS |& HttpService
- print Hello |& HttpService
- while ((HttpService |& getline) > 0)
- continue;
- close(HttpService)
- }
- <!-- endfile -->
-</pre>
- <p>Now, on the same machine, start your favorite browser and let it point to
-<a href="http://localhost:8080">http://localhost:8080</a> (the browser needs
to know on which port
-our server is listening for requests). If this does not work, the browser
-probably tries to connect to a proxy server that does not know your machine.
-If so, change the browser's configuration so that the browser does not try to
-use a proxy to connect to your machine.
-
- </body></html>
-
Index: manual/gawkinet/html_node/REMCONF.html
===================================================================
RCS file: manual/gawkinet/html_node/REMCONF.html
diff -N manual/gawkinet/html_node/REMCONF.html
--- manual/gawkinet/html_node/REMCONF.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,176 +0,0 @@
-<html lang="en">
-<head>
-<title>REMCONF - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="GETURL.html#GETURL" title="GETURL">
-<link rel="next" href="URLCHK.html#URLCHK" title="URLCHK">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="REMCONF"></a>Next: <a rel="next" accesskey="n"
href="URLCHK.html#URLCHK">URLCHK</a>,
-Previous: <a rel="previous" accesskey="p"
href="GETURL.html#GETURL">GETURL</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.3 REMCONF: Remote Configuration of Embedded Systems</h3>
-
-<p><a name="index-REMCONF-program-130"></a><a name="index-Linux-131"></a><a
name="index-GNU_002fLinux-132"></a><a name="index-Yahoo_0021-133"></a>Today,
you often find powerful processors in embedded systems. Dedicated
-network routers and controllers for all kinds of machinery are examples
-of embedded systems. Processors like the Intel 80x86 or the AMD Elan are
-able to run multitasking operating systems, such as XINU or GNU/Linux
-in embedded PCs. These systems are small and usually do not have
-a keyboard or a display. Therefore it is difficult to set up their
-configuration. There are several widespread ways to set them up:
-
- <ul>
-<li>DIP switches
-
- <li>Read Only Memories such as EPROMs
-
- <li>Serial lines or some kind of keyboard
-
- <li>Network connections via <samp><span
class="command">telnet</span></samp> or SNMP
-
- <li>HTTP connections with HTML GUIs
-</ul>
-
- <p>In this section, we look at a solution that uses HTTP connections
-to control variables of an embedded system that are stored in a file.
-Since embedded systems have tight limits on resources like memory,
-it is difficult to employ advanced techniques such as SNMP and HTTP
-servers. <samp><span class="command">gawk</span></samp> fits in quite nicely
with its single executable
-which needs just a short script to start working.
-The following program stores the variables in a file, and a concurrent
-process in the embedded system may read the file. The program uses the
-site-independent part of the simple web server that we developed in
-<a href="Interacting-Service.html#Interacting-Service">A Web Service with
Interaction</a>.
-As mentioned there, all we have to do is to write two new procedures
-<code>SetUpServer</code> and <code>HandleGET</code>:
-
-<pre class="smallexample"> <!-- file eg/network/remconf.awk -->
- function SetUpServer() {
- TopHeader = "<HTML><title>Remote
Configuration</title>"
- TopDoc = "<BODY>\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this
server</A></LI>\
- <LI><A HREF=" MyPrefix "/ReadConfig>Read
Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/CheckConfig>Check
Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/ChangeConfig>Change
Configuration</A></LI>\
- <LI><A HREF=" MyPrefix "/SaveConfig>Save
Configuration</A></LI>\
- </UL>"
- TopFooter = "</BODY></HTML>"
- if (ConfigFile == "") ConfigFile = "config.asc"
- }
- <!-- endfile -->
-</pre>
- <p>The function <code>SetUpServer</code> initializes the top level HTML
texts
-as usual. It also initializes the name of the file that contains the
-configuration parameters and their values. In case the user supplies
-a name from the command line, that name is used. The file is expected to
-contain one parameter per line, with the name of the parameter in
-column one and the value in column two.
-
- <p>The function <code>HandleGET</code> reflects the structure of the menu
-tree as usual. The first menu choice tells the user what this is all
-about. The second choice reads the configuration file line by line
-and stores the parameters and their values. Notice that the record
-separator for this file is <code>"\n"</code>, in contrast to the record
separator
-for HTTP. The third menu choice builds an HTML table to show
-the contents of the configuration file just read. The fourth choice
-does the real work of changing parameters, and the last one just saves
-the configuration into a file:
-
-<pre class="smallexample"> <!-- file eg/network/remconf.awk -->
- function HandleGET() {
- if(MENU[2] == "AboutServer") {
- Document = "This is a GUI for remote configuration of an\
- embedded system. It is is implemented as one GAWK script."
- } else if (MENU[2] == "ReadConfig") {
- RS = "\n"
- while ((getline < ConfigFile) > 0)
- config[$1] = $2;
- close(ConfigFile)
- RS = "\r\n"
- Document = "Configuration has been read."
- } else if (MENU[2] == "CheckConfig") {
- Document = "<TABLE BORDER=1 CELLPADDING=5>"
- for (i in config)
- Document = Document "<TR><TD>" i "</TD>" \
- "<TD>" config[i] "</TD></TR>"
- Document = Document "</TABLE>"
- } else if (MENU[2] == "ChangeConfig") {
- if ("Param" in GETARG) { # any parameter to set?
- if (GETARG["Param"] in config) { # is parameter valid?
- config[GETARG["Param"]] = GETARG["Value"]
- Document = (GETARG["Param"] " = " GETARG["Value"] ".")
- } else {
- Document = "Parameter <b>" GETARG["Param"] "</b> is
invalid."
- }
- } else {
- Document = "<FORM method=GET><h4>Change one
parameter</h4>\
- <TABLE BORDER CELLPADDING=5>\
-
<TR><TD>Parameter</TD><TD>Value</TD></TR>\
- <TR><TD><input type=text name=Param value=\"\"
size=20></TD>\
- <TD><input type=text name=Value value=\"\"
size=40></TD>\
- </TR></TABLE><input type=submit
value=\"Set\"></FORM>"
- }
- } else if (MENU[2] == "SaveConfig") {
- for (i in config)
- printf("%s %s\n", i, config[i]) > ConfigFile
- close(ConfigFile)
- Document = "Configuration has been saved."
- }
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-MiniSQL-134"></a>We could also view the configuration
file as a database. From this
-point of view, the previous program acts like a primitive database server.
-Real SQL database systems also make a service available by providing
-a TCP port that clients can connect to. But the application level protocols
-they use are usually proprietary and also change from time to time.
-This is also true for the protocol that
-MiniSQL uses.
-
- </body></html>
-
Index: manual/gawkinet/html_node/STATIST.html
===================================================================
RCS file: manual/gawkinet/html_node/STATIST.html
diff -N manual/gawkinet/html_node/STATIST.html
--- manual/gawkinet/html_node/STATIST.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,302 +0,0 @@
-<html lang="en">
-<head>
-<title>STATIST - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="WEBGRAB.html#WEBGRAB" title="WEBGRAB">
-<link rel="next" href="MAZE.html#MAZE" title="MAZE">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="STATIST"></a>Next: <a rel="next" accesskey="n"
href="MAZE.html#MAZE">MAZE</a>,
-Previous: <a rel="previous" accesskey="p"
href="WEBGRAB.html#WEBGRAB">WEBGRAB</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.6 STATIST: Graphing a Statistical Distribution</h3>
-
-<p><a name="index-STATIST-program-140"></a>
-<a name="index-GNUPlot-utility-141"></a><a
name="index-image-format-142"></a><a name="index-GIF-image-format-143"></a><a
name="index-PNG-image-format-144"></a><a
name="index-PS-image-format-145"></a><a
name="index-Boutell_002c-Thomas-146"></a>In the HTTP server examples we've
shown thus far, we never present an image
-to the browser and its user. Presenting images is one task. Generating
-images that reflect some user input and presenting these dynamically
-generated images is another. In this section, we use GNUPlot
-for generating <samp><span class="file">.png</span></samp>, <samp><span
class="file">.ps</span></samp>, or <samp><span class="file">.gif</span></samp>
-files.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p>The program we develop takes the statistical parameters of two samples
-and computes the t-test statistics. As a result, we get the probabilities
-that the means and the variances of both samples are the same. In order to
-let the user check plausibility, the program presents an image of the
-distributions. The statistical computation follows
-<cite>Numerical Recipes in C: The Art of Scientific Computing</cite>
-by William H. Press, Saul A. Teukolsky, William T. Vetterling, and Brian P.
Flannery.
-Since <samp><span class="command">gawk</span></samp> does not have a built-in
function
-for the computation of the beta function, we use the <code>ibeta</code>
function
-of GNUPlot. As a side effect, we learn how to use GNUPlot as a
-sophisticated calculator. The comparison of means is done as in
<code>tutest</code>,
-paragraph 14.2, page 613, and the comparison of variances is done as in
<code>ftest</code>,
-page 611 in <cite>Numerical Recipes</cite>.
-<a name="index-Numerical-Recipes-147"></a>
-As usual, we take the site-independent code for servers and append
-our own functions <code>SetUpServer</code> and <code>HandleGET</code>:
-
-<pre class="smallexample"> <!-- file eg/network/statist.awk -->
- function SetUpServer() {
- TopHeader = "<HTML><title>Statistics with
GAWK</title>"
- TopDoc = "<BODY>\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI><A HREF=" MyPrefix "/AboutServer>About this
server</A></LI>\
- <LI><A HREF=" MyPrefix "/EnterParameters>Enter
Parameters</A></LI>\
- </UL>"
- TopFooter = "</BODY></HTML>"
- GnuPlot = "gnuplot 2>&1"
- m1=m2=0; v1=v2=1; n1=n2=10
- }
- <!-- endfile -->
-</pre>
- <p>Here, you see the menu structure that the user sees. Later, we
-will see how the program structure of the <code>HandleGET</code> function
-reflects the menu structure. What is missing here is the link for the
-image we generate. In an event-driven environment, request,
-generation, and delivery of images are separated.
-
- <p>Notice the way we initialize the <code>GnuPlot</code> command string for
-the pipe. By default,
-GNUPlot outputs the generated image via standard output, as well as
-the results of <code>print</code>(ed) calculations via standard error.
-The redirection causes standard error to be mixed into standard
-output, enabling us to read results of calculations with <code>getline</code>.
-By initializing the statistical parameters with some meaningful
-defaults, we make sure the user gets an image the first time
-he uses the program.
-
- <p><a name="index-JavaScript-148"></a>Following is the rather long function
<code>HandleGET</code>, which
-implements the contents of this service by reacting to the different
-kinds of requests from the browser. Before you start playing with
-this script, make sure that your browser supports JavaScript and that it also
-has this option switched on. The script uses a short snippet of
-JavaScript code for delayed opening of a window with an image.
-A more detailed explanation follows:
-
-<pre class="smallexample"> <!-- file eg/network/statist.awk -->
- function HandleGET() {
- if(MENU[2] == "AboutServer") {
- Document = "This is a GUI for a statistical computation.\
- It compares means and variances of two distributions.\
- It is implemented as one GAWK script and uses GNUPLOT."
- } else if (MENU[2] == "EnterParameters") {
- Document = ""
- if ("m1" in GETARG) { # are there parameters to compare?
- Document = Document "<SCRIPT LANGUAGE=\"JavaScript\">\
- setTimeout(\"window.open(\\\"" MyPrefix "/Image" systime()\
- "\\\",\\\"dist\\\", \\\"status=no\\\");\", 1000);
</SCRIPT>"
- m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"]
- m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"]
- t = (m1-m2)/sqrt(v1/n1+v2/n2)
- df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \
- + (v2/n2)*(v2/n2) /(n2-1))
- if (v1>v2) {
- f = v1/v2
- df1 = n1 - 1
- df2 = n2 - 1
- } else {
- f = v2/v1
- df1 = n2 - 1
- df2 = n1 - 1
- }
- print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot
- print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \
- df2/(df2+df1*f) ")" |& GnuPlot
- print "print pt, pF" |& GnuPlot
- RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF
- print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot
- print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot
- print "set term png small color" |& GnuPlot
- #print "set term postscript color" |& GnuPlot
- #print "set term gif medium size 320,240" |& GnuPlot
- print "set yrange[-0.3:]" |& GnuPlot
- print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot
- print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot
- print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\
- mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot
- print "quit" |& GnuPlot
- GnuPlot |& getline Image
- while ((GnuPlot |& getline) > 0)
- Image = Image RS $0
- close(GnuPlot)
- }
- Document = Document "\
- <h3>Do these samples have the same Gaussian
distribution?</h3>\
- <FORM METHOD=GET> <TABLE BORDER CELLPADDING=5>\
- <TR>\
- <TD>1. Mean </TD>
- <TD><input type=text name=m1 value=" m1 "
size=8></TD>\
- <TD>1. Variance</TD>
- <TD><input type=text name=v1 value=" v1 "
size=8></TD>\
- <TD>1. Count </TD>
- <TD><input type=text name=n1 value=" n1 "
size=8></TD>\
- </TR><TR>\
- <TD>2. Mean </TD>
- <TD><input type=text name=m2 value=" m2 "
size=8></TD>\
- <TD>2. Variance</TD>
- <TD><input type=text name=v2 value=" v2 "
size=8></TD>\
- <TD>2. Count </TD>
- <TD><input type=text name=n2 value=" n2 "
size=8></TD>\
- </TR> <input type=submit
value=\"Compute\">\
- </TABLE></FORM><BR>"
- } else if (MENU[2] ~ "Image") {
- Reason = "OK" ORS "Content-type: image/png"
- #Reason = "OK" ORS "Content-type: application/x-postscript"
- #Reason = "OK" ORS "Content-type: image/gif"
- Header = Footer = ""
- Document = Image
- }
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-PostScript-149"></a>As usual, we give a short description
of the service in the first
-menu choice. The third menu choice shows us that generation and
-presentation of an image are two separate actions. While the latter
-takes place quite instantly in the third menu choice, the former
-takes place in the much longer second choice. Image data passes from the
-generating action to the presenting action via the variable <code>Image</code>
-that contains a complete <samp><span class="file">.png</span></samp> image,
which is otherwise stored
-in a file. If you prefer <samp><span class="file">.ps</span></samp> or
<samp><span class="file">.gif</span></samp> images over the
-default <samp><span class="file">.png</span></samp> images, you may select
these options by uncommenting
-the appropriate lines. But remember to do so in two places: when
-telling GNUPlot which kind of images to generate, and when transmitting the
-image at the end of the program.
-
- <p>Looking at the end of the program,
-the way we pass the `<samp><span class="samp">Content-type</span></samp>' to
the browser is a bit unusual.
-It is appended to the `<samp><span class="samp">OK</span></samp>' of the first
header line
-to make sure the type information becomes part of the header.
-The other variables that get transmitted across the network are
-made empty, because in this case we do not have an HTML document to
-transmit, but rather raw image data to contain in the body.
-
- <p>Most of the work is done in the second menu choice. It starts with a
-strange JavaScript code snippet. When first implementing this server,
-we used a short <code>"<IMG SRC="<!-- /@w --> MyPrefix
"/Image>"</code> here. But then
-browsers got smarter and tried to improve on speed by requesting the
-image and the HTML code at the same time. When doing this, the browser
-tries to build up a connection for the image request while the request for
-the HTML text is not yet completed. The browser tries to connect
-to the <samp><span class="command">gawk</span></samp> server on port 8080
while port 8080 is still in use for
-transmission of the HTML text. The connection for the image cannot be
-built up, so the image appears as “broken” in the browser window.
-We solved this problem by telling the browser to open a separate window
-for the image, but only after a delay of 1000 milliseconds.
-By this time, the server should be ready for serving the next request.
-
- <p>But there is one more subtlety in the JavaScript code.
-Each time the JavaScript code opens a window for the image, the
-name of the image is appended with a timestamp (<code>systime</code>).
-Why this constant change of name for the image? Initially, we always named
-the image <code>Image</code>, but then the Netscape browser noticed the name
-had <em>not</em> changed since the previous request and displayed the
-previous image (caching behavior). The server core
-is implemented so that browsers are told <em>not</em> to cache anything.
-Obviously HTTP requests do not always work as expected. One way to
-circumvent the cache of such overly smart browsers is to change the
-name of the image with each request. These three lines of JavaScript
-caused us a lot of trouble.
-
- <p>The rest can be broken
-down into two phases. At first, we check if there are statistical
-parameters. When the program is first started, there usually are no
-parameters because it enters the page coming from the top menu.
-Then, we only have to present the user a form that he can use to change
-statistical parameters and submit them. Subsequently, the submission of
-the form causes the execution of the first phase because <em>now</em>
-there <em>are</em> parameters to handle.
-
- <p>Now that we have parameters, we know there will be an image available.
-Therefore we insert the JavaScript code here to initiate the opening
-of the image in a separate window. Then,
-we prepare some variables that will be passed to GNUPlot for calculation
-of the probabilities. Prior to reading the results, we must temporarily
-change <code>RS</code> because GNUPlot separates lines with newlines.
-After instructing GNUPlot to generate a <samp><span
class="file">.png</span></samp> (or <samp><span class="file">.ps</span></samp>
or
-<samp><span class="file">.gif</span></samp>) image, we initiate the insertion
of some text,
-explaining the resulting probabilities. The final `<samp><span
class="samp">plot</span></samp>' command
-actually generates the image data. This raw binary has to be read in carefully
-without adding, changing, or deleting a single byte. Hence the unusual
-initialization of <code>Image</code> and completion with a <code>while</code>
loop.
-
- <p>When using this server, it soon becomes clear that it is far from being
-perfect. It mixes source code of six scripting languages or protocols:
-
- <ul>
-<li>GNU <samp><span class="command">awk</span></samp> implements a server for
the protocol:
-<li>HTTP which transmits:
-<li>HTML text which contains a short piece of:
-<li>JavaScript code opening a separate window.
-<li>A Bourne shell script is used for piping commands into:
-<li>GNUPlot to generate the image to be opened.
-</ul>
-
- <p>After all this work, the GNUPlot image opens in the JavaScript window
-where it can be viewed by the user.
-
- <p>It is probably better not to mix up so many different languages.
-The result is not very readable. Furthermore, the
-statistical part of the server does not take care of invalid input.
-Among others, using negative variances will cause invalid results.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Due to licensing problems, the default
-installation of GNUPlot disables the generation of <samp><span
class="file">.gif</span></samp> files.
-If your installed version does not accept `<samp><span class="samp">set term
gif</span></samp>',
-just download and install the most recent version of GNUPlot and the
-<a href="http://www.boutell.com/gd/">GD library</a>
-by Thomas Boutell.
-Otherwise you still have the chance to generate some
-ASCII-art style images with GNUPlot by using `<samp><span class="samp">set
term dumb</span></samp>'.
-(We tried it and it worked.)</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/STOXPRED.html
===================================================================
RCS file: manual/gawkinet/html_node/STOXPRED.html
diff -N manual/gawkinet/html_node/STOXPRED.html
--- manual/gawkinet/html_node/STOXPRED.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,389 +0,0 @@
-<html lang="en">
-<head>
-<title>STOXPRED - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="MOBAGWHO.html#MOBAGWHO" title="MOBAGWHO">
-<link rel="next" href="PROTBASE.html#PROTBASE" title="PROTBASE">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="STOXPRED"></a>Next: <a rel="next" accesskey="n"
href="PROTBASE.html#PROTBASE">PROTBASE</a>,
-Previous: <a rel="previous" accesskey="p"
href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.9 STOXPRED: Stock Market Prediction As A Service</h3>
-
-<p><a name="index-STOXPRED-program-159"></a><a
name="index-Yahoo_0021-160"></a><blockquote>
-<i>Far out in the uncharted backwaters of the unfashionable end of
-the Western Spiral arm of the Galaxy lies a small unregarded yellow sun.</i>
-
- <p><i>Orbiting this at a distance of roughly ninety-two million miles
is an
-utterly insignificant little blue-green planet whose ape-descendent life
-forms are so amazingly primitive that they still think digital watches are
-a pretty neat idea.</i>
-
- <p><i>This planet has — or rather had — a problem, which
was this:
-most of the people living on it were unhappy for pretty much of the time.
-Many solutions were suggested for this problem, but most of these were
-largely concerned with the movements of small green pieces of paper,
-which is odd because it wasn't the small green pieces of paper that
-were unhappy.</i> <br>
-Douglas Adams, <cite>The Hitch Hiker's Guide to the Galaxy</cite>
-</blockquote>
-
- <p><a name="index-_0040command_007bcron_007d-utility-161"></a>Valuable
services on the Internet are usually <em>not</em> implemented
-as mobile agents. There are much simpler ways of implementing services.
-All Unix systems provide, for example, the <samp><span
class="command">cron</span></samp> service.
-Unix system users can write a list of tasks to be done each day, each
-week, twice a day, or just once. The list is entered into a file named
-<samp><span class="file">crontab</span></samp>. For example, to distribute a
newsletter on a daily
-basis this way, use <samp><span class="command">cron</span></samp> for calling
a script each day early
-in the morning.
-
-<pre class="example"> # run at 8 am on weekdays, distribute the newsletter
- 0 8 * * 1-5 $HOME/bin/daily.job >> $HOME/log/newsletter
2>&1
-</pre>
- <p>The script first looks for interesting information on the Internet,
-assembles it in a nice form and sends the results via email to
-the customers.
-
- <p>The following is an example of a primitive
-newsletter on stock market prediction. It is a report which first
-tries to predict the change of each share in the Dow Jones Industrial
-Index for the particular day. Then it mentions some especially
-promising shares as well as some shares which look remarkably bad
-on that day. The report ends with the usual disclaimer which tells
-every child <em>not</em> to try this at home and hurt anybody.
-<a name="index-Dow-Jones-Industrial-Index-162"></a>
-<pre class="smallexample"> Good morning Uncle Scrooge,
-
- This is your daily stock market report for Monday, October 16, 2000.
- Here are the predictions for today:
-
- AA neutral
- GE up
- JNJ down
- MSFT neutral
- ...
- UTX up
- DD down
- IBM up
- MO down
- WMT up
- DIS up
- INTC up
- MRK down
- XOM down
- EK down
- IP down
-
- The most promising shares for today are these:
-
- INTC http://biz.yahoo.com/n/i/intc.html
-
- The stock shares to avoid today are these:
-
- EK http://biz.yahoo.com/n/e/ek.html
- IP http://biz.yahoo.com/n/i/ip.html
- DD http://biz.yahoo.com/n/d/dd.html
- ...
-</pre>
- <p>The script as a whole is rather long. In order to ease the pain of
-studying other people's source code, we have broken the script
-up into meaningful parts which are invoked one after the other.
-The basic structure of the script is as follows:
-
-<pre class="example"> <!-- file eg/network/stoxpred.awk -->
- BEGIN {
- Init()
- ReadQuotes()
- CleanUp()
- Prediction()
- Report()
- SendMail()
- }
- <!-- endfile -->
-</pre>
- <p>The earlier parts store data into variables and arrays which are
-subsequently used by later parts of the script. The <code>Init</code> function
-first checks if the script is invoked correctly (without any parameters).
-If not, it informs the user of the correct usage. What follows are preparations
-for the retrieval of the historical quote data. The names of the 30 stock
-shares are stored in an array <code>name</code> along with the current date
-in <code>day</code>, <code>month</code>, and <code>year</code>.
-
- <p>All users who are separated
-from the Internet by a firewall and have to direct their Internet accesses
-to a proxy must supply the name of the proxy to this script with the
-`<samp><span class="samp">-v Proxy=</span><var>name</var></samp>' option. For
most users, the default proxy and
-port number should suffice.
-
-<pre class="example"> <!-- file eg/network/stoxpred.awk -->
- function Init() {
- if (ARGC != 1) {
- print "STOXPRED - daily stock share prediction"
- print "IN:\n no parameters, nothing on stdin"
- print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80"
- print "OUT:\n commented predictions as email"
- print "JK 09.10.2000"
- exit
- }
- # Remember ticker symbols from Dow Jones Industrial Index
- StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \
- SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \
- MRK XOM EK IP", name);
- # Remember the current date as the end of the time series
- day = strftime("%d")
- month = strftime("%m")
- year = strftime("%Y")
- if (Proxy == "") Proxy = "chart.yahoo.com"
- if (ProxyPort == 0) ProxyPort = 80
- YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-CSV-format-163"></a>There are two really interesting
parts in the script. One is the
-function which reads the historical stock quotes from an Internet
-server. The other is the one that does the actual prediction. In
-the following function we see how the quotes are read from the
-Yahoo server. The data which comes from the server is in
-CSV format (comma-separated values):
-
-<pre class="example"> <!-- file eg/network/stoxdata.txt -->
- Date,Open,High,Low,Close,Volume
- 9-Oct-00,22.75,22.75,21.375,22.375,7888500
- 6-Oct-00,23.8125,24.9375,21.5625,22,10701100
- 5-Oct-00,24.4375,24.625,23.125,23.50,5810300
- <!-- endfile -->
-</pre>
- <p>Lines contain values of the same time instant, whereas columns are
-separated by commas and contain the kind of data that is described
-in the header (first) line. At first, <samp><span
class="command">gawk</span></samp> is instructed to
-separate columns by commas (`<samp><span class="samp">FS =
","</span></samp>'). In the loop that follows,
-a connection to the Yahoo server is first opened, then a download takes
-place, and finally the connection is closed. All this happens once for
-each ticker symbol. In the body of this loop, an Internet address is
-built up as a string according to the rules of the Yahoo server. The
-starting and ending date are chosen to be exactly the same, but one year
-apart in the past. All the action is initiated within the <code>printf</code>
-command which transmits the request for data to the Yahoo server.
-
- <p>In the inner loop, the server's data is first read and then scanned
-line by line. Only lines which have six columns and the name of a month
-in the first column contain relevant data. This data is stored
-in the two-dimensional array <code>quote</code>; one dimension
-being time, the other being the ticker symbol. During retrieval of the
-first stock's data, the calendar names of the time instances are stored
-in the array <code>day</code> because we need them later.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function ReadQuotes() {
- # Retrieve historical data for each ticker symbol
- FS = ","
- for (stock = 1; stock <= StockCount; stock++) {
- URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \
- "&a=" month "&b=" day "&c=" year-1 \
- "&d=" month "&e=" day "&f=" year \
- "g=d&q=q&y=0&z=" name[stock] "&x=.csv"
- printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData
- while ((YahooData |& getline) > 0) {
- if (NF == 6 && $1 ~
/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) {
- if (stock == 1)
- days[++daycount] = $1;
- quote[$1, stock] = $5
- }
- }
- close(YahooData)
- }
- FS = " "
- }
- <!-- endfile -->
-</pre>
- <p>Now that we <em>have</em> the data, it can be checked once again to make
sure
-that no individual stock is missing or invalid, and that all the stock quotes
are
-aligned correctly. Furthermore, we renumber the time instances. The
-most recent day gets day number 1 and all other days get consecutive
-numbers. All quotes are rounded toward the nearest whole number in US Dollars.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function CleanUp() {
- # clean up time series; eliminate incomplete data sets
- for (d = 1; d <= daycount; d++) {
- for (stock = 1; stock <= StockCount; stock++)
- if (! ((days[d], stock) in quote))
- stock = StockCount + 10
- if (stock > StockCount + 1)
- continue
- datacount++
- for (stock = 1; stock <= StockCount; stock++)
- data[datacount, stock] = int(0.5 + quote[days[d], stock])
- }
- delete quote
- delete days
- }
- <!-- endfile -->
-</pre>
- <p>Now we have arrived at the second really interesting part of the whole
affair.
-What we present here is a very primitive prediction algorithm:
-<em>If a stock fell yesterday, assume it will also fall today; if
-it rose yesterday, assume it will rise today</em>. (Feel free to replace this
-algorithm with a smarter one.) If a stock changed in the same direction
-on two consecutive days, this is an indication which should be highlighted.
-Two-day advances are stored in <code>hot</code> and two-day declines in
-<code>avoid</code>.
-
- <p>The rest of the function is a sanity check. It counts the number of
-correct predictions in relation to the total number of predictions
-one could have made in the year before.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function Prediction() {
- # Predict each ticker symbol by prolonging yesterday's trend
- for (stock = 1; stock <= StockCount; stock++) {
- if (data[1, stock] > data[2, stock]) {
- predict[stock] = "up"
- } else if (data[1, stock] < data[2, stock]) {
- predict[stock] = "down"
- } else {
- predict[stock] = "neutral"
- }
- if ((data[1, stock] > data[2, stock]) && (data[2, stock]
> data[3, stock]))
- hot[stock] = 1
- if ((data[1, stock] < data[2, stock]) && (data[2, stock]
< data[3, stock]))
- avoid[stock] = 1
- }
- # Do a plausibility check: how many predictions proved correct?
- for (s = 1; s <= StockCount; s++) {
- for (d = 1; d <= datacount-2; d++) {
- if (data[d+1, s] > data[d+2, s]) {
- UpCount++
- } else if (data[d+1, s] < data[d+2, s]) {
- DownCount++
- } else {
- NeutralCount++
- }
- if (((data[d, s] > data[d+1, s]) && (data[d+1, s] >
data[d+2, s])) ||
- ((data[d, s] < data[d+1, s]) && (data[d+1, s] <
data[d+2, s])) ||
- ((data[d, s] == data[d+1, s]) && (data[d+1, s] ==
data[d+2, s])))
- CorrectCount++
- }
- }
- }
- <!-- endfile -->
-</pre>
- <p>At this point the hard work has been done: the array <code>predict</code>
-contains the predictions for all the ticker symbols. It is up to the
-function <code>Report</code> to find some nice words to introduce the
-desired information.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function Report() {
- # Generate report
- report = "\nThis is your daily "
- report = report "stock market report for "strftime("%A, %B %d, %Y")".\n"
- report = report "Here are the predictions for today:\n\n"
- for (stock = 1; stock <= StockCount; stock++)
- report = report "\t" name[stock] "\t" predict[stock] "\n"
- for (stock in hot) {
- if (HotCount++ == 0)
- report = report "\nThe most promising shares for today are
these:\n\n"
- report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
- tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock])
".html\n"
- }
- for (stock in avoid) {
- if (AvoidCount++ == 0)
- report = report "\nThe stock shares to avoid today are these:\n\n"
- report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
- tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock])
".html\n"
- }
- report = report "\nThis sums up to " HotCount+0 " winners and "
AvoidCount+0
- report = report " losers. When using this kind\nof prediction scheme
for"
- report = report " the 12 months which lie behind us,\nwe get " UpCount
- report = report " 'ups' and " DownCount " 'downs' and " NeutralCount
- report = report " 'neutrals'. Of all\nthese "
UpCount+DownCount+NeutralCount
- report = report " predictions " CorrectCount " proved correct next
day.\n"
- report = report "A success rate of "\
- int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n"
- report = report "Random choice would have produced a 33% success
rate.\n"
- report = report "Disclaimer: Like every other prediction of the stock\n"
- report = report "market, this report is, of course, complete
nonsense.\n"
- report = report "If you are stupid enough to believe these
predictions\n"
- report = report "you should visit a doctor who can treat your ailment."
- }
- <!-- endfile -->
-</pre>
- <p>The function <code>SendMail</code> goes through the list of customers
and opens
-a pipe to the <code>mail</code> command for each of them. Each one receives an
-email message with a proper subject heading and is addressed with his full
name.
-
-<pre class="smallexample"> <!-- file eg/network/stoxpred.awk -->
- function SendMail() {
- # send report to customers
- customer["address@hidden"] = "Uncle Scrooge"
- customer["address@hidden" ] = "Sir Thomas More"
- customer["address@hidden" ] = "Baruch de Spinoza"
- customer["address@hidden" ] = "Karl Marx"
- customer["address@hidden" ] = "John Maynard Keynes"
- customer["address@hidden" ] = "Ambrose Bierce"
- customer["address@hidden" ] = "Pierre Simon de Laplace"
- for (c in customer) {
- MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c
- print "Good morning " customer[c] "," | MailPipe
- print report "\n.\n" | MailPipe
- close(MailPipe)
- }
- }
- <!-- endfile -->
-</pre>
- <p>Be patient when running the script by hand.
-Retrieving the data for all the ticker symbols and sending the emails
-may take several minutes to complete, depending upon network traffic
-and the speed of the available Internet link.
-The quality of the prediction algorithm is likely to be disappointing.
-Try to find a better one.
-Should you find one with a success rate of more than 50%, please tell
-us about it! It is only for the sake of curiosity, of course. <code>:-)</code>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Setting-Up.html
===================================================================
RCS file: manual/gawkinet/html_node/Setting-Up.html
diff -N manual/gawkinet/html_node/Setting-Up.html
--- manual/gawkinet/html_node/Setting-Up.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,135 +0,0 @@
-<html lang="en">
-<head>
-<title>Setting Up - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Interacting.html#Interacting" title="Interacting">
-<link rel="next" href="Email.html#Email" title="Email">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Setting-Up"></a>Next: <a rel="next" accesskey="n"
href="Email.html#Email">Email</a>,
-Previous: <a rel="previous" accesskey="p"
href="Interacting.html#Interacting">Interacting</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.5 Setting Up a Service</h3>
-
-<!-- last comma is part of tertiary -->
-<p><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-service_002c-establishing-63"></a><!--
last comma is part of tertiary -->
-<a
name="index-_0040command_007bgawk_007d_002c-networking_002c-service_002c-establishing-64"></a>The
preceding programs behaved as clients that connect to a server somewhere
-on the Internet and request a particular service. Now we set up such a
-service to mimic the behavior of the `<samp><span
class="samp">daytime</span></samp>' service.
-Such a server does not know in advance who is going to connect to it over
-the network. Therefore, we cannot insert a name for the host to connect to
-in our special file name.
-
- <p>Start the following program in one window. Notice that the service does
-not have the name `<samp><span class="samp">daytime</span></samp>', but the
number `<samp><span class="samp">8888</span></samp>'.
-From looking at <samp><span class="file">/etc/services</span></samp>, you know
that names like `<samp><span class="samp">daytime</span></samp>'
-are just mnemonics for predetermined 16-bit integers.
-Only the system administrator (<code>root</code>) could enter
-our new service into <samp><span class="file">/etc/services</span></samp> with
an appropriate name.
-Also notice that the service name has to be entered into a different field
-of the special file name because we are setting up a server, not a client:
-
- <p><a name="index-_0040command_007bfinger_007d-utility-65"></a><a
name="index-servers-66"></a>
-<pre class="example"> BEGIN {
- print strftime() |& "/inet/tcp/8888/0/0"
- close("/inet/tcp/8888/0/0")
- }
-</pre>
- <p>Now open another window on the same machine.
-Copy the client program given as the first example
-(see <a href="TCP-Connecting.html#TCP-Connecting">Establishing a TCP
Connection</a>)
-to a new file and edit it, changing the name `<samp><span
class="samp">daytime</span></samp>' to
-`<samp><span class="samp">8888</span></samp>'. Then start the modified
client. You should get a reply
-like this:
-
-<pre class="example"> Sat Sep 27 19:08:16 CEST 1997
-</pre>
- <p class="noindent">Both programs explicitly close the connection.
-
-<!-- first comma is part of primary -->
-<p><a name="index-Microsoft-Windows_002c-networking_002c-ports-67"></a><a
name="index-networks_002c-ports_002c-reserved-68"></a><a
name="index-Unix_002c-network-ports-and-69"></a>Now we will intentionally make
a mistake to see what happens when the name
-`<samp><span class="samp">8888</span></samp>' (the so-called port) is already
used by another service.
-Start the server
-program in both windows. The first one works, but the second one
-complains that it could not open the connection. Each port on a single
-machine can only be used by one server program at a time. Now terminate the
-server program and change the name `<samp><span
class="samp">8888</span></samp>' to `<samp><span
class="samp">echo</span></samp>'. After restarting it,
-the server program does not run any more, and you know why: there is already
-an `<samp><span class="samp">echo</span></samp>' service running on your
machine. But even if this isn't true,
-you would not get
-your own `<samp><span class="samp">echo</span></samp>' server running on a
Unix machine,
-because the ports with numbers smaller
-than 1024 (`<samp><span class="samp">echo</span></samp>' is at port 7) are
reserved for <code>root</code>.
-On machines running some flavor of Microsoft Windows, there is no restriction
-that reserves ports 1 to 1024 for a privileged user; hence, you can start
-an `<samp><span class="samp">echo</span></samp>' server there.
-
- <p>Turning this short server program into something really useful is
simple.
-Imagine a server that first reads a file name from the client through the
-network connection, then does something with the file and
-sends a result back to the client. The server-side processing
-could be:
-
-<pre class="example"> BEGIN {
- NetService = "/inet/tcp/8888/0/0"
- NetService |& getline
- CatPipe = ("cat " $1) # sets $0 and the fields
- while ((CatPipe | getline) > 0)
- print $0 |& NetService
- close(NetService)
- }
-</pre>
- <p class="noindent">and we would
-have a remote copying facility. Such a server reads the name of a file
-from any client that connects to it and transmits the contents of the
-named file across the net. The server-side processing could also be
-the execution of a command that is transmitted across the network. From this
-example, you can see how simple it is to open up a security hole on your
-machine. If you allow clients to connect to your machine and
-execute arbitrary commands, anyone would be free to do `<samp><span
class="samp">rm -rf *</span></samp>'.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Simple-Server.html
===================================================================
RCS file: manual/gawkinet/html_node/Simple-Server.html
diff -N manual/gawkinet/html_node/Simple-Server.html
--- manual/gawkinet/html_node/Simple-Server.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,262 +0,0 @@
-<html lang="en">
-<head>
-<title>Simple Server - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Interacting-Service.html#Interacting-Service"
title="Interacting Service">
-<link rel="next" href="Caveats.html#Caveats" title="Caveats">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Simple-Server"></a>Next: <a rel="next" accesskey="n"
href="Caveats.html#Caveats">Caveats</a>,
-Previous: <a rel="previous" accesskey="p"
href="Interacting-Service.html#Interacting-Service">Interacting Service</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.10 A Simple Web Server</h3>
-
-<!-- STARTOFRANGE webserx -->
-<p><a name="index-web-servers-106"></a><!-- STARTOFRANGE serweb -->
-<a name="index-servers_002c-web-107"></a>In the preceding section, we built
the core logic for event-driven GUIs.
-In this section, we finally extend the core to a real application.
-No one would actually write a commercial web server in <samp><span
class="command">gawk</span></samp>, but
-it is instructive to see that it is feasible in principle.
-
- <p><a name="index-ELIZA-program-108"></a><a
name="index-Weizenbaum_002c-Joseph-109"></a>The application is ELIZA, the
famous program by Joseph Weizenbaum that
-mimics the behavior of a professional psychotherapist when talking to you.
-Weizenbaum would certainly object to this description, but this is part of
-the legend around ELIZA.
-Take the site-independent core logic and append the following code:
-
-<pre class="example"> <!-- file eg/network/eliza.awk -->
- function SetUpServer() {
- SetUpEliza()
- TopHeader = \
- "<HTML><title>An HTTP-based System with
GAWK</title>\
- <HEAD><META HTTP-EQUIV=\"Content-Type\"\
- CONTENT=\"text/html; charset=iso-8859-1\"></HEAD>\
- <BODY BGCOLOR=\"#ffffff\" TEXT=\"#000000\"\
- LINK=\"#0000ff\" VLINK=\"#0000ff\"\
- ALINK=\"#0000ff\"> <A NAME=\"top\">"
- TopDoc = "\
- <h2>Please choose one of the following actions:</h2>\
- <UL>\
- <LI>\
- <A HREF=" MyPrefix "/AboutServer>About this server</A>\
- </LI><LI>\
- <A HREF=" MyPrefix "/AboutELIZA>About Eliza</A></LI>\
- <LI>\
- <A HREF=" MyPrefix \
- "/StartELIZA>Start talking to
Eliza</A></LI></UL>"
- TopFooter = "</BODY></HTML>"
- }
- <!-- endfile -->
-</pre>
- <p><code>SetUpServer</code> is similar to the previous example,
-except for calling another function, <code>SetUpEliza</code>.
-This approach can be used to implement other kinds of servers.
-The only changes needed to do so are hidden in the functions
-<code>SetUpServer</code> and <code>HandleGET</code>. Perhaps it might be
necessary to
-implement other HTTP methods.
-The <samp><span class="command">igawk</span></samp> program that comes with
<samp><span class="command">gawk</span></samp>
-may be useful for this process.
-
- <p>When extending this example to a complete application, the first
-thing to do is to implement the function <code>SetUpServer</code> to
-initialize the HTML pages and some variables. These initializations
-determine the way your HTML pages look (colors, titles, menu
-items, etc.).
-
- <p>The function <code>HandleGET</code> is a nested case selection that
decides
-which page the user wants to see next. Each nesting level refers to a menu
-level of the GUI. Each case implements a certain action of the menu. On the
-deepest level of case selection, the handler essentially knows what the
-user wants and stores the answer into the variable that holds the HTML
-page contents:
-
-<pre class="smallexample"> <!-- file eg/network/eliza.awk -->
- function HandleGET() {
- # A real HTTP server would treat some parts of the URI as a file name.
- # We take parts of the URI as menu choices and go on accordingly.
- if(MENU[2] == "AboutServer") {
- Document = "This is not a CGI script.\
- This is an httpd, an HTML file, and a CGI script all \
- in one GAWK script. It needs no separate www-server, \
- no installation, and no root privileges.\
- <p>To run it, do this:</p><ul>\
- <li> start this script with \"gawk -f
httpserver.awk\",</li>\
- <li> and on the same host let your www browser open location\
- \"http://localhost:8080\"</li>\
- </ul>\<p>\ Details of HTTP come
from:</p><ul>\
- <li>Hethmon: Illustrated Guide to HTTP</p>\
- <li>RFC 2068</li></ul><p>JK
14.9.1997</p>"
- } else if (MENU[2] == "AboutELIZA") {
- Document = "This is an implementation of the famous ELIZA\
- program by Joseph Weizenbaum. It is written in GAWK and\
- /bin/sh: expad: command not found
- } else if (MENU[2] == "StartELIZA") {
- gsub(/\+/, " ", GETARG["YouSay"])
- # Here we also have to substitute coded special characters
- Document = "<form method=GET>" \
- "<h3>" ElizaSays(GETARG["YouSay"]) "</h3>\
- <p><input type=text name=YouSay value=\"\" size=60>\
- <br><input type=submit value=\"Tell her about
it\"></p></form>"
- }
- }
- <!-- endfile -->
-</pre>
- <p>Now we are down to the heart of ELIZA, so you can see how it works.
-Initially the user does not say anything; then ELIZA resets its money
-counter and asks the user to tell what comes to mind open heartedly.
-The subsequent answers are converted to uppercase characters and stored for
-later comparison. ELIZA presents the bill when being confronted with
-a sentence that contains the phrase “shut up.” Otherwise, it looks
for
-keywords in the sentence, conjugates the rest of the sentence, remembers
-the keyword for later use, and finally selects an answer from the set of
-possible answers:
-
-<pre class="smallexample"> <!-- file eg/network/eliza.awk -->
- function ElizaSays(YouSay) {
- if (YouSay == "") {
- cost = 0
- answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM"
- } else {
- q = toupper(YouSay)
- gsub("'", "", q)
- if(q == qold) {
- answer = "PLEASE DONT REPEAT YOURSELF !"
- } else {
- if (index(q, "SHUT UP") > 0) {
- answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\
- int(100*rand()+30+cost/100)
- } else {
- qold = q
- w = "-" # no keyword recognized yet
- for (i in k) { # search for keywords
- if (index(q, i) > 0) {
- w = i
- break
- }
- }
- if (w == "-") { # no keyword, take old subject
- w = wold
- subj = subjold
- } else { # find subject
- subj = substr(q, index(q, w) + length(w)+1)
- wold = w
- subjold = subj # remember keyword and subject
- }
- for (i in conj)
- gsub(i, conj[i], q) # conjugation
- # from all answers to this keyword, select one randomly
- answer = r[indices[int(split(k[w], indices) * rand()) + 1]]
- # insert subject into answer
- gsub("_", subj, answer)
- }
- }
- }
- cost += length(answer) # for later payment : 1 cent per character
- return answer
- }
- <!-- endfile -->
-</pre>
- <p>In the long but simple function <code>SetUpEliza</code>, you can see
tables
-for conjugation, keywords, and answers.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> The associative array <code>k</code>
-contains indices into the array of answers <code>r</code>. To choose an
-answer, ELIZA just picks an index randomly:
-
-<pre class="example"> <!-- file eg/network/eliza.awk -->
- function SetUpEliza() {
- srand()
- wold = "-"
- subjold = " "
-
- # table for conjugation
- conj[" ARE " ] = " AM "
- conj["WERE " ] = "WAS "
- conj[" YOU " ] = " I "
- conj["YOUR " ] = "MY "
- conj[" IVE " ] =\
- conj[" I HAVE " ] = " YOU HAVE "
- conj[" YOUVE " ] =\
- conj[" YOU HAVE "] = " I HAVE "
- conj[" IM " ] =\
- conj[" I AM " ] = " YOU ARE "
- conj[" YOURE " ] =\
- conj[" YOU ARE " ] = " I AM "
-
- # table of all answers
- r[1] = "DONT YOU BELIEVE THAT I CAN _"
- r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?"
- <!-- endfile -->
- ...
-</pre>
- <pre class="example"> <!-- file eg/network/eliza.awk -->
- # table for looking up answers that
- # fit to a certain keyword
- k["CAN YOU"] = "1 2 3"
- k["CAN I"] = "4 5"
- k["YOU ARE"] =\
- k["YOURE"] = "6 7 8 9"
- <!-- endfile -->
- ...
-</pre>
- <pre class="example"> <!-- file eg/network/eliza.awk -->
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-Humphrys_002c-Mark-110"></a><a
name="index-ELIZA-program-111"></a>Some interesting remarks and details
(including the original source code
-of ELIZA) are found on Mark Humphrys' home page. Yahoo! also has a
-page with a collection of ELIZA-like programs. Many of them are written
-in Java, some of them disclosing the Java source code, and a few even
-explain how to modify the Java source code.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The version shown
-here is abbreviated. The full version comes with the <samp><span
class="command">gawk</span></samp>
-distribution.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Some-Applications-and-Techniques.html
===================================================================
RCS file: manual/gawkinet/html_node/Some-Applications-and-Techniques.html
diff -N manual/gawkinet/html_node/Some-Applications-and-Techniques.html
--- manual/gawkinet/html_node/Some-Applications-and-Techniques.html 31 Aug
2004 22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-<html lang="en">
-<head>
-<title>Some Applications and Techniques - TCP/IP Internetworking With
`gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="next" href="Links.html#Links" title="Links">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Some-Applications-and-Techniques"></a>Next: <a rel="next"
accesskey="n" href="Links.html#Links">Links</a>,
-Previous: <a rel="previous" accesskey="p"
href="Using-Networking.html#Using-Networking">Using Networking</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h2 class="chapter">3 Some Applications and Techniques</h2>
-
-<p>In this chapter, we look at a number of self-contained
-scripts, with an emphasis on concise networking. Along the way, we
-work towards creating building blocks that encapsulate often needed
-functions of the networking world, show new techniques that
-broaden the scope of problems that can be solved with <samp><span
class="command">gawk</span></samp>, and
-explore leading edge technology that may shape the future of networking.
-
- <p>We often refer to the site-independent core of the server that
-we built in
-<a href="Simple-Server.html#Simple-Server">A Simple Web Server</a>.
-When building new and nontrivial servers, we
-always copy this building block and append new instances of the two
-functions <code>SetUpServer</code> and <code>HandleGET</code>.
-
- <p>This makes a lot of sense, since
-this scheme of event-driven
-execution provides <samp><span class="command">gawk</span></samp> with an
interface to the most widely
-accepted standard for GUIs: the web browser. Now, <samp><span
class="command">gawk</span></samp> can rival even
-Tcl/Tk.
-
- <p><a
name="index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-124"></a>Tcl and
<samp><span class="command">gawk</span></samp> have much in common. Both are
simple scripting languages
-that allow us to quickly solve problems with short programs. But Tcl has Tk
-on top of it, and <samp><span class="command">gawk</span></samp> had nothing
comparable up to now. While Tcl
-needs a large and ever-changing library (Tk, which was bound to the X Window
-System until recently), <samp><span class="command">gawk</span></samp> needs
just the networking interface
-and some kind of browser on the client's side. Besides better portability,
-the most important advantage of this approach (embracing well-established
-standards such HTTP and HTML) is that <em>we do not need to change the
-language</em>. We let others do the work of fighting over protocols and
standards.
-We can use HTML, JavaScript, VRML, or whatever else comes along to do our work.
-
-<ul class="menu">
-<li><a accesskey="1" href="PANIC.html#PANIC">PANIC</a>:
An Emergency Web Server.
-<li><a accesskey="2" href="GETURL.html#GETURL">GETURL</a>:
Retrieving Web Pages.
-<li><a accesskey="3" href="REMCONF.html#REMCONF">REMCONF</a>:
Remote Configuration Of Embedded Systems.
-<li><a accesskey="4" href="URLCHK.html#URLCHK">URLCHK</a>:
Look For Changed Web Pages.
-<li><a accesskey="5" href="WEBGRAB.html#WEBGRAB">WEBGRAB</a>:
Extract Links From A Page.
-<li><a accesskey="6" href="STATIST.html#STATIST">STATIST</a>:
Graphing A Statistical Distribution.
-<li><a accesskey="7" href="MAZE.html#MAZE">MAZE</a>:
Walking Through A Maze In Virtual Reality.
-<li><a accesskey="8" href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a>:
A Simple Mobile Agent.
-<li><a accesskey="9" href="STOXPRED.html#STOXPRED">STOXPRED</a>:
Stock Market Prediction As A Service.
-<li><a href="PROTBASE.html#PROTBASE">PROTBASE</a>:
Searching Through A Protein Database.
-</ul>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Special-File-Fields.html
===================================================================
RCS file: manual/gawkinet/html_node/Special-File-Fields.html
diff -N manual/gawkinet/html_node/Special-File-Fields.html
--- manual/gawkinet/html_node/Special-File-Fields.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,162 +0,0 @@
-<html lang="en">
-<head>
-<title>Special File Fields - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Gawk-Special-Files.html#Gawk-Special-Files" title="Gawk
Special Files">
-<link rel="prev" href="Gawk-Special-Files.html#Gawk-Special-Files" title="Gawk
Special Files">
-<link rel="next" href="Comparing-Protocols.html#Comparing-Protocols"
title="Comparing Protocols">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Special-File-Fields"></a>Next: <a rel="next" accesskey="n"
href="Comparing-Protocols.html#Comparing-Protocols">Comparing Protocols</a>,
-Previous: <a rel="previous" accesskey="p"
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a>,
-Up: <a rel="up" accesskey="u"
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">2.1.1 The Fields of the Special File Name</h4>
-
-<p>This section explains the meaning of all the other fields,
-as well as the range of values and the defaults.
-All of the fields are mandatory. To let the system pick a value,
-or if the field doesn't apply to the protocol, specify it as `<samp><span
class="samp">0</span></samp>':
-
-
-<a name="index-protocol-field-27"></a>
-<dl><!-- last comma is part of secondary -->
-<a
name="index-TCP_002fIP_002c-protocols_002c-selecting-28"></a><dt><var>protocol</var><dd>Determines
which member of the TCP/IP
-family of protocols is selected to transport the data across the
-network. There are three possible values (always written in lowercase):
-`<samp><span class="samp">tcp</span></samp>', `<samp><span
class="samp">udp</span></samp>', and `<samp><span
class="samp">raw</span></samp>'. The exact meaning of each is
-explained later in this section.
-
- <br><dt><var>localport</var><dd><a
name="index-networks_002c-ports_002c-specifying-29"></a>Determines which port
on the local
-machine is used to communicate across the network. It has no meaning
-with <samp><span class="file">/inet/raw</span></samp> and must therefore be
`<samp><span class="samp">0</span></samp>'. Application-level clients
-usually use `<samp><span class="samp">0</span></samp>' to indicate they do not
care which local port is
-used—instead they specify a remote port to connect to. It is vital for
-application-level servers to use a number different from `<samp><span
class="samp">0</span></samp>' here
-because their service has to be available at a specific publicly known
-port number. It is possible to use a name from <samp><span
class="file">/etc/services</span></samp> here.
-
- <br><dt><var>hostname</var><dd><a name="index-hostname-field-30"></a><a
name="index-servers_002c-as-hosts-31"></a>Determines which remote host is to
-be at the other end of the connection. Application-level servers must fill
-this field with a `<samp><span class="samp">0</span></samp>' to indicate their
being open for all other hosts
-to connect to them and enforce connection level server behavior this way.
-It is not possible for an application-level server to restrict its
-availability to one remote host by entering a host name here.
-Application-level clients must enter a name different from `<samp><span
class="samp">0</span></samp>'.
-The name can be either symbolic
-(e.g., `<samp><span class="samp">jpl-devvax.jpl.nasa.gov</span></samp>') or
numeric (e.g., `<samp><span class="samp">128.149.1.143</span></samp>').
-
- <br><dt><var>remoteport</var><dd>Determines which port on the remote
-machine is used to communicate across the network. It has no meaning
-with <samp><span class="file">/inet/raw</span></samp> and must therefore be 0.
-For <samp><span class="file">/inet/tcp</span></samp> and <samp><span
class="file">/inet/udp</span></samp>,
-application-level clients <em>must</em> use a number
-other than `<samp><span class="samp">0</span></samp>' to indicate to which
port on the remote machine
-they want to connect. Application-level servers must not fill this field with
-a `<samp><span class="samp">0</span></samp>'. Instead they specify a local
port to which clients connect.
-It is possible to use a name from <samp><span
class="file">/etc/services</span></samp> here.
-</dl>
-
- <p><a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-32"></a><a
name="index-_0040command_007bgawk_007d_002c-networking_002c-connections-33"></a>Experts
in network programming will notice that the usual
-client/server asymmetry found at the level of the socket API is not visible
-here. This is for the sake of simplicity of the high-level concept. If this
-asymmetry is necessary for your application,
-use another language.
-For <samp><span class="command">gawk</span></samp>, it is
-more important to enable users to write a client program with a minimum
-of code. What happens when first accessing a network connection is seen
-in the following pseudocode:
-
-<pre class="smallexample"> if ((name of remote host given) &&
(other side accepts connection)) {
- rendez-vous successful; transmit with getline or print
- } else {
- if ((other side did not accept) && (localport == 0))
- exit unsuccessful
- if (TCP) {
- set up a server accepting connections
- this means waiting for the client on the other side to connect
- } else
- ready
- }
-</pre>
- <p>The exact behavior of this algorithm depends on the values of the
-fields of the special file name. When in doubt, <a
href="table_002dinet_002dcomponents.html#table_002dinet_002dcomponents">table-inet-components</a>
-gives you the combinations of values and their meaning. If this
-table is too complicated, focus on the three lines printed in
-<strong>bold</strong>. All the examples in
-<a href="Using-Networking.html#Using-Networking">Networking With <samp><span
class="command">gawk</span></samp></a>,
-use only the
-patterns printed in bold letters.
-
- <div class="float">
-<a name="table_002dinet_002dcomponents"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="15%"><span
class="sc">protocol</span> </th><th valign="top" width="15%"><span
class="sc">local port</span> </th><th valign="top" width="15%"><span
class="sc">host name</span>
-</th><th valign="top" width="15%"><span class="sc">remote port</span> </th><th
valign="top" width="40%"><span class="sc">Resulting connection-level
behavior</span>
-<br></th></tr><tr align="left"><td valign="top"
width="15%"><strong>tcp</strong> </td><td valign="top"
width="15%"><strong>0</strong> </td><td valign="top"
width="15%"><strong>x</strong> </td><td valign="top"
width="15%"><strong>x</strong> </td><td valign="top" width="40%">
- <strong>Dedicated client, fails if immediately connecting to a
- server on the other side fails</strong>
-<br></td></tr><tr align="left"><td valign="top" width="15%">udp </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">x </td><td valign="top" width="40%">Dedicated client
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Dedicated client,
works only as <code>root</code>
-<br></td></tr><tr align="left"><td valign="top" width="15%"><strong>tcp,
udp</strong> </td><td valign="top" width="15%"><strong>x</strong> </td><td
valign="top" width="15%"><strong>x</strong> </td><td valign="top"
width="15%"><strong>x</strong> </td><td valign="top" width="40%">
- <strong>Client, switches to dedicated server if necessary</strong>
-<br></td></tr><tr align="left"><td valign="top" width="15%"><strong>tcp,
udp</strong> </td><td valign="top" width="15%"><strong>x</strong> </td><td
valign="top" width="15%"><strong>0</strong> </td><td valign="top"
width="15%"><strong>0</strong> </td><td valign="top" width="40%">
- <strong>Dedicated server</strong>
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">0 </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Dedicated server,
works only as <code>root</code>
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp, raw
</td><td valign="top" width="15%">x </td><td valign="top" width="15%">x
</td><td valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp, raw
</td><td valign="top" width="15%">0 </td><td valign="top" width="15%">0
</td><td valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp, raw
</td><td valign="top" width="15%">x </td><td valign="top" width="15%">0
</td><td valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">0 </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">tcp, udp </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">x </td><td valign="top" width="15%">0 </td><td
valign="top" width="15%">0 </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">0 </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
-<br></td></tr><tr align="left"><td valign="top" width="15%">raw </td><td
valign="top" width="15%">x </td><td valign="top" width="15%">x </td><td
valign="top" width="15%">x </td><td valign="top" width="40%">Invalid
- <br></td></tr></table>
-<p><strong class="float-caption">Table 2.1: /inet Special File
Components</strong></p></div>
-
- <p>In general, TCP is the preferred mechanism to use. It is the simplest
-protocol to understand and to use. Use the others only if circumstances
-demand low-overhead.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Stream-Communications.html
===================================================================
RCS file: manual/gawkinet/html_node/Stream-Communications.html
diff -N manual/gawkinet/html_node/Stream-Communications.html
--- manual/gawkinet/html_node/Stream-Communications.html 31 Aug 2004
22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-<html lang="en">
-<head>
-<title>Stream Communications - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Introduction.html#Introduction" title="Introduction">
-<link rel="prev" href="Introduction.html#Introduction" title="Introduction">
-<link rel="next" href="Datagram-Communications.html#Datagram-Communications"
title="Datagram Communications">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Stream-Communications"></a>Next: <a rel="next" accesskey="n"
href="Datagram-Communications.html#Datagram-Communications">Datagram
Communications</a>,
-Previous: <a rel="previous" accesskey="p"
href="Introduction.html#Introduction">Introduction</a>,
-Up: <a rel="up" accesskey="u"
href="Introduction.html#Introduction">Introduction</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.1 Reliable Byte-streams (Phone Calls)</h3>
-
-<p>When you make a phone call, the following steps occur:
-
- <ol type=1 start=1>
-<li>You dial a number.
-
- <li>The phone system connects to the called party, telling
-them there is an incoming call. (Their phone rings.)
-
- <li>The other party answers the call, or, in the case of a
-computer network, refuses to answer the call.
-
- <li>Assuming the other party answers, the connection between
-you is now a <dfn>duplex</dfn> (two-way), <dfn>reliable</dfn> (no data lost),
-sequenced (data comes out in the order sent) data stream.
-
- <li>You and your friend may now talk freely, with the phone system
-moving the data (your voices) from one end to the other.
-From your point of view, you have a direct end-to-end
-connection with the person on the other end.
- </ol>
-
- <p>The same steps occur in a duplex reliable computer networking
connection.
-There is considerably more overhead in setting up the communications,
-but once it's done, data moves in both directions, reliably, in sequence.
-
- </body></html>
-
Index: manual/gawkinet/html_node/TCP-Connecting.html
===================================================================
RCS file: manual/gawkinet/html_node/TCP-Connecting.html
diff -N manual/gawkinet/html_node/TCP-Connecting.html
--- manual/gawkinet/html_node/TCP-Connecting.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,113 +0,0 @@
-<html lang="en">
-<head>
-<title>TCP Connecting - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Gawk-Special-Files.html#Gawk-Special-Files" title="Gawk
Special Files">
-<link rel="next" href="Troubleshooting.html#Troubleshooting"
title="Troubleshooting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="TCP-Connecting"></a>Next: <a rel="next" accesskey="n"
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a>,
-Previous: <a rel="previous" accesskey="p"
href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special Files</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.2 Establishing a TCP Connection</h3>
-
-<!-- STARTOFRANGE tcpcon -->
-<p><a
name="index-TCP-_0028Transmission-Control-Protocol_0029_002c-connection_002c-establishing-46"></a><!--
STARTOFRANGE netcon -->
-<a
name="index-networks_002c-_0040command_007bgawk_007d-and_002c-connections-47"></a><!--
STARTOFRANGE gawcon -->
-<a
name="index-_0040command_007bgawk_007d_002c-networking_002c-connections-48"></a>Let's
observe a network connection at work. Type in the following program
-and watch the output. Within a second, it connects via TCP (<samp><span
class="file">/inet/tcp</span></samp>)
-to the machine it is running on (`<samp><span
class="samp">localhost</span></samp>') and asks the service
-`<samp><span class="samp">daytime</span></samp>' on the machine what time it
is:
-
- <p><a name="index-_0040code_007bgetline_007d-command-49"></a>
-<pre class="example"> BEGIN {
- "/inet/tcp/0/localhost/daytime" |& getline
- print $0
- close("/inet/tcp/0/localhost/daytime")
- }
-</pre>
- <p>Even experienced <samp><span class="command">awk</span></samp> users
will find the second line strange in two
-respects:
-
- <ul>
-<li>A special file is used as a shell command that pipes its output
-into <code>getline</code>. One would rather expect to see the special file
-being read like any other file (`<samp><span class="samp">getline <
-"/inet/tcp/0/localhost/daytime")</span></samp>'.
-
- <li><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-50"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-51"></a>The
operator `<samp><span class="samp">|&</span></samp>' has not been part of
any <samp><span class="command">awk</span></samp>
-implementation (until now).
-It is actually the only extension of the <samp><span
class="command">awk</span></samp>
-language needed (apart from the special files) to introduce network access.
-</ul>
-
- <p><a name="index-pipes_002c-networking-and-52"></a>The `<samp><span
class="samp">|&</span></samp>' operator was introduced in <samp><span
class="command">gawk</span></samp> 3.1 in order to
-overcome the crucial restriction that access to files and pipes in
-<samp><span class="command">awk</span></samp> is always unidirectional. It was
formerly impossible to use
-both access modes on the same file or pipe. Instead of changing the whole
-concept of file access, the `<samp><span class="samp">|&</span></samp>'
operator
-behaves exactly like the usual pipe operator except for two additions:
-
- <ul>
-<li>Normal shell commands connected to their <samp><span
class="command">gawk</span></samp> program with a `<samp><span
class="samp">|&</span></samp>'
-pipe can be accessed bidirectionally. The `<samp><span
class="samp">|&</span></samp>' turns out to be a quite
-general, useful, and natural extension of <samp><span
class="command">awk</span></samp>.
-
- <li>Pipes that consist of a special file name for network connections are
not
-executed as shell commands. Instead, they can be read and written to, just
-like a full-duplex network connection.
-</ul>
-
- <p>In the earlier example, the `<samp><span
class="samp">|&</span></samp>' operator tells <code>getline</code>
-to read a line from the special file <samp><span
class="file">/inet/tcp/0/localhost/daytime</span></samp>.
-We could also have printed a line into the special file. But instead we just
-read a line with the time, printed it, and closed the connection.
-(While we could just let <samp><span class="command">gawk</span></samp> close
the connection by finishing
-the program, in this web page
-we are pedantic and always explicitly close the connections.)
-
- </body></html>
-
Index: manual/gawkinet/html_node/The-TCP_002fIP-Protocols.html
===================================================================
RCS file: manual/gawkinet/html_node/The-TCP_002fIP-Protocols.html
diff -N manual/gawkinet/html_node/The-TCP_002fIP-Protocols.html
--- manual/gawkinet/html_node/The-TCP_002fIP-Protocols.html 31 Aug 2004
22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-<html lang="en">
-<head>
-<title>The TCP/IP Protocols - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Introduction.html#Introduction" title="Introduction">
-<link rel="prev" href="Datagram-Communications.html#Datagram-Communications"
title="Datagram Communications">
-<link rel="next" href="Making-Connections.html#Making-Connections"
title="Making Connections">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="The-TCP_002fIP-Protocols"></a>Next: <a rel="next" accesskey="n"
href="Making-Connections.html#Making-Connections">Making Connections</a>,
-Previous: <a rel="previous" accesskey="p"
href="Datagram-Communications.html#Datagram-Communications">Datagram
Communications</a>,
-Up: <a rel="up" accesskey="u"
href="Introduction.html#Introduction">Introduction</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.3 The Internet Protocols</h3>
-
-<p>The Internet Protocol Suite (usually referred to as just TCP/IP)<a
rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-consists of a number of different protocols at different levels or
“layers.”
-For our purposes, three protocols provide the fundamental communications
-mechanisms. All other defined protocols are referred to as user-level
-protocols (e.g., HTTP, used later in this web page).
-
-<ul class="menu">
-<li><a accesskey="1" href="Basic-Protocols.html#Basic-Protocols">Basic
Protocols</a>: The basic protocols.
-<li><a accesskey="2" href="Ports.html#Ports">Ports</a>:
The idea behind ports.
-</ul>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small>
-It should be noted that although the Internet seems to have conquered the
-world, there are other networking protocol suites in existence and in use.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/Troubleshooting.html
===================================================================
RCS file: manual/gawkinet/html_node/Troubleshooting.html
diff -N manual/gawkinet/html_node/Troubleshooting.html
--- manual/gawkinet/html_node/Troubleshooting.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,136 +0,0 @@
-<html lang="en">
-<head>
-<title>Troubleshooting - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="TCP-Connecting.html#TCP-Connecting" title="TCP
Connecting">
-<link rel="next" href="Interacting.html#Interacting" title="Interacting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Troubleshooting"></a>Next: <a rel="next" accesskey="n"
href="Interacting.html#Interacting">Interacting</a>,
-Previous: <a rel="previous" accesskey="p"
href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.3 Troubleshooting Connection Problems</h3>
-
-<p><a name="index-advanced-features_002c-network-connections-53"></a><!-- last
comma is part of secondary -->
-<a name="index-troubleshooting_002c-networks_002c-connections-54"></a>It may
well be that for some reason the program shown in the previous example does not
run on your
-machine. When looking at possible reasons for this, you will learn much
-about typical problems that arise in network programming. First of all,
-your implementation of <samp><span class="command">gawk</span></samp> may not
support network access
-because it is
-a pre-3.1 version or you do not have a network interface in your machine.
-Perhaps your machine uses some other protocol, such as
-DECnet or Novell's IPX. For the rest of this chapter,
-we will assume
-you work on a Unix machine that supports TCP/IP. If the previous example
program does
-not run on your machine, it may help to replace the name
-`<samp><span class="samp">localhost</span></samp>' with the name of your
machine or its IP address. If it
-does, you could replace `<samp><span class="samp">localhost</span></samp>'
with the name of another machine
-in your vicinity—this way, the program connects to another machine.
-Now you should see the date and time being printed by the program,
-otherwise your machine may not support the `<samp><span
class="samp">daytime</span></samp>' service.
-Try changing the service to `<samp><span class="samp">chargen</span></samp>'
or `<samp><span class="samp">ftp</span></samp>'. This way, the program
-connects to other services that should give you some response. If you are
-curious, you should have a look at your <samp><span
class="file">/etc/services</span></samp> file. It could
-look like this:
-
-<pre class="smallexample"> # /etc/services:
- #
- # Network services, Internet style
- #
- # Name Number/Protcol Alternate name # Comments
-
- echo 7/tcp
- echo 7/udp
- discard 9/tcp sink null
- discard 9/udp sink null
- daytime 13/tcp
- daytime 13/udp
- chargen 19/tcp ttytst source
- chargen 19/udp ttytst source
- ftp 21/tcp
- telnet 23/tcp
- smtp 25/tcp mail
- finger 79/tcp
- www 80/tcp http # WorldWideWeb HTTP
- www 80/udp # HyperText Transfer Protocol
- pop-2 109/tcp postoffice # POP version 2
- pop-2 109/udp
- pop-3 110/tcp # POP version 3
- pop-3 110/udp
- nntp 119/tcp readnews untp # USENET News
- irc 194/tcp # Internet Relay Chat
- irc 194/udp
- ...
-</pre>
- <p><a name="index-Linux-55"></a><a name="index-GNU_002fLinux-56"></a><a
name="index-Microsoft-Windows_002c-networking-57"></a>Here, you find a list of
services that traditional Unix machines usually
-support. If your GNU/Linux machine does not do so, it may be that these
-services are switched off in some startup script. Systems running some
-flavor of Microsoft Windows usually do <em>not</em> support these services.
-Nevertheless, it <em>is</em> possible to do networking with <samp><span
class="command">gawk</span></samp> on
-Microsoft
-Windows.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-The first column of the file gives the name of the service, and
-the second column gives a unique number and the protocol that one can use to
connect to
-this service.
-The rest of the line is treated as a comment.
-You see that some services (`<samp><span class="samp">echo</span></samp>')
support TCP as
-well as UDP.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Microsoft prefered to ignore the TCP/IP
-family of protocols until 1995. Then came the rise of the Netscape browser
-as a landmark “killer application.” Microsoft added TCP/IP support
and
-their own browser to Microsoft Windows 95 at the last minute. They even
back-ported
-their TCP/IP implementation to Microsoft Windows for Workgroups 3.11, but it
was
-a rather rudimentary and half-hearted implementation. Nevertheless,
-the equivalent of <samp><span class="file">/etc/services</span></samp> resides
under
-<samp><span class="file">C:\WINNT\system32\drivers\etc\services</span></samp>
on Microsoft Windows 2000.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/URLCHK.html
===================================================================
RCS file: manual/gawkinet/html_node/URLCHK.html
diff -N manual/gawkinet/html_node/URLCHK.html
--- manual/gawkinet/html_node/URLCHK.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-<html lang="en">
-<head>
-<title>URLCHK - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="REMCONF.html#REMCONF" title="REMCONF">
-<link rel="next" href="WEBGRAB.html#WEBGRAB" title="WEBGRAB">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="URLCHK"></a>Next: <a rel="next" accesskey="n"
href="WEBGRAB.html#WEBGRAB">WEBGRAB</a>,
-Previous: <a rel="previous" accesskey="p"
href="REMCONF.html#REMCONF">REMCONF</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.4 URLCHK: Look for Changed Web Pages</h3>
-
-<p><a name="index-URLCHK-program-135"></a>Most people who make heavy use of
Internet resources have a large
-bookmark file with pointers to interesting web sites. It is impossible
-to regularly check by hand if any of these sites have changed. A program
-is needed to automatically look at the headers of web pages and tell
-which ones have changed. URLCHK does the comparison after using GETURL
-with the <code>HEAD</code> method to retrieve the header.
-
- <p>Like GETURL, this program first checks that it is called with exactly
-one command-line parameter. URLCHK also takes the same command-line variables
-<code>Proxy</code> and <code>ProxyPort</code> as GETURL,
-because these variables are handed over to GETURL for each URL
-that gets checked. The one and only parameter is the name of a file that
-contains one line for each URL. In the first column, we find the URL, and
-the second and third columns hold the length of the URL's body when checked
-for the two last times. Now, we follow this plan:
-
- <ol type=1 start=1>
-<li>Read the URLs from the file and remember their most recent lengths
-
- <li>Delete the contents of the file
-
- <li>For each URL, check its new length and write it into the file
-
- <li>If the most recent and the new length differ, tell the user
- </ol>
-
- <p>It may seem a bit peculiar to read the URLs from a file together
-with their two most recent lengths, but this approach has several
-advantages. You can call the program again and again with the same
-file. After running the program, you can regenerate the changed URLs
-by extracting those lines that differ in their second and third columns:
-
-<!-- inspired by URLCHK in iX 5/97 166. -->
-<pre class="smallexample"> <!-- file eg/network/urlchk.awk -->
- BEGIN {
- if (ARGC != 2) {
- print "URLCHK - check if URLs have changed"
- print "IN:\n the file with URLs as a command-line parameter"
- print " file contains URL, old length, new length"
- print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080"
- print "OUT:\n same as file with URLs"
- print "JK 02.03.1998"
- exit
- }
- URLfile = ARGV[1]; ARGV[1] = ""
- if (Proxy != "") Proxy = " -v Proxy=" Proxy
- if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort
- while ((getline < URLfile) > 0)
- Length[$1] = $3 + 0
- close(URLfile) # now, URLfile is read in and can be updated
- GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk "
- for (i in Length) {
- GetThisHeader = GetHeader i " 2>&1"
- while ((GetThisHeader | getline) > 0)
- if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0
- close(GetThisHeader)
- print i, Length[i], NewLength > URLfile
- if (Length[i] != NewLength) # report only changed URLs
- print i, Length[i], NewLength
- }
- close(URLfile)
- }
- <!-- endfile -->
-</pre>
- <p>Another thing that may look strange is the way GETURL is called.
-Before calling GETURL, we have to check if the proxy variables need
-to be passed on. If so, we prepare strings that will become part
-of the command line later. In <code>GetHeader</code>, we store these strings
-together with the longest part of the command line. Later, in the loop
-over the URLs, <code>GetHeader</code> is appended with the URL and a
redirection
-operator to form the command that reads the URL's header over the Internet.
-GETURL always produces the headers over <samp><span
class="file">/dev/stderr</span></samp>. That is
-the reason why we need the redirection operator to have the header
-piped in.
-
- <p>This program is not perfect because it assumes that changing URLs
-results in changed lengths, which is not necessarily true. A more
-advanced approach is to look at some other header line that
-holds time information. But, as always when things get a bit more
-complicated, this is left as an exercise to the reader.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Using-Networking.html
===================================================================
RCS file: manual/gawkinet/html_node/Using-Networking.html
diff -N manual/gawkinet/html_node/Using-Networking.html
--- manual/gawkinet/html_node/Using-Networking.html 31 Aug 2004 22:15:42
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-<html lang="en">
-<head>
-<title>Using Networking - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Introduction.html#Introduction" title="Introduction">
-<link rel="next"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Using-Networking"></a>Next: <a rel="next" accesskey="n"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>,
-Previous: <a rel="previous" accesskey="p"
href="Introduction.html#Introduction">Introduction</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<!-- node-name, next, previous, up -->
-<h2 class="chapter">2 Networking With <samp><span
class="command">gawk</span></samp></h2>
-
-<!-- STARTOFRANGE netgawk -->
-<p><a name="index-networks_002c-_0040command_007bgawk_007d-and-8"></a><!--
STARTOFRANGE gawknet -->
-<a name="index-_0040command_007bgawk_007d_002c-networking-9"></a>The
<samp><span class="command">awk</span></samp> programming language was
originally developed as a
-pattern-matching language for writing short programs to perform
-data manipulation tasks.
-<samp><span class="command">awk</span></samp>'s strength is the manipulation
of textual data
-that is stored in files.
-It was never meant to be used for networking purposes.
-To exploit its features in a
-networking context, it's necessary to use an access mode for network
connections
-that resembles the access of files as closely as possible.
-
- <p><a name="index-Perl-10"></a><a name="index-Python-11"></a><a
name="index-Tcl_002fTk-12"></a><samp><span class="command">awk</span></samp> is
also meant to be a prototyping language. It is used
-to demonstrate feasibility and to play with features and user interfaces.
-This can be done with file-like handling of network
-connections.
-<samp><span class="command">gawk</span></samp> trades the lack
-of many of the advanced features of the TCP/IP family of protocols
-for the convenience of simple connection handling.
-The advanced
-features are available when programming in C or Perl. In fact, the
-network programming
-in this chapter
-is very similar to what is described in books such as
-<cite>Internet Programming with Python</cite>,
-<cite>Advanced Perl Programming</cite>,
-or
-<cite>Web Client Programming with Perl</cite>.
-
- <p><a
name="index-Perl_002c-_0040command_007bgawk_007d-networking-and-13"></a><a
name="index-Python_002c-_0040command_007bgawk_007d-networking-and-14"></a><a
name="index-Tcl_002fTk_002c-_0040command_007bgawk_007d-and-15"></a>However, you
can do the programming here without first having to learn object-oriented
-ideology; underlying languages such as Tcl/Tk, Perl, Python; or all of
-the libraries necessary to extend these languages before they are ready for
the Internet.
-
- <p><a name="index-Transmission-Control-Protocol_002c-See-TCP-16"></a><a
name="index-TCP-_0028Transmission-Control-Protocol_0029-17"></a>This chapter
demonstrates how to use the TCP protocol. The
-other protocols are much less important for most users (UDP) or even
-untractable (RAW).
-
-<ul class="menu">
-<li><a accesskey="1" href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk
Special Files</a>: How to do <samp><span
class="command">gawk</span></samp> networking.
-<li><a accesskey="2" href="TCP-Connecting.html#TCP-Connecting">TCP
Connecting</a>: Making a TCP connection.
-<li><a accesskey="3"
href="Troubleshooting.html#Troubleshooting">Troubleshooting</a>:
Troubleshooting TCP/IP connections.
-<li><a accesskey="4" href="Interacting.html#Interacting">Interacting</a>:
Interacting with a service.
-<li><a accesskey="5" href="Setting-Up.html#Setting-Up">Setting Up</a>:
Setting up a service.
-<li><a accesskey="6" href="Email.html#Email">Email</a>:
Reading email.
-<li><a accesskey="7" href="Web-page.html#Web-page">Web page</a>:
Reading a Web page.
-<li><a accesskey="8" href="Primitive-Service.html#Primitive-Service">Primitive
Service</a>: A primitive Web service.
-<li><a accesskey="9"
href="Interacting-Service.html#Interacting-Service">Interacting Service</a>:
A Web service with interaction.
-<li><a href="Simple-Server.html#Simple-Server">Simple Server</a>:
A simple Web server.
-<li><a href="Caveats.html#Caveats">Caveats</a>: Network
programming caveats.
-<li><a href="Challenges.html#Challenges">Challenges</a>:
Where to go from here.
-</ul>
-
- </body></html>
-
Index: manual/gawkinet/html_node/WEBGRAB.html
===================================================================
RCS file: manual/gawkinet/html_node/WEBGRAB.html
diff -N manual/gawkinet/html_node/WEBGRAB.html
--- manual/gawkinet/html_node/WEBGRAB.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,151 +0,0 @@
-<html lang="en">
-<head>
-<title>WEBGRAB - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques"
title="Some Applications and Techniques">
-<link rel="prev" href="URLCHK.html#URLCHK" title="URLCHK">
-<link rel="next" href="STATIST.html#STATIST" title="STATIST">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="WEBGRAB"></a>Next: <a rel="next" accesskey="n"
href="STATIST.html#STATIST">STATIST</a>,
-Previous: <a rel="previous" accesskey="p"
href="URLCHK.html#URLCHK">URLCHK</a>,
-Up: <a rel="up" accesskey="u"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.5 WEBGRAB: Extract Links from a Page</h3>
-
-<p><a name="index-WEBGRAB-program-136"></a><!-- Inspired by iX 1/98 157. -->
-<a name="index-robot-137"></a>Sometimes it is necessary to extract links from
web pages.
-Browsers do it, web robots do it, and sometimes even humans do it.
-Since we have a tool like GETURL at hand, we can solve this problem with
-some help from the Bourne shell:
-
-<pre class="example"> <!-- file eg/network/webgrab.awk -->
- BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" }
- RT != "" {
- command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \
- " > doc" NR ".html")
- print command
- }
- <!-- endfile -->
-</pre>
- <p>Notice that the regular expression for URLs is rather crude. A precise
-regular expression is much more complex. But this one works
-rather well. One problem is that it is unable to find internal links of
-an HTML document. Another problem is that
-`<samp><span class="samp">ftp</span></samp>', `<samp><span
class="samp">telnet</span></samp>', `<samp><span
class="samp">news</span></samp>', `<samp><span
class="samp">mailto</span></samp>', and other kinds
-of links are missing in the regular expression.
-However, it is straightforward to add them, if doing so is necessary for other
tasks.
-
- <p>This program reads an HTML file and prints all the HTTP links that it
finds.
-It relies on <samp><span class="command">gawk</span></samp>'s ability to use
regular expressions as record
-separators. With <code>RS</code> set to a regular expression that matches
links,
-the second action is executed each time a non-empty link is found.
-We can find the matching link itself in <code>RT</code>.
-
- <p>The action could use the <code>system</code> function to let another
GETURL
-retrieve the page, but here we use a different approach.
-This simple program prints shell commands that can be piped into <samp><span
class="command">sh</span></samp>
-for execution. This way it is possible to first extract
-the links, wrap shell commands around them, and pipe all the shell commands
-into a file. After editing the file, execution of the file retrieves
-exactly those files that we really need. In case we do not want to edit,
-we can retrieve all the pages like this:
-
-<pre class="smallexample"> gawk -f geturl.awk http://www.suse.de | gawk -f
webgrab.awk | sh
-</pre>
- <p><a name="index-Microsoft-Windows-138"></a>After this, you will find the
contents of all referenced documents in
-files named <samp><span class="file">doc*.html</span></samp> even if they do
not contain HTML code.
-The most annoying thing is that we always have to pass the proxy to
-GETURL. If you do not like to see the headers of the web pages
-appear on the screen, you can redirect them to <samp><span
class="file">/dev/null</span></samp>.
-Watching the headers appear can be quite interesting, because
-it reveals
-interesting details such as which web server the companies use.
-Now, it is clear how the clever marketing people
-use web robots to determine the
-market shares
-of Microsoft and Netscape in the web server market.
-
- <p>Port 80 of any web server is like a small hole in a repellent firewall.
-After attaching a browser to port 80, we usually catch a glimpse
-of the bright side of the server (its home page). With a tool like GETURL
-at hand, we are able to discover some of the more concealed
-or even “indecent” services (i.e., lacking conformity to standards
of quality).
-It can be exciting to see the fancy CGI scripts that lie
-there, revealing the inner workings of the server, ready to be called:
-
- <ul>
-<li>With a command such as:
-
- <pre class="example"> gawk -f geturl.awk
http://any.host.on.the.net/cgi-bin/
- </pre>
- <p>some servers give you a directory listing of the CGI files.
-Knowing the names, you can try to call some of them and watch
-for useful results. Sometimes there are executables in such directories
-(such as Perl interpreters) that you may call remotely. If there are
-subdirectories with configuration data of the web server, this can also
-be quite interesting to read.
-
- <li><a name="index-apache-139"></a>The well-known Apache web server
usually has its CGI files in the
-directory <samp><span class="file">/cgi-bin</span></samp>. There you can often
find the scripts
-<samp><span class="file">test-cgi</span></samp> and <samp><span
class="file">printenv</span></samp>. Both tell you some things
-about the current connection and the installation of the web server.
-Just call:
-
- <pre class="smallexample"> gawk -f geturl.awk
http://any.host.on.the.net/cgi-bin/test-cgi
- gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/printenv
- </pre>
- <li>Sometimes it is even possible to retrieve system files like the web
-server's log file—possibly containing customer data—or even the
file
-<samp><span class="file">/etc/passwd</span></samp>.
-(We don't recommend this!)
-</ul>
-
- <p><strong>Caution:</strong>
-Although this may sound funny or simply irrelevant, we are talking about
-severe security holes. Try to explore your own system this way and make
-sure that none of the above reveals too much information about your system.
-
- </body></html>
-
Index: manual/gawkinet/html_node/Web-page.html
===================================================================
RCS file: manual/gawkinet/html_node/Web-page.html
diff -N manual/gawkinet/html_node/Web-page.html
--- manual/gawkinet/html_node/Web-page.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,126 +0,0 @@
-<html lang="en">
-<head>
-<title>Web page - TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Using-Networking.html#Using-Networking" title="Using
Networking">
-<link rel="prev" href="Email.html#Email" title="Email">
-<link rel="next" href="Primitive-Service.html#Primitive-Service"
title="Primitive Service">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Web-page"></a>Next: <a rel="next" accesskey="n"
href="Primitive-Service.html#Primitive-Service">Primitive Service</a>,
-Previous: <a rel="previous" accesskey="p"
href="Email.html#Email">Email</a>,
-Up: <a rel="up" accesskey="u"
href="Using-Networking.html#Using-Networking">Using Networking</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.7 Reading a Web Page</h3>
-
-<p><a name="index-web-pages-81"></a><a
name="index-HTTP-_0028Hypertext-Transfer-Protocol_0029-82"></a><a
name="index-Hypertext-Transfer-Protocol_002c-See-HTTP-83"></a><!-- @cindex RFC
2068 -->
-<!-- @cindex RFC 2616 -->
-
- <p>Retrieving a web page from a web server is as simple as
-retrieving email from an email server. We only have to use a
-similar, but not identical, protocol and a different port. The name of the
-protocol is HyperText Transfer Protocol (HTTP) and the port number is usually
-80. As in the preceding section, ask your administrator about the
-name of your local web server or proxy web server and its port number
-for HTTP requests.
-
- <p>The following program employs a rather crude approach toward retrieving a
-web page. It uses the prehistoric syntax of HTTP 0.9, which almost all
-web servers still support. The most noticeable thing about it is that the
-program directs the request to the local proxy server whose name you insert
-in the special file name (which in turn calls `<samp><span
class="samp">www.yahoo.com</span></samp>'):
-
-<pre class="example"> BEGIN {
- RS = ORS = "\r\n"
- HttpService = "/inet/tcp/0/<var>proxy</var>/80"
- print "GET http://www.yahoo.com" |& HttpService
- while ((HttpService |& getline) > 0)
- print $0
- close(HttpService)
- }
-</pre>
- <!-- @cindex RFC 1945 -->
-<p><a name="index-record-separators_002c-HTTP-and-84"></a><a
name="index-_0040code_007bRS_007d-variable_002c-HTTP-and-85"></a><a
name="index-_0040code_007bORS_007d-variable_002c-HTTP-and-86"></a><a
name="index-HTTP-_0028Hypertext-Transfer-Protocol_0029_002c-record-separators-and-87"></a><a
name="index-HTML-_0028Hypertext-Markup-Language_0029-88"></a><a
name="index-Hypertext-Markup-Language-_0028HTML_0029-89"></a>Again, lines are
separated by a redefined <code>RS</code> and <code>ORS</code>.
-The <code>GET</code> request that we send to the server is the only kind of
-HTTP request that existed when the web was created in the early 1990s.
-HTTP calls this <code>GET</code> request a “method,” which tells
the
-service to transmit a web page (here the home page of the Yahoo! search
-engine). Version 1.0 added the request methods <code>HEAD</code> and
-<code>POST</code>. The current version of HTTP is 1.1,<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a> and knows the additional request
-methods <code>OPTIONS</code>, <code>PUT</code>, <code>DELETE</code>, and
<code>TRACE</code>.
-You can fill in any valid web address, and the program prints the
-HTML code of that page to your screen.
-
- <p>Notice the similarity between the responses of the POP and HTTP
-services. First, you get a header that is terminated by an empty line, and
-then you get the body of the page in HTML. The lines of the headers also
-have the same form as in POP. There is the name of a parameter,
-then a colon, and finally the value of that parameter.
-
- <p><a
name="index-CGI-_0028Common-Gateway-Interface_0029_002c-dynamic-web-pages-and-90"></a><a
name="index-Common-Gateway-Interface_002c-See-CGI-91"></a><a
name="index-GIF-image-format-92"></a><a name="index-PNG-image-format-93"></a><a
name="index-images_002c-retrieving-over-networks-94"></a>Images (<samp><span
class="file">.png</span></samp> or <samp><span class="file">.gif</span></samp>
files) can also be retrieved this way,
-but then you
-get binary data that should be redirected into a file. Another
-application is calling a CGI (Common Gateway Interface) script on some
-server. CGI scripts are used when the contents of a web page are not
-constant, but generated instantly at the moment you send a request
-for the page. For example, to get a detailed report about the current
-quotes of Motorola stock shares, call a CGI script at Yahoo! with
-the following:
-
-<pre class="example"> get = "GET http://quote.yahoo.com/q?s=MOT&d=t"
- print get |& HttpService
-</pre>
- <p>You can also request weather reports this way.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Version 1.0 of
-HTTP was defined in RFC 1945. HTTP 1.1 was initially specified in RFC
-2068. In June 1999, RFC 2068 was made obsolete by RFC 2616, an update
-without any substantial changes.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/index.html
===================================================================
RCS file: manual/gawkinet/html_node/index.html
diff -N manual/gawkinet/html_node/index.html
--- manual/gawkinet/html_node/index.html 31 Aug 2004 22:15:42 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,202 +0,0 @@
-<html lang="en">
-<head>
-<title>TCP/IP Internetworking With `gawk'</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="TCP/IP Internetworking With `gawk'">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="../index.html#dir" title="(dir)">
-<link rel="prev" href="../index.html#dir" title="(dir)">
-<link rel="next" href="Preface.html#Preface" title="Preface">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-This is Edition 1.1 of `TCP/IP Internetworking With `gawk'',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-
- Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
-
-
- Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<h1 class="settitle">TCP/IP Internetworking With `gawk'</h1>
-<div class="node">
-<p>
-<a name="Top"></a>Next: <a rel="next" accesskey="n"
href="Preface.html#Preface">Preface</a>,
-Previous: <a rel="previous" accesskey="p"
href="../index.html#dir">(dir)</a>,
-Up: <a rel="up" accesskey="u" href="../index.html#dir">(dir)</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">General Introduction</h2>
-
-<!-- node-name, next, previous, up -->
-<p>This file documents the networking features in GNU Awk (<samp><span
class="command">gawk</span></samp>)
-version 3.1 and later.
-
- <p>This is Edition 1.1 of <cite>TCP/IP Internetworking With
<samp></cite><span class="command">gawk</span><cite></samp></cite>,
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
- <pre class="sp">
-
-
-</pre>
-Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
- <pre class="sp">
-
-
-</pre>
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being “GNU General Public License”, the
Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-“GNU Free Documentation License”.
-
- <ol type=a start=1>
-<li>“A GNU Manual”
-
- <li>“You have freedom to copy and modify this GNU Manual, like GNU
-software. Copies published by the Free Software Foundation raise
-funds for GNU development.”
- </ol>
-
-<ul class="menu">
-<li><a accesskey="1" href="Preface.html#Preface">Preface</a>:
About this document.
-<li><a accesskey="2" href="Introduction.html#Introduction">Introduction</a>:
About networkiing.
-<li><a accesskey="3" href="Using-Networking.html#Using-Networking">Using
Networking</a>: Some examples.
-<li><a accesskey="4"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">Some
Applications and Techniques</a>: More extended examples.
-<li><a accesskey="5" href="Links.html#Links">Links</a>:
Where to find the stuff mentioned in this
- document.
-<li><a accesskey="6"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>: The license for this document.
-<li><a accesskey="7" href="Index.html#Index">Index</a>:
The index.
-
-<li><a accesskey="8"
href="Stream-Communications.html#Stream-Communications">Stream
Communications</a>: Sending data streams.
-<li><a accesskey="9"
href="Datagram-Communications.html#Datagram-Communications">Datagram
Communications</a>: Sending self-contained messages.
-<li><a href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">The
TCP/IP Protocols</a>: How these models work in the Internet.
-<li><a href="Basic-Protocols.html#Basic-Protocols">Basic Protocols</a>:
The basic protocols.
-<li><a href="Ports.html#Ports">Ports</a>: The idea
behind ports.
-<li><a href="Making-Connections.html#Making-Connections">Making
Connections</a>: Making TCP/IP connections.
-<li><a href="Gawk-Special-Files.html#Gawk-Special-Files">Gawk Special
Files</a>: How to do <samp><span
class="command">gawk</span></samp> networking.
-<li><a href="Special-File-Fields.html#Special-File-Fields">Special File
Fields</a>: The fields in the special file name.
-<li><a href="Comparing-Protocols.html#Comparing-Protocols">Comparing
Protocols</a>: Differences between the protocols.
-<li><a href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">File
/inet/tcp</a>: The TCP special file.
-<li><a href="File-_002finet_002fudp.html#File-_002finet_002fudp">File
/inet/udp</a>: The UDP special file.
-<li><a href="File-_002finet_002fraw.html#File-_002finet_002fraw">File
/inet/raw</a>: The RAW special file.
-<li><a href="TCP-Connecting.html#TCP-Connecting">TCP Connecting</a>:
Making a TCP connection.
-<li><a href="Troubleshooting.html#Troubleshooting">Troubleshooting</a>:
Troubleshooting TCP/IP connections.
-<li><a href="Interacting.html#Interacting">Interacting</a>:
Interacting with a service.
-<li><a href="Setting-Up.html#Setting-Up">Setting Up</a>:
Setting up a service.
-<li><a href="Email.html#Email">Email</a>: Reading
email.
-<li><a href="Web-page.html#Web-page">Web page</a>:
Reading a Web page.
-<li><a href="Primitive-Service.html#Primitive-Service">Primitive Service</a>:
A primitive Web service.
-<li><a href="Interacting-Service.html#Interacting-Service">Interacting
Service</a>: A Web service with interaction.
-<li><a href="CGI-Lib.html#CGI-Lib">CGI Lib</a>: A
simple CGI library.
-<li><a href="Simple-Server.html#Simple-Server">Simple Server</a>:
A simple Web server.
-<li><a href="Caveats.html#Caveats">Caveats</a>:
Network programming caveats.
-<li><a href="Challenges.html#Challenges">Challenges</a>:
Where to go from here.
-<li><a href="PANIC.html#PANIC">PANIC</a>: An
Emergency Web Server.
-<li><a href="GETURL.html#GETURL">GETURL</a>:
Retrieving Web Pages.
-<li><a href="REMCONF.html#REMCONF">REMCONF</a>: Remote
Configuration Of Embedded Systems.
-<li><a href="URLCHK.html#URLCHK">URLCHK</a>: Look For
Changed Web Pages.
-<li><a href="WEBGRAB.html#WEBGRAB">WEBGRAB</a>:
Extract Links From A Page.
-<li><a href="STATIST.html#STATIST">STATIST</a>:
Graphing A Statistical Distribution.
-<li><a href="MAZE.html#MAZE">MAZE</a>: Walking
Through A Maze In Virtual Reality.
-<li><a href="MOBAGWHO.html#MOBAGWHO">MOBAGWHO</a>: A
Simple Mobile Agent.
-<li><a href="STOXPRED.html#STOXPRED">STOXPRED</a>:
Stock Market Prediction As A Service.
-<li><a href="PROTBASE.html#PROTBASE">PROTBASE</a>:
Searching Through A Protein Database.
-</ul>
-
-<div class="contents">
-<h2>Table of Contents</h2>
-<ul>
-<li><a name="toc_Top" href="index.html#Top">General Introduction</a>
-<li><a name="toc_Preface" href="Preface.html#Preface">Preface</a>
-<li><a name="toc_Introduction" href="Introduction.html#Introduction">1
Networking Concepts</a>
-<ul>
-<li><a href="Stream-Communications.html#Stream-Communications">1.1 Reliable
Byte-streams (Phone Calls)</a>
-<li><a href="Datagram-Communications.html#Datagram-Communications">1.2
Best-effort Datagrams (Mailed Letters)</a>
-<li><a href="The-TCP_002fIP-Protocols.html#The-TCP_002fIP-Protocols">1.3 The
Internet Protocols</a>
-<ul>
-<li><a href="Basic-Protocols.html#Basic-Protocols">1.3.1 The Basic Internet
Protocols</a>
-<li><a href="Ports.html#Ports">1.3.2 TCP and UDP Ports</a>
-</li></ul>
-<li><a href="Making-Connections.html#Making-Connections">1.4 Making TCP/IP
Connections (And Some Terminology)</a>
-</li></ul>
-<li><a name="toc_Using-Networking"
href="Using-Networking.html#Using-Networking">2 Networking With <samp><span
class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Gawk-Special-Files.html#Gawk-Special-Files">2.1 <samp><span
class="command">gawk</span></samp>'s Networking Mechanisms</a>
-<ul>
-<li><a href="Special-File-Fields.html#Special-File-Fields">2.1.1 The Fields of
the Special File Name</a>
-<li><a href="Comparing-Protocols.html#Comparing-Protocols">2.1.2 Comparing
Protocols</a>
-<ul>
-<li><a href="File-_002finet_002ftcp.html#File-_002finet_002ftcp">2.1.2.1
<samp><span class="file">/inet/tcp</span></samp></a>
-<li><a href="File-_002finet_002fudp.html#File-_002finet_002fudp">2.1.2.2
<samp><span class="file">/inet/udp</span></samp></a>
-<li><a href="File-_002finet_002fraw.html#File-_002finet_002fraw">2.1.2.3
<samp><span class="file">/inet/raw</span></samp></a>
-</li></ul>
-</li></ul>
-<li><a href="TCP-Connecting.html#TCP-Connecting">2.2 Establishing a TCP
Connection</a>
-<li><a href="Troubleshooting.html#Troubleshooting">2.3 Troubleshooting
Connection Problems</a>
-<li><a href="Interacting.html#Interacting">2.4 Interacting with a Network
Service</a>
-<li><a href="Setting-Up.html#Setting-Up">2.5 Setting Up a Service</a>
-<li><a href="Email.html#Email">2.6 Reading Email</a>
-<li><a href="Web-page.html#Web-page">2.7 Reading a Web Page</a>
-<li><a href="Primitive-Service.html#Primitive-Service">2.8 A Primitive Web
Service</a>
-<li><a href="Interacting-Service.html#Interacting-Service">2.9 A Web Service
with Interaction</a>
-<ul>
-<li><a href="CGI-Lib.html#CGI-Lib">2.9.1 A Simple CGI Library</a>
-</li></ul>
-<li><a href="Simple-Server.html#Simple-Server">2.10 A Simple Web Server</a>
-<li><a href="Caveats.html#Caveats">2.11 Network Programming Caveats</a>
-<li><a href="Challenges.html#Challenges">2.12 Where To Go From Here</a>
-</li></ul>
-<li><a name="toc_Some-Applications-and-Techniques"
href="Some-Applications-and-Techniques.html#Some-Applications-and-Techniques">3
Some Applications and Techniques</a>
-<ul>
-<li><a href="PANIC.html#PANIC">3.1 PANIC: An Emergency Web Server</a>
-<li><a href="GETURL.html#GETURL">3.2 GETURL: Retrieving Web Pages</a>
-<li><a href="REMCONF.html#REMCONF">3.3 REMCONF: Remote Configuration of
Embedded Systems</a>
-<li><a href="URLCHK.html#URLCHK">3.4 URLCHK: Look for Changed Web Pages</a>
-<li><a href="WEBGRAB.html#WEBGRAB">3.5 WEBGRAB: Extract Links from a Page</a>
-<li><a href="STATIST.html#STATIST">3.6 STATIST: Graphing a Statistical
Distribution</a>
-<li><a href="MAZE.html#MAZE">3.7 MAZE: Walking Through a Maze In Virtual
Reality</a>
-<li><a href="MOBAGWHO.html#MOBAGWHO">3.8 MOBAGWHO: a Simple Mobile Agent</a>
-<li><a href="STOXPRED.html#STOXPRED">3.9 STOXPRED: Stock Market Prediction As
A Service</a>
-<li><a href="PROTBASE.html#PROTBASE">3.10 PROTBASE: Searching Through A
Protein Database</a>
-</li></ul>
-<li><a name="toc_Links" href="Links.html#Links">4 Related Links</a>
-<li><a name="toc_GNU-Free-Documentation-License"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>
-<ul>
-<li><a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">ADDENDUM:
How to use this License for your documents</a>
-</li></ul>
-<li><a name="toc_Index" href="Index.html#Index">Index</a>
-</li></ul>
-</div>
-
- </body></html>
-
Index: manual/gawkinet/html_node/table_002dinet_002dcomponents.html
===================================================================
RCS file: manual/gawkinet/html_node/table_002dinet_002dcomponents.html
diff -N manual/gawkinet/html_node/table_002dinet_002dcomponents.html
--- manual/gawkinet/html_node/table_002dinet_002dcomponents.html 31 Aug
2004 22:15:42 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Special-File-Fields.html#table%2dinet%2dcomponents">
Index: manual/html_node/ARGC-and-ARGV.html
===================================================================
RCS file: manual/html_node/ARGC-and-ARGV.html
diff -N manual/html_node/ARGC-and-ARGV.html
--- manual/html_node/ARGC-and-ARGV.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,158 +0,0 @@
-<html lang="en">
-<head>
-<title>ARGC and ARGV - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din-Variables.html#Built_002din-Variables"
title="Built-in Variables">
-<link rel="prev" href="Auto_002dset.html#Auto_002dset" title="Auto-set">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="ARGC-and-ARGV"></a>Previous: <a rel="previous" accesskey="p"
href="Auto_002dset.html#Auto_002dset">Auto-set</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din-Variables.html#Built_002din-Variables">Built-in Variables</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.5.3 Using <code>ARGC</code> and <code>ARGV</code></h4>
-
-<p><a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1071"></a><a
name="index-arguments_002c-command_002dline-1072"></a><a
name="index-command-line_002c-arguments-1073"></a>
-<a href="Auto_002dset.html#Auto_002dset">Auto-set</a>,
-presented the following program describing the information contained in
<code>ARGC</code>
-and <code>ARGV</code>:
-
-<pre class="example"> $ awk 'BEGIN {
- > for (i = 0; i < ARGC; i++)
- > print ARGV[i]
- > }' inventory-shipped BBS-list
- -| awk
- -| inventory-shipped
- -| BBS-list
-</pre>
- <p class="noindent">In this example, <code>ARGV[0]</code> contains
`<samp><span class="samp">awk</span></samp>', <code>ARGV[1]</code>
-contains `<samp><span class="samp">inventory-shipped</span></samp>', and
<code>ARGV[2]</code> contains
-`<samp><span class="samp">BBS-list</span></samp>'.
-Notice that the <samp><span class="command">awk</span></samp> program is not
entered in <code>ARGV</code>. The
-other special command-line options, with their arguments, are also not
-entered. This includes variable assignments done with the <samp><span
class="option">-v</span></samp>
-option (see <a href="Options.html#Options">Options</a>).
-Normal variable assignments on the command line <em>are</em>
-treated as arguments and do show up in the <code>ARGV</code> array:
-
-<pre class="example"> $ cat showargs.awk
- -| BEGIN {
- -| printf "A=%d, B=%d\n", A, B
- -| for (i = 0; i < ARGC; i++)
- -| printf "\tARGV[%d] = %s\n", i, ARGV[i]
- -| }
- -| END { printf "A=%d, B=%d\n", A, B }
- $ awk -v A=1 -f showargs.awk B=2 /dev/null
- -| A=1, B=0
- -| ARGV[0] = awk
- -| ARGV[1] = B=2
- -| ARGV[2] = /dev/null
- -| A=1, B=2
-</pre>
- <p>A program can alter <code>ARGC</code> and the elements of
<code>ARGV</code>.
-Each time <samp><span class="command">awk</span></samp> reaches the end of an
input file, it uses the next
-element of <code>ARGV</code> as the name of the next input file. By storing a
-different string there, a program can change which files are read.
-Use <code>"-"</code> to represent the standard input. Storing
-additional elements and incrementing <code>ARGC</code> causes
-additional files to be read.
-
- <p>If the value of <code>ARGC</code> is decreased, that eliminates input
files
-from the end of the list. By recording the old value of <code>ARGC</code>
-elsewhere, a program can treat the eliminated arguments as
-something other than file names.
-
- <p>To eliminate a file from the middle of the list, store the null string
-(<code>""</code>) into <code>ARGV</code> in place of the file's name. As a
-special feature, <samp><span class="command">awk</span></samp> ignores file
names that have been
-replaced with the null string.
-Another option is to
-use the <code>delete</code> statement to remove elements from
-<code>ARGV</code> (see <a href="Delete.html#Delete">Delete</a>).
-
- <p>All of these actions are typically done in the <code>BEGIN</code> rule,
-before actual processing of the input begins.
-See <a href="Split-Program.html#Split-Program">Split Program</a>, and see
-<a href="Tee-Program.html#Tee-Program">Tee Program</a>, for examples
-of each way of removing elements from <code>ARGV</code>.
-The following fragment processes <code>ARGV</code> in order to examine, and
-then remove, command-line options:
-<!-- NEXT ED: Add xref to rewind() function -->
-
-<pre class="example"> BEGIN {
- for (i = 1; i < ARGC; i++) {
- if (ARGV[i] == "-v")
- verbose = 1
- else if (ARGV[i] == "-d")
- debug = 1
- else if (ARGV[i] ~ /^-?/) {
- e = sprintf("%s: unrecognized option -- %c",
- ARGV[0], substr(ARGV[i], 1, ,1))
- print e > "/dev/stderr"
- } else
- break
- delete ARGV[i]
- }
- }
-</pre>
- <p>To actually get the options into the <samp><span
class="command">awk</span></samp> program,
-end the <samp><span class="command">awk</span></samp> options with <samp><span
class="option">--</span></samp> and then supply
-the <samp><span class="command">awk</span></samp> program's options, in the
following manner:
-
-<pre class="example"> awk -f myprog -- -v -d file1 file2 ...
-</pre>
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1074"></a>This
is not necessary in <samp><span class="command">gawk</span></samp>. Unless
<samp><span class="option">--posix</span></samp> has
-been specified, <samp><span class="command">gawk</span></samp> silently puts
any unrecognized options
-into <code>ARGV</code> for the <samp><span class="command">awk</span></samp>
program to deal with. As soon
-as it sees an unknown option, <samp><span class="command">gawk</span></samp>
stops looking for other
-options that it might otherwise recognize. The previous example with
-<samp><span class="command">gawk</span></samp> would be:
-
-<pre class="example"> gawk -f myprog -d -v file1 file2 ...
-</pre>
- <p class="noindent">Because <samp><span class="option">-d</span></samp> is
not a valid <samp><span class="command">gawk</span></samp> option,
-it and the following <samp><span class="option">-v</span></samp>
-are passed on to the <samp><span class="command">awk</span></samp> program.
-
- </body></html>
-
Index: manual/html_node/AWKPATH-Variable.html
===================================================================
RCS file: manual/html_node/AWKPATH-Variable.html
diff -N manual/html_node/AWKPATH-Variable.html
--- manual/html_node/AWKPATH-Variable.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,122 +0,0 @@
-<html lang="en">
-<head>
-<title>AWKPATH Variable - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="prev" href="Other-Arguments.html#Other-Arguments" title="Other
Arguments">
-<link rel="next" href="Obsolete.html#Obsolete" title="Obsolete">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="AWKPATH-Variable"></a>Next: <a rel="next" accesskey="n"
href="Obsolete.html#Obsolete">Obsolete</a>,
-Previous: <a rel="previous" accesskey="p"
href="Other-Arguments.html#Other-Arguments">Other Arguments</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.4 The <samp><span class="env">AWKPATH</span></samp>
Environment Variable</h3>
-
-<p><a name="index-_0040env_007bAWKPATH_007d-environment-variable-1568"></a><a
name="index-directories_002c-searching-1569"></a><a
name="index-search-paths_002c-for-source-files-1570"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bAWKPATH_007d-environment-variable-1571"></a>In
most <samp><span class="command">awk</span></samp>
-implementations, you must supply a precise path name for each program
-file, unless the file is in the current directory.
-But in <samp><span class="command">gawk</span></samp>, if the file name
supplied to the <samp><span class="option">-f</span></samp> option
-does not contain a `<samp><span class="samp">/</span></samp>', then
<samp><span class="command">gawk</span></samp> searches a list of
-directories (called the <dfn>search path</dfn>), one by one, looking for a
-file with the specified name.
-
- <p>The search path is a string consisting of directory names
-separated by colons. <samp><span class="command">gawk</span></samp> gets its
search path from the
-<samp><span class="env">AWKPATH</span></samp> environment variable. If that
variable does not exist,
-<samp><span class="command">gawk</span></samp> uses a default path,
-`<samp><span class="samp">.:/usr/local/share/awk</span></samp>'.<a
rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> (Programs written for
use by
-system administrators should use an <samp><span
class="env">AWKPATH</span></samp> variable that
-does not include the current directory, <samp><span
class="file">.</span></samp>.)
-
- <p>The search path feature is particularly useful for building libraries
-of useful <samp><span class="command">awk</span></samp> functions. The
library files can be placed in a
-standard directory in the default path and then specified on
-the command line with a short file name. Otherwise, the full file name
-would have to be typed for each file.
-
- <p>By using both the <samp><span class="option">--source</span></samp> and
<samp><span class="option">-f</span></samp> options, your command-line
-<samp><span class="command">awk</span></samp> programs can use facilities in
<samp><span class="command">awk</span></samp> library files
-(see <a href="Library-Functions.html#Library-Functions">Library
Functions</a>).
-Path searching is not done if <samp><span class="command">gawk</span></samp>
is in compatibility mode.
-This is true for both <samp><span class="option">--traditional</span></samp>
and <samp><span class="option">--posix</span></samp>.
-See <a href="Options.html#Options">Options</a>.
-
- <blockquote>
-<b>NOTE:</b> If you want files in the current directory to be found,
-you must include the current directory in the path, either by including
-<samp><span class="file">.</span></samp> explicitly in the path or by writing
a null entry in the
-path. (A null entry is indicated by starting or ending the path with a
-colon or by placing two colons next to each other (`<samp><span
class="samp">::</span></samp>').) If the
-current directory is not included in the path, then files cannot be
-found in the current directory. This path search mechanism is identical
-to the shell's.
-<!-- someday, @cite{The Bourne Again Shell}.... -->
-</blockquote>
-
- <p>Starting with version 3.0, if <samp><span
class="env">AWKPATH</span></samp> is not defined in the
-environment, <samp><span class="command">gawk</span></samp> places its default
search path into
-<code>ENVIRON["AWKPATH"]</code>. This makes it easy to determine
-the actual search path that <samp><span class="command">gawk</span></samp>
will use
-from within an <samp><span class="command">awk</span></samp> program.
-
- <p>While you can change <code>ENVIRON["AWKPATH"]</code> within your
<samp><span class="command">awk</span></samp>
-program, this has no effect on the running program's behavior. This makes
-sense: the <samp><span class="env">AWKPATH</span></samp> environment variable
is used to find the program
-source files. Once your program is running, all the files have been
-found, and <samp><span class="command">gawk</span></samp> no longer needs to
use <samp><span class="env">AWKPATH</span></samp>.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Your version of <samp><span
class="command">gawk</span></samp>
-may use a different directory; it
-will depend upon how <samp><span class="command">gawk</span></samp> was built
and installed. The actual
-directory is the value of `<samp><span class="samp">$(datadir)</span></samp>'
generated when
-<samp><span class="command">gawk</span></samp> was configured. You probably
don't need to worry about this,
-though.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Acknowledgments.html
===================================================================
RCS file: manual/html_node/Acknowledgments.html
diff -N manual/html_node/Acknowledgments.html
--- manual/html_node/Acknowledgments.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,167 +0,0 @@
-<html lang="en">
-<head>
-<title>Acknowledgments - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="prev" href="How-To-Contribute.html#How-To-Contribute" title="How To
Contribute">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Acknowledgments"></a>Previous: <a rel="previous" accesskey="p"
href="How-To-Contribute.html#How-To-Contribute">How To Contribute</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="unnumberedsec">Acknowledgments</h3>
-
-<p>The initial draft of <cite>The GAWK Manual</cite> had the following
acknowledgments:
-
- <blockquote>
-Many people need to be thanked for their assistance in producing this
-manual. Jay Fenlason contributed many ideas and sample programs. Richard
-Mlynarik and Robert Chassell gave helpful comments on drafts of this
-manual. The paper <cite>A Supplemental Document for <samp></cite><span
class="command">awk</span><cite></samp></cite> by John W.
-Pierce of the Chemistry Department at UC San Diego, pinpointed several
-issues relevant both to <samp><span class="command">awk</span></samp>
implementation and to this manual, that
-would otherwise have escaped us.
-</blockquote>
-
- <p><a name="index-Stallman_002c-Richard-44"></a>I would like to acknowledge
Richard M. Stallman, for his vision of a
-better world and for his courage in founding the FSF and starting the
-GNU Project.
-
- <p>The following people (in alphabetical order)
-provided helpful comments on various
-versions of this book, up to and including this edition.
-Rick Adams,
-Nelson H.F. Beebe,
-Karl Berry,
-Dr. Michael Brennan,
-Rich Burridge,
-Claire Cloutier,
-Diane Close,
-Scott Deifik,
-Christopher (“Topher”) Eliot,
-Jeffrey Friedl,
-Dr. Darrel Hankerson,
-Michal Jaegermann,
-Dr. Richard J. LeBlanc,
-Michael Lijewski,
-Pat Rankin,
-Miriam Robbins,
-Mary Sheehan,
-and
-Chuck Toporek.
-
- <p><a name="index-Berry_002c-Karl-45"></a><a
name="index-Chassell_002c-Robert-J_002e_0040_003a-46"></a><!-- @cindex Texinfo
-->
-Robert J. Chassell provided much valuable advice on
-the use of Texinfo.
-He also deserves special thanks for
-convincing me <em>not</em> to title this Web page
-<cite>How To Gawk Politely</cite>.
-Karl Berry helped significantly with the TeX part of Texinfo.
-
- <p><a name="index-Hartholz_002c-Marshall-47"></a><a
name="index-Hartholz_002c-Elaine-48"></a><a
name="index-Schreiber_002c-Bert-49"></a><a
name="index-Schreiber_002c-Rita-50"></a>I would like to thank Marshall and
Elaine Hartholz of Seattle and
-Dr. Bert and Rita Schreiber of Detroit for large amounts of quiet vacation
-time in their homes, which allowed me to make significant progress on
-this Web page and on <samp><span class="command">gawk</span></samp> itself.
-
- <p><a name="index-Hughes_002c-Phil-51"></a>Phil Hughes of SSC
-contributed in a very important way by loaning me his laptop GNU/Linux
-system, not once, but twice, which allowed me to do a lot of work while
-away from home.
-
- <p><a name="index-Trueman_002c-David-52"></a>David Trueman deserves special
credit; he has done a yeoman job
-of evolving <samp><span class="command">gawk</span></samp> so that it performs
well and without bugs.
-Although he is no longer involved with <samp><span
class="command">gawk</span></samp>,
-working with him on this project was a significant pleasure.
-
- <p><a name="index-Drepper_002c-Ulrich-53"></a><a
name="index-GNITS-mailing-list-54"></a><a
name="index-mailing-list_002c-GNITS-55"></a>The intrepid members of the GNITS
mailing list, and most notably Ulrich
-Drepper, provided invaluable help and feedback for the design of the
-internationalization features.
-
- <p><a name="index-Beebe_002c-Nelson-56"></a><a
name="index-Brown_002c-Martin-57"></a><a
name="index-Buening_002c-Andreas-58"></a><a
name="index-Deifik_002c-Scott-59"></a><a
name="index-Hankerson_002c-Darrel-60"></a><a
name="index-Hasegawa_002c-Isamu-61"></a><a
name="index-Jaegermann_002c-Michal-62"></a><a
name="index-Kahrs_002c-J_0040_0022urgen-63"></a><a
name="index-Rankin_002c-Pat-64"></a><a
name="index-Rommel_002c-Kai-Uwe-65"></a><a
name="index-Zaretskii_002c-Eli-66"></a>Nelson Beebe,
-Martin Brown,
-Andreas Buening,
-Scott Deifik,
-Darrel Hankerson,
-Isamu Hasegawa,
-Michal Jaegermann,
-Jürgen Kahrs,
-Pat Rankin,
-Kai Uwe Rommel,
-and Eli Zaretskii
-(in alphabetical order)
-make up the
-<samp><span class="command">gawk</span></samp> “crack portability
team.” Without their hard work and
-help, <samp><span class="command">gawk</span></samp> would not be nearly the
fine program it is today. It
-has been and continues to be a pleasure working with this team of fine
-people.
-
- <p><a name="index-Kernighan_002c-Brian-67"></a>David and I would like to
thank Brian Kernighan of Bell Laboratories for
-invaluable assistance during the testing and debugging of <samp><span
class="command">gawk</span></samp>, and for
-help in clarifying numerous points about the language. We could not have
-done nearly as good a job on either <samp><span
class="command">gawk</span></samp> or its documentation without
-his help.
-
- <p>Chuck Toporek, Mary Sheehan, and Claire Coutier of O'Reilly &
Associates contributed
-significant editorial help for this Web page for the
-3.1 release of <samp><span class="command">gawk</span></samp>.
-
- <p><a name="index-Robbins_002c-Miriam-68"></a><a
name="index-Robbins_002c-Jean-69"></a><a
name="index-Robbins_002c-Harry-70"></a><a name="index-G_002dd-71"></a>I must
thank my wonderful wife, Miriam, for her patience through
-the many versions of this project, for her proofreading,
-and for sharing me with the computer.
-I would like to thank my parents for their love, and for the grace with
-which they raised and educated me.
-Finally, I also must acknowledge my gratitude to G-d, for the many
opportunities
-He has sent my way, as well as for the gifts He has given me with which to
-take advantage of those opportunities.
- <pre class="sp">
-
-
-</pre>
-Arnold Robbins <br>
-Nof Ayalon <br>
-ISRAEL <br>
-March, 2001
-
- </body></html>
-
Index: manual/html_node/Action-Overview.html
===================================================================
RCS file: manual/html_node/Action-Overview.html
diff -N manual/html_node/Action-Overview.html
--- manual/html_node/Action-Overview.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,122 +0,0 @@
-<html lang="en">
-<head>
-<title>Action Overview - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link rel="prev" href="Using-Shell-Variables.html#Using-Shell-Variables"
title="Using Shell Variables">
-<link rel="next" href="Statements.html#Statements" title="Statements">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Action-Overview"></a>Next: <a rel="next" accesskey="n"
href="Statements.html#Statements">Statements</a>,
-Previous: <a rel="previous" accesskey="p"
href="Using-Shell-Variables.html#Using-Shell-Variables">Using Shell
Variables</a>,
-Up: <a rel="up" accesskey="u"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>
-<hr><br>
-</div>
-
-<h3 class="section">6.3 Actions</h3>
-
-<!-- @cindex action, definition of -->
-<!-- @cindex curly braces -->
-<!-- @cindex action, curly braces -->
-<!-- @cindex action, separating statements -->
-<p><a name="index-actions-931"></a>
-An <samp><span class="command">awk</span></samp> program or script consists of
a series of
-rules and function definitions interspersed. (Functions are
-described later. See <a
href="User_002ddefined.html#User_002ddefined">User-defined</a>.)
-A rule contains a pattern and an action, either of which (but not
-both) may be omitted. The purpose of the <dfn>action</dfn> is to tell
-<samp><span class="command">awk</span></samp> what to do once a match for the
pattern is found. Thus,
-in outline, an <samp><span class="command">awk</span></samp> program generally
looks like this:
-
-<pre class="example"> <span class="roman">[</span><var>pattern</var><span
class="roman">]</span> <span class="roman">[</span>{ <var>action</var> }<span
class="roman">]</span>
- <span class="roman">[</span><var>pattern</var><span
class="roman">]</span> <span class="roman">[</span>{ <var>action</var> }<span
class="roman">]</span>
- ...
- function <var>name</var>(<var>args</var>) { ... }
- ...
-</pre>
- <p><a
name="index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-actions-and-932"></a><a
name="index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-actions-and-933"></a><a
name="index-separators_002c-for-statements-in-actions-934"></a><a
name="index-newlines_002c-separating-statements-in-actions-935"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-936"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-937"></a>An
action consists of one or more <samp><span class="command">awk</span></samp>
<dfn>statements</dfn>, enclosed
-in curly braces (`<samp><span class="samp">{...}</span></samp>'). Each
statement specifies one
-thing to do. The statements are separated by newlines or semicolons.
-The curly braces around an action must be used even if the action
-contains only one statement, or if it contains no statements at
-all. However, if you omit the action entirely, omit the curly braces as
-well. An omitted action is equivalent to `<samp><span class="samp">{ print $0
}</span></samp>':
-
-<pre class="example"> /foo/ { } <i>match </i><code>foo</code><i>, do
nothing --- empty action</i>
- /foo/ <i>match </i><code>foo</code><i>, print the record ---
omitted action</i>
-</pre>
- <p>The following types of statements are supported in <samp><span
class="command">awk</span></samp>:
-
-
-<a name="index-side-effects_002c-statements-938"></a>
-<dl><dt>Expressions<dd>Call functions or assign values to variables
-(see <a href="Expressions.html#Expressions">Expressions</a>). Executing
-this kind of statement simply computes the value of the expression.
-This is useful when the expression has side effects
-(see <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-
- <br><dt>Control statements<dd>Specify the control flow of <samp><span
class="command">awk</span></samp>
-programs. The <samp><span class="command">awk</span></samp> language gives
you C-like constructs
-(<code>if</code>, <code>for</code>, <code>while</code>, and <code>do</code>)
as well as a few
-special ones (see <a href="Statements.html#Statements">Statements</a>).
-
- <br><dt>Compound statements<dd>Consist of one or more statements enclosed
in
-curly braces. A compound statement is used in order to put several
-statements together in the body of an <code>if</code>, <code>while</code>,
<code>do</code>,
-or <code>for</code> statement.
-
- <br><dt>Input statements<dd>Use the <code>getline</code> command
-(see <a href="Getline.html#Getline">Getline</a>).
-Also supplied in <samp><span class="command">awk</span></samp> are the
<code>next</code>
-statement (see <a href="Next-Statement.html#Next-Statement">Next
Statement</a>),
-and the <code>nextfile</code> statement
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-
- <br><dt>Output statements<dd>Such as <code>print</code> and
<code>printf</code>.
-See <a href="Printing.html#Printing">Printing</a>.
-
- <br><dt>Deletion statements<dd>For deleting array elements.
-See <a href="Delete.html#Delete">Delete</a>.
-</dl>
-
- </body></html>
-
Index: manual/html_node/Adding-Code.html
===================================================================
RCS file: manual/html_node/Adding-Code.html
diff -N manual/html_node/Adding-Code.html
--- manual/html_node/Adding-Code.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,196 +0,0 @@
-<html lang="en">
-<head>
-<title>Adding Code - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Additions.html#Additions" title="Additions">
-<link rel="next" href="New-Ports.html#New-Ports" title="New Ports">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Adding-Code"></a>Next: <a rel="next" accesskey="n"
href="New-Ports.html#New-Ports">New Ports</a>,
-Up: <a rel="up" accesskey="u"
href="Additions.html#Additions">Additions</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">C.2.1 Adding New Features</h4>
-
-<!-- STARTOFRANGE adfgaw -->
-<p><a
name="index-adding_002c-features-to-_0040command_007bgawk_007d-1955"></a><!--
STARTOFRANGE fadgaw -->
-<a
name="index-features_002c-adding-to-_0040command_007bgawk_007d-1956"></a><!--
STARTOFRANGE gawadf -->
-<a
name="index-_0040command_007bgawk_007d_002c-features_002c-adding-1957"></a>You
are free to add any new features you like to <samp><span
class="command">gawk</span></samp>.
-However, if you want your changes to be incorporated into the <samp><span
class="command">gawk</span></samp>
-distribution, there are several steps that you need to take in order to
-make it possible for me to include your changes:
-
- <ol type=1 start=1>
-<li>Before building the new feature into <samp><span
class="command">gawk</span></samp> itself,
-consider writing it as an extension module
-(see <a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a>).
-If that's not possible, continue with the rest of the steps in this list.
-
- <li>Get the latest version.
-It is much easier for me to integrate changes if they are relative to
-the most recent distributed version of <samp><span
class="command">gawk</span></samp>. If your version of
-<samp><span class="command">gawk</span></samp> is very old, I may not be able
to integrate them at all.
-(See <a href="Getting.html#Getting">Getting</a>,
-for information on getting the latest version of <samp><span
class="command">gawk</span></samp>.)
-
- <li>Follow the <cite>GNU Coding Standards</cite>.
-This document describes how GNU software should be written. If you haven't
-read it, please do so, preferably <em>before</em> starting to modify
<samp><span class="command">gawk</span></samp>.
-(The <cite>GNU Coding Standards</cite> are available from
-the GNU Project's
-<samp><span class="command">ftp</span></samp>
-site, at
-<a
href="ftp://ftp.gnu.org/gnu/GNUinfo/standards.text">ftp://ftp.gnu.org/gnu/GNUinfo/standards.text</a>.
-An HTML version, suitable for reading with a WWW browser, is
-available at
-<a
href="http://www.gnu.org/prep/standards_toc.html">http://www.gnu.org/prep/standards_toc.html</a>.
-Texinfo, Info, and DVI versions are also available.)
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-coding-style-in-1958"></a><li>Use
the <samp><span class="command">gawk</span></samp> coding style.
-The C code for <samp><span class="command">gawk</span></samp> follows the
instructions in the
-<cite>GNU Coding Standards</cite>, with minor exceptions. The code is
formatted
-using the traditional “K&R” style, particularly as regards to
the placement
-of braces and the use of tabs. In brief, the coding rules for <samp><span
class="command">gawk</span></samp>
-are as follows:
-
- <ul>
-<li>Use ANSI/ISO style (prototype) function headers when defining functions.
-
- <li>Put the name of the function at the beginning of its own line.
-
- <li>Put the return type of the function, even if it is
<code>int</code>, on the
-line above the line with the name and arguments of the function.
-
- <li>Put spaces around parentheses used in control structures
-(<code>if</code>, <code>while</code>, <code>for</code>, <code>do</code>,
<code>switch</code>,
-and <code>return</code>).
-
- <li>Do not put spaces in front of parentheses used in function calls.
-
- <li>Put spaces around all C operators and after commas in function
calls.
-
- <li>Do not use the comma operator to produce multiple side effects,
except
-in <code>for</code> loop initialization and increment parts, and in macro
bodies.
-
- <li>Use real tabs for indenting, not spaces.
-
- <li>Use the “K&R” brace layout style.
-
- <li>Use comparisons against <code>NULL</code> and <code>'\0'</code>
in the conditions of
-<code>if</code>, <code>while</code>, and <code>for</code> statements, as well
as in the <code>case</code>s
-of <code>switch</code> statements, instead of just the
-plain pointer or character value.
-
- <li>Use the <code>TRUE</code>, <code>FALSE</code> and
<code>NULL</code> symbolic constants
-and the character constant <code>'\0'</code> where appropriate, instead of
<code>1</code>
-and <code>0</code>.
-
- <li>Use the <code>ISALPHA</code>, <code>ISDIGIT</code>, etc. macros,
instead of the
-traditional lowercase versions; these macros are better behaved for
-non-ASCII character sets.
-
- <li>Provide one-line descriptive comments for each function.
-
- <li>Do not use `<samp><span class="samp">#elif</span></samp>'. Many
older Unix C compilers cannot handle it.
-
- <li>Do not use the <code>alloca</code> function for allocating
memory off the stack.
-Its use causes more portability trouble than is worth the minor benefit of not
having
-to free the storage. Instead, use <code>malloc</code> and <code>free</code>.
-</ul>
-
- <blockquote>
-<b>NOTE:</b> If I have to reformat your code to follow the coding style used in
-<samp><span class="command">gawk</span></samp>, I may not bother to integrate
your changes at all.
-</blockquote>
-
- <li>Be prepared to sign the appropriate paperwork.
-In order for the FSF to distribute your changes, you must either place
-those changes in the public domain and submit a signed statement to that
-effect, or assign the copyright in your changes to the FSF.
-Both of these actions are easy to do and <em>many</em> people have done so
-already. If you have questions, please contact me
-(see <a href="Bugs.html#Bugs">Bugs</a>),
-or <a href="mailto:address@hidden">address@hidden</a>.
-
- <p><a name="index-Texinfo-1959"></a><li>Update the documentation.
-Along with your new code, please supply new sections and/or chapters
-for this Web page. If at all possible, please use real
-Texinfo, instead of just supplying unformatted ASCII text (although
-even that is better than no documentation at all).
-Conventions to be followed in <cite>GAWK: Effective AWK Programming</cite> are
provided
-after the `<samp><span class="samp">@bye</span></samp>' at the end of the
Texinfo source file.
-If possible, please update the <samp><span class="command">man</span></samp>
page as well.
-
- <p>You will also have to sign paperwork for your documentation changes.
-
- <li>Submit changes as context diffs or unified diffs.
-Use `<samp><span class="samp">diff -c -r -N</span></samp>' or `<samp><span
class="samp">diff -u -r -N</span></samp>' to compare
-the original <samp><span class="command">gawk</span></samp> source tree with
your version.
-(I find context diffs to be more readable but unified diffs are
-more compact.)
-I recommend using the GNU version of <samp><span
class="command">diff</span></samp>.
-Send the output produced by either run of <samp><span
class="command">diff</span></samp> to me when you
-submit your changes.
-(See <a href="Bugs.html#Bugs">Bugs</a>, for the electronic mail
-information.)
-
- <p>Using this format makes it easy for me to apply your changes to the
-master version of the <samp><span class="command">gawk</span></samp> source
code (using <code>patch</code>).
-If I have to apply the changes manually, using a text editor, I may
-not do so, particularly if there are lots of changes.
-
- <li>Include an entry for the <samp><span
class="file">ChangeLog</span></samp> file with your submission.
-This helps further minimize the amount of work I have to do,
-making it easier for me to accept patches.
- </ol>
-
- <p>Although this sounds like a lot of work, please remember that while you
-may write the new code, I have to maintain it and support it. If it
-isn't possible for me to do that with a minimum of extra work, then I
-probably will not.
-<!-- ENDOFRANGE adfgaw -->
-<!-- ENDOFRANGE gawadf -->
-<!-- ENDOFRANGE fadgaw -->
-
- </body></html>
-
Index: manual/html_node/Additional-Configuration-Options.html
===================================================================
RCS file: manual/html_node/Additional-Configuration-Options.html
diff -N manual/html_node/Additional-Configuration-Options.html
--- manual/html_node/Additional-Configuration-Options.html 31 Aug 2004
22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,103 +0,0 @@
-<html lang="en">
-<head>
-<title>Additional Configuration Options - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Unix-Installation.html#Unix-Installation" title="Unix
Installation">
-<link rel="prev" href="Quick-Installation.html#Quick-Installation"
title="Quick Installation">
-<link rel="next" href="Configuration-Philosophy.html#Configuration-Philosophy"
title="Configuration Philosophy">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Additional-Configuration-Options"></a>Next: <a rel="next"
accesskey="n"
href="Configuration-Philosophy.html#Configuration-Philosophy">Configuration
Philosophy</a>,
-Previous: <a rel="previous" accesskey="p"
href="Quick-Installation.html#Quick-Installation">Quick Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Unix-Installation.html#Unix-Installation">Unix Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.2.2 Additional Configuration Options</h4>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-configuring_002c-options-1879"></a><a
name="index-configuration-options_0040comma_007b_007d-_0040command_007bgawk_007d-1880"></a>
-There are several additional options you may use on the <samp><span
class="command">configure</span></samp>
-command line when compiling <samp><span class="command">gawk</span></samp>
from scratch, including:
-
-
-<a
name="index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1881"></a>
-<a
name="index-configuration-option_002c-_0040code_007b_002d_002denable_002dportals_007d-1882"></a>
-<dl><dt><code>--enable-portals</code><dd>Treat pathnames that begin
-with <samp><span class="file">/p</span></samp> as BSD portal files when doing
two-way I/O with
-the `<samp><span class="samp">|&</span></samp>' operator
-(see <a href="Portal-Files.html#Portal-Files">Portal Files</a>).
-
- <p><a
name="index-_0040code_007b_002d_002denable_002dswitch_007d-configuration-option-1883"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002denable_002dswitch_007d-1884"></a><br><dt><code>--enable-switch</code><dd>Enable
the recognition and execution of C-style <code>switch</code> statements
-in <samp><span class="command">awk</span></samp> programs
-(see <a href="Switch-Statement.html#Switch-Statement">Switch Statement</a>.)
-
- <p><a name="index-Linux-1885"></a><a
name="index-GNU_002fLinux-1886"></a><a
name="index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1887"></a><a
name="index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option_002c-configuring-_0040command_007bgawk_007d-with-1888"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1889"></a><br><dt><code>--with-included-gettext</code><dd>Use
the version of the <code>gettext</code> library that comes with <samp><span
class="command">gawk</span></samp>.
-This option should be used on systems that do <em>not</em> use version 2 (or
later)
-of the GNU C library.
-All known modern GNU/Linux systems use Glibc 2. Use this option on any other
system.
-
- <p><a
name="index-_0040code_007b_002d_002ddisable_002dlint_007d-configuration-option-1890"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dlint_007d-1891"></a><br><dt><code>--disable-lint</code><dd>This
option disables all lint checking within <code>gawk</code>. The
-<samp><span class="option">--lint</span></samp> and <samp><span
class="option">--lint-old</span></samp> options
-(see <a href="Options.html#Options">Options</a>)
-are accepted, but silently do nothing.
-Similarly, setting the <code>LINT</code> variable
-(see <a href="User_002dmodified.html#User_002dmodified">User-modified</a>)
-has no effect on the running <samp><span class="command">awk</span></samp>
program.
-
- <p>When used with GCC's automatic dead-code-elimination, this option
-cuts almost 200K bytes off the size of the <samp><span
class="command">gawk</span></samp>
-executable on GNU/Linux x86 systems. Results on other systems and
-with other compilers are likely to vary.
-Using this option may bring you some slight performance improvement.
-
- <p>Using this option will cause some of the tests in the test suite
-to fail. This option may be removed at a later date.
-
- <p><a
name="index-_0040code_007b_002d_002ddisable_002dnls_007d-configuration-option-1892"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dnls_007d-1893"></a><br><dt><code>--disable-nls</code><dd>Disable
all message-translation facilities.
-This is usually not desirable, but it may bring you some slight performance
-improvement.
-You should also use this option if <samp><span
class="option">--with-included-gettext</span></samp>
-doesn't work on your system.
-</dl>
-
- </body></html>
-
Index: manual/html_node/Additions.html
===================================================================
RCS file: manual/html_node/Additions.html
diff -N manual/html_node/Additions.html
--- manual/html_node/Additions.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-<html lang="en">
-<head>
-<title>Additions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Notes.html#Notes" title="Notes">
-<link rel="prev" href="Compatibility-Mode.html#Compatibility-Mode"
title="Compatibility Mode">
-<link rel="next" href="Dynamic-Extensions.html#Dynamic-Extensions"
title="Dynamic Extensions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Additions"></a>Next: <a rel="next" accesskey="n"
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a>,
-Up: <a rel="up" accesskey="u" href="Notes.html#Notes">Notes</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">C.2 Making Additions to <samp><span
class="command">gawk</span></samp></h3>
-
-<p>If you find that you want to enhance <samp><span
class="command">gawk</span></samp> in a significant
-fashion, you are perfectly free to do so. That is the point of having
-free software; the source code is available and you are free to change
-it as you want (see <a href="Copying.html#Copying">Copying</a>).
-
- <p>This section discusses the ways you might want to change <samp><span
class="command">gawk</span></samp>
-as well as any considerations you should bear in mind.
-
-<ul class="menu">
-<li><a accesskey="1" href="Adding-Code.html#Adding-Code">Adding Code</a>:
Adding code to the main body of
- <samp><span
class="command">gawk</span></samp>.
-<li><a accesskey="2" href="New-Ports.html#New-Ports">New Ports</a>:
Porting <samp><span class="command">gawk</span></samp> to a new
operating
- system.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Advanced-Features.html
===================================================================
RCS file: manual/html_node/Advanced-Features.html
diff -N manual/html_node/Advanced-Features.html
--- manual/html_node/Advanced-Features.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,89 +0,0 @@
-<html lang="en">
-<head>
-<title>Advanced Features - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="next" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Advanced-Features"></a>Next: <a rel="next" accesskey="n"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>,
-Previous: <a rel="previous" accesskey="p"
href="Internationalization.html#Internationalization">Internationalization</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">10 Advanced Features of <samp><span
class="command">gawk</span></samp></h2>
-
-<p><a
name="index-advanced-features_002c-network-connections_002c-See-Also-networks_002c-connections-1395"></a><!--
STARTOFRANGE gawadv -->
-<a
name="index-_0040command_007bgawk_007d_002c-features_002c-advanced-1396"></a><!--
STARTOFRANGE advgaw -->
-<a
name="index-advanced-features_002c-_0040command_007bgawk_007d-1397"></a><blockquote>
-<i>Write documentation as if whoever reads it is
-a violent psychopath who knows where you live.</i><br>
-Steve English, as quoted by Peter Langston
-</blockquote>
-
- <p>This chapter discusses advanced features in <samp><span
class="command">gawk</span></samp>.
-It's a bit of a “grab bag” of items that are otherwise unrelated
-to each other.
-First, a command-line option allows <samp><span
class="command">gawk</span></samp> to recognize
-nondecimal numbers in input data, not just in <samp><span
class="command">awk</span></samp>
-programs. Next, two-way I/O, discussed briefly in earlier parts of this
-Web page, is described in full detail, along with the basics
-of TCP/IP networking and BSD portal files. Finally, <samp><span
class="command">gawk</span></samp>
-can <dfn>profile</dfn> an <samp><span class="command">awk</span></samp>
program, making it possible to tune
-it for performance.
-
- <p><a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a>,
-discusses the ability to dynamically add new built-in functions to
-<samp><span class="command">gawk</span></samp>. As this feature is still
immature and likely to change,
-its description is relegated to an appendix.
-
-<ul class="menu">
-<li><a accesskey="1" href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal
Data</a>: Allowing nondecimal input data.
-<li><a accesskey="2"
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>:
Two-way communications with another process.
-<li><a accesskey="3"
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP Networking</a>:
Using <samp><span class="command">gawk</span></samp> for network
programming.
-<li><a accesskey="4" href="Portal-Files.html#Portal-Files">Portal Files</a>:
Using <samp><span class="command">gawk</span></samp> with BSD
portals.
-<li><a accesskey="5" href="Profiling.html#Profiling">Profiling</a>:
Profiling your <samp><span class="command">awk</span></samp> programs.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Alarm-Program.html
===================================================================
RCS file: manual/html_node/Alarm-Program.html
diff -N manual/html_node/Alarm-Program.html
--- manual/html_node/Alarm-Program.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,193 +0,0 @@
-<html lang="en">
-<head>
-<title>Alarm Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Dupword-Program.html#Dupword-Program" title="Dupword
Program">
-<link rel="next" href="Translate-Program.html#Translate-Program"
title="Translate Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Alarm-Program"></a>Next: <a rel="next" accesskey="n"
href="Translate-Program.html#Translate-Program">Translate Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Dupword-Program.html#Dupword-Program">Dupword Program</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.2 An Alarm Clock Program</h4>
-
-<p><a name="index-insomnia_002c-cure-for-1791"></a><a
name="index-Robbins_002c-Arnold-1792"></a><blockquote>
-<i>Nothing cures insomnia like a ringing alarm clock.</i><br>
-Arnold Robbins
-</blockquote>
-
-<!-- STARTOFRANGE tialarm -->
-<p><a name="index-time_002c-alarm-clock-example-program-1793"></a><!--
STARTOFRANGE alaex -->
-<a name="index-alarm-clock-example-program-1794"></a>The following program is
a simple “alarm clock” program.
-You give it a time of day and an optional message. At the specified time,
-it prints the message on the standard output. In addition, you can give it
-the number of times to repeat the message as well as a delay between
-repetitions.
-
- <p>This program uses the <code>gettimeofday</code> function from
-<a href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a>.
-
- <p>All the work is done in the <code>BEGIN</code> rule. The first part is
argument
-checking and setting of defaults: the delay, the count, and the message to
-print. If the user supplied a message without the ASCII BEL
-character (known as the “alert” character, <code>"\a"</code>),
then it is added to
-the message. (On many systems, printing the ASCII BEL generates an
-audible alert. Thus when the alarm goes off, the system calls attention
-to itself in case the user is not looking at the computer or terminal.)
-Here is the program:
-
- <p><a name="index-_0040code_007balarm_002eawk_007d-program-1795"></a>
-<pre class="example"> <!-- file eg/prog/alarm.awk -->
- # alarm.awk --- set an alarm
- #
- # Requires gettimeofday library function
- <!-- endfile -->
- <!-- file eg/prog/alarm.awk -->
- # usage: alarm time [ "message" [ count [ delay ] ] ]
-
- BEGIN \
- {
- # Initial argument sanity checking
- usage1 = "usage: alarm time ['message' [count [delay]]]"
- usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1])
-
- if (ARGC < 2) {
- print usage1 > "/dev/stderr"
- print usage2 > "/dev/stderr"
- exit 1
- } else if (ARGC == 5) {
- delay = ARGV[4] + 0
- count = ARGV[3] + 0
- message = ARGV[2]
- } else if (ARGC == 4) {
- count = ARGV[3] + 0
- message = ARGV[2]
- } else if (ARGC == 3) {
- message = ARGV[2]
- } else if (ARGV[1] !~ /[0-9]?[0-9]:[0-9][0-9]/) {
- print usage1 > "/dev/stderr"
- print usage2 > "/dev/stderr"
- exit 1
- }
-
- # set defaults for once we reach the desired time
- if (delay == 0)
- delay = 180 # 3 minutes
- if (count == 0)
- count = 5
- if (message == "")
- message = sprintf("\aIt is now %s!\a", ARGV[1])
- else if (index(message, "\a") == 0)
- message = "\a" message "\a"
- <!-- endfile -->
-</pre>
- <p>The next section of code turns the alarm time into hours and minutes,
-converts it (if necessary) to a 24-hour clock, and then turns that
-time into a count of the seconds since midnight. Next it turns the current
-time into a count of seconds since midnight. The difference between the two
-is how long to wait before setting off the alarm:
-
-<pre class="example"> <!-- file eg/prog/alarm.awk -->
- # split up alarm time
- split(ARGV[1], atime, ":")
- hour = atime[1] + 0 # force numeric
- minute = atime[2] + 0 # force numeric
-
- # get current broken down time
- gettimeofday(now)
-
- # if time given is 12-hour hours and it's after that
- # hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m.,
- # then add 12 to real hour
- if (hour < 12 && now["hour"] > hour)
- hour += 12
-
- # set target time in seconds since midnight
- target = (hour * 60 * 60) + (minute * 60)
-
- # get current time in seconds since midnight
- current = (now["hour"] * 60 * 60) + \
- (now["minute"] * 60) + now["second"]
-
- # how long to sleep for
- naptime = target - current
- if (naptime <= 0) {
- print "time is in the past!" > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-_0040command_007bsleep_007d-utility-1796"></a>Finally,
the program uses the <code>system</code> function
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>)
-to call the <samp><span class="command">sleep</span></samp> utility. The
<samp><span class="command">sleep</span></samp> utility simply pauses
-for the given number of seconds. If the exit status is not zero,
-the program assumes that <samp><span class="command">sleep</span></samp> was
interrupted and exits. If
-<samp><span class="command">sleep</span></samp> exited with an OK status
(zero), then the program prints the
-message in a loop, again using <samp><span class="command">sleep</span></samp>
to delay for however many
-seconds are necessary:
-
-<pre class="example"> <!-- file eg/prog/alarm.awk -->
- # zzzzzz..... go away if interrupted
- if (system(sprintf("sleep %d", naptime)) != 0)
- exit 1
-
- # time to notify!
- command = sprintf("sleep %d", delay)
- for (i = 1; i <= count; i++) {
- print message
- # if sleep command interrupted, go away
- if (system(command) != 0)
- break
- }
-
- exit 0
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE tialarm -->
-<!-- ENDOFRANGE alaex -->
-</body></html>
-
Index: manual/html_node/Amiga-Installation.html
===================================================================
RCS file: manual/html_node/Amiga-Installation.html
diff -N manual/html_node/Amiga-Installation.html
--- manual/html_node/Amiga-Installation.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-<html lang="en">
-<head>
-<title>Amiga Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Non_002dUnix-Installation.html#Non_002dUnix-Installation"
title="Non-Unix Installation">
-<link rel="next" href="BeOS-Installation.html#BeOS-Installation" title="BeOS
Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Amiga-Installation"></a>Next: <a rel="next" accesskey="n"
href="BeOS-Installation.html#BeOS-Installation">BeOS Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.3.1 Installing <samp><span
class="command">gawk</span></samp> on an Amiga</h4>
-
-<p><a name="index-amiga-1896"></a><a
name="index-installation_002c-amiga-1897"></a>You can install <samp><span
class="command">gawk</span></samp> on an Amiga system using a Unix emulation
-environment, available via anonymous <samp><span
class="command">ftp</span></samp> from
-<code>ftp.ninemoons.com</code> in the directory <samp><span
class="file">pub/ade/current</span></samp>.
-This includes a shell based on <samp><span
class="command">pdksh</span></samp>. The primary component of
-this environment is a Unix emulation library, <samp><span
class="file">ixemul.lib</span></samp>.
-<!-- could really use more background here, who wrote this, etc. -->
-
- <p>A more complete distribution for the Amiga is available on
-the Geek Gadgets CD-ROM, available from:
-
-<pre class="display"> CRONUS
- 1840 E. Warner Road #105-265
- Tempe, AZ 85284 USA
- US Toll Free: (800) 804-0833
- Phone: +1-602-491-0442
- FAX: +1-602-491-0048
- Email: <a href="mailto:address@hidden">address@hidden</a>
- WWW: <a href="http://www.ninemoons.com">http://www.ninemoons.com</a>
- Anonymous <samp><span class="command">ftp</span></samp> site:
<code>ftp.ninemoons.com</code>
-</pre>
- <p>Once you have the distribution, you can configure <samp><span
class="command">gawk</span></samp> simply by
-running <samp><span class="command">configure</span></samp>:
-
-<pre class="example"> configure -v m68k-amigaos
-</pre>
- <p>Then run <samp><span class="command">make</span></samp> and you should
be all set!
-If these steps do not work, please send in a bug report
-(see <a href="Bugs.html#Bugs">Bugs</a>).
-
- </body></html>
-
Index: manual/html_node/Arithmetic-Ops.html
===================================================================
RCS file: manual/html_node/Arithmetic-Ops.html
diff -N manual/html_node/Arithmetic-Ops.html
--- manual/html_node/Arithmetic-Ops.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-<html lang="en">
-<head>
-<title>Arithmetic Ops - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Conversion.html#Conversion" title="Conversion">
-<link rel="next" href="Concatenation.html#Concatenation" title="Concatenation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Arithmetic-Ops"></a>Next: <a rel="next" accesskey="n"
href="Concatenation.html#Concatenation">Concatenation</a>,
-Previous: <a rel="previous" accesskey="p"
href="Conversion.html#Conversion">Conversion</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.5 Arithmetic Operators</h3>
-
-<p><a name="index-arithmetic-operators-652"></a><a
name="index-operators_002c-arithmetic-653"></a><!-- @cindex addition -->
-<!-- @cindex subtraction -->
-<!-- @cindex multiplication -->
-<!-- @cindex division -->
-<!-- @cindex remainder -->
-<!-- @cindex quotient -->
-<!-- @cindex exponentiation -->
-
- <p>The <samp><span class="command">awk</span></samp> language uses the
common arithmetic operators when
-evaluating expressions. All of these arithmetic operators follow normal
-precedence rules and work as you would expect them to.
-
- <p>The following example uses a file named <samp><span
class="file">grades</span></samp>, which contains
-a list of student names as well as three test scores per student (it's
-a small class):
-
-<pre class="example"> Pat 100 97 58
- Sandy 84 72 93
- Chris 72 92 89
-</pre>
- <p class="noindent">This programs takes the file <samp><span
class="file">grades</span></samp> and prints the average
-of the scores:
-
-<pre class="example"> $ awk '{ sum = $2 + $3 + $4 ; avg = sum / 3
- > print $1, avg }' grades
- -| Pat 85
- -| Sandy 83
- -| Chris 84.3333
-</pre>
- <p>The following list provides the arithmetic operators in <samp><span
class="command">awk</span></samp>, in order from
-the highest precedence to the lowest:
-
- <dl>
-<dt><code>- </code><var>x</var><dd>Negation.
-
- <br><dt><code>+ </code><var>x</var><dd>Unary plus; the expression is
converted to a number.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-arithmetic-operators-and-654"></a><br><dt><var>x</var><code>
^ </code><var>y</var><dt><var>x</var><code> **
</code><var>y</var><dd>Exponentiation; <var>x</var> raised to the <var>y</var>
power. `<samp><span class="samp">2 ^ 3</span></samp>' has
-the value eight; the character sequence `<samp><span
class="samp">**</span></samp>' is equivalent to
-`<samp><span class="samp">^</span></samp>'.
-
- <br><dt><var>x</var><code> * </code><var>y</var><dd>Multiplication.
-
- <p><a name="index-troubleshooting_002c-division-655"></a><a
name="index-division-656"></a><br><dt><var>x</var><code> /
</code><var>y</var><dd>Division; because all numbers in <samp><span
class="command">awk</span></samp> are floating-point
-numbers, the result is <em>not</em> rounded to an integer—`<samp><span
class="samp">3 / 4</span></samp>' has
-the value 0.75. (It is a common mistake, especially for C programmers,
-to forget that <em>all</em> numbers in <samp><span
class="command">awk</span></samp> are floating-point,
-and that division of integer-looking constants produces a real number,
-not an integer.)
-
- <br><dt><var>x</var><code> % </code><var>y</var><dd>Remainder; further
discussion is provided in the text, just
-after this list.
-
- <br><dt><var>x</var><code> + </code><var>y</var><dd>Addition.
-
- <br><dt><var>x</var><code> - </code><var>y</var><dd>Subtraction.
-</dl>
-
- <p>Unary plus and minus have the same precedence,
-the multiplication operators all have the same precedence, and
-addition and subtraction have the same precedence.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-trunc_002dmod-operation-657"></a><a
name="index-trunc_002dmod-operation-658"></a>When computing the remainder of
<var>x</var><code> % </code><var>y</var>,
-the quotient is rounded toward zero to an integer and
-multiplied by <var>y</var>. This result is subtracted from <var>x</var>;
-this operation is sometimes known as “trunc-mod.” The following
-relation always holds:
-
-<pre class="example"> b * int(a / b) + (a % b) == a
-</pre>
- <p>One possibly undesirable effect of this definition of remainder is that
-<var>x</var><code> % </code><var>y</var> is negative if <var>x</var> is
negative. Thus:
-
-<pre class="example"> -17 % 8 = -1
-</pre>
- <p>In other <samp><span class="command">awk</span></samp> implementations,
the signedness of the remainder
-may be machine-dependent.
-<!-- !!! what does posix say? -->
-
- <p><a
name="index-portability_002c-_0040code_007b_002a_002a_007d-operator-and-659"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-660"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-661"></a><blockquote>
-<b>NOTE:</b> The POSIX standard only specifies the use of `<samp><span
class="samp">^</span></samp>'
-for exponentiation.
-For maximum portability, do not use the `<samp><span
class="samp">**</span></samp>' operator.
-</blockquote>
-
- </body></html>
-
Index: manual/html_node/Array-Example.html
===================================================================
RCS file: manual/html_node/Array-Example.html
diff -N manual/html_node/Array-Example.html
--- manual/html_node/Array-Example.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,114 +0,0 @@
-<html lang="en">
-<head>
-<title>Array Example - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Assigning-Elements.html#Assigning-Elements"
title="Assigning Elements">
-<link rel="next" href="Scanning-an-Array.html#Scanning-an-Array"
title="Scanning an Array">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Array-Example"></a>Next: <a rel="next" accesskey="n"
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a>,
-Previous: <a rel="previous" accesskey="p"
href="Assigning-Elements.html#Assigning-Elements">Assigning Elements</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.4 Basic Array Example</h3>
-
-<p>The following program takes a list of lines, each beginning with a line
-number, and prints them out in order of line number. The line numbers
-are not in order when they are first read—instead they
-are scrambled. This program sorts the lines by making an array using
-the line numbers as subscripts. The program then prints out the lines
-in sorted order of their numbers. It is a very simple program and gets
-confused upon encountering repeated numbers, gaps, or lines that don't
-begin with a number:
-
-<pre class="example"> <!-- file eg/misc/arraymax.awk -->
- {
- if ($1 > max)
- max = $1
- arr[$1] = $0
- }
-
- END {
- for (x = 1; x <= max; x++)
- print arr[x]
- }
- <!-- endfile -->
-</pre>
- <p>The first rule keeps track of the largest line number seen so far;
-it also stores each line into the array <code>arr</code>, at an index that
-is the line's number.
-The second rule runs after all the input has been read, to print out
-all the lines.
-When this program is run with the following input:
-
-<pre class="example"> <!-- file eg/misc/arraymax.data -->
- 5 I am the Five man
- 2 Who are you? The new number two!
- 4 . . . And four on the floor
- 1 Who is number one?
- 3 I three you.
- <!-- endfile -->
-</pre>
- <p class="noindent">Its output is:
-
-<pre class="example"> 1 Who is number one?
- 2 Who are you? The new number two!
- 3 I three you.
- 4 . . . And four on the floor
- 5 I am the Five man
-</pre>
- <p>If a line number is repeated, the last line with a given number overrides
-the others.
-Gaps in the line numbers can be handled with an easy improvement to the
-program's <code>END</code> rule, as follows:
-
-<pre class="example"> END {
- for (x = 1; x <= max; x++)
- if (x in arr)
- print arr[x]
- }
-</pre>
- </body></html>
-
Index: manual/html_node/Array-Intro.html
===================================================================
RCS file: manual/html_node/Array-Intro.html
diff -N manual/html_node/Array-Intro.html
--- manual/html_node/Array-Intro.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,151 +0,0 @@
-<html lang="en">
-<head>
-<title>Array Intro - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="next" href="Reference-to-Elements.html#Reference-to-Elements"
title="Reference to Elements">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Array-Intro"></a>Next: <a rel="next" accesskey="n"
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.1 Introduction to Arrays</h3>
-
-<p>The <samp><span class="command">awk</span></samp> language provides
one-dimensional arrays
-for storing groups of related strings or numbers.
-Every <samp><span class="command">awk</span></samp> array must have a name.
Array names have the same
-syntax as variable names; any valid variable name would also be a valid
-array name. But one name cannot be used in both ways (as an array and
-as a variable) in the same <samp><span class="command">awk</span></samp>
program.
-
- <p>Arrays in <samp><span class="command">awk</span></samp> superficially
resemble arrays in other programming
-languages, but there are fundamental differences. In <samp><span
class="command">awk</span></samp>, it
-isn't necessary to specify the size of an array before starting to use it.
-Additionally, any number or string in <samp><span
class="command">awk</span></samp>, not just consecutive integers,
-may be used as an array index.
-
- <p>In most other languages, arrays must be <dfn>declared</dfn> before use,
-including a specification of
-how many elements or components they contain. In such languages, the
-declaration causes a contiguous block of memory to be allocated for that
-many elements. Usually, an index in the array must be a positive integer.
-For example, the index zero specifies the first element in the array, which is
-actually stored at the beginning of the block of memory. Index one
-specifies the second element, which is stored in memory right after the
-first element, and so on. It is impossible to add more elements to the
-array, because it has room only for as many elements as given in
-the declaration.
-(Some languages allow arbitrary starting and ending
-indices—e.g., `<samp><span class="samp">15 ..
27</span></samp>'—but the size of the array is still fixed when
-the array is declared.)
-
- <p>A contiguous array of four elements might look like the following
example,
-conceptually, if the element values are 8, <code>"foo"</code>,
-<code>""</code>, and 30:
-
-<!-- NEXT ED: Use real images here -->
-<p class="noindent">Only the values are stored; the indices are implicit from
the order of
-the values. Here, 8 is the value at index zero, because 8 appears in the
-position with zero elements before it.
-
-<!-- STARTOFRANGE arrin -->
-<p><a name="index-arrays_002c-indexing-1081"></a><!-- STARTOFRANGE inarr -->
-<a name="index-indexing-arrays-1082"></a><a
name="index-associative-arrays-1083"></a><a
name="index-arrays_002c-associative-1084"></a>Arrays in <samp><span
class="command">awk</span></samp> are different—they are
<dfn>associative</dfn>. This means
-that each array is a collection of pairs: an index and its corresponding
-array element value:
-
-<pre class="example"> <span class="roman">Element</span> 3 <span
class="roman">Value</span> 30
- <span class="roman">Element</span> 1 <span class="roman">Value</span>
"foo"
- <span class="roman">Element</span> 0 <span class="roman">Value</span>
8
- <span class="roman">Element</span> 2 <span class="roman">Value</span>
""
-</pre>
- <p class="noindent">The pairs are shown in jumbled order because their
order is irrelevant.
-
- <p>One advantage of associative arrays is that new pairs can be added
-at any time. For example, suppose a tenth element is added to the array
-whose value is <code>"number ten"</code><!-- /@w -->. The result is:
-
-<pre class="example"> <span class="roman">Element</span> 10 <span
class="roman">Value</span> "number ten"
- <span class="roman">Element</span> 3 <span class="roman">Value</span>
30
- <span class="roman">Element</span> 1 <span class="roman">Value</span>
"foo"
- <span class="roman">Element</span> 0 <span class="roman">Value</span>
8
- <span class="roman">Element</span> 2 <span class="roman">Value</span>
""
-</pre>
- <p class="noindent"><a name="index-sparse-arrays-1085"></a><a
name="index-arrays_002c-sparse-1086"></a>Now the array is <dfn>sparse</dfn>,
which just means some indices are missing.
-It has elements 0–3 and 10, but doesn't have elements 4, 5, 6, 7, 8, or
9.
-
- <p>Another consequence of associative arrays is that the indices don't
-have to be positive integers. Any number, or even a string, can be
-an index. For example, the following is an array that translates words from
-English to French:
-
-<pre class="example"> <span class="roman">Element</span> "dog" <span
class="roman">Value</span> "chien"
- <span class="roman">Element</span> "cat" <span class="roman">Value</span>
"chat"
- <span class="roman">Element</span> "one" <span class="roman">Value</span>
"un"
- <span class="roman">Element</span> 1 <span class="roman">Value</span>
"un"
-</pre>
- <p class="noindent">Here we decided to translate the number one in both
spelled-out and
-numeric form—thus illustrating that a single array can have both
-numbers and strings as indices.
-In fact, array subscripts are always strings; this is discussed
-in more detail in
-<a href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a>.
-Here, the number <code>1</code> isn't double-quoted, since <samp><span
class="command">awk</span></samp>
-automatically converts it to a string.
-
- <p><a name="index-case-sensitivity_002c-array-indices-and-1087"></a><a
name="index-arrays_002c-_0040code_007bIGNORECASE_007d-variable-and-1088"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable_002c-array-subscripts-and-1089"></a>The
value of <code>IGNORECASE</code> has no effect upon array subscripting.
-The identical string value used to store an array element must be used
-to retrieve it.
-When <samp><span class="command">awk</span></samp> creates an array (e.g.,
with the <code>split</code>
-built-in function),
-that array's indices are consecutive integers starting at one.
-(See <a href="String-Functions.html#String-Functions">String Functions</a>.)
-
- <p><samp><span class="command">awk</span></samp>'s arrays are
efficient—the time to access an element
-is independent of the number of elements in the array.
-<!-- ENDOFRANGE arrin -->
-<!-- ENDOFRANGE inarr -->
-
- </body></html>
-
Index: manual/html_node/Array-Sorting.html
===================================================================
RCS file: manual/html_node/Array-Sorting.html
diff -N manual/html_node/Array-Sorting.html
--- manual/html_node/Array-Sorting.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,151 +0,0 @@
-<html lang="en">
-<head>
-<title>Array Sorting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Multi_002dscanning.html#Multi_002dscanning"
title="Multi-scanning">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Array-Sorting"></a>Previous: <a rel="previous" accesskey="p"
href="Multi_002dscanning.html#Multi_002dscanning">Multi-scanning</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.11 Sorting Array Values and Indices with <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-arrays_002c-sorting-1132"></a><a
name="index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1133"></a><a
name="index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029_002c-arrays_0040comma_007b_007d-sorting-1134"></a><a
name="index-sort-function_002c-arrays_002c-sorting-1135"></a>The order in
which an array is scanned with a `<samp><span class="samp">for (i in
array)</span></samp>'
-loop is essentially arbitrary.
-In most <samp><span class="command">awk</span></samp> implementations, sorting
an array requires
-writing a <code>sort</code> function.
-While this can be educational for exploring different sorting algorithms,
-usually that's not the point of the program.
-<samp><span class="command">gawk</span></samp> provides the built-in
<code>asort</code>
-and <code>asorti</code> functions
-(see <a href="String-Functions.html#String-Functions">String Functions</a>)
-for sorting arrays. For example:
-
-<pre class="example"> <var>populate the array</var> data
- n = asort(data)
- for (i = 1; i <= n; i++)
- <var>do something with</var> data[i]
-</pre>
- <p>After the call to <code>asort</code>, the array <code>data</code> is
indexed from 1
-to some number <var>n</var>, the total number of elements in
<code>data</code>.
-(This count is <code>asort</code>'s return value.)
-<code>data[1]</code> <= <code>data[2]</code> <= <code>data[3]</code>,
and so on.
-The comparison of array elements is done
-using <samp><span class="command">gawk</span></samp>'s usual comparison rules
-(see <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>).
-
- <p><a
name="index-side-effects_002c-_0040code_007basort_007d-function-1136"></a>An
important side effect of calling <code>asort</code> is that
-<em>the array's original indices are irrevocably lost</em>.
-As this isn't always desirable, <code>asort</code> accepts a
-second argument:
-
-<pre class="example"> <var>populate the array</var> source
- n = asort(source, dest)
- for (i = 1; i <= n; i++)
- <var>do something with</var> dest[i]
-</pre>
- <p>In this case, <samp><span class="command">gawk</span></samp> copies the
<code>source</code> array into the
-<code>dest</code> array and then sorts <code>dest</code>, destroying its
indices.
-However, the <code>source</code> array is not affected.
-
- <p>Often, what's needed is to sort on the values of the <em>indices</em>
-instead of the values of the elements.
-To do that, starting with <samp><span class="command">gawk</span></samp>
3.1.2, use the
-<code>asorti</code> function. The interface is identical to that of
-<code>asort</code>, except that the index values are used for sorting, and
-become the values of the result array:
-
-<pre class="example"> { source[$0] = some_func($0) }
-
- END {
- n = asorti(source, dest)
- for (i = 1; i <= n; i++) {
- <var>do something with</var> dest[i] <i>Work with
sorted indices directly</i>
- ...
- <var>do something with</var> source[dest[i]] <i>Access
original array via sorted indices</i>
- }
- }
-</pre>
- <p>If your version of <samp><span class="command">gawk</span></samp> is
3.1.0 or 3.1.1, you don't
-have <code>asorti</code>. Instead, use a helper array
-to hold the sorted index values, and then access the original array's
-elements. It works in the following way:
-
-<pre class="example"> <var>populate the array</var> data
- # copy indices
- j = 1
- for (i in data) {
- ind[j] = i # index value becomes element value
- j++
- }
- n = asort(ind) # index values are now sorted
- for (i = 1; i <= n; i++) {
- <var>do something with</var> ind[i] <i>Work with sorted
indices directly</i>
- ...
- <var>do something with</var> data[ind[i]] <i>Access original
array via sorted indices</i>
- }
-</pre>
- <p>Sorting the array by replacing the indices provides maximal flexibility.
-To traverse the elements in decreasing order, use a loop that goes from
-<var>n</var> down to 1, either over the elements or over the indices.
-
- <p><a name="index-reference-counting_002c-sorting-arrays-1137"></a>Copying
array indices and elements isn't expensive in terms of memory.
-Internally, <samp><span class="command">gawk</span></samp> maintains
<dfn>reference counts</dfn> to data.
-For example, when <code>asort</code> copies the first array to the second one,
-there is only one copy of the original array elements' data, even though
-both arrays use the values. Similarly, when copying the indices from
-<code>data</code> to <code>ind</code>, there is only one copy of the actual
index
-strings.
-
-<!-- Document It And Call It A Feature. Sigh. -->
-<p><a
name="index-arrays_002c-sorting_002c-_0040code_007bIGNORECASE_007d-variable-and-1138"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable_002c-array-sorting-and-1139"></a>We
said previously that comparisons are done using <samp><span
class="command">gawk</span></samp>'s
-“usual comparison rules.” Because <code>IGNORECASE</code> affects
-string comparisons, the value of <code>IGNORECASE</code> also
-affects sorting for both <code>asort</code> and <code>asorti</code>.
-Caveat Emptor.
-<!-- ENDOFRANGE arrs -->
-
- </body></html>
-
Index: manual/html_node/Arrays.html
===================================================================
RCS file: manual/html_node/Arrays.html
diff -N manual/html_node/Arrays.html
--- manual/html_node/Arrays.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>Arrays - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link rel="next" href="Functions.html#Functions" title="Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Arrays"></a>Next: <a rel="next" accesskey="n"
href="Functions.html#Functions">Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">7 Arrays in <samp><span
class="command">awk</span></samp></h2>
-
-<!-- STARTOFRANGE arrs -->
-<p><a name="index-arrays-1075"></a>
-An <dfn>array</dfn> is a table of values called <dfn>elements</dfn>. The
-elements of an array are distinguished by their indices. <dfn>Indices</dfn>
-may be either numbers or strings.
-
- <p>This chapter describes how arrays work in <samp><span
class="command">awk</span></samp>,
-how to use array elements, how to scan through every element in an array,
-and how to remove array elements.
-It also describes how <samp><span class="command">awk</span></samp> simulates
multidimensional
-arrays, as well as some of the less obvious points about array usage.
-The chapter finishes with a discussion of <samp><span
class="command">gawk</span></samp>'s facility
-for sorting an array based on its indices.
-
- <p><a name="index-variables_002c-names-of-1076"></a><a
name="index-functions_002c-names-of-1077"></a><a
name="index-arrays_002c-names-of-1078"></a><a
name="index-names_002c-arrays_002fvariables-1079"></a><a
name="index-namespace-issues-1080"></a><samp><span
class="command">awk</span></samp> maintains a single set
-of names that may be used for naming variables, arrays, and functions
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>).
-Thus, you cannot have a variable and an array with the same name in the
-same <samp><span class="command">awk</span></samp> program.
-
-<ul class="menu">
-<li><a accesskey="1" href="Array-Intro.html#Array-Intro">Array Intro</a>:
Introduction to Arrays
-<li><a accesskey="2"
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>: How to examine one element of an array.
-<li><a accesskey="3"
href="Assigning-Elements.html#Assigning-Elements">Assigning Elements</a>:
How to change an element of an array.
-<li><a accesskey="4" href="Array-Example.html#Array-Example">Array
Example</a>: Basic Example of an Array
-<li><a accesskey="5" href="Scanning-an-Array.html#Scanning-an-Array">Scanning
an Array</a>: A variation of the <code>for</code> statement. It
- loops through the indices of an array's
- existing elements.
-<li><a accesskey="6" href="Delete.html#Delete">Delete</a>:
The <code>delete</code> statement removes an element
- from an array.
-<li><a accesskey="7"
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a>: How to use numbers as subscripts in
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="8"
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a>: Using Uninitialized variables as subscripts.
-<li><a accesskey="9"
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a>:
Emulating multidimensional arrays in
- <samp><span class="command">awk</span></samp>.
-<li><a href="Multi_002dscanning.html#Multi_002dscanning">Multi-scanning</a>:
Scanning multidimensional arrays.
-<li><a href="Array-Sorting.html#Array-Sorting">Array Sorting</a>:
Sorting array values and indices.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Assert-Function.html
===================================================================
RCS file: manual/html_node/Assert-Function.html
diff -N manual/html_node/Assert-Function.html
--- manual/html_node/Assert-Function.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,155 +0,0 @@
-<html lang="en">
-<head>
-<title>Assert Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Strtonum-Function.html#Strtonum-Function"
title="Strtonum Function">
-<link rel="next" href="Round-Function.html#Round-Function" title="Round
Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Assert-Function"></a>Next: <a rel="next" accesskey="n"
href="Round-Function.html#Round-Function">Round Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="Strtonum-Function.html#Strtonum-Function">Strtonum Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.3 Assertions</h4>
-
-<!-- STARTOFRANGE asse -->
-<p><a name="index-assertions-1620"></a><!-- STARTOFRANGE assef -->
-<a
name="index-_0040code_007bassert_007d-function-_0028C-library_0029-1621"></a><!--
STARTOFRANGE libfass -->
-<a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-assertions-1622"></a><!--
STARTOFRANGE flibass -->
-<a name="index-functions_002c-library_002c-assertions-1623"></a><a
name="index-_0040command_007bawk_007d-programs_002c-lengthy_002c-assertions-1624"></a>When
writing large programs, it is often useful to know
-that a condition or set of conditions is true. Before proceeding with a
-particular computation, you make a statement about what you believe to be
-the case. Such a statement is known as an
-<dfn>assertion</dfn>. The C language provides an
<code><assert.h></code> header file
-and corresponding <code>assert</code> macro that the programmer can use to make
-assertions. If an assertion fails, the <code>assert</code> macro arranges to
-print a diagnostic message describing the condition that should have
-been true but was not, and then it kills the program. In C, using
-<code>assert</code> looks this:
-
-<pre class="example"> #include <assert.h>
-
- int myfunc(int a, double b)
- {
- assert(a <= 5 && b >= 17.1);
- ...
- }
-</pre>
- <p>If the assertion fails, the program prints a message similar to this:
-
-<pre class="example"> prog.c:5: assertion failed: a <= 5 && b
>= 17.1
-</pre>
- <p><a
name="index-_0040code_007bassert_007d-user_002ddefined-function-1625"></a>The C
language makes it possible to turn the condition into a string for use
-in printing the diagnostic message. This is not possible in <samp><span
class="command">awk</span></samp>, so
-this <code>assert</code> function also requires a string version of the
condition
-that is being tested.
-Following is the function:
-
-<pre class="example"> <!-- file eg/lib/assert.awk -->
- # assert --- assert that a condition is true. Otherwise exit.
- <!-- endfile -->
- <!-- file eg/lib/assert.awk -->
- function assert(condition, string)
- {
- if (! condition) {
- printf("%s:%d: assertion failed: %s\n",
- FILENAME, FNR, string) > "/dev/stderr"
- _assert_exit = 1
- exit 1
- }
- }
-
- END {
- if (_assert_exit)
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p>The <code>assert</code> function tests the <code>condition</code>
parameter. If it
-is false, it prints a message to standard error, using the <code>string</code>
-parameter to describe the failed condition. It then sets the variable
-<code>_assert_exit</code> to one and executes the <code>exit</code> statement.
-The <code>exit</code> statement jumps to the <code>END</code> rule. If the
<code>END</code>
-rules finds <code>_assert_exit</code> to be true, it exits immediately.
-
- <p>The purpose of the test in the <code>END</code> rule is to
-keep any other <code>END</code> rules from running. When an assertion fails,
the
-program should exit immediately.
-If no assertions fail, then <code>_assert_exit</code> is still
-false when the <code>END</code> rule is run normally, and the rest of the
-program's <code>END</code> rules execute.
-For all of this to work correctly, <samp><span
class="file">assert.awk</span></samp> must be the
-first source file read by <samp><span class="command">awk</span></samp>.
-The function can be used in a program in the following way:
-
-<pre class="example"> function myfunc(a, b)
- {
- assert(a <= 5 && b >= 17.1, "a <= 5 && b
>= 17.1")
- ...
- }
-</pre>
- <p class="noindent">If the assertion fails, you see a message similar to
the following:
-
-<pre class="example"> mydata:1357: assertion failed: a <= 5 &&
b >= 17.1
-</pre>
- <p><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1626"></a>There
is a small problem with this version of <code>assert</code>.
-An <code>END</code> rule is automatically added
-to the program calling <code>assert</code>. Normally, if a program consists
-of just a <code>BEGIN</code> rule, the input files and/or standard input are
-not read. However, now that the program has an <code>END</code> rule,
<samp><span class="command">awk</span></samp>
-attempts to read the input data files or standard input
-(see <a href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using
BEGIN/END</a>),
-most likely causing the program to hang as it waits for input.
-
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1627"></a>There
is a simple workaround to this:
-make sure the <code>BEGIN</code> rule always ends
-with an <code>exit</code> statement.
-<!-- ENDOFRANGE asse -->
-<!-- ENDOFRANGE assef -->
-<!-- ENDOFRANGE flibass -->
-<!-- ENDOFRANGE libfass -->
-
- </body></html>
-
Index: manual/html_node/Assigning-Elements.html
===================================================================
RCS file: manual/html_node/Assigning-Elements.html
diff -N manual/html_node/Assigning-Elements.html
--- manual/html_node/Assigning-Elements.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-<html lang="en">
-<head>
-<title>Assigning Elements - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Reference-to-Elements.html#Reference-to-Elements"
title="Reference to Elements">
-<link rel="next" href="Array-Example.html#Array-Example" title="Array Example">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Assigning-Elements"></a>Next: <a rel="next" accesskey="n"
href="Array-Example.html#Array-Example">Array Example</a>,
-Previous: <a rel="previous" accesskey="p"
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.3 Assigning Array Elements</h3>
-
-<p><a name="index-arrays_002c-elements_002c-assigning-1094"></a><a
name="index-elements-in-arrays_002c-assigning-1095"></a>
-Array elements can be assigned values just like
-<samp><span class="command">awk</span></samp> variables:
-
-<pre class="example"> <var>array</var>[<var>subscript</var>] =
<var>value</var>
-</pre>
- <p class="noindent"><var>array</var> is the name of an array. The
expression
-<var>subscript</var> is the index of the element of the array that is
-assigned a value. The expression <var>value</var> is the value to
-assign to that element of the array.
-
- </body></html>
-
Index: manual/html_node/Assignment-Ops.html
===================================================================
RCS file: manual/html_node/Assignment-Ops.html
diff -N manual/html_node/Assignment-Ops.html
--- manual/html_node/Assignment-Ops.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,243 +0,0 @@
-<html lang="en">
-<head>
-<title>Assignment Ops - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Concatenation.html#Concatenation" title="Concatenation">
-<link rel="next" href="Increment-Ops.html#Increment-Ops" title="Increment Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Assignment-Ops"></a>Next: <a rel="next" accesskey="n"
href="Increment-Ops.html#Increment-Ops">Increment Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="Concatenation.html#Concatenation">Concatenation</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.7 Assignment Expressions</h3>
-
-<!-- STARTOFRANGE asop -->
-<p><a name="index-assignment-operators-670"></a><!-- STARTOFRANGE opas -->
-<a name="index-operators_002c-assignment-671"></a><!-- STARTOFRANGE exas -->
-<a name="index-expressions_002c-assignment-672"></a><a
name="index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_007d-operator-673"></a><a
name="index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_007d-operator-674"></a>An
<dfn>assignment</dfn> is an expression that stores a (usually different)
-value into a variable. For example, let's assign the value one to the variable
-<code>z</code>:
-
-<pre class="example"> z = 1
-</pre>
- <p>After this expression is executed, the variable <code>z</code> has the
value one.
-Whatever old value <code>z</code> had before the assignment is forgotten.
-
- <p>Assignments can also store string values. For example, the
-following stores
-the value <code>"this food is good"</code> in the variable
<code>message</code>:
-
-<pre class="example"> thing = "food"
- predicate = "good"
- message = "this " thing " is " predicate
-</pre>
- <p class="noindent"><a
name="index-side-effects_002c-assignment-expressions-675"></a>This also
illustrates string concatenation.
-The `<samp><span class="samp">=</span></samp>' sign is called an
<dfn>assignment operator</dfn>. It is the
-simplest assignment operator because the value of the righthand
-operand is stored unchanged.
-Most operators (addition, concatenation, and so on) have no effect
-except to compute a value. If the value isn't used, there's no reason to
-use the operator. An assignment operator is different; it does
-produce a value, but even if you ignore it, the assignment still
-makes itself felt through the alteration of the variable. We call this
-a <dfn>side effect</dfn>.
-
- <p><a name="index-lvalues_002frvalues-676"></a><a
name="index-rvalues_002flvalues-677"></a><a
name="index-assignment-operators_002c-lvalues_002frvalues-678"></a><a
name="index-operators_002c-assignment-679"></a>The lefthand operand of an
assignment need not be a variable
-(see <a href="Variables.html#Variables">Variables</a>); it can also be a field
-(see <a href="Changing-Fields.html#Changing-Fields">Changing Fields</a>) or
-an array element (see <a href="Arrays.html#Arrays">Arrays</a>).
-These are all called <dfn>lvalues</dfn>,
-which means they can appear on the lefthand side of an assignment operator.
-The righthand operand may be any expression; it produces the new value
-that the assignment stores in the specified variable, field, or array
-element. (Such values are called <dfn>rvalues</dfn>.)
-
- <p><a name="index-variables_002c-types-of-680"></a>It is important to note
that variables do <em>not</em> have permanent types.
-A variable's type is simply the type of whatever value it happens
-to hold at the moment. In the following program fragment, the variable
-<code>foo</code> has a numeric value at first, and a string value later on:
-
-<pre class="example"> foo = 1
- print foo
- foo = "bar"
- print foo
-</pre>
- <p class="noindent">When the second assignment gives <code>foo</code> a
string value, the fact that
-it previously had a numeric value is forgotten.
-
- <p>String values that do not begin with a digit have a numeric value of
-zero. After executing the following code, the value of <code>foo</code> is
five:
-
-<pre class="example"> foo = "a string"
- foo = foo + 5
-</pre>
- <blockquote>
-<b>NOTE:</b> Using a variable as a number and then later as a string
-can be confusing and is poor programming style. The previous two examples
-illustrate how <samp><span class="command">awk</span></samp> works,
<em>not</em> how you should write your
-programs!
-</blockquote>
-
- <p>An assignment is an expression, so it has a value—the same value
that
-is assigned. Thus, `<samp><span class="samp">z = 1</span></samp>' is an
expression with the value one.
-One consequence of this is that you can write multiple assignments together,
-such as:
-
-<pre class="example"> x = y = z = 5
-</pre>
- <p class="noindent">This example stores the value five in all three
variables
-(<code>x</code>, <code>y</code>, and <code>z</code>).
-It does so because the
-value of `<samp><span class="samp">z = 5</span></samp>', which is five, is
stored into <code>y</code> and then
-the value of `<samp><span class="samp">y = z = 5</span></samp>', which is
five, is stored into <code>x</code>.
-
- <p>Assignments may be used anywhere an expression is called for. For
-example, it is valid to write `<samp><span class="samp">x != (y =
1)</span></samp>' to set <code>y</code> to one,
-and then test whether <code>x</code> equals one. But this style tends to make
-programs hard to read; such nesting of assignments should be avoided,
-except perhaps in a one-shot program.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-681"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-682"></a>Aside
from `<samp><span class="samp">=</span></samp>', there are several other
assignment operators that
-do arithmetic with the old value of the variable. For example, the
-operator `<samp><span class="samp">+=</span></samp>' computes a new value by
adding the righthand value
-to the old value of the variable. Thus, the following assignment adds
-five to the value of <code>foo</code>:
-
-<pre class="example"> foo += 5
-</pre>
- <p class="noindent">This is equivalent to the following:
-
-<pre class="example"> foo = foo + 5
-</pre>
- <p class="noindent">Use whichever makes the meaning of your program clearer.
-
- <p>There are situations where using `<samp><span
class="samp">+=</span></samp>' (or any assignment operator)
-is <em>not</em> the same as simply repeating the lefthand operand in the
-righthand expression. For example:
-
- <p><a name="index-Rankin_002c-Pat-683"></a>
-<pre class="example"> # Thanks to Pat Rankin for this example
- BEGIN {
- foo[rand()] += 5
- for (x in foo)
- print x, foo[x]
-
- bar[rand()] = bar[rand()] + 5
- for (x in bar)
- print x, bar[x]
- }
-</pre>
- <p><a
name="index-operators_002c-assignment_002c-evaluation-order-684"></a><a
name="index-assignment-operators_002c-evaluation-order-685"></a>The indices of
<code>bar</code> are practically guaranteed to be different, because
-<code>rand</code> returns different values each time it is called.
-(Arrays and the <code>rand</code> function haven't been covered yet.
-See <a href="Arrays.html#Arrays">Arrays</a>,
-and see <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a>, for more information).
-This example illustrates an important fact about assignment
-operators: the lefthand expression is only evaluated <em>once</em>.
-It is up to the implementation as to which expression is evaluated
-first, the lefthand or the righthand.
-Consider this example:
-
-<pre class="example"> i = 1
- a[i += 2] = i + 1
-</pre>
- <p class="noindent">The value of <code>a[3]</code> could be either two or
four.
-
- <p><a
href="table_002dassign_002dops.html#table_002dassign_002dops">table-assign-ops</a>
lists the arithmetic assignment operators. In each
-case, the righthand operand is an expression whose value is converted
-to a number.
-
- <p><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-686"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-687"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-688"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-689"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-690"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-691"></a><a
name="index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-692"></a><a
name="index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-693"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-694"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-695"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-696"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-697"></a><div
class="float">
-<a name="table_002dassign_002dops"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="30%">Operator
</th><th valign="top" width="70%">Effect
-<br></th></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>+=</code> <var>increment</var> </td><td valign="top" width="70%">Adds
<var>increment</var> to the value of <var>lvalue</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>-=</code> <var>decrement</var> </td><td valign="top"
width="70%">Subtracts <var>decrement</var> from the value of <var>lvalue</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>*=</code> <var>coefficient</var> </td><td valign="top"
width="70%">Multiplies the value of <var>lvalue</var> by
<var>coefficient</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>/=</code> <var>divisor</var> </td><td valign="top" width="70%">Divides
the value of <var>lvalue</var> by <var>divisor</var>.
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>%=</code> <var>modulus</var> </td><td valign="top" width="70%">Sets
<var>lvalue</var> to its remainder by <var>modulus</var>.
-<a
name="index-_0040command_007bawk_007d-language_002c-POSIX-version-698"></a><a
name="index-POSIX-_0040command_007bawk_007d-699"></a><br></td></tr><tr
align="left"><td valign="top" width="30%"><var>lvalue</var> <code>^=</code>
<var>power</var> </td><td valign="top" width="70%">
-<br></td></tr><tr align="left"><td valign="top" width="30%"><var>lvalue</var>
<code>**=</code> <var>power</var> </td><td valign="top" width="70%">Raises
<var>lvalue</var> to the power <var>power</var>.
- <br></td></tr></table>
-<p><strong class="float-caption">Table 5.1: Arithmetic Assignment
Operators</strong></p></div>
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_002a_002a_003d_007d-operator-and-700"></a><a
name="index-portability_002c-_0040code_007b_002a_002a_003d_007d-operator-and-701"></a><blockquote>
-<b>NOTE:</b> Only the `<samp><span class="samp">^=</span></samp>' operator is
specified by POSIX.
-For maximum portability, do not use the `<samp><span
class="samp">**=</span></samp>' operator.
-</blockquote>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Syntactic Ambiguities Between
`<samp><span class="samp">/=</span></samp>' and Regular Expressions</h4>
-
-<p><a name="index-advanced-features_002c-regexp-constants-702"></a><a
name="index-dark-corner_002c-regexp-constants_002c-_0040code_007b_002f_003d_007d-operator-and-703"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-704"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-705"></a><a
name="index-regexp-constants_002c-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d_002c-_0040code_007b_002f_003d_007d-operator-and-706"></a>
-<!-- derived from email from "Nelson H. F. Beebe" <address@hidden> -->
-<!-- Date: Mon, 1 Sep 1997 13:38:35 -0600 (MDT) -->
-
- <p><a name="index-dark-corner-707"></a><a
name="index-ambiguity_002c-syntactic_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-708"></a><a
name="index-syntactic-ambiguity_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-709"></a><a
name="index-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-710"></a>There
is a syntactic ambiguity between the `<samp><span
class="samp">/=</span></samp>' assignment
-operator and regexp constants whose first character is an `<samp><span
class="samp">=</span></samp>'.
-(d.c.)
-This is most notable in commercial <samp><span
class="command">awk</span></samp> versions.
-For example:
-
-<pre class="example"> $ awk /==/ /dev/null
- error--> awk: syntax error at source line 1
- error--> context is
- error--> >>> /= <<<
- error--> awk: bailing out at source line 1
-</pre>
- <p class="noindent">A workaround is:
-
-<pre class="example"> awk '/[=]=/' /dev/null
-</pre>
- <p><samp><span class="command">gawk</span></samp> does not have this
problem,
-nor do the other
-freely available versions described in
-<a href="Other-Versions.html#Other-Versions">Other Versions</a>.
-<!-- ENDOFRANGE exas -->
-<!-- ENDOFRANGE opas -->
-<!-- ENDOFRANGE asop -->
-
- </body></html>
-
Index: manual/html_node/Assignment-Options.html
===================================================================
RCS file: manual/html_node/Assignment-Options.html
diff -N manual/html_node/Assignment-Options.html
--- manual/html_node/Assignment-Options.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-<html lang="en">
-<head>
-<title>Assignment Options - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Variables.html#Variables" title="Variables">
-<link rel="prev" href="Using-Variables.html#Using-Variables" title="Using
Variables">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Assignment-Options"></a>Previous: <a rel="previous"
accesskey="p" href="Using-Variables.html#Using-Variables">Using Variables</a>,
-Up: <a rel="up" accesskey="u"
href="Variables.html#Variables">Variables</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">5.3.2 Assigning Variables on the Command Line</h4>
-
-<p><a name="index-variables_002c-assigning-on-command-line-636"></a><a
name="index-command-line_002c-variables_0040comma_007b_007d-assigning-on-637"></a>
-Any <samp><span class="command">awk</span></samp> variable can be set by
including a <dfn>variable assignment</dfn>
-among the arguments on the command line when <samp><span
class="command">awk</span></samp> is invoked
-(see <a href="Other-Arguments.html#Other-Arguments">Other Arguments</a>).
-Such an assignment has the following form:
-
-<pre class="example"> <var>variable</var>=<var>text</var>
-</pre>
- <p><a
name="index-_0040code_007b_002dv_007d-option_002c-variables_0040comma_007b_007d-assigning-638"></a>With
it, a variable is set either at the beginning of the
-<samp><span class="command">awk</span></samp> run or in between input files.
-When the assignment is preceded with the <samp><span
class="option">-v</span></samp> option,
-as in the following:
-
-<pre class="example"> -v <var>variable</var>=<var>text</var>
-</pre>
- <p class="noindent">the variable is set at the very beginning, even before
the
-<code>BEGIN</code> rules are run. The <samp><span
class="option">-v</span></samp> option and its assignment
-must precede all the file name arguments, as well as the program text.
-(See <a href="Options.html#Options">Options</a>, for more information about
-the <samp><span class="option">-v</span></samp> option.)
-Otherwise, the variable assignment is performed at a time determined by
-its position among the input file arguments—after the processing of the
-preceding input file argument. For example:
-
-<pre class="example"> awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list
-</pre>
- <p class="noindent">prints the value of field number <code>n</code> for all
input records. Before
-the first file is read, the command line sets the variable <code>n</code>
-equal to four. This causes the fourth field to be printed in lines from
-the file <samp><span class="file">inventory-shipped</span></samp>. After the
first file has finished,
-but before the second file is started, <code>n</code> is set to two, so that
the
-second field is printed in lines from <samp><span
class="file">BBS-list</span></samp>:
-
-<pre class="example"> $ awk '{ print $n }' n=4 inventory-shipped n=2
BBS-list
- -| 15
- -| 24
- ...
- -| 555-5553
- -| 555-3412
- ...
-</pre>
- <p><a
name="index-dark-corner_002c-command_002dline-arguments-639"></a>Command-line
arguments are made available for explicit examination by
-the <samp><span class="command">awk</span></samp> program in the
<code>ARGV</code> array
-(see <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a>).
-<samp><span class="command">awk</span></samp> processes the values of
command-line assignments for escape
-sequences
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-(d.c.)
-
- </body></html>
-
Index: manual/html_node/Atari-Compiling.html
===================================================================
RCS file: manual/html_node/Atari-Compiling.html
diff -N manual/html_node/Atari-Compiling.html
--- manual/html_node/Atari-Compiling.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,89 +0,0 @@
-<html lang="en">
-<head>
-<title>Atari Compiling - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Atari-Installation.html#Atari-Installation" title="Atari
Installation">
-<link rel="next" href="Atari-Using.html#Atari-Using" title="Atari Using">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Atari-Compiling"></a>Next: <a rel="next" accesskey="n"
href="Atari-Using.html#Atari-Using">Atari Using</a>,
-Up: <a rel="up" accesskey="u"
href="Atari-Installation.html#Atari-Installation">Atari Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.4.1.1 Compiling <samp><span
class="command">gawk</span></samp> on the Atari ST</h5>
-
-<p>A proper compilation of <samp><span class="command">gawk</span></samp>
sources when <code>sizeof(int)</code>
-differs from <code>sizeof(void *)</code> requires an ISO C compiler. An initial
-port was done with <samp><span class="command">gcc</span></samp>. You may
actually prefer executables
-where <code>int</code>s are four bytes wide but the other variant works as
well.
-
- <p>You may need quite a bit of memory when trying to recompile the
<samp><span class="command">gawk</span></samp>
-sources, as some source files (<samp><span class="file">regex.c</span></samp>
in particular) are quite
-big. If you run out of memory compiling such a file, try reducing the
-optimization level for this particular file, which may help.
-
- <p><a name="index-Linux-1917"></a><a
name="index-GNU_002fLinux-1918"></a>With a reasonable shell (<samp><span
class="command">bash</span></samp> will do), you have a pretty good chance
-that the <samp><span class="command">configure</span></samp> utility will
succeed, and in particular if
-you run GNU/Linux, MiNT or a similar operating system. Otherwise
-sample versions of <samp><span class="file">config.h</span></samp> and
<samp><span class="file">Makefile.st</span></samp> are given in the
-<samp><span class="file">atari</span></samp> subdirectory and can be edited
and copied to the
-corresponding files in the main source directory. Even if
-<samp><span class="command">configure</span></samp> produces something, it
might be advisable to compare
-its results with the sample versions and possibly make adjustments.
-
- <p>Some <samp><span class="command">gawk</span></samp> source code
fragments depend on a preprocessor define
-`<samp><span class="samp">atarist</span></samp>'. This basically assumes the
TOS environment with <samp><span class="command">gcc</span></samp>.
-Modify these sections as appropriate if they are not right for your
-environment. Also see the remarks about <samp><span
class="env">AWKPATH</span></samp> and <code>envsep</code> in
-<a href="Atari-Using.html#Atari-Using">Atari Using</a>.
-
- <p>As shipped, the sample <samp><span class="file">config.h</span></samp>
claims that the <code>system</code>
-function is missing from the libraries, which is not true, and an
-alternative implementation of this function is provided in
-<samp><span class="file">unsupported/atari/system.c</span></samp>.
-Depending upon your particular combination of
-shell and operating system, you might want to change the file to indicate
-that <code>system</code> is available.
-
- </body></html>
-
Index: manual/html_node/Atari-Installation.html
===================================================================
RCS file: manual/html_node/Atari-Installation.html
diff -N manual/html_node/Atari-Installation.html
--- manual/html_node/Atari-Installation.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-<html lang="en">
-<head>
-<title>Atari Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Unsupported.html#Unsupported" title="Unsupported">
-<link rel="next" href="Tandem-Installation.html#Tandem-Installation"
title="Tandem Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Atari-Installation"></a>Next: <a rel="next" accesskey="n"
href="Tandem-Installation.html#Tandem-Installation">Tandem Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Unsupported.html#Unsupported">Unsupported</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.4.1 Installing <samp><span
class="command">gawk</span></samp> on the Atari ST</h4>
-
-<p>The Atari port is no longer supported. It is
-included for those who might want to use it but it is no longer being
-actively maintained.
-
-<!-- based on material from Michal Jaegermann <address@hidden> -->
-<p><a name="index-atari-1915"></a><a
name="index-installation_002c-atari-1916"></a>There are no substantial
differences when installing <samp><span class="command">gawk</span></samp> on
-various Atari models. Compiled <samp><span class="command">gawk</span></samp>
executables do not require
-a large amount of memory with most <samp><span
class="command">awk</span></samp> programs, and should run on all
-Motorola processor-based models (called further ST, even if that is not
-exactly right).
-
- <p>In order to use <samp><span class="command">gawk</span></samp>, you need
to have a shell, either text or
-graphics, that does not map all the characters of a command line to
-uppercase. Maintaining case distinction in option flags is very
-important (see <a href="Options.html#Options">Options</a>).
-These days this is the default and it may only be a problem for some
-very old machines. If your system does not preserve the case of option
-flags, you need to upgrade your tools. Support for I/O
-redirection is necessary to make it easy to import <samp><span
class="command">awk</span></samp> programs
-from other environments. Pipes are nice to have but not vital.
-
-<ul class="menu">
-<li><a accesskey="1" href="Atari-Compiling.html#Atari-Compiling">Atari
Compiling</a>: Compiling <samp><span
class="command">gawk</span></samp> on Atari.
-<li><a accesskey="2" href="Atari-Using.html#Atari-Using">Atari Using</a>:
Running <samp><span class="command">gawk</span></samp> on Atari.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Atari-Using.html
===================================================================
RCS file: manual/html_node/Atari-Using.html
diff -N manual/html_node/Atari-Using.html
--- manual/html_node/Atari-Using.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,106 +0,0 @@
-<html lang="en">
-<head>
-<title>Atari Using - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Atari-Installation.html#Atari-Installation" title="Atari
Installation">
-<link rel="prev" href="Atari-Compiling.html#Atari-Compiling" title="Atari
Compiling">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Atari-Using"></a>Previous: <a rel="previous" accesskey="p"
href="Atari-Compiling.html#Atari-Compiling">Atari Compiling</a>,
-Up: <a rel="up" accesskey="u"
href="Atari-Installation.html#Atari-Installation">Atari Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.4.1.2 Running <samp><span
class="command">gawk</span></samp> on the Atari ST</h5>
-
-<p>An executable version of <samp><span class="command">gawk</span></samp>
should be placed, as usual,
-anywhere in your <samp><span class="env">PATH</span></samp> where your shell
can find it.
-
- <p>While executing, the Atari version of <samp><span
class="command">gawk</span></samp> creates a number of temporary files. When
-using <samp><span class="command">gcc</span></samp> libraries for TOS,
<samp><span class="command">gawk</span></samp> looks for either of
-the environment variables, <samp><span class="env">TEMP</span></samp> or
<samp><span class="env">TMPDIR</span></samp>, in that order.
-If either one is found, its value is assumed to be a directory for
-temporary files. This directory must exist, and if you can spare the
-memory, it is a good idea to put it on a RAM drive. If neither
-<samp><span class="env">TEMP</span></samp> nor <samp><span
class="env">TMPDIR</span></samp> are found, then <samp><span
class="command">gawk</span></samp> uses the
-current directory for its temporary files.
-
- <p>The ST version of <samp><span class="command">gawk</span></samp>
searches for its program files, as described in
-<a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>.
-The default value for the <samp><span class="env">AWKPATH</span></samp>
variable is taken from
-<code>DEFPATH</code> defined in <samp><span
class="file">Makefile</span></samp>. The sample <samp><span
class="command">gcc</span></samp>/TOS
-<samp><span class="file">Makefile</span></samp> for the ST in the distribution
sets <code>DEFPATH</code> to
-<code>".,c:\lib\awk,c:\gnu\lib\awk"<!-- /@w --></code>. The search path can be
-modified by explicitly setting <samp><span class="env">AWKPATH</span></samp>
to whatever you want.
-Note that colons cannot be used on the ST to separate elements in the
-<samp><span class="env">AWKPATH</span></samp> variable, since they have
another reserved meaning.
-Instead, you must use a comma to separate elements in the path. When
-recompiling, the separating character can be modified by initializing
-the <code>envsep</code> variable in <samp><span
class="file">unsupported/atari/gawkmisc.atr</span></samp> to another
-value.
-
- <p>Although <samp><span class="command">awk</span></samp> allows great
flexibility in doing I/O redirections
-from within a program, this facility should be used with care on the ST
-running under TOS. In some circumstances, the OS routines for file-handle
-pool processing lose track of certain events, causing the
-computer to crash and requiring a reboot. Often a warm reboot is
-sufficient. Fortunately, this happens infrequently and in rather
-esoteric situations. In particular, avoid having one part of an
-<samp><span class="command">awk</span></samp> program using <code>print</code>
statements explicitly redirected
-to <samp><span class="file">/dev/stdout</span></samp>, while other
<code>print</code> statements use the
-default standard output, and a calling shell has redirected standard
-output to a file.
-<!-- 10/2000: Is this still true, now that gawk does /dev/stdout internally?
-->
-
- <p>When <samp><span class="command">gawk</span></samp> is compiled with the
ST version of <samp><span class="command">gcc</span></samp> and its
-usual libraries, it accepts both `<samp><span class="samp">/</span></samp>'
and `<samp><span class="samp">\</span></samp>' as path separators.
-While this is convenient, it should be remembered that this removes one
-technically valid character (`<samp><span class="samp">/</span></samp>') from
your file name.
-It may also create problems for external programs called via the
<code>system</code>
-function, which may not support this convention. Whenever it is possible
-that a file created by <samp><span class="command">gawk</span></samp> will be
used by some other program,
-use only backslashes. Also remember that in <samp><span
class="command">awk</span></samp>, backslashes in
-strings have to be doubled in order to get literal backslashes
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-
- </body></html>
-
Index: manual/html_node/Auto_002dset.html
===================================================================
RCS file: manual/html_node/Auto_002dset.html
diff -N manual/html_node/Auto_002dset.html
--- manual/html_node/Auto_002dset.html 31 Aug 2004 22:04:10 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,287 +0,0 @@
-<html lang="en">
-<head>
-<title>Auto-set - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din-Variables.html#Built_002din-Variables"
title="Built-in Variables">
-<link rel="prev" href="User_002dmodified.html#User_002dmodified"
title="User-modified">
-<link rel="next" href="ARGC-and-ARGV.html#ARGC-and-ARGV" title="ARGC and ARGV">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Auto_002dset"></a>Next: <a rel="next" accesskey="n"
href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a>,
-Previous: <a rel="previous" accesskey="p"
href="User_002dmodified.html#User_002dmodified">User-modified</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din-Variables.html#Built_002din-Variables">Built-in Variables</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.5.2 Built-in Variables That Convey Information</h4>
-
-<!-- STARTOFRANGE bvconi -->
-<p><a
name="index-built_002din-variables_002c-conveying-information-1041"></a><!--
STARTOFRANGE vbconi -->
-<a
name="index-variables_002c-built_002din_002c-conveying-information-1042"></a>The
following is an alphabetical list of variables that <samp><span
class="command">awk</span></samp>
-sets automatically on certain occasions in order to provide
-information to your program. The variables that are specific to
-<samp><span class="command">gawk</span></samp> are marked with a pound
sign (`<samp><span class="samp">#</span></samp>').<!-- /@w -->
-
-
-<a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1043"></a>
-<a name="index-arguments_002c-command_002dline-1044"></a>
-<a name="index-command-line_002c-arguments-1045"></a>
-<dl><dt><code>ARGC</code><span class="roman">,</span><code> ARGV</code><dd>The
command-line arguments available to <samp><span
class="command">awk</span></samp> programs are stored in
-an array called <code>ARGV</code>. <code>ARGC</code> is the number of
command-line
-arguments present. See <a href="Other-Arguments.html#Other-Arguments">Other
Arguments</a>.
-Unlike most <samp><span class="command">awk</span></samp> arrays,
-<code>ARGV</code> is indexed from 0 to <code>ARGC</code> − 1.
-In the following example:
-
- <pre class="example"> $ awk 'BEGIN {
- > for (i = 0; i < ARGC; i++)
- > print ARGV[i]
- > }' inventory-shipped BBS-list
- -| awk
- -| inventory-shipped
- -| BBS-list
- </pre>
- <p class="noindent"><code>ARGV[0]</code> contains <code>"awk"</code>,
<code>ARGV[1]</code>
-contains <code>"inventory-shipped"</code>, and <code>ARGV[2]</code> contains
-<code>"BBS-list"</code>. The value of <code>ARGC</code> is three, one more
than the
-index of the last element in <code>ARGV</code>, because the elements are
numbered
-from zero.
-
- <p><a
name="index-programming-conventions_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1046"></a>The
names <code>ARGC</code> and <code>ARGV</code>, as well as the convention of
indexing
-the array from 0 to <code>ARGC</code> − 1, are derived from the C
language's
-method of accessing command-line arguments.
-
- <p>The value of <code>ARGV[0]</code> can vary from system to system.
-Also, you should note that the program text is <em>not</em> included in
-<code>ARGV</code>, nor are any of <samp><span
class="command">awk</span></samp>'s command-line options.
-See <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a>, for
information
-about how <samp><span class="command">awk</span></samp> uses these variables.
-
- <p><a name="index-_0040code_007bARGIND_007d-variable-1047"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGIND_007d-variable-1048"></a><br><dt><code>ARGIND
#</code><dd>The index in <code>ARGV</code> of the current file being
processed.
-Every time <samp><span class="command">gawk</span></samp> opens a new data
file for processing, it sets
-<code>ARGIND</code> to the index in <code>ARGV</code> of the file name.
-When <samp><span class="command">gawk</span></samp> is processing the input
files,
-`<samp><span class="samp">FILENAME == ARGV[ARGIND]</span></samp>' is always
true.
-
- <p><a
name="index-files_002c-processing_0040comma_007b_007d-_0040code_007bARGIND_007d-variable-and-1049"></a>This
variable is useful in file processing; it allows you to tell how far
-along you are in the list of data files as well as to distinguish between
-successive instances of the same file name on the command line.
-
- <p><a
name="index-_0040value_007bFN_007ds_002c-distinguishing-1050"></a>While you can
change the value of <code>ARGIND</code> within your <samp><span
class="command">awk</span></samp>
-program, <samp><span class="command">gawk</span></samp> automatically sets it
to a new value when the
-next file is opened.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-it is not special.
-
- <p><a name="index-_0040code_007bENVIRON_007d-variable-1051"></a><a
name="index-environment-variables-1052"></a><br><dt><code>ENVIRON</code><dd>An
associative array that contains the values of the environment. The array
-indices are the environment variable names; the elements are the values of
-the particular environment variables. For example,
-<code>ENVIRON["HOME"]</code> might be <samp><span
class="file">/home/arnold</span></samp>. Changing this array
-does not affect the environment passed on to any programs that
-<samp><span class="command">awk</span></samp> may spawn via redirection or the
<code>system</code> function.
-<!-- (In a future version of @command{gawk}, it may do so.) -->
-
- <p>Some operating systems may not have environment variables.
-On such systems, the <code>ENVIRON</code> array is empty (except for
-<code>ENVIRON["AWKPATH"]</code><!-- /@w -->,
-see <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>).
-
- <p><a name="index-_0040code_007bERRNO_007d-variable-1053"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bERRNO_007d-variable-1054"></a><a
name="index-error-handling_002c-_0040code_007bERRNO_007d-variable-and-1055"></a><br><dt><code>ERRNO
#</code><dd>If a system error occurs during a redirection for
<code>getline</code>,
-during a read for <code>getline</code>, or during a <code>close</code>
operation,
-then <code>ERRNO</code> contains a string describing the error.
-
- <p><code>ERRNO</code> works similarly to the C variable
<code>errno</code>.
-In particular <samp><span class="command">gawk</span></samp> <em>never</em>
clears it (sets it
-to zero or <code>""</code>). Thus, you should only expect its value
-to be meaningful when an I/O operation returns a failure
-value, such as <code>getline</code> returning −1.
-You are, of course, free to clear it yourself before doing an
-I/O operation.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-it is not special.
-
- <p><a name="index-_0040code_007bFILENAME_007d-variable-1056"></a><a
name="index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-1057"></a><br><dt><code>FILENAME</code><dd>The
name of the file that <samp><span class="command">awk</span></samp> is
currently reading.
-When no data files are listed on the command line, <samp><span
class="command">awk</span></samp> reads
-from the standard input and <code>FILENAME</code> is set to <code>"-"</code>.
-<code>FILENAME</code> is changed each time a new file is read
-(see <a href="Reading-Files.html#Reading-Files">Reading Files</a>).
-Inside a <code>BEGIN</code> rule, the value of <code>FILENAME</code> is
-<code>""</code>, since there are no input files being processed
-yet.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-(d.c.)
-Note, though, that using <code>getline</code>
-(see <a href="Getline.html#Getline">Getline</a>)
-inside a <code>BEGIN</code> rule can give
-<code>FILENAME</code> a value.
-
- <p><a
name="index-_0040code_007bFNR_007d-variable-1058"></a><br><dt><code>FNR</code><dd>The
current record number in the current file. <code>FNR</code> is
-incremented each time a new record is read
-(see <a href="Getline.html#Getline">Getline</a>). It is reinitialized
-to zero each time a new input file is started.
-
- <p><a
name="index-_0040code_007bNF_007d-variable-1059"></a><br><dt><code>NF</code><dd>The
number of fields in the current input record.
-<code>NF</code> is set each time a new record is read, when a new field is
-created or when <code>$0</code> changes (see <a
href="Fields.html#Fields">Fields</a>).
-
- <p>Unlike most of the variables described in this
-section,
-assigning a value to <code>NF</code> has the potential to affect
-<samp><span class="command">awk</span></samp>'s internal workings. In
particular, assignments
-to <code>NF</code> can be used to create or remove fields from the
-current record: See <a href="Changing-Fields.html#Changing-Fields">Changing
Fields</a>.
-
- <p><a
name="index-_0040code_007bNR_007d-variable-1060"></a><br><dt><code>NR</code><dd>The
number of input records <samp><span class="command">awk</span></samp> has
processed since
-the beginning of the program's execution
-(see <a href="Records.html#Records">Records</a>).
-<code>NR</code> is incremented each time a new record is read.
-
- <p><a name="index-_0040code_007bPROCINFO_007d-array-1061"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bPROCINFO_007d-array-1062"></a><br><dt><code>PROCINFO
#</code><dd>The elements of this array provide access to information about the
-running <samp><span class="command">awk</span></samp> program.
-The following elements (listed alphabetically)
-are guaranteed to be available:
-
- <dl>
-<dt><code>PROCINFO["egid"]</code><dd>The value of the <code>getegid</code>
system call.
-
- <br><dt><code>PROCINFO["euid"]</code><dd>The value of the
<code>geteuid</code> system call.
-
- <br><dt><code>PROCINFO["FS"]</code><dd>This is
-<code>"FS"</code> if field splitting with <code>FS</code> is in effect, or it
is
-<code>"FIELDWIDTHS"</code> if field splitting with <code>FIELDWIDTHS</code> is
in effect.
-
- <br><dt><code>PROCINFO["gid"]</code><dd>The value of the
<code>getgid</code> system call.
-
- <br><dt><code>PROCINFO["pgrpid"]</code><dd>The process group ID of
the current process.
-
- <br><dt><code>PROCINFO["pid"]</code><dd>The process ID of the
current process.
-
- <br><dt><code>PROCINFO["ppid"]</code><dd>The parent process ID of
the current process.
-
- <br><dt><code>PROCINFO["uid"]</code><dd>The value of the
<code>getuid</code> system call.
-
- <br><dt><code>PROCINFO["version"]</code><dd>The version of
<samp><span class="command">gawk</span></samp>. This is available from
-version 3.1.4 and later.
-</dl>
-
- <p>On some systems, there may be elements in the array,
<code>"group1"</code>
-through <code>"group</code><var>N</var><code>"</code> for some <var>N</var>.
<var>N</var> is the number of
-supplementary groups that the process has. Use the <code>in</code> operator
-to test for these elements
-(see <a href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>).
-
- <p>This array is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-it is not special.
-
- <p><a
name="index-_0040code_007bRLENGTH_007d-variable-1063"></a><br><dt><code>RLENGTH</code><dd>The
length of the substring matched by the
-<code>match</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-<code>RLENGTH</code> is set by invoking the <code>match</code> function. Its
value
-is the length of the matched string, or −1 if no match is found.
-
- <p><a
name="index-_0040code_007bRSTART_007d-variable-1064"></a><br><dt><code>RSTART</code><dd>The
start-index in characters of the substring that is matched by the
-<code>match</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-<code>RSTART</code> is set by invoking the <code>match</code> function. Its
value
-is the position of the string where the matched substring starts, or zero
-if no match was found.
-
- <p><a name="index-_0040code_007bRT_007d-variable-1065"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRT_007d-variable-1066"></a><br><dt><code>RT
#</code><dd>This is set each time a record is read. It contains the input text
-that matched the text denoted by <code>RS</code>, the record separator.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-it is not special.
-</dl>
- <!-- ENDOFRANGE bvconi -->
-<!-- ENDOFRANGE vbconi -->
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Changing <code>NR</code> and
<code>FNR</code></h4>
-
-<p><a name="index-_0040code_007bNR_007d-variable_002c-changing-1067"></a><a
name="index-_0040code_007bFNR_007d-variable_002c-changing-1068"></a><a
name="index-advanced-features_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1069"></a><a
name="index-dark-corner_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1070"></a><samp><span
class="command">awk</span></samp> increments <code>NR</code> and
<code>FNR</code>
-each time it reads a record, instead of setting them to the absolute
-value of the number of records read. This means that a program can
-change these variables and their new values are incremented for
-each record.
-(d.c.)
-This is demonstrated in the following example:
-
-<pre class="example"> $ echo '1
- > 2
- > 3
- > 4' | awk 'NR == 2 { NR = 17 }
- > { print NR }'
- -| 1
- -| 17
- -| 18
- -| 19
-</pre>
- <p class="noindent">Before <code>FNR</code> was added to the <samp><span
class="command">awk</span></samp> language
-(see <a href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a>),
-many <samp><span class="command">awk</span></samp> programs used this feature
to track the number of
-records in a file by resetting <code>NR</code> to zero when
<code>FILENAME</code>
-changed.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Some early implementations of Unix <samp><span
class="command">awk</span></samp> initialized
-<code>FILENAME</code> to <code>"-"</code>, even if there were data files to be
-processed. This behavior was incorrect and should not be relied
-upon in your programs.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/BEGIN_002fEND.html
===================================================================
RCS file: manual/html_node/BEGIN_002fEND.html
diff -N manual/html_node/BEGIN_002fEND.html
--- manual/html_node/BEGIN_002fEND.html 31 Aug 2004 22:04:10 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-<html lang="en">
-<head>
-<title>BEGIN/END - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Pattern-Overview.html#Pattern-Overview" title="Pattern
Overview">
-<link rel="prev" href="Ranges.html#Ranges" title="Ranges">
-<link rel="next" href="Empty.html#Empty" title="Empty">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="BEGIN_002fEND"></a>Next: <a rel="next" accesskey="n"
href="Empty.html#Empty">Empty</a>,
-Previous: <a rel="previous" accesskey="p"
href="Ranges.html#Ranges">Ranges</a>,
-Up: <a rel="up" accesskey="u"
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.1.4 The <code>BEGIN</code> and <code>END</code>
Special Patterns</h4>
-
-<!-- STARTOFRANGE beg -->
-<p><a name="index-_0040code_007bBEGIN_007d-pattern-912"></a><!-- STARTOFRANGE
end -->
-<a name="index-_0040code_007bEND_007d-pattern-913"></a>All the patterns
described so far are for matching input records.
-The <code>BEGIN</code> and <code>END</code> special patterns are different.
-They supply startup and cleanup actions for <samp><span
class="command">awk</span></samp> programs.
-<code>BEGIN</code> and <code>END</code> rules must have actions; there is no
default
-action for these rules because there is no current record when they run.
-<code>BEGIN</code> and <code>END</code> rules are often referred to as
-“<code>BEGIN</code> and <code>END</code> blocks” by long-time
<samp><span class="command">awk</span></samp>
-programmers.
-
-<ul class="menu">
-<li><a accesskey="1" href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using
BEGIN/END</a>: How and why to use BEGIN/END rules.
-<li><a accesskey="2"
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a>: I/O issues in BEGIN/END rules.
-</ul>
-
- </body></html>
-
Index: manual/html_node/BTL.html
===================================================================
RCS file: manual/html_node/BTL.html
diff -N manual/html_node/BTL.html
--- manual/html_node/BTL.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-<html lang="en">
-<head>
-<title>BTL - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Language-History.html#Language-History" title="Language
History">
-<link rel="prev" href="POSIX.html#POSIX" title="POSIX">
-<link rel="next" href="POSIX_002fGNU.html#POSIX_002fGNU" title="POSIX/GNU">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="BTL"></a>Next: <a rel="next" accesskey="n"
href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a>,
-Previous: <a rel="previous" accesskey="p"
href="POSIX.html#POSIX">POSIX</a>,
-Up: <a rel="up" accesskey="u"
href="Language-History.html#Language-History">Language History</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">A.4 Extensions in the Bell Laboratories <samp><span
class="command">awk</span></samp></h3>
-
-<p><a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-See-Also-Bell-Laboratories-_0040command_007bawk_007d-1829"></a><a
name="index-extensions_002c-Bell-Laboratories-_0040command_007bawk_007d-1830"></a><a
name="index-Bell-Laboratories-_0040command_007bawk_007d-extensions-1831"></a><a
name="index-Kernighan_002c-Brian-1832"></a>Brian Kernighan, one of the original
designers of Unix <samp><span class="command">awk</span></samp>,
-has made his version available via his home page
-(see <a href="Other-Versions.html#Other-Versions">Other Versions</a>).
-This section describes extensions in his version of <samp><span
class="command">awk</span></samp> that are
-not in POSIX <samp><span class="command">awk</span></samp>:
-
- <ul>
-<li>The `<samp><span class="samp">-mf </span><var>N</var></samp>' and
`<samp><span class="samp">-mr </span><var>N</var></samp>' command-line options
-to set the maximum number of fields and the maximum
-record size, respectively
-(see <a href="Options.html#Options">Options</a>).
-As a side note, his <samp><span class="command">awk</span></samp> no longer
needs these options;
-it continues to accept them to avoid breaking old programs.
-
- <li>The <code>fflush</code> built-in function for flushing buffered output
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-
- <li>The `<samp><span class="samp">**</span></samp>' and `<samp><span
class="samp">**=</span></samp>' operators
-(see <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>
-and
-<a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-
- <li>The use of <code>func</code> as an abbreviation for
<code>function</code>
-(see <a href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a>).
-
- </ul>
-
- <p>The Bell Laboratories <samp><span class="command">awk</span></samp> also
incorporates the following extensions,
-originally developed for <samp><span class="command">gawk</span></samp>:
-
- <ul>
-<li>The `<samp><span class="samp">\x</span></samp>' escape sequence
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-
- <li>The <samp><span class="file">/dev/stdin</span></samp>, <samp><span
class="file">/dev/stdout</span></samp>, and <samp><span
class="file">/dev/stderr</span></samp>
-special files
-(see <a href="Special-Files.html#Special-Files">Special Files</a>).
-
- <li>The ability for <code>FS</code> and for the third
-argument to <code>split</code> to be null strings
-(see <a href="Single-Character-Fields.html#Single-Character-Fields">Single
Character Fields</a>).
-
- <li>The <code>nextfile</code> statement
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-
- <li>The ability to delete all of an array at once with `<samp><span
class="samp">delete </span><var>array</var></samp>'
-(see <a href="Delete.html#Delete">Delete</a>).
-</ul>
-
- </body></html>
-
Index: manual/html_node/Basic-Concepts.html
===================================================================
RCS file: manual/html_node/Basic-Concepts.html
diff -N manual/html_node/Basic-Concepts.html
--- manual/html_node/Basic-Concepts.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-<html lang="en">
-<head>
-<title>Basic Concepts - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Notes.html#Notes" title="Notes">
-<link rel="next" href="Glossary.html#Glossary" title="Glossary">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Basic-Concepts"></a>Next: <a rel="next" accesskey="n"
href="Glossary.html#Glossary">Glossary</a>,
-Previous: <a rel="previous" accesskey="p"
href="Notes.html#Notes">Notes</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="appendix">Appendix D Basic Programming Concepts</h2>
-
-<p><a name="index-programming_002c-concepts-2023"></a><!-- STARTOFRANGE procon
-->
-<a name="index-programming_002c-concepts-2024"></a>
-This appendix attempts to define some of the basic concepts
-and terms that are used throughout the rest of this Web page.
-As this Web page is specifically about <samp><span
class="command">awk</span></samp>,
-and not about computer programming in general, the coverage here
-is by necessity fairly cursory and simplistic.
-(If you need more background, there are many
-other introductory texts that you should refer to instead.)
-
-<ul class="menu">
-<li><a accesskey="1" href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a>: The high level view.
-<li><a accesskey="2" href="Basic-Data-Typing.html#Basic-Data-Typing">Basic
Data Typing</a>: A very quick intro to data types.
-<li><a accesskey="3"
href="Floating-Point-Issues.html#Floating-Point-Issues">Floating Point
Issues</a>: Stuff to know about floating-point numbers.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Basic-Data-Typing.html
===================================================================
RCS file: manual/html_node/Basic-Data-Typing.html
diff -N manual/html_node/Basic-Data-Typing.html
--- manual/html_node/Basic-Data-Typing.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,149 +0,0 @@
-<html lang="en">
-<head>
-<title>Basic Data Typing - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Basic-Concepts.html#Basic-Concepts" title="Basic
Concepts">
-<link rel="prev" href="Basic-High-Level.html#Basic-High-Level" title="Basic
High Level">
-<link rel="next" href="Floating-Point-Issues.html#Floating-Point-Issues"
title="Floating Point Issues">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Basic-Data-Typing"></a>Next: <a rel="next" accesskey="n"
href="Floating-Point-Issues.html#Floating-Point-Issues">Floating Point
Issues</a>,
-Previous: <a rel="previous" accesskey="p"
href="Basic-High-Level.html#Basic-High-Level">Basic High Level</a>,
-Up: <a rel="up" accesskey="u"
href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">D.2 Data Values in a Computer</h3>
-
-<p><a name="index-variables-2034"></a>In a program,
-you keep track of information and values in things called
<dfn>variables</dfn>.
-A variable is just a name for a given value, such as <code>first_name</code>,
-<code>last_name</code>, <code>address</code>, and so on.
-<samp><span class="command">awk</span></samp> has several predefined
variables, and it has
-special names to refer to the current input record
-and the fields of the record.
-You may also group multiple
-associated values under one name, as an array.
-
- <p><a name="index-values_002c-numeric-2035"></a><a
name="index-values_002c-string-2036"></a><a
name="index-scalar-values-2037"></a>Data, particularly in <samp><span
class="command">awk</span></samp>, consists of either numeric
-values, such as 42 or 3.1415927, or string values.
-String values are essentially anything that's not a number, such as a name.
-Strings are sometimes referred to as <dfn>character data</dfn>, since they
-store the individual characters that comprise them.
-Individual variables, as well as numeric and string variables, are
-referred to as <dfn>scalar</dfn> values.
-Groups of values, such as arrays, are not scalars.
-
- <p><a name="index-integers-2038"></a><a
name="index-floating_002dpoint_002c-numbers-2039"></a><a
name="index-numbers_002c-floating_002dpoint-2040"></a>Within computers, there
are two kinds of numeric values: <dfn>integers</dfn>
-and <dfn>floating-point</dfn>.
-In school, integer values were referred to as “whole”
numbers—that is,
-numbers without any fractional part, such as 1, 42, or −17.
-The advantage to integer numbers is that they represent values exactly.
-The disadvantage is that their range is limited. On most modern systems,
-this range is −2,147,483,648 to 2,147,483,647.
-
- <p><a name="index-unsigned-integers-2041"></a><a
name="index-integers_002c-unsigned-2042"></a>Integer values come in two
flavors: <dfn>signed</dfn> and <dfn>unsigned</dfn>.
-Signed values may be negative or positive, with the range of values just
-described.
-Unsigned values are always positive. On most modern systems,
-the range is from 0 to 4,294,967,295.
-
- <p><a name="index-double_002dprecision-floating_002dpoint-2043"></a><a
name="index-single_002dprecision-floating_002dpoint-2044"></a>Floating-point
numbers represent what are called “real” numbers; i.e.,
-those that do have a fractional part, such as 3.1415927.
-The advantage to floating-point numbers is that they
-can represent a much larger range of values.
-The disadvantage is that there are numbers that they cannot represent
-exactly.
-<samp><span class="command">awk</span></samp> uses <dfn>double-precision</dfn>
floating-point numbers, which
-can hold more digits than <dfn>single-precision</dfn>
-floating-point numbers.
-Floating-point issues are discussed more fully in
-<a href="Floating-Point-Issues.html#Floating-Point-Issues">Floating Point
Issues</a>.
-
- <p>At the very lowest level, computers store values as groups of binary
digits,
-or <dfn>bits</dfn>. Modern computers group bits into groups of eight, called
<dfn>bytes</dfn>.
-Advanced applications sometimes have to manipulate bits directly,
-and <samp><span class="command">gawk</span></samp> provides functions for
doing so.
-
- <p><a name="index-null-strings-2045"></a>While you are probably used to the
idea of a number without a value (i.e., zero),
-it takes a bit more getting used to the idea of zero-length character data.
-Nevertheless, such a thing exists.
-It is called the <dfn>null string</dfn>.
-The null string is character data that has no value.
-In other words, it is empty. It is written in <samp><span
class="command">awk</span></samp> programs
-like this: <code>""</code>.
-
- <p>Humans are used to working in decimal; i.e., base 10. In base 10,
-numbers go from 0 to 9, and then “roll over” into the next
-column. (Remember grade school? 42 is 4 times 10 plus 2.)
-
- <p>There are other number bases though. Computers commonly use base 2
-or <dfn>binary</dfn>, base 8 or <dfn>octal</dfn>, and base 16 or
<dfn>hexadecimal</dfn>.
-In binary, each column represents two times the value in the column to
-its right. Each column may contain either a 0 or a 1.
-Thus, binary 1010 represents 1 times 8, plus 0 times 4, plus 1 times 2,
-plus 0 times 1, or decimal 10.
-Octal and hexadecimal are discussed more in
-<a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>.
-
- <p>Programs are written in programming languages.
-Hundreds, if not thousands, of programming languages exist.
-One of the most popular is the C programming language.
-The C language had a very strong influence on the design of
-the <samp><span class="command">awk</span></samp> language.
-
- <p><a name="index-Kernighan_002c-Brian-2046"></a><a
name="index-Ritchie_002c-Dennis-2047"></a>There have been several versions of
C. The first is often referred to
-as “K&R” C, after the initials of Brian Kernighan and Dennis
Ritchie,
-the authors of the first book on C. (Dennis Ritchie created the language,
-and Brian Kernighan was one of the creators of <samp><span
class="command">awk</span></samp>.)
-
- <p>In the mid-1980s, an effort began to produce an international standard
-for C. This work culminated in 1989, with the production of the ANSI
-standard for C. This standard became an ISO standard in 1990.
-Where it makes sense, POSIX <samp><span class="command">awk</span></samp> is
compatible with 1990 ISO C.
-
- <p>In 1999, a revised ISO C standard was approved and released.
-Future versions of <samp><span class="command">gawk</span></samp> will be as
compatible as possible
-with this standard.
-
- </body></html>
-
Index: manual/html_node/Basic-High-Level.html
===================================================================
RCS file: manual/html_node/Basic-High-Level.html
diff -N manual/html_node/Basic-High-Level.html
--- manual/html_node/Basic-High-Level.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,157 +0,0 @@
-<html lang="en">
-<head>
-<title>Basic High Level - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Basic-Concepts.html#Basic-Concepts" title="Basic
Concepts">
-<link rel="next" href="Basic-Data-Typing.html#Basic-Data-Typing" title="Basic
Data Typing">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Basic-High-Level"></a>Next: <a rel="next" accesskey="n"
href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data Typing</a>,
-Up: <a rel="up" accesskey="u"
href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">D.1 What a Program Does</h3>
-
-<p><a name="index-processing-data-2025"></a>At the most basic level, the job
of a program is to process
-some input data and produce results.
-
-<!-- NEXT ED: Use real images here -->
-<pre class="example"> _______
- +------+ / \ +---------+
- | Data | -----> < Program > -----> | Results |
- +------+ \_______/ +---------+
-</pre>
- <p><a name="index-compiled-programs-2026"></a><a
name="index-interpreted-programs-2027"></a>The “program” in the
figure can be either a compiled
-program<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-(such as <samp><span class="command">ls</span></samp>),
-or it may be <dfn>interpreted</dfn>. In the latter case, a machine-executable
-program such as <samp><span class="command">awk</span></samp> reads your
program, and then uses the
-instructions in your program to process the data.
-
- <p><a name="index-programming_002c-basic-steps-2028"></a>When you write a
program, it usually consists
-of the following, very basic set of steps:
-
-<!-- NEXT ED: Use real images here -->
-<pre class="example"> ______
- +----------------+ / More \ No +----------+
- | Initialization | -------> < Data > -------> | Clean Up |
- +----------------+ ^ \ ? / +----------+
- | +--+-+
- | | Yes
- | |
- | V
- | +---------+
- +-----+ Process |
- +---------+
-</pre>
- <dl>
-<dt>Initialization<dd>These are the things you do before actually starting to
process
-data, such as checking arguments, initializing any data you need
-to work with, and so on.
-This step corresponds to <samp><span class="command">awk</span></samp>'s
<code>BEGIN</code> rule
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-
- <p>If you were baking a cake, this might consist of laying out all the
-mixing bowls and the baking pan, and making sure you have all the
-ingredients that you need.
-
- <br><dt>Processing<dd>This is where the actual work is done. Your
program reads data,
-one logical chunk at a time, and processes it as appropriate.
-
- <p>In most programming languages, you have to manually manage the reading
-of data, checking to see if there is more each time you read a chunk.
-<samp><span class="command">awk</span></samp>'s pattern-action paradigm
-(see <a href="Getting-Started.html#Getting-Started">Getting Started</a>)
-handles the mechanics of this for you.
-
- <p>In baking a cake, the processing corresponds to the actual labor:
-breaking eggs, mixing the flour, water, and other ingredients, and then
putting the cake
-into the oven.
-
- <br><dt>Clean Up<dd>Once you've processed all the data, you may have
things you need to
-do before exiting.
-This step corresponds to <samp><span class="command">awk</span></samp>'s
<code>END</code> rule
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-
- <p>After the cake comes out of the oven, you still have to wrap it in
-plastic wrap to keep anyone from tasting it, as well as wash
-the mixing bowls and utensils.
-</dl>
-
- <p><a name="index-algorithms-2029"></a>An <dfn>algorithm</dfn> is a
detailed set of instructions necessary to accomplish
-a task, or process data. It is much the same as a recipe for baking
-a cake. Programs implement algorithms. Often, it is up to you to design
-the algorithm and implement it, simultaneously.
-
- <p><a name="index-records-2030"></a><a name="index-fields-2031"></a>The
“logical chunks” we talked about previously are called
<dfn>records</dfn>,
-similar to the records a company keeps on employees, a school keeps for
-students, or a doctor keeps for patients.
-Each record has many component parts, such as first and last names,
-date of birth, address, and so on. The component parts are referred
-to as the <dfn>fields</dfn> of the record.
-
- <p>The act of reading data is termed <dfn>input</dfn>, and that of
-generating results, not too surprisingly, is termed <dfn>output</dfn>.
-They are often referred to together as “input/output,”
-and even more often, as “I/O” for short.
-(You will also see “input” and “output” used as verbs.)
-
- <p><a name="index-data_002ddriven-languages-2032"></a><a
name="index-languages_0040comma_007b_007d-data_002ddriven-2033"></a><samp><span
class="command">awk</span></samp> manages the reading of data for you, as well
as the
-breaking it up into records and fields. Your program's job is to
-tell <samp><span class="command">awk</span></samp> what to with the data. You
do this by describing
-<dfn>patterns</dfn> in the data to look for, and <dfn>actions</dfn> to execute
-when those patterns are seen. This <dfn>data-driven</dfn> nature of
-<samp><span class="command">awk</span></samp> programs usually makes them both
easier to write
-and easier to read.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Compiled programs are typically written
-in lower-level languages such as C, C++, Fortran, or Ada,
-and then translated, or <dfn>compiled</dfn>, into a form that
-the computer can execute directly.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Basic-Printf.html
===================================================================
RCS file: manual/html_node/Basic-Printf.html
diff -N manual/html_node/Basic-Printf.html
--- manual/html_node/Basic-Printf.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-<html lang="en">
-<head>
-<title>Basic Printf - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printf.html#Printf" title="Printf">
-<link rel="next" href="Control-Letters.html#Control-Letters" title="Control
Letters">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Basic-Printf"></a>Next: <a rel="next" accesskey="n"
href="Control-Letters.html#Control-Letters">Control Letters</a>,
-Up: <a rel="up" accesskey="u" href="Printf.html#Printf">Printf</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.5.1 Introduction to the <code>printf</code>
Statement</h4>
-
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-syntax-of-530"></a>A
simple <code>printf</code> statement looks like this:
-
-<pre class="example"> printf <var>format</var>, <var>item1</var>,
<var>item2</var>, ...
-</pre>
- <p class="noindent">The entire list of arguments may optionally be enclosed
in parentheses. The
-parentheses are necessary if any of the item expressions use the `<samp><span
class="samp">></span></samp>'
-relational operator; otherwise, it can be confused with a redirection
-(see <a href="Redirection.html#Redirection">Redirection</a>).
-
- <p><a name="index-format-strings-531"></a>The difference between
<code>printf</code> and <code>print</code> is the <var>format</var>
-argument. This is an expression whose value is taken as a string; it
-specifies how to output each of the other arguments. It is called the
-<dfn>format string</dfn>.
-
- <p>The format string is very similar to that in the ISO C library function
-<code>printf</code>. Most of <var>format</var> is text to output verbatim.
-Scattered among this text are <dfn>format specifiers</dfn>—one per item.
-Each format specifier says to output the next item in the argument list
-at that place in the format.
-
- <p>The <code>printf</code> statement does not automatically append a newline
-to its output. It outputs only what the format string specifies.
-So if a newline is needed, you must include one in the format string.
-The output separator variables <code>OFS</code> and <code>ORS</code> have no
effect
-on <code>printf</code> statements. For example:
-
-<pre class="example"> $ awk 'BEGIN {
- > ORS = "\nOUCH!\n"; OFS = "+"
- > msg = "Dont Panic!"
- > printf "%s\n", msg
- > }'
- -| Dont Panic!
-</pre>
- <p class="noindent">Here, neither the `<samp><span
class="samp">+</span></samp>' nor the `<samp><span
class="samp">OUCH</span></samp>' appear when
-the message is printed.
-
- </body></html>
-
Index: manual/html_node/BeOS-Installation.html
===================================================================
RCS file: manual/html_node/BeOS-Installation.html
diff -N manual/html_node/BeOS-Installation.html
--- manual/html_node/BeOS-Installation.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-<html lang="en">
-<head>
-<title>BeOS Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Non_002dUnix-Installation.html#Non_002dUnix-Installation"
title="Non-Unix Installation">
-<link rel="prev" href="Amiga-Installation.html#Amiga-Installation"
title="Amiga Installation">
-<link rel="next" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="BeOS-Installation"></a>Next: <a rel="next" accesskey="n"
href="PC-Installation.html#PC-Installation">PC Installation</a>,
-Previous: <a rel="previous" accesskey="p"
href="Amiga-Installation.html#Amiga-Installation">Amiga Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.3.2 Installing <samp><span
class="command">gawk</span></samp> on BeOS</h4>
-
-<p><a name="index-BeOS-1898"></a><a
name="index-installation_002c-beos-1899"></a>
-<!-- From email contributed by Martin Brown, address@hidden -->
-Since BeOS DR9, all the tools that you should need to build <code>gawk</code>
are
-included with BeOS. The process is basically identical to the Unix process
-of running <samp><span class="command">configure</span></samp> and then
<samp><span class="command">make</span></samp>. Full instructions are given
below.
-
- <p>You can compile <samp><span class="command">gawk</span></samp> under
BeOS by extracting the standard sources
-and running <samp><span class="command">configure</span></samp>. You
<em>must</em> specify the location
-prefix for the installation directory. For BeOS DR9 and beyond, the best
directory to
-use is <samp><span class="file">/boot/home/config</span></samp>, so the
<samp><span class="command">configure</span></samp> command is:
-
-<pre class="example"> configure --prefix=/boot/home/config
-</pre>
- <p>This installs the compiled application into <samp><span
class="file">/boot/home/config/bin</span></samp>,
-which is already specified in the standard <samp><span
class="env">PATH</span></samp>.
-
- <p>Once the configuration process is completed, you can run <samp><span
class="command">make</span></samp>,
-and then `<samp><span class="samp">make install</span></samp>':
-
-<pre class="example"> $ make
- ...
- $ make install
-</pre>
- <p>BeOS uses <samp><span class="command">bash</span></samp> as its shell;
thus, you use <samp><span class="command">gawk</span></samp> the same way you
would
-under Unix.
-If these steps do not work, please send in a bug report
-(see <a href="Bugs.html#Bugs">Bugs</a>).
-
-<!-- Rewritten by Scott Deifik <address@hidden> -->
-<!-- and Darrel Hankerson <address@hidden> -->
-</body></html>
-
Index: manual/html_node/Bitwise-Functions.html
===================================================================
RCS file: manual/html_node/Bitwise-Functions.html
diff -N manual/html_node/Bitwise-Functions.html
--- manual/html_node/Bitwise-Functions.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,216 +0,0 @@
-<html lang="en">
-<head>
-<title>Bitwise Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="prev" href="Time-Functions.html#Time-Functions" title="Time
Functions">
-<link rel="next" href="I18N-Functions.html#I18N-Functions" title="I18N
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Bitwise-Functions"></a>Next: <a rel="next" accesskey="n"
href="I18N-Functions.html#I18N-Functions">I18N Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Time-Functions.html#Time-Functions">Time Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.6 Bit-Manipulation Functions of <samp><span
class="command">gawk</span></samp></h4>
-
-<!-- STARTOFRANGE bit -->
-<p><a name="index-bitwise_002c-operations-1245"></a><!-- STARTOFRANGE and -->
-<a name="index-AND-bitwise-operation-1246"></a><!-- STARTOFRANGE oro -->
-<a name="index-OR-bitwise-operation-1247"></a><!-- STARTOFRANGE xor -->
-<a name="index-XOR-bitwise-operation-1248"></a><!-- STARTOFRANGE opbit -->
-<a name="index-operations_002c-bitwise-1249"></a><blockquote>
-<i>I can explain it for you, but I can't understand it for you.</i><br>
-Anonymous
-</blockquote>
-
- <p>Many languages provide the ability to perform <dfn>bitwise</dfn>
operations
-on two integer numbers. In other words, the operation is performed on
-each successive pair of bits in the operands.
-Three common operations are bitwise AND, OR, and XOR.
-The operations are described in <a
href="table_002dbitwise_002dops.html#table_002dbitwise_002dops">table-bitwise-ops</a>.
-
- <div class="float">
-<a name="table_002dbitwise_002dops"></a>
-<pre class="display"> Bit Operator
- | AND | OR | XOR
- |—+—+—+—+—+—
- Operands | 0 | 1 | 0 | 1 | 0 | 1
-
————–+—+—+—+—+—+—
- 0 | 0 0 | 0 1 | 0 1
- 1 | 0 1 | 1 1 | 1 0
-</pre>
- <p><strong class="float-caption">Table 8.6: Bitwise
Operations</strong></p></div>
-
- <p><a name="index-bitwise_002c-complement-1250"></a><a
name="index-complement_002c-bitwise-1251"></a>As you can see, the result of an
AND operation is 1 only when <em>both</em>
-bits are 1.
-The result of an OR operation is 1 if <em>either</em> bit is 1.
-The result of an XOR operation is 1 if either bit is 1,
-but not both.
-The next operation is the <dfn>complement</dfn>; the complement of 1 is 0 and
-the complement of 0 is 1. Thus, this operation “flips” all the bits
-of a given value.
-
- <p><a name="index-bitwise_002c-shift-1252"></a><a
name="index-left-shift_002c-bitwise-1253"></a><a
name="index-right-shift_002c-bitwise-1254"></a><a
name="index-shift_002c-bitwise-1255"></a>Finally, two other common operations
are to shift the bits left or right.
-For example, if you have a bit string `<samp><span
class="samp">10111001</span></samp>' and you shift it
-right by three bits, you end up with `<samp><span
class="samp">00010111</span></samp>'.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-<!-- Purposely decided to use 0's and 1's here. 2/2001. -->
-If you start over
-again with `<samp><span class="samp">10111001</span></samp>' and shift it left
by three bits, you end up
-with `<samp><span class="samp">11001000</span></samp>'.
-<samp><span class="command">gawk</span></samp> provides built-in functions
that implement the
-bitwise operations just described. They are:
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-bitwise-operations-in-1256"></a>
- <p><table summary=""><a
name="index-_0040code_007band_007d-function-_0028_0040command_007bgawk_007d_0029-1257"></a><tr
align="left"><td valign="top"><code>and(</code><var>v1</var><code>,
</code><var>v2</var><code>)</code>
-</td><td valign="top">Returns the bitwise AND of the values provided by
<var>v1</var> and <var>v2</var>.
-
-<p><a
name="index-_0040code_007bor_007d-function-_0028_0040command_007bgawk_007d_0029-1258"></a><br></td></tr><tr
align="left"><td valign="top"><code>or(</code><var>v1</var><code>,
</code><var>v2</var><code>)</code>
-</td><td valign="top">Returns the bitwise OR of the values provided by
<var>v1</var> and <var>v2</var>.
-
-<p><a
name="index-_0040code_007bxor_007d-function-_0028_0040command_007bgawk_007d_0029-1259"></a><br></td></tr><tr
align="left"><td valign="top"><code>xor(</code><var>v1</var><code>,
</code><var>v2</var><code>)</code>
-</td><td valign="top">Returns the bitwise XOR of the values provided by
<var>v1</var> and <var>v2</var>.
-
-<p><a
name="index-_0040code_007bcompl_007d-function-_0028_0040command_007bgawk_007d_0029-1260"></a><br></td></tr><tr
align="left"><td valign="top"><code>compl(</code><var>val</var><code>)</code>
-</td><td valign="top">Returns the bitwise complement of <var>val</var>.
-
-<p><a
name="index-_0040code_007blshift_007d-function-_0028_0040command_007bgawk_007d_0029-1261"></a><br></td></tr><tr
align="left"><td valign="top"><code>lshift(</code><var>val</var><code>,
</code><var>count</var><code>)</code>
-</td><td valign="top">Returns the value of <var>val</var>, shifted left by
<var>count</var> bits.
-
-<p><a
name="index-_0040code_007brshift_007d-function-_0028_0040command_007bgawk_007d_0029-1262"></a><br></td></tr><tr
align="left"><td valign="top"><code>rshift(</code><var>val</var><code>,
</code><var>count</var><code>)</code>
-</td><td valign="top">Returns the value of <var>val</var>, shifted right by
<var>count</var> bits.
- <br></td></tr></table>
-
- <p>For all of these functions, first the double-precision floating-point
value is
-converted to the widest C unsigned integer type, then the bitwise operation is
-performed. If the result cannot be represented exactly as a C
<code>double</code>,
-leading nonzero bits are removed one by one until it can be represented
-exactly. The result is then converted back into a C <code>double</code>. (If
-you don't understand this paragraph, don't worry about it.)
-
- <p>Here is a user-defined function
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>)
-that illustrates the use of these functions:
-
- <p><a
name="index-_0040code_007bbits2str_007d-user_002ddefined-function-1263"></a><a
name="index-_0040code_007btestbits_002eawk_007d-program-1264"></a>
-<pre class="smallexample"> <!-- file eg/lib/bits2str.awk -->
- # bits2str --- turn a byte into readable 1's and 0's
-
- function bits2str(bits, data, mask)
- {
- if (bits == 0)
- return "0"
-
- mask = 1
- for (; bits != 0; bits = rshift(bits, 1))
- data = (and(bits, mask) ? "1" : "0") data
-
- while ((length(data) % 8) != 0)
- data = "0" data
-
- return data
- }
- <!-- endfile -->
-
- <!-- this is a hack to make testbits.awk self-contained -->
- <!-- file eg/prog/testbits.awk -->
- BEGIN {
- printf "123 = %s\n", bits2str(123)
- printf "0123 = %s\n", bits2str(0123)
- printf "0x99 = %s\n", bits2str(0x99)
- comp = compl(0x99)
- printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp)
- shift = lshift(0x99, 2)
- printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
- shift = rshift(0x99, 2)
- printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift)
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">This program produces the following output when run:
-
-<pre class="smallexample"> $ gawk -f testbits.awk
- -| 123 = 01111011
- -| 0123 = 01010011
- -| 0x99 = 10011001
- -| compl(0x99) = 0xffffff66 = 11111111111111111111111101100110
- -| lshift(0x99, 2) = 0x264 = 0000001001100100
- -| rshift(0x99, 2) = 0x26 = 00100110
-</pre>
- <p><a name="index-numbers_002c-converting_002c-to-strings-1265"></a><a
name="index-strings_002c-converting_002c-numbers-to-1266"></a><a
name="index-converting_002c-numbers_002c-to-strings-1267"></a>The
<code>bits2str</code> function turns a binary number into a string.
-The number <code>1</code> represents a binary value where the rightmost bit
-is set to 1. Using this mask,
-the function repeatedly checks the rightmost bit.
-ANDing the mask with the value indicates whether the
-rightmost bit is 1 or not. If so, a <code>"1"</code> is concatenated onto the
front
-of the string.
-Otherwise, a <code>"0"</code> is added.
-The value is then shifted right by one bit and the loop continues
-until there are no more 1 bits.
-
- <p>If the initial value is zero it returns a simple <code>"0"</code>.
-Otherwise, at the end, it pads the value with zeros to represent multiples
-of 8-bit quantities. This is typical in modern computers.
-
- <p>The main code in the <code>BEGIN</code> rule shows the difference
between the
-decimal and octal values for the same numbers
-(see <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>),
-and then demonstrates the
-results of the <code>compl</code>, <code>lshift</code>, and
<code>rshift</code> functions.
-<!-- ENDOFRANGE bit -->
-<!-- ENDOFRANGE and -->
-<!-- ENDOFRANGE oro -->
-<!-- ENDOFRANGE xor -->
-<!-- ENDOFRANGE opbit -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This example
-shows that 0's come in on the left side. For <samp><span
class="command">gawk</span></samp>, this is
-always true, but in some languages, it's possible to have the left side
-fill with 1's. Caveat emptor.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Boolean-Ops.html
===================================================================
RCS file: manual/html_node/Boolean-Ops.html
diff -N manual/html_node/Boolean-Ops.html
--- manual/html_node/Boolean-Ops.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,156 +0,0 @@
-<html lang="en">
-<head>
-<title>Boolean Ops - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Typing-and-Comparison.html#Typing-and-Comparison"
title="Typing and Comparison">
-<link rel="next" href="Conditional-Exp.html#Conditional-Exp"
title="Conditional Exp">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Boolean-Ops"></a>Next: <a rel="next" accesskey="n"
href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>,
-Previous: <a rel="previous" accesskey="p"
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.11 Boolean Expressions</h3>
-
-<p><a name="index-and-Boolean_002dlogic-operator-774"></a><a
name="index-or-Boolean_002dlogic-operator-775"></a><a
name="index-not-Boolean_002dlogic-operator-776"></a><!-- STARTOFRANGE exbo -->
-<a name="index-expressions_002c-Boolean-777"></a><!-- STARTOFRANGE boex -->
-<a name="index-Boolean-expressions-778"></a><a
name="index-operators_002c-Boolean_002c-See-Boolean-expressions-779"></a><a
name="index-Boolean-operators_002c-See-Boolean-expressions-780"></a><a
name="index-logical-operators_002c-See-Boolean-expressions-781"></a><a
name="index-operators_002c-logical_002c-See-Boolean-expressions-782"></a>
-A <dfn>Boolean expression</dfn> is a combination of comparison expressions or
-matching expressions, using the Boolean operators “or”
-(`<samp><span class="samp">||</span></samp>'), “and” (`<samp><span
class="samp">&&</span></samp>'), and “not” (`<samp><span
class="samp">!</span></samp>'), along with
-parentheses to control nesting. The truth value of the Boolean expression is
-computed by combining the truth values of the component expressions.
-Boolean expressions are also referred to as <dfn>logical expressions</dfn>.
-The terms are equivalent.
-
- <p>Boolean expressions can be used wherever comparison and matching
-expressions can be used. They can be used in <code>if</code>,
<code>while</code>,
-<code>do</code>, and <code>for</code> statements
-(see <a href="Statements.html#Statements">Statements</a>).
-They have numeric values (one if true, zero if false) that come into play
-if the result of the Boolean expression is stored in a variable or
-used in arithmetic.
-
- <p>In addition, every Boolean expression is also a valid pattern, so
-you can use one as a pattern to control the execution of rules.
-The Boolean operators are:
-
- <dl>
-<dt><var>boolean1</var><code> && </code><var>boolean2</var><dd>True if
both <var>boolean1</var> and <var>boolean2</var> are true. For example,
-the following statement prints the current input record if it contains
-both `<samp><span class="samp">2400</span></samp>' and `<samp><span
class="samp">foo</span></samp>':
-
- <pre class="example"> if ($0 ~ /2400/ && $0 ~ /foo/)
print
- </pre>
- <p><a name="index-side-effects_002c-Boolean-operators-783"></a>The
subexpression <var>boolean2</var> is evaluated only if <var>boolean1</var>
-is true. This can make a difference when <var>boolean2</var> contains
-expressions that have side effects. In the case of `<samp><span
class="samp">$0 ~ /foo/ &&
-($2 == bar++)</span></samp>', the variable <code>bar</code> is not incremented
if there is
-no substring `<samp><span class="samp">foo</span></samp>' in the record.
-
- <br><dt><var>boolean1</var><code> || </code><var>boolean2</var><dd>True
if at least one of <var>boolean1</var> or <var>boolean2</var> is true.
-For example, the following statement prints all records in the input
-that contain <em>either</em> `<samp><span class="samp">2400</span></samp>' or
-`<samp><span class="samp">foo</span></samp>' or both:
-
- <pre class="example"> if ($0 ~ /2400/ || $0 ~ /foo/) print
- </pre>
- <p>The subexpression <var>boolean2</var> is evaluated only if
<var>boolean1</var>
-is false. This can make a difference when <var>boolean2</var> contains
-expressions that have side effects.
-
- <br><dt><code>! </code><var>boolean</var><dd>True if <var>boolean</var>
is false. For example,
-the following program prints `<samp><span class="samp">no home!</span></samp>'
in
-the unusual event that the <samp><span class="env">HOME</span></samp>
environment
-variable is not defined:
-
- <pre class="example"> BEGIN { if (! ("HOME" in ENVIRON))
- print "no home!" }
- </pre>
- <p>(The <code>in</code> operator is described in
-<a href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>.)
-</dl>
-
- <p><a name="index-short_002dcircuit-operators-784"></a><a
name="index-operators_002c-short_002dcircuit-785"></a><a
name="index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-786"></a><a
name="index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007d-operator-787"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-788"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-789"></a>The
`<samp><span class="samp">&&</span></samp>' and `<samp><span
class="samp">||</span></samp>' operators are called <dfn>short-circuit</dfn>
-operators because of the way they work. Evaluation of the full expression
-is “short-circuited” if the result can be determined part way
through
-its evaluation.
-
- <p><a name="index-line-continuations-790"></a>Statements that use
`<samp><span class="samp">&&</span></samp>' or `<samp><span
class="samp">||</span></samp>' can be continued simply
-by putting a newline after them. But you cannot put a newline in front
-of either of these operators without using backslash continuation
-(see <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>).
-
- <p><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d--operator-791"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-792"></a><a
name="index-newlines-793"></a><a name="index-variables_002c-flag-794"></a><a
name="index-flag-variables-795"></a>The actual value of an expression using the
`<samp><span class="samp">!</span></samp>' operator is
-either one or zero, depending upon the truth value of the expression it
-is applied to.
-The `<samp><span class="samp">!</span></samp>' operator is often useful for
changing the sense of a flag
-variable from false to true and back again. For example, the following
-program is one way to print lines in between special bracketing lines:
-
-<pre class="example"> $1 == "START" { interested = ! interested; next }
- interested == 1 { print }
- $1 == "END" { interested = ! interested; next }
-</pre>
- <p class="noindent">The variable <code>interested</code>, as with all
<samp><span class="command">awk</span></samp> variables, starts
-out initialized to zero, which is also false. When a line is seen whose
-first field is `<samp><span class="samp">START</span></samp>', the value of
<code>interested</code> is toggled
-to true, using `<samp><span class="samp">!</span></samp>'. The next rule
prints lines as long as
-<code>interested</code> is true. When a line is seen whose first field is
-`<samp><span class="samp">END</span></samp>', <code>interested</code> is
toggled back to false.
-
- <p><a name="index-_0040code_007bnext_007d-statement-796"></a><blockquote>
-<b>NOTE:</b> The <code>next</code> statement is discussed in
-<a href="Next-Statement.html#Next-Statement">Next Statement</a>.
-<code>next</code> tells <samp><span class="command">awk</span></samp> to skip
the rest of the rules, get the
-next record, and start processing the rules over again at the top.
-The reason it's there is to avoid printing the bracketing
-`<samp><span class="samp">START</span></samp>' and `<samp><span
class="samp">END</span></samp>' lines.
-</blockquote>
- <!-- ENDOFRANGE exbo -->
-<!-- ENDOFRANGE boex -->
-
- </body></html>
-
Index: manual/html_node/Break-Statement.html
===================================================================
RCS file: manual/html_node/Break-Statement.html
diff -N manual/html_node/Break-Statement.html
--- manual/html_node/Break-Statement.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,120 +0,0 @@
-<html lang="en">
-<head>
-<title>Break Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="Switch-Statement.html#Switch-Statement" title="Switch
Statement">
-<link rel="next" href="Continue-Statement.html#Continue-Statement"
title="Continue Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Break-Statement"></a>Next: <a rel="next" accesskey="n"
href="Continue-Statement.html#Continue-Statement">Continue Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="Switch-Statement.html#Switch-Statement">Switch Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.6 The <code>break</code> Statement</h4>
-
-<p><a name="index-_0040code_007bbreak_007d-statement-961"></a><a
name="index-loops_002c-exiting-962"></a>
-The <code>break</code> statement jumps out of the innermost <code>for</code>,
-<code>while</code>, or <code>do</code> loop that encloses it. The following
example
-finds the smallest divisor of any integer, and also identifies prime
-numbers:
-
-<pre class="example"> # find smallest divisor of num
- {
- num = $1
- for (div = 2; div*div <= num; div++)
- if (num % div == 0)
- break
- if (num % div == 0)
- printf "Smallest divisor of %d is %d\n", num, div
- else
- printf "%d is prime\n", num
- }
-</pre>
- <p>When the remainder is zero in the first <code>if</code> statement,
<samp><span class="command">awk</span></samp>
-immediately <dfn>breaks out</dfn> of the containing <code>for</code> loop.
This means
-that <samp><span class="command">awk</span></samp> proceeds immediately to the
statement following the loop
-and continues processing. (This is very different from the <code>exit</code>
-statement, which stops the entire <samp><span
class="command">awk</span></samp> program.
-See <a href="Exit-Statement.html#Exit-Statement">Exit Statement</a>.)
-
- <p>Th following program illustrates how the <var>condition</var> of a
<code>for</code>
-or <code>while</code> statement could be replaced with a <code>break</code>
inside
-an <code>if</code>:
-
-<pre class="example"> # find smallest divisor of num
- {
- num = $1
- for (div = 2; ; div++) {
- if (num % div == 0) {
- printf "Smallest divisor of %d is %d\n", num, div
- break
- }
- if (div*div > num) {
- printf "%d is prime\n", num
- break
- }
- }
- }
-</pre>
- <!-- @cindex @code{break}, outside of loops -->
-<!-- @cindex historical features -->
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bbreak_007d-statement-and-963"></a><a
name="index-dark-corner_002c-_0040code_007bbreak_007d-statement-964"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bbreak_007d-statement-in-965"></a>The
<code>break</code> statement has no meaning when
-used outside the body of a loop. However, although it was never documented,
-historical implementations of <samp><span class="command">awk</span></samp>
treated the <code>break</code>
-statement outside of a loop as if it were a <code>next</code> statement
-(see <a href="Next-Statement.html#Next-Statement">Next Statement</a>).
-Recent versions of Unix <samp><span class="command">awk</span></samp> no
longer allow this usage.
-<samp><span class="command">gawk</span></samp> supports this use of
<code>break</code> only
-if <samp><span class="option">--traditional</span></samp>
-has been specified on the command line
-(see <a href="Options.html#Options">Options</a>).
-Otherwise, it is treated as an error, since the POSIX standard
-specifies that <code>break</code> should only be used inside the body of a
-loop.
-(d.c.)
-
- </body></html>
-
Index: manual/html_node/Bugs.html
===================================================================
RCS file: manual/html_node/Bugs.html
diff -N manual/html_node/Bugs.html
--- manual/html_node/Bugs.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,135 +0,0 @@
-<html lang="en">
-<head>
-<title>Bugs - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Installation.html#Installation" title="Installation">
-<link rel="prev" href="Unsupported.html#Unsupported" title="Unsupported">
-<link rel="next" href="Other-Versions.html#Other-Versions" title="Other
Versions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Bugs"></a>Next: <a rel="next" accesskey="n"
href="Other-Versions.html#Other-Versions">Other Versions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Unsupported.html#Unsupported">Unsupported</a>,
-Up: <a rel="up" accesskey="u"
href="Installation.html#Installation">Installation</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">B.5 Reporting Problems and Bugs</h3>
-
-<p><a name="index-archeologists-1921"></a><blockquote>
-<i>There is nothing more dangerous than a bored archeologist.</i><br>
-The Hitchhiker's Guide to the Galaxy
-</blockquote>
- <!-- the radio show, not the book. :-) -->
-
-<!-- STARTOFRANGE dbugg -->
-<p><a
name="index-debugging-_0040command_007bgawk_007d_002c-bug-reports-1922"></a><!--
STARTOFRANGE tblgawb -->
-<a
name="index-troubleshooting_002c-_0040command_007bgawk_007d_002c-bug-reports-1923"></a>If
you have problems with <samp><span class="command">gawk</span></samp> or think
that you have found a bug,
-please report it to the developers; we cannot promise to do anything
-but we might well want to fix it.
-
- <p>Before reporting a bug, make sure you have actually found a real bug.
-Carefully reread the documentation and see if it really says you can do
-what you're trying to do. If it's not clear whether you should be able
-to do something or not, report that too; it's a bug in the documentation!
-
- <p>Before reporting a bug or trying to fix it yourself, try to isolate it
-to the smallest possible <samp><span class="command">awk</span></samp> program
and input data file that
-reproduces the problem. Then send us the program and data file,
-some idea of what kind of Unix system you're using,
-the compiler you used to compile <samp><span
class="command">gawk</span></samp>, and the exact results
-<samp><span class="command">gawk</span></samp> gave you. Also say what you
expected to occur; this helps
-us decide whether the problem is really in the documentation.
-
- <p><a
name="index-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-bug-reporting-address-1924"></a><a
name="index-email-address-for-bug-reports_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1925"></a><a
name="index-bug-reports_002c-email-address_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1926"></a>Once
you have a precise problem, send email to <a
href="mailto:address@hidden">address@hidden</a>.
-
- <p><a name="index-Robbins_002c-Arnold-1927"></a>Please include the version
number of <samp><span class="command">gawk</span></samp> you are using.
-You can get this information with the command `<samp><span class="samp">gawk
--version</span></samp>'.
-Using this address automatically sends a carbon copy of your
-mail to me. If necessary, I can be reached directly at
-<a href="mailto:address@hidden">address@hidden</a>. The bug reporting address
is preferred since the
-email list is archived at the GNU Project.
-<em>All email should be in English, since that is my native language.</em>
-
- <p><a
name="index-_0040code_007bcomp_002elang_002eawk_007d-newsgroup-1928"></a><strong>Caution:</strong>
Do <em>not</em> try to report bugs in <samp><span
class="command">gawk</span></samp> by
-posting to the Usenet/Internet newsgroup <code>comp.lang.awk</code>.
-While the <samp><span class="command">gawk</span></samp> developers do
occasionally read this newsgroup,
-there is no guarantee that we will see your posting. The steps described
-above are the official recognized ways for reporting bugs.
-
- <p>Non-bug suggestions are always welcome as well. If you have questions
-about things that are unclear in the documentation or are just obscure
-features, ask me; I will try to help you out, although I
-may not have the time to fix the problem. You can send me electronic
-mail at the Internet address noted previously.
-
- <p>If you find bugs in one of the non-Unix ports of <samp><span
class="command">gawk</span></samp>, please send
-an electronic mail message to the person who maintains that port. They
-are named in the following list, as well as in the <samp><span
class="file">README</span></samp> file in the <samp><span
class="command">gawk</span></samp>
-distribution. Information in the <samp><span
class="file">README</span></samp> file should be considered
-authoritative if it conflicts with this Web page.
-
- <p>The people maintaining the non-Unix ports of <samp><span
class="command">gawk</span></samp> are
-as follows:
-
- <p><table summary=""><a name="index-Fish_002c-Fred-1929"></a><tr
align="left"><td valign="top">Amiga </td><td valign="top">Fred Fish, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Brown_002c-Martin-1930"></a><br></td></tr><tr
align="left"><td valign="top">BeOS </td><td valign="top">Martin Brown, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Deifik_002c-Scott-1931"></a><a
name="index-Hankerson_002c-Darrel-1932"></a><br></td></tr><tr align="left"><td
valign="top">MS-DOS </td><td valign="top">Scott Deifik, <a
href="mailto:address@hidden">address@hidden</a> and
-Darrel Hankerson, <a href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Grigera_002c-Juan-1933"></a><br></td></tr><tr
align="left"><td valign="top">MS-Windows </td><td valign="top">Juan Grigera, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><br></td></tr><tr align="left"><td valign="top">OS/2 </td><td
valign="top">The Unix for OS/2 team, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Davies_002c-Stephen-1934"></a><br></td></tr><tr
align="left"><td valign="top">Tandem </td><td valign="top">Stephen Davies, <a
href="mailto:address@hidden">address@hidden</a>.
-
-<p><a name="index-Rankin_002c-Pat-1935"></a><br></td></tr><tr align="left"><td
valign="top">VMS </td><td valign="top">Pat Rankin, <a
href="mailto:address@hidden">address@hidden</a>.
- <br></td></tr></table>
-
- <p>If your bug is also reproducible under Unix, please send a copy of your
-report to the <a href="mailto:address@hidden">address@hidden</a> email list as
well.
-<!-- ENDOFRANGE dbugg -->
-<!-- ENDOFRANGE tblgawb -->
-
- </body></html>
-
Index: manual/html_node/Built_002din-Variables.html
===================================================================
RCS file: manual/html_node/Built_002din-Variables.html
diff -N manual/html_node/Built_002din-Variables.html
--- manual/html_node/Built_002din-Variables.html 31 Aug 2004 22:04:10
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-<html lang="en">
-<head>
-<title>Built-in Variables - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link rel="prev" href="Statements.html#Statements" title="Statements">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Built_002din-Variables"></a>Previous: <a rel="previous"
accesskey="p" href="Statements.html#Statements">Statements</a>,
-Up: <a rel="up" accesskey="u"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>
-<hr><br>
-</div>
-
-<h3 class="section">6.5 Built-in Variables</h3>
-
-<!-- STARTOFRANGE bvar -->
-<p><a name="index-built_002din-variables-990"></a><!-- STARTOFRANGE varb -->
-<a name="index-variables_002c-built_002din-991"></a>
-Most <samp><span class="command">awk</span></samp> variables are available to
use for your own
-purposes; they never change unless your program assigns values to
-them, and they never affect anything unless your program examines them.
-However, a few variables in <samp><span class="command">awk</span></samp> have
special built-in meanings.
-<samp><span class="command">awk</span></samp> examines some of these
automatically, so that they enable you
-to tell <samp><span class="command">awk</span></samp> how to do certain
things. Others are set
-automatically by <samp><span class="command">awk</span></samp>, so that they
carry information from the
-internal workings of <samp><span class="command">awk</span></samp> to your
program.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-built_002din-variables-and-992"></a>This
section documents all the built-in variables of
-<samp><span class="command">gawk</span></samp>, most of which are also
documented in the chapters
-describing their areas of activity.
-
-<ul class="menu">
-<li><a accesskey="1"
href="User_002dmodified.html#User_002dmodified">User-modified</a>:
Built-in variables that you change to control
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="2" href="Auto_002dset.html#Auto_002dset">Auto-set</a>:
Built-in variables where <samp><span
class="command">awk</span></samp> gives
- you information.
-<li><a accesskey="3" href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and
ARGV</a>: Ways to use <code>ARGC</code> and <code>ARGV</code>.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Built_002din.html
===================================================================
RCS file: manual/html_node/Built_002din.html
diff -N manual/html_node/Built_002din.html
--- manual/html_node/Built_002din.html 31 Aug 2004 22:04:10 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-<html lang="en">
-<head>
-<title>Built-in - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Functions.html#Functions" title="Functions">
-<link rel="next" href="User_002ddefined.html#User_002ddefined"
title="User-defined">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Built_002din"></a>Next: <a rel="next" accesskey="n"
href="User_002ddefined.html#User_002ddefined">User-defined</a>,
-Up: <a rel="up" accesskey="u"
href="Functions.html#Functions">Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">8.1 Built-in Functions</h3>
-
-<!-- 2e: USE TEXINFO-2 FUNCTION DEFINITION STUFF!!!!!!!!!!!!! -->
-<p><dfn>Built-in</dfn> functions are always available for
-your <samp><span class="command">awk</span></samp> program to call. This
section defines all
-the built-in
-functions in <samp><span class="command">awk</span></samp>; some of these are
mentioned in other sections
-but are summarized here for your convenience.
-
-<ul class="menu">
-<li><a accesskey="1"
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a>:
How to call built-in functions.
-<li><a accesskey="2" href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a>: Functions that work with numbers, including
- <code>int</code>, <code>sin</code> and
<code>rand</code>.
-<li><a accesskey="3" href="String-Functions.html#String-Functions">String
Functions</a>: Functions for string manipulation, such as
- <code>split</code>, <code>match</code> and
<code>sprintf</code>.
-<li><a accesskey="4" href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a>: Functions for files and shell commands.
-<li><a accesskey="5" href="Time-Functions.html#Time-Functions">Time
Functions</a>: Functions for dealing with timestamps.
-<li><a accesskey="6" href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a>: Functions for bitwise operations.
-<li><a accesskey="7" href="I18N-Functions.html#I18N-Functions">I18N
Functions</a>: Functions for string translation.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Calling-Built_002din.html
===================================================================
RCS file: manual/html_node/Calling-Built_002din.html
diff -N manual/html_node/Calling-Built_002din.html
--- manual/html_node/Calling-Built_002din.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,97 +0,0 @@
-<html lang="en">
-<head>
-<title>Calling Built-in - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="next" href="Numeric-Functions.html#Numeric-Functions"
title="Numeric Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Calling-Built_002din"></a>Next: <a rel="next" accesskey="n"
href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.1 Calling Built-in Functions</h4>
-
-<p>To call one of <samp><span class="command">awk</span></samp>'s built-in
functions, write the name of
-the function followed
-by arguments in parentheses. For example, `<samp><span class="samp">atan2(y +
z, 1)</span></samp>'
-is a call to the function <code>atan2</code> and has two arguments.
-
- <p><a
name="index-programming-conventions_002c-functions_002c-calling-1142"></a><a
name="index-whitespace_002c-functions_0040comma_007b_007d-calling-1143"></a>Whitespace
is ignored between the built-in function name and the
-open parenthesis, and it is good practice to avoid using whitespace
-there. User-defined functions do not permit whitespace in this way, and
-it is easier to avoid mistakes by following a simple
-convention that always works—no whitespace after a function name.
-
- <p><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d_002c-fatal-errors_0040comma_007b_007d-function-arguments-1144"></a><a
name="index-_0040command_007bgawk_007d_002c-function-arguments-and-1145"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-function-arguments-_0028_0040command_007bgawk_007d_0029-1146"></a>Each
built-in function accepts a certain number of arguments.
-In some cases, arguments can be omitted. The defaults for omitted
-arguments vary from function to function and are described under the
-individual functions. In some <samp><span class="command">awk</span></samp>
implementations, extra
-arguments given to built-in functions are ignored. However, in <samp><span
class="command">gawk</span></samp>,
-it is a fatal error to give extra arguments to a built-in function.
-
- <p>When a function is called, expressions that create the function's actual
-parameters are evaluated completely before the call is performed.
-For example, in the following code fragment:
-
-<pre class="example"> i = 4
- j = sqrt(i++)
-</pre>
- <p><a name="index-evaluation-order_002c-functions-1147"></a><a
name="index-functions_002c-built_002din_002c-evaluation-order-1148"></a><a
name="index-built_002din-functions_002c-evaluation-order-1149"></a>the variable
<code>i</code> is incremented to the value five before <code>sqrt</code>
-is called with a value of four for its actual parameter.
-The order of evaluation of the expressions used for the function's
-parameters is undefined. Thus, avoid writing programs that
-assume that parameters are evaluated from left to right or from
-right to left. For example:
-
-<pre class="example"> i = 5
- j = atan2(i++, i *= 2)
-</pre>
- <p>If the order of evaluation is left to right, then <code>i</code> first
becomes
-6, and then 12, and <code>atan2</code> is called with the two arguments 6
-and 12. But if the order of evaluation is right to left, <code>i</code>
-first becomes 10, then 11, and <code>atan2</code> is called with the
-two arguments 11 and 10.
-
- </body></html>
-
Index: manual/html_node/Case_002dsensitivity.html
===================================================================
RCS file: manual/html_node/Case_002dsensitivity.html
diff -N manual/html_node/Case_002dsensitivity.html
--- manual/html_node/Case_002dsensitivity.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,148 +0,0 @@
-<html lang="en">
-<head>
-<title>Case-sensitivity - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="GNU-Regexp-Operators.html#GNU-Regexp-Operators"
title="GNU Regexp Operators">
-<link rel="next" href="Leftmost-Longest.html#Leftmost-Longest" title="Leftmost
Longest">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Case_002dsensitivity"></a>Next: <a rel="next" accesskey="n"
href="Leftmost-Longest.html#Leftmost-Longest">Leftmost Longest</a>,
-Previous: <a rel="previous" accesskey="p"
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp Operators</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.6 Case Sensitivity in Matching</h3>
-
-<!-- STARTOFRANGE regexpcs -->
-<p><a name="index-regular-expressions_002c-case-sensitivity-314"></a><!--
STARTOFRANGE csregexp -->
-<a name="index-case-sensitivity_002c-regexps-and-315"></a>Case is normally
significant in regular expressions, both when matching
-ordinary characters (i.e., not metacharacters) and inside character
-sets. Thus, a `<samp><span class="samp">w</span></samp>' in a regular
expression matches only a lowercase
-`<samp><span class="samp">w</span></samp>' and not an uppercase `<samp><span
class="samp">W</span></samp>'.
-
- <p>The simplest way to do a case-independent match is to use a character
-list—for example, `<samp><span class="samp">[Ww]</span></samp>'.
However, this can be cumbersome if
-you need to use it often, and it can make the regular expressions harder
-to read. There are two alternatives that you might prefer.
-
- <p>One way to perform a case-insensitive match at a particular point in the
-program is to convert the data to a single case, using the
-<code>tolower</code> or <code>toupper</code> built-in string functions (which
we
-haven't discussed yet;
-see <a href="String-Functions.html#String-Functions">String Functions</a>).
-For example:
-
-<pre class="example"> tolower($1) ~ /foo/ { ... }
-</pre>
- <p class="noindent">converts the first field to lowercase before matching
against it.
-This works in any POSIX-compliant <samp><span
class="command">awk</span></samp>.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-regular-expressions_002c-case-sensitivity-316"></a><a
name="index-case-sensitivity_002c-_0040command_007bgawk_007d-317"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regular-expressions-318"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-319"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-320"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-321"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-322"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable-323"></a><!-- @cindex
variables, @code{IGNORECASE} -->
-Another method, specific to <samp><span class="command">gawk</span></samp>, is
to set the variable
-<code>IGNORECASE</code> to a nonzero value (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-When <code>IGNORECASE</code> is not zero, <em>all</em> regexp and string
-operations ignore case. Changing the value of
-<code>IGNORECASE</code> dynamically controls the case-sensitivity of the
-program as it runs. Case is significant by default because
-<code>IGNORECASE</code> (like most variables) is initialized to zero:
-
-<pre class="example"> x = "aB"
- if (x ~ /ab/) ... # this test will fail
-
- IGNORECASE = 1
- if (x ~ /ab/) ... # now it will succeed
-</pre>
- <p>In general, you cannot use <code>IGNORECASE</code> to make certain rules
-case-insensitive and other rules case-sensitive, because there is no
-straightforward way
-to set <code>IGNORECASE</code> just for the pattern of
-a particular rule.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-To do this, use either character lists or <code>tolower</code>. However, one
-thing you can do with <code>IGNORECASE</code> only is dynamically turn
-case-sensitivity on or off for all the rules at once.
-
- <p><code>IGNORECASE</code> can be set on the command line or in a
<code>BEGIN</code> rule
-(see <a href="Other-Arguments.html#Other-Arguments">Other Arguments</a>; also
-see <a href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using
BEGIN/END</a>).
-Setting <code>IGNORECASE</code> from the command line is a way to make
-a program case-insensitive without having to edit it.
-
- <p>Prior to <samp><span class="command">gawk</span></samp> 3.0, the value
of <code>IGNORECASE</code>
-affected regexp operations only. It did not affect string comparison
-with `<samp><span class="samp">==</span></samp>', `<samp><span
class="samp">!=</span></samp>', and so on.
-Beginning with version 3.0, both regexp and string comparison
-operations are also affected by <code>IGNORECASE</code>.
-
-<!-- @cindex ISO 8859-1 -->
-<!-- @cindex ISO Latin-1 -->
-<p>Beginning with <samp><span class="command">gawk</span></samp> 3.0,
-the equivalences between upper-
-and lowercase characters are based on the ISO-8859-1 (ISO Latin-1)
-character set. This character set is a superset of the traditional 128
-ASCII characters, which also provides a number of characters suitable
-for use with European languages.
-
- <p>As of <samp><span class="command">gawk</span></samp> 3.1.4, the case
equivalencies are fully
-locale-aware. They are based on the C <code><ctype.h></code> facilities,
-such as <code>isalpha()</code> and <code>toupper()</code>.
-
- <p>The value of <code>IGNORECASE</code> has no effect if <samp><span
class="command">gawk</span></samp> is in
-compatibility mode (see <a href="Options.html#Options">Options</a>).
-Case is always significant in compatibility mode.
-<!-- ENDOFRANGE csregexp -->
-<!-- ENDOFRANGE regexpcs -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Experienced C and C++ programmers will note
-that it is possible, using something like
-`<samp><span class="samp">IGNORECASE = 1 && /foObAr/ { ...
}</span></samp>'
-and
-`<samp><span class="samp">IGNORECASE = 0 || /foobar/ { ... }</span></samp>'.
-However, this is somewhat obscure and we don't recommend it.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Changing-Fields.html
===================================================================
RCS file: manual/html_node/Changing-Fields.html
diff -N manual/html_node/Changing-Fields.html
--- manual/html_node/Changing-Fields.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,202 +0,0 @@
-<html lang="en">
-<head>
-<title>Changing Fields - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Nonconstant-Fields.html#Nonconstant-Fields"
title="Nonconstant Fields">
-<link rel="next" href="Field-Separators.html#Field-Separators" title="Field
Separators">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Changing-Fields"></a>Next: <a rel="next" accesskey="n"
href="Field-Separators.html#Field-Separators">Field Separators</a>,
-Previous: <a rel="previous" accesskey="p"
href="Nonconstant-Fields.html#Nonconstant-Fields">Nonconstant Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.4 Changing the Contents of a Field</h3>
-
-<!-- STARTOFRANGE ficon -->
-<p><a name="index-fields_002c-changing-contents-of-392"></a>The contents of a
field, as seen by <samp><span class="command">awk</span></samp>, can be changed
within an
-<samp><span class="command">awk</span></samp> program; this changes what
<samp><span class="command">awk</span></samp> perceives as the
-current input record. (The actual input is untouched; <samp><span
class="command">awk</span></samp> <em>never</em>
-modifies the input file.)
-Consider the following example and its output:
-
-<pre class="example"> $ awk '{ nboxes = $3 ; $3 = $3 - 10
- > print nboxes, $3 }' inventory-shipped
- -| 25 15
- -| 32 22
- -| 24 14
- ...
-</pre>
- <p class="noindent">The program first saves the original value of field
three in the variable
-<code>nboxes</code>.
-The `<samp><span class="samp">-</span></samp>' sign represents subtraction, so
this program reassigns
-field three, <code>$3</code>, as the original value of field three minus ten:
-`<samp><span class="samp">$3 - 10</span></samp>'. (See <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>.)
-Then it prints the original and new values for field three.
-(Someone in the warehouse made a consistent mistake while inventorying
-the red boxes.)
-
- <p>For this to work, the text in field <code>$3</code> must make sense
-as a number; the string of characters must be converted to a number
-for the computer to do arithmetic on it. The number resulting
-from the subtraction is converted back to a string of characters that
-then becomes field three.
-See <a href="Conversion.html#Conversion">Conversion</a>.
-
- <p>When the value of a field is changed (as perceived by <samp><span
class="command">awk</span></samp>), the
-text of the input record is recalculated to contain the new field where
-the old one was. In other words, <code>$0</code> changes to reflect the
altered
-field. Thus, this program
-prints a copy of the input file, with 10 subtracted from the second
-field of each line:
-
-<pre class="example"> $ awk '{ $2 = $2 - 10; print $0 }' inventory-shipped
- -| Jan 3 25 15 115
- -| Feb 5 32 24 226
- -| Mar 5 24 34 228
- ...
-</pre>
- <p>It is also possible to also assign contents to fields that are out
-of range. For example:
-
-<pre class="example"> $ awk '{ $6 = ($5 + $4 + $3 + $2)
- > print $6 }' inventory-shipped
- -| 168
- -| 297
- -| 301
- ...
-</pre>
- <p><a name="index-adding_002c-fields-393"></a><a
name="index-fields_002c-adding-394"></a>We've just created <code>$6</code>,
whose value is the sum of fields
-<code>$2</code>, <code>$3</code>, <code>$4</code>, and <code>$5</code>. The
`<samp><span class="samp">+</span></samp>' sign
-represents addition. For the file <samp><span
class="file">inventory-shipped</span></samp>, <code>$6</code>
-represents the total number of parcels shipped for a particular month.
-
- <p>Creating a new field changes <samp><span
class="command">awk</span></samp>'s internal copy of the current
-input record, which is the value of <code>$0</code>. Thus, if you do
`<samp><span class="samp">print $0</span></samp>'
-after adding a field, the record printed includes the new field, with
-the appropriate number of field separators between it and the previously
-existing fields.
-
- <p><a name="index-_0040code_007bOFS_007d-variable-395"></a><a
name="index-output-field-separator_002c-See-_0040code_007bOFS_007d-variable-396"></a><a
name="index-field-separators_002c-See-Also-_0040code_007bOFS_007d-397"></a>This
recomputation affects and is affected by
-<code>NF</code> (the number of fields; see <a
href="Fields.html#Fields">Fields</a>).
-For example, the value of <code>NF</code> is set to the number of the highest
-field you create.
-The exact format of <code>$0</code> is also affected by a feature that has not
been discussed yet:
-the <dfn>output field separator</dfn>, <code>OFS</code>,
-used to separate the fields (see <a
href="Output-Separators.html#Output-Separators">Output Separators</a>).
-
- <p>Note, however, that merely <em>referencing</em> an out-of-range field
-does <em>not</em> change the value of either <code>$0</code> or
<code>NF</code>.
-Referencing an out-of-range field only produces an empty string. For
-example:
-
-<pre class="example"> if ($(NF+1) != "")
- print "can't happen"
- else
- print "everything is normal"
-</pre>
- <p class="noindent">should print `<samp><span class="samp">everything is
normal</span></samp>', because <code>NF+1</code> is certain
-to be out of range. (See <a href="If-Statement.html#If-Statement">If
Statement</a>,
-for more information about <samp><span class="command">awk</span></samp>'s
<code>if-else</code> statements.
-See <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>,
-for more information about the `<samp><span class="samp">!=</span></samp>'
operator.)
-
- <p>It is important to note that making an assignment to an existing field
-changes the
-value of <code>$0</code> but does not change the value of <code>NF</code>,
-even when you assign the empty string to a field. For example:
-
-<pre class="example"> $ echo a b c d | awk '{ OFS = ":"; $2 = ""
- > print $0; print NF }'
- -| a::c:d
- -| 4
-</pre>
- <p class="noindent">The field is still there; it just has an empty value,
denoted by
-the two colons between `<samp><span class="samp">a</span></samp>' and
`<samp><span class="samp">c</span></samp>'.
-This example shows what happens if you create a new field:
-
-<pre class="example"> $ echo a b c d | awk '{ OFS = ":"; $2 = ""; $6 =
"new"
- > print $0; print NF }'
- -| a::c:d::new
- -| 6
-</pre>
- <p class="noindent">The intervening field, <code>$5</code>, is created with
an empty value
-(indicated by the second pair of adjacent colons),
-and <code>NF</code> is updated with the value six.
-
-<!-- FIXME: Verify that this is in POSIX -->
-<p><a
name="index-dark-corner_002c-_0040code_007bNF_007d-variable_002c-decrementing-398"></a><a
name="index-_0040code_007bNF_007d-variable_002c-decrementing-399"></a>Decrementing
<code>NF</code> throws away the values of the fields
-after the new value of <code>NF</code> and recomputes <code>$0</code>.
-(d.c.)
-Here is an example:
-
-<pre class="example"> $ echo a b c d e f | awk '{ print "NF =", NF;
- > NF = 3; print $0 }'
- -| NF = 6
- -| a b c
-</pre>
- <p><a
name="index-portability_002c-_0040code_007bNF_007d-variable_0040comma_007b_007d-decrementing-400"></a><strong>Caution:</strong>
Some versions of <samp><span class="command">awk</span></samp> don't
-rebuild <code>$0</code> when <code>NF</code> is decremented. Caveat emptor.
-
- <p>Finally, there are times when it is convenient to force
-<samp><span class="command">awk</span></samp> to rebuild the entire record,
using the current
-value of the fields and <code>OFS</code>. To do this, use the
-seemingly innocuous assignment:
-
-<pre class="example"> $1 = $1 # force record to be reconstituted
- print $0 # or whatever else with $0
-</pre>
- <p class="noindent">This forces <samp><span
class="command">awk</span></samp> rebuild the record. It does help
-to add a comment, as we've shown here.
-
- <p>There is a flip side to the relationship between <code>$0</code> and
-the fields. Any assignment to <code>$0</code> causes the record to be
-reparsed into fields using the <em>current</em> value of <code>FS</code>.
-This also applies to any built-in function that updates <code>$0</code>,
-such as <code>sub</code> and <code>gsub</code>
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-<!-- ENDOFRANGE ficon -->
-
- </body></html>
-
Index: manual/html_node/Character-Lists.html
===================================================================
RCS file: manual/html_node/Character-Lists.html
diff -N manual/html_node/Character-Lists.html
--- manual/html_node/Character-Lists.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,161 +0,0 @@
-<html lang="en">
-<head>
-<title>Character Lists - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Regexp-Operators.html#Regexp-Operators" title="Regexp
Operators">
-<link rel="next" href="GNU-Regexp-Operators.html#GNU-Regexp-Operators"
title="GNU Regexp Operators">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Character-Lists"></a>Next: <a rel="next" accesskey="n"
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp Operators</a>,
-Previous: <a rel="previous" accesskey="p"
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.4 Using Character Lists</h3>
-
-<!-- STARTOFRANGE charlist -->
-<p><a name="index-character-lists-256"></a><a
name="index-character-lists_002c-range-expressions-257"></a><a
name="index-range-expressions-258"></a>
-Within a character list, a <dfn>range expression</dfn> consists of two
-characters separated by a hyphen. It matches any single character that
-sorts between the two characters, using the locale's
-collating sequence and character set. For example, in the default C
-locale, `<samp><span class="samp">[a-dx-z]</span></samp>' is equivalent to
`<samp><span class="samp">[abcdxyz]</span></samp>'. Many locales
-sort characters in dictionary order, and in these locales,
-`<samp><span class="samp">[a-dx-z]</span></samp>' is typically not equivalent
to `<samp><span class="samp">[abcdxyz]</span></samp>'; instead it
-might be equivalent to `<samp><span
class="samp">[aBbCcDdxXyYz]</span></samp>', for example. To obtain
-the traditional interpretation of bracket expressions, you can use the C
-locale by setting the <samp><span class="env">LC_ALL</span></samp> environment
variable to the value
-`<samp><span class="samp">C</span></samp>'.
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-character-lists-259"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-character-lists-260"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-in-character-lists-261"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-in-character-lists-262"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-in-character-lists-263"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-in-character-lists-264"></a>To
include one of the characters `<samp><span class="samp">\</span></samp>',
`<samp><span class="samp">]</span></samp>', `<samp><span
class="samp">-</span></samp>', or `<samp><span class="samp">^</span></samp>' in
a
-character list, put a `<samp><span class="samp">\</span></samp>' in front of
it. For example:
-
-<pre class="example"> [d\]]
-</pre>
- <p class="noindent">matches either `<samp><span
class="samp">d</span></samp>' or `<samp><span class="samp">]</span></samp>'.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-character-lists-and-265"></a><a
name="index-Extended-Regular-Expressions-_0028EREs_0029-266"></a><a
name="index-EREs-_0028Extended-Regular-Expressions_0029-267"></a><a
name="index-_0040command_007begrep_007d-utility-268"></a>This treatment of
`<samp><span class="samp">\</span></samp>' in character lists
-is compatible with other <samp><span class="command">awk</span></samp>
-implementations and is also mandated by POSIX.
-The regular expressions in <samp><span class="command">awk</span></samp> are a
superset
-of the POSIX specification for Extended Regular Expressions (EREs).
-POSIX EREs are based on the regular expressions accepted by the
-traditional <samp><span class="command">egrep</span></samp> utility.
-
- <p><a name="index-character-lists_002c-character-classes-269"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-character-lists-and_002c-character-classes-270"></a><dfn>Character
classes</dfn> are a new feature introduced in the POSIX standard.
-A character class is a special notation for describing
-lists of characters that have a specific attribute, but the
-actual characters can vary from country to country and/or
-from character set to character set. For example, the notion of what
-is an alphabetic character differs between the United States and France.
-
- <p>A character class is only valid in a regexp <em>inside</em> the
-brackets of a character list. Character classes consist of `<samp><span
class="samp">[:</span></samp>',
-a keyword denoting the class, and `<samp><span class="samp">:]</span></samp>'.
-<a
href="table_002dchar_002dclasses.html#table_002dchar_002dclasses">table-char-classes</a>
lists the character classes defined by the
-POSIX standard.
-
- <div class="float">
-<a name="table_002dchar_002dclasses"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="15%">Class
</th><th valign="top" width="85%">Meaning
-<br></th></tr><tr align="left"><td valign="top"
width="15%"><code>[:alnum:]</code> </td><td valign="top"
width="85%">Alphanumeric characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:alpha:]</code> </td><td valign="top" width="85%">Alphabetic
characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:blank:]</code> </td><td valign="top" width="85%">Space and
TAB characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:cntrl:]</code> </td><td valign="top" width="85%">Control
characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:digit:]</code> </td><td valign="top" width="85%">Numeric
characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:graph:]</code> </td><td valign="top" width="85%">Characters
that are both printable and visible.
-(A space is printable but not visible, whereas an `<samp><span
class="samp">a</span></samp>' is both.)
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:lower:]</code> </td><td valign="top" width="85%">Lowercase
alphabetic characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:print:]</code> </td><td valign="top" width="85%">Printable
characters (characters that are not control characters).
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:punct:]</code> </td><td valign="top"
width="85%">Punctuation characters (characters that are not letters, digits,
-control characters, or space characters).
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:space:]</code> </td><td valign="top" width="85%">Space
characters (such as space, TAB, and formfeed, to name a few).
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:upper:]</code> </td><td valign="top" width="85%">Uppercase
alphabetic characters.
-<br></td></tr><tr align="left"><td valign="top"
width="15%"><code>[:xdigit:]</code> </td><td valign="top"
width="85%">Characters that are hexadecimal digits.
- <br></td></tr></table>
-<p><strong class="float-caption">Table 2.1: POSIX Character
Classes</strong></p></div>
-
- <p>For example, before the POSIX standard, you had to write
<code>/[A-Za-z0-9]/</code>
-to match alphanumeric characters. If your
-character set had other alphabetic characters in it, this would not
-match them, and if your character set collated differently from
-ASCII, this might not even match the ASCII alphanumeric characters.
-With the POSIX character classes, you can write
-<code>/[[:alnum:]]/</code> to match the alphabetic
-and numeric characters in your character set.
-
- <p><a name="index-character-lists_002c-collating-elements-271"></a><a
name="index-character-lists_002c-non_002dASCII-272"></a><a
name="index-collating-elements-273"></a>Two additional special sequences can
appear in character lists.
-These apply to non-ASCII character sets, which can have single symbols
-(called <dfn>collating elements</dfn>) that are represented with more than one
-character. They can also have several characters that are equivalent for
-<dfn>collating</dfn>, or sorting, purposes. (For example, in French, a plain
“e”
-and a grave-accented “è” are equivalent.)
-These sequences are:
-
-
-<a name="index-character-lists_002c-collating-symbols-274"></a>
-<a name="index-collating-symbols-275"></a>
-<dl><dt>Collating symbols<dd>Multicharacter collating elements enclosed between
-`<samp><span class="samp">[.</span></samp>' and `<samp><span
class="samp">.]</span></samp>'. For example, if `<samp><span
class="samp">ch</span></samp>' is a collating element,
-then <code>[[.ch.]]</code> is a regexp that matches this collating element,
whereas
-<code>[ch]</code> is a regexp that matches either `<samp><span
class="samp">c</span></samp>' or `<samp><span class="samp">h</span></samp>'.
-
- <p><a
name="index-character-lists_002c-equivalence-classes-276"></a><br><dt>Equivalence
classes<dd>Locale-specific names for a list of
-characters that are equal. The name is enclosed between
-`<samp><span class="samp">[=</span></samp>' and `<samp><span
class="samp">=]</span></samp>'.
-For example, the name `<samp><span class="samp">e</span></samp>' might be used
to represent all of
-“e,” “è,” and “é.” In this
case, <code>[[=e=]]</code> is a regexp
-that matches any of `<samp><span class="samp">e</span></samp>', `<samp><span
class="samp">é</span></samp>', or `<samp><span
class="samp">è</span></samp>'.
-</dl>
-
- <p>These features are very valuable in non-English-speaking locales.
-
- <p><a
name="index-internationalization_002c-localization_002c-character-classes-277"></a><a
name="index-_0040command_007bgawk_007d_002c-character-classes-and-278"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-character-lists-and_002c-character-classes-279"></a><strong>Caution:</strong>
The library functions that <samp><span class="command">gawk</span></samp> uses
for regular
-expression matching currently recognize only POSIX character classes;
-they do not recognize collating symbols or equivalence classes.
-<!-- maybe one day ... -->
-<!-- ENDOFRANGE charlist -->
-
- </body></html>
-
Index: manual/html_node/Cliff-Random-Function.html
===================================================================
RCS file: manual/html_node/Cliff-Random-Function.html
diff -N manual/html_node/Cliff-Random-Function.html
--- manual/html_node/Cliff-Random-Function.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,93 +0,0 @@
-<html lang="en">
-<head>
-<title>Cliff Random Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Round-Function.html#Round-Function" title="Round
Function">
-<link rel="next" href="Ordinal-Functions.html#Ordinal-Functions"
title="Ordinal Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Cliff-Random-Function"></a>Next: <a rel="next" accesskey="n"
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Round-Function.html#Round-Function">Round Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.5 The Cliff Random Number Generator</h4>
-
-<p><a name="index-random-numbers_002c-Cliff-1637"></a><a
name="index-Cliff-random-numbers-1638"></a><a
name="index-numbers_002c-Cliff-random-1639"></a><a
name="index-functions_002c-library_002c-Cliff-random-numbers-1640"></a>
-The Cliff random number
-generator<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-is a very simple random number generator that “passes the noise sphere
test
-for randomness by showing no structure.”
-It is easily programmed, in less than 10 lines of <samp><span
class="command">awk</span></samp> code:
-
- <p><a
name="index-_0040code_007bcliff_005frand_007d-user_002ddefined-function-1641"></a>
-<pre class="example"> <!-- file eg/lib/cliff_rand.awk -->
- # cliff_rand.awk --- generate Cliff random numbers
- <!-- endfile -->
- <!-- file eg/lib/cliff_rand.awk -->
- BEGIN { _cliff_seed = 0.1 }
-
- function cliff_rand()
- {
- _cliff_seed = (100 * log(_cliff_seed)) % 1
- if (_cliff_seed < 0)
- _cliff_seed = - _cliff_seed
- return _cliff_seed
- }
- <!-- endfile -->
-</pre>
- <p>This algorithm requires an initial “seed” of 0.1. Each new
value
-uses the current seed as input for the calculation.
-If the built-in <code>rand</code> function
-(see <a href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a>)
-isn't random enough, you might try using this function instead.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <a
href="http://mathworld.wolfram.com/CliffRandomNumberGenerator.hmtl">http://mathworld.wolfram.com/CliffRandomNumberGenerator.hmtl</a></p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Clones.html
===================================================================
RCS file: manual/html_node/Clones.html
diff -N manual/html_node/Clones.html
--- manual/html_node/Clones.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-<html lang="en">
-<head>
-<title>Clones - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Sample-Programs.html#Sample-Programs" title="Sample
Programs">
-<link rel="prev" href="Running-Examples.html#Running-Examples" title="Running
Examples">
-<link rel="next" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Clones"></a>Next: <a rel="next" accesskey="n"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>,
-Previous: <a rel="previous" accesskey="p"
href="Running-Examples.html#Running-Examples">Running Examples</a>,
-Up: <a rel="up" accesskey="u"
href="Sample-Programs.html#Sample-Programs">Sample Programs</a>
-<hr><br>
-</div>
-
-<h3 class="section">13.2 Reinventing Wheels for Fun and Profit</h3>
-
-<!-- STARTOFRANGE posimawk -->
-<p><a
name="index-POSIX_002c-programs_0040comma_007b_007d-implementing-in-_0040command_007bawk_007d-1742"></a>
-This section presents a number of POSIX utilities that are implemented in
-<samp><span class="command">awk</span></samp>. Reinventing these programs in
<samp><span class="command">awk</span></samp> is often enjoyable,
-because the algorithms can be very clearly expressed, and the code is usually
-very concise and simple. This is true because <samp><span
class="command">awk</span></samp> does so much for you.
-
- <p>It should be noted that these programs are not necessarily intended to
-replace the installed versions on your system. Instead, their
-purpose is to illustrate <samp><span class="command">awk</span></samp>
language programming for “real world”
-tasks.
-
- <p>The programs are presented in alphabetical order.
-
-<ul class="menu">
-<li><a accesskey="1" href="Cut-Program.html#Cut-Program">Cut Program</a>:
The <samp><span class="command">cut</span></samp> utility.
-<li><a accesskey="2" href="Egrep-Program.html#Egrep-Program">Egrep
Program</a>: The <samp><span class="command">egrep</span></samp>
utility.
-<li><a accesskey="3" href="Id-Program.html#Id-Program">Id Program</a>:
The <samp><span class="command">id</span></samp> utility.
-<li><a accesskey="4" href="Split-Program.html#Split-Program">Split
Program</a>: The <samp><span class="command">split</span></samp>
utility.
-<li><a accesskey="5" href="Tee-Program.html#Tee-Program">Tee Program</a>:
The <samp><span class="command">tee</span></samp> utility.
-<li><a accesskey="6" href="Uniq-Program.html#Uniq-Program">Uniq Program</a>:
The <samp><span class="command">uniq</span></samp> utility.
-<li><a accesskey="7" href="Wc-Program.html#Wc-Program">Wc Program</a>:
The <samp><span class="command">wc</span></samp> utility.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Close-Files-And-Pipes.html
===================================================================
RCS file: manual/html_node/Close-Files-And-Pipes.html
diff -N manual/html_node/Close-Files-And-Pipes.html
--- manual/html_node/Close-Files-And-Pipes.html 7 Feb 2007 02:36:56 -0000
1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,247 +0,0 @@
-<html lang="en">
-<head>
-<title>Close Files And Pipes - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="Special-Files.html#Special-Files" title="Special Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Close-Files-And-Pipes"></a>Previous: <a rel="previous"
accesskey="p" href="Special-Files.html#Special-Files">Special Files</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.8 Closing Input and Output Redirections</h3>
-
-<p><a name="index-files_002c-output_002c-See-output-files-588"></a><!--
STARTOFRANGE ifc -->
-<a name="index-input-files_002c-closing-589"></a><!-- STARTOFRANGE ofc -->
-<a name="index-output_002c-files_0040comma_007b_007d-closing-590"></a><!--
STARTOFRANGE pc -->
-<a name="index-pipes_002c-closing-591"></a><!-- STARTOFRANGE cc -->
-<a name="index-coprocesses_002c-closing-592"></a><a
name="index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-593"></a>
-If the same file name or the same shell command is used with
<code>getline</code>
-more than once during the execution of an <samp><span
class="command">awk</span></samp> program
-(see <a href="Getline.html#Getline">Getline</a>),
-the file is opened (or the command is executed) the first time only.
-At that time, the first record of input is read from that file or command.
-The next time the same file or command is used with <code>getline</code>,
-another record is read from it, and so on.
-
- <p>Similarly, when a file or pipe is opened for output, the file name or
-command associated with it is remembered by <samp><span
class="command">awk</span></samp>, and subsequent
-writes to the same file or command are appended to the previous writes.
-The file or pipe stays open until <samp><span
class="command">awk</span></samp> exits.
-
- <p><a name="index-_0040code_007bclose_007d-function-594"></a>This implies
that special steps are necessary in order to read the same
-file again from the beginning, or to rerun a shell command (rather than
-reading more output from the same command). The <code>close</code> function
-makes these things possible:
-
-<pre class="example"> close(<var>filename</var>)
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> close(<var>command</var>)
-</pre>
- <p>The argument <var>filename</var> or <var>command</var> can be any
expression. Its
-value must <em>exactly</em> match the string that was used to open the file or
-start the command (spaces and other “irrelevant” characters
-included). For example, if you open a pipe with this:
-
-<pre class="example"> "sort -r names" | getline foo
-</pre>
- <p class="noindent">then you must close it with this:
-
-<pre class="example"> close("sort -r names")
-</pre>
- <p>Once this function call is executed, the next <code>getline</code> from
that
-file or command, or the next <code>print</code> or <code>printf</code> to that
-file or command, reopens the file or reruns the command.
-Because the expression that you use to close a file or pipeline must
-exactly match the expression used to open the file or run the command,
-it is good practice to use a variable to store the file name or command.
-The previous example becomes the following:
-
-<pre class="example"> sortcom = "sort -r names"
- sortcom | getline foo
- ...
- close(sortcom)
-</pre>
- <p class="noindent">This helps avoid hard-to-find typographical errors in
your <samp><span class="command">awk</span></samp>
-programs. Here are some of the reasons for closing an output file:
-
- <ul>
-<li>To write a file and read it back later on in the same <samp><span
class="command">awk</span></samp>
-program. Close the file after writing it, then
-begin reading it with <code>getline</code>.
-
- <li>To write numerous files, successively, in the same <samp><span
class="command">awk</span></samp>
-program. If the files aren't closed, eventually <samp><span
class="command">awk</span></samp> may exceed a
-system limit on the number of open files in one process. It is best to
-close each one when the program has finished writing it.
-
- <li>To make a command finish. When output is redirected through a pipe,
-the command reading the pipe normally continues to try to read input
-as long as the pipe is open. Often this means the command cannot
-really do its work until the pipe is closed. For example, if
-output is redirected to the <samp><span class="command">mail</span></samp>
program, the message is not
-actually sent until the pipe is closed.
-
- <li>To run the same program a second time, with the same arguments.
-This is not the same thing as giving more input to the first run!
-
- <p>For example, suppose a program pipes output to the <samp><span
class="command">mail</span></samp> program.
-If it outputs several lines redirected to this pipe without closing
-it, they make a single message of several lines. By contrast, if the
-program closes the pipe after each line of output, then each line makes
-a separate message.
-</ul>
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bclose_007d-function-595"></a><a
name="index-portability_002c-_0040code_007bclose_007d-function-and-596"></a>If
you use more files than the system allows you to have open,
-<samp><span class="command">gawk</span></samp> attempts to multiplex the
available open files among
-your data files. <samp><span class="command">gawk</span></samp>'s ability to
do this depends upon the
-facilities of your operating system, so it may not always work. It is
-therefore both good practice and good portability advice to always
-use <code>close</code> on your files when you are done with them.
-In fact, if you are using a lot of pipes, it is essential that
-you close commands when done. For example, consider something like this:
-
-<pre class="example"> {
- ...
- command = ("grep " $1 " /some/file | my_prog -q " $3)
- while ((command | getline) > 0) {
- <var>process output of</var> command
- }
- # need close(command) here
- }
-</pre>
- <p>This example creates a new pipeline based on data in <em>each</em>
record.
-Without the call to <code>close</code> indicated in the comment, <samp><span
class="command">awk</span></samp>
-creates child processes to run the commands, until it eventually
-runs out of file descriptors for more pipelines.
-
- <p>Even though each command has finished (as indicated by the end-of-file
-return status from <code>getline</code>), the child process is not
-terminated;<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-<!-- Good old Unix: give the marketing guys fits, that's the ticket -->
-more importantly, the file descriptor for the pipe
-is not closed and released until <code>close</code> is called or
-<samp><span class="command">awk</span></samp> exits.
-
- <p><code>close</code> will silently do nothing if given an argument that
-does not represent a file, pipe or coprocess that was opened with
-a redirection.
-
- <p>Note also that `<samp><span class="samp">close(FILENAME)</span></samp>'
has no
-“magic” effects on the implicit loop that reads through the
-files named on the command line. It is, more likely, a close
-of a file that was never opened, so <samp><span
class="command">awk</span></samp> silently
-does nothing.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-pipes_0040comma_007b_007d-closing-597"></a>When
using the `<samp><span class="samp">|&</span></samp>' operator to
communicate with a coprocess,
-it is occasionally useful to be able to close one end of the two-way
-pipe without closing the other.
-This is done by supplying a second argument to <code>close</code>.
-As in any other call to <code>close</code>,
-the first argument is the name of the command or special file used
-to start the coprocess.
-The second argument should be a string, with either of the values
-<code>"to"</code> or <code>"from"</code>. Case does not matter.
-As this is an advanced feature, a more complete discussion is
-delayed until
-<a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>,
-which discusses it in more detail and gives an example.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Using <code>close</code>'s Return
Value</h4>
-
-<p><a
name="index-advanced-features_002c-_0040code_007bclose_007d-function-598"></a><a
name="index-dark-corner_002c-_0040code_007bclose_007d-function-599"></a><a
name="index-_0040code_007bclose_007d-function_002c-return-values-600"></a><a
name="index-return-values_0040comma_007b_007d-_0040code_007bclose_007d-function-601"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bclose_007d-function-602"></a><a
name="index-Unix-_0040command_007bawk_007d_002c-_0040code_007bclose_007d-function-and-603"></a>
-In many versions of Unix <samp><span class="command">awk</span></samp>, the
<code>close</code> function
-is actually a statement. It is a syntax error to try and use the return
-value from <code>close</code>:
-(d.c.)
-
-<pre class="example"> command = "..."
- command | getline info
- retval = close(command) # syntax error in most Unix awks
-</pre>
- <p><samp><span class="command">gawk</span></samp> treats <code>close</code>
as a function.
-The return value is −1 if the argument names something
-that was never opened with a redirection, or if there is
-a system problem closing the file or process.
-In these cases, <samp><span class="command">gawk</span></samp> sets the
built-in variable
-<code>ERRNO</code> to a string describing the problem.
-
- <p>In <samp><span class="command">gawk</span></samp>,
-when closing a pipe or coprocess,
-the return value is the exit status of the command.<a rel="footnote"
href="#fn-2" name="fnd-2"><sup>2</sup></a>
-Otherwise, it is the return value from the system's <code>close</code> or
-<code>fclose</code> C functions when closing input or output
-files, respectively.
-This value is zero if the close succeeds, or −1 if
-it fails.
-
- <p>The POSIX standard is very vague; it says that <code>close</code>
-returns zero on success and non-zero otherwise. In general,
-different implementations vary in what they report when closing
-pipes; thus the return value cannot be used portably.
-(d.c.)
-
-<!-- ENDOFRANGE ifc -->
-<!-- ENDOFRANGE ofc -->
-<!-- ENDOFRANGE pc -->
-<!-- ENDOFRANGE cc -->
-<!-- ENDOFRANGE prnt -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The technical terminology is rather morbid.
-The finished child is called a “zombie,” and cleaning up after
-it is referred to as “reaping.”</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
-This is a full 16-bit value as returned by the <code>wait</code>
-system call. See the system manual pages for information on
-how to decode this value.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Command-Line-Field-Separator.html
===================================================================
RCS file: manual/html_node/Command-Line-Field-Separator.html
diff -N manual/html_node/Command-Line-Field-Separator.html
--- manual/html_node/Command-Line-Field-Separator.html 31 Aug 2004 22:04:10
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,147 +0,0 @@
-<html lang="en">
-<head>
-<title>Command Line Field Separator - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Field-Separators.html#Field-Separators" title="Field
Separators">
-<link rel="prev" href="Single-Character-Fields.html#Single-Character-Fields"
title="Single Character Fields">
-<link rel="next" href="Field-Splitting-Summary.html#Field-Splitting-Summary"
title="Field Splitting Summary">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Command-Line-Field-Separator"></a>Next: <a rel="next"
accesskey="n" href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field
Splitting Summary</a>,
-Previous: <a rel="previous" accesskey="p"
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Field-Separators.html#Field-Separators">Field Separators</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.5.3 Setting <code>FS</code> from the Command Line</h4>
-
-<p><a name="index-_0040code_007b_002dF_007d-option-423"></a><a
name="index-options_002c-command_002dline-424"></a><a
name="index-command-line_002c-options-425"></a><a
name="index-field-separators_002c-on-command-line-426"></a><a
name="index-command-line_002c-_0040code_007bFS_007d-on_0040comma_007b_007d-setting-427"></a><a
name="index-_0040code_007bFS_007d-variable_002c-setting-from-command-line-428"></a>
-<code>FS</code> can be set on the command line. Use the <samp><span
class="option">-F</span></samp> option to
-do so. For example:
-
-<pre class="example"> awk -F, '<var>program</var>' <var>input-files</var>
-</pre>
- <p class="noindent">sets <code>FS</code> to the `<samp><span
class="samp">,</span></samp>' character. Notice that the option uses
-an uppercase `<samp><span class="samp">F</span></samp>' instead of a lowercase
`<samp><span class="samp">f</span></samp>'. The latter
-option (<samp><span class="option">-f</span></samp>) specifies a file
-containing an <samp><span class="command">awk</span></samp> program. Case is
significant in command-line
-options:
-the <samp><span class="option">-F</span></samp> and <samp><span
class="option">-f</span></samp> options have nothing to do with each other.
-You can use both options at the same time to set the <code>FS</code> variable
-<em>and</em> get an <samp><span class="command">awk</span></samp> program from
a file.
-
- <p>The value used for the argument to <samp><span
class="option">-F</span></samp> is processed in exactly the
-same way as assignments to the built-in variable <code>FS</code>.
-Any special characters in the field separator must be escaped
-appropriately. For example, to use a `<samp><span
class="samp">\</span></samp>' as the field separator
-on the command line, you would have to type:
-
-<pre class="example"> # same as FS = "\\"
- awk -F\\\\ '...' files ...
-</pre>
- <p class="noindent"><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-as-field-separators-429"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-as-field-separators-430"></a>Because
`<samp><span class="samp">\</span></samp>' is used for quoting in the shell,
<samp><span class="command">awk</span></samp> sees
-`<samp><span class="samp">-F\\</span></samp>'. Then <samp><span
class="command">awk</span></samp> processes the `<samp><span
class="samp">\\</span></samp>' for escape
-characters (see <a href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a>), finally yielding
-a single `<samp><span class="samp">\</span></samp>' to use for the field
separator.
-
-<!-- @cindex historical features -->
-<p>As a special case, in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-if the argument to <samp><span class="option">-F</span></samp> is `<samp><span
class="samp">t</span></samp>', then <code>FS</code> is set to
-the TAB character. If you type `<samp><span class="samp">-F\t</span></samp>'
at the
-shell, without any quotes, the `<samp><span class="samp">\</span></samp>' gets
deleted, so <samp><span class="command">awk</span></samp>
-figures that you really want your fields to be separated with tabs and
-not `<samp><span class="samp">t</span></samp>'s. Use `<samp><span
class="samp">-v FS="t"</span></samp>' or `<samp><span
class="samp">-F"[t]"</span></samp>' on the command line
-if you really do want to separate your fields with `<samp><span
class="samp">t</span></samp>'s.
-
- <p>For example, let's use an <samp><span class="command">awk</span></samp>
program file called <samp><span class="file">baud.awk</span></samp>
-that contains the pattern <code>/300/</code> and the action `<samp><span
class="samp">print $1</span></samp>':
-
-<pre class="example"> /300/ { print $1 }
-</pre>
- <p>Let's also set <code>FS</code> to be the `<samp><span
class="samp">-</span></samp>' character and run the
-program on the file <samp><span class="file">BBS-list</span></samp>. The
following command prints a
-list of the names of the bulletin boards that operate at 300 baud and
-the first three digits of their phone numbers:
-
-<!-- tweaked to make the tex output look better in @smallbook -->
-<pre class="example"> $ awk -F- -f baud.awk BBS-list
- -| aardvark 555
- -| alpo
- -| barfly 555
- -| bites 555
- -| camelot 555
- -| core 555
- -| fooey 555
- -| foot 555
- -| macfoo 555
- -| sdace 555
- -| sabafoo 555
-</pre>
- <p class="noindent">Note the second line of output. The second line
-in the original file looked like this:
-
-<pre class="example"> alpo-net 555-3412 2400/1200/300 A
-</pre>
- <p>The `<samp><span class="samp">-</span></samp>' as part of the system's
name was used as the field
-separator, instead of the `<samp><span class="samp">-</span></samp>' in the
phone number that was
-originally intended. This demonstrates why you have to be careful in
-choosing your field and record separators.
-
- <p><a
name="index-Unix-_0040command_007bawk_007d_002c-password-files_0040comma_007b_007d-field-separators-and-431"></a>Perhaps
the most common use of a single character as the field
-separator occurs when processing the Unix system password file.
-On many Unix systems, each user has a separate entry in the system password
-file, one line per user. The information in these lines is separated
-by colons. The first field is the user's logon name and the second is
-the user's (encrypted or shadow) password. A password file entry might look
-like this:
-
- <p><a name="index-Robbins_002c-Arnold-432"></a>
-<pre class="example"> arnold:xyzzy:2076:10:Arnold
Robbins:/home/arnold:/bin/bash
-</pre>
- <p>The following program searches the system password file and prints
-the entries for users who have no password:
-
-<pre class="example"> awk -F: '$2 == ""' /etc/passwd
-</pre>
- </body></html>
-
Index: manual/html_node/Command-Line.html
===================================================================
RCS file: manual/html_node/Command-Line.html
diff -N manual/html_node/Command-Line.html
--- manual/html_node/Command-Line.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,78 +0,0 @@
-<html lang="en">
-<head>
-<title>Command Line - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="next" href="Options.html#Options" title="Options">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Command-Line"></a>Next: <a rel="next" accesskey="n"
href="Options.html#Options">Options</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.1 Invoking <samp><span
class="command">awk</span></samp></h3>
-
-<p><a
name="index-command-line_002c-invoking-_0040command_007bawk_007d-from-1467"></a><a
name="index-_0040command_007bawk_007d_002c-invoking-1468"></a><a
name="index-arguments_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1469"></a><a
name="index-options_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1470"></a>
-There are two ways to run <samp><span
class="command">awk</span></samp>—with an explicit program or with
-one or more program files. Here are templates for both of them; items
-enclosed in [<small class="dots">...</small>] in these templates are optional:
-
-<pre class="example"> awk <span
class="roman">[</span><var>options</var><span class="roman">]</span> -f
progfile <span class="roman">[</span><code>--</code><span
class="roman">]</span> <var>file</var> ...
- awk <span class="roman">[</span><var>options</var><span
class="roman">]</span> <span class="roman">[</span><code>--</code><span
class="roman">]</span> '<var>program</var>' <var>file</var> ...
-</pre>
- <p><a name="index-GNU-long-options-1471"></a><a
name="index-long-options-1472"></a><a
name="index-options_002c-long-1473"></a>Besides traditional one-letter
POSIX-style options, <samp><span class="command">gawk</span></samp> also
-supports GNU long options.
-
- <p><a
name="index-dark-corner_002c-invoking-_0040command_007bawk_007d-1474"></a><a
name="index-lint-checking_002c-empty-programs-1475"></a>It is possible to
invoke <samp><span class="command">awk</span></samp> with an empty program:
-
-<pre class="example"> awk '' datafile1 datafile2
-</pre>
- <p><a name="index-_0040code_007b_002d_002dlint_007d-option-1476"></a>Doing
so makes little sense, though; <samp><span class="command">awk</span></samp>
exits
-silently when given an empty program.
-(d.c.)
-If <samp><span class="option">--lint</span></samp> has
-been specified on the command line, <samp><span
class="command">gawk</span></samp> issues a
-warning that the program is empty.
-
- </body></html>
-
Index: manual/html_node/Comments.html
===================================================================
RCS file: manual/html_node/Comments.html
diff -N manual/html_node/Comments.html
--- manual/html_node/Comments.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-<html lang="en">
-<head>
-<title>Comments - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="prev" href="Executable-Scripts.html#Executable-Scripts"
title="Executable Scripts">
-<link rel="next" href="Quoting.html#Quoting" title="Quoting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Comments"></a>Next: <a rel="next" accesskey="n"
href="Quoting.html#Quoting">Quoting</a>,
-Previous: <a rel="previous" accesskey="p"
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a>,
-Up: <a rel="up" accesskey="u"
href="Running-gawk.html#Running-gawk">Running gawk</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.1.5 Comments in <samp><span
class="command">awk</span></samp> Programs</h4>
-
-<p><a
name="index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-commenting-113"></a><a
name="index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-commenting-114"></a><a
name="index-commenting-115"></a><a
name="index-_0040command_007bawk_007d-programs_002c-documenting-116"></a>
-A <dfn>comment</dfn> is some text that is included in a program for the sake
-of human readers; it is not really an executable part of the program. Comments
-can explain what the program does and how it works. Nearly all
-programming languages have provisions for comments, as programs are
-typically hard to understand without them.
-
- <p>In the <samp><span class="command">awk</span></samp> language, a comment
starts with the sharp sign
-character (`<samp><span class="samp">#</span></samp>') and continues to the
end of the line.
-The `<samp><span class="samp">#</span></samp>' does not have to be the first
character on the line. The
-<samp><span class="command">awk</span></samp> language ignores the rest of a
line following a sharp sign.
-For example, we could have put the following into <samp><span
class="file">advice</span></samp>:
-
-<pre class="example"> # This program prints a nice friendly message. It
helps
- # keep novice users from being afraid of the computer.
- BEGIN { print "Don't Panic!" }
-</pre>
- <p>You can put comment lines into keyboard-composed throwaway <samp><span
class="command">awk</span></samp>
-programs, but this usually isn't very useful; the purpose of a
-comment is to help you or another person understand the program
-when reading it at a later time.
-
- <p><a name="index-quoting-117"></a><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-vs_002e-apostrophe-118"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-vs_002e-apostrophe-119"></a><strong>Caution:</strong>
As mentioned in
-<a href="One_002dshot.html#One_002dshot">One-shot</a>,
-you can enclose small to medium programs in single quotes, in order to keep
-your shell scripts self-contained. When doing so, <em>don't</em> put
-an apostrophe (i.e., a single quote) into a comment (or anywhere else
-in your program). The shell interprets the quote as the closing
-quote for the entire program. As a result, usually the shell
-prints a message about mismatched quotes, and if <samp><span
class="command">awk</span></samp> actually
-runs, it will probably print strange messages about syntax errors.
-For example, look at the following:
-
-<pre class="example"> $ awk '{ print "hello" } # let's be cute'
- >
-</pre>
- <p>The shell sees that the first two quotes match, and that
-a new quoted object begins at the end of the command line.
-It therefore prompts with the secondary prompt, waiting for more input.
-With Unix <samp><span class="command">awk</span></samp>, closing the quoted
string produces this result:
-
-<pre class="example"> $ awk '{ print "hello" } # let's be cute'
- > '
- error--> awk: can't open file be
- error--> source line number 1
-</pre>
- <p><a name="index-_0040code_007b_005c_007d-_0028backslash_0029-120"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029-121"></a>Putting a
backslash before the single quote in `<samp><span
class="samp">let's</span></samp>' wouldn't help,
-since backslashes are not special inside single quotes.
-The next subsection describes the shell's quoting rules.
-
- </body></html>
-
Index: manual/html_node/Compatibility-Mode.html
===================================================================
RCS file: manual/html_node/Compatibility-Mode.html
diff -N manual/html_node/Compatibility-Mode.html
--- manual/html_node/Compatibility-Mode.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-<html lang="en">
-<head>
-<title>Compatibility Mode - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Notes.html#Notes" title="Notes">
-<link rel="next" href="Additions.html#Additions" title="Additions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Compatibility-Mode"></a>Next: <a rel="next" accesskey="n"
href="Additions.html#Additions">Additions</a>,
-Up: <a rel="up" accesskey="u" href="Notes.html#Notes">Notes</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">C.1 Downward Compatibility and Debugging</h3>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-downward-compatibility-1951"></a><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-debugging-1952"></a><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d-1953"></a><a
name="index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-debugging-1954"></a>
-See <a href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a>,
-for a summary of the GNU extensions to the <samp><span
class="command">awk</span></samp> language and program.
-All of these features can be turned off by invoking <samp><span
class="command">gawk</span></samp> with the
-<samp><span class="option">--traditional</span></samp> option or with the
<samp><span class="option">--posix</span></samp> option.
-
- <p>If <samp><span class="command">gawk</span></samp> is compiled for
debugging with `<samp><span class="samp">-DDEBUG</span></samp>', then there
-is one more option available on the command line:
-
- <dl>
-<dt><code>-W parsedebug</code><dt><code>--parsedebug</code><dd>Prints out the
parse stack information as the program is being parsed.
-</dl>
-
- <p>This option is intended only for serious <samp><span
class="command">gawk</span></samp> developers
-and not for the casual user. It probably has not even been compiled into
-your version of <samp><span class="command">gawk</span></samp>, since it slows
down execution.
-
- </body></html>
-
Index: manual/html_node/Computed-Regexps.html
===================================================================
RCS file: manual/html_node/Computed-Regexps.html
diff -N manual/html_node/Computed-Regexps.html
--- manual/html_node/Computed-Regexps.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-<html lang="en">
-<head>
-<title>Computed Regexps - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Leftmost-Longest.html#Leftmost-Longest" title="Leftmost
Longest">
-<link rel="next" href="Locales.html#Locales" title="Locales">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Computed-Regexps"></a>Next: <a rel="next" accesskey="n"
href="Locales.html#Locales">Locales</a>,
-Previous: <a rel="previous" accesskey="p"
href="Leftmost-Longest.html#Leftmost-Longest">Leftmost Longest</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.8 Using Dynamic Regexps</h3>
-
-<!-- STARTOFRANGE dregexp -->
-<p><a name="index-regular-expressions_002c-computed-325"></a><!-- STARTOFRANGE
regexpd -->
-<a name="index-regular-expressions_002c-dynamic-326"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-327"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-328"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-329"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-330"></a><!--
@cindex operators, @code{~} -->
-<!-- @cindex operators, @code{!~} -->
-The righthand side of a `<samp><span class="samp">~</span></samp>' or
`<samp><span class="samp">!~</span></samp>' operator need not be a
-regexp constant (i.e., a string of characters between slashes). It may
-be any expression. The expression is evaluated and converted to a string
-if necessary; the contents of the string are used as the
-regexp. A regexp that is computed in this way is called a <dfn>dynamic
-regexp</dfn>:
-
-<pre class="example"> BEGIN { digits_regexp = "[[:digit:]]+" }
- $0 ~ digits_regexp { print }
-</pre>
- <p class="noindent">This sets <code>digits_regexp</code> to a regexp that
describes one or more digits,
-and tests whether the input record matches this regexp.
-
- <p><strong>Caution:</strong> When using the `<samp><span
class="samp">~</span></samp>' and `<samp><span class="samp">!~</span></samp>'
-operators, there is a difference between a regexp constant
-enclosed in slashes and a string constant enclosed in double quotes.
-If you are going to use a string constant, you have to understand that
-the string is, in essence, scanned <em>twice</em>: the first time when
-<samp><span class="command">awk</span></samp> reads your program, and the
second time when it goes to
-match the string on the lefthand side of the operator with the pattern
-on the right. This is true of any string-valued expression (such as
-<code>digits_regexp</code>, shown previously), not just string constants.
-
- <p><a name="index-regexp-constants_002c-slashes-vs_002e-quotes-331"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-regexp-constants-332"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-regexp-constants-333"></a><a
name="index-_0040code_007b_0022_007d-_0028double-quote_0029_002c-regexp-constants-334"></a><a
name="index-double-quote-_0028_0040code_007b_0022_007d_0029_002c-regexp-constants-335"></a>What
difference does it make if the string is
-scanned twice? The answer has to do with escape sequences, and particularly
-with backslashes. To get a backslash into a regular expression inside a
-string, you have to type two backslashes.
-
- <p>For example, <code>/\*/</code> is a regexp constant for a literal
`<samp><span class="samp">*</span></samp>'.
-Only one backslash is needed. To do the same thing with a string,
-you have to type <code>"\\*"</code>. The first backslash escapes the
-second one so that the string actually contains the
-two characters `<samp><span class="samp">\</span></samp>' and `<samp><span
class="samp">*</span></samp>'.
-
- <p><a
name="index-troubleshooting_002c-regexp-constants-vs_002e-string-constants-336"></a><a
name="index-regexp-constants_002c-vs_002e-string-constants-337"></a><a
name="index-string-constants_002c-vs_002e-regexp-constants-338"></a>Given that
you can use both regexp and string constants to describe
-regular expressions, which should you use? The answer is “regexp
-constants,” for several reasons:
-
- <ul>
-<li>String constants are more complicated to write and
-more difficult to read. Using regexp constants makes your programs
-less error-prone. Not understanding the difference between the two
-kinds of constants is a common source of errors.
-
- <li>It is more efficient to use regexp constants. <samp><span
class="command">awk</span></samp> can note
-that you have supplied a regexp and store it internally in a form that
-makes pattern matching more efficient. When using a string constant,
-<samp><span class="command">awk</span></samp> must first convert the string
into this internal form and
-then perform the pattern matching.
-
- <li>Using regexp constants is better form; it shows clearly that you
-intend a regexp match.
-</ul>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Using <code>\n</code> in Character
Lists of Dynamic Regexps</h4>
-
-<p><a
name="index-regular-expressions_002c-dynamic_002c-with-embedded-newlines-339"></a><a
name="index-newlines_002c-in-dynamic-regexps-340"></a>
-Some commercial versions of <samp><span class="command">awk</span></samp> do
not allow the newline
-character to be used inside a character list for a dynamic regexp:
-
-<pre class="example"> $ awk '$0 ~ "[ \t\n]"'
- error--> awk: newline in character class [
- error--> ]...
- error--> source line number 1
- error--> context is
- error--> >>> <<<
-</pre>
- <p><a name="index-newlines_002c-in-regexp-constants-341"></a>But a newline
in a regexp constant works with no problem:
-
-<pre class="example"> $ awk '$0 ~ /[ \t\n]/'
- here is a sample line
- -| here is a sample line
- <kbd>Ctrl-d</kbd>
-</pre>
- <p><samp><span class="command">gawk</span></samp> does not have this
problem, and it isn't likely to
-occur often in practice, but it's worth noting for future reference.
-<!-- ENDOFRANGE dregexp -->
-<!-- ENDOFRANGE regexpd -->
-<!-- ENDOFRANGE regexp -->
-
- </body></html>
-
Index: manual/html_node/Concatenation.html
===================================================================
RCS file: manual/html_node/Concatenation.html
diff -N manual/html_node/Concatenation.html
--- manual/html_node/Concatenation.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,137 +0,0 @@
-<html lang="en">
-<head>
-<title>Concatenation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Arithmetic-Ops.html#Arithmetic-Ops" title="Arithmetic
Ops">
-<link rel="next" href="Assignment-Ops.html#Assignment-Ops" title="Assignment
Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Concatenation"></a>Next: <a rel="next" accesskey="n"
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.6 String Concatenation</h3>
-
-<p><a name="index-Kernighan_002c-Brian-662"></a><blockquote>
-<i>It seemed like a good idea at the time.</i><br>
-Brian Kernighan
-</blockquote>
-
- <p><a name="index-string-operators-663"></a><a
name="index-operators_002c-string-664"></a><a
name="index-concatenating-665"></a>There is only one string operation:
concatenation. It does not have a
-specific operator to represent it. Instead, concatenation is performed by
-writing expressions next to one another, with no operator. For example:
-
-<pre class="example"> $ awk '{ print "Field number one: " $1 }' BBS-list
- -| Field number one: aardvark
- -| Field number one: alpo-net
- ...
-</pre>
- <p>Without the space in the string constant after the `<samp><span
class="samp">:</span></samp>', the line
-runs together. For example:
-
-<pre class="example"> $ awk '{ print "Field number one:" $1 }' BBS-list
- -| Field number one:aardvark
- -| Field number one:alpo-net
- ...
-</pre>
- <p><a
name="index-troubleshooting_002c-string-concatenation-666"></a>Because string
concatenation does not have an explicit operator, it is
-often necessary to insure that it happens at the right time by using
-parentheses to enclose the items to concatenate. For example, the
-following code fragment does not concatenate <code>file</code> and
<code>name</code>
-as you might expect:
-
-<pre class="example"> file = "file"
- name = "name"
- print "something meaningful" > file name
-</pre>
- <p class="noindent">It is necessary to use the following:
-
-<pre class="example"> print "something meaningful" > (file name)
-</pre>
- <p><a name="index-order-of-evaluation_002c-concatenation-667"></a><a
name="index-evaluation-order_002c-concatenation-668"></a><a
name="index-side-effects-669"></a>Parentheses should be used around
concatenation in all but the
-most common contexts, such as on the righthand side of `<samp><span
class="samp">=</span></samp>'.
-Be careful about the kinds of expressions used in string concatenation.
-In particular, the order of evaluation of expressions used for concatenation
-is undefined in the <samp><span class="command">awk</span></samp> language.
Consider this example:
-
-<pre class="example"> BEGIN {
- a = "don't"
- print (a " " (a = "panic"))
- }
-</pre>
- <p class="noindent">It is not defined whether the assignment to
<code>a</code> happens
-before or after the value of <code>a</code> is retrieved for producing the
-concatenated value. The result could be either `<samp><span
class="samp">don't panic</span></samp>',
-or `<samp><span class="samp">panic panic</span></samp>'.
-<!-- see test/nasty.awk for a worse example -->
-The precedence of concatenation, when mixed with other operators, is often
-counter-intuitive. Consider this example:
-
-<pre class="example"> $ awk 'BEGIN { print -12 " " -24 }'
- -| -12-24
-</pre>
- <p>This “obviously” is concatenating −12, a space, and
−24.
-But where did the space disappear to?
-The answer lies in the combination of operator precedences and
-<samp><span class="command">awk</span></samp>'s automatic conversion rules.
To get the desired result,
-write the program in the following manner:
-
-<pre class="example"> $ awk 'BEGIN { print -12 " " (-24) }'
- -| -12 -24
-</pre>
- <p>This forces <samp><span class="command">awk</span></samp> to treat the
`<samp><span class="samp">-</span></samp>' on the `<samp><span
class="samp">-24</span></samp>' as unary.
-Otherwise, it's parsed as follows:
-
-<pre class="display"> −12 (<code>" "</code> − 24)
- => −12 (0 − 24)
- => −12 (−24)
- => −12−24
-</pre>
- <p>As mentioned earlier,
-when doing concatenation, <em>parenthesize</em>. Otherwise,
-you're never quite sure what you'll get.
-
- </body></html>
-
Index: manual/html_node/Conditional-Exp.html
===================================================================
RCS file: manual/html_node/Conditional-Exp.html
diff -N manual/html_node/Conditional-Exp.html
--- manual/html_node/Conditional-Exp.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-<html lang="en">
-<head>
-<title>Conditional Exp - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Boolean-Ops.html#Boolean-Ops" title="Boolean Ops">
-<link rel="next" href="Function-Calls.html#Function-Calls" title="Function
Calls">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Conditional-Exp"></a>Next: <a rel="next" accesskey="n"
href="Function-Calls.html#Function-Calls">Function Calls</a>,
-Previous: <a rel="previous" accesskey="p"
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.12 Conditional Expressions</h3>
-
-<p><a name="index-conditional-expressions-797"></a><a
name="index-expressions_002c-conditional-798"></a><a
name="index-expressions_002c-selecting-799"></a>
-A <dfn>conditional expression</dfn> is a special kind of expression that has
-three operands. It allows you to use one expression's value to select
-one of two other expressions.
-The conditional expression is the same as in the C language,
-as shown here:
-
-<pre class="example"> <var>selector</var> ? <var>if-true-exp</var> :
<var>if-false-exp</var>
-</pre>
- <p class="noindent">There are three subexpressions. The first,
<var>selector</var>, is always
-computed first. If it is “true” (not zero or not null), then
-<var>if-true-exp</var> is computed next and its value becomes the value of
-the whole expression. Otherwise, <var>if-false-exp</var> is computed next
-and its value becomes the value of the whole expression.
-For example, the following expression produces the absolute value of
<code>x</code>:
-
-<pre class="example"> x >= 0 ? x : -x
-</pre>
- <p><a name="index-side-effects_002c-conditional-expressions-800"></a>Each
time the conditional expression is computed, only one of
-<var>if-true-exp</var> and <var>if-false-exp</var> is used; the other is
ignored.
-This is important when the expressions have side effects. For example,
-this conditional expression examines element <code>i</code> of either array
-<code>a</code> or array <code>b</code>, and increments <code>i</code>:
-
-<pre class="example"> x == y ? a[i++] : b[i++]
-</pre>
- <p class="noindent">This is guaranteed to increment <code>i</code> exactly
once, because each time
-only one of the two increment expressions is executed
-and the other is not.
-See <a href="Arrays.html#Arrays">Arrays</a>,
-for more information about arrays.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-line-continuations-801"></a><a
name="index-line-continuations_002c-_0040command_007bgawk_007d-802"></a><a
name="index-_0040command_007bgawk_007d_002c-line-continuation-in-803"></a>As a
minor <samp><span class="command">gawk</span></samp> extension,
-a statement that uses `<samp><span class="samp">?:</span></samp>' can be
continued simply
-by putting a newline after either character.
-However, putting a newline in front
-of either character does not work without using backslash continuation
-(see <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>).
-If <samp><span class="option">--posix</span></samp> is specified
-(see <a href="Options.html#Options">Options</a>), then this extension is
disabled.
-
- </body></html>
-
Index: manual/html_node/Configuration-Philosophy.html
===================================================================
RCS file: manual/html_node/Configuration-Philosophy.html
diff -N manual/html_node/Configuration-Philosophy.html
--- manual/html_node/Configuration-Philosophy.html 31 Aug 2004 22:04:10
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-<html lang="en">
-<head>
-<title>Configuration Philosophy - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Unix-Installation.html#Unix-Installation" title="Unix
Installation">
-<link rel="prev"
href="Additional-Configuration-Options.html#Additional-Configuration-Options"
title="Additional Configuration Options">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Configuration-Philosophy"></a>Previous: <a rel="previous"
accesskey="p"
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>,
-Up: <a rel="up" accesskey="u"
href="Unix-Installation.html#Unix-Installation">Unix Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.2.3 The Configuration Process</h4>
-
-<p><a name="index-_0040command_007bgawk_007d_002c-configuring-1894"></a>This
section is of interest only if you know something about using the
-C language and the Unix operating system.
-
- <p>The source code for <samp><span class="command">gawk</span></samp>
generally attempts to adhere to formal
-standards wherever possible. This means that <samp><span
class="command">gawk</span></samp> uses library
-routines that are specified by the ISO C standard and by the POSIX
-operating system interface standard. When using an ISO C compiler,
-function prototypes are used to help improve the compile-time checking.
-
- <p>Many Unix systems do not support all of either the ISO or the
-POSIX standards. The <samp><span class="file">missing_d</span></samp>
subdirectory in the <samp><span class="command">gawk</span></samp>
-distribution contains replacement versions of those functions that are
-most likely to be missing.
-
- <p>The <samp><span class="file">config.h</span></samp> file that
<samp><span class="command">configure</span></samp> creates contains
-definitions that describe features of the particular operating system
-where you are attempting to compile <samp><span
class="command">gawk</span></samp>. The three things
-described by this file are: what header files are available, so that
-they can be correctly included, what (supposedly) standard functions
-are actually available in your C libraries, and various miscellaneous
-facts about your variant of Unix. For example, there may not be an
-<code>st_blksize</code> element in the <code>stat</code> structure. In this
case,
-`<samp><span class="samp">HAVE_ST_BLKSIZE</span></samp>' is undefined.
-
- <p><a name="index-_0040code_007bcustom_002eh_007d-file-1895"></a>It is
possible for your C compiler to lie to <samp><span
class="command">configure</span></samp>. It may
-do so by not exiting with an error when a library function is not
-available. To get around this, edit the file <samp><span
class="file">custom.h</span></samp>.
-Use an `<samp><span class="samp">#ifdef</span></samp>' that is appropriate for
your system, and either
-<code>#define</code> any constants that <samp><span
class="command">configure</span></samp> should have defined but
-didn't, or <code>#undef</code> any constants that <samp><span
class="command">configure</span></samp> defined and
-should not have. <samp><span class="file">custom.h</span></samp> is
automatically included by
-<samp><span class="file">config.h</span></samp>.
-
- <p>It is also possible that the <samp><span
class="command">configure</span></samp> program generated by
-<samp><span class="command">autoconf</span></samp> will not work on your
system in some other fashion.
-If you do have a problem, the file <samp><span
class="file">configure.in</span></samp> is the input for
-<samp><span class="command">autoconf</span></samp>. You may be able to change
this file and generate a
-new version of <samp><span class="command">configure</span></samp> that works
on your system
-(see <a href="Bugs.html#Bugs">Bugs</a>,
-for information on how to report problems in configuring <samp><span
class="command">gawk</span></samp>).
-The same mechanism may be used to send in updates to <samp><span
class="file">configure.in</span></samp>
-and/or <samp><span class="file">custom.h</span></samp>.
-
- </body></html>
-
Index: manual/html_node/Constant-Size.html
===================================================================
RCS file: manual/html_node/Constant-Size.html
diff -N manual/html_node/Constant-Size.html
--- manual/html_node/Constant-Size.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,165 +0,0 @@
-<html lang="en">
-<head>
-<title>Constant Size - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Field-Separators.html#Field-Separators" title="Field
Separators">
-<link rel="next" href="Multiple-Line.html#Multiple-Line" title="Multiple Line">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Constant-Size"></a>Next: <a rel="next" accesskey="n"
href="Multiple-Line.html#Multiple-Line">Multiple Line</a>,
-Previous: <a rel="previous" accesskey="p"
href="Field-Separators.html#Field-Separators">Field Separators</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.6 Reading Fixed-Width Data</h3>
-
-<blockquote>
-<b>NOTE:</b> This section discusses an advanced
-feature of <samp><span class="command">gawk</span></samp>. If you are a
novice <samp><span class="command">awk</span></samp> user,
-you might want to skip it on the first reading.
-</blockquote>
-
-<p><a name="index-data_002c-fixed_002dwidth-438"></a><a
name="index-fixed_002dwidth-data-439"></a><a
name="index-advanced-features_002c-fixed_002dwidth-data-440"></a><samp><span
class="command">gawk</span></samp> version 2.13 introduced a facility for
dealing with
-fixed-width fields with no distinctive field separator. For example,
-data of this nature arises in the input for old Fortran programs where
-numbers are run together, or in the output of programs that did not
-anticipate the use of their output as input for other programs.
-
- <p>An example of the latter is a table where all the columns are lined up by
-the use of a variable number of spaces and <em>empty fields are just
-spaces</em>. Clearly, <samp><span class="command">awk</span></samp>'s normal
field splitting based on <code>FS</code>
-does not work well in this case. Although a portable <samp><span
class="command">awk</span></samp> program
-can use a series of <code>substr</code> calls on <code>$0</code>
-(see <a href="String-Functions.html#String-Functions">String Functions</a>),
-this is awkward and inefficient for a large number of fields.
-
- <p><a
name="index-troubleshooting_002c-fatal-errors_002c-field-widths_0040comma_007b_007d-specifying-441"></a><a
name="index-_0040command_007bw_007d-utility-442"></a><a
name="index-_0040code_007bFIELDWIDTHS_007d-variable-443"></a>The splitting of
an input record into fixed-width fields is specified by
-assigning a string containing space-separated numbers to the built-in
-variable <code>FIELDWIDTHS</code>. Each number specifies the width of the
field,
-<em>including</em> columns between fields. If you want to ignore the columns
-between fields, you can specify the width as a separate field that is
-subsequently ignored.
-It is a fatal error to supply a field width that is not a positive number.
-The following data is the output of the Unix <samp><span
class="command">w</span></samp> utility. It is useful
-to illustrate the use of <code>FIELDWIDTHS</code>:
-
-<pre class="example"> 10:06pm up 21 days, 14:04, 23 users
- User tty login idle JCPU PCPU what
- hzuo ttyV0 8:58pm 9 5 vi p24.tex
- hzang ttyV3 6:37pm 50 -csh
- eklye ttyV5 9:53pm 7 1 em thes.tex
- dportein ttyV6 8:17pm 1:47 -csh
- gierd ttyD3 10:00pm 1 elm
- dave ttyD4 9:47pm 4 4 w
- brent ttyp0 26Jun91 4:46 26:46 4:41 bash
- dave ttyq4 26Jun9115days 46 46 wnewmail
-</pre>
- <p>The following program takes the above input, converts the idle time to
-number of seconds, and prints out the first two fields and the calculated
-idle time:
-
- <blockquote>
-<b>NOTE:</b> This program uses a number of <samp><span
class="command">awk</span></samp> features that
-haven't been introduced yet.
-</blockquote>
-
-<pre class="example"> BEGIN { FIELDWIDTHS = "9 6 10 6 7 7 35" }
- NR > 2 {
- idle = $4
- sub(/^ */, "", idle) # strip leading spaces
- if (idle == "")
- idle = 0
- if (idle ~ /:/) {
- split(idle, t, ":")
- idle = t[1] * 60 + t[2]
- }
- if (idle ~ /days/)
- idle *= 24 * 60 * 60
-
- print $1, $2, idle
- }
-</pre>
- <p>Running the program on the data produces the following results:
-
-<pre class="example"> hzuo ttyV0 0
- hzang ttyV3 50
- eklye ttyV5 0
- dportein ttyV6 107
- gierd ttyD3 1
- dave ttyD4 0
- brent ttyp0 286
- dave ttyq4 1296000
-</pre>
- <p>Another (possibly more practical) example of fixed-width input data
-is the input from a deck of balloting cards. In some parts of
-the United States, voters mark their choices by punching holes in computer
-cards. These cards are then processed to count the votes for any particular
-candidate or on any particular issue. Because a voter may choose not to
-vote on some issue, any column on the card may be empty. An <samp><span
class="command">awk</span></samp>
-program for processing such data could use the <code>FIELDWIDTHS</code> feature
-to simplify reading the data. (Of course, getting <samp><span
class="command">gawk</span></samp> to run on
-a system with card readers is another story!)
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-splitting-fields-and-444"></a>Assigning
a value to <code>FS</code> causes <samp><span
class="command">gawk</span></samp> to use
-<code>FS</code> for field splitting again. Use `<samp><span class="samp">FS =
FS</span></samp>' to make this happen,
-without having to know the current value of <code>FS</code>.
-In order to tell which kind of field splitting is in effect,
-use <code>PROCINFO["FS"]</code>
-(see <a href="Auto_002dset.html#Auto_002dset">Auto-set</a>).
-The value is <code>"FS"</code> if regular field splitting is being used,
-or it is <code>"FIELDWIDTHS"</code> if fixed-width field splitting is being
used:
-
-<pre class="example"> if (PROCINFO["FS"] == "FS")
- <var>regular field splitting</var> ...
- else
- <var>fixed-width field splitting</var> ...
-</pre>
- <p>This information is useful when writing a function
-that needs to temporarily change <code>FS</code> or <code>FIELDWIDTHS</code>,
-read some records, and then restore the original settings
-(see <a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>,
-for an example of such a function).
-
- </body></html>
-
Index: manual/html_node/Constants.html
===================================================================
RCS file: manual/html_node/Constants.html
diff -N manual/html_node/Constants.html
--- manual/html_node/Constants.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-<html lang="en">
-<head>
-<title>Constants - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="next" href="Using-Constant-Regexps.html#Using-Constant-Regexps"
title="Using Constant Regexps">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Constants"></a>Next: <a rel="next" accesskey="n"
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.1 Constant Expressions</h3>
-
-<p><a name="index-constants_002c-types-of-605"></a>
-The simplest type of expression is the <dfn>constant</dfn>, which always has
-the same value. There are three types of constants: numeric,
-string, and regular expression.
-
- <p>Each is used in the appropriate context when you need a data
-value that isn't going to change. Numeric constants can
-have different forms, but are stored identically internally.
-
-<ul class="menu">
-<li><a accesskey="1" href="Scalar-Constants.html#Scalar-Constants">Scalar
Constants</a>: Numeric and string constants.
-<li><a accesskey="2"
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>:
What are octal and hex numbers.
-<li><a accesskey="3" href="Regexp-Constants.html#Regexp-Constants">Regexp
Constants</a>: Regular Expression constants.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Continue-Statement.html
===================================================================
RCS file: manual/html_node/Continue-Statement.html
diff -N manual/html_node/Continue-Statement.html
--- manual/html_node/Continue-Statement.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,112 +0,0 @@
-<html lang="en">
-<head>
-<title>Continue Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="Break-Statement.html#Break-Statement" title="Break
Statement">
-<link rel="next" href="Next-Statement.html#Next-Statement" title="Next
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Continue-Statement"></a>Next: <a rel="next" accesskey="n"
href="Next-Statement.html#Next-Statement">Next Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="Break-Statement.html#Break-Statement">Break Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.7 The <code>continue</code> Statement</h4>
-
-<p><a name="index-_0040code_007bcontinue_007d-statement-966"></a>As with
<code>break</code>, the <code>continue</code> statement is used only inside
-<code>for</code>, <code>while</code>, and <code>do</code> loops. It skips
-over the rest of the loop body, causing the next cycle around the loop
-to begin immediately. Contrast this with <code>break</code>, which jumps out
-of the loop altogether.
-
- <p>The <code>continue</code> statement in a <code>for</code> loop directs
<samp><span class="command">awk</span></samp> to
-skip the rest of the body of the loop and resume execution with the
-increment-expression of the <code>for</code> statement. The following program
-illustrates this fact:
-
-<pre class="example"> BEGIN {
- for (x = 0; x <= 20; x++) {
- if (x == 5)
- continue
- printf "%d ", x
- }
- print ""
- }
-</pre>
- <p class="noindent">This program prints all the numbers from 0 to
20—except for 5, for
-which the <code>printf</code> is skipped. Because the increment `<samp><span
class="samp">x++</span></samp>'
-is not skipped, <code>x</code> does not remain stuck at 5. Contrast the
-<code>for</code> loop from the previous example with the following
<code>while</code> loop:
-
-<pre class="example"> BEGIN {
- x = 0
- while (x <= 20) {
- if (x == 5)
- continue
- printf "%d ", x
- x++
- }
- print ""
- }
-</pre>
- <p class="noindent">This program loops forever once <code>x</code> reaches
5.
-
-<!-- @cindex @code{continue}, outside of loops -->
-<!-- @cindex historical features -->
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bcontinue_007d-statement-and-967"></a><a
name="index-dark-corner_002c-_0040code_007bcontinue_007d-statement-968"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bcontinue_007d-statement-in-969"></a>The
<code>continue</code> statement has no meaning when used outside the body of
-a loop. Historical versions of <samp><span class="command">awk</span></samp>
treated a <code>continue</code>
-statement outside a loop the same way they treated a <code>break</code>
-statement outside a loop: as if it were a <code>next</code>
-statement
-(see <a href="Next-Statement.html#Next-Statement">Next Statement</a>).
-Recent versions of Unix <samp><span class="command">awk</span></samp> no
longer work this way, and
-<samp><span class="command">gawk</span></samp> allows it only if <samp><span
class="option">--traditional</span></samp> is specified on
-the command line (see <a href="Options.html#Options">Options</a>). Just like
the
-<code>break</code> statement, the POSIX standard specifies that
<code>continue</code>
-should only be used inside the body of a loop.
-(d.c.)
-
- </body></html>
-
Index: manual/html_node/Contributors.html
===================================================================
RCS file: manual/html_node/Contributors.html
diff -N manual/html_node/Contributors.html
--- manual/html_node/Contributors.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,171 +0,0 @@
-<html lang="en">
-<head>
-<title>Contributors - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Language-History.html#Language-History" title="Language
History">
-<link rel="prev" href="POSIX_002fGNU.html#POSIX_002fGNU" title="POSIX/GNU">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Contributors"></a>Previous: <a rel="previous" accesskey="p"
href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a>,
-Up: <a rel="up" accesskey="u"
href="Language-History.html#Language-History">Language History</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">A.6 Major Contributors to <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-list-of-contributors-to-1837"></a><blockquote>
-<i>Always give credit where credit is due.</i><br>
-Anonymous
-</blockquote>
-
- <p>This section names the major contributors to <samp><span
class="command">gawk</span></samp>
-and/or this Web page, in approximate chronological order:
-
- <ul>
-<li><a name="index-Aho_002c-Alfred-1838"></a><a
name="index-Weinberger_002c-Peter-1839"></a><a
name="index-Kernighan_002c-Brian-1840"></a>Dr. Alfred V. Aho,
-Dr. Peter J. Weinberger, and
-Dr. Brian W. Kernighan, all of Bell Laboratories,
-designed and implemented Unix <samp><span class="command">awk</span></samp>,
-from which <samp><span class="command">gawk</span></samp> gets the majority of
its feature set.
-
- <li><a name="index-Rubin_002c-Paul-1841"></a>Paul Rubin
-did the initial design and implementation in 1986, and wrote
-the first draft (around 40 pages) of this Web page.
-
- <li><a name="index-Fenlason_002c-Jay-1842"></a>Jay Fenlason
-finished the initial implementation.
-
- <li><a name="index-Close_002c-Diane-1843"></a>Diane Close
-revised the first draft of this Web page, bringing it
-to around 90 pages.
-
- <li><a name="index-Stallman_002c-Richard-1844"></a>Richard Stallman
-helped finish the implementation and the initial draft of this
-Web page.
-He is also the founder of the FSF and the GNU project.
-
- <li><a name="index-Woods_002c-John-1845"></a>John Woods
-contributed parts of the code (mostly fixes) in
-the initial version of <samp><span class="command">gawk</span></samp>.
-
- <li><a name="index-Trueman_002c-David-1846"></a>In 1988,
-David Trueman
-took over primary maintenance of <samp><span
class="command">gawk</span></samp>,
-making it compatible with “new” <samp><span
class="command">awk</span></samp>, and
-greatly improving its performance.
-
- <li><a name="index-Rankin_002c-Pat-1847"></a>Pat Rankin
-provided the VMS port and its documentation.
-
- <li><a name="index-Kwok_002c-Conrad-1848"></a><a
name="index-Garfinkle_002c-Scott-1849"></a><a
name="index-Williams_002c-Kent-1850"></a>Conrad Kwok,
-Scott Garfinkle,
-and
-Kent Williams
-did the initial ports to MS-DOS with various versions of MSC.
-
- <li><a name="index-Peterson_002c-Hal-1851"></a>Hal Peterson
-provided help in porting <samp><span class="command">gawk</span></samp> to
Cray systems.
-
- <li><a name="index-Rommel_002c-Kai-Uwe-1852"></a>Kai Uwe Rommel
-provided the initial port to OS/2 and its documentation.
-
- <li><a name="index-Jaegermann_002c-Michal-1853"></a>Michal Jaegermann
-provided the port to Atari systems and its documentation.
-He continues to provide portability checking with DEC Alpha
-systems, and has done a lot of work to make sure <samp><span
class="command">gawk</span></samp>
-works on non-32-bit systems.
-
- <li><a name="index-Fish_002c-Fred-1854"></a>Fred Fish
-provided the port to Amiga systems and its documentation.
-
- <li><a name="index-Deifik_002c-Scott-1855"></a>Scott Deifik
-currently maintains the MS-DOS port.
-
- <li><a name="index-Grigera_002c-Juan-1856"></a>Juan Grigera
-maintains the port to Windows32 systems.
-
- <li><a name="index-Hankerson_002c-Darrel-1857"></a>Dr. Darrel Hankerson
-acts as coordinator for the various ports to different PC platforms
-and creates binary distributions for various PC operating systems.
-He is also instrumental in keeping the documentation up to date for
-the various PC platforms.
-
- <li><a name="index-Zoulas_002c-Christos-1858"></a>Christos Zoulas
-provided the <code>extension</code>
-built-in function for dynamically adding new modules.
-
- <li><a name="index-Kahrs_002c-J_0040_0022urgen-1859"></a>Jürgen Kahrs
-contributed the initial version of the TCP/IP networking
-code and documentation, and motivated the inclusion of the `<samp><span
class="samp">|&</span></samp>' operator.
-
- <li><a name="index-Davies_002c-Stephen-1860"></a>Stephen Davies
-provided the port to Tandem systems and its documentation.
-
- <li><a name="index-Brown_002c-Martin-1861"></a>Martin Brown
-provided the port to BeOS and its documentation.
-
- <li><a name="index-Peters_002c-Arno-1862"></a>Arno Peters
-did the initial work to convert <samp><span class="command">gawk</span></samp>
to use
-GNU Automake and <code>gettext</code>.
-
- <li><a name="index-Broder_002c-Alan-J_002e_0040_003a-1863"></a>Alan J.
Broder
-provided the initial version of the <code>asort</code> function
-as well as the code for the new optional third argument to the
<code>match</code> function.
-
- <li><a name="index-Buening_002c-Andreas-1864"></a>Andreas Buening
-updated the <samp><span class="command">gawk</span></samp> port for OS/2.
-
- <p><a name="index-Hasegawa_002c-Isamu-1865"></a>Isamu Hasegawa,
-of IBM in Japan, contributed support for multibyte characters.
-
- <p><a name="index-Benzinger_002c-Michael-1866"></a>Michael Benzinger
contributed the initial code for <code>switch</code> statements.
-
- <p><a name="index-McPhee_002c-Patrick-1867"></a>Patrick T.J. McPhee
contributed the code for dynamic loading in Windows32
-environments.
-
- <li><a name="index-Robbins_002c-Arnold-1868"></a>Arnold Robbins
-has been working on <samp><span class="command">gawk</span></samp> since 1988,
at first
-helping David Trueman, and as the primary maintainer since around 1994.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Control-Letters.html
===================================================================
RCS file: manual/html_node/Control-Letters.html
diff -N manual/html_node/Control-Letters.html
--- manual/html_node/Control-Letters.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,140 +0,0 @@
-<html lang="en">
-<head>
-<title>Control Letters - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printf.html#Printf" title="Printf">
-<link rel="prev" href="Basic-Printf.html#Basic-Printf" title="Basic Printf">
-<link rel="next" href="Format-Modifiers.html#Format-Modifiers" title="Format
Modifiers">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Control-Letters"></a>Next: <a rel="next" accesskey="n"
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a>,
-Previous: <a rel="previous" accesskey="p"
href="Basic-Printf.html#Basic-Printf">Basic Printf</a>,
-Up: <a rel="up" accesskey="u" href="Printf.html#Printf">Printf</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.5.2 Format-Control Letters</h4>
-
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-format_002dcontrol-characters-532"></a><a
name="index-format-specifiers_002c-_0040code_007bprintf_007d-statement-533"></a>
-A format specifier starts with the character `<samp><span
class="samp">%</span></samp>' and ends with
-a <dfn>format-control letter</dfn>—it tells the <code>printf</code>
statement
-how to output one item. The format-control letter specifies what <em>kind</em>
-of value to print. The rest of the format specifier is made up of
-optional <dfn>modifiers</dfn> that control <em>how</em> to print the value,
such as
-the field width. Here is a list of the format-control letters:
-
- <dl>
-<dt><code>%c</code><dd>This prints a number as an ASCII character; thus,
`<samp><span class="samp">printf "%c",
-65</span></samp>' outputs the letter `<samp><span
class="samp">A</span></samp>'. (The output for a string value is
-the first character of the string.)
-
- <br><dt><code>%d</code><span class="roman">,</span><code>
%i</code><dd>These are equivalent; they both print a decimal integer.
-(The `<samp><span class="samp">%i</span></samp>' specification is for
compatibility with ISO C.)
-
- <br><dt><code>%e</code><span class="roman">,</span><code>
%E</code><dd>These print a number in scientific (exponential) notation;
-for example:
-
- <pre class="example"> printf "%4.3e\n", 1950
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">1.950e+03</span></samp>', with a total of four significant
figures, three of
-which follow the decimal point.
-(The `<samp><span class="samp">4.3</span></samp>' represents two modifiers,
-discussed in the next subsection.)
-`<samp><span class="samp">%E</span></samp>' uses `<samp><span
class="samp">E</span></samp>' instead of `<samp><span
class="samp">e</span></samp>' in the output.
-
- <br><dt><code>%f</code><dd>This prints a number in floating-point
notation.
-For example:
-
- <pre class="example"> printf "%4.3f", 1950
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">1950.000</span></samp>', with a total of four significant figures,
three of
-which follow the decimal point.
-(The `<samp><span class="samp">4.3</span></samp>' represents two modifiers,
-discussed in the next subsection.)
-
- <p>On systems supporting IEEE 754 floating point format, values
-representing negative
-infinity are formatted as
-`<samp><span class="samp">-inf</span></samp>' or `<samp><span
class="samp">-infinity</span></samp>',
-and positive infinity as
-`<samp><span class="samp">inf</span></samp>' and `<samp><span
class="samp">-infinity</span></samp>'.
-The special “not a number” value formats as `<samp><span
class="samp">-nan</span></samp>' or `<samp><span
class="samp">nan</span></samp>'.
-
- <br><dt><code>%F</code><dd>Like <code>%f</code> but the infinity and
“not a number” values are spelled
-using uppercase letters.
-
- <p>The <code>%F</code> format is a POSIX extension to ISO C; not all
systems
-support. On those that don't, <samp><span class="command">gawk</span></samp>
uses <code>%f</code> instead.
-
- <br><dt><code>%g</code><span class="roman">,</span><code>
%G</code><dd>These print a number in either scientific notation or in
floating-point
-notation, whichever uses fewer characters; if the result is printed in
-scientific notation, `<samp><span class="samp">%G</span></samp>' uses
`<samp><span class="samp">E</span></samp>' instead of `<samp><span
class="samp">e</span></samp>'.
-
- <br><dt><code>%o</code><dd>This prints an unsigned octal integer.
-
- <br><dt><code>%s</code><dd>This prints a string.
-
- <br><dt><code>%u</code><dd>This prints an unsigned decimal integer.
-(This format is of marginal use, because all numbers in <samp><span
class="command">awk</span></samp>
-are floating-point; it is provided primarily for compatibility with C.)
-
- <br><dt><code>%x</code><span class="roman">,</span><code>
%X</code><dd>These print an unsigned hexadecimal integer;
-`<samp><span class="samp">%X</span></samp>' uses the letters `<samp><span
class="samp">A</span></samp>' through `<samp><span class="samp">F</span></samp>'
-instead of `<samp><span class="samp">a</span></samp>' through `<samp><span
class="samp">f</span></samp>'.
-
- <br><dt><code>%%</code><dd>This isn't a format-control letter, but it
does have meaning—the
-sequence `<samp><span class="samp">%%</span></samp>' outputs one `<samp><span
class="samp">%</span></samp>'; it does not consume an
-argument and it ignores any modifiers.
-</dl>
-
- <p><a
name="index-dark-corner_002c-format_002dcontrol-characters-534"></a><a
name="index-_0040command_007bgawk_007d_002c-format_002dcontrol-characters-535"></a><blockquote>
-<b>NOTE:</b> When using the integer format-control letters for values that are
-outside the range of the widest C integer type, <samp><span
class="command">gawk</span></samp> switches to the
-the `<samp><span class="samp">%g</span></samp>' format specifier. If
<samp><span class="option">--lint</span></samp> is provided on the
-command line (see <a href="Options.html#Options">Options</a>), <samp><span
class="command">gawk</span></samp>
-warns about this. Other versions of <samp><span
class="command">awk</span></samp> may print invalid
-values or do something else entirely.
-(d.c.)
-</blockquote>
-
- </body></html>
-
Index: manual/html_node/Conventions.html
===================================================================
RCS file: manual/html_node/Conventions.html
diff -N manual/html_node/Conventions.html
--- manual/html_node/Conventions.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,112 +0,0 @@
-<html lang="en">
-<head>
-<title>Conventions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="prev" href="This-Manual.html#This-Manual" title="This Manual">
-<link rel="next" href="Manual-History.html#Manual-History" title="Manual
History">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Conventions"></a>Next: <a rel="next" accesskey="n"
href="Manual-History.html#Manual-History">Manual History</a>,
-Previous: <a rel="previous" accesskey="p"
href="This-Manual.html#This-Manual">This Manual</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="section">Typographical Conventions</h3>
-
-<p><a name="index-Texinfo-28"></a>This Web page is written using Texinfo, the
GNU documentation
-formatting language.
-A single Texinfo source file is used to produce both the printed and online
-versions of the documentation.
-Because of this, the typographical conventions
-are slightly different than in other books you may have read.
-
- <p>Examples you would type at the command-line are preceded by the common
-shell primary and secondary prompts, `<samp><span
class="samp">$</span></samp>' and `<samp><span
class="samp">></span></samp>'.
-Output from the command is preceded by the glyph “-|”.
-This typically represents the command's standard output.
-Error messages, and other output on the command's standard error, are preceded
-by the glyph “error-->”. For example:
-
-<pre class="example"> $ echo hi on stdout
- -| hi on stdout
- $ echo hello on stderr 1>&2
- error--> hello on stderr
-</pre>
- <p>In the text, command names appear in <code>this font</code>, while code
segments
-appear in the same font and quoted, `<samp><span class="samp">like
this</span></samp>'. Some things are
-emphasized <em>like this</em>, and if a point needs to be made
-strongly, it is done <strong>like this</strong>. The first occurrence of
-a new term is usually its <dfn>definition</dfn> and appears in the same
-font as the previous occurrence of “definition” in this sentence.
-file names are indicated like this: <samp><span
class="file">/path/to/ourfile</span></samp>.
-
- <p>Characters that you type at the keyboard look <kbd>like this</kbd>. In
particular,
-there are special characters called “control characters.” These
are
-characters that you type by holding down both the <kbd>CONTROL</kbd> key and
-another key, at the same time. For example, a <kbd>Ctrl-d</kbd> is typed
-by first pressing and holding the <kbd>CONTROL</kbd> key, next
-pressing the <kbd>d</kbd> key and finally releasing both keys.
-
-<!-- fakenode - for prepinfo -->
-<h5 class="subsubheading">Dark Corners</h5>
-
-<p><a name="index-Kernighan_002c-Brian-29"></a><blockquote>
-<i>Dark corners are basically fractal — no matter how much
-you illuminate, there's always a smaller but darker one.</i><br>
-Brian Kernighan
-</blockquote>
-
- <p><a name="index-d_002ec_002e_002c-See-dark-corner-30"></a><a
name="index-dark-corner-31"></a>Until the POSIX standard (and <cite>The Gawk
Manual</cite>),
-many features of <samp><span class="command">awk</span></samp> were either
poorly documented or not
-documented at all. Descriptions of such features
-(often called “dark corners”) are noted in this Web page with
-“(d.c.)”.
-They also appear in the index under the heading “dark corner.”
-
- <p>As noted by the opening quote, though, any
-coverage of dark corners
-is, by definition, something that is incomplete.
-
- </body></html>
-
Index: manual/html_node/Conversion.html
===================================================================
RCS file: manual/html_node/Conversion.html
diff -N manual/html_node/Conversion.html
--- manual/html_node/Conversion.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,166 +0,0 @@
-<html lang="en">
-<head>
-<title>Conversion - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Variables.html#Variables" title="Variables">
-<link rel="next" href="Arithmetic-Ops.html#Arithmetic-Ops" title="Arithmetic
Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Conversion"></a>Next: <a rel="next" accesskey="n"
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="Variables.html#Variables">Variables</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.4 Conversion of Strings and Numbers</h3>
-
-<p><a name="index-converting_002c-strings-to-numbers-640"></a><a
name="index-strings_002c-converting-641"></a><a
name="index-numbers_002c-converting-642"></a><a
name="index-converting_002c-numbers-643"></a>Strings are converted to numbers
and numbers are converted to strings, if the context
-of the <samp><span class="command">awk</span></samp> program demands it. For
example, if the value of
-either <code>foo</code> or <code>bar</code> in the expression `<samp><span
class="samp">foo + bar</span></samp>'
-happens to be a string, it is converted to a number before the addition
-is performed. If numeric values appear in string concatenation, they
-are converted to strings. Consider the following:
-
-<pre class="example"> two = 2; three = 3
- print (two three) + 4
-</pre>
- <p class="noindent">This prints the (numeric) value 27. The numeric values
of
-the variables <code>two</code> and <code>three</code> are converted to strings
and
-concatenated together. The resulting string is converted back to the
-number 23, to which 4 is then added.
-
- <p><a
name="index-null-strings_002c-converting-numbers-to-strings-644"></a><a
name="index-type-conversion-645"></a>If, for some reason, you need to force a
number to be converted to a
-string, concatenate the empty string, <code>""</code>, with that number.
-To force a string to be converted to a number, add zero to that string.
-A string is converted to a number by interpreting any numeric prefix
-of the string as numerals:
-<code>"2.5"</code> converts to 2.5, <code>"1e3"</code> converts to 1000, and
<code>"25fix"</code>
-has a numeric value of 25.
-Strings that can't be interpreted as valid numbers convert to zero.
-
- <p><a name="index-_0040code_007bCONVFMT_007d-variable-646"></a>The exact
manner in which numbers are converted into strings is controlled
-by the <samp><span class="command">awk</span></samp> built-in variable
<code>CONVFMT</code> (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-Numbers are converted using the <code>sprintf</code> function
-with <code>CONVFMT</code> as the format
-specifier
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <p><code>CONVFMT</code>'s default value is <code>"%.6g"</code>, which
prints a value with
-at least six significant digits. For some applications, you might want to
-change it to specify more precision.
-On most modern machines,
-17 digits is enough to capture a floating-point number's
-value exactly,
-most of the time.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p><a
name="index-dark-corner_002c-_0040code_007bCONVFMT_007d-variable-647"></a>Strange
results can occur if you set <code>CONVFMT</code> to a string that doesn't
-tell <code>sprintf</code> how to format floating-point numbers in a useful
way.
-For example, if you forget the `<samp><span class="samp">%</span></samp>' in
the format, <samp><span class="command">awk</span></samp> converts
-all numbers to the same constant string.
-As a special case, if a number is an integer, then the result of converting
-it to a string is <em>always</em> an integer, no matter what the value of
-<code>CONVFMT</code> may be. Given the following code fragment:
-
-<pre class="example"> CONVFMT = "%2.2f"
- a = 12
- b = a ""
-</pre>
- <p class="noindent"><code>b</code> has the value <code>"12"</code>, not
<code>"12.00"</code>.
-(d.c.)
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-648"></a><a
name="index-_0040code_007bOFMT_007d-variable-649"></a><a
name="index-portability_002c-new-_0040command_007bawk_007d-vs_002e-old-_0040command_007bawk_007d-650"></a><a
name="index-_0040command_007bawk_007d_002c-new-vs_002e-old_002c-_0040code_007bOFMT_007d-variable-651"></a>Prior
to the POSIX standard, <samp><span class="command">awk</span></samp> used the
value
-of <code>OFMT</code> for converting numbers to strings. <code>OFMT</code>
-specifies the output format to use when printing numbers with
<code>print</code>.
-<code>CONVFMT</code> was introduced in order to separate the semantics of
-conversion from the semantics of printing. Both <code>CONVFMT</code> and
-<code>OFMT</code> have the same default value: <code>"%.6g"</code>. In the
vast majority
-of cases, old <samp><span class="command">awk</span></samp> programs do not
change their behavior.
-However, these semantics for <code>OFMT</code> are something to keep in mind
if you must
-port your new style program to older implementations of <samp><span
class="command">awk</span></samp>.
-We recommend
-that instead of changing your programs, just port <samp><span
class="command">gawk</span></samp> itself.
-See <a href="Print.html#Print">Print</a>,
-for more information on the <code>print</code> statement.
-
- <p>Finally, once again, where you are can matter when it comes to
-converting between numbers and strings. In
-<a href="Locales.html#Locales">Locales</a>, we mentioned that the
-local character set and language (the locale) can affect how <samp><span
class="command">gawk</span></samp> matches
-characters. The locale also affects numeric formats. In particular, for
<samp><span class="command">awk</span></samp>
-programs, it affects the decimal point character. The <code>"C"</code>
locale, and most
-English-language locales, use the period character (`<samp><span
class="samp">.</span></samp>') as the decimal point.
-However, many (if not most) European and non-English locales use the comma
(`<samp><span class="samp">,</span></samp>')
-as the decimal point character.
-
- <p>The POSIX standard says that <samp><span
class="command">awk</span></samp> always uses the period as the decimal
-point when reading the <samp><span class="command">awk</span></samp> program
source code, and for command-line
-variable assignments (see <a href="Other-Arguments.html#Other-Arguments">Other
Arguments</a>).
-However, when interpreting input data, for <code>print</code> and
<code>printf</code> output,
-and for number to string conversion, the local decimal point character is
used.
-As of version 3.1.3, <samp><span class="command">gawk</span></samp> fully
complies with this aspect
-of the standard. Here are some examples indicating the difference in behavior,
-on a GNU/Linux system:
-
-<pre class="example"> $ gawk 'BEGIN { printf "%g\n", 3.1415927 }'
- -| 3.14159
- $ LC_ALL=en_DK gawk 'BEGIN { printf "%g\n", 3.1415927 }'
- -| 3,14159
- $ echo 4,321 | gawk '{ print $1 + 1 }'
- -| 5
- $ echo 4,321 | LC_ALL=en_DK gawk '{ print $1 + 1 }'
- -| 5,321
-</pre>
- <p class="noindent">The `<samp><span class="samp">en_DK</span></samp>'
locale is for English in Denmark, where the comma acts as
-the decimal point separator. In the normal <code>"C"</code> locale,
<samp><span class="command">gawk</span></samp>
-treats `<samp><span class="samp">4,321</span></samp>' as `<samp><span
class="samp">4</span></samp>', while in the Danish locale, it's treated
-as the full number, `<samp><span class="samp">4.321</span></samp>'.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Pathological cases can require up to
-752 digits (!), but we doubt that you need to worry about this.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Copying.html
===================================================================
RCS file: manual/html_node/Copying.html
diff -N manual/html_node/Copying.html
--- manual/html_node/Copying.html 29 Jun 2005 21:04:12 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,411 +0,0 @@
-<html lang="en">
-<head>
-<title>Copying - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Glossary.html#Glossary" title="Glossary">
-<link rel="next"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License"
title="GNU Free Documentation License">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Copying"></a>Next: <a rel="next" accesskey="n"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>,
-Previous: <a rel="previous" accesskey="p"
href="Glossary.html#Glossary">Glossary</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">GNU General Public License</h2>
-
-<div align="center">Version 2, June 1991</div>
-
-<pre class="display"> Copyright © 1989, 1991 Free Software
Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-</pre>
- <!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">Preamble</h3>
-
-<p>The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software—to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- <p>When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- <p>To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- <p>For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- <p>We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- <p>Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- <p>Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- <p>The precise terms and conditions for copying, distribution and
-modification follow.
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">Terms and Conditions for Copying, Distribution and
Modification</h3>
-
- <ol type=1 start=0>
-<li>This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The “Program”,
below,
-refers to any such program or work, and a “work based on the
Program”
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term “modification”.) Each licensee is addressed as
“you”.
-
- <p>Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- <li>You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
- <p>You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- <li>You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- <ol type=a start=1>
-<li>You must cause the modified files to carry prominent notices
-stating that you changed the files and the date of any change.
-
- <li>You must cause any work that you distribute or publish, that in
-whole or in part contains or is derived from the Program or any
-part thereof, to be licensed as a whole at no charge to all third
-parties under the terms of this License.
-
- <li>If the modified program normally reads commands interactively
-when run, you must cause it, when started running for such
-interactive use in the most ordinary way, to print or display an
-announcement including an appropriate copyright notice and a
-notice that there is no warranty (or else, saying that you provide
-a warranty) and that users may redistribute the program under
-these conditions, and telling the user how to view a copy of this
-License. (Exception: if the Program itself is interactive but
-does not normally print such an announcement, your work based on
-the Program is not required to print an announcement.)
- </ol>
-
- <p>These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
- <p>Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
- <p>In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- <li>You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- <ol type=a start=1>
-<li>Accompany it with the complete corresponding machine-readable
-source code, which must be distributed under the terms of Sections
-1 and 2 above on a medium customarily used for software interchange; or,
-
- <li>Accompany it with a written offer, valid for at least three
-years, to give any third party, for a charge no more than your
-cost of physically performing source distribution, a complete
-machine-readable copy of the corresponding source code, to be
-distributed under the terms of Sections 1 and 2 above on a medium
-customarily used for software interchange; or,
-
- <li>Accompany it with the information you received as to the offer
-to distribute corresponding source code. (This alternative is
-allowed only for noncommercial distribution and only if you
-received the program in object code or executable form with such
-an offer, in accord with Subsection b above.)
- </ol>
-
- <p>The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
- <p>If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- <li>You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- <li>You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- <li>Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- <li>If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
- <p>If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
- <p>It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
- <p>This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- <li>If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- <li>The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- <p>Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and “any
-later version”, you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- <li>If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- <!-- fakenode - for prepinfo -->
-<h3 class="heading">NO WARRANTY</h3>
-
- <li>BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- <li>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
- </ol>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="heading">END OF TERMS AND CONDITIONS</h3>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">How to Apply These Terms to Your New Programs</h3>
-
-<p>If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- <p>To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the “copyright” line and a pointer to where the full notice is
found.
-
-<pre class="smallexample"> <var>one line to give the program's name and an
idea of what it does.</var>
- Copyright (C) <var>year</var> <var>name of author</var>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
-</pre>
- <p>Also add information on how to contact you by electronic and paper mail.
-
- <p>If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-<pre class="smallexample"> Gnomovision version 69, Copyright (C)
<var>year</var> <var>name of author</var>
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
- type `show w'. This is free software, and you are welcome
- to redistribute it under certain conditions; type `show c'
- for details.
-</pre>
- <p>The hypothetical commands `<samp><span class="samp">show
w</span></samp>' and `<samp><span class="samp">show c</span></samp>' should show
-the appropriate parts of the General Public License. Of course, the
-commands you use may be called something other than `<samp><span
class="samp">show w</span></samp>' and
-`<samp><span class="samp">show c</span></samp>'; they could even be
mouse-clicks or menu items—whatever
-suits your program.
-
- <p>You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a “copyright disclaimer” for the program,
if
-necessary. Here is a sample; alter the names:
-
-<pre class="smallexample"> Yoyodyne, Inc., hereby disclaims all copyright
- interest in the program `Gnomovision'
- (which makes passes at compilers) written
- by James Hacker.
-
- <var>signature of Ty Coon</var>, 1 April 1989
- Ty Coon, President of Vice
-</pre>
- <p>This General Public License does not permit incorporating your program
into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.
-
- </body></html>
-
Index: manual/html_node/Cut-Program.html
===================================================================
RCS file: manual/html_node/Cut-Program.html
diff -N manual/html_node/Cut-Program.html
--- manual/html_node/Cut-Program.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,337 +0,0 @@
-<html lang="en">
-<head>
-<title>Cut Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="next" href="Egrep-Program.html#Egrep-Program" title="Egrep Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Cut-Program"></a>Next: <a rel="next" accesskey="n"
href="Egrep-Program.html#Egrep-Program">Egrep Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.1 Cutting out Fields and Columns</h4>
-
-<p><a name="index-_0040command_007bcut_007d-utility-1743"></a><!--
STARTOFRANGE cut -->
-<a name="index-_0040command_007bcut_007d-utility-1744"></a><!-- STARTOFRANGE
ficut -->
-<a name="index-fields_002c-cutting-1745"></a><!-- STARTOFRANGE colcut -->
-<a name="index-columns_002c-cutting-1746"></a>The <samp><span
class="command">cut</span></samp> utility selects, or “cuts,”
characters or fields
-from its standard input and sends them to its standard output.
-Fields are separated by tabs by default,
-but you may supply a command-line option to change the field
-<dfn>delimiter</dfn> (i.e., the field-separator character). <samp><span
class="command">cut</span></samp>'s
-definition of fields is less general than <samp><span
class="command">awk</span></samp>'s.
-
- <p>A common use of <samp><span class="command">cut</span></samp> might be
to pull out just the login name of
-logged-on users from the output of <samp><span
class="command">who</span></samp>. For example, the following
-pipeline generates a sorted, unique list of the logged-on users:
-
-<pre class="example"> who | cut -c1-8 | sort | uniq
-</pre>
- <p>The options for <samp><span class="command">cut</span></samp> are:
-
- <dl>
-<dt><code>-c </code><var>list</var><dd>Use <var>list</var> as the list of
characters to cut out. Items within the list
-may be separated by commas, and ranges of characters can be separated with
-dashes. The list `<samp><span class="samp">1-8,15,22-35</span></samp>'
specifies characters 1 through
-8, 15, and 22 through 35.
-
- <br><dt><code>-f </code><var>list</var><dd>Use <var>list</var> as the
list of fields to cut out.
-
- <br><dt><code>-d </code><var>delim</var><dd>Use <var>delim</var> as the
field-separator character instead of the tab
-character.
-
- <br><dt><code>-s</code><dd>Suppress printing of lines that do not contain
the field delimiter.
-</dl>
-
- <p>The <samp><span class="command">awk</span></samp> implementation of
<samp><span class="command">cut</span></samp> uses the <code>getopt</code>
library
-function (see <a href="Getopt-Function.html#Getopt-Function">Getopt
Function</a>)
-and the <code>join</code> library function
-(see <a href="Join-Function.html#Join-Function">Join Function</a>).
-
- <p>The program begins with a comment describing the options, the library
-functions needed, and a <code>usage</code> function that prints out a usage
-message and exits. <code>usage</code> is called if invalid arguments are
-supplied:
-
- <p><a name="index-_0040code_007bcut_002eawk_007d-program-1747"></a>
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- # cut.awk --- implement cut in awk
- <!-- endfile -->
- <!-- file eg/prog/cut.awk -->
- # Options:
- # -f list Cut fields
- # -d c Field delimiter character
- # -c list Cut characters
- #
- # -s Suppress lines without the delimiter
- #
- # Requires getopt and join library functions
-
- function usage( e1, e2)
- {
- e1 = "usage: cut [-f list] [-d c] [-s] [files...]"
- e2 = "usage: cut [-c list] [files...]"
- print e1 > "/dev/stderr"
- print e2 > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">The variables <code>e1</code> and <code>e2</code> are
used so that the function
-fits nicely on the
-page.
-screen.
-
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-running-_0040command_007bawk_007d-programs-and-1748"></a><a
name="index-_0040code_007bFS_007d-variable_002c-running-_0040command_007bawk_007d-programs-and-1749"></a>Next
comes a <code>BEGIN</code> rule that parses the command-line options.
-It sets <code>FS</code> to a single TAB character, because that is <samp><span
class="command">cut</span></samp>'s
-default field separator. The output field separator is also set to be the
-same as the input field separator. Then <code>getopt</code> is used to step
-through the command-line options. Exactly one of the variables
-<code>by_fields</code> or <code>by_chars</code> is set to true, to indicate
that
-processing should be done by fields or by characters, respectively.
-When cutting by characters, the output field separator is set to the null
-string:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- BEGIN \
- {
- FS = "\t" # default
- OFS = FS
- while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) {
- if (c == "f") {
- by_fields = 1
- fieldlist = Optarg
- } else if (c == "c") {
- by_chars = 1
- fieldlist = Optarg
- OFS = ""
- } else if (c == "d") {
- if (length(Optarg) > 1) {
- printf("Using first character of %s" \
- " for delimiter\n", Optarg) > "/dev/stderr"
- Optarg = substr(Optarg, 1, 1)
- }
- FS = Optarg
- OFS = FS
- if (FS == " ") # defeat awk semantics
- FS = "[ ]"
- } else if (c == "s")
- suppress++
- else
- usage()
- }
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
- <!-- endfile -->
-</pre>
- <p><a name="index-field-separators_002c-spaces-as-1750"></a>Special care is
taken when the field delimiter is a space. Using
-a single space (<code>" "<!-- /@w --></code>) for the value of
<code>FS</code> is
-incorrect—<samp><span class="command">awk</span></samp> would separate
fields with runs of spaces,
-tabs, and/or newlines, and we want them to be separated with individual
-spaces. Also, note that after <code>getopt</code> is through, we have to
-clear out all the elements of <code>ARGV</code> from 1 to <code>Optind</code>,
-so that <samp><span class="command">awk</span></samp> does not try to process
the command-line options
-as file names.
-
- <p>After dealing with the command-line options, the program verifies that
the
-options make sense. Only one or the other of <samp><span
class="option">-c</span></samp> and <samp><span class="option">-f</span></samp>
-should be used, and both require a field list. Then the program calls
-either <code>set_fieldlist</code> or <code>set_charlist</code> to pull apart
the
-list of fields or characters:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- if (by_fields && by_chars)
- usage()
-
- if (by_fields == 0 && by_chars == 0)
- by_fields = 1 # default
-
- if (fieldlist == "") {
- print "cut: needs list for -c or -f" > "/dev/stderr"
- exit 1
- }
-
- if (by_fields)
- set_fieldlist()
- else
- set_charlist()
- }
- <!-- endfile -->
-</pre>
- <p><code>set_fieldlist</code> is used to split the field list apart at the
commas
-and into an array. Then, for each element of the array, it looks to
-see if it is actually a range, and if so, splits it apart. The range
-is verified to make sure the first number is smaller than the second.
-Each number in the list is added to the <code>flist</code> array, which
-simply lists the fields that will be printed. Normal field splitting
-is used. The program lets <samp><span class="command">awk</span></samp>
handle the job of doing the
-field splitting:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- function set_fieldlist( n, m, i, j, k, f, g)
- {
- n = split(fieldlist, f, ",")
- j = 1 # index in flist
- for (i = 1; i <= n; i++) {
- if (index(f[i], "-") != 0) { # a range
- m = split(f[i], g, "-")
- if (m != 2 || g[1] >= g[2]) {
- printf("bad field list: %s\n",
- f[i]) > "/dev/stderr"
- exit 1
- }
- for (k = g[1]; k <= g[2]; k++)
- flist[j++] = k
- } else
- flist[j++] = f[i]
- }
- nfields = j - 1
- }
- <!-- endfile -->
-</pre>
- <p>The <code>set_charlist</code> function is more complicated than
<code>set_fieldlist</code>.
-The idea here is to use <samp><span class="command">gawk</span></samp>'s
<code>FIELDWIDTHS</code> variable
-(see <a href="Constant-Size.html#Constant-Size">Constant Size</a>),
-which describes constant-width input. When using a character list, that is
-exactly what we have.
-
- <p>Setting up <code>FIELDWIDTHS</code> is more complicated than simply
listing the
-fields that need to be printed. We have to keep track of the fields to
-print and also the intervening characters that have to be skipped.
-For example, suppose you wanted characters 1 through 8, 15, and
-22 through 35. You would use `<samp><span class="samp">-c
1-8,15,22-35</span></samp>'. The necessary value
-for <code>FIELDWIDTHS</code> is <code>"8 6 1 6 14"<!-- /@w
--></code>. This yields five
-fields, and the fields to print
-are <code>$1</code>, <code>$3</code>, and <code>$5</code>.
-The intermediate fields are <dfn>filler</dfn>,
-which is stuff in between the desired data.
-<code>flist</code> lists the fields to print, and <code>t</code> tracks the
-complete field list, including filler fields:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- function set_charlist( field, i, j, f, g, t,
- filler, last, len)
- {
- field = 1 # count total fields
- n = split(fieldlist, f, ",")
- j = 1 # index in flist
- for (i = 1; i <= n; i++) {
- if (index(f[i], "-") != 0) { # range
- m = split(f[i], g, "-")
- if (m != 2 || g[1] >= g[2]) {
- printf("bad character list: %s\n",
- f[i]) > "/dev/stderr"
- exit 1
- }
- len = g[2] - g[1] + 1
- if (g[1] > 1) # compute length of filler
- filler = g[1] - last - 1
- else
- filler = 0
- if (filler)
- t[field++] = filler
- t[field++] = len # length of field
- last = g[2]
- flist[j++] = field - 1
- } else {
- if (f[i] > 1)
- filler = f[i] - last - 1
- else
- filler = 0
- if (filler)
- t[field++] = filler
- t[field++] = 1
- last = f[i]
- flist[j++] = field - 1
- }
- }
- FIELDWIDTHS = join(t, 1, field - 1)
- nfields = j - 1
- }
- <!-- endfile -->
-</pre>
- <p>Next is the rule that actually processes the data. If the <samp><span
class="option">-s</span></samp> option
-is given, then <code>suppress</code> is true. The first <code>if</code>
statement
-makes sure that the input record does have the field separator. If
-<samp><span class="command">cut</span></samp> is processing fields,
<code>suppress</code> is true, and the field
-separator character is not in the record, then the record is skipped.
-
- <p>If the record is valid, then <samp><span
class="command">gawk</span></samp> has split the data
-into fields, either using the character in <code>FS</code> or using
fixed-length
-fields and <code>FIELDWIDTHS</code>. The loop goes through the list of fields
-that should be printed. The corresponding field is printed if it contains
data.
-If the next field also has data, then the separator character is
-written out between the fields:
-
-<pre class="example"> <!-- file eg/prog/cut.awk -->
- {
- if (by_fields && suppress && index($0, FS) != 0)
- next
-
- for (i = 1; i <= nfields; i++) {
- if ($flist[i] != "") {
- printf "%s", $flist[i]
- if (i < nfields && $flist[i+1] != "")
- printf "%s", OFS
- }
- }
- print ""
- }
- <!-- endfile -->
-</pre>
- <p>This version of <samp><span class="command">cut</span></samp> relies on
<samp><span class="command">gawk</span></samp>'s <code>FIELDWIDTHS</code>
-variable to do the character-based cutting. While it is possible in
-other <samp><span class="command">awk</span></samp> implementations to use
<code>substr</code>
-(see <a href="String-Functions.html#String-Functions">String Functions</a>),
-it is also extremely painful.
-The <code>FIELDWIDTHS</code> variable supplies an elegant solution to the
problem
-of picking the input line apart by characters.
-<!-- ENDOFRANGE cut -->
-<!-- ENDOFRANGE ficut -->
-<!-- ENDOFRANGE colcut -->
-
-<!-- Exercise: Rewrite using split with "". -->
-</body></html>
-
Index: manual/html_node/Cygwin.html
===================================================================
RCS file: manual/html_node/Cygwin.html
diff -N manual/html_node/Cygwin.html
--- manual/html_node/Cygwin.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-<html lang="en">
-<head>
-<title>Cygwin - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link rel="prev" href="PC-Using.html#PC-Using" title="PC Using">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Cygwin"></a>Previous: <a rel="previous" accesskey="p"
href="PC-Using.html#PC-Using">PC Using</a>,
-Up: <a rel="up" accesskey="u"
href="PC-Installation.html#PC-Installation">PC Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.5 Using <samp><span
class="command">gawk</span></samp> In The Cygwin Environment</h5>
-
-<p><samp><span class="command">gawk</span></samp> can be used “out of
the box” under Windows if you are
-using the Cygwin environment.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-This environment provides an excellent simulation of Unix, using the
-GNU tools, such as <samp><span class="command">bash</span></samp>, the GNU
Compiler Collection (GCC),
-GNU Make, and other GNU tools. Compilation and installation for Cygwin
-is the same as for a Unix system:
-
-<pre class="example"> tar -xvpzf gawk-3.1.4.tar.gz
- cd gawk-3.1.4
- ./configure
- make
-</pre>
- <p>When compared to GNU/Linux on the same system, the `<samp><span
class="samp">configure</span></samp>'
-step on Cygwin takes considerably longer. However, it does finish,
-and then the `<samp><span class="samp">make</span></samp>' proceeds as usual.
-
- <blockquote>
-<b>NOTE:</b> The `<samp><span class="samp">|&</span></samp>' operator and
TCP/IP networking
-(see <a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a>)
-are fully supported in the Cygwin environment. This is not true
-for any other environment for MS-DOS or MS-Windows.
-</blockquote>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <a
href="http://www.cygwin.com">http://www.cygwin.com</a></p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Data-File-Management.html
===================================================================
RCS file: manual/html_node/Data-File-Management.html
diff -N manual/html_node/Data-File-Management.html
--- manual/html_node/Data-File-Management.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-<html lang="en">
-<head>
-<title>Data File Management - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Library-Functions.html#Library-Functions" title="Library
Functions">
-<link rel="prev" href="General-Functions.html#General-Functions"
title="General Functions">
-<link rel="next" href="Getopt-Function.html#Getopt-Function" title="Getopt
Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Data-File-Management"></a>Next: <a rel="next" accesskey="n"
href="Getopt-Function.html#Getopt-Function">Getopt Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="General-Functions.html#General-Functions">General Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Library-Functions.html#Library-Functions">Library Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">12.3 Data File Management</h3>
-
-<!-- STARTOFRANGE dataf -->
-<p><a name="index-files_002c-managing-1663"></a><!-- STARTOFRANGE libfdataf -->
-<a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-_0040value_007bDF_007ds-1664"></a><!--
STARTOFRANGE flibdataf -->
-<a
name="index-functions_002c-library_002c-managing-_0040value_007bDF_007ds-1665"></a>This
section presents functions that are useful for managing
-command-line data files.
-
-<ul class="menu">
-<li><a accesskey="1"
href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a>:
A function for handling data file transitions.
-<li><a accesskey="2" href="Rewind-Function.html#Rewind-Function">Rewind
Function</a>: A function for rereading the current file.
-<li><a accesskey="3" href="File-Checking.html#File-Checking">File
Checking</a>: Checking that data files are readable.
-<li><a accesskey="4" href="Empty-Files.html#Empty-Files">Empty Files</a>:
Checking for zero-length files.
-<li><a accesskey="5" href="Ignoring-Assigns.html#Ignoring-Assigns">Ignoring
Assigns</a>: Treating assignments as file names.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Definition-Syntax.html
===================================================================
RCS file: manual/html_node/Definition-Syntax.html
diff -N manual/html_node/Definition-Syntax.html
--- manual/html_node/Definition-Syntax.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,150 +0,0 @@
-<html lang="en">
-<head>
-<title>Definition Syntax - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="User_002ddefined.html#User_002ddefined"
title="User-defined">
-<link rel="next" href="Function-Example.html#Function-Example" title="Function
Example">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Definition-Syntax"></a>Next: <a rel="next" accesskey="n"
href="Function-Example.html#Function-Example">Function Example</a>,
-Up: <a rel="up" accesskey="u"
href="User_002ddefined.html#User_002ddefined">User-defined</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.2.1 Function Definition Syntax</h4>
-
-<!-- STARTOFRANGE fdef -->
-<p><a name="index-functions_002c-defining-1277"></a>Definitions of functions
can appear anywhere between the rules of an
-<samp><span class="command">awk</span></samp> program. Thus, the general form
of an <samp><span class="command">awk</span></samp> program is
-extended to include sequences of rules <em>and</em> user-defined function
-definitions.
-There is no need to put the definition of a function
-before all uses of the function. This is because <samp><span
class="command">awk</span></samp> reads the
-entire program before starting to execute any of it.
-
- <p>The definition of a function named <var>name</var> looks like this:
-<!-- NEXT ED: put [ ] around parameter list -->
-
-<pre class="example"> function <var>name</var>(<var>parameter-list</var>)
- {
- <var>body-of-function</var>
- }
-</pre>
- <p><a name="index-names_002c-functions-1278"></a><a
name="index-functions_002c-names-of-1279"></a><a
name="index-namespace-issues_002c-functions-1280"></a><var>name</var> is the
name of the function to define. A valid function
-name is like a valid variable name: a sequence of letters, digits, and
-underscores that doesn't start with a digit.
-Within a single <samp><span class="command">awk</span></samp> program, any
particular name can only be
-used as a variable, array, or function.
-
-<!-- NEXT ED: parameter-list is an OPTIONAL list of ... -->
-<p><var>parameter-list</var> is a list of the function's arguments and local
-variable names, separated by commas. When the function is called,
-the argument names are used to hold the argument values given in
-the call. The local variables are initialized to the empty string.
-A function cannot have two parameters with the same name, nor may it
-have a parameter with the same name as the function itself.
-
- <p>The <var>body-of-function</var> consists of <samp><span
class="command">awk</span></samp> statements. It is the
-most important part of the definition, because it says what the function
-should actually <em>do</em>. The argument names exist to give the body a
-way to talk about the arguments; local variables exist to give the body
-places to keep temporary values.
-
- <p>Argument names are not distinguished syntactically from local variable
-names. Instead, the number of arguments supplied when the function is
-called determines how many argument variables there are. Thus, if three
-argument values are given, the first three names in <var>parameter-list</var>
-are arguments and the rest are local variables.
-
- <p>It follows that if the number of arguments is not the same in all calls
-to the function, some of the names in <var>parameter-list</var> may be
-arguments on some occasions and local variables on others. Another
-way to think of this is that omitted arguments default to the
-null string.
-
- <p><a
name="index-programming-conventions_002c-functions_002c-writing-1281"></a>Usually
when you write a function, you know how many names you intend to
-use for arguments and how many you intend to use as local variables. It is
-conventional to place some extra space between the arguments and
-the local variables, in order to document how your function is supposed to be
used.
-
- <p><a name="index-variables_002c-shadowing-1282"></a>During execution of
the function body, the arguments and local variable
-values hide, or <dfn>shadow</dfn>, any variables of the same names used in the
-rest of the program. The shadowed variables are not accessible in the
-function definition, because there is no way to name them while their
-names have been taken away for the local variables. All other variables
-used in the <samp><span class="command">awk</span></samp> program can be
referenced or set normally in the
-function's body.
-
- <p>The arguments and local variables last only as long as the function body
-is executing. Once the body finishes, you can once again access the
-variables that were shadowed while the function was running.
-
- <p><a name="index-recursive-functions-1283"></a><a
name="index-functions_002c-recursive-1284"></a>The function body can contain
expressions that call functions. They
-can even call this function, either directly or by way of another
-function. When this happens, we say the function is <dfn>recursive</dfn>.
-The act of a function calling itself is called <dfn>recursion</dfn>.
-
-<!-- @cindex @command{awk} language, POSIX version -->
-<!-- @cindex POSIX @command{awk} -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bfunction_007d-keyword-in-1285"></a>In
many <samp><span class="command">awk</span></samp> implementations, including
<samp><span class="command">gawk</span></samp>,
-the keyword <code>function</code> may be
-abbreviated <code>func</code>. However, POSIX only specifies the use of
-the keyword <code>function</code>. This actually has some practical
implications.
-If <samp><span class="command">gawk</span></samp> is in POSIX-compatibility
mode
-(see <a href="Options.html#Options">Options</a>), then the following
-statement does <em>not</em> define a function:
-
-<pre class="example"> func foo() { a = sqrt($1) ; print a }
-</pre>
- <p class="noindent">Instead it defines a rule that, for each record,
concatenates the value
-of the variable `<samp><span class="samp">func</span></samp>' with the return
value of the function `<samp><span class="samp">foo</span></samp>'.
-If the resulting string is non-null, the action is executed.
-This is probably not what is desired. (<samp><span
class="command">awk</span></samp> accepts this input as
-syntactically valid, because functions may be used before they are defined
-in <samp><span class="command">awk</span></samp> programs.)
-<!-- NEXT ED: This won't actually run, since foo() is undefined ... -->
-
- <p><a
name="index-portability_002c-functions_0040comma_007b_007d-defining-1286"></a>To
ensure that your <samp><span class="command">awk</span></samp> programs are
portable, always use the
-keyword <code>function</code> when defining a function.
-
- </body></html>
-
Index: manual/html_node/Delete.html
===================================================================
RCS file: manual/html_node/Delete.html
diff -N manual/html_node/Delete.html
--- manual/html_node/Delete.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,131 +0,0 @@
-<html lang="en">
-<head>
-<title>Delete - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Scanning-an-Array.html#Scanning-an-Array"
title="Scanning an Array">
-<link rel="next" href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts"
title="Numeric Array Subscripts">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Delete"></a>Next: <a rel="next" accesskey="n"
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a>,
-Previous: <a rel="previous" accesskey="p"
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.6 The <code>delete</code> Statement</h3>
-
-<p><a name="index-_0040code_007bdelete_007d-statement-1103"></a><a
name="index-deleting-elements-in-arrays-1104"></a><a
name="index-arrays_002c-elements_002c-deleting-1105"></a><a
name="index-elements-in-arrays_002c-deleting-1106"></a>
-To remove an individual element of an array, use the <code>delete</code>
-statement:
-
-<pre class="example"> delete <var>array</var>[<var>index</var>]
-</pre>
- <p>Once an array element has been deleted, any value the element once
-had is no longer available. It is as if the element had never
-been referred to or had been given a value.
-The following is an example of deleting elements in an array:
-
-<pre class="example"> for (i in frequencies)
- delete frequencies[i]
-</pre>
- <p class="noindent">This example removes all the elements from the array
<code>frequencies</code>.
-Once an element is deleted, a subsequent <code>for</code> statement to scan
the array
-does not report that element and the <code>in</code> operator to check for
-the presence of that element returns zero (i.e., false):
-
-<pre class="example"> delete foo[4]
- if (4 in foo)
- print "This will never be printed"
-</pre>
- <p><a name="index-null-strings_002c-array-elements-and-1107"></a>It is
important to note that deleting an element is <em>not</em> the
-same as assigning it a null value (the empty string, <code>""</code>).
-For example:
-
-<pre class="example"> foo[4] = ""
- if (4 in foo)
- print "This is printed, even though foo[4] is empty"
-</pre>
- <p><a name="index-lint-checking_002c-array-elements-1108"></a>It is not an
error to delete an element that does not exist.
-If <samp><span class="option">--lint</span></samp> is provided on the command
line
-(see <a href="Options.html#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> issues a warning message when
an element that
-is not in the array is deleted.
-
- <p><a name="index-arrays_002c-deleting-entire-contents-1109"></a><a
name="index-deleting-entire-arrays-1110"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-array-elements_002c-deleting-1111"></a>All
the elements of an array may be deleted with a single statement
-by leaving off the subscript in the <code>delete</code> statement,
-as follows:
-
-<pre class="example"> delete <var>array</var>
-</pre>
- <p>This ability is a <samp><span class="command">gawk</span></samp>
extension; it is not available in
-compatibility mode (see <a href="Options.html#Options">Options</a>).
-
- <p>Using this version of the <code>delete</code> statement is about three
times
-more efficient than the equivalent loop that deletes each element one
-at a time.
-
- <p><a name="index-portability_002c-deleting-array-elements-1112"></a><a
name="index-Brennan_002c-Michael-1113"></a>The following statement provides a
portable but nonobvious way to clear
-out an array:<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
-<pre class="example"> split("", array)
-</pre>
- <p><a
name="index-_0040code_007bsplit_007d-function_002c-array-elements_0040comma_007b_007d-deleting-1114"></a>The
<code>split</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>)
-clears out the target array first. This call asks it to split
-apart the null string. Because there is no data to split out, the
-function simply clears the array and then returns.
-
- <p><strong>Caution:</strong> Deleting an array does not change its type;
you cannot
-delete an array and then use the array's name as a scalar
-(i.e., a regular variable). For example, the following does not work:
-
-<pre class="example"> a[1] = 3; delete a; a = 3
-</pre>
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Thanks to Michael Brennan for pointing this
out.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Distribution-contents.html
===================================================================
RCS file: manual/html_node/Distribution-contents.html
diff -N manual/html_node/Distribution-contents.html
--- manual/html_node/Distribution-contents.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,173 +0,0 @@
-<html lang="en">
-<head>
-<title>Distribution contents - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Gawk-Distribution.html#Gawk-Distribution" title="Gawk
Distribution">
-<link rel="prev" href="Extracting.html#Extracting" title="Extracting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Distribution-contents"></a>Previous: <a rel="previous"
accesskey="p" href="Extracting.html#Extracting">Extracting</a>,
-Up: <a rel="up" accesskey="u"
href="Gawk-Distribution.html#Gawk-Distribution">Gawk Distribution</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.1.3 Contents of the <samp><span
class="command">gawk</span></samp> Distribution</h4>
-
-<!-- STARTOFRANGE gawdis -->
-<p><a name="index-_0040command_007bgawk_007d_002c-distribution-1876"></a>
-The <samp><span class="command">gawk</span></samp> distribution has a number
of C source files,
-documentation files,
-subdirectories, and files related to the configuration process
-(see <a href="Unix-Installation.html#Unix-Installation">Unix Installation</a>),
-as well as several subdirectories related to different non-Unix
-operating systems:
-
- <dl>
-<dt>Various `<samp><span class="samp">.c</span></samp>', `<samp><span
class="samp">.y</span></samp>', and `<samp><span class="samp">.h</span></samp>'
files<dd>The actual <samp><span class="command">gawk</span></samp> source code.
-</dl>
-
- <dl>
-<dt><samp><span class="file">README</span></samp><dt><samp><span
class="file">README_d/README.*</span></samp><dd>Descriptive files: <samp><span
class="file">README</span></samp> for <samp><span
class="command">gawk</span></samp> under Unix and the
-rest for the various hardware and software combinations.
-
- <br><dt><samp><span class="file">INSTALL</span></samp><dd>A file
providing an overview of the configuration and installation process.
-
- <br><dt><samp><span class="file">ChangeLog</span></samp><dd>A detailed
list of source code changes as bugs are fixed or improvements made.
-
- <br><dt><samp><span class="file">NEWS</span></samp><dd>A list of changes
to <samp><span class="command">gawk</span></samp> since the last release or
patch.
-
- <br><dt><samp><span class="file">COPYING</span></samp><dd>The GNU General
Public License.
-
- <br><dt><samp><span class="file">FUTURES</span></samp><dd>A brief list of
features and changes being contemplated for future
-releases, with some indication of the time frame for the feature, based
-on its difficulty.
-
- <br><dt><samp><span class="file">LIMITATIONS</span></samp><dd>A list of
those factors that limit <samp><span class="command">gawk</span></samp>'s
performance.
-Most of these depend on the hardware or operating system software and
-are not limits in <samp><span class="command">gawk</span></samp> itself.
-
- <br><dt><samp><span class="file">POSIX.STD</span></samp><dd>A description
of one area in which the POSIX standard for <samp><span
class="command">awk</span></samp> is
-incorrect as well as how <samp><span class="command">gawk</span></samp>
handles the problem.
-
- <p><a
name="index-artificial-intelligence_0040comma_007b_007d-_0040command_007bgawk_007d-and-1877"></a><br><dt><samp><span
class="file">doc/awkforai.txt</span></samp><dd>A short article describing why
<samp><span class="command">gawk</span></samp> is a good language for
-AI (Artificial Intelligence) programming.
-
- <br><dt><samp><span
class="file">doc/README.card</span></samp><dt><samp><span
class="file">doc/ad.block</span></samp><dt><samp><span
class="file">doc/awkcard.in</span></samp><dt><samp><span
class="file">doc/cardfonts</span></samp><dt><samp><span
class="file">doc/colors</span></samp><dt><samp><span
class="file">doc/macros</span></samp><dt><samp><span
class="file">doc/no.colors</span></samp><dt><samp><span
class="file">doc/setter.outline</span></samp><dd>The <samp><span
class="command">troff</span></samp> source for a five-color <samp><span
class="command">awk</span></samp> reference card.
-A modern version of <samp><span class="command">troff</span></samp> such as
GNU <samp><span class="command">troff</span></samp> (<samp><span
class="command">groff</span></samp>) is
-needed to produce the color version. See the file <samp><span
class="file">README.card</span></samp>
-for instructions if you have an older <samp><span
class="command">troff</span></samp>.
-
- <br><dt><samp><span class="file">doc/gawk.1</span></samp><dd>The
<samp><span class="command">troff</span></samp> source for a manual page
describing <samp><span class="command">gawk</span></samp>.
-This is distributed for the convenience of Unix users.
-
- <p><a name="index-Texinfo-1878"></a><br><dt><samp><span
class="file">doc/gawk.texi</span></samp><dd>The Texinfo source file for this
Web page.
-It should be processed with TeX to produce a printed document, and
-with <samp><span class="command">makeinfo</span></samp> to produce an Info or
HTML file.
-
- <br><dt><samp><span class="file">doc/gawk.info</span></samp><dd>The
generated Info file for this Web page.
-
- <br><dt><samp><span class="file">doc/gawkinet.texi</span></samp><dd>The
Texinfo source file for
-<cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>.
-It should be processed with TeX to produce a printed document and
-with <samp><span class="command">makeinfo</span></samp> to produce an Info or
HTML file.
-
- <br><dt><samp><span class="file">doc/gawkinet.info</span></samp><dd>The
generated Info file for
-<cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>.
-
- <br><dt><samp><span class="file">doc/igawk.1</span></samp><dd>The
<samp><span class="command">troff</span></samp> source for a manual page
describing the <samp><span class="command">igawk</span></samp>
-program presented in
-<a href="Igawk-Program.html#Igawk-Program">Igawk Program</a>.
-
- <br><dt><samp><span class="file">doc/Makefile.in</span></samp><dd>The
input file used during the configuration process to generate the
-actual <samp><span class="file">Makefile</span></samp> for creating the
documentation.
-
- <br><dt><samp><span class="file">Makefile.am</span></samp><dt><samp><span
class="file">*/Makefile.am</span></samp><dd>Files used by the GNU <samp><span
class="command">automake</span></samp> software for generating
-the <samp><span class="file">Makefile.in</span></samp> files used by
<samp><span class="command">autoconf</span></samp> and
-<samp><span class="command">configure</span></samp>.
-
- <br><dt><samp><span class="file">Makefile.in</span></samp><dt><samp><span
class="file">acconfig.h</span></samp><dt><samp><span
class="file">acinclude.m4</span></samp><dt><samp><span
class="file">aclocal.m4</span></samp><dt><samp><span
class="file">configh.in</span></samp><dt><samp><span
class="file">configure.in</span></samp><dt><samp><span
class="file">configure</span></samp><dt><samp><span
class="file">custom.h</span></samp><dt><samp><span
class="file">missing_d/*</span></samp><dt><samp><span
class="file">m4/*</span></samp><dd>These files and subdirectories are used when
configuring <samp><span class="command">gawk</span></samp>
-for various Unix systems. They are explained in
-<a href="Unix-Installation.html#Unix-Installation">Unix Installation</a>.
-
- <br><dt><samp><span class="file">intl/*</span></samp><dt><samp><span
class="file">po/*</span></samp><dd>The <samp><span
class="file">intl</span></samp> directory provides the GNU <code>gettext</code>
library, which implements
-<samp><span class="command">gawk</span></samp>'s internationalization
features, while the <samp><span class="file">po</span></samp> library
-contains message translations.
-
- <br><dt><samp><span
class="file">awklib/extract.awk</span></samp><dt><samp><span
class="file">awklib/Makefile.am</span></samp><dt><samp><span
class="file">awklib/Makefile.in</span></samp><dt><samp><span
class="file">awklib/eg/*</span></samp><dd>The <samp><span
class="file">awklib</span></samp> directory contains a copy of <samp><span
class="file">extract.awk</span></samp>
-(see <a href="Extract-Program.html#Extract-Program">Extract Program</a>),
-which can be used to extract the sample programs from the Texinfo
-source file for this Web page. It also contains a <samp><span
class="file">Makefile.in</span></samp> file, which
-<samp><span class="command">configure</span></samp> uses to generate a
<samp><span class="file">Makefile</span></samp>.
-<samp><span class="file">Makefile.am</span></samp> is used by GNU Automake to
create <samp><span class="file">Makefile.in</span></samp>.
-The library functions from
-<a href="Library-Functions.html#Library-Functions">Library Functions</a>,
-and the <samp><span class="command">igawk</span></samp> program from
-<a href="Igawk-Program.html#Igawk-Program">Igawk Program</a>,
-are included as ready-to-use files in the <samp><span
class="command">gawk</span></samp> distribution.
-They are installed as part of the installation process.
-The rest of the programs in this Web page are available in appropriate
-subdirectories of <samp><span class="file">awklib/eg</span></samp>.
-
- <br><dt><samp><span
class="file">unsupported/atari/*</span></samp><dd>Files needed for building
<samp><span class="command">gawk</span></samp> on an Atari ST
-(see <a href="Atari-Installation.html#Atari-Installation">Atari
Installation</a>, for details).
-
- <br><dt><samp><span
class="file">unsupported/tandem/*</span></samp><dd>Files needed for building
<samp><span class="command">gawk</span></samp> on a Tandem
-(see <a href="Tandem-Installation.html#Tandem-Installation">Tandem
Installation</a>, for details).
-
- <br><dt><samp><span class="file">posix/*</span></samp><dd>Files needed
for building <samp><span class="command">gawk</span></samp> on POSIX-compliant
systems.
-
- <br><dt><samp><span class="file">pc/*</span></samp><dd>Files needed for
building <samp><span class="command">gawk</span></samp> under MS-DOS, MS
Windows and OS/2
-(see <a href="PC-Installation.html#PC-Installation">PC Installation</a>, for
details).
-
- <br><dt><samp><span class="file">vms/*</span></samp><dd>Files needed for
building <samp><span class="command">gawk</span></samp> under VMS
-(see <a href="VMS-Installation.html#VMS-Installation">VMS Installation</a>,
for details).
-
- <br><dt><samp><span class="file">test/*</span></samp><dd>A test suite for
-<samp><span class="command">gawk</span></samp>. You can use `<samp><span
class="samp">make check</span></samp>' from the top-level <samp><span
class="command">gawk</span></samp>
-directory to run your version of <samp><span
class="command">gawk</span></samp> against the test suite.
-If <samp><span class="command">gawk</span></samp> successfully passes
`<samp><span class="samp">make check</span></samp>', then you can
-be confident of a successful port.
-</dl>
- <!-- ENDOFRANGE gawdis -->
-
- </body></html>
-
Index: manual/html_node/Do-Statement.html
===================================================================
RCS file: manual/html_node/Do-Statement.html
diff -N manual/html_node/Do-Statement.html
--- manual/html_node/Do-Statement.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-<html lang="en">
-<head>
-<title>Do Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="While-Statement.html#While-Statement" title="While
Statement">
-<link rel="next" href="For-Statement.html#For-Statement" title="For Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Do-Statement"></a>Next: <a rel="next" accesskey="n"
href="For-Statement.html#For-Statement">For Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="While-Statement.html#While-Statement">While Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.3 The <code>do</code>-<code>while</code>
Statement</h4>
-
-<p><a
name="index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-955"></a>
-The <code>do</code> loop is a variation of the <code>while</code> looping
statement.
-The <code>do</code> loop executes the <var>body</var> once and then repeats the
-<var>body</var> as long as the <var>condition</var> is true. It looks like
this:
-
-<pre class="example"> do
- <var>body</var>
- while (<var>condition</var>)
-</pre>
- <p>Even if the <var>condition</var> is false at the start, the
<var>body</var> is
-executed at least once (and only once, unless executing <var>body</var>
-makes <var>condition</var> true). Contrast this with the corresponding
-<code>while</code> statement:
-
-<pre class="example"> while (<var>condition</var>)
- <var>body</var>
-</pre>
- <p class="noindent">This statement does not execute <var>body</var> even
once if the <var>condition</var>
-is false to begin with.
-The following is an example of a <code>do</code> statement:
-
-<pre class="example"> { i = 1
- do {
- print $0
- i++
- } while (i <= 10)
- }
-</pre>
- <p class="noindent">This program prints each input record 10 times.
However, it isn't a very
-realistic example, since in this case an ordinary <code>while</code> would do
-just as well. This situation reflects actual experience; only
-occasionally is there a real use for a <code>do</code> statement.
-
- </body></html>
-
Index: manual/html_node/Dupword-Program.html
===================================================================
RCS file: manual/html_node/Dupword-Program.html
diff -N manual/html_node/Dupword-Program.html
--- manual/html_node/Dupword-Program.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,104 +0,0 @@
-<html lang="en">
-<head>
-<title>Dupword Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="next" href="Alarm-Program.html#Alarm-Program" title="Alarm Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Dupword-Program"></a>Next: <a rel="next" accesskey="n"
href="Alarm-Program.html#Alarm-Program">Alarm Program</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.1 Finding Duplicated Words in a Document</h4>
-
-<p><a
name="index-words_002c-duplicate_0040comma_007b_007d-searching-for-1786"></a><a
name="index-searching_002c-for-words-1787"></a><a
name="index-documents_0040comma_007b_007d-searching-1788"></a>A common error
when writing large amounts of prose is to accidentally
-duplicate words. Typically you will see this in text as something like
“the
-the program does the following<small class="dots">...</small>” When the
text is online, often
-the duplicated words occur at the end of one line and the beginning of
-another, making them very difficult to spot.
-<!-- as here! -->
-
- <p>This program, <samp><span class="file">dupword.awk</span></samp>, scans
through a file one line at a time
-and looks for adjacent occurrences of the same word. It also saves the last
-word on a line (in the variable <code>prev</code>) for comparison with the
first
-word on the next line.
-
- <p><a name="index-Texinfo-1789"></a>The first two statements make sure that
the line is all lowercase,
-so that, for example, “The” and “the” compare equal to
each other.
-The next statement replaces nonalphanumeric and nonwhitespace characters
-with spaces, so that punctuation does not affect the comparison either.
-The characters are replaced with spaces so that formatting controls
-don't create nonsense words (e.g., the Texinfo `<samp><span
class="samp">@code{NF}</span></samp>'
-becomes `<samp><span class="samp">codeNF</span></samp>' if punctuation is
simply deleted). The record is
-then resplit into fields, yielding just the actual words on the line,
-and ensuring that there are no empty fields.
-
- <p>If there are no fields left after removing all the punctuation, the
-current record is skipped. Otherwise, the program loops through each
-word, comparing it to the previous one:
-
- <p><a name="index-_0040code_007bdupword_002eawk_007d-program-1790"></a>
-<pre class="example"> <!-- file eg/prog/dupword.awk -->
- # dupword.awk --- find duplicate words in text
- <!-- endfile -->
- <!-- file eg/prog/dupword.awk -->
- {
- $0 = tolower($0)
- gsub(/[^[:alnum:][:blank:]]/, " ");
- $0 = $0 # re-split
- if (NF == 0)
- next
- if ($1 == prev)
- printf("%s:%d: duplicate %s\n",
- FILENAME, FNR, $1)
- for (i = 2; i <= NF; i++)
- if ($i == $(i-1))
- printf("%s:%d: duplicate %s\n",
- FILENAME, FNR, $i)
- prev = $NF
- }
- <!-- endfile -->
-</pre>
- </body></html>
-
Index: manual/html_node/Dynamic-Extensions.html
===================================================================
RCS file: manual/html_node/Dynamic-Extensions.html
diff -N manual/html_node/Dynamic-Extensions.html
--- manual/html_node/Dynamic-Extensions.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,86 +0,0 @@
-<html lang="en">
-<head>
-<title>Dynamic Extensions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Notes.html#Notes" title="Notes">
-<link rel="prev" href="Additions.html#Additions" title="Additions">
-<link rel="next" href="Future-Extensions.html#Future-Extensions" title="Future
Extensions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Dynamic-Extensions"></a>Next: <a rel="next" accesskey="n"
href="Future-Extensions.html#Future-Extensions">Future Extensions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Additions.html#Additions">Additions</a>,
-Up: <a rel="up" accesskey="u" href="Notes.html#Notes">Notes</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">C.3 Adding New Built-in Functions to <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-Robinson_002c-Will-1963"></a><a
name="index-robot_002c-the-1964"></a><a
name="index-Lost-In-Space-1965"></a><blockquote>
-<i>Danger Will Robinson! Danger!!<br>
-Warning! Warning!</i><br>
-The Robot
-</blockquote>
-
-<!-- STARTOFRANGE gladfgaw -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-functions_002c-adding-1966"></a><!--
STARTOFRANGE adfugaw -->
-<a
name="index-adding_002c-functions-to-_0040command_007bgawk_007d-1967"></a><!--
STARTOFRANGE fubadgaw -->
-<a
name="index-functions_002c-built_002din_002c-adding-to-_0040command_007bgawk_007d-1968"></a>Beginning
with <samp><span class="command">gawk</span></samp> 3.1, it is possible to add
new built-in
-functions to <samp><span class="command">gawk</span></samp> using dynamically
loaded libraries. This
-facility is available on systems (such as GNU/Linux) that support
-the <code>dlopen</code> and <code>dlsym</code> functions.
-This section describes how to write and use dynamically
-loaded extensions for <samp><span class="command">gawk</span></samp>.
-Experience with programming in
-C or C++ is necessary when reading this section.
-
- <p><strong>Caution:</strong> The facilities described in this section
-are very much subject to change in a future <samp><span
class="command">gawk</span></samp> release.
-Be aware that you may have to re-do everything, perhaps from scratch,
-at some future time.
-
-<ul class="menu">
-<li><a accesskey="1" href="Internals.html#Internals">Internals</a>:
A brief look at some <samp><span class="command">gawk</span></samp>
internals.
-<li><a accesskey="2" href="Sample-Library.html#Sample-Library">Sample
Library</a>: A example of new functions.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Dynamic-Typing.html
===================================================================
RCS file: manual/html_node/Dynamic-Typing.html
diff -N manual/html_node/Dynamic-Typing.html
--- manual/html_node/Dynamic-Typing.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-<html lang="en">
-<head>
-<title>Dynamic Typing - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="User_002ddefined.html#User_002ddefined"
title="User-defined">
-<link rel="prev" href="Return-Statement.html#Return-Statement" title="Return
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Dynamic-Typing"></a>Previous: <a rel="previous" accesskey="p"
href="Return-Statement.html#Return-Statement">Return Statement</a>,
-Up: <a rel="up" accesskey="u"
href="User_002ddefined.html#User_002ddefined">User-defined</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.2.5 Functions and Their Effects on Variable
Typing</h4>
-
-<p><samp><span class="command">awk</span></samp> is a very fluid language.
-It is possible that <samp><span class="command">awk</span></samp> can't tell
if an identifier
-represents a regular variable or an array until runtime.
-Here is an annotated sample program:
-
-<pre class="example"> function foo(a)
- {
- a[1] = 1 # parameter is an array
- }
-
- BEGIN {
- b = 1
- foo(b) # invalid: fatal type mismatch
-
- foo(x) # x uninitialized, becomes an array dynamically
- x = 1 # now not allowed, runtime error
- }
-</pre>
- <p>Usually, such things aren't a big issue, but it's worth
-being aware of them.
-<!-- ENDOFRANGE udfunc -->
-<!-- ENDOFRANGE funcud -->
-
- </body></html>
-
Index: manual/html_node/Egrep-Program.html
===================================================================
RCS file: manual/html_node/Egrep-Program.html
diff -N manual/html_node/Egrep-Program.html
--- manual/html_node/Egrep-Program.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,314 +0,0 @@
-<html lang="en">
-<head>
-<title>Egrep Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="prev" href="Cut-Program.html#Cut-Program" title="Cut Program">
-<link rel="next" href="Id-Program.html#Id-Program" title="Id Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Egrep-Program"></a>Next: <a rel="next" accesskey="n"
href="Id-Program.html#Id-Program">Id Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Cut-Program.html#Cut-Program">Cut Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.2 Searching for Regular Expressions in Files</h4>
-
-<!-- STARTOFRANGE regexps -->
-<p><a name="index-regular-expressions_002c-searching-for-1751"></a><!--
STARTOFRANGE sfregexp -->
-<a name="index-searching_002c-files-for-regular-expressions-1752"></a><!--
STARTOFRANGE fsregexp -->
-<a name="index-files_002c-searching-for-regular-expressions-1753"></a><a
name="index-_0040command_007begrep_007d-utility-1754"></a>The <samp><span
class="command">egrep</span></samp> utility searches files for patterns. It
uses regular
-expressions that are almost identical to those available in <samp><span
class="command">awk</span></samp>
-(see <a href="Regexp.html#Regexp">Regexp</a>).
-It is used in the following manner:
-
-<pre class="example"> egrep <span class="roman">[</span>
<var>options</var> <span class="roman">]</span> '<var>pattern</var>'
<var>files</var> ...
-</pre>
- <p>The <var>pattern</var> is a regular expression. In typical usage, the
regular
-expression is quoted to prevent the shell from expanding any of the
-special characters as file name wildcards. Normally, <samp><span
class="command">egrep</span></samp>
-prints the lines that matched. If multiple file names are provided on
-the command line, each output line is preceded by the name of the file
-and a colon.
-
- <p>The options to <samp><span class="command">egrep</span></samp> are as
follows:
-
- <dl>
-<dt><code>-c</code><dd>Print out a count of the lines that matched the
pattern, instead of the
-lines themselves.
-
- <br><dt><code>-s</code><dd>Be silent. No output is produced and the exit
value indicates whether
-the pattern was matched.
-
- <br><dt><code>-v</code><dd>Invert the sense of the test. <samp><span
class="command">egrep</span></samp> prints the lines that do
-<em>not</em> match the pattern and exits successfully if the pattern is not
-matched.
-
- <br><dt><code>-i</code><dd>Ignore case distinctions in both the pattern
and the input data.
-
- <br><dt><code>-l</code><dd>Only print (list) the names of the files that
matched, not the lines that matched.
-
- <br><dt><code>-e </code><var>pattern</var><dd>Use <var>pattern</var> as
the regexp to match. The purpose of the <samp><span
class="option">-e</span></samp>
-option is to allow patterns that start with a `<samp><span
class="samp">-</span></samp>'.
-</dl>
-
- <p>This version uses the <code>getopt</code> library function
-(see <a href="Getopt-Function.html#Getopt-Function">Getopt Function</a>)
-and the file transition library program
-(see <a href="Filetrans-Function.html#Filetrans-Function">Filetrans
Function</a>).
-
- <p>The program begins with a descriptive comment and then a
<code>BEGIN</code> rule
-that processes the command-line arguments with <code>getopt</code>. The
<samp><span class="option">-i</span></samp>
-(ignore case) option is particularly easy with <samp><span
class="command">gawk</span></samp>; we just use the
-<code>IGNORECASE</code> built-in variable
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>):
-
- <p><a name="index-_0040code_007begrep_002eawk_007d-program-1755"></a>
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- # egrep.awk --- simulate egrep in awk
- <!-- endfile -->
- <!-- file eg/prog/egrep.awk -->
- # Options:
- # -c count of lines
- # -s silent - use exit value
- # -v invert test, success if no match
- # -i ignore case
- # -l print filenames only
- # -e argument is pattern
- #
- # Requires getopt and file transition library functions
-
- BEGIN {
- while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) {
- if (c == "c")
- count_only++
- else if (c == "s")
- no_print++
- else if (c == "v")
- invert++
- else if (c == "i")
- IGNORECASE = 1
- else if (c == "l")
- filenames_only++
- else if (c == "e")
- pattern = Optarg
- else
- usage()
- }
- <!-- endfile -->
-</pre>
- <p>Next comes the code that handles the <samp><span
class="command">egrep</span></samp>-specific behavior. If no
-pattern is supplied with <samp><span class="option">-e</span></samp>, the
first nonoption on the
-command line is used. The <samp><span class="command">awk</span></samp>
command-line arguments up to <code>ARGV[Optind]</code>
-are cleared, so that <samp><span class="command">awk</span></samp> won't try
to process them as files. If no
-files are specified, the standard input is used, and if multiple files are
-specified, we make sure to note this so that the file names can precede the
-matched lines in the output:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- if (pattern == "")
- pattern = ARGV[Optind++]
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
- if (Optind >= ARGC) {
- ARGV[1] = "-"
- ARGC = 2
- } else if (ARGC - Optind > 1)
- do_filenames++
-
- # if (IGNORECASE)
- # pattern = tolower(pattern)
- }
- <!-- endfile -->
-</pre>
- <p>The last two lines are commented out, since they are not needed in
-<samp><span class="command">gawk</span></samp>. They should be uncommented if
you have to use another version
-of <samp><span class="command">awk</span></samp>.
-
- <p>The next set of lines should be uncommented if you are not using
-<samp><span class="command">gawk</span></samp>. This rule translates all the
characters in the input line
-into lowercase if the <samp><span class="option">-i</span></samp> option is
specified.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-The rule is
-commented out since it is not necessary with <samp><span
class="command">gawk</span></samp>:
-
-<!-- Exercise: Fix this, w/array and new line as key to original line -->
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- #{
- # if (IGNORECASE)
- # $0 = tolower($0)
- #}
- <!-- endfile -->
-</pre>
- <p>The <code>beginfile</code> function is called by the rule in <samp><span
class="file">ftrans.awk</span></samp>
-when each new file is processed. In this case, it is very simple; all it
-does is initialize a variable <code>fcount</code> to zero. <code>fcount</code>
tracks
-how many lines in the current file matched the pattern
-(naming the parameter <code>junk</code> shows we know that
<code>beginfile</code>
-is called with a parameter, but that we're not interested in its value):
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- function beginfile(junk)
- {
- fcount = 0
- }
- <!-- endfile -->
-</pre>
- <p>The <code>endfile</code> function is called after each file has been
processed.
-It affects the output only when the user wants a count of the number of lines
that
-matched. <code>no_print</code> is true only if the exit status is desired.
-<code>count_only</code> is true if line counts are desired. <samp><span
class="command">egrep</span></samp>
-therefore only prints line counts if printing and counting are enabled.
-The output format must be adjusted depending upon the number of files to
-process. Finally, <code>fcount</code> is added to <code>total</code>, so that
we
-know the total number of lines that matched the pattern:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- function endfile(file)
- {
- if (! no_print && count_only)
- if (do_filenames)
- print file ":" fcount
- else
- print fcount
-
- total += fcount
- }
- <!-- endfile -->
-</pre>
- <p>The following rule does most of the work of matching lines. The variable
-<code>matches</code> is true if the line matched the pattern. If the user
-wants lines that did not match, the sense of <code>matches</code> is inverted
-using the `<samp><span class="samp">!</span></samp>' operator.
<code>fcount</code> is incremented with the value of
-<code>matches</code>, which is either one or zero, depending upon a
-successful or unsuccessful match. If the line does not match, the
-<code>next</code> statement just moves on to the next record.
-
- <p><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-1756"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-1757"></a>A
number of additional tests are made, but they are only done if we
-are not counting lines. First, if the user only wants exit status
-(<code>no_print</code> is true), then it is enough to know that <em>one</em>
-line in this file matched, and we can skip on to the next file with
-<code>nextfile</code>. Similarly, if we are only printing file names, we can
-print the file name, and then skip to the next file with
<code>nextfile</code>.
-Finally, each line is printed, with a leading file name and colon
-if necessary:
-
- <p><a name="index-_0040code_007b_0021_007d-operator-1758"></a>
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- {
- matches = ($0 ~ pattern)
- if (invert)
- matches = ! matches
-
- fcount += matches # 1 or 0
-
- if (! matches)
- next
-
- if (! count_only) {
- if (no_print)
- nextfile
-
- if (filenames_only) {
- print FILENAME
- nextfile
- }
-
- if (do_filenames)
- print FILENAME ":" $0
- else
- print
- }
- }
- <!-- endfile -->
-</pre>
- <p>The <code>END</code> rule takes care of producing the correct exit
status. If
-there are no matches, the exit status is one; otherwise it is zero:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- END \
- {
- if (total == 0)
- exit 1
- exit 0
- }
- <!-- endfile -->
-</pre>
- <p>The <code>usage</code> function prints a usage message in case of
invalid options,
-and then exits:
-
-<pre class="example"> <!-- file eg/prog/egrep.awk -->
- function usage( e)
- {
- e = "Usage: egrep [-csvil] [-e pat] [files ...]"
- e = e "\n\tegrep [-csvil] pat [files ...]"
- print e > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p>The variable <code>e</code> is used so that the function fits nicely
-on the printed page.
-
- <p><a
name="index-_0040code_007bEND_007d-pattern_002c-backslash-continuation-and-1759"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-1760"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-1761"></a>Just
a note on programming style: you may have noticed that the <code>END</code>
-rule uses backslash continuation, with the open brace on a line by
-itself. This is so that it more closely resembles the way functions
-are written. Many of the examples
-in this chapter
-use this style. You can decide for yourself if you like writing
-your <code>BEGIN</code> and <code>END</code> rules this way
-or not.
-<!-- ENDOFRANGE regexps -->
-<!-- ENDOFRANGE sfregexp -->
-<!-- ENDOFRANGE fsregexp -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> It
-also introduces a subtle bug;
-if a match happens, we output the translated line, not the original.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Empty-Files.html
===================================================================
RCS file: manual/html_node/Empty-Files.html
diff -N manual/html_node/Empty-Files.html
--- manual/html_node/Empty-Files.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,114 +0,0 @@
-<html lang="en">
-<head>
-<title>Empty Files - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link rel="prev" href="File-Checking.html#File-Checking" title="File Checking">
-<link rel="next" href="Ignoring-Assigns.html#Ignoring-Assigns" title="Ignoring
Assigns">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Empty-Files"></a>Next: <a rel="next" accesskey="n"
href="Ignoring-Assigns.html#Ignoring-Assigns">Ignoring Assigns</a>,
-Previous: <a rel="previous" accesskey="p"
href="File-Checking.html#File-Checking">File Checking</a>,
-Up: <a rel="up" accesskey="u"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.3.4 Checking For Zero-length Files</h4>
-
-<p>All known <samp><span class="command">awk</span></samp> implementations
silently skip over zero-length files.
-This is a by-product of <samp><span class="command">awk</span></samp>'s
implicit
-read-a-record-and-match-against-the-rules loop: when <samp><span
class="command">awk</span></samp>
-tries to read a record from an empty file, it immediately receives an
-end of file indication, closes the file, and proceeds on to the next
-command-line data file, <em>without</em> executing any user-level
-<samp><span class="command">awk</span></samp> program code.
-
- <p>Using <samp><span class="command">gawk</span></samp>'s
<code>ARGIND</code> variable
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>), it is possible to detect when an empty
-data file has been skipped. Similar to the library file presented
-in <a href="Filetrans-Function.html#Filetrans-Function">Filetrans
Function</a>, the following library file calls a function named
-<code>zerofile</code> that the user must provide. The arguments passed are
-the file name and the position in <code>ARGV</code> where it was found:
-
- <p><a name="index-_0040code_007bzerofile_002eawk_007d-program-1677"></a>
-<pre class="example"> <!-- file eg/lib/zerofile.awk -->
- # zerofile.awk --- library file to process empty input files
- <!-- endfile -->
- <!-- file eg/lib/zerofile.awk -->
- BEGIN { Argind = 0 }
-
- ARGIND > Argind + 1 {
- for (Argind++; Argind < ARGIND; Argind++)
- zerofile(ARGV[Argind], Argind)
- }
-
- ARGIND != Argind { Argind = ARGIND }
-
- END {
- if (ARGIND > Argind)
- for (Argind++; Argind <= ARGIND; Argind++)
- zerofile(ARGV[Argind], Argind)
- }
- <!-- endfile -->
-</pre>
- <p>The user-level variable <code>Argind</code> allows the <samp><span
class="command">awk</span></samp> program
-to track its progress through <code>ARGV</code>. Whenever the program detects
-that <code>ARGIND</code> is greater than `<samp><span class="samp">Argind +
1</span></samp>', it means that one or
-more empty files were skipped. The action then calls <code>zerofile</code> for
-each such file, incrementing <code>Argind</code> along the way.
-
- <p>The `<samp><span class="samp">Argind != ARGIND</span></samp>' rule
simply keeps <code>Argind</code> up to date
-in the normal case.
-
- <p>Finally, the <code>END</code> rule catches the case of any empty files at
-the end of the command-line arguments. Note that the test in the
-condition of the <code>for</code> loop uses the `<samp><span
class="samp"><=</span></samp>' operator,
-not <code><</code>.
-
- <p>As an exercise, you might consider whether this same problem can
-be solved without relying on <samp><span class="command">gawk</span></samp>'s
<code>ARGIND</code> variable.
-
- <p>As a second exercise, revise this code to handle the case where
-an intervening value in <code>ARGV</code> is a variable assignment.
-
- </body></html>
-
Index: manual/html_node/Empty.html
===================================================================
RCS file: manual/html_node/Empty.html
diff -N manual/html_node/Empty.html
--- manual/html_node/Empty.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-<html lang="en">
-<head>
-<title>Empty - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Pattern-Overview.html#Pattern-Overview" title="Pattern
Overview">
-<link rel="prev" href="BEGIN_002fEND.html#BEGIN_002fEND" title="BEGIN/END">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Empty"></a>Previous: <a rel="previous" accesskey="p"
href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>,
-Up: <a rel="up" accesskey="u"
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.1.5 The Empty Pattern</h4>
-
-<p><a name="index-empty-pattern-926"></a><a
name="index-patterns_002c-empty-927"></a>An empty (i.e., nonexistent) pattern
is considered to match <em>every</em>
-input record. For example, the program:
-
-<pre class="example"> awk '{ print $1 }' BBS-list
-</pre>
- <p class="noindent">prints the first field of every record.
-<!-- ENDOFRANGE pat -->
-
- </body></html>
-
Index: manual/html_node/Escape-Sequences.html
===================================================================
RCS file: manual/html_node/Escape-Sequences.html
diff -N manual/html_node/Escape-Sequences.html
--- manual/html_node/Escape-Sequences.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,206 +0,0 @@
-<html lang="en">
-<head>
-<title>Escape Sequences - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Regexp-Usage.html#Regexp-Usage" title="Regexp Usage">
-<link rel="next" href="Regexp-Operators.html#Regexp-Operators" title="Regexp
Operators">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Escape-Sequences"></a>Next: <a rel="next" accesskey="n"
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>,
-Previous: <a rel="previous" accesskey="p"
href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.2 Escape Sequences</h3>
-
-<p><a name="index-escape-sequences-184"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences-185"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences-186"></a>Some
characters cannot be included literally in string constants
-(<code>"foo"</code>) or regexp constants (<code>/foo/</code>).
-Instead, they should be represented with <dfn>escape sequences</dfn>,
-which are character sequences beginning with a backslash (`<samp><span
class="samp">\</span></samp>').
-One use of an escape sequence is to include a double-quote character in
-a string constant. Because a plain double quote ends the string, you
-must use `<samp><span class="samp">\"</span></samp>' to represent an actual
double-quote character as a
-part of the string. For example:
-
-<pre class="example"> $ awk 'BEGIN { print "He said \"hi!\" to her." }'
- -| He said "hi!" to her.
-</pre>
- <p>The backslash character itself is another character that cannot be
-included normally; you must write `<samp><span class="samp">\\</span></samp>'
to put one backslash in the
-string or regexp. Thus, the string whose contents are the two characters
-`<samp><span class="samp">"</span></samp>' and `<samp><span
class="samp">\</span></samp>' must be written <code>"\"\\"</code>.
-
- <p>Backslash also represents unprintable characters
-such as TAB or newline. While there is nothing to stop you from entering most
-unprintable characters directly in a string constant or regexp constant,
-they may look ugly.
-
- <p>The following table lists
-all the escape sequences used in <samp><span class="command">awk</span></samp>
and
-what they represent. Unless noted otherwise, all these escape
-sequences apply to both string constants and regexp constants:
-
- <dl>
-<dt><code>\\</code><dd>A literal backslash, `<samp><span
class="samp">\</span></samp>'.
-
- <!-- @cindex @command{awk} language, V.4 version -->
-<p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ca_007d-escape-sequence-187"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ca_007d-escape-sequence-188"></a><br><dt><code>\a</code><dd>The
“alert” character, <kbd>Ctrl-g</kbd>, ASCII code 7 (BEL).
-(This usually makes some sort of audible noise.)
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cb_007d-escape-sequence-189"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cb_007d-escape-sequence-190"></a><br><dt><code>\b</code><dd>Backspace,
<kbd>Ctrl-h</kbd>, ASCII code 8 (BS).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cf_007d-escape-sequence-191"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cf_007d-escape-sequence-192"></a><br><dt><code>\f</code><dd>Formfeed,
<kbd>Ctrl-l</kbd>, ASCII code 12 (FF).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cn_007d-escape-sequence-193"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cn_007d-escape-sequence-194"></a><br><dt><code>\n</code><dd>Newline,
<kbd>Ctrl-j</kbd>, ASCII code 10 (LF).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cr_007d-escape-sequence-195"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cr_007d-escape-sequence-196"></a><br><dt><code>\r</code><dd>Carriage
return, <kbd>Ctrl-m</kbd>, ASCII code 13 (CR).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ct_007d-escape-sequence-197"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ct_007d-escape-sequence-198"></a><br><dt><code>\t</code><dd>Horizontal
TAB, <kbd>Ctrl-i</kbd>, ASCII code 9 (HT).
-
- <!-- @cindex @command{awk} language, V.4 version -->
-<p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cv_007d-escape-sequence-199"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cv_007d-escape-sequence-200"></a><br><dt><code>\v</code><dd>Vertical
tab, <kbd>Ctrl-k</kbd>, ASCII code 11 (VT).
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-201"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-202"></a><br><dt><code>\</code><var>nnn</var><dd>The
octal value <var>nnn</var>, where <var>nnn</var> stands for 1 to 3 digits
-between `<samp><span class="samp">0</span></samp>' and `<samp><span
class="samp">7</span></samp>'. For example, the code for the ASCII ESC
-(escape) character is `<samp><span class="samp">\033</span></samp>'.
-
- <!-- @cindex @command{awk} language, V.4 version -->
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cx_007d-escape-sequence-203"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cx_007d-escape-sequence-204"></a><br><dt><code>\x</code><var>hh</var><code>...</code><dd>The
hexadecimal value <var>hh</var>, where <var>hh</var> stands for a sequence
-of hexadecimal digits (`<samp><span
class="samp">0</span></samp>'–`<samp><span class="samp">9</span></samp>',
and either `<samp><span class="samp">A</span></samp>'–`<samp><span
class="samp">F</span></samp>'
-or `<samp><span class="samp">a</span></samp>'–`<samp><span
class="samp">f</span></samp>'). Like the same construct
-in ISO C, the escape sequence continues until the first nonhexadecimal
-digit is seen. However, using more than two hexadecimal digits produces
-undefined results. (The `<samp><span class="samp">\x</span></samp>' escape
sequence is not allowed in
-POSIX <samp><span class="command">awk</span></samp>.)
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-205"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-206"></a><br><dt><code>\/</code><dd>A
literal slash (necessary for regexp constants only).
-This expression is used when you want to write a regexp
-constant that contains a slash. Because the regexp is delimited by
-slashes, you need to escape the slash that is part of the pattern,
-in order to tell <samp><span class="command">awk</span></samp> to keep
processing the rest of the regexp.
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-207"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-208"></a><br><dt><code>\"</code><dd>A
literal double quote (necessary for string constants only).
-This expression is used when you want to write a string
-constant that contains a double quote. Because the string is delimited by
-double quotes, you need to escape the quote that is part of the string,
-in order to tell <samp><span class="command">awk</span></samp> to keep
processing the rest of the string.
-</dl>
-
- <p>In <samp><span class="command">gawk</span></samp>, a number of
additional two-character sequences that begin
-with a backslash have special meaning in regexps.
-See <a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a>.
-
- <p>In a regexp, a backslash before any character that is not in the
previous list
-and not listed in
-<a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a>,
-means that the next character should be taken literally, even if it would
-normally be a regexp operator. For example, <code>/a\+b/</code> matches the
three
-characters `<samp><span class="samp">a+b</span></samp>'.
-
- <p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences-209"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences-210"></a><a
name="index-portability-211"></a>For complete portability, do not use a
backslash before any character not
-shown in the previous list.
-
- <p>To summarize:
-
- <ul>
-<li>The escape sequences in the table above are always processed first,
-for both string constants and regexp constants. This happens very early,
-as soon as <samp><span class="command">awk</span></samp> reads your program.
-
- <li><samp><span class="command">gawk</span></samp> processes both regexp
constants and dynamic regexps
-(see <a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>),
-for the special operators listed in
-<a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a>.
-
- <li>A backslash before any other character means to treat that character
-literally.
-</ul>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Backslash Before Regular Characters</h4>
-
-<p><a name="index-portability_002c-backslash-in-escape-sequences-212"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-backslashes-in-string-constants-213"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences_002c-POSIX-and-214"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences_002c-POSIX-and-215"></a>
-<a
name="index-troubleshooting_002c-backslash-before-nonspecial-character-216"></a>If
you place a backslash in a string constant before something that is
-not one of the characters previously listed, POSIX <samp><span
class="command">awk</span></samp> purposely
-leaves what happens as undefined. There are two choices:
-
-<!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<dl>
-<dt>Strip the backslash out<dd>This is what Unix <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp> both do.
-For example, <code>"a\qc"</code> is the same as <code>"aqc"</code>.
-(Because this is such an easy bug both to introduce and to miss,
-<samp><span class="command">gawk</span></samp> warns you about it.)
-Consider `<samp><span class="samp">FS = "[ \t]+\|[ \t]+"<!-- /@w
--></span></samp>' to use vertical bars
-surrounded by whitespace as the field separator. There should be
-two backslashes in the string `<samp><span class="samp">FS =
"[ \t]+\\|[ \t]+"<!-- /@w --></span></samp>'.)
-<!-- I did this! This is why I added the warning. -->
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-escape-sequences-217"></a><a
name="index-Unix-_0040command_007bawk_007d_002c-backslashes-in-escape-sequences-218"></a><br><dt>Leave
the backslash alone<dd>Some other <samp><span
class="command">awk</span></samp> implementations do this.
-In such implementations, typing <code>"a\qc"</code> is the same as typing
-<code>"a\\qc"</code>.
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Escape Sequences for Metacharacters</h4>
-
-<p><a name="index-metacharacters_002c-escape-sequences-for-219"></a>
-Suppose you use an octal or hexadecimal
-escape to represent a regexp metacharacter.
-(See <a href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>.)
-Does <samp><span class="command">awk</span></samp> treat the character as a
literal character or as a regexp
-operator?
-
- <p><a
name="index-dark-corner_002c-escape-sequences_002c-for-metacharacters-220"></a>Historically,
such characters were taken literally.
-(d.c.)
-However, the POSIX standard indicates that they should be treated
-as real metacharacters, which is what <samp><span
class="command">gawk</span></samp> does.
-In compatibility mode (see <a href="Options.html#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> treats the characters
represented by octal and hexadecimal
-escape sequences literally when used in regexp constants. Thus,
-<code>/a\52b/</code> is equivalent to <code>/a\*b/</code>.
-
- </body></html>
-
Index: manual/html_node/Executable-Scripts.html
===================================================================
RCS file: manual/html_node/Executable-Scripts.html
diff -N manual/html_node/Executable-Scripts.html
--- manual/html_node/Executable-Scripts.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,125 +0,0 @@
-<html lang="en">
-<head>
-<title>Executable Scripts - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="prev" href="Long.html#Long" title="Long">
-<link rel="next" href="Comments.html#Comments" title="Comments">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Executable-Scripts"></a>Next: <a rel="next" accesskey="n"
href="Comments.html#Comments">Comments</a>,
-Previous: <a rel="previous" accesskey="p" href="Long.html#Long">Long</a>,
-Up: <a rel="up" accesskey="u"
href="Running-gawk.html#Running-gawk">Running gawk</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.1.4 Executable <samp><span
class="command">awk</span></samp> Programs</h4>
-
-<p><a name="index-_0040command_007bawk_007d-programs-104"></a><a
name="index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-105"></a><a
name="index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-106"></a><a
name="index-Unix_002c-_0040command_007bawk_007d-scripts-and-107"></a><a
name="index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-108"></a><a
name="index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-109"></a>
-Once you have learned <samp><span class="command">awk</span></samp>, you may
want to write self-contained
-<samp><span class="command">awk</span></samp> scripts, using the `<samp><span
class="samp">#!</span></samp>' script mechanism. You can do
-this on many Unix systems<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> as well as on the GNU system.
-For example, you could update the file <samp><span
class="file">advice</span></samp> to look like this:
-
-<pre class="example"> #! /bin/awk -f
-
- BEGIN { print "Don't Panic!" }
-</pre>
- <p class="noindent">After making this file executable (with the <samp><span
class="command">chmod</span></samp> utility),
-simply type `<samp><span class="samp">advice</span></samp>'
-at the shell and the system arranges to run <samp><span
class="command">awk</span></samp><a rel="footnote" href="#fn-2"
name="fnd-2"><sup>2</sup></a> as if you had
-typed `<samp><span class="samp">awk -f advice</span></samp>':
-
-<pre class="example"> $ chmod +x advice
- $ advice
- -| Don't Panic!
-</pre>
- <p class="noindent">(We assume you have the current directory in your
shell's search
-path variable (typically <code>$PATH</code>). If not, you may need
-to type `<samp><span class="samp">./advice</span></samp>' at the shell.)
-
- <p>Self-contained <samp><span class="command">awk</span></samp> scripts are
useful when you want to write a
-program that users can invoke without their having to know that the program is
-written in <samp><span class="command">awk</span></samp>.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Portability Issues with `<samp><span
class="samp">#!</span></samp>'</h4>
-
-<p><a
name="index-portability_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-110"></a>
-Some systems limit the length of the interpreter name to 32 characters.
-Often, this can be dealt with by using a symbolic link.
-
- <p>You should not put more than one argument on the `<samp><span
class="samp">#!</span></samp>'
-line after the path to <samp><span class="command">awk</span></samp>. It does
not work. The operating system
-treats the rest of the line as a single argument and passes it to <samp><span
class="command">awk</span></samp>.
-Doing this leads to confusing behavior—most likely a usage diagnostic
-of some sort from <samp><span class="command">awk</span></samp>.
-
- <p><a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-portability-and-111"></a><a
name="index-portability_002c-_0040code_007bARGV_007d-variable-112"></a>Finally,
-the value of <code>ARGV[0]</code>
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>)
-varies depending upon your operating system.
-Some systems put `<samp><span class="samp">awk</span></samp>' there, some put
the full pathname
-of <samp><span class="command">awk</span></samp> (such as <samp><span
class="file">/bin/awk</span></samp>), and some put the name
-of your script (`<samp><span class="samp">advice</span></samp>'). Don't rely
on the value of <code>ARGV[0]</code>
-to provide your script name.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The `<samp><span class="samp">#!</span></samp>'
mechanism works on
-Linux systems,
-systems derived from the 4.4-Lite Berkeley Software Distribution,
-and most commercial Unix systems.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> The
-line beginning with `<samp><span class="samp">#!</span></samp>' lists the full
file name of an interpreter
-to run and an optional initial command-line argument to pass to that
-interpreter. The operating system then runs the interpreter with the given
-argument and the full argument list of the executed program. The first
argument
-in the list is the full file name of the <samp><span
class="command">awk</span></samp> program. The rest of the
-argument list contains either options to <samp><span
class="command">awk</span></samp>, or data files,
-or both.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Exit-Statement.html
===================================================================
RCS file: manual/html_node/Exit-Statement.html
diff -N manual/html_node/Exit-Statement.html
--- manual/html_node/Exit-Statement.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,109 +0,0 @@
-<html lang="en">
-<head>
-<title>Exit Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="Nextfile-Statement.html#Nextfile-Statement"
title="Nextfile Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Exit-Statement"></a>Previous: <a rel="previous" accesskey="p"
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.10 The <code>exit</code> Statement</h4>
-
-<p><a name="index-_0040code_007bexit_007d-statement-985"></a>The
<code>exit</code> statement causes <samp><span
class="command">awk</span></samp> to immediately stop
-executing the current rule and to stop processing input; any remaining input
-is ignored. The <code>exit</code> statement is written as follows:
-
-<pre class="example"> exit <span class="roman">[</span><var>return
code</var><span class="roman">]</span>
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bexit_007d-statement-and-986"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bexit_007d-statement-and-987"></a>When
an <code>exit</code> statement is executed from a <code>BEGIN</code> rule, the
-program stops processing everything immediately. No input records are
-read. However, if an <code>END</code> rule is present,
-as part of executing the <code>exit</code> statement,
-the <code>END</code> rule is executed
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-If <code>exit</code> is used as part of an <code>END</code> rule, it causes
-the program to stop immediately.
-
- <p>An <code>exit</code> statement that is not part of a <code>BEGIN</code>
or <code>END</code>
-rule stops the execution of any further automatic rules for the current
-record, skips reading any remaining input records, and executes the
-<code>END</code> rule if there is one.
-
- <p>In such a case,
-if you don't want the <code>END</code> rule to do its job, set a variable
-to nonzero before the <code>exit</code> statement and check that variable in
-the <code>END</code> rule.
-See <a href="Assert-Function.html#Assert-Function">Assert Function</a>,
-for an example that does this.
-
- <p><a
name="index-dark-corner_002c-_0040code_007bexit_007d-statement-988"></a>If an
argument is supplied to <code>exit</code>, its value is used as the exit
-status code for the <samp><span class="command">awk</span></samp> process. If
no argument is supplied,
-<code>exit</code> returns status zero (success). In the case where an argument
-is supplied to a first <code>exit</code> statement, and then <code>exit</code>
is
-called a second time from an <code>END</code> rule with no argument,
-<samp><span class="command">awk</span></samp> uses the previously supplied
exit value.
-(d.c.)
-
- <p><a
name="index-programming-conventions_002c-_0040code_007bexit_007d-statement-989"></a>For
example, suppose an error condition occurs that is difficult or
-impossible to handle. Conventionally, programs report this by
-exiting with a nonzero status. An <samp><span
class="command">awk</span></samp> program can do this
-using an <code>exit</code> statement with a nonzero argument, as shown
-in the following example:
-
-<pre class="example"> BEGIN {
- if (("date" | getline date_now) <= 0) {
- print "Can't get system date" > "/dev/stderr"
- exit 1
- }
- print "current date is", date_now
- close("date")
- }
-</pre>
- <!-- ENDOFRANGE csta -->
-<!-- ENDOFRANGE acs -->
-<!-- ENDOFRANGE accs -->
-</body></html>
-
Index: manual/html_node/Explaining-gettext.html
===================================================================
RCS file: manual/html_node/Explaining-gettext.html
diff -N manual/html_node/Explaining-gettext.html
--- manual/html_node/Explaining-gettext.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,190 +0,0 @@
-<html lang="en">
-<head>
-<title>Explaining gettext - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="prev" href="I18N-and-L10N.html#I18N-and-L10N" title="I18N and L10N">
-<link rel="next" href="Programmer-i18n.html#Programmer-i18n" title="Programmer
i18n">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Explaining-gettext"></a>Next: <a rel="next" accesskey="n"
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a>,
-Previous: <a rel="previous" accesskey="p"
href="I18N-and-L10N.html#I18N-and-L10N">I18N and L10N</a>,
-Up: <a rel="up" accesskey="u"
href="Internationalization.html#Internationalization">Internationalization</a>
-<hr><br>
-</div>
-
-<h3 class="section">9.2 GNU <code>gettext</code></h3>
-
-<p><a name="index-internationalizing-a-program-1306"></a><!-- STARTOFRANGE
gettex -->
-<a name="index-_0040code_007bgettext_007d-library-1307"></a>The facilities in
GNU <code>gettext</code> focus on messages; strings printed
-by a program, either directly or via formatting with <code>printf</code> or
-<code>sprintf</code>.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
- <p><a
name="index-portability_002c-_0040code_007bgettext_007d-library-and-1308"></a>When
using GNU <code>gettext</code>, each application has its own
-<dfn>text domain</dfn>. This is a unique name, such as `<samp><span
class="samp">kpilot</span></samp>' or `<samp><span
class="samp">gawk</span></samp>',
-that identifies the application.
-A complete application may have multiple components—programs written
-in C or C++, as well as scripts written in <samp><span
class="command">sh</span></samp> or <samp><span
class="command">awk</span></samp>.
-All of the components use the same text domain.
-
- <p>To make the discussion concrete, assume we're writing an application
-named <samp><span class="command">guide</span></samp>. Internationalization
consists of the
-following steps, in this order:
-
- <ol type=1 start=1>
-<li>The programmer goes
-through the source for all of <samp><span
class="command">guide</span></samp>'s components
-and marks each string that is a candidate for translation.
-For example, <code>"`-F': option required"</code> is a good candidate for
translation.
-A table with strings of option names is not (e.g., <samp><span
class="command">gawk</span></samp>'s
-<samp><span class="option">--profile</span></samp> option should remain the
same, no matter what the local
-language).
-
- <p><a
name="index-_0040code_007btextdomain_007d-function-_0028C-library_0029-1309"></a><li>The
programmer indicates the application's text domain
-(<code>"guide"</code>) to the <code>gettext</code> library,
-by calling the <code>textdomain</code> function.
-
- <li>Messages from the application are extracted from the source code and
-collected into a portable object file (<samp><span
class="file">guide.po</span></samp>),
-which lists the strings and their translations.
-The translations are initially empty.
-The original (usually English) messages serve as the key for
-lookup of the translations.
-
- <p><a name="index-_0040code_007b_002epo_007d-files-1310"></a><a
name="index-files_002c-_0040code_007b_002epo_007d-1311"></a><a
name="index-portable-object-files-1312"></a><a
name="index-files_002c-portable-object-1313"></a><li>For each language with a
translator, <samp><span class="file">guide.po</span></samp>
-is copied and translations are created and shipped with the application.
-
- <p><a name="index-_0040code_007b_002emo_007d-files-1314"></a><a
name="index-files_002c-_0040code_007b_002emo_007d-1315"></a><a
name="index-message-object-files-1316"></a><a
name="index-files_002c-message-object-1317"></a><li>Each language's <samp><span
class="file">.po</span></samp> file is converted into a binary
-message object (<samp><span class="file">.mo</span></samp>) file.
-A message object file contains the original messages and their
-translations in a binary format that allows fast lookup of translations
-at runtime.
-
- <li>When <samp><span class="command">guide</span></samp> is built and
installed, the binary translation files
-are installed in a standard place.
-
- <p><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028C-library_0029-1318"></a><li>For
testing and development, it is possible to tell <code>gettext</code>
-to use <samp><span class="file">.mo</span></samp> files in a different
directory than the standard
-one by using the <code>bindtextdomain</code> function.
-
- <p><a
name="index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1319"></a><a
name="index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1320"></a><a
name="index-message-object-files_002c-specifying-directory-of-1321"></a><a
name="index-files_002c-message-object_002c-specifying-directory-of-1322"></a><li>At
runtime, <samp><span class="command">guide</span></samp> looks up each string
via a call
-to <code>gettext</code>. The returned string is the translated string
-if available, or the original string if not.
-
- <li>If necessary, it is possible to access messages from a different
-text domain than the one belonging to the application, without
-having to switch the application's default text domain back
-and forth.
- </ol>
-
- <p><a
name="index-_0040code_007bgettext_007d-function-_0028C-library_0029-1323"></a>In
C (or C++), the string marking and dynamic translation lookup
-are accomplished by wrapping each string in a call to <code>gettext</code>:
-
-<pre class="example"> printf(gettext("Don't Panic!\n"));
-</pre>
- <p>The tools that extract messages from source code pull out all
-strings enclosed in calls to <code>gettext</code>.
-
- <p><a
name="index-_0040code_007b_005f_007d-_0028underscore_0029_002c-_0040code_007b_005f_007d-C-macro-1324"></a><a
name="index-underscore-_0028_0040code_007b_005f_007d_0029_002c-_0040code_007b_005f_007d-C-macro-1325"></a>The
GNU <code>gettext</code> developers, recognizing that typing
-`<samp><span class="samp">gettext</span></samp>' over and over again is both
painful and ugly to look
-at, use the macro `<samp><span class="samp">_</span></samp>' (an underscore)
to make things easier:
-
-<pre class="example"> /* In the standard header file: */
- #define _(str) gettext(str)
-
- /* In the program text: */
- printf(_("Don't Panic!\n"));
-</pre>
- <p><a
name="index-internationalization_002c-localization_002c-locale-categories-1326"></a><a
name="index-_0040code_007bgettext_007d-library_002c-locale-categories-1327"></a><a
name="index-locale-categories-1328"></a>This reduces the typing overhead to
just three extra characters per string
-and is considerably easier to read as well.
-There are locale <dfn>categories</dfn>
-for different types of locale-related information.
-The defined locale categories that <code>gettext</code> knows about are:
-
-
-<a name="index-_0040code_007bLC_005fMESSAGES_007d-locale-category-1329"></a>
-<dl><dt><code>LC_MESSAGES</code><dd>Text messages. This is the default
category for <code>gettext</code>
-operations, but it is possible to supply a different one explicitly,
-if necessary. (It is almost never necessary to supply a different category.)
-
- <p><a name="index-sorting-characters-in-different-languages-1330"></a><a
name="index-_0040code_007bLC_005fCOLLATE_007d-locale-category-1331"></a><br><dt><code>LC_COLLATE</code><dd>Text-collation
information; i.e., how different characters
-and/or groups of characters sort in a given language.
-
- <p><a
name="index-_0040code_007bLC_005fCTYPE_007d-locale-category-1332"></a><br><dt><code>LC_CTYPE</code><dd>Character-type
information (alphabetic, digit, upper- or lowercase, and
-so on).
-This information is accessed via the
-POSIX character classes in regular expressions,
-such as <code>/[[:alnum:]]/</code>
-(see <a href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>).
-
- <p><a name="index-monetary-information_002c-localization-1333"></a><a
name="index-currency-symbols_002c-localization-1334"></a><a
name="index-_0040code_007bLC_005fMONETARY_007d-locale-category-1335"></a><br><dt><code>LC_MONETARY</code><dd>Monetary
information, such as the currency symbol, and whether the
-symbol goes before or after a number.
-
- <p><a
name="index-_0040code_007bLC_005fNUMERIC_007d-locale-category-1336"></a><br><dt><code>LC_NUMERIC</code><dd>Numeric
information, such as which characters to use for the decimal
-point and the thousands separator.<a rel="footnote" href="#fn-2"
name="fnd-2"><sup>2</sup></a>
-
- <p><a
name="index-_0040code_007bLC_005fRESPONSE_007d-locale-category-1337"></a><br><dt><code>LC_RESPONSE</code><dd>Response
information, such as how “yes” and “no” appear in the
-local language, and possibly other information as well.
-
- <p><a name="index-time_002c-localization-and-1338"></a><a
name="index-dates_002c-information-related-to_0040comma_007b_007d-localization-1339"></a><a
name="index-_0040code_007bLC_005fTIME_007d-locale-category-1340"></a><br><dt><code>LC_TIME</code><dd>Time-
and date-related information, such as 12- or 24-hour clock, month printed
-before or after day in a date, local month abbreviations, and so on.
-
- <p><a
name="index-_0040code_007bLC_005fALL_007d-locale-category-1341"></a><br><dt><code>LC_ALL</code><dd>All
of the above. (Not too useful in the context of <code>gettext</code>.)
-</dl>
- <!-- ENDOFRANGE gettex -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> For some operating systems, the <samp><span
class="command">gawk</span></samp>
-port doesn't support GNU <code>gettext</code>. This applies most notably to
-the PC operating systems. As such, these features are not available
-if you are using one of those operating systems. Sorry.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
Americans
-use a comma every three decimal places and a period for the decimal
-point, while many Europeans do exactly the opposite:
-<code>1,234.56</code> versus <code>1.234,56</code>.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Expression-Patterns.html
===================================================================
RCS file: manual/html_node/Expression-Patterns.html
diff -N manual/html_node/Expression-Patterns.html
--- manual/html_node/Expression-Patterns.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-<html lang="en">
-<head>
-<title>Expression Patterns - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Pattern-Overview.html#Pattern-Overview" title="Pattern
Overview">
-<link rel="prev" href="Regexp-Patterns.html#Regexp-Patterns" title="Regexp
Patterns">
-<link rel="next" href="Ranges.html#Ranges" title="Ranges">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Expression-Patterns"></a>Next: <a rel="next" accesskey="n"
href="Ranges.html#Ranges">Ranges</a>,
-Previous: <a rel="previous" accesskey="p"
href="Regexp-Patterns.html#Regexp-Patterns">Regexp Patterns</a>,
-Up: <a rel="up" accesskey="u"
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.1.2 Expressions as Patterns</h4>
-
-<p><a name="index-expressions_002c-as-patterns-890"></a>
-Any <samp><span class="command">awk</span></samp> expression is valid as an
<samp><span class="command">awk</span></samp> pattern.
-The pattern matches if the expression's value is nonzero (if a
-number) or non-null (if a string).
-The expression is reevaluated each time the rule is tested against a new
-input record. If the expression uses fields such as <code>$1</code>, the
-value depends directly on the new input record's text; otherwise, it
-depends on only what has happened so far in the execution of the
-<samp><span class="command">awk</span></samp> program.
-
- <p><a name="index-comparison-expressions_002c-as-patterns-891"></a><a
name="index-patterns_002c-comparison-expressions-as-892"></a>Comparison
expressions, using the comparison operators described in
-<a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>,
-are a very common kind of pattern.
-Regexp matching and nonmatching are also very common expressions.
-The left operand of the `<samp><span class="samp">~</span></samp>' and
`<samp><span class="samp">!~</span></samp>' operators is a string.
-The right operand is either a constant regular expression enclosed in
-slashes (<code>/</code><var>regexp</var><code>/</code>), or any expression
whose string value
-is used as a dynamic regular expression
-(see <a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>).
-The following example prints the second field of each input record
-whose first field is precisely `<samp><span class="samp">foo</span></samp>':
-
- <p><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-patterns-and-893"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-patterns-and-894"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-895"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-896"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-897"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-898"></a>
-<pre class="example"> $ awk '$1 == "foo" { print $2 }' BBS-list
-</pre>
- <p class="noindent">(There is no output, because there is no BBS site with
the exact name `<samp><span class="samp">foo</span></samp>'.)
-Contrast this with the following regular expression match, which
-accepts any record with a first field that contains `<samp><span
class="samp">foo</span></samp>':
-
-<pre class="example"> $ awk '$1 ~ /foo/ { print $2 }' BBS-list
- -| 555-1234
- -| 555-6699
- -| 555-6480
- -| 555-2127
-</pre>
- <p><a name="index-regexp-constants_002c-as-patterns-899"></a><a
name="index-patterns_002c-regexp-constants-as-900"></a>A regexp constant as a
pattern is also a special case of an expression
-pattern. The expression <code>/foo/</code> has the value one if `<samp><span
class="samp">foo</span></samp>'
-appears in the current input record. Thus, as a pattern, <code>/foo/</code>
-matches any record containing `<samp><span class="samp">foo</span></samp>'.
-
- <p><a name="index-Boolean-expressions_002c-as-patterns-901"></a>Boolean
expressions are also commonly used as patterns.
-Whether the pattern
-matches an input record depends on whether its subexpressions match.
-For example, the following command prints all the records in
-<samp><span class="file">BBS-list</span></samp> that contain both `<samp><span
class="samp">2400</span></samp>' and `<samp><span
class="samp">foo</span></samp>':
-
-<pre class="example"> $ awk '/2400/ && /foo/' BBS-list
- -| fooey 555-1234 2400/1200/300 B
-</pre>
- <p>The following command prints all records in
-<samp><span class="file">BBS-list</span></samp> that contain <em>either</em>
`<samp><span class="samp">2400</span></samp>' or `<samp><span
class="samp">foo</span></samp>'
-(or both, of course):
-
-<pre class="example"> $ awk '/2400/ || /foo/' BBS-list
- -| alpo-net 555-3412 2400/1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sdace 555-3430 2400/1200/300 A
- -| sabafoo 555-2127 1200/300 C
-</pre>
- <p>The following command prints all records in
-<samp><span class="file">BBS-list</span></samp> that do <em>not</em> contain
the string `<samp><span class="samp">foo</span></samp>':
-
-<pre class="example"> $ awk '! /foo/' BBS-list
- -| aardvark 555-5553 1200/300 B
- -| alpo-net 555-3412 2400/1200/300 A
- -| barfly 555-7685 1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| camelot 555-0542 300 C
- -| core 555-2912 1200/300 C
- -| sdace 555-3430 2400/1200/300 A
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-Boolean-patterns-and-902"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-Boolean-patterns-and-903"></a>The
subexpressions of a Boolean operator in a pattern can be constant regular
-expressions, comparisons, or any other <samp><span
class="command">awk</span></samp> expressions. Range
-patterns are not expressions, so they cannot appear inside Boolean
-patterns. Likewise, the special patterns <code>BEGIN</code> and
<code>END</code>,
-which never match any input record, are not expressions and cannot
-appear inside Boolean patterns.
-
- </body></html>
-
Index: manual/html_node/Expressions.html
===================================================================
RCS file: manual/html_node/Expressions.html
diff -N manual/html_node/Expressions.html
--- manual/html_node/Expressions.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>Expressions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Printing.html#Printing" title="Printing">
-<link rel="next" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Expressions"></a>Next: <a rel="next" accesskey="n"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Printing.html#Printing">Printing</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">5 Expressions</h2>
-
-<!-- STARTOFRANGE exps -->
-<p><a name="index-expressions-604"></a>
-Expressions are the basic building blocks of <samp><span
class="command">awk</span></samp> patterns
-and actions. An expression evaluates to a value that you can print, test,
-or pass to a function. Additionally, an expression
-can assign a new value to a variable or a field by using an assignment
operator.
-
- <p>An expression can serve as a pattern or action statement on its own.
-Most other kinds of
-statements contain one or more expressions that specify the data on which to
-operate. As in other languages, expressions in <samp><span
class="command">awk</span></samp> include
-variables, array references, constants, and function calls, as well as
-combinations of these with various operators.
-
-<ul class="menu">
-<li><a accesskey="1" href="Constants.html#Constants">Constants</a>:
String, numeric and regexp constants.
-<li><a accesskey="2"
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a>: When and how to use a regexp constant.
-<li><a accesskey="3" href="Variables.html#Variables">Variables</a>:
Variables give names to values for later use.
-<li><a accesskey="4" href="Conversion.html#Conversion">Conversion</a>:
The conversion of strings to numbers and vice
- versa.
-<li><a accesskey="5" href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic
Ops</a>: Arithmetic operations (`<samp><span
class="samp">+</span></samp>', `<samp><span class="samp">-</span></samp>',
- etc.)
-<li><a accesskey="6"
href="Concatenation.html#Concatenation">Concatenation</a>:
Concatenating strings.
-<li><a accesskey="7" href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a>: Changing the value of a variable or a field.
-<li><a accesskey="8" href="Increment-Ops.html#Increment-Ops">Increment
Ops</a>: Incrementing the numeric value of a variable.
-<li><a accesskey="9" href="Truth-Values.html#Truth-Values">Truth Values</a>:
What is ``true'' and what is ``false''.
-<li><a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>: How variables acquire types and how this
- affects comparison of numbers and strings with
- `<samp><span class="samp"><</span></samp>',
etc.
-<li><a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a>:
Combining comparison expressions using boolean
- operators `<samp><span
class="samp">||</span></samp>' (``or''), `<samp><span
class="samp">&&</span></samp>'
- (``and'') and `<samp><span
class="samp">!</span></samp>' (``not'').
-<li><a href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>:
Conditional expressions select between two
- subexpressions under control of a third
- subexpression.
-<li><a href="Function-Calls.html#Function-Calls">Function Calls</a>:
A function call is an expression.
-<li><a href="Precedence.html#Precedence">Precedence</a>: How
various operators nest.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Extract-Program.html
===================================================================
RCS file: manual/html_node/Extract-Program.html
diff -N manual/html_node/Extract-Program.html
--- manual/html_node/Extract-Program.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,276 +0,0 @@
-<html lang="en">
-<head>
-<title>Extract Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="History-Sorting.html#History-Sorting" title="History
Sorting">
-<link rel="next" href="Simple-Sed.html#Simple-Sed" title="Simple Sed">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Extract-Program"></a>Next: <a rel="next" accesskey="n"
href="Simple-Sed.html#Simple-Sed">Simple Sed</a>,
-Previous: <a rel="previous" accesskey="p"
href="History-Sorting.html#History-Sorting">History Sorting</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.7 Extracting Programs from Texinfo Source
Files</h4>
-
-<!-- STARTOFRANGE texse -->
-<p><a
name="index-Texinfo_002c-extracting-programs-from-source-files-1809"></a><!--
STARTOFRANGE fitex -->
-<a
name="index-files_002c-Texinfo_0040comma_007b_007d-extracting-programs-from-1810"></a>Both
this chapter and the previous chapter
-(<a href="Library-Functions.html#Library-Functions">Library Functions</a>)
-present a large number of <samp><span class="command">awk</span></samp>
programs.
-If you want to experiment with these programs, it is tedious to have to type
-them in by hand. Here we present a program that can extract parts of a
-Texinfo input file into separate files.
-
- <p><a name="index-Texinfo-1811"></a>This Web page is written in Texinfo,
the GNU project's document
-formatting
-language.
-A single Texinfo source file can be used to produce both
-printed and online documentation.
-Texinfo is fully documented in the book
-<cite>Texinfo—The GNU Documentation Format</cite>,
-available from the Free Software Foundation.
-
- <p>For our purposes, it is enough to know three things about Texinfo input
-files:
-
- <ul>
-<li>The “at” symbol (`<samp><span class="samp">@</span></samp>')
is special in Texinfo, much as
-the backslash (`<samp><span class="samp">\</span></samp>') is in C
-or <samp><span class="command">awk</span></samp>. Literal `<samp><span
class="samp">@</span></samp>' symbols are represented in Texinfo source
-files as `<samp><span class="samp">@@</span></samp>'.
-
- <li>Comments start with either `<samp><span
class="samp">@c</span></samp>' or `<samp><span
class="samp">@comment</span></samp>'.
-The file-extraction program works by using special comments that start
-at the beginning of a line.
-
- <li>Lines containing `<samp><span class="samp">@group</span></samp>' and
`<samp><span class="samp">@end group</span></samp>' commands bracket
-example text that should not be split across a page boundary.
-(Unfortunately, TeX isn't always smart enough to do things exactly right,
-and we have to give it some help.)
-</ul>
-
- <p>The following program, <samp><span
class="file">extract.awk</span></samp>, reads through a Texinfo source
-file and does two things, based on the special comments.
-Upon seeing `<samp><span class="samp">@c system ...<!-- /@w
--></span></samp>',
-it runs a command, by extracting the command text from the
-control line and passing it on to the <code>system</code> function
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-Upon seeing `<samp><span class="samp">@c file
</span><var>filename</var></samp>', each subsequent line is sent to
-the file <var>filename</var>, until `<samp><span class="samp">@c
endfile</span></samp>' is encountered.
-The rules in <samp><span class="file">extract.awk</span></samp> match either
`<samp><span class="samp">@c</span></samp>' or
-`<samp><span class="samp">@comment</span></samp>' by letting the `<samp><span
class="samp">omment</span></samp>' part be optional.
-Lines containing `<samp><span class="samp">@group</span></samp>' and
`<samp><span class="samp">@end group</span></samp>' are simply removed.
-<samp><span class="file">extract.awk</span></samp> uses the <code>join</code>
library function
-(see <a href="Join-Function.html#Join-Function">Join Function</a>).
-
- <p>The example programs in the online Texinfo source for <cite>GAWK:
Effective AWK Programming</cite>
-(<samp><span class="file">gawk.texi</span></samp>) have all been bracketed
inside `<samp><span class="samp">file</span></samp>' and
-`<samp><span class="samp">endfile</span></samp>' lines. The <samp><span
class="command">gawk</span></samp> distribution uses a copy of
-<samp><span class="file">extract.awk</span></samp> to extract the sample
programs and install many
-of them in a standard directory where <samp><span
class="command">gawk</span></samp> can find them.
-The Texinfo file looks something like this:
-
-<pre class="example"> ...
- This program has a @code{BEGIN} rule,
- that prints a nice message:
-
- @example
- @c file examples/messages.awk
- BEGIN @{ print "Don't panic!" @}
- @c end file
- @end example
-
- It also prints some final advice:
-
- @example
- @c file examples/messages.awk
- END @{ print "Always avoid bored archeologists!" @}
- @c end file
- @end example
- ...
-</pre>
- <p><samp><span class="file">extract.awk</span></samp> begins by setting
<code>IGNORECASE</code> to one, so that
-mixed upper- and lowercase letters in the directives won't matter.
-
- <p>The first rule handles calling <code>system</code>, checking that a
command is
-given (<code>NF</code> is at least three) and also checking that the command
-exits with a zero exit status, signifying OK:
-
- <p><a name="index-_0040code_007bextract_002eawk_007d-program-1812"></a>
-<pre class="example"> <!-- file eg/prog/extract.awk -->
- # extract.awk --- extract files and run programs
- # from texinfo files
- <!-- endfile -->
- <!-- file eg/prog/extract.awk -->
- BEGIN { IGNORECASE = 1 }
-
- /address@hidden(omment)?[ \t]+system/ \
- {
- if (NF < 3) {
- e = (FILENAME ":" FNR)
- e = (e ": badly formed `system' line")
- print e > "/dev/stderr"
- next
- }
- $1 = ""
- $2 = ""
- stat = system($0)
- if (stat != 0) {
- e = (FILENAME ":" FNR)
- e = (e ": warning: system returned " stat)
- print e > "/dev/stderr"
- }
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">The variable <code>e</code> is used so that the function
-fits nicely on the
-page.
-screen.
-
- <p>The second rule handles moving data into files. It verifies that a
-file name is given in the directive. If the file named is not the
-current file, then the current file is closed. Keeping the current file
-open until a new file is encountered allows the use of the `<samp><span
class="samp">></span></samp>'
-redirection for printing the contents, keeping open file management
-simple.
-
- <p>The `<samp><span class="samp">for</span></samp>' loop does the work. It
reads lines using <code>getline</code>
-(see <a href="Getline.html#Getline">Getline</a>).
-For an unexpected end of file, it calls the <code>unexpected_eof<!-- /@w
--></code>
-function. If the line is an “endfile” line, then it breaks out of
-the loop.
-If the line is an `<samp><span class="samp">@group</span></samp>' or
`<samp><span class="samp">@end group</span></samp>' line, then it
-ignores it and goes on to the next line.
-Similarly, comments within examples are also ignored.
-
- <p>Most of the work is in the following few lines. If the line has no
`<samp><span class="samp">@</span></samp>'
-symbols, the program can print it directly.
-Otherwise, each leading `<samp><span class="samp">@</span></samp>' must be
stripped off.
-To remove the `<samp><span class="samp">@</span></samp>' symbols, the line is
split into separate elements of
-the array <code>a</code>, using the <code>split</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-The `<samp><span class="samp">@</span></samp>' symbol is used as the separator
character.
-Each element of <code>a</code> that is empty indicates two successive
`<samp><span class="samp">@</span></samp>'
-symbols in the original line. For each two empty elements (`<samp><span
class="samp">@@</span></samp>' in
-the original file), we have to add a single `<samp><span
class="samp">@</span></samp>' symbol back in.
-
- <p>When the processing of the array is finished, <code>join</code> is
called with the
-value of <code>SUBSEP</code>, to rejoin the pieces back into a single
-line. That line is then printed to the output file:
-
-<pre class="example"> <!-- file eg/prog/extract.awk -->
- /address@hidden(omment)?[ \t]+file/ \
- {
- if (NF != 3) {
- e = (FILENAME ":" FNR ": badly formed `file' line")
- print e > "/dev/stderr"
- next
- }
- if ($3 != curfile) {
- if (curfile != "")
- close(curfile)
- curfile = $3
- }
-
- for (;;) {
- if ((getline line) <= 0)
- unexpected_eof()
- if (line ~ /address@hidden(omment)?[ \t]+endfile/)
- break
- else if (line ~ /^@(end[ \t]+)?group/)
- continue
- else if (line ~ /address@hidden(omment+)?[ \t]+/)
- continue
- if (index(line, "@") == 0) {
- print line > curfile
- continue
- }
- n = split(line, a, "@")
- # if a[1] == "", means leading @,
- # don't add one back in.
- for (i = 2; i <= n; i++) {
- if (a[i] == "") { # was an @@
- a[i] = "@"
- if (a[i+1] == "")
- i++
- }
- }
- print join(a, 1, n, SUBSEP) > curfile
- }
- }
- <!-- endfile -->
-</pre>
- <p>An important thing to note is the use of the `<samp><span
class="samp">></span></samp>' redirection.
-Output done with `<samp><span class="samp">></span></samp>' only opens the
file once; it stays open and
-subsequent output is appended to the file
-(see <a href="Redirection.html#Redirection">Redirection</a>).
-This makes it easy to mix program text and explanatory prose for the same
-sample source file (as has been done here!) without any hassle. The file is
-only closed when a new data file name is encountered or at the end of the
-input file.
-
- <p>Finally, the function <code>unexpected_eof<!-- /@w --></code> prints an
appropriate
-error message and then exits.
-The <code>END</code> rule handles the final cleanup, closing the open file:
-
-<!-- function lb put on same line for page breaking. sigh -->
-<pre class="example"> <!-- file eg/prog/extract.awk -->
- function unexpected_eof() {
- printf("%s:%d: unexpected EOF or error\n",
- FILENAME, FNR) > "/dev/stderr"
- exit 1
- }
-
- END {
- if (curfile)
- close(curfile)
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE texse -->
-<!-- ENDOFRANGE fitex -->
-</body></html>
-
Index: manual/html_node/Extracting.html
===================================================================
RCS file: manual/html_node/Extracting.html
diff -N manual/html_node/Extracting.html
--- manual/html_node/Extracting.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-<html lang="en">
-<head>
-<title>Extracting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Gawk-Distribution.html#Gawk-Distribution" title="Gawk
Distribution">
-<link rel="prev" href="Getting.html#Getting" title="Getting">
-<link rel="next" href="Distribution-contents.html#Distribution-contents"
title="Distribution contents">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Extracting"></a>Next: <a rel="next" accesskey="n"
href="Distribution-contents.html#Distribution-contents">Distribution
contents</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getting.html#Getting">Getting</a>,
-Up: <a rel="up" accesskey="u"
href="Gawk-Distribution.html#Gawk-Distribution">Gawk Distribution</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.1.2 Extracting the Distribution</h4>
-
-<p><samp><span class="command">gawk</span></samp> is distributed as a
<code>tar</code> file compressed with the
-GNU Zip program, <code>gzip</code>.
-
- <p>Once you have the distribution (for example,
-<samp><span class="file">gawk-3.1.4.tar.gz</span></samp>),
-use <code>gzip</code> to expand the
-file and then use <code>tar</code> to extract it. You can use the following
-pipeline to produce the <samp><span class="command">gawk</span></samp>
distribution:
-
-<pre class="example"> # Under System V, add 'o' to the tar options
- gzip -d -c gawk-3.1.4.tar.gz | tar -xvpf -
-</pre>
- <p class="noindent">This creates a directory named <samp><span
class="file">gawk-3.1.4</span></samp>
-in the current directory.
-
- <p>The distribution file name is of the form
-<samp><span class="file">gawk-</span><var>V</var><span
class="file">.</span><var>R</var><span class="file">.</span><var>P</var><span
class="file">.tar.gz</span></samp>.
-The <var>V</var> represents the major version of <samp><span
class="command">gawk</span></samp>,
-the <var>R</var> represents the current release of version <var>V</var>, and
-the <var>P</var> represents a <dfn>patch level</dfn>, meaning that minor bugs
have
-been fixed in the release. The current patch level is 4,
-but when retrieving distributions, you should get the version with the highest
-version, release, and patch level. (Note, however, that patch levels greater
than
-or equal to 80 denote “beta” or nonproduction software; you might
not want
-to retrieve such a version unless you don't mind experimenting.)
-If you are not on a Unix system, you need to make other arrangements
-for getting and extracting the <samp><span class="command">gawk</span></samp>
distribution. You should consult
-a local expert.
-
- </body></html>
-
Index: manual/html_node/Field-Separators.html
===================================================================
RCS file: manual/html_node/Field-Separators.html
diff -N manual/html_node/Field-Separators.html
--- manual/html_node/Field-Separators.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,138 +0,0 @@
-<html lang="en">
-<head>
-<title>Field Separators - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Changing-Fields.html#Changing-Fields" title="Changing
Fields">
-<link rel="next" href="Constant-Size.html#Constant-Size" title="Constant Size">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Field-Separators"></a>Next: <a rel="next" accesskey="n"
href="Constant-Size.html#Constant-Size">Constant Size</a>,
-Previous: <a rel="previous" accesskey="p"
href="Changing-Fields.html#Changing-Fields">Changing Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.5 Specifying How Fields Are Separated</h3>
-
-<ul class="menu">
-<li><a accesskey="1"
href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a>: Using regexps as the field separator.
-<li><a accesskey="2"
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a>: Making each character a separate field.
-<li><a accesskey="3"
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a>: Setting <code>FS</code> from the command-line.
-<li><a accesskey="4"
href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field Splitting
Summary</a>: Some final points and a summary table.
-</ul>
-
-<p><a name="index-_0040code_007bFS_007d-variable-401"></a><a
name="index-fields_002c-separating-402"></a><!-- STARTOFRANGE fisepr -->
-<a name="index-field-separators-403"></a><!-- STARTOFRANGE fisepg -->
-<a name="index-fields_002c-separating-404"></a>The <dfn>field separator</dfn>,
which is either a single character or a regular
-expression, controls the way <samp><span class="command">awk</span></samp>
splits an input record into fields.
-<samp><span class="command">awk</span></samp> scans the input record for
character sequences that
-match the separator; the fields themselves are the text between the matches.
-
- <p>In the examples that follow, we use the bullet symbol (•) to
-represent spaces in the output.
-If the field separator is `<samp><span class="samp">oo</span></samp>', then
the following line:
-
-<pre class="example"> moo goo gai pan
-</pre>
- <p class="noindent">is split into three fields: `<samp><span
class="samp">m</span></samp>', `<samp><span
class="samp">•g</span></samp>', and
-`<samp><span class="samp">•gai•pan</span></samp>'.
-Note the leading spaces in the values of the second and third fields.
-
- <p><a
name="index-troubleshooting_002c-_0040command_007bawk_007d-uses-_0040code_007bFS_007d-not-_0040code_007bIFS_007d-405"></a>The
field separator is represented by the built-in variable <code>FS</code>.
-Shell programmers take note: <samp><span class="command">awk</span></samp>
does <em>not</em> use the
-name <code>IFS</code> that is used by the POSIX-compliant shells (such as
-the Unix Bourne shell, <samp><span class="command">sh</span></samp>, or
<samp><span class="command">bash</span></samp>).
-
- <p><a
name="index-_0040code_007bFS_007d-variable_002c-changing-value-of-406"></a>The
value of <code>FS</code> can be changed in the <samp><span
class="command">awk</span></samp> program with the
-assignment operator, `<samp><span class="samp">=</span></samp>' (see <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-Often the right time to do this is at the beginning of execution
-before any input has been processed, so that the very first record
-is read with the proper separator. To do this, use the special
-<code>BEGIN</code> pattern
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-For example, here we set the value of <code>FS</code> to the string
-<code>","</code>:
-
-<pre class="example"> awk 'BEGIN { FS = "," } ; { print $2 }'
-</pre>
- <p><a name="index-_0040code_007bBEGIN_007d-pattern-407"></a>Given the input
line:
-
-<pre class="example"> John Q. Smith, 29 Oak St., Walamazoo, MI 42139
-</pre>
- <p class="noindent">this <samp><span class="command">awk</span></samp>
program extracts and prints the string
-`<samp><span class="samp">•29•Oak•St.</span></samp>'.
-
- <p><a name="index-field-separators_002c-choice-of-408"></a><a
name="index-regular-expressions-as-field-separators-409"></a><a
name="index-field-separators_002c-regular-expressions-as-410"></a>Sometimes the
input data contains separator characters that don't
-separate fields the way you thought they would. For instance, the
-person's name in the example we just used might have a title or
-suffix attached, such as:
-
-<pre class="example"> John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139
-</pre>
- <p class="noindent">The same program would extract `<samp><span
class="samp">•LXIX</span></samp>', instead of
-`<samp><span class="samp">•29•Oak•St.</span></samp>'.
-If you were expecting the program to print the
-address, you would be surprised. The moral is to choose your data layout and
-separator characters carefully to prevent such problems.
-(If the data is not in a form that is easy to process, perhaps you
-can massage it first with a separate <samp><span
class="command">awk</span></samp> program.)
-
- <p><a name="index-newlines_002c-as-field-separators-411"></a><a
name="index-whitespace_002c-as-field-separators-412"></a>Fields are normally
separated by whitespace sequences
-(spaces, tabs, and newlines), not by single spaces. Two spaces in a row do not
-delimit an empty field. The default value of the field separator
<code>FS</code>
-is a string containing a single space, <code>" "</code><!-- /@w -->. If
<samp><span class="command">awk</span></samp>
-interpreted this value in the usual way, each space character would separate
-fields, so two spaces in a row would make an empty field between them.
-The reason this does not happen is that a single space as the value of
-<code>FS</code> is a special case—it is taken to specify the default
manner
-of delimiting fields.
-
- <p>If <code>FS</code> is any other single character, such as
<code>","</code>, then
-each occurrence of that character separates two fields. Two consecutive
-occurrences delimit an empty field. If the character occurs at the
-beginning or the end of the line, that too delimits an empty field. The
-space character is the only single character that does not follow these
-rules.
-
- </body></html>
-
Index: manual/html_node/Field-Splitting-Summary.html
===================================================================
RCS file: manual/html_node/Field-Splitting-Summary.html
diff -N manual/html_node/Field-Splitting-Summary.html
--- manual/html_node/Field-Splitting-Summary.html 31 Aug 2004 22:04:10
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,145 +0,0 @@
-<html lang="en">
-<head>
-<title>Field Splitting Summary - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Field-Separators.html#Field-Separators" title="Field
Separators">
-<link rel="prev"
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator"
title="Command Line Field Separator">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Field-Splitting-Summary"></a>Previous: <a rel="previous"
accesskey="p"
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a>,
-Up: <a rel="up" accesskey="u"
href="Field-Separators.html#Field-Separators">Field Separators</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.5.4 Field-Splitting Summary</h4>
-
-<p>It is important to remember that when you assign a string constant
-as the value of <code>FS</code>, it undergoes normal <samp><span
class="command">awk</span></samp> string
-processing. For example, with Unix <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>,
-the assignment `<samp><span class="samp">FS = "\.."</span></samp>' assigns the
character string <code>".."</code>
-to <code>FS</code> (the backslash is stripped). This creates a regexp meaning
-“fields are separated by occurrences of any two characters.”
-If instead you want fields to be separated by a literal period followed
-by any single character, use `<samp><span class="samp">FS =
"\\.."</span></samp>'.
-
- <p>The following table summarizes how fields are split, based on the value
-of <code>FS</code> (`<samp><span class="samp">==</span></samp>' means
“is equal to”):
-
- <dl>
-<dt><code>FS == " "</code><dd>Fields are separated by runs of whitespace.
Leading and trailing
-whitespace are ignored. This is the default.
-
- <br><dt><code>FS == </code><var>any other single
character</var><dd>Fields are separated by each occurrence of the character.
Multiple
-successive occurrences delimit empty fields, as do leading and
-trailing occurrences.
-The character can even be a regexp metacharacter; it does not need
-to be escaped.
-
- <br><dt><code>FS == </code><var>regexp</var><dd>Fields are separated by
occurrences of characters that match <var>regexp</var>.
-Leading and trailing matches of <var>regexp</var> delimit empty fields.
-
- <br><dt><code>FS == ""</code><dd>Each individual character in the record
becomes a separate field.
-(This is a <samp><span class="command">gawk</span></samp> extension; it is not
specified by the
-POSIX standard.)
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Changing <code>FS</code> Does Not
Affect the Fields</h4>
-
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-433"></a><a
name="index-field-separators_002c-POSIX-and-434"></a>According to the POSIX
standard, <samp><span class="command">awk</span></samp> is supposed to behave
-as if each record is split into fields at the time it is read.
-In particular, this means that if you change the value of <code>FS</code>
-after a record is read, the value of the fields (i.e., how they were split)
-should reflect the old value of <code>FS</code>, not the new one.
-
- <p><a name="index-dark-corner_002c-field-separators-435"></a><a
name="index-_0040command_007bsed_007d-utility-436"></a><a
name="index-stream-editors-437"></a>However, many implementations of
<samp><span class="command">awk</span></samp> do not work this way. Instead,
-they defer splitting the fields until a field is actually
-referenced. The fields are split
-using the <em>current</em> value of <code>FS</code>!
-(d.c.)
-This behavior can be difficult
-to diagnose. The following example illustrates the difference
-between the two methods.
-(The <samp><span class="command">sed</span></samp><a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a>
-command prints just the first line of <samp><span
class="file">/etc/passwd</span></samp>.)
-
-<pre class="example"> sed 1q /etc/passwd | awk '{ FS = ":" ; print $1 }'
-</pre>
- <p class="noindent">which usually prints:
-
-<pre class="example"> root
-</pre>
- <p class="noindent">on an incorrect implementation of <samp><span
class="command">awk</span></samp>, while <samp><span
class="command">gawk</span></samp>
-prints something like:
-
-<pre class="example"> root:nSijPlPhZZwgE:0:0:Root:/:
-</pre>
- <!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: <code>FS</code> and
<code>IGNORECASE</code></h4>
-
-<p>The <code>IGNORECASE</code> variable
-(see <a href="User_002dmodified.html#User_002dmodified">User-modified</a>)
-affects field splitting <em>only</em> when the value of <code>FS</code> is a
regexp.
-It has no effect when <code>FS</code> is a single character, even if
-that character is a letter. Thus, in the following code:
-
-<pre class="example"> FS = "c"
- IGNORECASE = 1
- $0 = "aCa"
- print $1
-</pre>
- <p class="noindent">The output is `<samp><span
class="samp">aCa</span></samp>'. If you really want to split fields on an
-alphabetic character while ignoring case, use a regexp that will
-do it for you. E.g., `<samp><span class="samp">FS = "[c]"</span></samp>'. In
this case, <code>IGNORECASE</code>
-will take effect.
-
-<!-- ENDOFRANGE fisepr -->
-<!-- ENDOFRANGE fisepg -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The <samp><span class="command">sed</span></samp>
utility is a “stream editor.”
-Its behavior is also defined by the POSIX standard.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Fields.html
===================================================================
RCS file: manual/html_node/Fields.html
diff -N manual/html_node/Fields.html
--- manual/html_node/Fields.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,135 +0,0 @@
-<html lang="en">
-<head>
-<title>Fields - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Records.html#Records" title="Records">
-<link rel="next" href="Nonconstant-Fields.html#Nonconstant-Fields"
title="Nonconstant Fields">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Fields"></a>Next: <a rel="next" accesskey="n"
href="Nonconstant-Fields.html#Nonconstant-Fields">Nonconstant Fields</a>,
-Previous: <a rel="previous" accesskey="p"
href="Records.html#Records">Records</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.2 Examining Fields</h3>
-
-<p><a name="index-examining-fields-376"></a><a name="index-fields-377"></a><a
name="index-accessing-fields-378"></a><!-- STARTOFRANGE fiex -->
-<a name="index-fields_002c-examining-379"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-380"></a><a
name="index-field-separators_002c-POSIX-and-381"></a><a
name="index-separators_002c-field_002c-POSIX-and-382"></a>When <samp><span
class="command">awk</span></samp> reads an input record, the record is
-automatically <dfn>parsed</dfn> or separated by the interpreter into chunks
-called <dfn>fields</dfn>. By default, fields are separated by
<dfn>whitespace</dfn>,
-like words in a line.
-Whitespace in <samp><span class="command">awk</span></samp> means any string
of one or more spaces,
-tabs, or newlines;<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
other characters, such as
-formfeed, vertical tab, etc. that are
-considered whitespace by other languages, are <em>not</em> considered
-whitespace by <samp><span class="command">awk</span></samp>.
-
- <p>The purpose of fields is to make it more convenient for you to refer to
-these pieces of the record. You don't have to use them—you can
-operate on the whole record if you want—but fields are what make
-simple <samp><span class="command">awk</span></samp> programs so powerful.
-
- <p><a name="index-_0040code_007b_0024_007d-field-operator-383"></a><a
name="index-field-operator-_0040code_007b_0024_007d-384"></a><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-385"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-386"></a><a
name="index-field-operators_0040comma_007b_007d-dollar-sign-as-387"></a>A
dollar-sign (`<samp><span class="samp">$</span></samp>') is used
-to refer to a field in an <samp><span class="command">awk</span></samp>
program,
-followed by the number of the field you want. Thus, <code>$1</code>
-refers to the first field, <code>$2</code> to the second, and so on.
-(Unlike the Unix shells, the field numbers are not limited to single digits.
-<code>$127</code> is the one hundred twenty-seventh field in the record.)
-For example, suppose the following is a line of input:
-
-<pre class="example"> This seems like a pretty nice example.
-</pre>
- <p class="noindent">Here the first field, or <code>$1</code>, is
`<samp><span class="samp">This</span></samp>', the second field, or
-<code>$2</code>, is `<samp><span class="samp">seems</span></samp>', and so on.
Note that the last field,
-<code>$7</code>, is `<samp><span class="samp">example.</span></samp>'.
Because there is no space between the
-`<samp><span class="samp">e</span></samp>' and the `<samp><span
class="samp">.</span></samp>', the period is considered part of the seventh
-field.
-
- <p><a name="index-_0040code_007bNF_007d-variable-388"></a><a
name="index-fields_002c-number-of-389"></a><code>NF</code> is a built-in
variable whose value is the number of fields
-in the current record. <samp><span class="command">awk</span></samp>
automatically updates the value
-of <code>NF</code> each time it reads a record. No matter how many fields
-there are, the last field in a record can be represented by <code>$NF</code>.
-So, <code>$NF</code> is the same as <code>$7</code>, which is `<samp><span
class="samp">example.</span></samp>'.
-If you try to reference a field beyond the last
-one (such as <code>$8</code> when the record has only seven fields), you get
-the empty string. (If used in a numeric operation, you get zero.)
-
- <p>The use of <code>$0</code>, which looks like a reference to the
“zero-th” field, is
-a special case: it represents the whole input record
-when you are not interested in specific fields.
-Here are some more examples:
-
-<pre class="example"> $ awk '$1 ~ /foo/ { print $0 }' BBS-list
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sabafoo 555-2127 1200/300 C
-</pre>
- <p class="noindent">This example prints each record in the file <samp><span
class="file">BBS-list</span></samp> whose first
-field contains the string `<samp><span class="samp">foo</span></samp>'. The
operator `<samp><span class="samp">~</span></samp>' is called a
-<dfn>matching operator</dfn>
-(see <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>);
-it tests whether a string (here, the field <code>$1</code>) matches a given
regular
-expression.
-
- <p>By contrast, the following example
-looks for `<samp><span class="samp">foo</span></samp>' in <em>the entire
record</em> and prints the first
-field and the last field for each matching input record:
-
-<pre class="example"> $ awk '/foo/ { print $1, $NF }' BBS-list
- -| fooey B
- -| foot B
- -| macfoo A
- -| sabafoo C
-</pre>
- <!-- ENDOFRANGE fiex -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> In POSIX <samp><span
class="command">awk</span></samp>, newlines are not
-considered whitespace for separating fields.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/File-Checking.html
===================================================================
RCS file: manual/html_node/File-Checking.html
diff -N manual/html_node/File-Checking.html
--- manual/html_node/File-Checking.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-<html lang="en">
-<head>
-<title>File Checking - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link rel="prev" href="Rewind-Function.html#Rewind-Function" title="Rewind
Function">
-<link rel="next" href="Empty-Files.html#Empty-Files" title="Empty Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="File-Checking"></a>Next: <a rel="next" accesskey="n"
href="Empty-Files.html#Empty-Files">Empty Files</a>,
-Previous: <a rel="previous" accesskey="p"
href="Rewind-Function.html#Rewind-Function">Rewind Function</a>,
-Up: <a rel="up" accesskey="u"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.3.3 Checking for Readable Data Files</h4>
-
-<p><a
name="index-troubleshooting_002c-readable-_0040value_007bDF_007ds-1672"></a><a
name="index-readable-_0040value_007bDF_007ds_0040comma_007b_007d-checking-1673"></a><a
name="index-files_002c-skipping-1674"></a>Normally, if you give <samp><span
class="command">awk</span></samp> a data file that isn't readable,
-it stops with a fatal error. There are times when you
-might want to just ignore such files and keep going. You can
-do this by prepending the following program to your <samp><span
class="command">awk</span></samp>
-program:
-
- <p><a name="index-_0040code_007breadable_002eawk_007d-program-1675"></a>
-<pre class="example"> <!-- file eg/lib/readable.awk -->
- # readable.awk --- library file to skip over unreadable files
- <!-- endfile -->
- <!-- file eg/lib/readable.awk -->
- BEGIN {
- for (i = 1; i < ARGC; i++) {
- if (ARGV[i] ~ /^[A-Za-z_][A-Za-z0-9_]*=.*/ \
- || ARGV[i] == "-")
- continue # assignment or standard input
- else if ((getline junk < ARGV[i]) < 0) # unreadable
- delete ARGV[i]
- else
- close(ARGV[i])
- }
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-troubleshooting_002c-_0040code_007bgetline_007d-function-1676"></a>In
<samp><span class="command">gawk</span></samp>, the <code>getline</code> won't
be fatal (unless
-<samp><span class="option">--posix</span></samp> is in force).
-Removing the element from <code>ARGV</code> with <code>delete</code>
-skips the file (since it's no longer in the list).
-
-<!-- This doesn't handle /dev/stdin etc. Not worth the hassle to mention or
fix. -->
-</body></html>
-
Index: manual/html_node/Filetrans-Function.html
===================================================================
RCS file: manual/html_node/Filetrans-Function.html
diff -N manual/html_node/Filetrans-Function.html
--- manual/html_node/Filetrans-Function.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-<html lang="en">
-<head>
-<title>Filetrans Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link rel="next" href="Rewind-Function.html#Rewind-Function" title="Rewind
Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Filetrans-Function"></a>Next: <a rel="next" accesskey="n"
href="Rewind-Function.html#Rewind-Function">Rewind Function</a>,
-Up: <a rel="up" accesskey="u"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.3.1 Noting Data File Boundaries</h4>
-
-<p><a
name="index-files_002c-managing_002c-_0040value_007bDF_007d-boundaries-1666"></a><a
name="index-files_002c-initialization-and-cleanup-1667"></a>The
<code>BEGIN</code> and <code>END</code> rules are each executed exactly once at
-the beginning and end of your <samp><span class="command">awk</span></samp>
program, respectively
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-We (the <samp><span class="command">gawk</span></samp> authors) once had a
user who mistakenly thought that the
-<code>BEGIN</code> rule is executed at the beginning of each data file and the
-<code>END</code> rule is executed at the end of each data file. When informed
-that this was not the case, the user requested that we add new special
-patterns to <samp><span class="command">gawk</span></samp>, named
<code>BEGIN_FILE</code> and <code>END_FILE</code>, that
-would have the desired behavior. He even supplied us the code to do so.
-
- <p>Adding these special patterns to <samp><span
class="command">gawk</span></samp> wasn't necessary;
-the job can be done cleanly in <samp><span class="command">awk</span></samp>
itself, as illustrated
-by the following library program.
-It arranges to call two user-supplied functions, <code>beginfile</code> and
-<code>endfile</code>, at the beginning and end of each data file.
-Besides solving the problem in only nine(!) lines of code, it does so
-<em>portably</em>; this works with any implementation of <samp><span
class="command">awk</span></samp>:
-
-<pre class="example"> # transfile.awk
- #
- # Give the user a hook for filename transitions
- #
- # The user must supply functions beginfile() and endfile()
- # that each take the name of the file being started or
- # finished, respectively.
- <!-- # -->
- <!-- # Arnold Robbins, arnold@@gnu.org, Public Domain -->
- <!-- # January 1992 -->
-
- FILENAME != _oldfilename \
- {
- if (_oldfilename != "")
- endfile(_oldfilename)
- _oldfilename = FILENAME
- beginfile(FILENAME)
- }
-
- END { endfile(FILENAME) }
-</pre>
- <p>This file must be loaded before the user's “main” program,
so that the
-rule it supplies is executed first.
-
- <p>This rule relies on <samp><span class="command">awk</span></samp>'s
<code>FILENAME</code> variable that
-automatically changes for each new data file. The current file name is
-saved in a private variable, <code>_oldfilename</code>. If
<code>FILENAME</code> does
-not equal <code>_oldfilename</code>, then a new data file is being processed
and
-it is necessary to call <code>endfile</code> for the old file. Because
-<code>endfile</code> should only be called if a file has been processed, the
-program first checks to make sure that <code>_oldfilename</code> is not the
null
-string. The program then assigns the current file name to
-<code>_oldfilename</code> and calls <code>beginfile</code> for the file.
-Because, like all <samp><span class="command">awk</span></samp> variables,
<code>_oldfilename</code> is
-initialized to the null string, this rule executes correctly even for the
-first data file.
-
- <p>The program also supplies an <code>END</code> rule to do the final
processing for
-the last file. Because this <code>END</code> rule comes before any
<code>END</code> rules
-supplied in the “main” program, <code>endfile</code> is called
first. Once
-again the value of multiple <code>BEGIN</code> and <code>END</code> rules
should be clear.
-
- <p><a
name="index-_0040code_007bbeginfile_007d-user_002ddefined-function-1668"></a><a
name="index-_0040code_007bendfile_007d-user_002ddefined-function-1669"></a>This
version has same problem as the first version of <code>nextfile</code>
-(see <a href="Nextfile-Function.html#Nextfile-Function">Nextfile
Function</a>).
-If the same data file occurs twice in a row on the command line, then
-<code>endfile</code> and <code>beginfile</code> are not executed at the end of
the
-first pass and at the beginning of the second pass.
-The following version solves the problem:
-
-<pre class="example"> <!-- file eg/lib/ftrans.awk -->
- # ftrans.awk --- handle data file transitions
- #
- # user supplies beginfile() and endfile() functions
- <!-- endfile -->
- <!-- file eg/lib/ftrans.awk -->
- FNR == 1 {
- if (_filename_ != "")
- endfile(_filename_)
- _filename_ = FILENAME
- beginfile(FILENAME)
- }
-
- END { endfile(_filename_) }
- <!-- endfile -->
-</pre>
- <p><a href="Wc-Program.html#Wc-Program">Wc Program</a>,
-shows how this library function can be used and
-how it simplifies writing the main program.
-
- </body></html>
-
Index: manual/html_node/Floating-Point-Issues.html
===================================================================
RCS file: manual/html_node/Floating-Point-Issues.html
diff -N manual/html_node/Floating-Point-Issues.html
--- manual/html_node/Floating-Point-Issues.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,169 +0,0 @@
-<html lang="en">
-<head>
-<title>Floating Point Issues - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Basic-Concepts.html#Basic-Concepts" title="Basic
Concepts">
-<link rel="prev" href="Basic-Data-Typing.html#Basic-Data-Typing" title="Basic
Data Typing">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Floating-Point-Issues"></a>Previous: <a rel="previous"
accesskey="p" href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a>,
-Up: <a rel="up" accesskey="u"
href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">D.3 Floating-Point Number Caveats</h3>
-
-<p>As mentioned earlier, floating-point numbers represent what are called
-“real” numbers, i.e., those that have a fractional part.
<samp><span class="command">awk</span></samp>
-uses double-precision floating-point numbers to represent all
-numeric values. This section describes some of the issues
-involved in using floating-point numbers.
-
- <p>There is a very nice paper on floating-point arithmetic by
-David Goldberg, “What Every
-Computer Scientist Should Know About Floating-point Arithmetic,”
-<cite>ACM Computing Surveys</cite> <strong>23</strong>, 1 (1991-03),
-5-48.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-This is worth reading if you are interested in the details,
-but it does require a background in computer science.
-
- <p>Internally, <samp><span class="command">awk</span></samp> keeps both the
numeric value
-(double-precision floating-point) and the string value for a variable.
-Separately, <samp><span class="command">awk</span></samp> keeps
-track of what type the variable has
-(see <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>),
-which plays a role in how variables are used in comparisons.
-
- <p>It is important to note that the string value for a number may not
-reflect the full value (all the digits) that the numeric value
-actually contains.
-The following program (<samp><span class="file">values.awk</span></samp>)
illustrates this:
-
-<pre class="example"> {
- $1 = $2 + $3
- # see it for what it is
- printf("$1 = %.12g\n", $1)
- # use CONVFMT
- a = "<" $1 ">"
- print "a =", a
- # use OFMT
- print "$1 =", $1
- }
-</pre>
- <p class="noindent">This program shows the full value of the sum of
<code>$2</code> and <code>$3</code>
-using <code>printf</code>, and then prints the string values obtained
-from both automatic conversion (via <code>CONVFMT</code>) and
-from printing (via <code>OFMT</code>).
-
- <p>Here is what happens when the program is run:
-
-<pre class="example"> $ echo 2 3.654321 1.2345678 | awk -f values.awk
- -| $1 = 4.8888888
- -| a = <4.88889>
- -| $1 = 4.88889
-</pre>
- <p>This makes it clear that the full numeric value is different from
-what the default string representations show.
-
- <p><code>CONVFMT</code>'s default value is <code>"%.6g"</code>, which
yields a value with
-at least six significant digits. For some applications, you might want to
-change it to specify more precision.
-On most modern machines, most of the time,
-17 digits is enough to capture a floating-point number's
-value exactly.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
-
- <p><a name="index-floating_002dpoint-2048"></a>Unlike numbers in the
abstract sense (such as what you studied in high school
-or college math), numbers stored in computers are limited in certain ways.
-They cannot represent an infinite number of digits, nor can they always
-represent things exactly.
-In particular,
-floating-point numbers cannot
-always represent values exactly. Here is an example:
-
-<pre class="example"> $ awk '{ printf("%010d\n", $1 * 100) }'
- 515.79
- -| 0000051579
- 515.80
- -| 0000051579
- 515.81
- -| 0000051580
- 515.82
- -| 0000051582
- <kbd>Ctrl-d</kbd>
-</pre>
- <p class="noindent">This shows that some values can be represented exactly,
-whereas others are only approximated. This is not a “bug”
-in <samp><span class="command">awk</span></samp>, but simply an artifact of
how computers
-represent numbers.
-
- <p><a name="index-negative-zero-2049"></a><a
name="index-positive-zero-2050"></a><a
name="index-zero_0040comma_007b_007d-negative-vs_002e_0040_003a-positive-2051"></a>Another
peculiarity of floating-point numbers on modern systems
-is that they often have more than one representation for the number zero!
-In particular, it is possible to represent “minus zero” as well as
-regular, or “positive” zero.
-
- <p>This example shows that negative and positive zero are distinct values
-when stored internally, but that they are in fact equal to each other,
-as well as to “regular” zero:
-
-<pre class="smallexample"> $ gawk 'BEGIN { mz = -0 ; pz = 0
- > printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz
- > printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0
- > }'
- -| -0 = -0, +0 = 0, (-0 == +0) -> 1
- -| mz == 0 -> 1, pz == 0 -> 1
-</pre>
- <p>It helps to keep this in mind should you process numeric data
-that contains negative zero values; the fact that the zero is negative
-is noted and can affect comparisons.
-<!-- ENDOFRANGE procon -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <a
href="http://www.validlab.com/goldberg/paper.ps">http://www.validlab.com/goldberg/paper.ps</a>.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
Pathological cases can require up to
-752 digits (!), but we doubt that you need to worry about this.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/For-Statement.html
===================================================================
RCS file: manual/html_node/For-Statement.html
diff -N manual/html_node/For-Statement.html
--- manual/html_node/For-Statement.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,132 +0,0 @@
-<html lang="en">
-<head>
-<title>For Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="Do-Statement.html#Do-Statement" title="Do Statement">
-<link rel="next" href="Switch-Statement.html#Switch-Statement" title="Switch
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="For-Statement"></a>Next: <a rel="next" accesskey="n"
href="Switch-Statement.html#Switch-Statement">Switch Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="Do-Statement.html#Do-Statement">Do Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.4 The <code>for</code> Statement</h4>
-
-<p><a name="index-_0040code_007bfor_007d-statement-956"></a>
-The <code>for</code> statement makes it more convenient to count iterations of
a
-loop. The general form of the <code>for</code> statement looks like this:
-
-<pre class="example"> for (<var>initialization</var>;
<var>condition</var>; <var>increment</var>)
- <var>body</var>
-</pre>
- <p class="noindent">The <var>initialization</var>, <var>condition</var>,
and <var>increment</var> parts are
-arbitrary <samp><span class="command">awk</span></samp> expressions, and
<var>body</var> stands for any
-<samp><span class="command">awk</span></samp> statement.
-
- <p>The <code>for</code> statement starts by executing
<var>initialization</var>.
-Then, as long
-as the <var>condition</var> is true, it repeatedly executes <var>body</var>
and then
-<var>increment</var>. Typically, <var>initialization</var> sets a variable to
-either zero or one, <var>increment</var> adds one to it, and
<var>condition</var>
-compares it against the desired number of iterations.
-For example:
-
-<pre class="example"> awk '{ for (i = 1; i <= 3; i++)
- print $i
- }' inventory-shipped
-</pre>
- <p class="noindent">This prints the first three fields of each input
record, with one field per
-line.
-
- <p>It isn't possible to
-set more than one variable in the
-<var>initialization</var> part without using a multiple assignment statement
-such as `<samp><span class="samp">x = y = 0</span></samp>'. This makes sense
only if all the initial values
-are equal. (But it is possible to initialize additional variables by writing
-their assignments as separate statements preceding the <code>for</code> loop.)
-
-<!-- @cindex comma operator, not supported -->
-<p>The same is true of the <var>increment</var> part. Incrementing additional
-variables requires separate statements at the end of the loop.
-The C compound expression, using C's comma operator, is useful in
-this context but it is not supported in <samp><span
class="command">awk</span></samp>.
-
- <p>Most often, <var>increment</var> is an increment expression, as in the
previous
-example. But this is not required; it can be any expression
-whatsoever. For example, the following statement prints all the powers of two
-between 1 and 100:
-
-<pre class="example"> for (i = 1; i <= 100; i *= 2)
- print i
-</pre>
- <p>If there is nothing to be done, any of the three expressions in the
-parentheses following the <code>for</code> keyword may be omitted. Thus,
-`<samp><span
class="samp">for (; x > 0;)</span></samp>'<!-- /@w -->
is equivalent to `<samp><span
class="samp">while (x > 0)</span></samp>'<!-- /@w -->. If the
-<var>condition</var> is omitted, it is treated as true, effectively
-yielding an <dfn>infinite loop</dfn> (i.e., a loop that never terminates).
-
- <p>In most cases, a <code>for</code> loop is an abbreviation for a
<code>while</code>
-loop, as shown here:
-
-<pre class="example"> <var>initialization</var>
- while (<var>condition</var>) {
- <var>body</var>
- <var>increment</var>
- }
-</pre>
- <p><a
name="index-loops_002c-_0040code_007bcontinue_007d-statements-and-957"></a>The
only exception is when the <code>continue</code> statement
-(see <a href="Continue-Statement.html#Continue-Statement">Continue
Statement</a>) is used
-inside the loop. Changing a <code>for</code> statement to a <code>while</code>
-statement in this way can change the effect of the <code>continue</code>
-statement inside the loop.
-
- <p>The <samp><span class="command">awk</span></samp> language has a
<code>for</code> statement in addition to a
-<code>while</code> statement because a <code>for</code> loop is often both
less work to
-type and more natural to think of. Counting the number of iterations is
-very common in loops. It can be easier to think of this counting as part
-of looping rather than as something to do inside the loop.
-
- </body></html>
-
Index: manual/html_node/Foreword.html
===================================================================
RCS file: manual/html_node/Foreword.html
diff -N manual/html_node/Foreword.html
--- manual/html_node/Foreword.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,156 +0,0 @@
-<html lang="en">
-<head>
-<title>Foreword - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="index.html#Top" title="Top">
-<link rel="next" href="Preface.html#Preface" title="Preface">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Foreword"></a>Next: <a rel="next" accesskey="n"
href="Preface.html#Preface">Preface</a>,
-Previous: <a rel="previous" accesskey="p" href="index.html#Top">Top</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">Foreword</h2>
-
-<p>Arnold Robbins and I are good friends. We were introduced 11 years ago
-by circumstances—and our favorite programming language, AWK.
-The circumstances started a couple of years
-earlier. I was working at a new job and noticed an unplugged
-Unix computer sitting in the corner. No one knew how to use it,
-and neither did I. However,
-a couple of days later it was running, and
-I was <code>root</code> and the one-and-only user.
-That day, I began the transition from statistician to Unix programmer.
-
- <p>On one of many trips to the library or bookstore in search of
-books on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and
-Weinberger, <cite>The AWK Programming Language</cite>, Addison-Wesley,
-1988. AWK's simple programming paradigm—find a pattern in the
-input and then perform an action—often reduced complex or tedious
-data manipulations to few lines of code. I was excited to try my
-hand at programming in AWK.
-
- <p>Alas, the <samp><span class="command">awk</span></samp> on my computer
was a limited version of the
-language described in the AWK book. I discovered that my computer
-had “old <samp><span class="command">awk</span></samp>” and the
AWK book described “new <samp><span
class="command">awk</span></samp>.”
-I learned that this was typical; the old version refused to step
-aside or relinquish its name. If a system had a new <samp><span
class="command">awk</span></samp>, it was
-invariably called <samp><span class="command">nawk</span></samp>, and few
systems had it.
-The best way to get a new <samp><span class="command">awk</span></samp> was to
<samp><span class="command">ftp</span></samp> the source code for
-<samp><span class="command">gawk</span></samp> from
<code>prep.ai.mit.edu</code>. <samp><span class="command">gawk</span></samp>
was a version of
-new <samp><span class="command">awk</span></samp> written by David Trueman and
Arnold, and available under
-the GNU General Public License.
-
- <p>(Incidentally,
-it's no longer difficult to find a new <samp><span
class="command">awk</span></samp>. <samp><span
class="command">gawk</span></samp> ships with
-Linux, and you can download binaries or source code for almost
-any system; my wife uses <samp><span class="command">gawk</span></samp> on her
VMS box.)
-
- <p>My Unix system started out unplugged from the wall; it certainly was not
-plugged into a network. So, oblivious to the existence of <samp><span
class="command">gawk</span></samp>
-and the Unix community in general, and desiring a new <samp><span
class="command">awk</span></samp>, I wrote
-my own, called <samp><span class="command">mawk</span></samp>.
-Before I was finished I knew about <samp><span
class="command">gawk</span></samp>,
-but it was too late to stop, so I eventually posted
-to a <code>comp.sources</code> newsgroup.
-
- <p>A few days after my posting, I got a friendly email
-from Arnold introducing
-himself. He suggested we share design and algorithms and
-attached a draft of the POSIX standard so
-that I could update <samp><span class="command">mawk</span></samp> to support
language extensions added
-after publication of the AWK book.
-
- <p>Frankly, if our roles had
-been reversed, I would not have been so open and we probably would
-have never met. I'm glad we did meet.
-He is an AWK expert's AWK expert and a genuinely nice person.
-Arnold contributes significant amounts of his
-expertise and time to the Free Software Foundation.
-
- <p>This book is the <samp><span class="command">gawk</span></samp>
reference manual, but at its core it
-is a book about AWK programming that
-will appeal to a wide audience.
-It is a definitive reference to the AWK language as defined by the
-1987 Bell Labs release and codified in the 1992 POSIX Utilities
-standard.
-
- <p>On the other hand, the novice AWK programmer can study
-a wealth of practical programs that emphasize
-the power of AWK's basic idioms:
-data driven control-flow, pattern matching with regular expressions,
-and associative arrays.
-Those looking for something new can try out <samp><span
class="command">gawk</span></samp>'s
-interface to network protocols via special <samp><span
class="file">/inet</span></samp> files.
-
- <p>The programs in this book make clear that an AWK program is
-typically much smaller and faster to develop than
-a counterpart written in C.
-Consequently, there is often a payoff to prototype an
-algorithm or design in AWK to get it running quickly and expose
-problems early. Often, the interpreted performance is adequate
-and the AWK prototype becomes the product.
-
- <p>The new <samp><span class="command">pgawk</span></samp> (profiling
<samp><span class="command">gawk</span></samp>), produces
-program execution counts.
-I recently experimented with an algorithm that for
-n lines of input, exhibited
-~ C n^2
-performance, while
-theory predicted
-~ C n log n
-behavior. A few minutes poring
-over the <samp><span class="file">awkprof.out</span></samp> profile pinpointed
the problem to
-a single line of code. <samp><span class="command">pgawk</span></samp> is a
welcome addition to
-my programmer's toolbox.
-
- <p>Arnold has distilled over a decade of experience writing and
-using AWK programs, and developing <samp><span
class="command">gawk</span></samp>, into this book. If you use
-AWK or want to learn how, then read this book.
-
-<pre class="display"> Michael Brennan
- Author of <samp><span class="command">mawk</span></samp>
-</pre>
- </body></html>
-
Index: manual/html_node/Format-Modifiers.html
===================================================================
RCS file: manual/html_node/Format-Modifiers.html
diff -N manual/html_node/Format-Modifiers.html
--- manual/html_node/Format-Modifiers.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,224 +0,0 @@
-<html lang="en">
-<head>
-<title>Format Modifiers - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printf.html#Printf" title="Printf">
-<link rel="prev" href="Control-Letters.html#Control-Letters" title="Control
Letters">
-<link rel="next" href="Printf-Examples.html#Printf-Examples" title="Printf
Examples">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Format-Modifiers"></a>Next: <a rel="next" accesskey="n"
href="Printf-Examples.html#Printf-Examples">Printf Examples</a>,
-Previous: <a rel="previous" accesskey="p"
href="Control-Letters.html#Control-Letters">Control Letters</a>,
-Up: <a rel="up" accesskey="u" href="Printf.html#Printf">Printf</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.5.3 Modifiers for <code>printf</code> Formats</h4>
-
-<!-- STARTOFRANGE pfm -->
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-modifiers-536"></a><a
name="index-modifiers_0040comma_007b_007d-in-format-specifiers-537"></a>A
format specification can also include <dfn>modifiers</dfn> that can control
-how much of the item's value is printed, as well as how much space it gets.
-The modifiers come between the `<samp><span class="samp">%</span></samp>' and
the format-control letter.
-We will use the bullet symbol “•” in the following examples to
-represent
-spaces in the output. Here are the possible modifiers, in the order in
-which they may appear:
-
-
-<a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-538"></a>
-<a
name="index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-539"></a>
-<dl><!-- the command does NOT start a secondary -->
-<a
name="index-positional-specifiers_002c-_0040code_007bprintf_007d-statement-540"></a><dt><var>N</var><code>$</code><dd>An
integer constant followed by a `<samp><span class="samp">$</span></samp>' is a
<dfn>positional specifier</dfn>.
-Normally, format specifications are applied to arguments in the order
-given in the format string. With a positional specifier, the format
-specification is applied to a specific argument, instead of what
-would be the next argument in the list. Positional specifiers begin
-counting with one. Thus:
-
- <pre class="example"> printf "%s %s\n", "don't", "panic"
- printf "%2$s %1$s\n", "panic", "don't"
- </pre>
- <p class="noindent">prints the famous friendly message twice.
-
- <p>At first glance, this feature doesn't seem to be of much use.
-It is in fact a <samp><span class="command">gawk</span></samp> extension,
intended for use in translating
-messages at runtime.
-See <a href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a>,
-which describes how and why to use positional specifiers.
-For now, we will not use them.
-
- <br><dt><code>-</code><dd>The minus sign, used before the width modifier
(see later on in
-this table),
-says to left-justify
-the argument within its specified width. Normally, the argument
-is printed right-justified in the specified width. Thus:
-
- <pre class="example"> printf "%-4s", "foo"
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">foo•</span></samp>'.
-
- <br><dt><var>space</var><dd>For numeric conversions, prefix positive
values with a space and
-negative values with a minus sign.
-
- <br><dt><code>+</code><dd>The plus sign, used before the width modifier
(see later on in
-this table),
-says to always supply a sign for numeric conversions, even if the data
-to format is positive. The `<samp><span class="samp">+</span></samp>'
overrides the space modifier.
-
- <br><dt><code>#</code><dd>Use an “alternate form” for certain
control letters.
-For `<samp><span class="samp">%o</span></samp>', supply a leading zero.
-For `<samp><span class="samp">%x</span></samp>' and `<samp><span
class="samp">%X</span></samp>', supply a leading `<samp><span
class="samp">0x</span></samp>' or `<samp><span class="samp">0X</span></samp>'
for
-a nonzero result.
-For `<samp><span class="samp">%e</span></samp>', `<samp><span
class="samp">%E</span></samp>', and `<samp><span
class="samp">%f</span></samp>', the result always contains a
-decimal point.
-For `<samp><span class="samp">%g</span></samp>' and `<samp><span
class="samp">%G</span></samp>', trailing zeros are not removed from the result.
-
- <p><a name="index-dark-corner-541"></a><br><dt><code>0</code><dd>A
leading `<samp><span class="samp">0</span></samp>' (zero) acts as a flag that
indicates that output should be
-padded with zeros instead of spaces.
-This applies even to non-numeric output formats.
-(d.c.)
-This flag only has an effect when the field width is wider than the
-value to print.
-
- <br><dt><code>'</code><dd>A single quote or apostrohe character is a
POSIX extension to ISO C.
-It indicates that the integer part of a floating point value, or the
-entire part of an integer decimal value, should have a thousands-separator
-character in it. This only works in locales that support such characters.
-For example:
-
- <pre class="example"> $ <kbd>cat thousands.awk</kbd>
<i>Show source program</i>
- -| BEGIN { printf "%'d\n", 1234567 }
- $ <kbd>LC_ALL=C gawk -f thousands.awk</kbd>
<i>Run it in "C" locale</i>
- -| 1234567
- $ <kbd>LC_ALL=en_US.UTF-8 gawk -f thousands.awk</kbd>
<i>Run in US English UTF locale</i>
- -| 1,234,567
- </pre>
- <p class="noindent">For more information about locales and
internationalization issues,
-<strong>FIXME: see xxxx</strong>.
-
- <blockquote>
-<b>NOTE:</b> The `<samp><span class="samp">'</span></samp>' flag is a nice
feature, but its use complicates things: it
-now becomes difficult to use it in command-line programs. For information
-on appropriate quoting tricks, <strong>FIXME: see XXXX</strong>.
-</blockquote>
-
- <br><dt><var>width</var><dd>This is a number specifying the desired
minimum width of a field. Inserting any
-number between the `<samp><span class="samp">%</span></samp>' sign and the
format-control character forces the
-field to expand to this width. The default way to do this is to
-pad with spaces on the left. For example:
-
- <pre class="example"> printf "%4s", "foo"
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">•foo</span></samp>'.
-
- <p>The value of <var>width</var> is a minimum width, not a maximum. If
the item
-value requires more than <var>width</var> characters, it can be as wide as
-necessary. Thus, the following:
-
- <pre class="example"> printf "%4s", "foobar"
- </pre>
- <p class="noindent">prints `<samp><span
class="samp">foobar</span></samp>'.
-
- <p>Preceding the <var>width</var> with a minus sign causes the output to
be
-padded with spaces on the right, instead of on the left.
-
- <br><dt><code>.</code><var>prec</var><dd>A period followed by an integer
constant
-specifies the precision to use when printing.
-The meaning of the precision varies by control letter:
-
- <dl>
-<dt><code>%e</code>, <code>%E</code>, <code>%f</code><dd>Number of digits to
the right of the decimal point.
-
- <br><dt><code>%g</code>, <code>%G</code><dd>Maximum number of
significant digits.
-
- <br><dt><code>%d</code>, <code>%i</code>, <code>%o</code>,
<code>%u</code>, <code>%x</code>, <code>%X</code><dd>Minimum number of digits
to print.
-
- <br><dt><code>%s</code><dd>Maximum number of characters from the
string that should print.
-</dl>
-
- <p>Thus, the following:
-
- <pre class="example"> printf "%.4s", "foobar"
- </pre>
- <p class="noindent">prints `<samp><span class="samp">foob</span></samp>'.
-</dl>
-
- <p>The C library <code>printf</code>'s dynamic <var>width</var> and
<var>prec</var>
-capability (for example, <code>"%*.*s"</code>) is supported. Instead of
-supplying explicit <var>width</var> and/or <var>prec</var> values in the format
-string, they are passed in the argument list. For example:
-
-<pre class="example"> w = 5
- p = 3
- s = "abcdefg"
- printf "%*.*s\n", w, p, s
-</pre>
- <p class="noindent">is exactly equivalent to:
-
-<pre class="example"> s = "abcdefg"
- printf "%5.3s\n", s
-</pre>
- <p class="noindent">Both programs output `<samp><span
class="samp">••abc<!-- /@w --></span></samp>'.
-Earlier versions of <samp><span class="command">awk</span></samp> did not
support this capability.
-If you must use such a version, you may simulate this feature by using
-concatenation to build up the format string, like so:
-
-<pre class="example"> w = 5
- p = 3
- s = "abcdefg"
- printf "%" w "." p "s\n", s
-</pre>
- <p class="noindent">This is not particularly easy to read but it does work.
-
-<!-- @cindex lint checks -->
-<p><a
name="index-troubleshooting_002c-fatal-errors_002c-_0040code_007bprintf_007d-format-strings-542"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bprintf_007d-format-strings-and-543"></a>C
programmers may be used to supplying additional
-`<samp><span class="samp">l</span></samp>', `<samp><span
class="samp">L</span></samp>', and `<samp><span class="samp">h</span></samp>'
-modifiers in <code>printf</code> format strings. These are not valid in
<samp><span class="command">awk</span></samp>.
-Most <samp><span class="command">awk</span></samp> implementations silently
ignore these modifiers.
-If <samp><span class="option">--lint</span></samp> is provided on the command
line
-(see <a href="Options.html#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> warns about their use. If
<samp><span class="option">--posix</span></samp> is supplied,
-their use is a fatal error.
-<!-- ENDOFRANGE pfm -->
-
- </body></html>
-
Index: manual/html_node/Function-Calls.html
===================================================================
RCS file: manual/html_node/Function-Calls.html
diff -N manual/html_node/Function-Calls.html
--- manual/html_node/Function-Calls.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,124 +0,0 @@
-<html lang="en">
-<head>
-<title>Function Calls - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Conditional-Exp.html#Conditional-Exp"
title="Conditional Exp">
-<link rel="next" href="Precedence.html#Precedence" title="Precedence">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Function-Calls"></a>Next: <a rel="next" accesskey="n"
href="Precedence.html#Precedence">Precedence</a>,
-Previous: <a rel="previous" accesskey="p"
href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.13 Function Calls</h3>
-
-<p><a name="index-function-calls-804"></a>
-A <dfn>function</dfn> is a name for a particular calculation.
-This enables you to
-ask for it by name at any point in the program. For
-example, the function <code>sqrt</code> computes the square root of a number.
-
- <p><a name="index-functions_002c-built_002din-805"></a>A fixed set of
functions are <dfn>built-in</dfn>, which means they are
-available in every <samp><span class="command">awk</span></samp> program. The
<code>sqrt</code> function is one
-of these. See <a href="Built_002din.html#Built_002din">Built-in</a>, for a
list of built-in
-functions and their descriptions. In addition, you can define
-functions for use in your program.
-See <a href="User_002ddefined.html#User_002ddefined">User-defined</a>,
-for instructions on how to do this.
-
- <p><a name="index-arguments_002c-in-function-calls-806"></a>The way to use
a function is with a <dfn>function call</dfn> expression,
-which consists of the function name followed immediately by a list of
-<dfn>arguments</dfn> in parentheses. The arguments are expressions that
-provide the raw materials for the function's calculations.
-When there is more than one argument, they are separated by commas. If
-there are no arguments, just write `<samp><span class="samp">()</span></samp>'
after the function name.
-The following examples show function calls with and without arguments:
-
-<pre class="example"> sqrt(x^2 + y^2) <i>one argument</i>
- atan2(y, x) <i>two arguments</i>
- rand() <i>no arguments</i>
-</pre>
- <p><a
name="index-troubleshooting_002c-function-call-syntax-807"></a><strong>Caution:</strong>
-Do not put any space between the function name and the open-parenthesis!
-A user-defined function name looks just like the name of a
-variable—a space would make the expression look like concatenation of
-a variable with an expression inside parentheses.
-
- <p>With built-in functions, space before the parenthesis is harmless, but
-it is best not to get into the habit of using space to avoid mistakes
-with user-defined functions. Each function expects a particular number
-of arguments. For example, the <code>sqrt</code> function must be called with
-a single argument, the number of which to take the square root:
-
-<pre class="example"> sqrt(<var>argument</var>)
-</pre>
- <p>Some of the built-in functions have one or
-more optional arguments.
-If those arguments are not supplied, the functions
-use a reasonable default value.
-See <a href="Built_002din.html#Built_002din">Built-in</a>, for full details.
If arguments
-are omitted in calls to user-defined functions, then those arguments are
-treated as local variables and initialized to the empty string
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>).
-
- <p><a name="index-side-effects_002c-function-calls-808"></a>Like every
other expression, the function call has a value, which is
-computed by the function based on the arguments you give it. In this
-example, the value of `<samp><span
class="samp">sqrt(</span><var>argument</var><span class="samp">)</span></samp>'
is the square root of
-<var>argument</var>. A function can also have side effects, such as assigning
-values to certain variables or doing I/O.
-The following program reads numbers, one number per line, and prints the
-square root of each one:
-
-<pre class="example"> $ awk '{ print "The square root of", $1, "is",
sqrt($1) }'
- 1
- -| The square root of 1 is 1
- 3
- -| The square root of 3 is 1.73205
- 5
- -| The square root of 5 is 2.23607
- <kbd>Ctrl-d</kbd>
-</pre>
- </body></html>
-
Index: manual/html_node/Function-Caveats.html
===================================================================
RCS file: manual/html_node/Function-Caveats.html
diff -N manual/html_node/Function-Caveats.html
--- manual/html_node/Function-Caveats.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,164 +0,0 @@
-<html lang="en">
-<head>
-<title>Function Caveats - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="User_002ddefined.html#User_002ddefined"
title="User-defined">
-<link rel="prev" href="Function-Example.html#Function-Example" title="Function
Example">
-<link rel="next" href="Return-Statement.html#Return-Statement" title="Return
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Function-Caveats"></a>Next: <a rel="next" accesskey="n"
href="Return-Statement.html#Return-Statement">Return Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="Function-Example.html#Function-Example">Function Example</a>,
-Up: <a rel="up" accesskey="u"
href="User_002ddefined.html#User_002ddefined">User-defined</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.2.3 Calling User-Defined Functions</h4>
-
-<!-- STARTOFRANGE fudc -->
-<p><a
name="index-functions_002c-user_002ddefined_002c-calling-1289"></a><dfn>Calling
a function</dfn> means causing the function to run and do its job.
-A function call is an expression and its value is the value returned by
-the function.
-
- <p>A function call consists of the function name followed by the arguments
-in parentheses. <samp><span class="command">awk</span></samp> expressions are
what you write in the
-call for the arguments. Each time the call is executed, these
-expressions are evaluated, and the values are the actual arguments. For
-example, here is a call to <code>foo</code> with three arguments (the first
-being a string concatenation):
-
-<pre class="example"> foo(x y, "lose", 4 * z)
-</pre>
- <p><strong>Caution:</strong> Whitespace characters (spaces and tabs) are
not allowed
-between the function name and the open-parenthesis of the argument list.
-If you write whitespace by mistake, <samp><span
class="command">awk</span></samp> might think that you mean
-to concatenate a variable with an expression in parentheses. However, it
-notices that you used a function name and not a variable name, and reports
-an error.
-
- <p><a name="index-call-by-value-1290"></a>When a function is called, it is
given a <em>copy</em> of the values of
-its arguments. This is known as <dfn>call by value</dfn>. The caller may use
-a variable as the expression for the argument, but the called function
-does not know this—it only knows what value the argument had. For
-example, if you write the following code:
-
-<pre class="example"> foo = "bar"
- z = myfunc(foo)
-</pre>
- <p class="noindent">then you should not think of the argument to
<code>myfunc</code> as being
-“the variable <code>foo</code>.” Instead, think of the argument
as the
-string value <code>"bar"</code>.
-If the function <code>myfunc</code> alters the values of its local variables,
-this has no effect on any other variables. Thus, if <code>myfunc</code>
-does this:
-
-<pre class="example"> function myfunc(str)
- {
- print str
- str = "zzz"
- print str
- }
-</pre>
- <p class="noindent">to change its first argument variable <code>str</code>,
it does <em>not</em>
-change the value of <code>foo</code> in the caller. The role of
<code>foo</code> in
-calling <code>myfunc</code> ended when its value (<code>"bar"</code>) was
computed.
-If <code>str</code> also exists outside of <code>myfunc</code>, the function
body
-cannot alter this outer value, because it is shadowed during the
-execution of <code>myfunc</code> and cannot be seen or changed from there.
-
- <p><a name="index-call-by-reference-1291"></a><a
name="index-arrays_002c-as-parameters-to-functions-1292"></a><a
name="index-functions_002c-arrays-as-parameters-to-1293"></a>However, when
arrays are the parameters to functions, they are <em>not</em>
-copied. Instead, the array itself is made available for direct manipulation
-by the function. This is usually called <dfn>call by reference</dfn>.
-Changes made to an array parameter inside the body of a function <em>are</em>
-visible outside that function.
-
- <blockquote>
-<b>NOTE:</b> Changing an array parameter inside a function
-can be very dangerous if you do not watch what you are doing.
-For example:
-
- <pre class="example"> function changeit(array, ind, nvalue)
- {
- array[ind] = nvalue
- }
-
- BEGIN {
- a[1] = 1; a[2] = 2; a[3] = 3
- changeit(a, 2, "two")
- printf "a[1] = %s, a[2] = %s, a[3] = %s\n",
- a[1], a[2], a[3]
- }
- </pre>
- <p class="noindent">prints `<samp><span class="samp">a[1] = 1, a[2] =
two, a[3] = 3</span></samp>', because
-<code>changeit</code> stores <code>"two"</code> in the second element of
<code>a</code>.
-</blockquote>
-
- <p><a name="index-undefined-functions-1294"></a><a
name="index-functions_002c-undefined-1295"></a>Some <samp><span
class="command">awk</span></samp> implementations allow you to call a function
that
-has not been defined. They only report a problem at runtime when the
-program actually tries to call the function. For example:
-
-<pre class="example"> BEGIN {
- if (0)
- foo()
- else
- bar()
- }
- function bar() { ... }
- # note that `foo' is not defined
-</pre>
- <p class="noindent">Because the `<samp><span class="samp">if</span></samp>'
statement will never be true, it is not really a
-problem that <code>foo</code> has not been defined. Usually, though, it is a
-problem if a program calls an undefined function.
-
- <p><a name="index-lint-checking_002c-undefined-functions-1296"></a>If
<samp><span class="option">--lint</span></samp> is specified
-(see <a href="Options.html#Options">Options</a>),
-<samp><span class="command">gawk</span></samp> reports calls to undefined
functions.
-
- <p><a
name="index-portability_002c-_0040code_007bnext_007d-statement-in-user_002ddefined-functions-1297"></a>Some
<samp><span class="command">awk</span></samp> implementations generate a
runtime
-error if you use the <code>next</code> statement
-(see <a href="Next-Statement.html#Next-Statement">Next Statement</a>)
-inside a user-defined function.
-<samp><span class="command">gawk</span></samp> does not have this limitation.
-<!-- ENDOFRANGE fudc -->
-
- </body></html>
-
Index: manual/html_node/Function-Example.html
===================================================================
RCS file: manual/html_node/Function-Example.html
diff -N manual/html_node/Function-Example.html
--- manual/html_node/Function-Example.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,144 +0,0 @@
-<html lang="en">
-<head>
-<title>Function Example - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="User_002ddefined.html#User_002ddefined"
title="User-defined">
-<link rel="prev" href="Definition-Syntax.html#Definition-Syntax"
title="Definition Syntax">
-<link rel="next" href="Function-Caveats.html#Function-Caveats" title="Function
Caveats">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Function-Example"></a>Next: <a rel="next" accesskey="n"
href="Function-Caveats.html#Function-Caveats">Function Caveats</a>,
-Previous: <a rel="previous" accesskey="p"
href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a>,
-Up: <a rel="up" accesskey="u"
href="User_002ddefined.html#User_002ddefined">User-defined</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.2.2 Function Definition Examples</h4>
-
-<p>Here is an example of a user-defined function, called <code>myprint</code>,
that
-takes a number and prints it in a specific format:
-
-<pre class="example"> function myprint(num)
- {
- printf "%6.3g\n", num
- }
-</pre>
- <p class="noindent">To illustrate, here is an <samp><span
class="command">awk</span></samp> rule that uses our <code>myprint</code>
-function:
-
-<pre class="example"> $3 > 0 { myprint($3) }
-</pre>
- <p class="noindent">This program prints, in our special format, all the
third fields that
-contain a positive number in our input. Therefore, when given the following:
-
-<pre class="example"> 1.2 3.4 5.6 7.8
- 9.10 11.12 -13.14 15.16
- 17.18 19.20 21.22 23.24
-</pre>
- <p class="noindent">this program, using our function to format the results,
prints:
-
-<pre class="example"> 5.6
- 21.2
-</pre>
- <p>This function deletes all the elements in an array:
-
-<pre class="example"> function delarray(a, i)
- {
- for (i in a)
- delete a[i]
- }
-</pre>
- <p>When working with arrays, it is often necessary to delete all the
elements
-in an array and start over with a new list of elements
-(see <a href="Delete.html#Delete">Delete</a>).
-Instead of having
-to repeat this loop everywhere that you need to clear out
-an array, your program can just call <code>delarray</code>.
-(This guarantees portability. The use of `<samp><span class="samp">delete
</span><var>array</var></samp>' to delete
-the contents of an entire array is a nonstandard extension.)
-
- <p>The following is an example of a recursive function. It takes a string
-as an input parameter and returns the string in backwards order.
-Recursive functions must always have a test that stops the recursion.
-In this case, the recursion terminates when the starting position
-is zero, i.e., when there are no more characters left in the string.
-
- <p><a
name="index-_0040code_007brev_007d-user_002ddefined-function-1287"></a>
-<pre class="example"> function rev(str, start)
- {
- if (start == 0)
- return ""
-
- return (substr(str, start, 1) rev(str, start - 1))
- }
-</pre>
- <p>If this function is in a file named <samp><span
class="file">rev.awk</span></samp>, it can be tested
-this way:
-
-<pre class="example"> $ echo "Don't Panic!" |
- > gawk --source '{ print rev($0, length($0)) }' -f rev.awk
- -| !cinaP t'noD
-</pre>
- <p>The C <code>ctime</code> function takes a timestamp and returns it in a
string,
-formatted in a well-known fashion.
-The following example uses the built-in <code>strftime</code> function
-(see <a href="Time-Functions.html#Time-Functions">Time Functions</a>)
-to create an <samp><span class="command">awk</span></samp> version of
<code>ctime</code>:
-
- <p><a
name="index-_0040code_007bctime_007d-user_002ddefined-function-1288"></a><!--
FIXME: One day, change %d to %e, when C 99 is common. -->
-<pre class="example"> <!-- file eg/lib/ctime.awk -->
- # ctime.awk
- #
- # awk version of C ctime(3) function
-
- function ctime(ts, format)
- {
- format = "%a %b %d %H:%M:%S %Z %Y"
- if (ts == 0)
- ts = systime() # use current time as default
- return strftime(format, ts)
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE fdef -->
-</body></html>
-
Index: manual/html_node/Functions.html
===================================================================
RCS file: manual/html_node/Functions.html
diff -N manual/html_node/Functions.html
--- manual/html_node/Functions.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-<html lang="en">
-<head>
-<title>Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Arrays.html#Arrays" title="Arrays">
-<link rel="next" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Functions"></a>Next: <a rel="next" accesskey="n"
href="Internationalization.html#Internationalization">Internationalization</a>,
-Previous: <a rel="previous" accesskey="p"
href="Arrays.html#Arrays">Arrays</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">8 Functions</h2>
-
-<!-- STARTOFRANGE funcbi -->
-<p><a name="index-functions_002c-built_002din-1140"></a><!-- STARTOFRANGE
bifunc -->
-<a name="index-built_002din-functions-1141"></a>This chapter describes
<samp><span class="command">awk</span></samp>'s built-in functions,
-which fall into three categories: numeric, string, and I/O.
-<samp><span class="command">gawk</span></samp> provides additional groups of
functions
-to work with values that represent time, do
-bit manipulation, and internationalize and localize programs.
-
- <p>Besides the built-in functions, <samp><span
class="command">awk</span></samp> has provisions for
-writing new functions that the rest of a program can use.
-The second half of this chapter describes these
-<dfn>user-defined</dfn> functions.
-
-<ul class="menu">
-<li><a accesskey="1" href="Built_002din.html#Built_002din">Built-in</a>:
Summarizes the built-in functions.
-<li><a accesskey="2"
href="User_002ddefined.html#User_002ddefined">User-defined</a>:
Describes User-defined functions in detail.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Future-Extensions.html
===================================================================
RCS file: manual/html_node/Future-Extensions.html
diff -N manual/html_node/Future-Extensions.html
--- manual/html_node/Future-Extensions.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,157 +0,0 @@
-<html lang="en">
-<head>
-<title>Future Extensions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Notes.html#Notes" title="Notes">
-<link rel="prev" href="Dynamic-Extensions.html#Dynamic-Extensions"
title="Dynamic Extensions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Future-Extensions"></a>Previous: <a rel="previous" accesskey="p"
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a>,
-Up: <a rel="up" accesskey="u" href="Notes.html#Notes">Notes</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">C.4 Probable Future Extensions</h3>
-
-<p><a name="index-PERL-2019"></a><a name="index-Wall_002c-Larry-2020"></a><a
name="index-Robbins_002c-Arnold-2021"></a><blockquote>
-<i>AWK is a language similar to PERL, only considerably more elegant.</i><br>
-Arnold Robbins
-
- <p><i>Hey!</i><br>
-Larry Wall
-</blockquote>
-
- <p>This section briefly lists extensions and possible improvements
-that indicate the directions we are
-currently considering for <samp><span class="command">gawk</span></samp>. The
file <samp><span class="file">FUTURES</span></samp> in the
-<samp><span class="command">gawk</span></samp> distribution lists these
extensions as well.
-
- <p>Following is a list of probable future changes visible at the
-<samp><span class="command">awk</span></samp> language level:
-
-<!-- these are ordered by likelihood -->
-<dl>
-<dt>Loadable module interface<dd>It is not clear that the <samp><span
class="command">awk</span></samp>-level interface to the
-modules facility is as good as it should be. The interface needs to be
-redesigned, particularly taking namespace issues into account, as
-well as possibly including issues such as library search path order
-and versioning.
-
- <br><dt><code>RECLEN</code> variable for fixed-length records<dd>Along
with <code>FIELDWIDTHS</code>, this would speed up the processing of
-fixed-length records.
-<code>PROCINFO["RS"]</code> would be <code>"RS"</code> or
<code>"RECLEN"</code>,
-depending upon which kind of record processing is in effect.
-
- <br><dt>Additional <code>printf</code> specifiers<dd>The 1999 ISO C
standard added a number of additional <code>printf</code>
-format specifiers. These should be evaluated for possible inclusion
-in <samp><span class="command">gawk</span></samp>.
-
- <br><dt>Databases<dd>It may be possible to map a GDBM/NDBM/SDBM file into
an <samp><span class="command">awk</span></samp> array.
-
- <br><dt>Large character sets<dd>It would be nice if <samp><span
class="command">gawk</span></samp> could handle UTF-8 and other
-character sets that are larger than eight bits.
-(<samp><span class="command">gawk</span></samp> currently has partial
multi-byte support, but it
-needs an expert to really think out the multi-byte issues and consult
-with the maintainer on the appropriate changes.)
-
- <br><dt>More <code>lint</code> warnings<dd>There are more things that
could be checked for portability.
-</dl>
-
- <p>Following is a list of probable improvements that will make <samp><span
class="command">gawk</span></samp>'s
-source code easier to work with:
-
- <dl>
-<dt>Loadable module mechanics<dd>The current extension mechanism works
-(see <a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a>),
-but is rather primitive. It requires a fair amount of manual work
-to create and integrate a loadable module.
-Nor is the current mechanism as portable as might be desired.
-The GNU <samp><span class="command">libtool</span></samp> package provides a
number of features that
-would make using loadable modules much easier.
-<samp><span class="command">gawk</span></samp> should be changed to use
<samp><span class="command">libtool</span></samp>.
-
- <br><dt>Loadable module internals<dd>The API to its internals that
<samp><span class="command">gawk</span></samp> “exports” should be
revised.
-Too many things are needlessly exposed. A new API should be designed
-and implemented to make module writing easier.
-
- <br><dt>Better array subscript management<dd><samp><span
class="command">gawk</span></samp>'s management of array subscript storage
could use revamping,
-so that using the same value to index multiple arrays only
-stores one copy of the index value.
-
- <br><dt>Integrating the DBUG library<dd>Integrating Fred Fish's DBUG
library would be helpful during development,
-but it's a lot of work to do.
-</dl>
-
- <p>Following is a list of probable improvements that will make <samp><span
class="command">gawk</span></samp>
-perform better:
-
- <dl>
-<!-- NEXT ED: remove this item. awka and mawk do these respectively -->
-<dt>Compilation of <samp><span class="command">awk</span></samp>
programs<dd><samp><span class="command">gawk</span></samp> uses a Bison
(YACC-like)
-parser to convert the script given it into a syntax tree; the syntax
-tree is then executed by a simple recursive evaluator. This method incurs
-a lot of overhead, since the recursive evaluator performs many procedure
-calls to do even the simplest things.
-
- <p>It should be possible for <samp><span
class="command">gawk</span></samp> to convert the script's parse tree
-into a C program which the user would then compile, using the normal
-C compiler and a special <samp><span class="command">gawk</span></samp>
library to provide all the needed
-functions (regexps, fields, associative arrays, type coercion, and so on).
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2022"></a>An
easier possibility might be for an intermediate phase of <samp><span
class="command">gawk</span></samp> to
-convert the parse tree into a linear byte code form like the one used
-in GNU Emacs Lisp. The recursive evaluator would then be replaced by
-a straight line byte code interpreter that would be intermediate in speed
-between running a compiled program and doing what <samp><span
class="command">gawk</span></samp> does
-now.
-</dl>
-
- <p>Finally,
-the programs in the test suite could use documenting in this Web page.
-
- <p>See <a href="Additions.html#Additions">Additions</a>,
-if you are interested in tackling any of these projects.
-<!-- ENDOFRANGE impis -->
-<!-- ENDOFRANGE gawii -->
-
- </body></html>
-
Index: manual/html_node/GNU-Free-Documentation-License.html
===================================================================
RCS file: manual/html_node/GNU-Free-Documentation-License.html
diff -N manual/html_node/GNU-Free-Documentation-License.html
--- manual/html_node/GNU-Free-Documentation-License.html 29 Jun 2005
21:04:12 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,467 +0,0 @@
-<html lang="en">
-<head>
-<title>GNU Free Documentation License - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Copying.html#Copying" title="Copying">
-<link rel="next" href="Index.html#Index" title="Index">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="GNU-Free-Documentation-License"></a>Next: <a rel="next"
accesskey="n" href="Index.html#Index">Index</a>,
-Previous: <a rel="previous" accesskey="p"
href="Copying.html#Copying">Copying</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">GNU Free Documentation License</h2>
-
-<p><a name="index-FDL-_0028Free-Documentation-License_0029-2087"></a><a
name="index-Free-Documentation-License-_0028FDL_0029-2088"></a><a
name="index-GNU-Free-Documentation-License-2089"></a><div
align="center">Version 1.2, November 2002</div>
-
-<pre class="display"> Copyright © 2000,2001,2002 Free Software
Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-</pre>
- <ol type=1 start=0>
-<li>PREAMBLE
-
- <p>The purpose of this License is to make a manual, textbook, or other
-functional and useful document <dfn>free</dfn> in the sense of freedom: to
-assure everyone the effective freedom to copy and redistribute it,
-with or without modifying it, either commercially or noncommercially.
-Secondarily, this License preserves for the author and publisher a way
-to get credit for their work, while not being considered responsible
-for modifications made by others.
-
- <p>This License is a kind of “copyleft”, which means that
derivative
-works of the document must themselves be free in the same sense. It
-complements the GNU General Public License, which is a copyleft
-license designed for free software.
-
- <p>We have designed this License in order to use it for manuals for free
-software, because free software needs free documentation: a free
-program should come with manuals providing the same freedoms that the
-software does. But this License is not limited to software manuals;
-it can be used for any textual work, regardless of subject matter or
-whether it is published as a printed book. We recommend this License
-principally for works whose purpose is instruction or reference.
-
- <li>APPLICABILITY AND DEFINITIONS
-
- <p>This License applies to any manual or other work, in any medium, that
-contains a notice placed by the copyright holder saying it can be
-distributed under the terms of this License. Such a notice grants a
-world-wide, royalty-free license, unlimited in duration, to use that
-work under the conditions stated herein. The “Document”, below,
-refers to any such manual or work. Any member of the public is a
-licensee, and is addressed as “you”. You accept the license if you
-copy, modify or distribute the work in a way requiring permission
-under copyright law.
-
- <p>A “Modified Version” of the Document means any work
containing the
-Document or a portion of it, either copied verbatim, or with
-modifications and/or translated into another language.
-
- <p>A “Secondary Section” is a named appendix or a
front-matter section
-of the Document that deals exclusively with the relationship of the
-publishers or authors of the Document to the Document's overall
-subject (or to related matters) and contains nothing that could fall
-directly within that overall subject. (Thus, if the Document is in
-part a textbook of mathematics, a Secondary Section may not explain
-any mathematics.) The relationship could be a matter of historical
-connection with the subject or with related matters, or of legal,
-commercial, philosophical, ethical or political position regarding
-them.
-
- <p>The “Invariant Sections” are certain Secondary Sections
whose titles
-are designated, as being those of Invariant Sections, in the notice
-that says that the Document is released under this License. If a
-section does not fit the above definition of Secondary then it is not
-allowed to be designated as Invariant. The Document may contain zero
-Invariant Sections. If the Document does not identify any Invariant
-Sections then there are none.
-
- <p>The “Cover Texts” are certain short passages of text that
are listed,
-as Front-Cover Texts or Back-Cover Texts, in the notice that says that
-the Document is released under this License. A Front-Cover Text may
-be at most 5 words, and a Back-Cover Text may be at most 25 words.
-
- <p>A “Transparent” copy of the Document means a
machine-readable copy,
-represented in a format whose specification is available to the
-general public, that is suitable for revising the document
-straightforwardly with generic text editors or (for images composed of
-pixels) generic paint programs or (for drawings) some widely available
-drawing editor, and that is suitable for input to text formatters or
-for automatic translation to a variety of formats suitable for input
-to text formatters. A copy made in an otherwise Transparent file
-format whose markup, or absence of markup, has been arranged to thwart
-or discourage subsequent modification by readers is not Transparent.
-An image format is not Transparent if used for any substantial amount
-of text. A copy that is not “Transparent” is called
“Opaque”.
-
- <p>Examples of suitable formats for Transparent copies include plain
-<span class="sc">ascii</span> without markup, Texinfo input format, LaTeX input
-format, <acronym>SGML</acronym> or <acronym>XML</acronym> using a publicly
available
-<acronym>DTD</acronym>, and standard-conforming simple <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> designed for human modification. Examples
-of transparent image formats include <acronym>PNG</acronym>,
<acronym>XCF</acronym> and
-<acronym>JPG</acronym>. Opaque formats include proprietary formats that can be
-read and edited only by proprietary word processors, <acronym>SGML</acronym> or
-<acronym>XML</acronym> for which the <acronym>DTD</acronym> and/or processing
tools are
-not generally available, and the machine-generated <acronym>HTML</acronym>,
-PostScript or <acronym>PDF</acronym> produced by some word processors for
-output purposes only.
-
- <p>The “Title Page” means, for a printed book, the title page
itself,
-plus such following pages as are needed to hold, legibly, the material
-this License requires to appear in the title page. For works in
-formats which do not have any title page as such, “Title Page”
means
-the text near the most prominent appearance of the work's title,
-preceding the beginning of the body of the text.
-
- <p>A section “Entitled XYZ” means a named subunit of the
Document whose
-title either is precisely XYZ or contains XYZ in parentheses following
-text that translates XYZ in another language. (Here XYZ stands for a
-specific section name mentioned below, such as “Acknowledgements”,
-“Dedications”, “Endorsements”, or
“History”.) To “Preserve the Title”
-of such a section when you modify the Document means that it remains a
-section “Entitled XYZ” according to this definition.
-
- <p>The Document may include Warranty Disclaimers next to the notice which
-states that this License applies to the Document. These Warranty
-Disclaimers are considered to be included by reference in this
-License, but only as regards disclaiming warranties: any other
-implication that these Warranty Disclaimers may have is void and has
-no effect on the meaning of this License.
-
- <li>VERBATIM COPYING
-
- <p>You may copy and distribute the Document in any medium, either
-commercially or noncommercially, provided that this License, the
-copyright notices, and the license notice saying this License applies
-to the Document are reproduced in all copies, and that you add no other
-conditions whatsoever to those of this License. You may not use
-technical measures to obstruct or control the reading or further
-copying of the copies you make or distribute. However, you may accept
-compensation in exchange for copies. If you distribute a large enough
-number of copies you must also follow the conditions in section 3.
-
- <p>You may also lend copies, under the same conditions stated above, and
-you may publicly display copies.
-
- <li>COPYING IN QUANTITY
-
- <p>If you publish printed copies (or copies in media that commonly have
-printed covers) of the Document, numbering more than 100, and the
-Document's license notice requires Cover Texts, you must enclose the
-copies in covers that carry, clearly and legibly, all these Cover
-Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
-the back cover. Both covers must also clearly and legibly identify
-you as the publisher of these copies. The front cover must present
-the full title with all words of the title equally prominent and
-visible. You may add other material on the covers in addition.
-Copying with changes limited to the covers, as long as they preserve
-the title of the Document and satisfy these conditions, can be treated
-as verbatim copying in other respects.
-
- <p>If the required texts for either cover are too voluminous to fit
-legibly, you should put the first ones listed (as many as fit
-reasonably) on the actual cover, and continue the rest onto adjacent
-pages.
-
- <p>If you publish or distribute Opaque copies of the Document numbering
-more than 100, you must either include a machine-readable Transparent
-copy along with each Opaque copy, or state in or with each Opaque copy
-a computer-network location from which the general network-using
-public has access to download using public-standard network protocols
-a complete Transparent copy of the Document, free of added material.
-If you use the latter option, you must take reasonably prudent steps,
-when you begin distribution of Opaque copies in quantity, to ensure
-that this Transparent copy will remain thus accessible at the stated
-location until at least one year after the last time you distribute an
-Opaque copy (directly or through your agents or retailers) of that
-edition to the public.
-
- <p>It is requested, but not required, that you contact the authors of the
-Document well before redistributing any large number of copies, to give
-them a chance to provide you with an updated version of the Document.
-
- <li>MODIFICATIONS
-
- <p>You may copy and distribute a Modified Version of the Document under
-the conditions of sections 2 and 3 above, provided that you release
-the Modified Version under precisely this License, with the Modified
-Version filling the role of the Document, thus licensing distribution
-and modification of the Modified Version to whoever possesses a copy
-of it. In addition, you must do these things in the Modified Version:
-
- <ol type=A start=1>
-<li>Use in the Title Page (and on the covers, if any) a title distinct
-from that of the Document, and from those of previous versions
-(which should, if there were any, be listed in the History section
-of the Document). You may use the same title as a previous version
-if the original publisher of that version gives permission.
-
- <li>List on the Title Page, as authors, one or more persons or
entities
-responsible for authorship of the modifications in the Modified
-Version, together with at least five of the principal authors of the
-Document (all of its principal authors, if it has fewer than five),
-unless they release you from this requirement.
-
- <li>State on the Title page the name of the publisher of the
-Modified Version, as the publisher.
-
- <li>Preserve all the copyright notices of the Document.
-
- <li>Add an appropriate copyright notice for your modifications
-adjacent to the other copyright notices.
-
- <li>Include, immediately after the copyright notices, a license
notice
-giving the public permission to use the Modified Version under the
-terms of this License, in the form shown in the Addendum below.
-
- <li>Preserve in that license notice the full lists of Invariant
Sections
-and required Cover Texts given in the Document's license notice.
-
- <li>Include an unaltered copy of this License.
-
- <li>Preserve the section Entitled “History”, Preserve
its Title, and add
-to it an item stating at least the title, year, new authors, and
-publisher of the Modified Version as given on the Title Page. If
-there is no section Entitled “History” in the Document, create one
-stating the title, year, authors, and publisher of the Document as
-given on its Title Page, then add an item describing the Modified
-Version as stated in the previous sentence.
-
- <li>Preserve the network location, if any, given in the Document for
-public access to a Transparent copy of the Document, and likewise
-the network locations given in the Document for previous versions
-it was based on. These may be placed in the “History” section.
-You may omit a network location for a work that was published at
-least four years before the Document itself, or if the original
-publisher of the version it refers to gives permission.
-
- <li>For any section Entitled “Acknowledgements” or
“Dedications”, Preserve
-the Title of the section, and preserve in the section all the
-substance and tone of each of the contributor acknowledgements and/or
-dedications given therein.
-
- <li>Preserve all the Invariant Sections of the Document,
-unaltered in their text and in their titles. Section numbers
-or the equivalent are not considered part of the section titles.
-
- <li>Delete any section Entitled “Endorsements”. Such a
section
-may not be included in the Modified Version.
-
- <li>Do not retitle any existing section to be Entitled
“Endorsements” or
-to conflict in title with any Invariant Section.
-
- <li>Preserve any Warranty Disclaimers.
- </ol>
-
- <p>If the Modified Version includes new front-matter sections or
-appendices that qualify as Secondary Sections and contain no material
-copied from the Document, you may at your option designate some or all
-of these sections as invariant. To do this, add their titles to the
-list of Invariant Sections in the Modified Version's license notice.
-These titles must be distinct from any other section titles.
-
- <p>You may add a section Entitled “Endorsements”, provided it
contains
-nothing but endorsements of your Modified Version by various
-parties—for example, statements of peer review or that the text has
-been approved by an organization as the authoritative definition of a
-standard.
-
- <p>You may add a passage of up to five words as a Front-Cover Text, and a
-passage of up to 25 words as a Back-Cover Text, to the end of the list
-of Cover Texts in the Modified Version. Only one passage of
-Front-Cover Text and one of Back-Cover Text may be added by (or
-through arrangements made by) any one entity. If the Document already
-includes a cover text for the same cover, previously added by you or
-by arrangement made by the same entity you are acting on behalf of,
-you may not add another; but you may replace the old one, on explicit
-permission from the previous publisher that added the old one.
-
- <p>The author(s) and publisher(s) of the Document do not by this License
-give permission to use their names for publicity for or to assert or
-imply endorsement of any Modified Version.
-
- <li>COMBINING DOCUMENTS
-
- <p>You may combine the Document with other documents released under this
-License, under the terms defined in section 4 above for modified
-versions, provided that you include in the combination all of the
-Invariant Sections of all of the original documents, unmodified, and
-list them all as Invariant Sections of your combined work in its
-license notice, and that you preserve all their Warranty Disclaimers.
-
- <p>The combined work need only contain one copy of this License, and
-multiple identical Invariant Sections may be replaced with a single
-copy. If there are multiple Invariant Sections with the same name but
-different contents, make the title of each such section unique by
-adding at the end of it, in parentheses, the name of the original
-author or publisher of that section if known, or else a unique number.
-Make the same adjustment to the section titles in the list of
-Invariant Sections in the license notice of the combined work.
-
- <p>In the combination, you must combine any sections Entitled
“History”
-in the various original documents, forming one section Entitled
-“History”; likewise combine any sections Entitled
“Acknowledgements”,
-and any sections Entitled “Dedications”. You must delete all
-sections Entitled “Endorsements.”
-
- <li>COLLECTIONS OF DOCUMENTS
-
- <p>You may make a collection consisting of the Document and other
documents
-released under this License, and replace the individual copies of this
-License in the various documents with a single copy that is included in
-the collection, provided that you follow the rules of this License for
-verbatim copying of each of the documents in all other respects.
-
- <p>You may extract a single document from such a collection, and
distribute
-it individually under this License, provided you insert a copy of this
-License into the extracted document, and follow this License in all
-other respects regarding verbatim copying of that document.
-
- <li>AGGREGATION WITH INDEPENDENT WORKS
-
- <p>A compilation of the Document or its derivatives with other separate
-and independent documents or works, in or on a volume of a storage or
-distribution medium, is called an “aggregate” if the copyright
-resulting from the compilation is not used to limit the legal rights
-of the compilation's users beyond what the individual works permit.
-When the Document is included an aggregate, this License does not
-apply to the other works in the aggregate which are not themselves
-derivative works of the Document.
-
- <p>If the Cover Text requirement of section 3 is applicable to these
-copies of the Document, then if the Document is less than one half of
-the entire aggregate, the Document's Cover Texts may be placed on
-covers that bracket the Document within the aggregate, or the
-electronic equivalent of covers if the Document is in electronic form.
-Otherwise they must appear on printed covers that bracket the whole
-aggregate.
-
- <li>TRANSLATION
-
- <p>Translation is considered a kind of modification, so you may
-distribute translations of the Document under the terms of section 4.
-Replacing Invariant Sections with translations requires special
-permission from their copyright holders, but you may include
-translations of some or all Invariant Sections in addition to the
-original versions of these Invariant Sections. You may include a
-translation of this License, and all the license notices in the
-Document, and any Warrany Disclaimers, provided that you also include
-the original English version of this License and the original versions
-of those notices and disclaimers. In case of a disagreement between
-the translation and the original version of this License or a notice
-or disclaimer, the original version will prevail.
-
- <p>If a section in the Document is Entitled
“Acknowledgements”,
-“Dedications”, or “History”, the requirement (section
4) to Preserve
-its Title (section 1) will typically require changing the actual
-title.
-
- <li>TERMINATION
-
- <p>You may not copy, modify, sublicense, or distribute the Document except
-as expressly provided for under this License. Any other attempt to
-copy, modify, sublicense or distribute the Document is void, and will
-automatically terminate your rights under this License. However,
-parties who have received copies, or rights, from you under this
-License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- <li>FUTURE REVISIONS OF THIS LICENSE
-
- <p>The Free Software Foundation may publish new, revised versions
-of the GNU Free Documentation License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns. See
-<a href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
-
- <p>Each version of the License is given a distinguishing version number.
-If the Document specifies that a particular numbered version of this
-License “or any later version” applies to it, you have the option
of
-following the terms and conditions either of that specified version or
-of any later version that has been published (not as a draft) by the
-Free Software Foundation. If the Document does not specify a version
-number of this License, you may choose any version ever published (not
-as a draft) by the Free Software Foundation.
- </ol>
-
-<!-- fakenode - for prepinfo -->
-<h3 class="unnumberedsec">ADDENDUM: How to use this License for your
documents</h3>
-
-<p>To use this License in a document you have written, include a copy of
-the License in the document and put the following copyright and
-license notices just after the title page:
-
-<pre class="smallexample"> Copyright (C) <var>year</var> <var>your
name</var>.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.2
- or any later version published by the Free Software Foundation;
- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
- A copy of the license is included in the section entitled ``GNU
- Free Documentation License''.
-</pre>
- <p>If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
-replace the “with...Texts.” line with this:
-
-<pre class="smallexample"> with the Invariant Sections being <var>list
their titles</var>, with
- the Front-Cover Texts being <var>list</var>, and with the Back-Cover
Texts
- being <var>list</var>.
-</pre>
- <p>If you have Invariant Sections without Cover Texts, or some other
-combination of the three, merge those two alternatives to suit the
-situation.
-
- <p>If your document contains nontrivial examples of program code, we
-recommend releasing these examples in parallel under your choice of
-free software license, such as the GNU General Public License,
-to permit their use in free software.
-
-<!-- Local Variables: -->
-<!-- ispell-local-pdict: "ispell-dict" -->
-<!-- End: -->
-</body></html>
-
Index: manual/html_node/GNU-Regexp-Operators.html
===================================================================
RCS file: manual/html_node/GNU-Regexp-Operators.html
diff -N manual/html_node/GNU-Regexp-Operators.html
--- manual/html_node/GNU-Regexp-Operators.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,163 +0,0 @@
-<html lang="en">
-<head>
-<title>GNU Regexp Operators - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Character-Lists.html#Character-Lists" title="Character
Lists">
-<link rel="next" href="Case_002dsensitivity.html#Case_002dsensitivity"
title="Case-sensitivity">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="GNU-Regexp-Operators"></a>Next: <a rel="next" accesskey="n"
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>,
-Previous: <a rel="previous" accesskey="p"
href="Character-Lists.html#Character-Lists">Character Lists</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.5 <samp><span
class="command">gawk</span></samp>-Specific Regexp Operators</h3>
-
-<!-- This section adapted (long ago) from the regex-0.12 manual -->
-<!-- STARTOFRANGE regexpg -->
-<p><a
name="index-regular-expressions_002c-operators_002c-_0040command_007bgawk_007d-280"></a><!--
STARTOFRANGE gregexp -->
-<a
name="index-_0040command_007bgawk_007d_002c-regular-expressions_002c-operators-281"></a><a
name="index-operators_002c-GNU_002dspecific-282"></a><a
name="index-regular-expressions_002c-operators_002c-for-words-283"></a><a
name="index-word_002c-regexp-definition-of-284"></a>GNU software that deals
with regular expressions provides a number of
-additional regexp operators. These operators are described in this
-section and are specific to <samp><span class="command">gawk</span></samp>;
-they are not available in other <samp><span class="command">awk</span></samp>
implementations.
-Most of the additional operators deal with word matching.
-For our purposes, a <dfn>word</dfn> is a sequence of one or more letters,
digits,
-or underscores (`<samp><span class="samp">_</span></samp>'):
-
- <dl>
-<!-- @cindex operators, @code{\w} (@command{gawk}) -->
-<a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-285"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-286"></a><dt><code>\w</code><dd>Matches
any word-constituent character—that is, it matches any
-letter, digit, or underscore. Think of it as shorthand for
-<code>[[:alnum:]_]</code><!-- /@w -->.
-
- <!-- @cindex operators, @code{\W} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-287"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-288"></a><br><dt><code>\W</code><dd>Matches
any character that is not word-constituent.
-Think of it as shorthand for
-<code>[^[:alnum:]_]</code><!-- /@w -->.
-
- <!-- @cindex operators, @code{\<} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-289"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-290"></a><br><dt><code>\<</code><dd>Matches
the empty string at the beginning of a word.
-For example, <code>/\<away/</code> matches `<samp><span
class="samp">away</span></samp>' but not
-`<samp><span class="samp">stowaway</span></samp>'.
-
- <!-- @cindex operators, @code{\>} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-291"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-292"></a><br><dt><code>\></code><dd>Matches
the empty string at the end of a word.
-For example, <code>/stow\>/</code> matches `<samp><span
class="samp">stow</span></samp>' but not `<samp><span
class="samp">stowaway</span></samp>'.
-
- <!-- @cindex operators, @code{\y} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-293"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-294"></a><a
name="index-word-boundaries_0040comma_007b_007d-matching-295"></a><br><dt><code>\y</code><dd>Matches
the empty string at either the beginning or the
-end of a word (i.e., the word boundar<strong>y</strong>). For example,
`<samp><span class="samp">\yballs?\y</span></samp>'
-matches either `<samp><span class="samp">ball</span></samp>' or `<samp><span
class="samp">balls</span></samp>', as a separate word.
-
- <!-- @cindex operators, @code{\B} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-296"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-297"></a><br><dt><code>\B</code><dd>Matches
the empty string that occurs between two
-word-constituent characters. For example,
-<code>/\Brat\B/</code> matches `<samp><span class="samp">crate</span></samp>'
but it does not match `<samp><span class="samp">dirty rat</span></samp>'.
-`<samp><span class="samp">\B</span></samp>' is essentially the opposite of
`<samp><span class="samp">\y</span></samp>'.
-</dl>
-
- <p><a name="index-buffers_002c-operators-for-298"></a><a
name="index-regular-expressions_002c-operators_002c-for-buffers-299"></a><a
name="index-operators_002c-string_002dmatching_002c-for-buffers-300"></a>There
are two other operators that work on buffers. In Emacs, a
-<dfn>buffer</dfn> is, naturally, an Emacs buffer. For other programs,
-<samp><span class="command">gawk</span></samp>'s regexp library routines
consider the entire
-string to match as the buffer.
-The operators are:
-
- <dl>
-<dt><code>\`</code><dd><!-- @cindex operators, @code{\`} (@command{gawk}) -->
-<a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-301"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-302"></a>Matches
the empty string at the
-beginning of a buffer (string).
-
- <!-- @cindex operators, @code{\'} (@command{gawk}) -->
-<p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-303"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-304"></a><br><dt><code>\'</code><dd>Matches
the empty string at the
-end of a buffer (string).
-</dl>
-
- <p><a name="index-_0040code_007b_005e_007d-_0028caret_0029-305"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029-306"></a><a
name="index-_0040code_007b_003f_007d-_0028question-mark_0029-307"></a><a
name="index-question-mark-_0028_0040code_007b_003f_007d_0029-308"></a>Because
`<samp><span class="samp">^</span></samp>' and `<samp><span
class="samp">$</span></samp>' always work in terms of the beginning
-and end of strings, these operators don't add any new capabilities
-for <samp><span class="command">awk</span></samp>. They are provided for
compatibility with other
-GNU software.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-word_002dboundary-operator-309"></a><a
name="index-word_002dboundary-operator-_0028_0040command_007bgawk_007d_0029-310"></a><a
name="index-operators_002c-word_002dboundary-_0028_0040command_007bgawk_007d_0029-311"></a>In
other GNU software, the word-boundary operator is `<samp><span
class="samp">\b</span></samp>'. However,
-that conflicts with the <samp><span class="command">awk</span></samp>
language's definition of `<samp><span class="samp">\b</span></samp>'
-as backspace, so <samp><span class="command">gawk</span></samp> uses a
different letter.
-An alternative method would have been to require two backslashes in the
-GNU operators, but this was deemed too confusing. The current
-method of using `<samp><span class="samp">\y</span></samp>' for the GNU
`<samp><span class="samp">\b</span></samp>' appears to be the
-lesser of two evils.
-
-<!-- NOTE!!! Keep this in sync with the same table in the summary appendix! -->
-<!-- Should really do this with file inclusion. -->
-<p><a
name="index-regular-expressions_002c-_0040command_007bgawk_007d_002c-command_002dline-options-312"></a><a
name="index-_0040command_007bgawk_007d_002c-command_002dline-options-313"></a>The
various command-line options
-(see <a href="Options.html#Options">Options</a>)
-control how <samp><span class="command">gawk</span></samp> interprets
characters in regexps:
-
- <dl>
-<dt>No options<dd>In the default case, <samp><span
class="command">gawk</span></samp> provides all the facilities of
-POSIX regexps and the
-previously described
-GNU regexp operators.
-GNU regexp operators described
-in <a href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>.
-However, interval expressions are not supported.
-
- <br><dt><code>--posix</code><dd>Only POSIX regexps are supported; the GNU
operators are not special
-(e.g., `<samp><span class="samp">\w</span></samp>' matches a literal
`<samp><span class="samp">w</span></samp>'). Interval expressions
-are allowed.
-
- <br><dt><code>--traditional</code><dd>Traditional Unix <samp><span
class="command">awk</span></samp> regexps are matched. The GNU operators
-are not special, interval expressions are not available, nor
-are the POSIX character classes (<code>[[:alnum:]]</code>, etc.).
-Characters described by octal and hexadecimal escape sequences are
-treated literally, even if they represent regexp metacharacters.
-
- <br><dt><code>--re-interval</code><dd>Allow interval expressions in
regexps, even if <samp><span class="option">--traditional</span></samp>
-has been provided. (<samp><span class="option">--posix</span></samp>
automatically enables
-interval expressions, so <samp><span
class="option">--re-interval</span></samp> is redundant
-when <samp><span class="option">--posix</span></samp> is is used.)
-</dl>
- <!-- ENDOFRANGE gregexp -->
-<!-- ENDOFRANGE regexpg -->
-
- </body></html>
-
Index: manual/html_node/Gawk-Distribution.html
===================================================================
RCS file: manual/html_node/Gawk-Distribution.html
diff -N manual/html_node/Gawk-Distribution.html
--- manual/html_node/Gawk-Distribution.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<html lang="en">
-<head>
-<title>Gawk Distribution - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Installation.html#Installation" title="Installation">
-<link rel="next" href="Unix-Installation.html#Unix-Installation" title="Unix
Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Gawk-Distribution"></a>Next: <a rel="next" accesskey="n"
href="Unix-Installation.html#Unix-Installation">Unix Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Installation.html#Installation">Installation</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">B.1 The <samp><span class="command">gawk</span></samp>
Distribution</h3>
-
-<p><a name="index-source-code_002c-_0040command_007bgawk_007d-1872"></a>
-This section describes how to get the <samp><span
class="command">gawk</span></samp>
-distribution, how to extract it, and then what is in the various files and
-subdirectories.
-
-<ul class="menu">
-<li><a accesskey="1" href="Getting.html#Getting">Getting</a>:
How to get the distribution.
-<li><a accesskey="2" href="Extracting.html#Extracting">Extracting</a>:
How to extract the distribution.
-<li><a accesskey="3"
href="Distribution-contents.html#Distribution-contents">Distribution
contents</a>: What is in the distribution.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Gawk-I18N.html
===================================================================
RCS file: manual/html_node/Gawk-I18N.html
diff -N manual/html_node/Gawk-I18N.html
--- manual/html_node/Gawk-I18N.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-<html lang="en">
-<head>
-<title>Gawk I18N - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="prev" href="I18N-Example.html#I18N-Example" title="I18N Example">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Gawk-I18N"></a>Previous: <a rel="previous" accesskey="p"
href="I18N-Example.html#I18N-Example">I18N Example</a>,
-Up: <a rel="up" accesskey="u"
href="Internationalization.html#Internationalization">Internationalization</a>
-<hr><br>
-</div>
-
-<h3 class="section">9.6 <samp><span class="command">gawk</span></samp> Can
Speak Your Language</h3>
-
-<p>As of version 3.1, <samp><span class="command">gawk</span></samp> itself
has been internationalized
-using the GNU <code>gettext</code> package.
-(GNU <code>gettext</code> is described in
-complete detail in
-<cite>GNU gettext tools</cite>.)
-As of this writing, the latest version of GNU <code>gettext</code> is
-<a href="ftp://ftp.gnu.org/gnu/gettext/gettext-0.11.5.tar.gz">version
0.11.5</a>.
-
- <p>If a translation of <samp><span class="command">gawk</span></samp>'s
messages exists,
-then <samp><span class="command">gawk</span></samp> produces usage messages,
warnings,
-and fatal errors in the local language.
-
- <p><a
name="index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1393"></a><a
name="index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1394"></a>On
systems that do not use version 2 (or later) of the GNU C library, you should
-configure <samp><span class="command">gawk</span></samp> with the <samp><span
class="option">--with-included-gettext</span></samp> option
-before compiling and installing it.
-See <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>,
-for more information.
-<!-- ENDOFRANGE inloc -->
-
- </body></html>
-
Index: manual/html_node/General-Functions.html
===================================================================
RCS file: manual/html_node/General-Functions.html
diff -N manual/html_node/General-Functions.html
--- manual/html_node/General-Functions.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,77 +0,0 @@
-<html lang="en">
-<head>
-<title>General Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Library-Functions.html#Library-Functions" title="Library
Functions">
-<link rel="prev" href="Library-Names.html#Library-Names" title="Library Names">
-<link rel="next" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="General-Functions"></a>Next: <a rel="next" accesskey="n"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>,
-Previous: <a rel="previous" accesskey="p"
href="Library-Names.html#Library-Names">Library Names</a>,
-Up: <a rel="up" accesskey="u"
href="Library-Functions.html#Library-Functions">Library Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">12.2 General Programming</h3>
-
-<p>This section presents a number of functions that are of general
-programming use.
-
-<ul class="menu">
-<li><a accesskey="1" href="Nextfile-Function.html#Nextfile-Function">Nextfile
Function</a>: Two implementations of a <code>nextfile</code>
- function.
-<li><a accesskey="2" href="Strtonum-Function.html#Strtonum-Function">Strtonum
Function</a>: A replacement for the built-in <code>strtonum</code>
- function.
-<li><a accesskey="3" href="Assert-Function.html#Assert-Function">Assert
Function</a>: A function for assertions in <samp><span
class="command">awk</span></samp>
- programs.
-<li><a accesskey="4" href="Round-Function.html#Round-Function">Round
Function</a>: A function for rounding if <code>sprintf</code> does
- not do it correctly.
-<li><a accesskey="5"
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a>: The Cliff Random Number Generator.
-<li><a accesskey="6" href="Ordinal-Functions.html#Ordinal-Functions">Ordinal
Functions</a>: Functions for using characters as numbers and
- vice versa.
-<li><a accesskey="7" href="Join-Function.html#Join-Function">Join
Function</a>: A function to join an array into a string.
-<li><a accesskey="8"
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a>: A function to get formatted times.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Getline-Notes.html
===================================================================
RCS file: manual/html_node/Getline-Notes.html
diff -N manual/html_node/Getline-Notes.html
--- manual/html_node/Getline-Notes.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline Notes - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev"
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess"
title="Getline/Variable/Coprocess">
-<link rel="next" href="Getline-Summary.html#Getline-Summary" title="Getline
Summary">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline-Notes"></a>Next: <a rel="next" accesskey="n"
href="Getline-Summary.html#Getline-Summary">Getline Summary</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.9 Points to Remember About <code>getline</code></h4>
-
-<p>Here are some miscellaneous points about <code>getline</code> that
-you should bear in mind:
-
- <ul>
-<li>When <code>getline</code> changes the value of <code>$0</code> and
<code>NF</code>,
-<samp><span class="command">awk</span></samp> does <em>not</em> automatically
jump to the start of the
-program and start testing the new record against every pattern.
-However, the new record is tested against any subsequent rules.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-488"></a><a
name="index-implementation-issues_002c-_0040command_007bgawk_007d_002c-limits-489"></a><a
name="index-_0040command_007bawk_007d_002c-implementations_002c-limits-490"></a><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-limits-491"></a><li>Many
<samp><span class="command">awk</span></samp> implementations limit the number
of pipelines that an <samp><span class="command">awk</span></samp>
-program may have open to just one. In <samp><span
class="command">gawk</span></samp>, there is no such limit.
-You can open as many pipelines (and coprocesses) as the underlying operating
-system permits.
-
- <p><a
name="index-side-effects_002c-_0040code_007bFILENAME_007d-variable-492"></a><a
name="index-_0040code_007bFILENAME_007d-variable_002c-_0040code_007bgetline_007d_0040comma_007b_007d-setting-with-493"></a><a
name="index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-494"></a><a
name="index-_0040code_007bgetline_007d-command_002c-_0040code_007bFILENAME_007d-variable-and-495"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bgetline_007d-and-496"></a><li>An
interesting side effect occurs if you use <code>getline</code> without a
-redirection inside a <code>BEGIN</code> rule. Because an unredirected
<code>getline</code>
-reads from the command-line data files, the first <code>getline</code> command
-causes <samp><span class="command">awk</span></samp> to set the value of
<code>FILENAME</code>. Normally,
-<code>FILENAME</code> does not have a value inside <code>BEGIN</code> rules,
because you
-have not yet started to process the command-line data files.
-(d.c.)
-(See <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>,
-also see <a href="Auto_002dset.html#Auto_002dset">Auto-set</a>.)
-
- <li>Using <code>FILENAME</code> with <code>getline</code>
-(`<samp><span class="samp">getline < FILENAME</span></samp>')
-is likely to be a source for
-confusion. <samp><span class="command">awk</span></samp> opens a separate
input stream from the
-current input file. However, by not using a variable, <code>$0</code>
-and <code>NR</code> are still updated. If you're doing this, it's
-probably by accident, and you should reconsider what it is you're
-trying to accomplish.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Getline-Summary.html
===================================================================
RCS file: manual/html_node/Getline-Summary.html
diff -N manual/html_node/Getline-Summary.html
--- manual/html_node/Getline-Summary.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,78 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline Summary - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev" href="Getline-Notes.html#Getline-Notes" title="Getline Notes">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline-Summary"></a>Previous: <a rel="previous" accesskey="p"
href="Getline-Notes.html#Getline-Notes">Getline Notes</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.10 Summary of <code>getline</code> Variants</h4>
-
-<p><a name="index-_0040code_007bgetline_007d-command_002c-variants-497"></a>
-<a
href="table_002dgetline_002dvariants.html#table_002dgetline_002dvariants">table-getline-variants</a>
-summarizes the eight variants of <code>getline</code>,
-listing which built-in variables are set by each one.
-
- <div class="float">
-<a name="table_002dgetline_002dvariants"></a>
- <p><table summary=""><tr align="left"><th valign="top" width="35%">Variant
</th><th valign="top" width="65%">Effect
-<br></th></tr><tr align="left"><td valign="top"
width="35%"><code>getline</code> </td><td valign="top" width="65%">Sets
<code>$0</code>, <code>NF</code>, <code>FNR</code>, and <code>NR</code>
-<br></td></tr><tr align="left"><td valign="top"
width="35%"><code>getline</code> <var>var</var> </td><td valign="top"
width="65%">Sets <var>var</var>, <code>FNR</code>, and <code>NR</code>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><code>getline
<</code> <var>file</var> </td><td valign="top" width="65%">Sets
<code>$0</code> and <code>NF</code>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><code>getline
</code><var>var</var><code> < </code><var>file</var> </td><td valign="top"
width="65%">Sets <var>var</var>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>| getline</code> </td><td valign="top" width="65%">Sets <code>$0</code>
and <code>NF</code>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>| getline</code> <var>var</var> </td><td valign="top" width="65%">Sets
<var>var</var>
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>|& getline</code> </td><td valign="top" width="65%">Sets
<code>$0</code> and <code>NF</code>. This is a <samp><span
class="command">gawk</span></samp> extension
-<br></td></tr><tr align="left"><td valign="top" width="35%"><var>command</var>
<code>|& getline</code> <var>var</var> </td><td valign="top"
width="65%">Sets <var>var</var>. This is a <samp><span
class="command">gawk</span></samp> extension
- <br></td></tr></table>
-<p><strong class="float-caption">Table 3.1: getline Variants and What They
Set</strong></p></div>
-<!-- ENDOFRANGE getl -->
-<!-- ENDOFRANGE inex -->
-<!-- ENDOFRANGE infir -->
-
- </body></html>
-
Index: manual/html_node/Getline.html
===================================================================
RCS file: manual/html_node/Getline.html
diff -N manual/html_node/Getline.html
--- manual/html_node/Getline.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Multiple-Line.html#Multiple-Line" title="Multiple Line">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline"></a>Previous: <a rel="previous" accesskey="p"
href="Multiple-Line.html#Multiple-Line">Multiple Line</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.8 Explicit Input with <code>getline</code></h3>
-
-<!-- STARTOFRANGE getl -->
-<p><a
name="index-_0040code_007bgetline_007d-command_002c-explicit-input-with-456"></a><a
name="index-input_002c-explicit-457"></a>So far we have been getting our input
data from <samp><span class="command">awk</span></samp>'s main
-input stream—either the standard input (usually your terminal, sometimes
-the output from another program) or from the
-files specified on the command line. The <samp><span
class="command">awk</span></samp> language has a
-special built-in command called <code>getline</code> that
-can be used to read input under your explicit control.
-
- <p>The <code>getline</code> command is used in several different ways and
should
-<em>not</em> be used by beginners.
-The examples that follow the explanation of the <code>getline</code> command
-include material that has not been covered yet. Therefore, come back
-and study the <code>getline</code> command <em>after</em> you have reviewed the
-rest of this Web page and have a good knowledge of how <samp><span
class="command">awk</span></samp> works.
-
- <p><a name="index-_0040code_007bERRNO_007d-variable-458"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bgetline_007d-command-459"></a><a
name="index-_0040code_007bgetline_007d-command_002c-return-values-460"></a>The
<code>getline</code> command returns one if it finds a record and zero if
-it encounters the end of the file. If there is some error in getting
-a record, such as a file that cannot be opened, then <code>getline</code>
-returns −1. In this case, <samp><span
class="command">gawk</span></samp> sets the variable
-<code>ERRNO</code> to a string describing the error that occurred.
-
- <p>In the following examples, <var>command</var> stands for a string value
that
-represents a shell command.
-
-<ul class="menu">
-<li><a accesskey="1" href="Plain-Getline.html#Plain-Getline">Plain
Getline</a>: Using <code>getline</code> with no arguments.
-<li><a accesskey="2"
href="Getline_002fVariable.html#Getline_002fVariable">Getline/Variable</a>:
Using <code>getline</code> into a variable.
-<li><a accesskey="3"
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a>:
Using <code>getline</code> from a file.
-<li><a accesskey="4"
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">Getline/Variable/File</a>:
Using <code>getline</code> into a variable from a
- file.
-<li><a accesskey="5"
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a>:
Using <code>getline</code> from a pipe.
-<li><a accesskey="6"
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>:
Using <code>getline</code> into a variable from a
- pipe.
-<li><a accesskey="7"
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a>:
Using <code>getline</code> from a coprocess.
-<li><a accesskey="8"
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>:
Using <code>getline</code> into a variable from a
- coprocess.
-<li><a accesskey="9" href="Getline-Notes.html#Getline-Notes">Getline
Notes</a>: Important things to know about <code>getline</code>.
-<li><a href="Getline-Summary.html#Getline-Summary">Getline Summary</a>:
Summary of <code>getline</code> Variants.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Getline_002fCoprocess.html
===================================================================
RCS file: manual/html_node/Getline_002fCoprocess.html
diff -N manual/html_node/Getline_002fCoprocess.html
--- manual/html_node/Getline_002fCoprocess.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/Coprocess - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev"
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe"
title="Getline/Variable/Pipe">
-<link rel="next"
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess"
title="Getline/Variable/Coprocess">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fCoprocess"></a>Next: <a rel="next" accesskey="n"
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.7 Using <code>getline</code> from a Coprocess</h4>
-
-<p><a name="index-coprocesses_002c-_0040code_007bgetline_007d-from-481"></a><a
name="index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-482"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-483"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-484"></a><a
name="index-operators_002c-input_002foutput-485"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-486"></a>
-Input into <code>getline</code> from a pipe is a one-way operation.
-The command that is started with `<samp><var>command</var><span class="samp">
| getline</span></samp>' only
-sends data <em>to</em> your <samp><span class="command">awk</span></samp>
program.
-
- <p>On occasion, you might want to send data to another program
-for processing and then read the results back.
-<samp><span class="command">gawk</span></samp> allows you start a
<dfn>coprocess</dfn>, with which two-way
-communications are possible. This is done with the `<samp><span
class="samp">|&</span></samp>'
-operator.
-Typically, you write data to the coprocess first and then
-read results back, as shown in the following:
-
-<pre class="example"> print "<var>some query</var>" |& "db_server"
- "db_server" |& getline
-</pre>
- <p class="noindent">which sends a query to <samp><span
class="command">db_server</span></samp> and then reads the results.
-
- <p>The values of <code>NR</code> and
-<code>FNR</code> are not changed,
-because the main input stream is not used.
-However, the record is split into fields in
-the normal manner, thus changing the values of <code>$0</code>, of the other
fields,
-and of <code>NF</code>.
-
- <p>Coprocesses are an advanced feature. They are discussed here only because
-this is the section on <code>getline</code>.
-See <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>,
-where coprocesses are discussed in more detail.
-
- </body></html>
-
Index: manual/html_node/Getline_002fFile.html
===================================================================
RCS file: manual/html_node/Getline_002fFile.html
diff -N manual/html_node/Getline_002fFile.html
--- manual/html_node/Getline_002fFile.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/File - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev" href="Getline_002fVariable.html#Getline_002fVariable"
title="Getline/Variable">
-<link rel="next"
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile"
title="Getline/Variable/File">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fFile"></a>Next: <a rel="next" accesskey="n"
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">Getline/Variable/File</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fVariable.html#Getline_002fVariable">Getline/Variable</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.3 Using <code>getline</code> from a File</h4>
-
-<p><a name="index-input-redirection-462"></a><a
name="index-redirection-of-input-463"></a><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-464"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-465"></a><a
name="index-operators_002c-input_002foutput-466"></a>Use `<samp><span
class="samp">getline < </span><var>file</var></samp>' to read the next
record from <var>file</var>.
-Here <var>file</var> is a string-valued expression that
-specifies the file name. `<samp><span class="samp"><
</span><var>file</var></samp>' is called a <dfn>redirection</dfn>
-because it directs input to come from a different place.
-For example, the following
-program reads its input record from the file <samp><span
class="file">secondary.input</span></samp> when it
-encounters a first field with a value equal to 10 in the current input
-file:
-
-<pre class="example"> {
- if ($1 == 10) {
- getline < "secondary.input"
- print
- } else
- print
- }
-</pre>
- <p>Because the main input stream is not used, the values of <code>NR</code>
and
-<code>FNR</code> are not changed. However, the record it reads is split into
fields in
-the normal manner, so the values of <code>$0</code> and the other fields are
-changed, resulting in a new value of <code>NF</code>.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_003c_007d-operator-and-467"></a><!--
Thanks to Paul Eggert for initial wording here -->
-According to POSIX, `<samp><span class="samp">getline <
</span><var>expression</var></samp>' is ambiguous if
-<var>expression</var> contains unparenthesized operators other than
-`<samp><span class="samp">$</span></samp>'; for example, `<samp><span
class="samp">getline < dir "/" file</span></samp>' is ambiguous
-because the concatenation operator is not parenthesized. You should
-write it as `<samp><span class="samp">getline < (dir "/"
file)</span></samp>' if you want your program
-to be portable to other <samp><span class="command">awk</span></samp>
implementations.
-
- </body></html>
-
Index: manual/html_node/Getline_002fPipe.html
===================================================================
RCS file: manual/html_node/Getline_002fPipe.html
diff -N manual/html_node/Getline_002fPipe.html
--- manual/html_node/Getline_002fPipe.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,118 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/Pipe - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev"
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile"
title="Getline/Variable/File">
-<link rel="next"
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe"
title="Getline/Variable/Pipe">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fPipe"></a>Next: <a rel="next" accesskey="n"
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">Getline/Variable/File</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.5 Using <code>getline</code> from a Pipe</h4>
-
-<p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-470"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-471"></a><a
name="index-input-pipeline-472"></a><a
name="index-pipes_002c-input-473"></a><a
name="index-operators_002c-input_002foutput-474"></a>The output of a command
can also be piped into <code>getline</code>, using
-`<samp><var>command</var><span class="samp"> | getline</span></samp>'. In
-this case, the string <var>command</var> is run as a shell command and its
output
-is piped into <samp><span class="command">awk</span></samp> to be used as
input. This form of <code>getline</code>
-reads one record at a time from the pipe.
-For example, the following program copies its input to its output, except for
-lines that begin with `<samp><span class="samp">@execute</span></samp>', which
are replaced by the output
-produced by running the rest of the line as a shell command:
-
-<pre class="example"> {
- if ($1 == "@execute") {
- tmp = substr($0, 10)
- while ((tmp | getline) > 0)
- print
- close(tmp)
- } else
- print
- }
-</pre>
- <p class="noindent"><a
name="index-_0040code_007bclose_007d-function-475"></a>The <code>close</code>
function is called to ensure that if two identical
-`<samp><span class="samp">@execute</span></samp>' lines appear in the input,
the command is run for
-each one.
-See <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>.
-<!-- Exercise!! -->
-<!-- This example is unrealistic, since you could just use system -->
-Given the input:
-
-<pre class="example"> foo
- bar
- baz
- @execute who
- bletch
-</pre>
- <p class="noindent">the program might produce:
-
- <p><a name="index-Robbins_002c-Bill-476"></a><a
name="index-Robbins_002c-Miriam-477"></a><a
name="index-Robbins_002c-Arnold-478"></a>
-<pre class="example"> foo
- bar
- baz
- arnold ttyv0 Jul 13 14:22
- miriam ttyp0 Jul 13 14:23 (murphy:0)
- bill ttyp1 Jul 13 14:23 (murphy:0)
- bletch
-</pre>
- <p class="noindent">Notice that this program ran the command <samp><span
class="command">who</span></samp> and printed the previous result.
-(If you try this program yourself, you will of course get different results,
-depending upon who is logged in on your system.)
-
- <p>This variation of <code>getline</code> splits the record into fields,
sets the
-value of <code>NF</code>, and recomputes the value of <code>$0</code>. The
values of
-<code>NR</code> and <code>FNR</code> are not changed.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_007c_007d-I_002fO-operator-and-479"></a><!--
Thanks to Paul Eggert for initial wording here -->
-According to POSIX, `<samp><var>expression</var><span class="samp"> |
getline</span></samp>' is ambiguous if
-<var>expression</var> contains unparenthesized operators other than
-`<samp><span class="samp">$</span></samp>'—for example, `<samp><span
class="samp">"echo "<!-- /@w --> "date" | getline</span></samp>' is
ambiguous
-because the concatenation operator is not parenthesized. You should
-write it as `<samp><span class="samp">("echo "<!-- /@w --> "date") |
getline</span></samp>' if you want your program
-to be portable to other <samp><span class="command">awk</span></samp>
implementations.
-
- </body></html>
-
Index: manual/html_node/Getline_002fVariable.html
===================================================================
RCS file: manual/html_node/Getline_002fVariable.html
diff -N manual/html_node/Getline_002fVariable.html
--- manual/html_node/Getline_002fVariable.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/Variable - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev" href="Plain-Getline.html#Plain-Getline" title="Plain Getline">
-<link rel="next" href="Getline_002fFile.html#Getline_002fFile"
title="Getline/File">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fVariable"></a>Next: <a rel="next" accesskey="n"
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a>,
-Previous: <a rel="previous" accesskey="p"
href="Plain-Getline.html#Plain-Getline">Plain Getline</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.2 Using <code>getline</code> into a Variable</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-461"></a>
-You can use `<samp><span class="samp">getline </span><var>var</var></samp>' to
read the next record from
-<samp><span class="command">awk</span></samp>'s input into the variable
<var>var</var>. No other processing is
-done.
-For example, suppose the next line is a comment or a special string,
-and you want to read it without triggering
-any rules. This form of <code>getline</code> allows you to read that line
-and store it in a variable so that the main
-read-a-line-and-check-each-rule loop of <samp><span
class="command">awk</span></samp> never sees it.
-The following example swaps every two lines of input:
-
-<pre class="example"> {
- if ((getline tmp) > 0) {
- print tmp
- print $0
- } else
- print $0
- }
-</pre>
- <p class="noindent">It takes the following list:
-
-<pre class="example"> wan
- tew
- free
- phore
-</pre>
- <p class="noindent">and produces these results:
-
-<pre class="example"> tew
- wan
- phore
- free
-</pre>
- <p>The <code>getline</code> command used in this way sets only the variables
-<code>NR</code> and <code>FNR</code> (and of course, <var>var</var>). The
record is not
-split into fields, so the values of the fields (including <code>$0</code>) and
-the value of <code>NF</code> do not change.
-
- </body></html>
-
Index: manual/html_node/Getline_002fVariable_002fCoprocess.html
===================================================================
RCS file: manual/html_node/Getline_002fVariable_002fCoprocess.html
diff -N manual/html_node/Getline_002fVariable_002fCoprocess.html
--- manual/html_node/Getline_002fVariable_002fCoprocess.html 31 Aug 2004
22:04:10 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/Variable/Coprocess - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev" href="Getline_002fCoprocess.html#Getline_002fCoprocess"
title="Getline/Coprocess">
-<link rel="next" href="Getline-Notes.html#Getline-Notes" title="Getline Notes">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fVariable_002fCoprocess"></a>Next: <a rel="next"
accesskey="n" href="Getline-Notes.html#Getline-Notes">Getline Notes</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.8 Using <code>getline</code> into a Variable from a
Coprocess</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-487"></a>
-When you use `<samp><var>command</var><span class="samp"> |& getline
</span><var>var</var></samp>', the output from
-the coprocess <var>command</var> is sent through a two-way pipe to
<code>getline</code>
-and into the variable <var>var</var>.
-
- <p>In this version of <code>getline</code>, none of the built-in variables
are
-changed and the record is not split into fields. The only variable
-changed is <var>var</var>.
-
- </body></html>
-
Index: manual/html_node/Getline_002fVariable_002fFile.html
===================================================================
RCS file: manual/html_node/Getline_002fVariable_002fFile.html
diff -N manual/html_node/Getline_002fVariable_002fFile.html
--- manual/html_node/Getline_002fVariable_002fFile.html 31 Aug 2004 22:04:10
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,97 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/Variable/File - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev" href="Getline_002fFile.html#Getline_002fFile"
title="Getline/File">
-<link rel="next" href="Getline_002fPipe.html#Getline_002fPipe"
title="Getline/Pipe">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fVariable_002fFile"></a>Next: <a rel="next"
accesskey="n" href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.4 Using <code>getline</code> into a Variable from a
File</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-468"></a>
-Use `<samp><span class="samp">getline </span><var>var</var><span class="samp">
< </span><var>file</var></samp>' to read input
-from the file
-<var>file</var>, and put it in the variable <var>var</var>. As above,
<var>file</var>
-is a string-valued expression that specifies the file from which to read.
-
- <p>In this version of <code>getline</code>, none of the built-in variables
are
-changed and the record is not split into fields. The only variable
-changed is <var>var</var>.
-For example, the following program copies all the input files to the
-output, except for records that say `<samp><span
class="samp">@include </span><var>filename</var></samp>'<!-- /@w -->.
-Such a record is replaced by the contents of the file
-<var>filename</var>:
-
-<pre class="example"> {
- if (NF == 2 && $1 == "@include") {
- while ((getline line < $2) > 0)
- print line
- close($2)
- } else
- print
- }
-</pre>
- <p>Note here how the name of the extra input file is not built into
-the program; it is taken directly from the data, specifically from the second
field on
-the `<samp><span class="samp">@include</span></samp>' line.
-
- <p><a name="index-_0040code_007bclose_007d-function-469"></a>The
<code>close</code> function is called to ensure that if two identical
-`<samp><span class="samp">@include</span></samp>' lines appear in the input,
the entire specified file is
-included twice.
-See <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>.
-
- <p>One deficiency of this program is that it does not process nested
-`<samp><span class="samp">@include</span></samp>' statements
-(i.e., `<samp><span class="samp">@include</span></samp>' statements in
included files)
-the way a true macro preprocessor would.
-See <a href="Igawk-Program.html#Igawk-Program">Igawk Program</a>, for a program
-that does handle nested `<samp><span class="samp">@include</span></samp>'
statements.
-
- </body></html>
-
Index: manual/html_node/Getline_002fVariable_002fPipe.html
===================================================================
RCS file: manual/html_node/Getline_002fVariable_002fPipe.html
diff -N manual/html_node/Getline_002fVariable_002fPipe.html
--- manual/html_node/Getline_002fVariable_002fPipe.html 31 Aug 2004 22:04:10
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-<html lang="en">
-<head>
-<title>Getline/Variable/Pipe - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="prev" href="Getline_002fPipe.html#Getline_002fPipe"
title="Getline/Pipe">
-<link rel="next" href="Getline_002fCoprocess.html#Getline_002fCoprocess"
title="Getline/Coprocess">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getline_002fVariable_002fPipe"></a>Next: <a rel="next"
accesskey="n"
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.6 Using <code>getline</code> into a Variable from a
Pipe</h4>
-
-<p><a
name="index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-480"></a>
-When you use `<samp><var>command</var><span class="samp"> | getline
</span><var>var</var></samp>', the
-output of <var>command</var> is sent through a pipe to
-<code>getline</code> and into the variable <var>var</var>. For example, the
-following program reads the current date and time into the variable
-<code>current_time</code>, using the <samp><span
class="command">date</span></samp> utility, and then
-prints it:
-
-<pre class="example"> BEGIN {
- "date" | getline current_time
- close("date")
- print "Report printed on " current_time
- }
-</pre>
- <p>In this version of <code>getline</code>, none of the built-in variables
are
-changed and the record is not split into fields.
-
- </body></html>
-
Index: manual/html_node/Getopt-Function.html
===================================================================
RCS file: manual/html_node/Getopt-Function.html
diff -N manual/html_node/Getopt-Function.html
--- manual/html_node/Getopt-Function.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,370 +0,0 @@
-<html lang="en">
-<head>
-<title>Getopt Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Library-Functions.html#Library-Functions" title="Library
Functions">
-<link rel="prev" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link rel="next" href="Passwd-Functions.html#Passwd-Functions" title="Passwd
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getopt-Function"></a>Next: <a rel="next" accesskey="n"
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>,
-Up: <a rel="up" accesskey="u"
href="Library-Functions.html#Library-Functions">Library Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">12.4 Processing Command-Line Options</h3>
-
-<!-- STARTOFRANGE libfclo -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-command_002dline-options-1681"></a><!--
STARTOFRANGE flibclo -->
-<a
name="index-functions_002c-library_002c-command_002dline-options-1682"></a><!--
STARTOFRANGE clop -->
-<a name="index-command_002dline-options_002c-processing-1683"></a><!--
STARTOFRANGE oclp -->
-<a name="index-options_002c-command_002dline_002c-processing-1684"></a><!--
STARTOFRANGE clibf -->
-<a name="index-functions_002c-library_002c-C-library-1685"></a><a
name="index-arguments_002c-processing-1686"></a>Most utilities on POSIX
compatible systems take options, or “switches,” on
-the command line that can be used to change the way a program behaves.
-<samp><span class="command">awk</span></samp> is an example of such a program
-(see <a href="Options.html#Options">Options</a>).
-Often, options take <dfn>arguments</dfn>; i.e., data that the program needs to
-correctly obey the command-line option. For example, <samp><span
class="command">awk</span></samp>'s
-<samp><span class="option">-F</span></samp> option requires a string to use as
the field separator.
-The first occurrence on the command line of either <samp><span
class="option">--</span></samp> or a
-string that does not begin with `<samp><span class="samp">-</span></samp>'
ends the options.
-
- <p><a
name="index-_0040code_007bgetopt_007d-function-_0028C-library_0029-1687"></a>Modern
Unix systems provide a C function named <code>getopt</code> for processing
-command-line arguments. The programmer provides a string describing the
-one-letter options. If an option requires an argument, it is followed in the
-string with a colon. <code>getopt</code> is also passed the
-count and values of the command-line arguments and is called in a loop.
-<code>getopt</code> processes the command-line arguments for option letters.
-Each time around the loop, it returns a single character representing the
-next option letter that it finds, or `<samp><span
class="samp">?</span></samp>' if it finds an invalid option.
-When it returns −1, there are no options left on the command line.
-
- <p>When using <code>getopt</code>, options that do not take arguments can be
-grouped together. Furthermore, options that take arguments require that the
-argument is present. The argument can immediately follow the option letter,
-or it can be a separate command-line argument.
-
- <p>Given a hypothetical program that takes
-three command-line options, <samp><span class="option">-a</span></samp>,
<samp><span class="option">-b</span></samp>, and <samp><span
class="option">-c</span></samp>, where
-<samp><span class="option">-b</span></samp> requires an argument, all of the
following are valid ways of
-invoking the program:
-
-<pre class="example"> prog -a -b foo -c data1 data2 data3
- prog -ac -bfoo -- data1 data2 data3
- prog -acbfoo data1 data2 data3
-</pre>
- <p>Notice that when the argument is grouped with its option, the rest of
-the argument is considered to be the option's argument.
-In this example, <samp><span class="option">-acbfoo</span></samp> indicates
that all of the
-<samp><span class="option">-a</span></samp>, <samp><span
class="option">-b</span></samp>, and <samp><span
class="option">-c</span></samp> options were supplied,
-and that `<samp><span class="samp">foo</span></samp>' is the argument to the
<samp><span class="option">-b</span></samp> option.
-
- <p><code>getopt</code> provides four external variables that the programmer
can use:
-
- <dl>
-<dt><code>optind</code><dd>The index in the argument value array
(<code>argv</code>) where the first
-nonoption command-line argument can be found.
-
- <br><dt><code>optarg</code><dd>The string value of the argument to an
option.
-
- <br><dt><code>opterr</code><dd>Usually <code>getopt</code> prints an
error message when it finds an invalid
-option. Setting <code>opterr</code> to zero disables this feature. (An
-application might want to print its own error message.)
-
- <br><dt><code>optopt</code><dd>The letter representing the command-line
option.
-<!-- While not usually documented, most versions supply this variable. -->
-</dl>
-
- <p>The following C fragment shows how <code>getopt</code> might process
command-line
-arguments for <samp><span class="command">awk</span></samp>:
-
-<pre class="example"> int
- main(int argc, char *argv[])
- {
- ...
- /* print our own message */
- opterr = 0;
- while ((c = getopt(argc, argv, "v:f:F:W:")) != -1) {
- switch (c) {
- case 'f': /* file */
- ...
- break;
- case 'F': /* field separator */
- ...
- break;
- case 'v': /* variable assignment */
- ...
- break;
- case 'W': /* extension */
- ...
- break;
- case '?':
- default:
- usage();
- break;
- }
- }
- ...
- }
-</pre>
- <p>As a side point, <samp><span class="command">gawk</span></samp> actually
uses the GNU <code>getopt_long</code>
-function to process both normal and GNU-style long options
-(see <a href="Options.html#Options">Options</a>).
-
- <p>The abstraction provided by <code>getopt</code> is very useful and is
quite
-handy in <samp><span class="command">awk</span></samp> programs as well.
Following is an <samp><span class="command">awk</span></samp>
-version of <code>getopt</code>. This function highlights one of the
-greatest weaknesses in <samp><span class="command">awk</span></samp>, which is
that it is very poor at
-manipulating single characters. Repeated calls to <code>substr</code> are
-necessary for accessing individual characters
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).<a
rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p>The discussion that follows walks through the code a bit at a time:
-
- <p><a
name="index-_0040code_007bgetopt_007d-user_002ddefined-function-1688"></a>
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- # getopt.awk --- do C library getopt(3) function in awk
- <!-- endfile -->
- <!-- file eg/lib/getopt.awk -->
- # External variables:
- # Optind -- index in ARGV of first nonoption argument
- # Optarg -- string value of argument to current option
- # Opterr -- if nonzero, print our own diagnostic
- # Optopt -- current option letter
-
- # Returns:
- # -1 at end of options
- # ? for unrecognized option
- # <c> a character representing the current option
-
- # Private Data:
- # _opti -- index in multi-flag option, e.g., -abc
- <!-- endfile -->
-</pre>
- <p>The function starts out with
-a list of the global variables it uses,
-what the return values are, what they mean, and any global variables that
-are “private” to this library function. Such documentation is
essential
-for any program, and particularly for library functions.
-
- <p>The <code>getopt</code> function first checks that it was indeed called
with a string of options
-(the <code>options</code> parameter). If <code>options</code> has a zero
length,
-<code>getopt</code> immediately returns −1:
-
- <p><a
name="index-_0040code_007bgetopt_007d-user_002ddefined-function-1689"></a>
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- function getopt(argc, argv, options, thisopt, i)
- {
- if (length(options) == 0) # no options given
- return -1
-
- if (argv[Optind] == "--") { # all done
- Optind++
- _opti = 0
- return -1
- } else if (argv[Optind] !~ /^-[^: \t\n\f\r\v\b]/) {
- _opti = 0
- return -1
- }
- <!-- endfile -->
-</pre>
- <p>The next thing to check for is the end of the options. A <samp><span
class="option">--</span></samp>
-ends the command-line options, as does any command-line argument that
-does not begin with a `<samp><span class="samp">-</span></samp>'.
<code>Optind</code> is used to step through
-the array of command-line arguments; it retains its value across calls
-to <code>getopt</code>, because it is a global variable.
-
- <p>The regular expression that is used,
<code>/^-[^: \t\n\f\r\v\b]/<!-- /@w --></code>, is
-perhaps a bit of overkill; it checks for a `<samp><span
class="samp">-</span></samp>' followed by anything
-that is not whitespace and not a colon.
-If the current command-line argument does not match this pattern,
-it is not an option, and it ends option processing:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- if (_opti == 0)
- _opti = 2
- thisopt = substr(argv[Optind], _opti, 1)
- Optopt = thisopt
- i = index(options, thisopt)
- if (i == 0) {
- if (Opterr)
- printf("%c -- invalid option\n",
- thisopt) > "/dev/stderr"
- if (_opti >= length(argv[Optind])) {
- Optind++
- _opti = 0
- } else
- _opti++
- return "?"
- }
- <!-- endfile -->
-</pre>
- <p>The <code>_opti</code> variable tracks the position in the current
command-line
-argument (<code>argv[Optind]</code>). If multiple options are
-grouped together with one `<samp><span class="samp">-</span></samp>' (e.g.,
<samp><span class="option">-abx</span></samp>), it is necessary
-to return them to the user one at a time.
-
- <p>If <code>_opti</code> is equal to zero, it is set to two, which is the
index in
-the string of the next character to look at (we skip the `<samp><span
class="samp">-</span></samp>', which
-is at position one). The variable <code>thisopt</code> holds the character,
-obtained with <code>substr</code>. It is saved in <code>Optopt</code> for the
main
-program to use.
-
- <p>If <code>thisopt</code> is not in the <code>options</code> string, then
it is an
-invalid option. If <code>Opterr</code> is nonzero, <code>getopt</code> prints
an error
-message on the standard error that is similar to the message from the C
-version of <code>getopt</code>.
-
- <p>Because the option is invalid, it is necessary to skip it and move on to
the
-next option character. If <code>_opti</code> is greater than or equal to the
-length of the current command-line argument, it is necessary to move on
-to the next argument, so <code>Optind</code> is incremented and
<code>_opti</code> is reset
-to zero. Otherwise, <code>Optind</code> is left alone and <code>_opti</code>
is merely
-incremented.
-
- <p>In any case, because the option is invalid, <code>getopt</code> returns
`<samp><span class="samp">?</span></samp>'.
-The main program can examine <code>Optopt</code> if it needs to know what the
-invalid option letter actually is. Continuing on:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- if (substr(options, i + 1, 1) == ":") {
- # get option argument
- if (length(substr(argv[Optind], _opti + 1)) > 0)
- Optarg = substr(argv[Optind], _opti + 1)
- else
- Optarg = argv[++Optind]
- _opti = 0
- } else
- Optarg = ""
- <!-- endfile -->
-</pre>
- <p>If the option requires an argument, the option letter is followed by a
colon
-in the <code>options</code> string. If there are remaining characters in the
-current command-line argument (<code>argv[Optind]</code>), then the rest of
that
-string is assigned to <code>Optarg</code>. Otherwise, the next command-line
-argument is used (`<samp><span class="samp">-xFOO</span></samp>' versus
`<samp><span class="samp">-x FOO<!-- /@w --></span></samp>'). In either
case,
-<code>_opti</code> is reset to zero, because there are no more characters left
to
-examine in the current command-line argument. Continuing:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- if (_opti == 0 || _opti >= length(argv[Optind])) {
- Optind++
- _opti = 0
- } else
- _opti++
- return thisopt
- }
- <!-- endfile -->
-</pre>
- <p>Finally, if <code>_opti</code> is either zero or greater than the length
of the
-current command-line argument, it means this element in <code>argv</code> is
-through being processed, so <code>Optind</code> is incremented to point to the
-next element in <code>argv</code>. If neither condition is true, then only
-<code>_opti</code> is incremented, so that the next option letter can be
processed
-on the next call to <code>getopt</code>.
-
- <p>The <code>BEGIN</code> rule initializes both <code>Opterr</code> and
<code>Optind</code> to one.
-<code>Opterr</code> is set to one, since the default behavior is for
<code>getopt</code>
-to print a diagnostic message upon seeing an invalid option.
<code>Optind</code>
-is set to one, since there's no reason to look at the program name, which is
-in <code>ARGV[0]</code>:
-
-<pre class="example"> <!-- file eg/lib/getopt.awk -->
- BEGIN {
- Opterr = 1 # default is to diagnose
- Optind = 1 # skip ARGV[0]
-
- # test program
- if (_getopt_test) {
- while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1)
- printf("c = <%c>, optarg = <%s>\n",
- _go_c, Optarg)
- printf("non-option arguments:\n")
- for (; Optind < ARGC; Optind++)
- printf("\tARGV[%d] = <%s>\n",
- Optind, ARGV[Optind])
- }
- }
- <!-- endfile -->
-</pre>
- <p>The rest of the <code>BEGIN</code> rule is a simple test program. Here
is the
-result of two sample runs of the test program:
-
-<pre class="example"> $ awk -f getopt.awk -v _getopt_test=1 -- -a -cbARG
bax -x
- -| c = <a>, optarg = <>
- -| c = <c>, optarg = <>
- -| c = <b>, optarg = <ARG>
- -| non-option arguments:
- -| ARGV[3] = <bax>
- -| ARGV[4] = <-x>
-
- $ awk -f getopt.awk -v _getopt_test=1 -- -a -x -- xyz abc
- -| c = <a>, optarg = <>
- error--> x -- invalid option
- -| c = <?>, optarg = <>
- -| non-option arguments:
- -| ARGV[4] = <xyz>
- -| ARGV[5] = <abc>
-</pre>
- <p>In both runs,
-the first <samp><span class="option">--</span></samp> terminates the arguments
to <samp><span class="command">awk</span></samp>, so that it does
-not try to interpret the <samp><span class="option">-a</span></samp>, etc., as
its own options.
-Several of the sample programs presented in
-<a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-use <code>getopt</code> to process their arguments.
-<!-- ENDOFRANGE libfclo -->
-<!-- ENDOFRANGE flibclo -->
-<!-- ENDOFRANGE clop -->
-<!-- ENDOFRANGE oclp -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This
-function was written before <samp><span class="command">gawk</span></samp>
acquired the ability to
-split strings into single characters using <code>""</code> as the separator.
-We have left it alone, since using <code>substr</code> is more portable.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Gettimeofday-Function.html
===================================================================
RCS file: manual/html_node/Gettimeofday-Function.html
diff -N manual/html_node/Gettimeofday-Function.html
--- manual/html_node/Gettimeofday-Function.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,140 +0,0 @@
-<html lang="en">
-<head>
-<title>Gettimeofday Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Join-Function.html#Join-Function" title="Join Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Gettimeofday-Function"></a>Previous: <a rel="previous"
accesskey="p" href="Join-Function.html#Join-Function">Join Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.8 Managing the Time of Day</h4>
-
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-time-1658"></a><a
name="index-functions_002c-library_002c-managing-time-1659"></a><a
name="index-timestamps_002c-formatted-1660"></a><a
name="index-time_002c-managing-1661"></a>The <code>systime</code> and
<code>strftime</code> functions described in
-<a href="Time-Functions.html#Time-Functions">Time Functions</a>,
-provide the minimum functionality necessary for dealing with the time of day
-in human readable form. While <code>strftime</code> is extensive, the control
-formats are not necessarily easy to remember or intuitively obvious when
-reading a program.
-
- <p>The following function, <code>gettimeofday</code>, populates a
user-supplied array
-with preformatted time information. It returns a string with the current
-time formatted in the same way as the <samp><span
class="command">date</span></samp> utility:
-
- <p><a
name="index-_0040code_007bgettimeofday_007d-user_002ddefined-function-1662"></a>
-<pre class="example"> <!-- file eg/lib/gettime.awk -->
- # gettimeofday.awk --- get the time of day in a usable format
- <!-- endfile -->
- <!-- file eg/lib/gettime.awk -->
-
- # Returns a string in the format of output of date(1)
- # Populates the array argument time with individual values:
- # time["second"] -- seconds (0 - 59)
- # time["minute"] -- minutes (0 - 59)
- # time["hour"] -- hours (0 - 23)
- # time["althour"] -- hours (0 - 12)
- # time["monthday"] -- day of month (1 - 31)
- # time["month"] -- month of year (1 - 12)
- # time["monthname"] -- name of the month
- # time["shortmonth"] -- short name of the month
- # time["year"] -- year modulo 100 (0 - 99)
- # time["fullyear"] -- full year
- # time["weekday"] -- day of week (Sunday = 0)
- # time["altweekday"] -- day of week (Monday = 0)
- # time["dayname"] -- name of weekday
- # time["shortdayname"] -- short name of weekday
- # time["yearday"] -- day of year (0 - 365)
- # time["timezone"] -- abbreviation of timezone name
- # time["ampm"] -- AM or PM designation
- # time["weeknum"] -- week number, Sunday first day
- # time["altweeknum"] -- week number, Monday first day
-
- function gettimeofday(time, ret, now, i)
- {
- # get time once, avoids unnecessary system calls
- now = systime()
-
- # return date(1)-style output
- ret = strftime("%a %b %d %H:%M:%S %Z %Y", now)
-
- # clear out target array
- delete time
-
- # fill in values, force numeric values to be
- # numeric by adding 0
- time["second"] = strftime("%S", now) + 0
- time["minute"] = strftime("%M", now) + 0
- time["hour"] = strftime("%H", now) + 0
- time["althour"] = strftime("%I", now) + 0
- time["monthday"] = strftime("%d", now) + 0
- time["month"] = strftime("%m", now) + 0
- time["monthname"] = strftime("%B", now)
- time["shortmonth"] = strftime("%b", now)
- time["year"] = strftime("%y", now) + 0
- time["fullyear"] = strftime("%Y", now) + 0
- time["weekday"] = strftime("%w", now) + 0
- time["altweekday"] = strftime("%u", now) + 0
- time["dayname"] = strftime("%A", now)
- time["shortdayname"] = strftime("%a", now)
- time["yearday"] = strftime("%j", now) + 0
- time["timezone"] = strftime("%Z", now)
- time["ampm"] = strftime("%p", now)
- time["weeknum"] = strftime("%U", now) + 0
- time["altweeknum"] = strftime("%W", now) + 0
-
- return ret
- }
- <!-- endfile -->
-</pre>
- <p>The string indices are easier to use and read than the various formats
-required by <code>strftime</code>. The <code>alarm</code> program presented in
-<a href="Alarm-Program.html#Alarm-Program">Alarm Program</a>,
-uses this function.
-A more general design for the <code>gettimeofday</code> function would have
-allowed the user to supply an optional timestamp value to use instead
-of the current time.
-
- </body></html>
-
Index: manual/html_node/Getting-Started.html
===================================================================
RCS file: manual/html_node/Getting-Started.html
diff -N manual/html_node/Getting-Started.html
--- manual/html_node/Getting-Started.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-<html lang="en">
-<head>
-<title>Getting Started - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Preface.html#Preface" title="Preface">
-<link rel="next" href="Regexp.html#Regexp" title="Regexp">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getting-Started"></a>Next: <a rel="next" accesskey="n"
href="Regexp.html#Regexp">Regexp</a>,
-Previous: <a rel="previous" accesskey="p"
href="Preface.html#Preface">Preface</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">1 Getting Started with <samp><span
class="command">awk</span></samp></h2>
-
-<!-- @cindex script, definition of -->
-<!-- @cindex rule, definition of -->
-<!-- @cindex program, definition of -->
-<!-- @cindex basic function of @command{awk} -->
-<p><a name="index-_0040command_007bawk_007d_002c-function-of-72"></a>
-The basic function of <samp><span class="command">awk</span></samp> is to
search files for lines (or other
-units of text) that contain certain patterns. When a line matches one
-of the patterns, <samp><span class="command">awk</span></samp> performs
specified actions on that line.
-<samp><span class="command">awk</span></samp> keeps processing input lines in
this way until it reaches
-the end of the input files.
-
- <p><a name="index-_0040command_007bawk_007d_002c-uses-for-73"></a><a
name="index-programming-languages_0040comma_007b_007d-data_002ddriven-vs_002e-procedural-74"></a><a
name="index-_0040command_007bawk_007d-programs-75"></a>Programs in <samp><span
class="command">awk</span></samp> are different from programs in most other
languages,
-because <samp><span class="command">awk</span></samp> programs are
<dfn>data-driven</dfn>; that is, you describe
-the data you want to work with and then what to do when you find it.
-Most other languages are <dfn>procedural</dfn>; you have to describe, in great
-detail, every step the program is to take. When working with procedural
-languages, it is usually much
-harder to clearly describe the data your program will process.
-For this reason, <samp><span class="command">awk</span></samp> programs are
often refreshingly easy to
-read and write.
-
- <p><a name="index-program_002c-definition-of-76"></a><a
name="index-rule_002c-definition-of-77"></a>When you run <samp><span
class="command">awk</span></samp>, you specify an <samp><span
class="command">awk</span></samp> <dfn>program</dfn> that
-tells <samp><span class="command">awk</span></samp> what to do. The program
consists of a series of
-<dfn>rules</dfn>. (It may also contain <dfn>function definitions</dfn>,
-an advanced feature that we will ignore for now.
-See <a href="User_002ddefined.html#User_002ddefined">User-defined</a>.) Each
rule specifies one
-pattern to search for and one action to perform
-upon finding the pattern.
-
- <p>Syntactically, a rule consists of a pattern followed by an action. The
-action is enclosed in curly braces to separate it from the pattern.
-Newlines usually separate rules. Therefore, an <samp><span
class="command">awk</span></samp>
-program looks like this:
-
-<pre class="example"> <var>pattern</var> { <var>action</var> }
- <var>pattern</var> { <var>action</var> }
- ...
-</pre>
- <ul class="menu">
-<li><a accesskey="1" href="Running-gawk.html#Running-gawk">Running gawk</a>:
How to run <samp><span class="command">gawk</span></samp>
programs; includes
- command-line syntax.
-<li><a accesskey="2" href="Sample-Data-Files.html#Sample-Data-Files">Sample
Data Files</a>: Sample data files for use in the <samp><span
class="command">awk</span></samp>
- programs illustrated in this Web page.
-<li><a accesskey="3" href="Very-Simple.html#Very-Simple">Very Simple</a>:
A very simple example.
-<li><a accesskey="4" href="Two-Rules.html#Two-Rules">Two Rules</a>:
A less simple one-line example using two
- rules.
-<li><a accesskey="5" href="More-Complex.html#More-Complex">More Complex</a>:
A more complex example.
-<li><a accesskey="6"
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>:
Subdividing or combining statements into
- lines.
-<li><a accesskey="7" href="Other-Features.html#Other-Features">Other
Features</a>: Other Features of <samp><span
class="command">awk</span></samp>.
-<li><a accesskey="8" href="When.html#When">When</a>:
When to use <samp><span class="command">gawk</span></samp> and when to use
- other things.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Getting.html
===================================================================
RCS file: manual/html_node/Getting.html
diff -N manual/html_node/Getting.html
--- manual/html_node/Getting.html 29 Jun 2005 21:04:12 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-<html lang="en">
-<head>
-<title>Getting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Gawk-Distribution.html#Gawk-Distribution" title="Gawk
Distribution">
-<link rel="next" href="Extracting.html#Extracting" title="Extracting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Getting"></a>Next: <a rel="next" accesskey="n"
href="Extracting.html#Extracting">Extracting</a>,
-Up: <a rel="up" accesskey="u"
href="Gawk-Distribution.html#Gawk-Distribution">Gawk Distribution</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.1.1 Getting the <samp><span
class="command">gawk</span></samp> Distribution</h4>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-source-code_0040comma_007b_007d-obtaining-1873"></a>There
are three ways to get GNU software:
-
- <ul>
-<li>Copy it from someone else who already has it.
-
- <p><a name="index-FSF-_0028Free-Software-Foundation_0029-1874"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-1875"></a><li>Order
<samp><span class="command">gawk</span></samp> directly from the Free Software
Foundation.
-Software distributions are available for
-Gnu/Linux, Unix, and MS-Windows, in several CD packages.
-Their address is:
-
- <pre class="display"> Free Software Foundation
- 51 Franklin Street, Fifth Floor
- Boston, MA 02110-1301 USA
- Phone: +1-617-542-5942
- Fax (including Japan): +1-617-542-2652
- Email: <a href="mailto:address@hidden">address@hidden</a>
- URL: <a href="http://www.gnu.org">http://www.gnu.org</a>
- </pre>
- <p class="noindent">Ordering from the FSF directly contributes to the
support of the foundation
-and to the production of more free software.
-
- <li>Retrieve <samp><span class="command">gawk</span></samp> by using
anonymous <samp><span class="command">ftp</span></samp> to the Internet host
-<code>ftp.gnu.org</code>, in the directory <samp><span
class="file">/gnu/gawk</span></samp>.
-</ul>
-
- <p>The GNU software archive is mirrored around the world.
-The up-to-date list of mirror sites is available from
-<a href="http://www.gnu.org/order/ftp.html">the main FSF web site</a>.
-Try to use one of the mirrors; they
-will be less busy, and you can usually find one closer to your site.
-
- </body></html>
-
Index: manual/html_node/Glossary.html
===================================================================
RCS file: manual/html_node/Glossary.html
diff -N manual/html_node/Glossary.html
--- manual/html_node/Glossary.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,591 +0,0 @@
-<html lang="en">
-<head>
-<title>Glossary - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Basic-Concepts.html#Basic-Concepts" title="Basic
Concepts">
-<link rel="next" href="Copying.html#Copying" title="Copying">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Glossary"></a>Next: <a rel="next" accesskey="n"
href="Copying.html#Copying">Copying</a>,
-Previous: <a rel="previous" accesskey="p"
href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">Glossary</h2>
-
- <dl>
-<dt>Action<dd>A series of <samp><span class="command">awk</span></samp>
statements attached to a rule. If the rule's
-pattern matches an input record, <samp><span class="command">awk</span></samp>
executes the
-rule's action. Actions are always enclosed in curly braces.
-(See <a href="Action-Overview.html#Action-Overview">Action Overview</a>.)
-
- <p><a name="index-Spencer_002c-Henry-2052"></a><a
name="index-_0040command_007bsed_007d-utility-2053"></a><a
name="index-amazing-_0040command_007bawk_007d-assembler-_0028_0040command_007baaa_007d_0029-2054"></a><br><dt>Amazing
<samp><span class="command">awk</span></samp> Assembler<dd>Henry Spencer at
the University of Toronto wrote a retargetable assembler
-completely as <samp><span class="command">sed</span></samp> and <samp><span
class="command">awk</span></samp> scripts. It is thousands
-of lines long, including machine descriptions for several eight-bit
-microcomputers. It is a good example of a program that would have been
-better written in another language.
-You can get it from <a
href="ftp://ftp.freefriends.org/arnold/Awkstuff/aaa.tgz">ftp://ftp.freefriends.org/arnold/Awkstuff/aaa.tgz</a>.
-
- <p><a
name="index-amazingly-workable-formatter-_0028_0040command_007bawf_007d_0029-2055"></a><a
name="index-_0040command_007bawf_007d-_0028amazingly-workable-formatter_0029-program-2056"></a><br><dt>Amazingly
Workable Formatter (<samp><span class="command">awf</span></samp>)<dd>Henry
Spencer at the University of Toronto wrote a formatter that accepts
-a large subset of the `<samp><span class="samp">nroff -ms</span></samp>' and
`<samp><span class="samp">nroff -man</span></samp>' formatting
-commands, using <samp><span class="command">awk</span></samp> and <samp><span
class="command">sh</span></samp>.
-It is available over the Internet
-from <a
href="ftp://ftp.freefriends.org/arnold/Awkstuff/awf.tgz">ftp://ftp.freefriends.org/arnold/Awkstuff/awf.tgz</a>.
-
- <br><dt>Anchor<dd>The regexp metacharacters `<samp><span
class="samp">^</span></samp>' and `<samp><span class="samp">$</span></samp>',
which force the match
-to the beginning or end of the string, respectively.
-
- <p><a name="index-ANSI-2057"></a><br><dt>ANSI<dd>The American National
Standards Institute. This organization produces
-many standards, among them the standards for the C and C++ programming
-languages.
-These standards often become international standards as well. See also
-“ISO.”
-
- <br><dt>Array<dd>A grouping of multiple values under the same name.
-Most languages just provide sequential arrays.
-<samp><span class="command">awk</span></samp> provides associative arrays.
-
- <br><dt>Assertion<dd>A statement in a program that a condition is true at
this point in the program.
-Useful for reasoning about how a program is supposed to behave.
-
- <br><dt>Assignment<dd>An <samp><span class="command">awk</span></samp>
expression that changes the value of some <samp><span
class="command">awk</span></samp>
-variable or data object. An object that you can assign to is called an
-<dfn>lvalue</dfn>. The assigned values are called <dfn>rvalues</dfn>.
-See <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>.
-
- <br><dt>Associative Array<dd>Arrays in which the indices may be numbers
or strings, not just
-sequential integers in a fixed range.
-
- <br><dt><samp><span class="command">awk</span></samp> Language<dd>The
language in which <samp><span class="command">awk</span></samp> programs are
written.
-
- <br><dt><samp><span class="command">awk</span></samp> Program<dd>An
<samp><span class="command">awk</span></samp> program consists of a series of
<dfn>patterns</dfn> and
-<dfn>actions</dfn>, collectively known as <dfn>rules</dfn>. For each input
record
-given to the program, the program's rules are all processed in turn.
-<samp><span class="command">awk</span></samp> programs may also contain
function definitions.
-
- <br><dt><samp><span class="command">awk</span></samp> Script<dd>Another
name for an <samp><span class="command">awk</span></samp> program.
-
- <br><dt>Bash<dd>The GNU version of the standard shell
-(the <b>B</b>ourne-<b>A</b>gain <b>SH</b>ell).
-See also “Bourne Shell.”
-
- <br><dt>BBS<dd>See “Bulletin Board System.”
-
- <br><dt>Bit<dd>Short for “Binary Digit.”
-All values in computer memory ultimately reduce to binary digits: values
-that are either zero or one.
-Groups of bits may be interpreted differently—as integers,
-floating-point numbers, character data, addresses of other
-memory objects, or other data.
-<samp><span class="command">awk</span></samp> lets you work with
floating-point numbers and strings.
-<samp><span class="command">gawk</span></samp> lets you manipulate bit values
with the built-in
-functions described in
-<a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>.
-
- <p>Computers are often defined by how many bits they use to represent
integer
-values. Typical systems are 32-bit systems, but 64-bit systems are
-becoming increasingly popular, and 16-bit systems are waning in
-popularity.
-
- <br><dt>Boolean Expression<dd>Named after the English mathematician
Boole. See also “Logical Expression.”
-
- <br><dt>Bourne Shell<dd>The standard shell (<samp><span
class="file">/bin/sh</span></samp>) on Unix and Unix-like systems,
-originally written by Steven R. Bourne.
-Many shells (<samp><span class="command">bash</span></samp>, <samp><span
class="command">ksh</span></samp>, <samp><span
class="command">pdksh</span></samp>, <samp><span
class="command">zsh</span></samp>) are
-generally upwardly compatible with the Bourne shell.
-
- <br><dt>Built-in Function<dd>The <samp><span
class="command">awk</span></samp> language provides built-in functions that
perform various
-numerical, I/O-related, and string computations. Examples are
-<code>sqrt</code> (for the square root of a number) and <code>substr</code>
(for a
-substring of a string).
-<samp><span class="command">gawk</span></samp> provides functions for
timestamp management, bit manipulation,
-and runtime string translation.
-(See <a href="Built_002din.html#Built_002din">Built-in</a>.)
-
- <br><dt>Built-in Variable<dd><code>ARGC</code>,
-<code>ARGV</code>,
-<code>CONVFMT</code>,
-<code>ENVIRON</code>,
-<code>FILENAME</code>,
-<code>FNR</code>,
-<code>FS</code>,
-<code>NF</code>,
-<code>NR</code>,
-<code>OFMT</code>,
-<code>OFS</code>,
-<code>ORS</code>,
-<code>RLENGTH</code>,
-<code>RSTART</code>,
-<code>RS</code>,
-and
-<code>SUBSEP</code>
-are the variables that have special meaning to <samp><span
class="command">awk</span></samp>.
-In addition,
-<code>ARGIND</code>,
-<code>BINMODE</code>,
-<code>ERRNO</code>,
-<code>FIELDWIDTHS</code>,
-<code>IGNORECASE</code>,
-<code>LINT</code>,
-<code>PROCINFO</code>,
-<code>RT</code>,
-and
-<code>TEXTDOMAIN</code>
-are the variables that have special meaning to <samp><span
class="command">gawk</span></samp>.
-Changing some of them affects <samp><span class="command">awk</span></samp>'s
running environment.
-(See <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>.)
-
- <br><dt>Braces<dd>See “Curly Braces.”
-
- <br><dt>Bulletin Board System<dd>A computer system allowing users to log
in and read and/or leave messages
-for other users of the system, much like leaving paper notes on a bulletin
-board.
-
- <br><dt>C<dd>The system programming language that most GNU software is
written in. The
-<samp><span class="command">awk</span></samp> programming language has C-like
syntax, and this Web page
-points out similarities between <samp><span class="command">awk</span></samp>
and C when appropriate.
-
- <p>In general, <samp><span class="command">gawk</span></samp> attempts to
be as similar to the 1990 version
-of ISO C as makes sense. Future versions of <samp><span
class="command">gawk</span></samp> may adopt features
-from the newer 1999 standard, as appropriate.
-
- <br><dt>C++<dd>A popular object-oriented programming language derived
from C.
-
- <p><a name="index-ISO-8859_002d1-2058"></a><a
name="index-ISO-Latin_002d1-2059"></a><a
name="index-character-sets-_0028machine-character-encodings_0029-2060"></a><br><dt>Character
Set<dd>The set of numeric codes used by a computer system to represent the
-characters (letters, numbers, punctuation, etc.) of a particular country
-or place. The most common character set in use today is ASCII (American
-Standard Code for Information Interchange). Many European
-countries use an extension of ASCII known as ISO-8859-1 (ISO Latin-1).
-
- <p><a
name="index-_0040command_007bchem_007d-utility-2061"></a><br><dt>CHEM<dd>A
preprocessor for <samp><span class="command">pic</span></samp> that reads
descriptions of molecules
-and produces <samp><span class="command">pic</span></samp> input for drawing
them.
-It was written in <samp><span class="command">awk</span></samp>
-by Brian Kernighan and Jon Bentley, and is available from
-<a
href="http://cm.bell-labs.com/netlib/typesetting/chem.gz">http://cm.bell-labs.com/netlib/typesetting/chem.gz</a>.
-
- <br><dt>Coprocess<dd>A subordinate program with which two-way
communications is possible.
-
- <p><a name="index-compiled-programs-2062"></a><br><dt>Compiler<dd>A
program that translates human-readable source code into
-machine-executable object code. The object code is then executed
-directly by the computer.
-See also “Interpreter.”
-
- <br><dt>Compound Statement<dd>A series of <samp><span
class="command">awk</span></samp> statements, enclosed in curly braces.
Compound
-statements may be nested.
-(See <a href="Statements.html#Statements">Statements</a>.)
-
- <br><dt>Concatenation<dd>Concatenating two strings means sticking them
together, one after another,
-producing a new string. For example, the string `<samp><span
class="samp">foo</span></samp>' concatenated with
-the string `<samp><span class="samp">bar</span></samp>' gives the string
`<samp><span class="samp">foobar</span></samp>'.
-(See <a href="Concatenation.html#Concatenation">Concatenation</a>.)
-
- <br><dt>Conditional Expression<dd>An expression using the `<samp><span
class="samp">?:</span></samp>' ternary operator, such as
-`<samp><var>expr1</var><span class="samp"> ? </span><var>expr2</var><span
class="samp"> : </span><var>expr3</var></samp>'. The expression
-<var>expr1</var> is evaluated; if the result is true, the value of the whole
-expression is the value of <var>expr2</var>; otherwise the value is
-<var>expr3</var>. In either case, only one of <var>expr2</var> and
<var>expr3</var>
-is evaluated. (See <a href="Conditional-Exp.html#Conditional-Exp">Conditional
Exp</a>.)
-
- <br><dt>Comparison Expression<dd>A relation that is either true or false,
such as `<samp><span class="samp">(a < b)</span></samp>'.
-Comparison expressions are used in <code>if</code>, <code>while</code>,
<code>do</code>,
-and <code>for</code>
-statements, and in patterns to select which input records to process.
-(See <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>.)
-
- <br><dt>Curly Braces<dd>The characters `<samp><span
class="samp">{</span></samp>' and `<samp><span class="samp">}</span></samp>'.
Curly braces are used in
-<samp><span class="command">awk</span></samp> for delimiting actions, compound
statements, and function
-bodies.
-
- <p><a name="index-dark-corner-2063"></a><br><dt>Dark Corner<dd>An area in
the language where specifications often were (or still
-are) not clear, leading to unexpected or undesirable behavior.
-Such areas are marked in this Web page with
-“(d.c.)” in the text
-and are indexed under the heading “dark corner.”
-
- <br><dt>Data Driven<dd>A description of <samp><span
class="command">awk</span></samp> programs, where you specify the data you
-are interested in processing, and what to do when that data is seen.
-
- <br><dt>Data Objects<dd>These are numbers and strings of characters.
Numbers are converted into
-strings and vice versa, as needed.
-(See <a href="Conversion.html#Conversion">Conversion</a>.)
-
- <br><dt>Deadlock<dd>The situation in which two communicating processes
are each waiting
-for the other to perform an action.
-
- <br><dt>Double-Precision<dd>An internal representation of numbers that
can have fractional parts.
-Double-precision numbers keep track of more digits than do single-precision
-numbers, but operations on them are sometimes more expensive. This is the way
-<samp><span class="command">awk</span></samp> stores numeric values. It is
the C type <code>double</code>.
-
- <br><dt>Dynamic Regular Expression<dd>A dynamic regular expression is a
regular expression written as an
-ordinary expression. It could be a string constant, such as
-<code>"foo"</code>, but it may also be an expression whose value can vary.
-(See <a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>.)
-
- <br><dt>Environment<dd>A collection of strings, of the form
<var>name</var><code>=</code><var>val</var>, that each
-program has available to it. Users generally place values into the
-environment in order to provide information to various programs. Typical
-examples are the environment variables <samp><span
class="env">HOME</span></samp> and <samp><span class="env">PATH</span></samp>.
-
- <br><dt>Empty String<dd>See “Null String.”
-
- <p><a name="index-epoch_002c-definition-of-2064"></a><br><dt>Epoch<dd>The
date used as the “beginning of time” for timestamps.
-Time values in Unix systems are represented as seconds since the epoch,
-with library functions available for converting these values into
-standard date and time formats.
-
- <p>The epoch on Unix and POSIX systems is 1970-01-01 00:00:00 UTC.
-See also “GMT” and “UTC.”
-
- <br><dt>Escape Sequences<dd>A special sequence of characters used for
describing nonprinting
-characters, such as `<samp><span class="samp">\n</span></samp>' for newline or
`<samp><span class="samp">\033</span></samp>' for the ASCII
-ESC (Escape) character. (See <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>.)
-
- <br><dt>FDL<dd>See “Free Documentation License.”
-
- <br><dt>Field<dd>When <samp><span class="command">awk</span></samp> reads
an input record, it splits the record into pieces
-separated by whitespace (or by a separator regexp that you can
-change by setting the built-in variable <code>FS</code>). Such pieces are
-called fields. If the pieces are of fixed length, you can use the built-in
-variable <code>FIELDWIDTHS</code> to describe their lengths.
-(See <a href="Field-Separators.html#Field-Separators">Field Separators</a>,
-and
-<a href="Constant-Size.html#Constant-Size">Constant Size</a>.)
-
- <br><dt>Flag<dd>A variable whose truth value indicates the existence or
nonexistence
-of some condition.
-
- <br><dt>Floating-Point Number<dd>Often referred to in mathematical terms
as a “rational” or real number,
-this is just a number that can have a fractional part.
-See also “Double-Precision” and “Single-Precision.”
-
- <br><dt>Format<dd>Format strings are used to control the appearance of
output in the
-<code>strftime</code> and <code>sprintf</code> functions, and are used in the
-<code>printf</code> statement as well. Also, data conversions from numbers to
strings
-are controlled by the format string contained in the built-in variable
-<code>CONVFMT</code>. (See <a
href="Control-Letters.html#Control-Letters">Control Letters</a>.)
-
- <br><dt>Free Documentation License<dd>This document describes the terms
under which this Web page
-is published and may be copied. (See <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>.)
-
- <br><dt>Function<dd>A specialized group of statements used to encapsulate
general
-or program-specific tasks. <samp><span class="command">awk</span></samp> has
a number of built-in
-functions, and also allows you to define your own.
-(See <a href="Functions.html#Functions">Functions</a>.)
-
- <br><dt>FSF<dd>See “Free Software Foundation.”
-
- <p><a name="index-FSF-_0028Free-Software-Foundation_0029-2065"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-2066"></a><a
name="index-Stallman_002c-Richard-2067"></a><br><dt>Free Software
Foundation<dd>A nonprofit organization dedicated
-to the production and distribution of freely distributable software.
-It was founded by Richard M. Stallman, the author of the original
-Emacs editor. GNU Emacs is the most widely used version of Emacs today.
-
- <br><dt><samp><span class="command">gawk</span></samp><dd>The GNU
implementation of <samp><span class="command">awk</span></samp>.
-
- <p><a name="index-GPL-_0028General-Public-License_0029-2068"></a><a
name="index-General-Public-License-_0028GPL_0029-2069"></a><a
name="index-GNU-General-Public-License-2070"></a><br><dt>General Public
License<dd>This document describes the terms under which <samp><span
class="command">gawk</span></samp> and its source
-code may be distributed. (See <a href="Copying.html#Copying">Copying</a>.)
-
- <br><dt>GMT<dd>“Greenwich Mean Time.”
-This is the old term for UTC.
-It is the time of day used as the epoch for Unix and POSIX systems.
-See also “Epoch” and “UTC.”
-
- <p><a name="index-FSF-_0028Free-Software-Foundation_0029-2071"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-2072"></a><a
name="index-GNU-Project-2073"></a><br><dt>GNU<dd>“GNU's not Unix”.
An on-going project of the Free Software Foundation
-to create a complete, freely distributable, POSIX-compliant computing
-environment.
-
- <br><dt>GNU/Linux<dd>A variant of the GNU system using the Linux kernel,
instead of the
-Free Software Foundation's Hurd kernel.
-Linux is a stable, efficient, full-featured clone of Unix that has
-been ported to a variety of architectures.
-It is most popular on PC-class systems, but runs well on a variety of
-other systems too.
-The Linux kernel source code is available under the terms of the GNU General
-Public License, which is perhaps its most important aspect.
-
- <br><dt>GPL<dd>See “General Public License.”
-
- <br><dt>Hexadecimal<dd>Base 16 notation, where the digits are
<code>0</code>–<code>9</code> and
-<code>A</code>–<code>F</code>, with `<samp><span
class="samp">A</span></samp>'
-representing 10, `<samp><span class="samp">B</span></samp>' representing 11,
and so on, up to `<samp><span class="samp">F</span></samp>' for 15.
-Hexadecimal numbers are written in C using a leading `<samp><span
class="samp">0x</span></samp>',
-to indicate their base. Thus, <code>0x12</code> is 18 (1 times 16 plus 2).
-
- <br><dt>I/O<dd>Abbreviation for “Input/Output,” the act of
moving data into and/or
-out of a running program.
-
- <br><dt>Input Record<dd>A single chunk of data that is read in by
<samp><span class="command">awk</span></samp>. Usually, an <samp><span
class="command">awk</span></samp> input
-record consists of one line of text.
-(See <a href="Records.html#Records">Records</a>.)
-
- <br><dt>Integer<dd>A whole number, i.e., a number that does not have a
fractional part.
-
- <br><dt>Internationalization<dd>The process of writing or modifying a
program so
-that it can use multiple languages without requiring
-further source code changes.
-
- <p><a name="index-interpreted-programs-2074"></a><br><dt>Interpreter<dd>A
program that reads human-readable source code directly, and uses
-the instructions in it to process data and produce results.
-<samp><span class="command">awk</span></samp> is typically (but not always)
implemented as an interpreter.
-See also “Compiler.”
-
- <br><dt>Interval Expression<dd>A component of a regular expression that
lets you specify repeated matches of
-some part of the regexp. Interval expressions were not traditionally available
-in <samp><span class="command">awk</span></samp> programs.
-
- <p><a name="index-ISO-2075"></a><br><dt>ISO<dd>The International
Standards Organization.
-This organization produces international standards for many things, including
-programming languages, such as C and C++.
-In the computer arena, important standards like those for C, C++, and POSIX
-become both American national and ISO international standards simultaneously.
-This Web page refers to Standard C as “ISO C” throughout.
-
- <br><dt>Keyword<dd>In the <samp><span class="command">awk</span></samp>
language, a keyword is a word that has special
-meaning. Keywords are reserved and may not be used as variable names.
-
- <p><samp><span class="command">gawk</span></samp>'s keywords are:
-<code>BEGIN</code>,
-<code>END</code>,
-<code>if</code>,
-<code>else</code>,
-<code>while</code>,
-<code>do...while</code>,
-<code>for</code>,
-<code>for...in</code>,
-<code>break</code>,
-<code>continue</code>,
-<code>delete</code>,
-<code>next</code>,
-<code>nextfile</code>,
-<code>function</code>,
-<code>func</code>,
-and
-<code>exit</code>.
-
- <p><a
name="index-LGPL-_0028Lesser-General-Public-License_0029-2076"></a><a
name="index-Lesser-General-Public-License-_0028LGPL_0029-2077"></a><a
name="index-GNU-Lesser-General-Public-License-2078"></a><br><dt>Lesser General
Public License<dd>This document describes the terms under which binary library
archives
-or shared objects,
-and their source code may be distributed.
-
- <br><dt>Linux<dd>See “GNU/Linux.”
-
- <br><dt>LGPL<dd>See “Lesser General Public License.”
-
- <br><dt>Localization<dd>The process of providing the data necessary for an
-internationalized program to work in a particular language.
-
- <br><dt>Logical Expression<dd>An expression using the operators for
logic, AND, OR, and NOT, written
-`<samp><span class="samp">&&</span></samp>', `<samp><span
class="samp">||</span></samp>', and `<samp><span class="samp">!</span></samp>'
in <samp><span class="command">awk</span></samp>. Often called Boolean
-expressions, after the mathematician who pioneered this kind of
-mathematical logic.
-
- <br><dt>Lvalue<dd>An expression that can appear on the left side of an
assignment
-operator. In most languages, lvalues can be variables or array
-elements. In <samp><span class="command">awk</span></samp>, a field
designator can also be used as an
-lvalue.
-
- <br><dt>Matching<dd>The act of testing a string against a regular
expression. If the
-regexp describes the contents of the string, it is said to <dfn>match</dfn> it.
-
- <br><dt>Metacharacters<dd>Characters used within a regexp that do not
stand for themselves.
-Instead, they denote regular expression operations, such as repetition,
-grouping, or alternation.
-
- <br><dt>Null String<dd>A string with no characters in it. It is
represented explicitly in
-<samp><span class="command">awk</span></samp> programs by placing two double
quote characters next to
-each other (<code>""</code>). It can appear in input data by having two
successive
-occurrences of the field separator appear next to each other.
-
- <br><dt>Number<dd>A numeric-valued data object. Modern <samp><span
class="command">awk</span></samp> implementations use
-double-precision floating-point to represent numbers.
-Very old <samp><span class="command">awk</span></samp> implementations use
single-precision floating-point.
-
- <br><dt>Octal<dd>Base-eight notation, where the digits are
<code>0</code>–<code>7</code>.
-Octal numbers are written in C using a leading `<samp><span
class="samp">0</span></samp>',
-to indicate their base. Thus, <code>013</code> is 11 (one times 8 plus 3).
-
- <p><a
name="index-P1003_002e2-POSIX-standard-2079"></a><br><dt>P1003.2<dd>See
“POSIX.”
-
- <br><dt>Pattern<dd>Patterns tell <samp><span
class="command">awk</span></samp> which input records are interesting to which
-rules.
-
- <p>A pattern is an arbitrary conditional expression against which input is
-tested. If the condition is satisfied, the pattern is said to <dfn>match</dfn>
-the input record. A typical pattern might compare the input record against
-a regular expression. (See <a
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>.)
-
- <br><dt>POSIX<dd>The name for a series of standards
-<!-- being developed by the IEEE -->
-that specify a Portable Operating System interface. The “IX”
denotes
-the Unix heritage of these standards. The main standard of interest for
-<samp><span class="command">awk</span></samp> users is
-<cite>IEEE Standard for Information Technology, Standard 1003.2-1992,
-Portable Operating System Interface (POSIX) Part 2: Shell and
Utilities</cite>.
-Informally, this standard is often referred to as simply “P1003.2.”
-
- <br><dt>Precedence<dd>The order in which operations are performed when
operators are used
-without explicit parentheses.
-
- <br><dt>Private<dd>Variables and/or functions that are meant for use
exclusively by library
-functions and not for the main <samp><span class="command">awk</span></samp>
program. Special care must be
-taken when naming such variables and functions.
-(See <a href="Library-Names.html#Library-Names">Library Names</a>.)
-
- <br><dt>Range (of input lines)<dd>A sequence of consecutive lines from
the input file(s). A pattern
-can specify ranges of input lines for <samp><span
class="command">awk</span></samp> to process or it can
-specify single lines. (See <a
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>.)
-
- <br><dt>Recursion<dd>When a function calls itself, either directly or
indirectly.
-If this isn't clear, refer to the entry for “recursion.”
-
- <br><dt>Redirection<dd>Redirection means performing input from something
other than the standard input
-stream, or performing output to something other than the standard output
stream.
-
- <p>You can redirect the output of the <code>print</code> and
<code>printf</code> statements
-to a file or a system command, using the `<samp><span
class="samp">></span></samp>', `<samp><span
class="samp">>></span></samp>', `<samp><span
class="samp">|</span></samp>', and `<samp><span
class="samp">|&</span></samp>'
-operators. You can redirect input to the <code>getline</code> statement using
-the `<samp><span class="samp"><</span></samp>', `<samp><span
class="samp">|</span></samp>', and `<samp><span
class="samp">|&</span></samp>' operators.
-(See <a href="Redirection.html#Redirection">Redirection</a>,
-and <a href="Getline.html#Getline">Getline</a>.)
-
- <br><dt>Regexp<dd>Short for <dfn>regular expression</dfn>. A regexp is a
pattern that denotes a
-set of strings, possibly an infinite set. For example, the regexp
-`<samp><span class="samp">R.*xp</span></samp>' matches any string starting
with the letter `<samp><span class="samp">R</span></samp>'
-and ending with the letters `<samp><span class="samp">xp</span></samp>'. In
<samp><span class="command">awk</span></samp>, regexps are
-used in patterns and in conditional expressions. Regexps may contain
-escape sequences. (See <a href="Regexp.html#Regexp">Regexp</a>.)
-
- <br><dt>Regular Expression<dd>See “regexp.”
-
- <br><dt>Regular Expression Constant<dd>A regular expression constant is a
regular expression written within
-slashes, such as <code>/foo/</code>. This regular expression is chosen
-when you write the <samp><span class="command">awk</span></samp> program and
cannot be changed during
-its execution. (See <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>.)
-
- <br><dt>Rule<dd>A segment of an <samp><span
class="command">awk</span></samp> program that specifies how to process single
-input records. A rule consists of a <dfn>pattern</dfn> and an
<dfn>action</dfn>.
-<samp><span class="command">awk</span></samp> reads an input record; then, for
each rule, if the input record
-satisfies the rule's pattern, <samp><span class="command">awk</span></samp>
executes the rule's action.
-Otherwise, the rule does nothing for that input record.
-
- <br><dt>Rvalue<dd>A value that can appear on the right side of an
assignment operator.
-In <samp><span class="command">awk</span></samp>, essentially every expression
has a value. These values
-are rvalues.
-
- <br><dt>Scalar<dd>A single value, be it a number or a string.
-Regular variables are scalars; arrays and functions are not.
-
- <br><dt>Search Path<dd>In <samp><span class="command">gawk</span></samp>,
a list of directories to search for <samp><span
class="command">awk</span></samp> program source files.
-In the shell, a list of directories to search for executable programs.
-
- <br><dt>Seed<dd>The initial value, or starting point, for a sequence of
random numbers.
-
- <br><dt><samp><span class="command">sed</span></samp><dd>See
“Stream Editor.”
-
- <br><dt>Shell<dd>The command interpreter for Unix and POSIX-compliant
systems.
-The shell works both interactively, and as a programming language
-for batch files, or shell scripts.
-
- <br><dt>Short-Circuit<dd>The nature of the <samp><span
class="command">awk</span></samp> logical operators `<samp><span
class="samp">&&</span></samp>' and `<samp><span
class="samp">||</span></samp>'.
-If the value of the entire expression is determinable from evaluating just
-the lefthand side of these operators, the righthand side is not
-evaluated.
-(See <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a>.)
-
- <br><dt>Side Effect<dd>A side effect occurs when an expression has an
effect aside from merely
-producing a value. Assignment expressions, increment and decrement
-expressions, and function calls have side effects.
-(See <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>.)
-
- <br><dt>Single-Precision<dd>An internal representation of numbers that
can have fractional parts.
-Single-precision numbers keep track of fewer digits than do double-precision
-numbers, but operations on them are sometimes less expensive in terms of CPU
time.
-This is the type used by some very old versions of <samp><span
class="command">awk</span></samp> to store
-numeric values. It is the C type <code>float</code>.
-
- <br><dt>Space<dd>The character generated by hitting the space bar on the
keyboard.
-
- <br><dt>Special File<dd>A file name interpreted internally by <samp><span
class="command">gawk</span></samp>, instead of being handed
-directly to the underlying operating system—for example, <samp><span
class="file">/dev/stderr</span></samp>.
-(See <a href="Special-Files.html#Special-Files">Special Files</a>.)
-
- <br><dt>Stream Editor<dd>A program that reads records from an input
stream and processes them one
-or more at a time. This is in contrast with batch programs, which may
-expect to read their input files in entirety before starting to do
-anything, as well as with interactive programs which require input from the
-user.
-
- <br><dt>String<dd>A datum consisting of a sequence of characters, such as
`<samp><span class="samp">I am a
-string</span></samp>'. Constant strings are written with double quotes in the
-<samp><span class="command">awk</span></samp> language and may contain escape
sequences.
-(See <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>.)
-
- <br><dt>Tab<dd>The character generated by hitting the <kbd>TAB</kbd> key
on the keyboard.
-It usually expands to up to eight spaces upon output.
-
- <br><dt>Text Domain<dd>A unique name that identifies an application.
-Used for grouping messages that are translated at runtime
-into the local language.
-
- <br><dt>Timestamp<dd>A value in the “seconds since the epoch”
format used by Unix
-and POSIX systems. Used for the <samp><span
class="command">gawk</span></samp> functions
-<code>mktime</code>, <code>strftime</code>, and <code>systime</code>.
-See also “Epoch” and “UTC.”
-
- <p><a name="index-Linux-2080"></a><a
name="index-GNU_002fLinux-2081"></a><a name="index-Unix-2082"></a><a
name="index-BSD_002dbased-operating-systems-2083"></a><a
name="index-NetBSD-2084"></a><a name="index-FreeBSD-2085"></a><a
name="index-OpenBSD-2086"></a><br><dt>Unix<dd>A computer operating system
originally developed in the early 1970's at
-AT&T Bell Laboratories. It initially became popular in universities around
-the world and later moved into commercial environments as a software
-development system and network server system. There are many commercial
-versions of Unix, as well as several work-alike systems whose source code
-is freely available (such as GNU/Linux, NetBSD, FreeBSD, and OpenBSD).
-
- <br><dt>UTC<dd>The accepted abbreviation for “Universal Coordinated
Time.”
-This is standard time in Greenwich, England, which is used as a
-reference time for day and date calculations.
-See also “Epoch” and “GMT.”
-
- <br><dt>Whitespace<dd>A sequence of space, TAB, or newline characters
occurring inside an input
-record or a string.
-</dl>
-
- </body></html>
-
Index: manual/html_node/Gory-Details.html
===================================================================
RCS file: manual/html_node/Gory-Details.html
diff -N manual/html_node/Gory-Details.html
--- manual/html_node/Gory-Details.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,249 +0,0 @@
-<html lang="en">
-<head>
-<title>Gory Details - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="String-Functions.html#String-Functions" title="String
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Gory-Details"></a>Up: <a rel="up" accesskey="u"
href="String-Functions.html#String-Functions">String Functions</a>
-<hr><br>
-</div>
-
-<h5 class="subsubsection">8.1.3.1 More About `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' with <code>sub</code>, <code>gsub</code>, and
<code>gensub</code></h5>
-
-<p><a
name="index-escape-processing_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-1197"></a><a
name="index-_0040code_007bsub_007d-function_002c-escape-processing-1198"></a><a
name="index-_0040code_007bgsub_007d-function_002c-escape-processing-1199"></a><a
name="index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029_002c-escape-processing-1200"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1201"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1202"></a><a
name="index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1203"></a><a
name="index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1204"></a>When
using <code>sub</code>, <code>gsub</code>, or <code>gensub</code>, and trying
to get literal
-backslashes and ampersands into the replacement text, you need to remember
-that there are several levels of <dfn>escape processing</dfn> going on.
-
- <p>First, there is the <dfn>lexical</dfn> level, which is when <samp><span
class="command">awk</span></samp> reads
-your program
-and builds an internal copy of it that can be executed.
-Then there is the runtime level, which is when <samp><span
class="command">awk</span></samp> actually scans the
-replacement string to determine what to generate.
-
- <p>At both levels, <samp><span class="command">awk</span></samp> looks for
a defined set of characters that
-can come after a backslash. At the lexical level, it looks for the
-escape sequences listed in <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>.
-Thus, for every `<samp><span class="samp">\</span></samp>' that <samp><span
class="command">awk</span></samp> processes at the runtime
-level, type two backslashes at the lexical level.
-When a character that is not valid for an escape sequence follows the
-`<samp><span class="samp">\</span></samp>', Unix <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp> both simply remove the initial
-`<samp><span class="samp">\</span></samp>' and put the next character into the
string. Thus, for
-example, <code>"a\qb"</code> is treated as <code>"aqb"</code>.
-
- <p>At the runtime level, the various functions handle sequences of
-`<samp><span class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' differently. The situation is (sadly)
somewhat complex.
-Historically, the <code>sub</code> and <code>gsub</code> functions treated the
two
-character sequence `<samp><span class="samp">\&</span></samp>' specially;
this sequence was replaced in
-the generated text with a single `<samp><span
class="samp">&</span></samp>'. Any other `<samp><span
class="samp">\</span></samp>' within
-the <var>replacement</var> string that did not precede an `<samp><span
class="samp">&</span></samp>' was passed
-through unchanged. This is illustrated in <a
href="table_002dsub_002descapes.html#table_002dsub_002descapes">table-sub-escapes</a>.
-
-<!-- Thank to Karl Berry for help with the TeX stuff. -->
-<div class="float">
-<a name="table_002dsub_002descapes"></a>
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>\&</code> <code>&</code> the
matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\\&</span></samp>'
- <code>\\q</code> <code>\q</code> a literal
`<samp><span class="samp">\q</span></samp>'
-</pre>
- <p><strong class="float-caption">Table 8.1: Historical Escape Sequence
Processing for sub and gsub</strong></p></div>
-
-<p class="noindent">This table shows both the lexical-level processing, where
-an odd number of backslashes becomes an even number at the runtime level,
-as well as the runtime processing done by <code>sub</code>.
-(For the sake of simplicity, the rest of the following tables only show the
-case of even numbers of backslashes entered at the lexical level.)
-
- <p>The problem with the historical approach is that there is no way to get
-a literal `<samp><span class="samp">\</span></samp>' followed by the matched
text.
-
-<!-- @cindex @command{awk} language, POSIX version -->
-<p><a
name="index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-1205"></a>The
1992 POSIX standard attempted to fix this problem. That standard
-says that <code>sub</code> and <code>gsub</code> look for either a
`<samp><span class="samp">\</span></samp>' or an `<samp><span
class="samp">&</span></samp>'
-after the `<samp><span class="samp">\</span></samp>'. If either one follows a
`<samp><span class="samp">\</span></samp>', that character is
-output literally. The interpretation of `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' then becomes
-as shown in <a
href="table_002dsub_002dposix_002d92.html#table_002dsub_002dposix_002d92">table-sub-posix-92</a>.
-
- <div class="float">
-<a name="table_002dsub_002dposix_002d92"></a>
-<!-- thanks to Karl Berry for formatting this table -->
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>&</code> <code>&</code> the
matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\</span></samp>', then the matched text
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
-</pre>
- <p><strong class="float-caption">Table 8.2: 1992 POSIX Rules for sub and
gsub Escape Sequence Processing</strong></p></div>
-
-<p class="noindent">This appears to solve the problem.
-Unfortunately, the phrasing of the standard is unusual. It
-says, in effect, that `<samp><span class="samp">\</span></samp>' turns off the
special meaning of any
-following character, but for anything other than `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>',
-such special meaning is undefined. This wording leads to two problems:
-
- <ul>
-<li>Backslashes must now be doubled in the <var>replacement</var> string,
breaking
-historical <samp><span class="command">awk</span></samp> programs.
-
- <li>To make sure that an <samp><span class="command">awk</span></samp>
program is portable, <em>every</em> character
-in the <var>replacement</var> string must be preceded with a
-backslash.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-<!-- I can say that, 'cause I was involved in making this change -->
-</ul>
-
- <p>Because of the problems just listed,
-in 1996, the <samp><span class="command">gawk</span></samp> maintainer
submitted
-proposed text for a revised standard that
-reverts to rules that correspond more closely to the original existing
-practice. The proposed rules have special cases that make it possible
-to produce a `<samp><span class="samp">\</span></samp>' preceding the matched
text. This is shown in
-<a
href="table_002dsub_002dproposed.html#table_002dsub_002dproposed">table-sub-proposed</a>.
-
- <div class="float">
-<a name="table_002dsub_002dproposed"></a>
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\</span></samp>', followed by the matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\q</code> <code>\q</code> a literal
`<samp><span class="samp">\q</span></samp>'
- <code>\\\\</code> <code>\\</code>
<code>\\</code>
-</pre>
- <p><strong class="float-caption">Table 8.3: Propsosed rules for sub and
backslash</strong></p></div>
-
- <p>In a nutshell, at the runtime level, there are now three special
sequences
-of characters (`<samp><span class="samp">\\\&</span></samp>', `<samp><span
class="samp">\\&</span></samp>' and `<samp><span
class="samp">\&</span></samp>') whereas historically
-there was only one. However, as in the historical case, any `<samp><span
class="samp">\</span></samp>' that
-is not part of one of these three sequences is not special and appears
-in the output literally.
-
- <p><samp><span class="command">gawk</span></samp> 3.0 and 3.1 follow these
proposed POSIX rules for <code>sub</code> and
-<code>gsub</code>.
-<!-- As much as we think it's a lousy idea. You win some, you lose some. Sigh.
-->
-The POSIX standard took much longer to be revised than was expected in 1996.
-The 2001 standard does not follow the above rules. Instead, the rules
-there are somewhat simpler. The results are similar except for one case.
-
- <p>The 2001 POSIX rules state that `<samp><span
class="samp">\&</span></samp>' in the replacement string produces
-a literal `<samp><span class="samp">&</span></samp>', `<samp><span
class="samp">\\</span></samp>' produces a literal `<samp><span
class="samp">\</span></samp>', and `<samp><span class="samp">\</span></samp>'
followed
-by anything else is not special; the `<samp><span
class="samp">\</span></samp>' is placed straight into the output.
-These rules are presented in <a
href="table_002dposix_002d2001_002dsub.html#table_002dposix_002d2001_002dsub">table-posix-2001-sub</a>.
-
- <div class="float">
-<a name="table_002dposix_002d2001_002dsub"></a>
-<pre class="display"> You type <code>sub</code> sees
<code>sub</code> generates
- ———– ————–
———————
- <code>\\\\\\&</code> <code>\\\&</code> a
literal `<samp><span class="samp">\&</span></samp>'
- <code>\\\\&</code> <code>\\&</code> a
literal `<samp><span class="samp">\</span></samp>', followed by the matched text
- <code>\\&</code> <code>\&</code> a
literal `<samp><span class="samp">&</span></samp>'
- <code>\\q</code> <code>\q</code> a literal
`<samp><span class="samp">\q</span></samp>'
- <code>\\\\</code> <code>\\</code> <code>\</code>
-</pre>
- <p><strong class="float-caption">Table 8.4: POSIX 2001 rules for
sub</strong></p></div>
-
- <p>The only case where the difference is noticeable is the last one:
`<samp><span class="samp">\\\\</span></samp>'
-is seen as `<samp><span class="samp">\\</span></samp>' and produces
`<samp><span class="samp">\</span></samp>' instead of `<samp><span
class="samp">\\</span></samp>'.
-
- <p>Starting with version 3.1.4, <samp><span
class="command">gawk</span></samp> follows the POSIX rules
-when <samp><span class="option">--posix</span></samp> is specified (see <a
href="Options.html#Options">Options</a>). Otherwise,
-it continues to follow the 1996 proposed rules, since, as of this
-writing, that has been its behavior for over seven years.
-
- <blockquote>
-<b>NOTE:</b> At the next major release, <samp><span
class="command">gawk</span></samp> will switch to using
-the POSIX 2001 rules by default.
-</blockquote>
-
- <p>The rules for <code>gensub</code> are considerably simpler. At the
runtime
-level, whenever <samp><span class="command">gawk</span></samp> sees a
`<samp><span class="samp">\</span></samp>', if the following character
-is a digit, then the text that matched the corresponding parenthesized
-subexpression is placed in the generated output. Otherwise,
-no matter what character follows the `<samp><span
class="samp">\</span></samp>', it
-appears in the generated text and the `<samp><span
class="samp">\</span></samp>' does not,
-as shown in <a
href="table_002dgensub_002descapes.html#table_002dgensub_002descapes">table-gensub-escapes</a>.
-
- <div class="float">
-<a name="table_002dgensub_002descapes"></a>
-<pre class="display"> You type <code>gensub</code> sees
<code>gensub</code> generates
- ———–
——————
————————–
- <code>&</code> <code>&</code>
the matched text
- <code>\\&</code> <code>\&</code>
a literal `<samp><span class="samp">&</span></samp>'
- <code>\\\\</code> <code>\\</code> a
literal `<samp><span class="samp">\</span></samp>'
- <code>\\\\&</code> <code>\\&</code>
a literal `<samp><span class="samp">\</span></samp>', then the matched text
- <code>\\\\\\&</code> <code>\\\&</code>
a literal `<samp><span class="samp">\&</span></samp>'
- <code>\\q</code> <code>\q</code> a
literal `<samp><span class="samp">q</span></samp>'
-</pre>
- <p><strong class="float-caption">Table 8.5: Escape Sequence Processing for
gensub</strong></p></div>
-
- <p>Because of the complexity of the lexical and runtime level processing
-and the special cases for <code>sub</code> and <code>gsub</code>,
-we recommend the use of <samp><span class="command">gawk</span></samp> and
<code>gensub</code> when you have
-to do substitutions.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Matching the Null String</h4>
-
-<p><a
name="index-advanced-features_002c-null-strings_0040comma_007b_007d-matching-1206"></a><a
name="index-matching_002c-null-strings-1207"></a><a
name="index-null-strings_002c-matching-1208"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1209"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1210"></a>
-In <samp><span class="command">awk</span></samp>, the `<samp><span
class="samp">*</span></samp>' operator can match the null string.
-This is particularly important for the <code>sub</code>, <code>gsub</code>,
-and <code>gensub</code> functions. For example:
-
-<pre class="example"> $ echo abc | awk '{ gsub(/m*/, "X"); print }'
- -| XaXbXcX
-</pre>
- <p class="noindent">Although this makes a certain amount of sense, it can
be surprising.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This consequence was certainly unintended.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Group-Functions.html
===================================================================
RCS file: manual/html_node/Group-Functions.html
diff -N manual/html_node/Group-Functions.html
--- manual/html_node/Group-Functions.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,326 +0,0 @@
-<html lang="en">
-<head>
-<title>Group Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Library-Functions.html#Library-Functions" title="Library
Functions">
-<link rel="prev" href="Passwd-Functions.html#Passwd-Functions" title="Passwd
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Group-Functions"></a>Previous: <a rel="previous" accesskey="p"
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Library-Functions.html#Library-Functions">Library Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">12.6 Reading the Group Database</h3>
-
-<!-- STARTOFRANGE libfgdata -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-group-database_002c-reading-1717"></a><!--
STARTOFRANGE flibgdata -->
-<a
name="index-functions_002c-library_002c-group-database_002c-reading-1718"></a><!--
STARTOFRANGE gdatar -->
-<a name="index-group-database_002c-reading-1719"></a><!-- STARTOFRANGE datagr
-->
-<a name="index-database_002c-group_002c-reading-1720"></a><a
name="index-_0040code_007bPROCINFO_007d-array-1721"></a><a
name="index-_0040code_007bgetgrent_007d-function-_0028C-library_0029-1722"></a><a
name="index-_0040code_007bgetgrent_007d-user_002ddefined-function-1723"></a><a
name="index-groups_0040comma_007b_007d-information-about-1724"></a><a
name="index-account-information-1725"></a><a
name="index-group-file-1726"></a><a name="index-files_002c-group-1727"></a>Much
of the discussion presented in
-<a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>,
-applies to the group database as well. Although there has traditionally
-been a well-known file (<samp><span class="file">/etc/group</span></samp>) in
a well-known format, the POSIX
-standard only provides a set of C library routines
-(<code><grp.h></code> and <code>getgrent</code>)
-for accessing the information.
-Even though this file may exist, it likely does not have
-complete information. Therefore, as with the user database, it is necessary
-to have a small C program that generates the group database as its output.
-
- <p><a name="index-_0040command_007bgrcat_007d-program-1728"></a><samp><span
class="command">grcat</span></samp>, a C program that “cats” the
group database,
-is as follows:
-
-<pre class="example"> <!-- file eg/lib/grcat.c -->
- /*
- * grcat.c
- *
- * Generate a printable version of the group database
- */
- <!-- endfile -->
- <!-- file eg/lib/grcat.c -->
- #include <stdio.h>
- #include <grp.h>
-
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct group *g;
- int i;
-
- while ((g = getgrent()) != NULL) {
- printf("%s:%s:%ld:", g->gr_name, g->gr_passwd,
- (long) g->gr_gid);
- for (i = 0; g->gr_mem[i] != NULL; i++) {
- printf("%s", g->gr_mem[i]);
- if (g->gr_mem[i+1] != NULL)
- putchar(',');
- }
- putchar('\n');
- }
- endgrent();
- return 0;
- }
- <!-- endfile -->
-</pre>
- <p>Each line in the group database represents one group. The fields are
-separated with colons and represent the following information:
-
- <p><table summary=""><tr align="left"><td valign="top">Group name </td><td
valign="top">The group's name.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group password </td><td
valign="top">The group's encrypted password. In practice, this field is never
used;
-it is usually empty or set to `<samp><span class="samp">*</span></samp>'.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group-ID </td><td
valign="top">
-The group's numeric group ID number; this number should be unique within the
file.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group member list </td><td
valign="top">
-A comma-separated list of usernames. These users are members of the group.
-Modern Unix systems allow users to be members of several groups
-simultaneously. If your system does, then there are elements
-<code>"group1"</code> through <code>"group</code><var>N</var><code>"</code> in
<code>PROCINFO</code>
-for those group ID numbers.
-(Note that <code>PROCINFO</code> is a <samp><span
class="command">gawk</span></samp> extension;
-see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>.)
- <br></td></tr></table>
-
- <p>Here is what running <samp><span class="command">grcat</span></samp>
might produce:
-
-<pre class="example"> $ grcat
- -| wheel:*:0:arnold
- -| nogroup:*:65534:
- -| daemon:*:1:
- -| kmem:*:2:
- -| staff:*:10:arnold,miriam,andy
- -| other:*:20:
- ...
-</pre>
- <p>Here are the functions for obtaining information from the group
database.
-There are several, modeled after the C library functions of the same names:
-
- <p><a
name="index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1729"></a><a
name="index-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1730"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- # group.awk --- functions for dealing with the group file
- <!-- endfile -->
- <!-- line break on _gr_init for smallbook -->
- <!-- file eg/lib/groupawk.in -->
- BEGIN \
- {
- # Change to suit your system
- _gr_awklib = "/usr/local/libexec/awk/"
- }
-
- function _gr_init( oldfs, oldrs, olddol0, grcat,
- using_fw, n, a, i)
- {
- if (_gr_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
- FS = ":"
- RS = "\n"
-
- grcat = _gr_awklib "grcat"
- while ((grcat | getline) > 0) {
- if ($1 in _gr_byname)
- _gr_byname[$1] = _gr_byname[$1] "," $4
- else
- _gr_byname[$1] = $0
- if ($3 in _gr_bygid)
- _gr_bygid[$3] = _gr_bygid[$3] "," $4
- else
- _gr_bygid[$3] = $0
-
- n = split($4, a, "[ \t]*,[ \t]*")
- for (i = 1; i <= n; i++)
- if (a[i] in _gr_groupsbyuser)
- _gr_groupsbyuser[a[i]] = \
- _gr_groupsbyuser[a[i]] " " $1
- else
- _gr_groupsbyuser[a[i]] = $1
-
- _gr_bycount[++_gr_count] = $0
- }
- close(grcat)
- _gr_count = 0
- _gr_inited++
- FS = oldfs
- if (using_fw)
- FIELDWIDTHS = FIELDWIDTHS
- RS = oldrs
- $0 = olddol0
- }
- <!-- endfile -->
-</pre>
- <p>The <code>BEGIN</code> rule sets a private variable to the directory
where
-<samp><span class="command">grcat</span></samp> is stored. Because it is used
to help out an <samp><span class="command">awk</span></samp> library
-routine, we have chosen to put it in <samp><span
class="file">/usr/local/libexec/awk</span></samp>. You might
-want it to be in a different directory on your system.
-
- <p>These routines follow the same general outline as the user database
routines
-(see <a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>).
-The <code>_gr_inited<!-- /@w --></code> variable is used to
-ensure that the database is scanned no more than once.
-The <code>_gr_init<!-- /@w --></code> function first saves <code>FS</code>,
<code>FIELDWIDTHS</code>, <code>RS</code>, and
-<code>$0</code>, and then sets <code>FS</code> and <code>RS</code> to the
correct values for
-scanning the group information.
-
- <p>The group information is stored is several associative arrays.
-The arrays are indexed by group name (<code>_gr_byname<!-- /@w --></code>), by
group ID number
-(<code>_gr_bygid<!-- /@w --></code>), and by position in the database
(<code>_gr_bycount<!-- /@w --></code>).
-There is an additional array indexed by username (<code>_gr_groupsbyuser<!--
/@w --></code>),
-which is a space-separated list of groups to which each user belongs.
-
- <p>Unlike the user database, it is possible to have multiple records in the
-database for the same group. This is common when a group has a large number
-of members. A pair of such entries might look like the following:
-
-<pre class="example"> tvpeople:*:101:johnny,jay,arsenio
- tvpeople:*:101:david,conan,tom,joan
-</pre>
- <p>For this reason, <code>_gr_init</code> looks to see if a group name or
-group ID number is already seen. If it is, then the usernames are
-simply concatenated onto the previous list of users. (There is actually a
-subtle problem with the code just presented. Suppose that
-the first time there were no names. This code adds the names with
-a leading comma. It also doesn't check that there is a <code>$4</code>.)
-
- <p>Finally, <code>_gr_init</code> closes the pipeline to <samp><span
class="command">grcat</span></samp>, restores
-<code>FS</code> (and <code>FIELDWIDTHS</code> if necessary), <code>RS</code>,
and <code>$0</code>,
-initializes <code>_gr_count</code> to zero
-(it is used later), and makes <code>_gr_inited</code> nonzero.
-
- <p><a
name="index-_0040code_007bgetgrnam_007d-function-_0028C-library_0029-1731"></a>The
<code>getgrnam</code> function takes a group name as its argument, and if that
-group exists, it is returned. Otherwise, <code>getgrnam</code> returns the null
-string:
-
- <p><a
name="index-_0040code_007bgetgrnam_007d-user_002ddefined-function-1732"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgrnam(group)
- {
- _gr_init()
- if (group in _gr_byname)
- return _gr_byname[group]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetgrgid_007d-function-_0028C-library_0029-1733"></a>The
<code>getgrgid</code> function is similar, it takes a numeric group ID and
-looks up the information associated with that group ID:
-
- <p><a
name="index-_0040code_007bgetgrgid_007d-user_002ddefined-function-1734"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgrgid(gid)
- {
- _gr_init()
- if (gid in _gr_bygid)
- return _gr_bygid[gid]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetgruser_007d-function-_0028C-library_0029-1735"></a>The
<code>getgruser</code> function does not have a C counterpart. It takes a
-username and returns the list of groups that have the user as a member:
-
- <p><a
name="index-_0040code_007bgetgruser_007d-function_002c-user_002ddefined-1736"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgruser(user)
- {
- _gr_init()
- if (user in _gr_groupsbyuser)
- return _gr_groupsbyuser[user]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetgrent_007d-function-_0028C-library_0029-1737"></a>The
<code>getgrent</code> function steps through the database one entry at a time.
-It uses <code>_gr_count</code> to track its position in the list:
-
- <p><a
name="index-_0040code_007bgetgrent_007d-user_002ddefined-function-1738"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function getgrent()
- {
- _gr_init()
- if (++_gr_count in _gr_bycount)
- return _gr_bycount[_gr_count]
- return ""
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE clibf -->
-<p><a
name="index-_0040code_007bendgrent_007d-function-_0028C-library_0029-1739"></a>The
<code>endgrent</code> function resets <code>_gr_count</code> to zero so that
<code>getgrent</code> can
-start over again:
-
- <p><a
name="index-_0040code_007bendgrent_007d-user_002ddefined-function-1740"></a>
-<pre class="example"> <!-- file eg/lib/groupawk.in -->
- function endgrent()
- {
- _gr_count = 0
- }
- <!-- endfile -->
-</pre>
- <p>As with the user database routines, each function calls
<code>_gr_init</code> to
-initialize the arrays. Doing so only incurs the extra overhead of running
-<samp><span class="command">grcat</span></samp> if these functions are used
(as opposed to moving the body of
-<code>_gr_init</code> into a <code>BEGIN</code> rule).
-
- <p>Most of the work is in scanning the database and building the various
-associative arrays. The functions that the user calls are themselves very
-simple, relying on <samp><span class="command">awk</span></samp>'s associative
arrays to do work.
-
- <p>The <samp><span class="command">id</span></samp> program in <a
href="Id-Program.html#Id-Program">Id Program</a>,
-uses these functions.
-<!-- ENDOFRANGE libfgdata -->
-<!-- ENDOFRANGE flibgdata -->
-<!-- ENDOFRANGE gdatar -->
-<!-- ENDOFRANGE libf -->
-<!-- ENDOFRANGE flib -->
-<!-- ENDOFRANGE fudlib -->
-<!-- ENDOFRANGE datagr -->
-
- </body></html>
-
Index: manual/html_node/History-Sorting.html
===================================================================
RCS file: manual/html_node/History-Sorting.html
diff -N manual/html_node/History-Sorting.html
--- manual/html_node/History-Sorting.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-<html lang="en">
-<head>
-<title>History Sorting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Word-Sorting.html#Word-Sorting" title="Word Sorting">
-<link rel="next" href="Extract-Program.html#Extract-Program" title="Extract
Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="History-Sorting"></a>Next: <a rel="next" accesskey="n"
href="Extract-Program.html#Extract-Program">Extract Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Word-Sorting.html#Word-Sorting">Word Sorting</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.6 Removing Duplicates from Unsorted Text</h4>
-
-<!-- STARTOFRANGE lidu -->
-<p><a
name="index-lines_002c-duplicate_0040comma_007b_007d-removing-1806"></a>The
<samp><span class="command">uniq</span></samp> program
-(see <a href="Uniq-Program.html#Uniq-Program">Uniq Program</a>),
-removes duplicate lines from <em>sorted</em> data.
-
- <p>Suppose, however, you need to remove duplicate lines from a data file but
-that you want to preserve the order the lines are in. A good example of
-this might be a shell history file. The history file keeps a copy of all
-the commands you have entered, and it is not unusual to repeat a command
-several times in a row. Occasionally you might want to compact the history
-by removing duplicate entries. Yet it is desirable to maintain the order
-of the original commands.
-
- <p>This simple program does the job. It uses two arrays. The
<code>data</code>
-array is indexed by the text of each line.
-For each line, <code>data[$0]</code> is incremented.
-If a particular line has not
-been seen before, then <code>data[$0]</code> is zero.
-In this case, the text of the line is stored in <code>lines[count]</code>.
-Each element of <code>lines</code> is a unique command, and the indices of
-<code>lines</code> indicate the order in which those lines are encountered.
-The <code>END</code> rule simply prints out the lines, in order:
-
- <p><a name="index-Rakitzis_002c-Byron-1807"></a><a
name="index-_0040code_007bhistsort_002eawk_007d-program-1808"></a>
-<pre class="example"> <!-- file eg/prog/histsort.awk -->
- # histsort.awk --- compact a shell history file
- # Thanks to Byron Rakitzis for the general idea
- <!-- endfile -->
- <!-- file eg/prog/histsort.awk -->
- {
- if (data[$0]++ == 0)
- lines[++count] = $0
- }
-
- END {
- for (i = 1; i <= count; i++)
- print lines[i]
- }
- <!-- endfile -->
-</pre>
- <p>This program also provides a foundation for generating other useful
-information. For example, using the following <code>print</code> statement in
the
-<code>END</code> rule indicates how often a particular command is used:
-
-<pre class="example"> print data[lines[i]], lines[i]
-</pre>
- <p>This works because <code>data[$0]</code> is incremented each time a line
is
-seen.
-<!-- ENDOFRANGE lidu -->
-
- </body></html>
-
Index: manual/html_node/History.html
===================================================================
RCS file: manual/html_node/History.html
diff -N manual/html_node/History.html
--- manual/html_node/History.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,106 +0,0 @@
-<html lang="en">
-<head>
-<title>History - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="next" href="Names.html#Names" title="Names">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="History"></a>Next: <a rel="next" accesskey="n"
href="Names.html#Names">Names</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="unnumberedsec">History of <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-recipe-for-a-programming-language-11"></a><a
name="index-programming-language_002c-recipe-for-12"></a><div
align="center">Recipe For A Programming Language</div>
-
-<p><table summary=""><tr align="left"><td valign="top"></td><td valign="top">1
part <code>egrep</code> </td><td valign="top">1 part <code>snobol</code>
-<br></td></tr><tr align="left"><td valign="top"></td><td valign="top">2 parts
<code>ed</code> </td><td valign="top">3 parts C
-<br></td></tr></table>
-
- <blockquote>
-Blend all parts well using <code>lex</code> and <code>yacc</code>.
-Document minimally and release.
-
- <p>After eight years, add another part <code>egrep</code> and two
-more parts C. Document very well and release.
-</blockquote>
-
- <p><a name="index-Aho_002c-Alfred-13"></a><a
name="index-Weinberger_002c-Peter-14"></a><a
name="index-Kernighan_002c-Brian-15"></a><a
name="index-_0040command_007bawk_007d_002c-history-of-16"></a>The name
<samp><span class="command">awk</span></samp> comes from the initials of its
designers: Alfred V.
-Aho, Peter J. Weinberger and Brian W. Kernighan. The original version of
-<samp><span class="command">awk</span></samp> was written in 1977 at AT&T
Bell Laboratories.
-In 1985, a new version made the programming
-language more powerful, introducing user-defined functions, multiple input
-streams, and computed regular expressions.
-This new version became widely available with Unix System V
-Release 3.1 (SVR3.1).
-The version in SVR4 added some new features and cleaned
-up the behavior in some of the “dark corners” of the language.
-The specification for <samp><span class="command">awk</span></samp> in the
POSIX Command Language
-and Utilities standard further clarified the language.
-Both the <samp><span class="command">gawk</span></samp> designers and the
original Bell Laboratories <samp><span class="command">awk</span></samp>
-designers provided feedback for the POSIX specification.
-
- <p><a name="index-Rubin_002c-Paul-17"></a><a
name="index-Fenlason_002c-Jay-18"></a><a
name="index-Trueman_002c-David-19"></a>Paul Rubin wrote the GNU implementation,
<samp><span class="command">gawk</span></samp>, in 1986.
-Jay Fenlason completed it, with advice from Richard Stallman. John Woods
-contributed parts of the code as well. In 1988 and 1989, David Trueman, with
-help from me, thoroughly reworked <samp><span
class="command">gawk</span></samp> for compatibility
-with the newer <samp><span class="command">awk</span></samp>.
-Circa 1995, I became the primary maintainer.
-Current development focuses on bug fixes,
-performance improvements, standards compliance, and occasionally, new features.
-
- <p>In May of 1997, Jürgen Kahrs felt the need for network access
-from <samp><span class="command">awk</span></samp>, and with a little help
from me, set about adding
-features to do this for <samp><span class="command">gawk</span></samp>. At
that time, he also
-wrote the bulk of
-<cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>
-(a separate document, available as part of the <samp><span
class="command">gawk</span></samp> distribution).
-His code finally became part of the main <samp><span
class="command">gawk</span></samp> distribution
-with <samp><span class="command">gawk</span></samp> version 3.1.
-
- <p>See <a href="Contributors.html#Contributors">Contributors</a>,
-for a complete list of those who made important contributions to <samp><span
class="command">gawk</span></samp>.
-
- </body></html>
-
Index: manual/html_node/How-To-Contribute.html
===================================================================
RCS file: manual/html_node/How-To-Contribute.html
diff -N manual/html_node/How-To-Contribute.html
--- manual/html_node/How-To-Contribute.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-<html lang="en">
-<head>
-<title>How To Contribute - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="prev" href="Manual-History.html#Manual-History" title="Manual
History">
-<link rel="next" href="Acknowledgments.html#Acknowledgments"
title="Acknowledgments">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="How-To-Contribute"></a>Next: <a rel="next" accesskey="n"
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a>,
-Previous: <a rel="previous" accesskey="p"
href="Manual-History.html#Manual-History">Manual History</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="unnumberedsec">How to Contribute</h3>
-
-<p>As the maintainer of GNU <samp><span class="command">awk</span></samp>,
-I am starting a collection of publicly available <samp><span
class="command">awk</span></samp>
-programs.
-For more information,
-see <a
href="ftp://ftp.freefriends.org/arnold/Awkstuff">ftp://ftp.freefriends.org/arnold/Awkstuff</a>.
-If you have written an interesting <samp><span
class="command">awk</span></samp> program, or have written a
-<samp><span class="command">gawk</span></samp> extension that you would like to
-share with the rest of the world, please contact me (<a
href="mailto:address@hidden">address@hidden</a>).
-Making things available on the Internet helps keep the
-<samp><span class="command">gawk</span></samp> distribution down to manageable
size.
-
- </body></html>
-
Index: manual/html_node/I18N-Example.html
===================================================================
RCS file: manual/html_node/I18N-Example.html
diff -N manual/html_node/I18N-Example.html
--- manual/html_node/I18N-Example.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,160 +0,0 @@
-<html lang="en">
-<head>
-<title>I18N Example - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="prev" href="Translator-i18n.html#Translator-i18n" title="Translator
i18n">
-<link rel="next" href="Gawk-I18N.html#Gawk-I18N" title="Gawk I18N">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="I18N-Example"></a>Next: <a rel="next" accesskey="n"
href="Gawk-I18N.html#Gawk-I18N">Gawk I18N</a>,
-Previous: <a rel="previous" accesskey="p"
href="Translator-i18n.html#Translator-i18n">Translator i18n</a>,
-Up: <a rel="up" accesskey="u"
href="Internationalization.html#Internationalization">Internationalization</a>
-<hr><br>
-</div>
-
-<h3 class="section">9.5 A Simple Internationalization Example</h3>
-
-<p>Now let's look at a step-by-step example of how to internationalize and
-localize a simple <samp><span class="command">awk</span></samp> program, using
<samp><span class="file">guide.awk</span></samp> as our
-original source:
-
-<pre class="example"> <!-- file eg/prog/guide.awk -->
- BEGIN {
- TEXTDOMAIN = "guide"
- bindtextdomain(".") # for testing
- print _"Don't Panic"
- print _"The Answer Is", 42
- print "Pardon me, Zaphod who?"
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">Run `<samp><span class="samp">gawk
--gen-po</span></samp>' to create the <samp><span
class="file">.po</span></samp> file:
-
-<pre class="example"> $ gawk --gen-po -f guide.awk > guide.po
-</pre>
- <p class="noindent">This produces:
-
-<pre class="example"> <!-- file eg/data/guide.po -->
- #: guide.awk:4
- msgid "Don't Panic"
- msgstr ""
-
- #: guide.awk:5
- msgid "The Answer Is"
- msgstr ""
-
- <!-- endfile -->
-</pre>
- <p>This original portable object file is saved and reused for each language
-into which the application is translated. The <code>msgid</code>
-is the original string and the <code>msgstr</code> is the translation.
-
- <blockquote>
-<b>NOTE:</b> Strings not marked with a leading underscore do not
-appear in the <samp><span class="file">guide.po</span></samp> file.
-</blockquote>
-
- <p>Next, the messages must be translated.
-Here is a translation to a hypothetical dialect of English,
-called “Mellow”:<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
-<pre class="example"> $ cp guide.po guide-mellow.po
- <var>Add translations to</var> guide-mellow.po ...
-</pre>
- <p class="noindent">Following are the translations:
-
-<pre class="example"> <!-- file eg/data/guide-mellow.po -->
- #: guide.awk:4
- msgid "Don't Panic"
- msgstr "Hey man, relax!"
-
- #: guide.awk:5
- msgid "The Answer Is"
- msgstr "Like, the scoop is"
-
- <!-- endfile -->
-</pre>
- <p><a name="index-Linux-1382"></a><a
name="index-GNU_002fLinux-1383"></a>The next step is to make the directory to
hold the binary message object
-file and then to create the <samp><span class="file">guide.mo</span></samp>
file.
-The directory layout shown here is standard for GNU <code>gettext</code> on
-GNU/Linux systems. Other versions of <code>gettext</code> may use a different
-layout:
-
-<pre class="example"> $ mkdir en_US en_US/LC_MESSAGES
-</pre>
- <p><a
name="index-_0040code_007b_002epo_007d-files_002c-converting-to-_0040code_007b_002emo_007d-1384"></a><a
name="index-files_002c-_0040code_007b_002epo_007d_002c-converting-to-_0040code_007b_002emo_007d-1385"></a><a
name="index-_0040code_007b_002emo_007d-files_002c-converting-from-_0040code_007b_002epo_007d-1386"></a><a
name="index-files_002c-_0040code_007b_002emo_007d_002c-converting-from-_0040code_007b_002epo_007d-1387"></a><a
name="index-portable-object-files_002c-converting-to-message-object-files-1388"></a><a
name="index-files_002c-portable-object_002c-converting-to-message-object-files-1389"></a><a
name="index-message-object-files_002c-converting-from-portable-object-files-1390"></a><a
name="index-files_002c-message-object_002c-converting-from-portable-object-files-1391"></a><a
name="index-_0040command_007bmsgfmt_007d-utility-1392"></a>The <samp><span
class="command">msgfmt</span></samp> utility does the conversion from
human-readable
-<samp><span class="file">.po</span></samp> file to machine-readable
<samp><span class="file">.mo</span></samp> file.
-By default, <samp><span class="command">msgfmt</span></samp> creates a file
named <samp><span class="file">messages</span></samp>.
-This file must be renamed and placed in the proper directory so that
-<samp><span class="command">gawk</span></samp> can find it:
-
-<pre class="example"> $ msgfmt guide-mellow.po
- $ mv messages en_US/LC_MESSAGES/guide.mo
-</pre>
- <p>Finally, we run the program to test it:
-
-<pre class="example"> $ gawk -f guide.awk
- -| Hey man, relax!
- -| Like, the scoop is 42
- -| Pardon me, Zaphod who?
-</pre>
- <p>If the three replacement functions for <code>dcgettext</code>,
<code>dcngettext</code>
-and <code>bindtextdomain</code>
-(see <a href="I18N-Portability.html#I18N-Portability">I18N Portability</a>)
-are in a file named <samp><span class="file">libintl.awk</span></samp>,
-then we can run <samp><span class="file">guide.awk</span></samp> unchanged as
follows:
-
-<pre class="example"> $ gawk --posix -f guide.awk -f libintl.awk
- -| Don't Panic
- -| The Answer Is 42
- -| Pardon me, Zaphod who?
-</pre>
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Perhaps it would be better if it were
-called “Hippy.” Ah, well.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/I18N-Functions.html
===================================================================
RCS file: manual/html_node/I18N-Functions.html
diff -N manual/html_node/I18N-Functions.html
--- manual/html_node/I18N-Functions.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,93 +0,0 @@
-<html lang="en">
-<head>
-<title>I18N Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="prev" href="Bitwise-Functions.html#Bitwise-Functions"
title="Bitwise Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="I18N-Functions"></a>Previous: <a rel="previous" accesskey="p"
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.7 Using <samp><span
class="command">gawk</span></samp>'s String-Translation Functions</h4>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-string_002dtranslation-functions-1268"></a><a
name="index-functions_002c-string_002dtranslation-1269"></a><a
name="index-internationalization-1270"></a><a
name="index-_0040command_007bawk_007d-programs_002c-internationalizing-1271"></a>
-<samp><span class="command">gawk</span></samp> provides facilities for
internationalizing <samp><span class="command">awk</span></samp> programs.
-These include the functions described in the following list.
-The descriptions here are purposely brief.
-See <a
href="Internationalization.html#Internationalization">Internationalization</a>,
-for the full story.
-Optional parameters are enclosed in square brackets ([ ]):
-
-
-<a
name="index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1272"></a>
-<dl><dt><code>dcgettext(</code><var>string</var> <span
class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This function returns the translation
of <var>string</var> in
-text domain <var>domain</var> for locale category <var>category</var>.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p><a
name="index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1273"></a><br><dt><code>dcngettext(</code><var>string1</var><code>,
</code><var>string2</var><code>, </code><var>number</var> <span
class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This function returns the plural form
used for <var>number</var> of the
-translation of <var>string1</var> and <var>string2</var> in text domain
-<var>domain</var> for locale category <var>category</var>. <var>string1</var>
is the
-English singular variant of a message, and <var>string2</var> the English
plural
-variant of the same message.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1274"></a><br><dt><code>bindtextdomain(</code><var>directory</var>
<span class="roman">[</span><code>, </code><var>domain</var><span
class="roman">]</span><code>)</code><dd>This function allows you to specify the
directory in which
-<samp><span class="command">gawk</span></samp> will look for message
translation files, in case they
-will not or cannot be placed in the “standard” locations
-(e.g., during testing).
-It returns the directory in which <var>domain</var> is “bound.”
-
- <p>The default <var>domain</var> is the value of <code>TEXTDOMAIN</code>.
-If <var>directory</var> is the null string (<code>""</code>), then
-<code>bindtextdomain</code> returns the current binding for the
-given <var>domain</var>.
-</dl>
- <!-- ENDOFRANGE funcbi -->
-<!-- ENDOFRANGE bifunc -->
-
- </body></html>
-
Index: manual/html_node/I18N-Portability.html
===================================================================
RCS file: manual/html_node/I18N-Portability.html
diff -N manual/html_node/I18N-Portability.html
--- manual/html_node/I18N-Portability.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,128 +0,0 @@
-<html lang="en">
-<head>
-<title>I18N Portability - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Translator-i18n.html#Translator-i18n" title="Translator
i18n">
-<link rel="prev" href="Printf-Ordering.html#Printf-Ordering" title="Printf
Ordering">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="I18N-Portability"></a>Previous: <a rel="previous" accesskey="p"
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a>,
-Up: <a rel="up" accesskey="u"
href="Translator-i18n.html#Translator-i18n">Translator i18n</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">9.4.3 <samp><span class="command">awk</span></samp>
Portability Issues</h4>
-
-<p><a name="index-portability_002c-internationalization-and-1376"></a><a
name="index-internationalization_002c-localization_002c-portability-and-1377"></a><samp><span
class="command">gawk</span></samp>'s internationalization features were
purposely chosen to
-have as little impact as possible on the portability of <samp><span
class="command">awk</span></samp>
-programs that use them to other versions of <samp><span
class="command">awk</span></samp>.
-Consider this program:
-
-<pre class="example"> BEGIN {
- TEXTDOMAIN = "guide"
- if (Test_Guide) # set with -v
- bindtextdomain("/test/guide/messages")
- print _"don't panic!"
- }
-</pre>
- <p class="noindent">As written, it won't work on other versions of
<samp><span class="command">awk</span></samp>.
-However, it is actually almost portable, requiring very little
-change:
-
-
-<a
name="index-_0040code_007bTEXTDOMAIN_007d-variable_002c-portability-and-1378"></a>
-<ul><li>Assignments to <code>TEXTDOMAIN</code> won't have any effect,
-since <code>TEXTDOMAIN</code> is not special in other <samp><span
class="command">awk</span></samp> implementations.
-
- <li>Non-GNU versions of <samp><span class="command">awk</span></samp>
treat marked strings
-as the concatenation of a variable named <code>_</code> with the string
-following it.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
Typically, the variable <code>_</code> has
-the null string (<code>""</code>) as its value, leaving the original string
constant as
-the result.
-
- <li>By defining “dummy” functions to replace
<code>dcgettext</code>, <code>dcngettext</code>
-and <code>bindtextdomain</code>, the <samp><span
class="command">awk</span></samp> program can be made to run, but
-all the messages are output in the original language.
-For example:
-
- <p><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1379"></a><a
name="index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1380"></a><a
name="index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1381"></a>
- <pre class="example"> <!-- file eg/lib/libintl.awk -->
- function bindtextdomain(dir, domain)
- {
- return dir
- }
-
- function dcgettext(string, domain, category)
- {
- return string
- }
-
- function dcngettext(string1, string2, number, domain, category)
- {
- return (number == 1 ? string1 : string2)
- }
- <!-- endfile -->
- </pre>
- <li>The use of positional specifications in <code>printf</code> or
-<code>sprintf</code> is <em>not</em> portable.
-To support <code>gettext</code> at the C level, many systems' C versions of
-<code>sprintf</code> do support positional specifiers. But it works only if
-enough arguments are supplied in the function call. Many versions of
-<samp><span class="command">awk</span></samp> pass <code>printf</code> formats
and arguments unchanged to the
-underlying C library version of <code>sprintf</code>, but only one format and
-argument at a time. What happens if a positional specification is
-used is anybody's guess.
-However, since the positional specifications are primarily for use in
-<em>translated</em> format strings, and since non-GNU <samp><span
class="command">awk</span></samp>s never
-retrieve the translated string, this should not be a problem in practice.
-</ul>
- <!-- ENDOFRANGE inap -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This is good fodder for an “Obfuscated
-<samp><span class="command">awk</span></samp>” contest.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/I18N-and-L10N.html
===================================================================
RCS file: manual/html_node/I18N-and-L10N.html
diff -N manual/html_node/I18N-and-L10N.html
--- manual/html_node/I18N-and-L10N.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-<html lang="en">
-<head>
-<title>I18N and L10N - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="next" href="Explaining-gettext.html#Explaining-gettext"
title="Explaining gettext">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="I18N-and-L10N"></a>Next: <a rel="next" accesskey="n"
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a>,
-Up: <a rel="up" accesskey="u"
href="Internationalization.html#Internationalization">Internationalization</a>
-<hr><br>
-</div>
-
-<h3 class="section">9.1 Internationalization and Localization</h3>
-
-<p><a name="index-internationalization-1303"></a><a
name="index-localization_002c-See-internationalization_0040comma_007b_007d-localization-1304"></a><a
name="index-localization-1305"></a><dfn>Internationalization</dfn> means
writing (or modifying) a program once,
-in such a way that it can use multiple languages without requiring
-further source-code changes.
-<dfn>Localization</dfn> means providing the data necessary for an
-internationalized program to work in a particular language.
-Most typically, these terms refer to features such as the language
-used for printing error messages, the language used to read
-responses, and information related to how numerical and
-monetary values are printed and read.
-
- </body></html>
-
Index: manual/html_node/I_002fO-And-BEGIN_002fEND.html
===================================================================
RCS file: manual/html_node/I_002fO-And-BEGIN_002fEND.html
diff -N manual/html_node/I_002fO-And-BEGIN_002fEND.html
--- manual/html_node/I_002fO-And-BEGIN_002fEND.html 31 Aug 2004 22:04:10
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,97 +0,0 @@
-<html lang="en">
-<head>
-<title>I/O And BEGIN/END - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="BEGIN_002fEND.html#BEGIN_002fEND" title="BEGIN/END">
-<link rel="prev" href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND"
title="Using BEGIN/END">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="I_002fO-And-BEGIN_002fEND"></a>Previous: <a rel="previous"
accesskey="p" href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using
BEGIN/END</a>,
-Up: <a rel="up" accesskey="u"
href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>
-<hr><br>
-</div>
-
-<h5 class="subsubsection">6.1.4.2 Input/Output from <code>BEGIN</code> and
<code>END</code> Rules</h5>
-
-<p><a
name="index-input_002foutput_002c-from-_0040code_007bBEGIN_007d-and-_0040code_007bEND_007d-916"></a>There
are several (sometimes subtle) points to remember when doing I/O
-from a <code>BEGIN</code> or <code>END</code> rule.
-The first has to do with the value of <code>$0</code> in a <code>BEGIN</code>
-rule. Because <code>BEGIN</code> rules are executed before any input is read,
-there simply is no input record, and therefore no fields, when
-executing <code>BEGIN</code> rules. References to <code>$0</code> and the
fields
-yield a null string or zero, depending upon the context. One way
-to give <code>$0</code> a real value is to execute a <code>getline</code>
command
-without a variable (see <a href="Getline.html#Getline">Getline</a>).
-Another way is simply to assign a value to <code>$0</code>.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-917"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-918"></a><a
name="index-_0040code_007bprint_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-919"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bprint_007d-statement-and-920"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bprint_007d-statement-and-921"></a>The
second point is similar to the first but from the other direction.
-Traditionally, due largely to implementation issues, <code>$0</code> and
-<code>NF</code> were <em>undefined</em> inside an <code>END</code> rule.
-The POSIX standard specifies that <code>NF</code> is available in an
<code>END</code>
-rule. It contains the number of fields from the last input record.
-Most probably due to an oversight, the standard does not say that
<code>$0</code>
-is also preserved, although logically one would think that it should be.
-In fact, <samp><span class="command">gawk</span></samp> does preserve the
value of <code>$0</code> for use in
-<code>END</code> rules. Be aware, however, that Unix <samp><span
class="command">awk</span></samp>, and possibly
-other implementations, do not.
-
- <p>The third point follows from the first two. The meaning of `<samp><span
class="samp">print</span></samp>'
-inside a <code>BEGIN</code> or <code>END</code> rule is the same as always:
-`<samp><span class="samp">print $0</span></samp>'. If <code>$0</code> is the
null string, then this prints an
-empty line. Many long time <samp><span class="command">awk</span></samp>
programmers use an unadorned
-`<samp><span class="samp">print</span></samp>' in <code>BEGIN</code> and
<code>END</code> rules, to mean `<samp><span class="samp">print ""<!-- /@w
--></span></samp>',
-relying on <code>$0</code> being null. Although one might generally get away
with
-this in <code>BEGIN</code> rules, it is a very bad idea in <code>END</code>
rules,
-at least in <samp><span class="command">gawk</span></samp>. It is also poor
style, since if an empty
-line is needed in the output, the program should print one explicitly.
-
- <p><a
name="index-_0040code_007bnext_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-922"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-923"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-924"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-925"></a>Finally,
the <code>next</code> and <code>nextfile</code> statements are not allowed
-in a <code>BEGIN</code> rule, because the implicit
-read-a-record-and-match-against-the-rules loop has not started yet.
Similarly, those statements
-are not valid in an <code>END</code> rule, since all the input has been read.
-(See <a href="Next-Statement.html#Next-Statement">Next Statement</a>, and see
-<a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a>.)
-<!-- ENDOFRANGE beg -->
-<!-- ENDOFRANGE end -->
-
- </body></html>
-
Index: manual/html_node/I_002fO-Functions.html
===================================================================
RCS file: manual/html_node/I_002fO-Functions.html
diff -N manual/html_node/I_002fO-Functions.html
--- manual/html_node/I_002fO-Functions.html 31 Aug 2004 22:04:10 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,234 +0,0 @@
-<html lang="en">
-<head>
-<title>I/O Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="prev" href="String-Functions.html#String-Functions" title="String
Functions">
-<link rel="next" href="Time-Functions.html#Time-Functions" title="Time
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="I_002fO-Functions"></a>Next: <a rel="next" accesskey="n"
href="Time-Functions.html#Time-Functions">Time Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="String-Functions.html#String-Functions">String Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.4 Input/Output Functions</h4>
-
-<p>The following functions relate to input/output (I/O).
-Optional parameters are enclosed in square brackets ([ ]):
-
- <dl>
-<dt><code>close(</code><var>filename</var> <span class="roman">[</span><code>,
</code><var>how</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bclose_007d-function-1211"></a><a
name="index-files_002c-closing-1212"></a>Close the file <var>filename</var> for
input or output. Alternatively, the
-argument may be a shell command that was used for creating a coprocess, or
-for redirecting to or from a pipe; then the coprocess or pipe is closed.
-See <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>,
-for more information.
-
- <p>When closing a coprocess, it is occasionally useful to first close
-one end of the two-way pipe and then to close the other. This is done
-by providing a second argument to <code>close</code>. This second argument
-should be one of the two string values <code>"to"</code> or
<code>"from"</code>,
-indicating which end of the pipe to close. Case in the string does
-not matter.
-See <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>,
-which discusses this feature in more detail and gives an example.
-
- <br><dt><code>fflush(</code><span
class="roman">[</span><var>filename</var><span
class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bfflush_007d-function-1213"></a>Flush any buffered
output associated with <var>filename</var>, which is either a
-file opened for writing or a shell command for redirecting output to
-a pipe or coprocess.
-
- <p><a
name="index-portability_002c-_0040code_007bfflush_007d-function-and-1214"></a><a
name="index-buffers_002c-flushing-1215"></a><a
name="index-output_002c-buffering-1216"></a>Many utility programs
<dfn>buffer</dfn> their output; i.e., they save information
-to write to a disk file or terminal in memory until there is enough
-for it to be worthwhile to send the data to the output device.
-This is often more efficient than writing
-every little bit of information as soon as it is ready. However, sometimes
-it is necessary to force a program to <dfn>flush</dfn> its buffers; that is,
-write the information to its destination, even if a buffer is not full.
-This is the purpose of the <code>fflush</code> function—<samp><span
class="command">gawk</span></samp> also
-buffers its output and the <code>fflush</code> function forces
-<samp><span class="command">gawk</span></samp> to flush its buffers.
-
- <p><code>fflush</code> was added to the Bell Laboratories research
-version of <samp><span class="command">awk</span></samp> in 1994; it is not
part of the POSIX standard and is
-not available if <samp><span class="option">--posix</span></samp> has been
specified on the
-command line (see <a href="Options.html#Options">Options</a>).
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bfflush_007d-function-in-1217"></a><samp><span
class="command">gawk</span></samp> extends the <code>fflush</code> function in
two ways. The first
-is to allow no argument at all. In this case, the buffer for the
-standard output is flushed. The second is to allow the null string
-(<code>""</code><!-- /@w -->) as the argument. In this case, the buffers for
-<em>all</em> open output files and pipes are flushed.
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a
name="index-troubleshooting_002c-_0040code_007bfflush_007d-function-1218"></a><code>fflush</code>
returns zero if the buffer is successfully flushed;
-otherwise, it returns −1.
-In the case where all buffers are flushed, the return value is zero
-only if all buffers were flushed successfully. Otherwise, it is
-−1, and <samp><span class="command">gawk</span></samp> warns about the
problem <var>filename</var>.
-
- <p><samp><span class="command">gawk</span></samp> also issues a warning
message if you attempt to flush
-a file or pipe that was opened for reading (such as with <code>getline</code>),
-or if <var>filename</var> is not an open file, pipe, or coprocess.
-In such a case, <code>fflush</code> returns −1, as well.
-
- <br><dt><code>system(</code><var>command</var><code>)</code><dd><a
name="index-_0040code_007bsystem_007d-function-1219"></a><a
name="index-interacting-with-other-programs-1220"></a>Executes operating-system
-commands and then returns to the <samp><span class="command">awk</span></samp>
program. The <code>system</code>
-function executes the command given by the string <var>command</var>.
-It returns the status returned by the command that was executed as
-its value.
-
- <p>For example, if the following fragment of code is put in your
<samp><span class="command">awk</span></samp>
-program:
-
- <pre class="example"> END {
- system("date | mail -s 'awk run done' root")
- }
- </pre>
- <p class="noindent">the system administrator is sent mail when the
<samp><span class="command">awk</span></samp> program
-finishes processing input and begins its end-of-input processing.
-
- <p>Note that redirecting <code>print</code> or <code>printf</code> into a
pipe is often
-enough to accomplish your task. If you need to run many commands, it
-is more efficient to simply print them down a pipeline to the shell:
-
- <pre class="example"> while (<var>more stuff to do</var>)
- print <var>command</var> | "/bin/sh"
- close("/bin/sh")
- </pre>
- <p class="noindent"><a
name="index-troubleshooting_002c-_0040code_007bsystem_007d-function-1221"></a>However,
if your <samp><span class="command">awk</span></samp>
-program is interactive, <code>system</code> is useful for cranking up large
-self-contained programs, such as a shell or an editor.
-Some operating systems cannot implement the <code>system</code> function.
-<code>system</code> causes a fatal error if it is not supported.
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Interactive Versus Noninteractive
Buffering</h4>
-
-<p><a name="index-advanced-features_002c-buffering-1222"></a><a
name="index-buffering_002c-interactive-vs_002e-noninteractive-1223"></a>
-As a side point, buffering issues can be even more confusing, depending
-upon whether your program is <dfn>interactive</dfn>, i.e., communicating
-with a user sitting at a keyboard.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
-<!-- Thanks to address@hidden for this example, and for -->
-<!-- motivating me to write this section. -->
-<p>Interactive programs generally <dfn>line buffer</dfn> their output; i.e.,
they
-write out every line. Noninteractive programs wait until they have
-a full buffer, which may be many lines of output.
-Here is an example of the difference:
-
-<pre class="example"> $ awk '{ print $1 + $2 }'
- 1 1
- -| 2
- 2 3
- -| 5
- <kbd>Ctrl-d</kbd>
-</pre>
- <p class="noindent">Each line of output is printed immediately. Compare
that behavior
-with this example:
-
-<pre class="example"> $ awk '{ print $1 + $2 }' | cat
- 1 1
- 2 3
- <kbd>Ctrl-d</kbd>
- -| 2
- -| 5
-</pre>
- <p class="noindent">Here, no output is printed until after the
<kbd>Ctrl-d</kbd> is typed, because
-it is all buffered and sent down the pipe to <samp><span
class="command">cat</span></samp> in one shot.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Controlling Output Buffering with
<code>system</code></h4>
-
-<p><a name="index-advanced-features_002c-buffering-1224"></a><a
name="index-buffers_002c-flushing-1225"></a><a
name="index-buffering_002c-input_002foutput-1226"></a><a
name="index-output_002c-buffering-1227"></a>
-The <code>fflush</code> function provides explicit control over output
buffering for
-individual files and pipes. However, its use is not portable to many other
-<samp><span class="command">awk</span></samp> implementations. An alternative
method to flush output
-buffers is to call <code>system</code> with a null string as its argument:
-
-<pre class="example"> system("") # flush output
-</pre>
- <p class="noindent"><samp><span class="command">gawk</span></samp> treats
this use of the <code>system</code> function as a special
-case and is smart enough not to run a shell (or other command
-interpreter) with the empty command. Therefore, with <samp><span
class="command">gawk</span></samp>, this
-idiom is not only useful, it is also efficient. While this method should work
-with other <samp><span class="command">awk</span></samp> implementations, it
does not necessarily avoid
-starting an unnecessary shell. (Other implementations may only
-flush the buffer associated with the standard output and not necessarily
-all buffered output.)
-
- <p>If you think about what a programmer expects, it makes sense that
-<code>system</code> should flush any pending output. The following program:
-
-<pre class="example"> BEGIN {
- print "first print"
- system("echo system echo")
- print "second print"
- }
-</pre>
- <p class="noindent">must print:
-
-<pre class="example"> first print
- system echo
- second print
-</pre>
- <p class="noindent">and not:
-
-<pre class="example"> system echo
- first print
- second print
-</pre>
- <p>If <samp><span class="command">awk</span></samp> did not flush its
buffers before calling <code>system</code>,
-you would see the latter (undesirable) output.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> A program is interactive
-if the standard output is connected
-to a terminal device.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Id-Program.html
===================================================================
RCS file: manual/html_node/Id-Program.html
diff -N manual/html_node/Id-Program.html
--- manual/html_node/Id-Program.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,171 +0,0 @@
-<html lang="en">
-<head>
-<title>Id Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="prev" href="Egrep-Program.html#Egrep-Program" title="Egrep Program">
-<link rel="next" href="Split-Program.html#Split-Program" title="Split Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Id-Program"></a>Next: <a rel="next" accesskey="n"
href="Split-Program.html#Split-Program">Split Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Egrep-Program.html#Egrep-Program">Egrep Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.3 Printing out User Information</h4>
-
-<p><a name="index-printing_002c-user-information-1762"></a><a
name="index-users_002c-information-about_002c-printing-1763"></a><a
name="index-_0040command_007bid_007d-utility-1764"></a>The <samp><span
class="command">id</span></samp> utility lists a user's real and effective user
ID numbers,
-real and effective group ID numbers, and the user's group set, if any.
-<samp><span class="command">id</span></samp> only prints the effective user ID
and group ID if they are
-different from the real ones. If possible, <samp><span
class="command">id</span></samp> also supplies the
-corresponding user and group names. The output might look like this:
-
-<pre class="example"> $ id
- -| uid=2076(arnold) gid=10(staff) groups=10(staff),4(tty)
-</pre>
- <p>This information is part of what is provided by <samp><span
class="command">gawk</span></samp>'s
-<code>PROCINFO</code> array (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-However, the <samp><span class="command">id</span></samp> utility provides a
more palatable output than just
-individual numbers.
-
- <p>Here is a simple version of <samp><span class="command">id</span></samp>
written in <samp><span class="command">awk</span></samp>.
-It uses the user database library functions
-(see <a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>)
-and the group database library functions
-(see <a href="Group-Functions.html#Group-Functions">Group Functions</a>):
-
- <p>The program is fairly straightforward. All the work is done in the
-<code>BEGIN</code> rule. The user and group ID numbers are obtained from
-<code>PROCINFO</code>.
-The code is repetitive. The entry in the user database for the real user ID
-number is split into parts at the `<samp><span class="samp">:</span></samp>'.
The name is the first field.
-Similar code is used for the effective user ID number and the group
-numbers:
-
- <p><a name="index-_0040code_007bid_002eawk_007d-program-1765"></a>
-<pre class="example"> <!-- file eg/prog/id.awk -->
- # id.awk --- implement id in awk
- #
- # Requires user and group library functions
- <!-- endfile -->
- <!-- file eg/prog/id.awk -->
- # output is:
- # uid=12(foo) euid=34(bar) gid=3(baz) \
- # egid=5(blat) groups=9(nine),2(two),1(one)
-
- BEGIN \
- {
- uid = PROCINFO["uid"]
- euid = PROCINFO["euid"]
- gid = PROCINFO["gid"]
- egid = PROCINFO["egid"]
-
- printf("uid=%d", uid)
- pw = getpwuid(uid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
-
- if (euid != uid) {
- printf(" euid=%d", euid)
- pw = getpwuid(euid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- }
-
- printf(" gid=%d", gid)
- pw = getgrgid(gid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
-
- if (egid != gid) {
- printf(" egid=%d", egid)
- pw = getgrgid(egid)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- }
-
- for (i = 1; ("group" i) in PROCINFO; i++) {
- if (i == 1)
- printf(" groups=")
- group = PROCINFO["group" i]
- printf("%d", group)
- pw = getgrgid(group)
- if (pw != "") {
- split(pw, a, ":")
- printf("(%s)", a[1])
- }
- if (("group" (i+1)) in PROCINFO)
- printf(",")
- }
-
- print ""
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-_0040code_007bin_007d-operator-1766"></a>The test in the
<code>for</code> loop is worth noting.
-Any supplementary groups in the <code>PROCINFO</code> array have the
-indices <code>"group1"</code> through
<code>"group</code><var>N</var><code>"</code> for some
-<var>N</var>, i.e., the total number of supplementary groups.
-However, we don't know in advance how many of these groups
-there are.
-
- <p>This loop works by starting at one, concatenating the value with
-<code>"group"</code>, and then using <code>in</code> to see if that value is
-in the array. Eventually, <code>i</code> is incremented past
-the last group in the array and the loop exits.
-
- <p>The loop is also correct if there are <em>no</em> supplementary
-groups; then the condition is false the first time it's
-tested, and the loop body never executes.
-
-<!-- exercise!!! -->
-</body></html>
-
Index: manual/html_node/If-Statement.html
===================================================================
RCS file: manual/html_node/If-Statement.html
diff -N manual/html_node/If-Statement.html
--- manual/html_node/If-Statement.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-<html lang="en">
-<head>
-<title>If Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="next" href="While-Statement.html#While-Statement" title="While
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="If-Statement"></a>Next: <a rel="next" accesskey="n"
href="While-Statement.html#While-Statement">While Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.1 The <code>if</code>-<code>else</code>
Statement</h4>
-
-<p><a name="index-_0040code_007bif_007d-statement-950"></a>The
<code>if</code>-<code>else</code> statement is <samp><span
class="command">awk</span></samp>'s decision-making
-statement. It looks like this:
-
-<pre class="example"> if (<var>condition</var>) <var>then-body</var> <span
class="roman">[</span>else <var>else-body</var><span class="roman">]</span>
-</pre>
- <p class="noindent">The <var>condition</var> is an expression that controls
what the rest of the
-statement does. If the <var>condition</var> is true, <var>then-body</var> is
-executed; otherwise, <var>else-body</var> is executed.
-The <code>else</code> part of the statement is
-optional. The condition is considered false if its value is zero or
-the null string; otherwise, the condition is true.
-Refer to the following:
-
-<pre class="example"> if (x % 2 == 0)
- print "x is even"
- else
- print "x is odd"
-</pre>
- <p>In this example, if the expression `<samp><span class="samp">x % 2 ==
0</span></samp>' is true (that is,
-if the value of <code>x</code> is evenly divisible by two), then the first
-<code>print</code> statement is executed; otherwise, the second
<code>print</code>
-statement is executed.
-If the <code>else</code> keyword appears on the same line as
<var>then-body</var> and
-<var>then-body</var> is not a compound statement (i.e., not surrounded by
-curly braces), then a semicolon must separate <var>then-body</var> from
-the <code>else</code>.
-To illustrate this, the previous example can be rewritten as:
-
-<pre class="example"> if (x % 2 == 0) print "x is even"; else
- print "x is odd"
-</pre>
- <p class="noindent">If the `<samp><span class="samp">;</span></samp>' is
left out, <samp><span class="command">awk</span></samp> can't interpret the
statement and
-it produces a syntax error. Don't actually write programs this way,
-because a human reader might fail to see the <code>else</code> if it is not
-the first thing on its line.
-
- </body></html>
-
Index: manual/html_node/Igawk-Program.html
===================================================================
RCS file: manual/html_node/Igawk-Program.html
diff -N manual/html_node/Igawk-Program.html
--- manual/html_node/Igawk-Program.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,471 +0,0 @@
-<html lang="en">
-<head>
-<title>Igawk Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Simple-Sed.html#Simple-Sed" title="Simple Sed">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Igawk-Program"></a>Previous: <a rel="previous" accesskey="p"
href="Simple-Sed.html#Simple-Sed">Simple Sed</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.9 An Easy Way to Use Library Functions</h4>
-
-<!-- STARTOFRANGE libfex -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-example-program-for-using-1817"></a><!--
STARTOFRANGE flibex -->
-<a
name="index-functions_002c-library_002c-example-program-for-using-1818"></a>Using
library functions in <samp><span class="command">awk</span></samp> can be very
beneficial. It
-encourages code reuse and the writing of general functions. Programs are
-smaller and therefore clearer.
-However, using library functions is only easy when writing <samp><span
class="command">awk</span></samp>
-programs; it is painful when running them, requiring multiple <samp><span
class="option">-f</span></samp>
-options. If <samp><span class="command">gawk</span></samp> is unavailable,
then so too is the <samp><span class="env">AWKPATH</span></samp>
-environment variable and the ability to put <samp><span
class="command">awk</span></samp> functions into a
-library directory (see <a href="Options.html#Options">Options</a>).
-It would be nice to be able to write programs in the following manner:
-
-<pre class="example"> # library functions
- @include getopt.awk
- @include join.awk
- ...
-
- # main program
- BEGIN {
- while ((c = getopt(ARGC, ARGV, "a:b:cde")) != -1)
- ...
- ...
- }
-</pre>
- <p>The following program, <samp><span class="file">igawk.sh</span></samp>,
provides this service.
-It simulates <samp><span class="command">gawk</span></samp>'s searching of the
<samp><span class="env">AWKPATH</span></samp> variable
-and also allows <dfn>nested</dfn> includes; i.e., a file that is included
-with `<samp><span class="samp">@include</span></samp>' can contain further
`<samp><span class="samp">@include</span></samp>' statements.
-<samp><span class="command">igawk</span></samp> makes an effort to only
include files once, so that nested
-includes don't accidentally include a library function twice.
-
- <p><samp><span class="command">igawk</span></samp> should behave just like
<samp><span class="command">gawk</span></samp> externally. This
-means it should accept all of <samp><span class="command">gawk</span></samp>'s
command-line arguments,
-including the ability to have multiple source files specified via
-<samp><span class="option">-f</span></samp>, and the ability to mix
command-line and library source files.
-
- <p>The program is written using the POSIX Shell (<samp><span
class="command">sh</span></samp>) command
-language.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> It works
as follows:
-
- <ol type=1 start=1>
-<li>Loop through the arguments, saving anything that doesn't represent
-<samp><span class="command">awk</span></samp> source code for later, when the
expanded program is run.
-
- <li>For any arguments that do represent <samp><span
class="command">awk</span></samp> text, put the arguments into
-a shell variable that will be expanded. There are two cases:
-
- <ol type=a start=1>
-<li>Literal text, provided with <samp><span
class="option">--source</span></samp> or <samp><span
class="option">--source=</span></samp>. This
-text is just appended directly.
-
- <li>Source file names, provided with <samp><span
class="option">-f</span></samp>. We use a neat trick and append
-`<samp><span class="samp">@include </span><var>filename</var></samp>' to the
shell variable's contents. Since the file-inclusion
-program works the way <samp><span class="command">gawk</span></samp> does,
this gets the text
-of the file included into the program at the correct point.
- </ol>
-
- <li>Run an <samp><span class="command">awk</span></samp> program
(naturally) over the shell variable's contents to expand
-`<samp><span class="samp">@include</span></samp>' statements. The expanded
program is placed in a second
-shell variable.
-
- <li>Run the expanded program with <samp><span
class="command">gawk</span></samp> and any other original command-line
-arguments that the user supplied (such as the data file names).
- </ol>
-
- <p>This program uses shell variables extensively; for storing command line
arguments,
-the text of the <samp><span class="command">awk</span></samp> program that
will expand the user's program, for the
-user's original program, and for the expanded program. Doing so removes some
-potential problems that might arise were we to use temporary files instead,
-at the cost of making the script somewhat more complicated.
-
- <p>The initial part of the program turns on shell tracing if the first
-argument is `<samp><span class="samp">debug</span></samp>'.
-
- <p>The next part loops through all the command-line arguments.
-There are several cases of interest:
-
- <dl>
-<dt><code>--</code><dd>This ends the arguments to <samp><span
class="command">igawk</span></samp>. Anything else should be passed on
-to the user's <samp><span class="command">awk</span></samp> program without
being evaluated.
-
- <br><dt><code>-W</code><dd>This indicates that the next option is
specific to <samp><span class="command">gawk</span></samp>. To make
-argument processing easier, the <samp><span class="option">-W</span></samp> is
appended to the front of the
-remaining arguments and the loop continues. (This is an <samp><span
class="command">sh</span></samp>
-programming trick. Don't worry about it if you are not familiar with
-<samp><span class="command">sh</span></samp>.)
-
- <br><dt><code>-v</code><span class="roman">,</span><code>
-F</code><dd>These are saved and passed on to <samp><span
class="command">gawk</span></samp>.
-
- <br><dt><code>-f</code><span class="roman">,</span><code>
--file</code><span class="roman">,</span><code> --file=</code><span
class="roman">,</span><code> -Wfile=</code><dd>The file name is appended to the
shell variable <code>program</code> with an
-`<samp><span class="samp">@include</span></samp>' statement.
-The <samp><span class="command">expr</span></samp> utility is used to remove
the leading option part of the
-argument (e.g., `<samp><span class="samp">--file=</span></samp>').
-(Typical <samp><span class="command">sh</span></samp> usage would be to use
the <samp><span class="command">echo</span></samp> and <samp><span
class="command">sed</span></samp>
-utilities to do this work. Unfortunately, some versions of <samp><span
class="command">echo</span></samp> evaluate
-escape sequences in their arguments, possibly mangling the program text.
-Using <samp><span class="command">expr</span></samp> avoids this problem.)
-
- <br><dt><code>--source</code><span class="roman">,</span><code>
--source=</code><span class="roman">,</span><code> -Wsource=</code><dd>The
source text is appended to <code>program</code>.
-
- <br><dt><code>--version</code><span class="roman">,</span><code>
-Wversion</code><dd><samp><span class="command">igawk</span></samp> prints its
version number, runs `<samp><span class="samp">gawk --version</span></samp>'
-to get the <samp><span class="command">gawk</span></samp> version information,
and then exits.
-</dl>
-
- <p>If none of the <samp><span class="option">-f</span></samp>, <samp><span
class="option">--file</span></samp>, <samp><span
class="option">-Wfile</span></samp>, <samp><span
class="option">--source</span></samp>,
-or <samp><span class="option">-Wsource</span></samp> arguments are supplied,
then the first nonoption argument
-should be the <samp><span class="command">awk</span></samp> program. If there
are no command-line
-arguments left, <samp><span class="command">igawk</span></samp> prints an
error message and exits.
-Otherwise, the first argument is appended to <code>program</code>.
-In any case, after the arguments have been processed,
-<code>program</code> contains the complete text of the original <samp><span
class="command">awk</span></samp>
-program.
-
- <p>The program is as follows:
-
- <p><a name="index-_0040code_007bigawk_002esh_007d-program-1819"></a>
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- #! /bin/sh
- # igawk --- like gawk but do @include processing
- <!-- endfile -->
- <!-- file eg/prog/igawk.sh -->
- if [ "$1" = debug ]
- then
- set -x
- shift
- fi
-
- # A literal newline, so that program text is formmatted correctly
- n='
- '
-
- # Initialize variables to empty
- program=
- opts=
-
- while [ $# -ne 0 ] # loop over arguments
- do
- case $1 in
- --) shift; break;;
-
- -W) shift
- # The ${x?'message here'} construct prints a
- # diagnostic if $x is the null string
- set -- -W"address@hidden'missing operand'}"
- continue;;
-
- -[vF]) opts="$opts $1 '${2?'missing operand'}'"
- shift;;
-
- -[vF]*) opts="$opts '$1'" ;;
-
- -f) program="address@hidden ${2?'missing operand'}"
- shift;;
-
- -f*) f=`expr "$1" : '-f\(.*\)'`
- program="address@hidden $f";;
-
- -[W-]file=*)
- f=`expr "$1" : '-.file=\(.*\)'`
- program="address@hidden $f";;
-
- -[W-]file)
- program="address@hidden ${2?'missing operand'}"
- shift;;
-
- -[W-]source=*)
- t=`expr "$1" : '-.source=\(.*\)'`
- program="$program$n$t";;
-
- -[W-]source)
- program="$program$n${2?'missing operand'}"
- shift;;
-
- -[W-]version)
- echo igawk: version 2.0 1>&2
- gawk --version
- exit 0 ;;
-
- -[W-]*) opts="$opts '$1'" ;;
-
- *) break;;
- esac
- shift
- done
-
- if [ -z "$program" ]
- then
- program=${1?'missing program'}
- shift
- fi
-
- # At this point, `program' has the program.
- <!-- endfile -->
-</pre>
- <p>The <samp><span class="command">awk</span></samp> program to process
`<samp><span class="samp">@include</span></samp>' directives
-is stored in the shell variable <code>expand_prog</code>. Doing this keeps
-the shell script readable. The <samp><span class="command">awk</span></samp>
program
-reads through the user's program, one line at a time, using
<code>getline</code>
-(see <a href="Getline.html#Getline">Getline</a>). The input
-file names and `<samp><span class="samp">@include</span></samp>' statements
are managed using a stack.
-As each `<samp><span class="samp">@include</span></samp>' is encountered, the
current file name is
-“pushed” onto the stack and the file named in the `<samp><span
class="samp">@include</span></samp>'
-directive becomes the current file name. As each file is finished,
-the stack is “popped,” and the previous input file becomes the
current
-input file again. The process is started by making the original file
-the first one on the stack.
-
- <p>The <code>pathto</code> function does the work of finding the full path
to
-a file. It simulates <samp><span class="command">gawk</span></samp>'s
behavior when searching the
-<samp><span class="env">AWKPATH</span></samp> environment variable
-(see <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>).
-If a file name has a `<samp><span class="samp">/</span></samp>' in it, no path
search is done. Otherwise,
-the file name is concatenated with the name of each directory in
-the path, and an attempt is made to open the generated file name.
-The only way to test if a file can be read in <samp><span
class="command">awk</span></samp> is to go
-ahead and try to read it with <code>getline</code>; this is what
<code>pathto</code>
-does.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a> If the file
can be read, it is closed and the file name
-is returned:
-
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- expand_prog='
-
- function pathto(file, i, t, junk)
- {
- if (index(file, "/") != 0)
- return file
-
- for (i = 1; i <= ndirs; i++) {
- t = (pathlist[i] "/" file)
- if ((getline junk < t) > 0) {
- # found it
- close(t)
- return t
- }
- }
- return ""
- }
- <!-- endfile -->
-</pre>
- <p>The main program is contained inside one <code>BEGIN</code> rule. The
first thing it
-does is set up the <code>pathlist</code> array that <code>pathto</code> uses.
After
-splitting the path on `<samp><span class="samp">:</span></samp>', null
elements are replaced with <code>"."</code>,
-which represents the current directory:
-
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- BEGIN {
- path = ENVIRON["AWKPATH"]
- ndirs = split(path, pathlist, ":")
- for (i = 1; i <= ndirs; i++) {
- if (pathlist[i] == "")
- pathlist[i] = "."
- }
- <!-- endfile -->
-</pre>
- <p>The stack is initialized with <code>ARGV[1]</code>, which will be
<samp><span class="file">/dev/stdin</span></samp>.
-The main loop comes next. Input lines are read in succession. Lines that
-do not start with `<samp><span class="samp">@include</span></samp>' are
printed verbatim.
-If the line does start with `<samp><span class="samp">@include</span></samp>',
the file name is in <code>$2</code>.
-<code>pathto</code> is called to generate the full path. If it cannot, then we
-print an error message and continue.
-
- <p>The next thing to check is if the file is included already. The
-<code>processed</code> array is indexed by the full file name of each included
-file and it tracks this information for us. If the file is
-seen again, a warning message is printed. Otherwise, the new file name is
-pushed onto the stack and processing continues.
-
- <p>Finally, when <code>getline</code> encounters the end of the input file,
the file
-is closed and the stack is popped. When <code>stackptr</code> is less than
zero,
-the program is done:
-
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- stackptr = 0
- input[stackptr] = ARGV[1] # ARGV[1] is first file
-
- for (; stackptr >= 0; stackptr--) {
- while ((getline < input[stackptr]) > 0) {
- if (tolower($1) != "@include") {
- print
- continue
- }
- fpath = pathto($2)
- if (fpath == "") {
- printf("igawk:%s:%d: cannot find %s\n",
- input[stackptr], FNR, $2) > "/dev/stderr"
- continue
- }
- if (! (fpath in processed)) {
- processed[fpath] = input[stackptr]
- input[++stackptr] = fpath # push onto stack
- } else
- print $2, "included in", input[stackptr],
- "already included in",
- processed[fpath] > "/dev/stderr"
- }
- close(input[stackptr])
- }
- }' # close quote ends `expand_prog' variable
-
- processed_program=`gawk -- "$expand_prog" /dev/stdin <<EOF
- $program
- EOF
- `
- <!-- endfile -->
-</pre>
- <p>The shell construct `<samp><var>command</var><span class="samp">
<< </span><var>marker</var></samp>' is called a <dfn>here document</dfn>.
-Everything in the shell script up to the <var>marker</var> is fed to
<var>command</var> as input.
-The shell processes the contents of the here document for variable and command
substitution
-(and possibly other things as well, depending upon the shell).
-
- <p>The shell construct `<samp><span class="samp">`...`</span></samp>' is
called <dfn>command substitution</dfn>.
-The output of the command between the two backquotes (grave accents) is
substituted
-into the command line. It is saved as a single string, even if the results
-contain whitespace.
-
- <p>The expanded program is saved in the variable
<code>processed_program</code>.
-It's done in these steps:
-
- <ol type=1 start=1>
-<li>Run <samp><span class="command">gawk</span></samp> with the `<samp><span
class="samp">@include</span></samp>'-processing program (the
-value of the <code>expand_prog</code> shell variable) on standard input.
-
- <li>Standard input is the contents of the user's program, from the shell
variable <code>program</code>.
-Its contents are fed to <samp><span class="command">gawk</span></samp> via a
here document.
-
- <li>The results of this processing are saved in the shell variable
<code>processed_program</code> by using command substitution.
- </ol>
-
- <p>The last step is to call <samp><span class="command">gawk</span></samp>
with the expanded program,
-along with the original
-options and command-line arguments that the user supplied.
-
-<!-- this causes more problems than it solves, so leave it out. -->
-<pre class="example"> <!-- file eg/prog/igawk.sh -->
- eval gawk $opts -- '"$processed_program"' '"$@"'
- <!-- endfile -->
-</pre>
- <p>The <samp><span class="command">eval</span></samp> command is a shell
construct that reruns the shell's parsing
-process. This keeps things properly quoted.
-
- <p>This version of <samp><span class="command">igawk</span></samp>
represents my fourth attempt at this program.
-There are four key simplifications that make the program work better:
-
- <ul>
-<li>Using `<samp><span class="samp">@include</span></samp>' even for the files
named with <samp><span class="option">-f</span></samp> makes building
-the initial collected <samp><span class="command">awk</span></samp> program
much simpler; all the
-`<samp><span class="samp">@include</span></samp>' processing can be done once.
-
- <li>Not trying to save the line read with <code>getline</code>
-in the <code>pathto</code> function when testing for the
-file's accessibility for use with the main program simplifies things
-considerably.
-<!-- what problem does this engender though - exercise -->
-<!-- answer, reading from "-" or /dev/stdin -->
-
- <li>Using a <code>getline</code> loop in the <code>BEGIN</code> rule does
it all in one
-place. It is not necessary to call out to a separate loop for processing
-nested `<samp><span class="samp">@include</span></samp>' statements.
-
- <li>Instead of saving the expanded program in a temporary file, putting
it in a shell variable
-avoids some potential security problems.
-This has the disadvantage that the script relies upon more features
-of the <samp><span class="command">sh</span></samp> language, making it harder
to follow for those who
-aren't familiar with <samp><span class="command">sh</span></samp>.
-</ul>
-
- <p>Also, this program illustrates that it is often worthwhile to combine
-<samp><span class="command">sh</span></samp> and <samp><span
class="command">awk</span></samp> programming together. You can usually
-accomplish quite a lot, without having to resort to low-level programming
-in C or C++, and it is frequently easier to do certain kinds of string
-and argument manipulation using the shell than it is in <samp><span
class="command">awk</span></samp>.
-
- <p>Finally, <samp><span class="command">igawk</span></samp> shows that it
is not always necessary to add new
-features to a program; they can often be layered on top. With <samp><span
class="command">igawk</span></samp>,
-there is no real reason to build `<samp><span
class="samp">@include</span></samp>' processing into
-<samp><span class="command">gawk</span></samp> itself.
-
- <p><a name="index-search-paths_002c-for-source-files-1820"></a><a
name="index-source-files_0040comma_007b_007d-search-path-for-1821"></a><a
name="index-files_002c-source_0040comma_007b_007d-search-path-for-1822"></a><a
name="index-directories_002c-searching-1823"></a>As an additional example of
this, consider the idea of having two
-files in a directory in the search path:
-
- <dl>
-<dt><samp><span class="file">default.awk</span></samp><dd>This file contains a
set of default library functions, such
-as <code>getopt</code> and <code>assert</code>.
-
- <br><dt><samp><span class="file">site.awk</span></samp><dd>This file
contains library functions that are specific to a site or
-installation; i.e., locally developed functions.
-Having a separate file allows <samp><span
class="file">default.awk</span></samp> to change with
-new <samp><span class="command">gawk</span></samp> releases, without requiring
the system administrator to
-update it each time by adding the local functions.
-</dl>
-
- <p>One user
-<!-- Karl Berry, address@hidden, 10/95 -->
-suggested that <samp><span class="command">gawk</span></samp> be modified to
automatically read these files
-upon startup. Instead, it would be very simple to modify <samp><span
class="command">igawk</span></samp>
-to do this. Since <samp><span class="command">igawk</span></samp> can process
nested `<samp><span class="samp">@include</span></samp>'
-directives, <samp><span class="file">default.awk</span></samp> could simply
contain `<samp><span class="samp">@include</span></samp>'
-statements for the desired library functions.
-<!-- ENDOFRANGE libfex -->
-<!-- ENDOFRANGE flibex -->
-<!-- ENDOFRANGE awkpex -->
-
-<!-- Exercise: make this change -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Fully explaining the <samp><span
class="command">sh</span></samp> language is beyond
-the scope of this book. We provide some minimal explanations, but see
-a good shell programming book if you wish to understand things in more
-depth.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> On
some very old versions of <samp><span class="command">awk</span></samp>, the
test
-`<samp><span class="samp">getline junk < t</span></samp>' can loop forever
if the file exists but is empty.
-Caveat emptor.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Ignoring-Assigns.html
===================================================================
RCS file: manual/html_node/Ignoring-Assigns.html
diff -N manual/html_node/Ignoring-Assigns.html
--- manual/html_node/Ignoring-Assigns.html 31 Aug 2004 22:04:10 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-<html lang="en">
-<head>
-<title>Ignoring Assigns - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link rel="prev" href="Empty-Files.html#Empty-Files" title="Empty Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Ignoring-Assigns"></a>Previous: <a rel="previous" accesskey="p"
href="Empty-Files.html#Empty-Files">Empty Files</a>,
-Up: <a rel="up" accesskey="u"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.3.5 Treating Assignments as File Names</h4>
-
-<p><a name="index-assignments-as-filenames-1678"></a><a
name="index-filenames_002c-assignments-as-1679"></a>Occasionally, you might not
want <samp><span class="command">awk</span></samp> to process command-line
-variable assignments
-(see <a href="Assignment-Options.html#Assignment-Options">Assignment
Options</a>).
-In particular, if you have file names that contain an `<samp><span
class="samp">=</span></samp>' character,
-<samp><span class="command">awk</span></samp> treats the file name as an
assignment, and does not process it.
-
- <p>Some users have suggested an additional command-line option for
<samp><span class="command">gawk</span></samp>
-to disable command-line assignments. However, some simple programming with
-a library file does the trick:
-
- <p><a name="index-_0040code_007bnoassign_002eawk_007d-program-1680"></a>
-<pre class="example"> <!-- file eg/lib/noassign.awk -->
- # noassign.awk --- library file to avoid the need for a
- # special option that disables command-line assignments
- <!-- endfile -->
- <!-- file eg/lib/noassign.awk -->
- function disable_assigns(argc, argv, i)
- {
- for (i = 1; i < argc; i++)
- if (argv[i] ~ /^[A-Za-z_][A-Za-z_0-9]*=.*/)
- argv[i] = ("./" argv[i])
- }
-
- BEGIN {
- if (No_command_assign)
- disable_assigns(ARGC, ARGV)
- }
- <!-- endfile -->
-</pre>
- <p>You then run your program this way:
-
-<pre class="example"> awk -v No_command_assign=1 -f noassign.awk -f
yourprog.awk *
-</pre>
- <p>The function works by looping through the arguments.
-It prepends `<samp><span class="samp">./</span></samp>' to
-any argument that matches the form
-of a variable assignment, turning that argument into a file name.
-
- <p>The use of <code>No_command_assign</code> allows you to disable
command-line
-assignments at invocation time, by giving the variable a true value.
-When not set, it is initially zero (i.e., false), so the command-line arguments
-are left alone.
-<!-- ENDOFRANGE dataf -->
-<!-- ENDOFRANGE flibdataf -->
-<!-- ENDOFRANGE libfdataf -->
-
- </body></html>
-
Index: manual/html_node/Increment-Ops.html
===================================================================
RCS file: manual/html_node/Increment-Ops.html
diff -N manual/html_node/Increment-Ops.html
--- manual/html_node/Increment-Ops.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,150 +0,0 @@
-<html lang="en">
-<head>
-<title>Increment Ops - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Assignment-Ops.html#Assignment-Ops" title="Assignment
Ops">
-<link rel="next" href="Truth-Values.html#Truth-Values" title="Truth Values">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Increment-Ops"></a>Next: <a rel="next" accesskey="n"
href="Truth-Values.html#Truth-Values">Truth Values</a>,
-Previous: <a rel="previous" accesskey="p"
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.8 Increment and Decrement Operators</h3>
-
-<!-- STARTOFRANGE inop -->
-<p><a name="index-increment-operators-711"></a><!-- STARTOFRANGE opde -->
-<a
name="index-operators_002c-decrement_002fincrement-712"></a><dfn>Increment</dfn>
and <dfn>decrement operators</dfn> increase or decrease the value of
-a variable by one. An assignment operator can do the same thing, so
-the increment operators add no power to the <samp><span
class="command">awk</span></samp> language; however, they
-are convenient abbreviations for very common operations.
-
- <p><a name="index-side-effects-713"></a><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-decrement_002fincrement-operators-714"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-decrement_002fincrement-operators-715"></a><a
name="index-side-effects_002c-decrement_002fincrement-operators-716"></a>The
operator used for adding one is written `<samp><span
class="samp">++</span></samp>'. It can be used to increment
-a variable either before or after taking its value.
-To pre-increment a variable <code>v</code>, write `<samp><span
class="samp">++v</span></samp>'. This adds
-one to the value of <code>v</code>—that new value is also the value of
the
-expression. (The assignment expression `<samp><span class="samp">v +=
1</span></samp>' is completely
-equivalent.)
-Writing the `<samp><span class="samp">++</span></samp>' after the variable
specifies post-increment. This
-increments the variable value just the same; the difference is that the
-value of the increment expression itself is the variable's <em>old</em>
-value. Thus, if <code>foo</code> has the value four, then the expression
`<samp><span class="samp">foo++</span></samp>'
-has the value four, but it changes the value of <code>foo</code> to five.
-In other words, the operator returns the old value of the variable,
-but with the side effect of incrementing it.
-
- <p>The post-increment `<samp><span class="samp">foo++</span></samp>' is
nearly the same as writing `<samp><span class="samp">(foo
-+= 1) - 1</span></samp>'. It is not perfectly equivalent because all numbers
in
-<samp><span class="command">awk</span></samp> are floating-point—in
floating-point, `<samp><span class="samp">foo + 1 - 1</span></samp>' does
-not necessarily equal <code>foo</code>. But the difference is minute as
-long as you stick to numbers that are fairly small (less than 10e12).
-
- <p><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-incrementing-fields-and-arrays-717"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-incrementing-fields-and-arrays-718"></a>Fields
and array elements are incremented
-just like variables. (Use `<samp><span class="samp">$(i++)</span></samp>'
when you want to do a field reference
-and a variable increment at the same time. The parentheses are necessary
-because of the precedence of the field reference operator `<samp><span
class="samp">$</span></samp>'.)
-
- <p><a name="index-decrement-operators-719"></a>The decrement operator
`<samp><span class="samp">--</span></samp>' works just like `<samp><span
class="samp">++</span></samp>', except that
-it subtracts one instead of adding it. As with `<samp><span
class="samp">++</span></samp>', it can be used before
-the lvalue to pre-decrement or after it to post-decrement.
-Following is a summary of increment and decrement expressions:
-
-
-<a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-720"></a>
-<a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-721"></a>
-<dl><dt><code>++</code><var>lvalue</var><dd>This expression increments
<var>lvalue</var>, and the new value becomes the
-value of the expression.
-
- <br><dt><var>lvalue</var><code>++</code><dd>This expression increments
<var>lvalue</var>, but
-the value of the expression is the <em>old</em> value of <var>lvalue</var>.
-
- <p><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-operator-722"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-operator-723"></a><br><dt><code>--</code><var>lvalue</var><dd>This
expression is
-like `<samp><span class="samp">++</span><var>lvalue</var></samp>', but instead
of adding, it subtracts. It
-decrements <var>lvalue</var> and delivers the value that is the result.
-
- <br><dt><var>lvalue</var><code>--</code><dd>This expression is
-like `<samp><var>lvalue</var><span class="samp">++</span></samp>', but instead
of adding, it subtracts. It
-decrements <var>lvalue</var>. The value of the expression is the <em>old</em>
-value of <var>lvalue</var>.
-</dl>
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Operator Evaluation Order</h4>
-
-<p><a
name="index-advanced-features_002c-operators_0040comma_007b_007d-precedence-724"></a><a
name="index-precedence-725"></a><a
name="index-operators_002c-precedence-726"></a><a
name="index-portability_002c-operators-727"></a><a
name="index-evaluation-order-728"></a><a
name="index-Marx_002c-Groucho-729"></a><blockquote>
-<i>Doctor, doctor! It hurts when I do this!<br>
-So don't do that!</i><br>
-Groucho Marx
-</blockquote>
-
-<p class="noindent">What happens for something like the following?
-
-<pre class="example"> b = 6
- print b += b++
-</pre>
- <p class="noindent">Or something even stranger?
-
-<pre class="example"> b = 6
- b += ++b + b++
- print b
-</pre>
- <p><a name="index-side-effects-730"></a>In other words, when do the various
side effects prescribed by the
-postfix operators (`<samp><span class="samp">b++</span></samp>') take effect?
-When side effects happen is <dfn>implementation defined</dfn>.
-In other words, it is up to the particular version of <samp><span
class="command">awk</span></samp>.
-The result for the first example may be 12 or 13, and for the second, it
-may be 22 or 23.
-
- <p>In short, doing things like this is not recommended and definitely
-not anything that you can rely upon for portability.
-You should avoid such things in your own programs.
-<!-- You'll sleep better at night and be able to look at yourself -->
-<!-- in the mirror in the morning. -->
-<!-- ENDOFRANGE inop -->
-<!-- ENDOFRANGE opde -->
-<!-- ENDOFRANGE deop -->
-
- </body></html>
-
Index: manual/html_node/Index.html
===================================================================
RCS file: manual/html_node/Index.html
diff -N manual/html_node/Index.html
--- manual/html_node/Index.html 31 Aug 2004 22:04:10 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2102 +0,0 @@
-<html lang="en">
-<head>
-<title>Index - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License"
title="GNU Free Documentation License">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Index"></a>Previous: <a rel="previous" accesskey="p"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">Index</h2>
-
-<ul class="index-cp" compact>
-<li><a
href="Boolean-Ops.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d--operator-791"><code>!</code>
(exclamation point), <code>!</code> operator</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Egrep-Program.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-1756"><code>!</code>
(exclamation point), <code>!</code> operator</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-825"><code>!</code>
(exclamation point), <code>!</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-847"><code>!</code>
(exclamation point), <code>!=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-758"><code>!</code>
(exclamation point), <code>!=</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Expression-Patterns.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-897"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-862"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-762"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Regexp-Constants.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-622"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Regexp-Constants.html#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="Computed-Regexps.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-329"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Case_002dsensitivity.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-321"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="Regexp-Usage.html#index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-177"><code>!</code>
(exclamation point), <code>!~</code> operator</a>: <a
href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Egrep-Program.html#index-_0040code_007b_0021_007d-operator-1758"><code>!</code>
operator</a>: <a href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Ranges.html#index-_0040code_007b_0021_007d-operator-911"><code>!</code>
operator</a>: <a href="Ranges.html#Ranges">Ranges</a></li>
-<li><a
href="Quoting.html#index-_0040code_007b_0022_007d-_0028double-quote_0029-130"><code>"</code>
(double quote)</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Read-Terminal.html#index-_0040code_007b_0022_007d-_0028double-quote_0029-92"><code>"</code>
(double quote)</a>: <a href="Read-Terminal.html#Read-Terminal">Read
Terminal</a></li>
-<li><a
href="Computed-Regexps.html#index-_0040code_007b_0022_007d-_0028double-quote_0029_002c-regexp-constants-334"><code>"</code>
(double quote), regexp constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Executable-Scripts.html#index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-105"><code>#</code>
(number sign), <code>#!</code> (executable scripts)</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Executable-Scripts.html#index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-108"><code>#</code>
(number sign), <code>#!</code> (executable scripts), portability issues
with</a>: <a href="Executable-Scripts.html#Executable-Scripts">Executable
Scripts</a></li>
-<li><a
href="Comments.html#index-_0040code_007b_0023_007d-_0028number-sign_0029_002c-commenting-113"><code>#</code>
(number sign), commenting</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_0024_007d-_0028dollar-sign_0029-228"><code>$</code>
(dollar sign)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-811"><code>$</code>
(dollar sign), <code>$</code> field operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Fields.html#index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-385"><code>$</code>
(dollar sign), <code>$</code> field operator</a>: <a
href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Increment-Ops.html#index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-incrementing-fields-and-arrays-717"><code>$</code>
(dollar sign), incrementing fields and arrays</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Fields.html#index-_0040code_007b_0024_007d-field-operator-383"><code>$</code>
field operator</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_007d-operator-831"><code>%</code>
(percent sign), <code>%</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-881"><code>%</code>
(percent sign), <code>%=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-692"><code>%</code>
(percent sign), <code>%=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-865"><code>&</code>
(ampersand), <code>&&</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Boolean-Ops.html#index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-786"><code>&</code>
(ampersand), <code>&&</code> operator</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Gory-Details.html#index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1203"><code>&</code>
(ampersand), <code>gsub</code>/<code>gensub</code>/<code>sub</code> functions
and</a>: <a href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Quoting.html#index-_0040code_007b_0027_007d-_0028single-quote_0029-128"><code>'</code>
(single quote)</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Long.html#index-_0040code_007b_0027_007d-_0028single-quote_0029-103"><code>'</code>
(single quote)</a>: <a href="Long.html#Long">Long</a></li>
-<li><a
href="One_002dshot.html#index-_0040code_007b_0027_007d-_0028single-quote_0029-81"><code>'</code>
(single quote)</a>: <a href="One_002dshot.html#One_002dshot">One-shot</a></li>
-<li><a
href="Comments.html#index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-vs_002e-apostrophe-119"><code>'</code>
(single quote), vs. apostrophe</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Quoting.html#index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-with-double-quotes-132"><code>'</code>
(single quote), with double quotes</a>: <a
href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_0028_0029_007d-_0028parentheses_0029-241"><code>()</code>
(parentheses)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Profiling.html#index-_0040code_007b_0028_0029_007d-_0028parentheses_0029_002c-_0040command_007bpgawk_007d-program-1454"><code>()</code>
(parentheses), <samp><span class="command">pgawk</span></samp> program</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-827"><code>*</code>
(asterisk), <code>*</code> operator, as multiplication operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-243"><code>*</code>
(asterisk), <code>*</code> operator, as regexp operator</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Gory-Details.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1209"><code>*</code>
(asterisk), <code>*</code> operator, null strings, matching</a>: <a
href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-1533"><code>*</code>
(asterisk), <code>**</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-819"><code>*</code>
(asterisk), <code>**</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Arithmetic-Ops.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-660"><code>*</code>
(asterisk), <code>**</code> operator</a>: <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1535"><code>*</code>
(asterisk), <code>**=</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-877"><code>*</code>
(asterisk), <code>**=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-696"><code>*</code>
(asterisk), <code>**=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-875"><code>*</code>
(asterisk), <code>*=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-688"><code>*</code>
(asterisk), <code>*=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029-245"><code>+</code>
(plus sign)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_007d-operator-821"><code>+</code>
(plus sign), <code>+</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-813"><code>+</code>
(plus sign), <code>++</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Increment-Ops.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-720"><code>+</code>
(plus sign), <code>++</code> operator</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-871"><code>+</code>
(plus sign), <code>+=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-681"><code>+</code>
(plus sign), <code>+=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Increment-Ops.html#index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-decrement_002fincrement-operators-714"><code>+</code>
(plus sign), decrement/increment operators</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Ranges.html#index-_0040code_007b_002c_007d-_0028comma_0029_002c-in-range-patterns-907"><code>,</code>
(comma), in range patterns</a>: <a href="Ranges.html#Ranges">Ranges</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_007d-operator-823"><code>-</code>
(hyphen), <code>-</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operator-815"><code>-</code>
(hyphen), <code>--</code> (decrement/increment) operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Increment-Ops.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-operator-722"><code>-</code>
(hyphen), <code>--</code> operator</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-873"><code>-</code>
(hyphen), <code>-=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-686"><code>-</code>
(hyphen), <code>-=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-filenames-beginning-with-1498"><code>-</code>
(hyphen), filenames beginning with</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Character-Lists.html#index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-in-character-lists-263"><code>-</code>
(hyphen), in character lists</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dassign_007d-option-1489"><code>--assign</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dcompat_007d-option-1500"><code>--compat</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dcopyleft_007d-option-1505"><code>--copyleft</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dcopyright_007d-option-1503"><code>--copyright</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040code_007b_002d_002ddisable_002dlint_007d-configuration-option-1890"><code>--disable-lint</code>
configuration option</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040code_007b_002d_002ddisable_002dnls_007d-configuration-option-1892"><code>--disable-nls</code>
configuration option</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Library-Names.html#index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1608"><code>--dump-variables</code>
option</a>: <a href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1506"><code>--dump-variables</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1881"><code>--enable-portals</code>
configuration option</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Portal-Files.html#index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1434"><code>--enable-portals</code>
configuration option</a>: <a href="Portal-Files.html#Portal-Files">Portal
Files</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040code_007b_002d_002denable_002dswitch_007d-configuration-option-1883"><code>--enable-switch</code>
configuration option</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dfield_002dseparator_007d-option-1483"><code>--field-separator</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dfile_007d-option-1486"><code>--file</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dgen_002dpo_007d-option-1511"><code>--gen-po</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="String-Extraction.html#index-_0040code_007b_002d_002dgen_002dpo_007d-option-1364"><code>--gen-po</code>
option</a>: <a href="String-Extraction.html#String-Extraction">String
Extraction</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dhelp_007d-option-1514"><code>--help</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dlint_007d-option-1519"><code>--lint</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Command-Line.html#index-_0040code_007b_002d_002dlint_007d-option-1476"><code>--lint</code>
option</a>: <a href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dlint_002dold_007d-option-1522"><code>--lint-old</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1523"><code>--non-decimal-data</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Nondecimal-Data.html#index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1398"><code>--non-decimal-data</code>
option</a>: <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal
Data</a></li>
-<li><a
href="Nondecimal-Data.html#index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option_002c-_0040code_007bstrtonum_007d-function-and-1403"><code>--non-decimal-data</code>
option, <code>strtonum</code> function and</a>: <a
href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dposix_007d-option-1527"><code>--posix</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dposix_007d-option_002c-_0040code_007b_002d_002dtraditional_007d-option-and-1544"><code>--posix</code>
option, <code>--traditional</code> option and</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dprofile_007d-option-1545"><code>--profile</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Profiling.html#index-_0040code_007b_002d_002dprofile_007d-option-1445"><code>--profile</code>
option</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dre_002dinterval_007d-option-1547"><code>--re-interval</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dsource_007d-option-1549"><code>--source</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dtraditional_007d-option-1501"><code>--traditional</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dtraditional_007d-option_002c-_0040code_007b_002d_002dposix_007d-option-and-1543"><code>--traditional</code>
option, <code>--posix</code> option and</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dusage_007d-option-1515"><code>--usage</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002d_002dversion_007d-option-1551"><code>--version</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1887"><code>--with-included-gettext</code>
configuration option</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Gawk-I18N.html#index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option-1393"><code>--with-included-gettext</code>
configuration option</a>: <a href="Gawk-I18N.html#Gawk-I18N">Gawk I18N</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-configuration-option_002c-configuring-_0040command_007bgawk_007d-with-1888"><code>--with-included-gettext</code>
configuration option, configuring <samp><span
class="command">gawk</span></samp> with</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002df_007d-option-1485"><code>-f</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002dF_007d-option-1482"><code>-F</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-_0040code_007b_002dF_007d-option-423"><code>-F</code>
option</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Long.html#index-_0040code_007b_002df_007d-option-98"><code>-f</code>
option</a>: <a href="Long.html#Long">Long</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002dF_007d-option_002c-_0040code_007b_002dFt_007d-sets-_0040code_007bFS_007d-to-TAB-1553"><code>-F</code>
option, <code>-Ft</code> sets <code>FS</code> to TAB</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002df_007d-option_002c-on-command-line-1554"><code>-f</code>
option, on command line</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Known-Bugs.html#index-_0040code_007b_002dF_007d-option_002c-troubleshooting-1588"><code>-F</code>
option, troubleshooting</a>: <a href="Known-Bugs.html#Known-Bugs">Known
Bugs</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002dmf_007d_002f_0040code_007b_002dmr_007d-options-1493"><code>-mf</code>/<code>-mr</code>
options</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002dv_007d-option-1488"><code>-v</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Assignment-Options.html#index-_0040code_007b_002dv_007d-option_002c-variables_0040comma_007b_007d-assigning-638"><code>-v</code>
option, variables, assigning</a>: <a
href="Assignment-Options.html#Assignment-Options">Assignment Options</a></li>
-<li><a
href="Options.html#index-_0040code_007b_002dW_007d-option-1495"><code>-W</code>
option</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_002e_007d-_0028period_0029-230"><code>.</code>
(period)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007b_002emo_007d-files-1314"><code>.mo</code>
files</a>: <a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="I18N-Example.html#index-_0040code_007b_002emo_007d-files_002c-converting-from-_0040code_007b_002epo_007d-1386"><code>.mo</code>
files, converting from <code>.po</code></a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1348"><code>.mo</code>
files, specifying directory of</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1319"><code>.mo</code>
files, specifying directory of</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Translator-i18n.html#index-_0040code_007b_002epo_007d-files-1358"><code>.po</code>
files</a>: <a href="Translator-i18n.html#Translator-i18n">Translator
i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007b_002epo_007d-files-1310"><code>.po</code>
files</a>: <a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="I18N-Example.html#index-_0040code_007b_002epo_007d-files_002c-converting-to-_0040code_007b_002emo_007d-1384"><code>.po</code>
files, converting to <code>.mo</code></a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Regexp.html#index-_0040code_007b_002f_007d-_0028forward-slash_0029-171"><code>/</code>
(forward slash)</a>: <a href="Regexp.html#Regexp">Regexp</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_007d-operator-829"><code>/</code>
(forward slash), <code>/</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-879"><code>/</code>
(forward slash), <code>/=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-690"><code>/</code>
(forward slash), <code>/=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-704"><code>/</code>
(forward slash), <code>/=</code> operator, vs. <code>/=.../</code> regexp
constant</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="Expression-Patterns.html#index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-patterns-and-893"><code>/</code>
(forward slash), patterns and</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-710"><code>/=</code>
operator vs. <code>/=.../</code> regexp constant</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Special-FD.html#index-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-_0028_0040command_007bgawk_007d_0029-578"><code>/dev/...</code>
special files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="TCP_002fIP-Networking.html#index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-1422"><code>/inet/</code>
files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Portal-Files.html#index-_0040code_007b_002fp_007d-files-_0028_0040command_007bgawk_007d_0029-1432"><code>/p</code>
files (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Portal-Files.html#Portal-Files">Portal Files</a></li>
-<li><a
href="Statements_002fLines.html#index-_0040code_007b_003b_007d-_0028semicolon_0029-163"><code>;</code>
(semicolon)</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="PC-Using.html#index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1907"><code>;</code>
(semicolon), <code>AWKPATH</code> variable and</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="Statements.html#index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-948"><code>;</code>
(semicolon), separating statements in actions</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Action-Overview.html#index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-936"><code>;</code>
(semicolon), separating statements in actions</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-837"><code><</code>
(left angle bracket), <code><</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-748"><code><</code>
(left angle bracket), <code><</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Getline_002fFile.html#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-464"><code><</code>
(left angle bracket), <code><</code> operator (I/O)</a>: <a
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-839"><code><</code>
(left angle bracket), <code><=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-750"><code><</code>
(left angle bracket), <code><=</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_007d-operator-673"><code>=</code>
(equals sign), <code>=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-845"><code>=</code>
(equals sign), <code>==</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-756"><code>=</code>
(equals sign), <code>==</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-843"><code>></code>
(right angle bracket), <code>></code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-754"><code>></code>
(right angle bracket), <code>></code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Redirection.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-548"><code>></code>
(right angle bracket), <code>></code> operator (I/O)</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-841"><code>></code>
(right angle bracket), <code>>=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-752"><code>></code>
(right angle bracket), <code>>=</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-849"><code>></code>
(right angle bracket), <code>>></code> operator (I/O)</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Redirection.html#index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-551"><code>></code>
(right angle bracket), <code>>></code> operator (I/O)</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_003f_007d-_0028question-mark_0029-307"><code>?</code>
(question mark)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_003f_007d-_0028question-mark_0029-247"><code>?</code>
(question mark)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_003f_007d-_0028question-mark_0029_002c-_0040code_007b_003f_003a_007d-operator-869"><code>?</code>
(question mark), <code>?:</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_005b_005d_007d-_0028square-brackets_0029-233"><code>[]</code>
(square brackets)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029-223"><code>\</code>
(backslash)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Quoting.html#index-_0040code_007b_005c_007d-_0028backslash_0029-125"><code>\</code>
(backslash)</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Comments.html#index-_0040code_007b_005c_007d-_0028backslash_0029-120"><code>\</code>
(backslash)</a>: <a href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Read-Terminal.html#index-_0040code_007b_005c_007d-_0028backslash_0029-93"><code>\</code>
(backslash)</a>: <a href="Read-Terminal.html#Read-Terminal">Read
Terminal</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-207"><code>\</code>
(backslash), <code>\"</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-304"><code>\</code>
(backslash), <code>\'</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-205"><code>\</code>
(backslash), <code>\/</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-290"><code>\</code>
(backslash), <code>\<</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-292"><code>\</code>
(backslash), <code>\></code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-302"><code>\</code>
(backslash), <code>\`</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ca_007d-escape-sequence-187"><code>\</code>
(backslash), <code>\a</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cb_007d-escape-sequence-189"><code>\</code>
(backslash), <code>\b</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-297"><code>\</code>
(backslash), <code>\B</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cf_007d-escape-sequence-191"><code>\</code>
(backslash), <code>\f</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cn_007d-escape-sequence-193"><code>\</code>
(backslash), <code>\n</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-201"><code>\</code>
(backslash), <code>\</code><var>nnn</var> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cr_007d-escape-sequence-195"><code>\</code>
(backslash), <code>\r</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005ct_007d-escape-sequence-197"><code>\</code>
(backslash), <code>\t</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cv_007d-escape-sequence-199"><code>\</code>
(backslash), <code>\v</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-288"><code>\</code>
(backslash), <code>\W</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-286"><code>\</code>
(backslash), <code>\w</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cx_007d-escape-sequence-203"><code>\</code>
(backslash), <code>\x</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-294"><code>\</code>
(backslash), <code>\y</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-as-field-separators-429"><code>\</code>
(backslash), as field separators</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Egrep-Program.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-1760"><code>\</code>
(backslash), continuing lines and</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Statements_002fLines.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-153"><code>\</code>
(backslash), continuing lines and</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Statements_002fLines.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-comments-and-160"><code>\</code>
(backslash), continuing lines and, comments and</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Statements_002fLines.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-158"><code>\</code>
(backslash), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="More-Complex.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-147"><code>\</code>
(backslash), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a
href="More-Complex.html#More-Complex">More Complex</a></li>
-<li><a
href="Gory-Details.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1201"><code>\</code>
(backslash), <code>gsub</code>/<code>gensub</code>/<code>sub</code> functions
and</a>: <a href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Character-Lists.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-character-lists-259"><code>\</code>
(backslash), in character lists</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences-186"><code>\</code>
(backslash), in escape sequences</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-in-escape-sequences_002c-POSIX-and-215"><code>\</code>
(backslash), in escape sequences, POSIX and</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Computed-Regexps.html#index-_0040code_007b_005c_007d-_0028backslash_0029_002c-regexp-constants-332"><code>\</code>
(backslash), regexp constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040code_007b_005e_007d-_0028caret_0029-305"><code>^</code>
(caret)</a>: <a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_005e_007d-_0028caret_0029-226"><code>^</code>
(caret)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Options.html#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-1537"><code>^</code>
(caret), <code>^</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-817"><code>^</code>
(caret), <code>^</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Options.html#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-1539"><code>^</code>
(caret), <code>^=</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-883"><code>^</code>
(caret), <code>^=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-694"><code>^</code>
(caret), <code>^=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Character-Lists.html#index-_0040code_007b_005e_007d-_0028caret_0029_002c-in-character-lists-261"><code>^</code>
(caret), in character lists</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007b_005f_007d-_0028underscore_0029_002c-_0040code_007b_005f_007d-C-macro-1324"><code>_</code>
(underscore), <code>_</code> C macro</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Library-Names.html#index-_0040code_007b_005f_007d-_0028underscore_0029_002c-in-names-of-private-variables-1606"><code>_</code>
(underscore), in names of private variables</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007b_005f_007d-_0028underscore_0029_002c-translatable-string-1355"><code>_</code>
(underscore), translatable string</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1730"><code>_gr_init</code>
user-defined function</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007b_005fpw_005finit_007d-user_002ddefined-function-1706"><code>_pw_init</code>
user-defined function</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a href="Fields.html#index-accessing-fields-378">accessing fields</a>: <a
href="Fields.html#Fields">Fields</a></li>
-<li><a href="Group-Functions.html#index-account-information-1725">account
information</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a href="Passwd-Functions.html#index-account-information-1699">account
information</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Action-Overview.html#index-actions-931">actions</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="Statements.html#index-actions_002c-control-statements-in-941">actions,
control statements in</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a href="Very-Simple.html#index-actions_002c-default-138">actions,
default</a>: <a href="Very-Simple.html#Very-Simple">Very Simple</a></li>
-<li><a href="Very-Simple.html#index-actions_002c-empty-140">actions,
empty</a>: <a href="Very-Simple.html#Very-Simple">Very Simple</a></li>
-<li><a
href="Adding-Code.html#index-adding_002c-features-to-_0040command_007bgawk_007d-1955">adding,
features to <samp><span class="command">gawk</span></samp></a>: <a
href="Adding-Code.html#Adding-Code">Adding Code</a></li>
-<li><a href="Changing-Fields.html#index-adding_002c-fields-393">adding,
fields</a>: <a href="Changing-Fields.html#Changing-Fields">Changing
Fields</a></li>
-<li><a
href="Dynamic-Extensions.html#index-adding_002c-functions-to-_0040command_007bgawk_007d-1967">adding,
functions to <samp><span class="command">gawk</span></samp></a>: <a
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a
href="I_002fO-Functions.html#index-advanced-features_002c-buffering-1222">advanced
features, buffering</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-advanced-features_002c-_0040code_007bclose_007d-function-598">advanced
features, <code>close</code> function</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-advanced-features_002c-constants_0040comma_007b_007d-values-of-618">advanced
features, constants, values of</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="Records.html#index-advanced-features_002c-_0040value_007bDF_007ds-as-single-record-370">advanced
features, data files as single record</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="Constant-Size.html#index-advanced-features_002c-fixed_002dwidth-data-440">advanced
features, fixed-width data</a>: <a
href="Constant-Size.html#Constant-Size">Constant Size</a></li>
-<li><a
href="Auto_002dset.html#index-advanced-features_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1069">advanced
features, <code>FNR</code>/<code>NR</code> variables</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Advanced-Features.html#index-advanced-features_002c-_0040command_007bgawk_007d-1397">advanced
features, <samp><span class="command">gawk</span></samp></a>: <a
href="Advanced-Features.html#Advanced-Features">Advanced Features</a></li>
-<li><a
href="Portal-Files.html#index-advanced-features_002c-_0040command_007bgawk_007d_002c-BSD-portals-1428">advanced
features, <samp><span class="command">gawk</span></samp>, BSD portals</a>: <a
href="Portal-Files.html#Portal-Files">Portal Files</a></li>
-<li><a
href="TCP_002fIP-Networking.html#index-advanced-features_002c-_0040command_007bgawk_007d_002c-network-programming-1419">advanced
features, <samp><span class="command">gawk</span></samp>, network
programming</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Nondecimal-Data.html#index-advanced-features_002c-_0040command_007bgawk_007d_002c-nondecimal-input-data-1399">advanced
features, <samp><span class="command">gawk</span></samp>, nondecimal input
data</a>: <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal
Data</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-advanced-features_002c-_0040command_007bgawk_007d_002c-processes_0040comma_007b_007d-communicating-with-1407">advanced
features, <samp><span class="command">gawk</span></samp>, processes,
communicating with</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Advanced-Features.html#index-advanced-features_002c-network-connections_002c-See-Also-networks_002c-connections-1395">advanced
features, network connections, See Also networks, connections</a>: <a
href="Advanced-Features.html#Advanced-Features">Advanced Features</a></li>
-<li><a
href="Gory-Details.html#index-advanced-features_002c-null-strings_0040comma_007b_007d-matching-1206">advanced
features, null strings, matching</a>: <a
href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Increment-Ops.html#index-advanced-features_002c-operators_0040comma_007b_007d-precedence-724">advanced
features, operators, precedence</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Redirection.html#index-advanced-features_002c-piping-into-_0040command_007bsh_007d-565">advanced
features, piping into <samp><span class="command">sh</span></samp></a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Assignment-Ops.html#index-advanced-features_002c-regexp-constants-702">advanced
features, regexp constants</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="Contributors.html#index-Aho_002c-Alfred-1838">Aho, Alfred</a>: <a
href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="History.html#index-Aho_002c-Alfred-13">Aho, Alfred</a>: <a
href="History.html#History">History</a></li>
-<li><a href="Alarm-Program.html#index-alarm-clock-example-program-1794">alarm
clock example program</a>: <a href="Alarm-Program.html#Alarm-Program">Alarm
Program</a></li>
-<li><a
href="Alarm-Program.html#index-_0040code_007balarm_002eawk_007d-program-1795"><code>alarm.awk</code>
program</a>: <a href="Alarm-Program.html#Alarm-Program">Alarm Program</a></li>
-<li><a href="Basic-High-Level.html#index-algorithms-2029">algorithms</a>: <a
href="Basic-High-Level.html#Basic-High-Level">Basic High Level</a></li>
-<li><a href="Manual-History.html#index-Alpha-_0028DEC_0029-42">Alpha
(DEC)</a>: <a href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a
href="Glossary.html#index-amazing-_0040command_007bawk_007d-assembler-_0028_0040command_007baaa_007d_0029-2054">amazing
<samp><span class="command">awk</span></samp> assembler (<samp><span
class="command">aaa</span></samp>)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Glossary.html#index-amazingly-workable-formatter-_0028_0040command_007bawf_007d_0029-2055">amazingly
workable formatter (<samp><span class="command">awf</span></samp>)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Assignment-Ops.html#index-ambiguity_002c-syntactic_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-708">ambiguity,
syntactic: <code>/=</code> operator vs. <code>/=.../</code> regexp
constant</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a href="Amiga-Installation.html#index-amiga-1896">amiga</a>: <a
href="Amiga-Installation.html#Amiga-Installation">Amiga Installation</a></li>
-<li><a
href="Boolean-Ops.html#index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007d-operator-787">ampersand
(<code>&</code>), <code>&&</code> operator</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Precedence.html#index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007doperator-866">ampersand
(<code>&</code>), <code>&&</code>operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Gory-Details.html#index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1204">ampersand
(<code>&</code>), <code>gsub</code>/<code>gensub</code>/<code>sub</code>
functions and</a>: <a href="Gory-Details.html#Gory-Details">Gory
Details</a></li>
-<li><a href="Bitwise-Functions.html#index-AND-bitwise-operation-1246">AND
bitwise operation</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="Boolean-Ops.html#index-and-Boolean_002dlogic-operator-774">and
Boolean-logic operator</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean
Ops</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007band_007d-function-_0028_0040command_007bgawk_007d_0029-1257"><code>and</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="Glossary.html#index-ANSI-2057">ANSI</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Bugs.html#index-archeologists-1921">archeologists</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a
href="ARGC-and-ARGV.html#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1071"><code>ARGC</code>/<code>ARGV</code>
variables</a>: <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and
ARGV</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1043"><code>ARGC</code>/<code>ARGV</code>
variables</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Other-Arguments.html#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-command_002dline-arguments-1564"><code>ARGC</code>/<code>ARGV</code>
variables, command-line arguments</a>: <a
href="Other-Arguments.html#Other-Arguments">Other Arguments</a></li>
-<li><a
href="Executable-Scripts.html#index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-portability-and-111"><code>ARGC</code>/<code>ARGV</code>
variables, portability and</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bARGIND_007d-variable-1047"><code>ARGIND</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Other-Arguments.html#index-_0040code_007bARGIND_007d-variable_002c-command_002dline-arguments-1563"><code>ARGIND</code>
variable, command-line arguments</a>: <a
href="Other-Arguments.html#Other-Arguments">Other Arguments</a></li>
-<li><a
href="Other-Arguments.html#index-arguments_002c-command_002dline-1562">arguments,
command-line</a>: <a href="Other-Arguments.html#Other-Arguments">Other
Arguments</a></li>
-<li><a
href="ARGC-and-ARGV.html#index-arguments_002c-command_002dline-1072">arguments,
command-line</a>: <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and
ARGV</a></li>
-<li><a
href="Auto_002dset.html#index-arguments_002c-command_002dline-1044">arguments,
command-line</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Command-Line.html#index-arguments_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1469">arguments,
command-line, invoking <samp><span class="command">awk</span></samp></a>: <a
href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a
href="Function-Calls.html#index-arguments_002c-in-function-calls-806">arguments,
in function calls</a>: <a href="Function-Calls.html#Function-Calls">Function
Calls</a></li>
-<li><a
href="Getopt-Function.html#index-arguments_002c-processing-1686">arguments,
processing</a>: <a href="Getopt-Function.html#Getopt-Function">Getopt
Function</a></li>
-<li><a href="Internals.html#index-arguments_002c-retrieving-2002">arguments,
retrieving</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Arithmetic-Ops.html#index-arithmetic-operators-652">arithmetic
operators</a>: <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic
Ops</a></li>
-<li><a href="Arrays.html#index-arrays-1075">arrays</a>: <a
href="Arrays.html#Arrays">Arrays</a></li>
-<li><a
href="Function-Caveats.html#index-arrays_002c-as-parameters-to-functions-1292">arrays,
as parameters to functions</a>: <a
href="Function-Caveats.html#Function-Caveats">Function Caveats</a></li>
-<li><a href="Array-Intro.html#index-arrays_002c-associative-1084">arrays,
associative</a>: <a href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="Internals.html#index-arrays_002c-associative_002c-clearing-1987">arrays,
associative, clearing</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Library-Names.html#index-arrays_002c-associative_002c-library-functions-and-1609">arrays,
associative, library functions and</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Delete.html#index-arrays_002c-deleting-entire-contents-1109">arrays,
deleting entire contents</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Assigning-Elements.html#index-arrays_002c-elements_002c-assigning-1094">arrays,
elements, assigning</a>: <a
href="Assigning-Elements.html#Assigning-Elements">Assigning Elements</a></li>
-<li><a
href="Delete.html#index-arrays_002c-elements_002c-deleting-1105">arrays,
elements, deleting</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Internals.html#index-arrays_002c-elements_002c-installing-1989">arrays,
elements, installing</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Scanning-an-Array.html#index-arrays_002c-elements_002c-order-of-1101">arrays,
elements, order of</a>: <a
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="Reference-to-Elements.html#index-arrays_002c-elements_002c-referencing-1090">arrays,
elements, referencing</a>: <a
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a></li>
-<li><a
href="String-Functions.html#index-arrays_002c-elements_002c-retrieving-number-of-1162">arrays,
elements, retrieving number of</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Scanning-an-Array.html#index-arrays_002c-_0040code_007bfor_007d-statement-and-1099">arrays,
<code>for</code> statement and</a>: <a
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="Array-Intro.html#index-arrays_002c-_0040code_007bIGNORECASE_007d-variable-and-1088">arrays,
<code>IGNORECASE</code> variable and</a>: <a
href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a href="Array-Intro.html#index-arrays_002c-indexing-1081">arrays,
indexing</a>: <a href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="Join-Function.html#index-arrays_002c-merging-into-strings-1656">arrays,
merging into strings</a>: <a href="Join-Function.html#Join-Function">Join
Function</a></li>
-<li><a
href="Multi_002ddimensional.html#index-arrays_002c-multidimensional-1128">arrays,
multidimensional</a>: <a
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a></li>
-<li><a
href="Multi_002dscanning.html#index-arrays_002c-multidimensional_002c-scanning-1131">arrays,
multidimensional, scanning</a>: <a
href="Multi_002dscanning.html#Multi_002dscanning">Multi-scanning</a></li>
-<li><a href="Arrays.html#index-arrays_002c-names-of-1078">arrays, names
of</a>: <a href="Arrays.html#Arrays">Arrays</a></li>
-<li><a href="Scanning-an-Array.html#index-arrays_002c-scanning-1097">arrays,
scanning</a>: <a href="Scanning-an-Array.html#Scanning-an-Array">Scanning an
Array</a></li>
-<li><a href="Array-Sorting.html#index-arrays_002c-sorting-1132">arrays,
sorting</a>: <a href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a
href="Array-Sorting.html#index-arrays_002c-sorting_002c-_0040code_007bIGNORECASE_007d-variable-and-1138">arrays,
sorting, <code>IGNORECASE</code> variable and</a>: <a
href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a href="Array-Intro.html#index-arrays_002c-sparse-1086">arrays,
sparse</a>: <a href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="Numeric-Array-Subscripts.html#index-arrays_002c-subscripts-1116">arrays,
subscripts</a>: <a
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-arrays_002c-subscripts_002c-uninitialized-variables-as-1123">arrays,
subscripts, uninitialized variables as</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="Distribution-contents.html#index-artificial-intelligence_0040comma_007b_007d-_0040command_007bgawk_007d-and-1877">artificial
intelligence, <samp><span class="command">gawk</span></samp> and</a>: <a
href="Distribution-contents.html#Distribution-contents">Distribution
contents</a></li>
-<li><a href="Ordinal-Functions.html#index-ASCII-1650">ASCII</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1163"><code>asort</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Array-Sorting.html#index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1133"><code>asort</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a
href="Array-Sorting.html#index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029_002c-arrays_0040comma_007b_007d-sorting-1134"><code>asort</code>
function (<samp><span class="command">gawk</span></samp>), arrays,
sorting</a>: <a href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007basorti_007d-function-_0028_0040command_007bgawk_007d_0029-1164"><code>asorti</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Assert-Function.html#index-_0040code_007bassert_007d-function-_0028C-library_0029-1621"><code>assert</code>
function (C library)</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a
href="Assert-Function.html#index-_0040code_007bassert_007d-user_002ddefined-function-1625"><code>assert</code>
user-defined function</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a href="Assert-Function.html#index-assertions-1620">assertions</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a href="Assignment-Ops.html#index-assignment-operators-670">assignment
operators</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-assignment-operators_002c-evaluation-order-685">assignment
operators, evaluation order</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-assignment-operators_002c-lvalues_002frvalues-678">assignment
operators, lvalues/rvalues</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Ignoring-Assigns.html#index-assignments-as-filenames-1678">assignments as
filenames</a>: <a href="Ignoring-Assigns.html#Ignoring-Assigns">Ignoring
Assigns</a></li>
-<li><a
href="Internals.html#index-_0040code_007bassoc_005fclear_007d-internal-function-1988"><code>assoc_clear</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bassoc_005flookup_007d-internal-function-1990"><code>assoc_lookup</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Array-Intro.html#index-associative-arrays-1083">associative
arrays</a>: <a href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="Precedence.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-828">asterisk
(<code>*</code>), <code>*</code> operator, as multiplication operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Regexp-Operators.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-244">asterisk
(<code>*</code>), <code>*</code> operator, as regexp operator</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Gory-Details.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-null-strings_0040comma_007b_007d-matching-1210">asterisk
(<code>*</code>), <code>*</code> operator, null strings, matching</a>: <a
href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Options.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-1534">asterisk
(<code>*</code>), <code>**</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-820">asterisk
(<code>*</code>), <code>**</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Arithmetic-Ops.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-661">asterisk
(<code>*</code>), <code>**</code> operator</a>: <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="Options.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1536">asterisk
(<code>*</code>), <code>**=</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-878">asterisk
(<code>*</code>), <code>**=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-697">asterisk
(<code>*</code>), <code>**=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Precedence.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-876">asterisk
(<code>*</code>), <code>*=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-689">asterisk
(<code>*</code>), <code>*=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007batan2_007d-function-1156"><code>atan2</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a href="Atari-Installation.html#index-atari-1915">atari</a>: <a
href="Atari-Installation.html#Atari-Installation">Atari Installation</a></li>
-<li><a
href="Glossary.html#index-_0040command_007bawf_007d-_0028amazingly-workable-formatter_0029-program-2056"><samp><span
class="command">awf</span></samp> (amazingly workable formatter) program</a>:
<a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Assignment-Ops.html#index-_0040command_007bawk_007d-language_002c-POSIX-version-698"><samp><span
class="command">awk</span></samp> language, POSIX version</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Two-Rules.html#index-_0040command_007bawk_007d-programs-143"><samp><span
class="command">awk</span></samp> programs</a>: <a
href="Two-Rules.html#Two-Rules">Two Rules</a></li>
-<li><a
href="Executable-Scripts.html#index-_0040command_007bawk_007d-programs-104"><samp><span
class="command">awk</span></samp> programs</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Getting-Started.html#index-_0040command_007bawk_007d-programs-75"><samp><span
class="command">awk</span></samp> programs</a>: <a
href="Getting-Started.html#Getting-Started">Getting Started</a></li>
-<li><a
href="When.html#index-_0040command_007bawk_007d-programs_002c-complex-167"><samp><span
class="command">awk</span></samp> programs, complex</a>: <a
href="When.html#When">When</a></li>
-<li><a
href="Library-Names.html#index-_0040command_007bawk_007d-programs_002c-documenting-1600"><samp><span
class="command">awk</span></samp> programs, documenting</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Comments.html#index-_0040command_007bawk_007d-programs_002c-documenting-116"><samp><span
class="command">awk</span></samp> programs, documenting</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Sample-Programs.html#index-_0040command_007bawk_007d-programs_002c-examples-of-1741"><samp><span
class="command">awk</span></samp> programs, examples of</a>: <a
href="Sample-Programs.html#Sample-Programs">Sample Programs</a></li>
-<li><a
href="Next-Statement.html#index-_0040command_007bawk_007d-programs_002c-execution-of-971"><samp><span
class="command">awk</span></samp> programs, execution of</a>: <a
href="Next-Statement.html#Next-Statement">Next Statement</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040command_007bawk_007d-programs_002c-internationalizing-1342"><samp><span
class="command">awk</span></samp> programs, internationalizing</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="I18N-Functions.html#index-_0040command_007bawk_007d-programs_002c-internationalizing-1271"><samp><span
class="command">awk</span></samp> programs, internationalizing</a>: <a
href="I18N-Functions.html#I18N-Functions">I18N Functions</a></li>
-<li><a
href="Long.html#index-_0040command_007bawk_007d-programs_002c-lengthy-96"><samp><span
class="command">awk</span></samp> programs, lengthy</a>: <a
href="Long.html#Long">Long</a></li>
-<li><a
href="Assert-Function.html#index-_0040command_007bawk_007d-programs_002c-lengthy_002c-assertions-1624"><samp><span
class="command">awk</span></samp> programs, lengthy, assertions</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a
href="Options.html#index-_0040command_007bawk_007d-programs_002c-location-of-1487"><samp><span
class="command">awk</span></samp> programs, location of</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Very-Simple.html#index-_0040command_007bawk_007d-programs_002c-one_002dline-examples-141"><samp><span
class="command">awk</span></samp> programs, one-line examples</a>: <a
href="Very-Simple.html#Very-Simple">Very Simple</a></li>
-<li><a
href="Profiling.html#index-_0040command_007bawk_007d-programs_002c-profiling-1438"><samp><span
class="command">awk</span></samp> programs, profiling</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Options.html#index-_0040command_007bawk_007d-programs_002c-profiling_002c-enabling-1546"><samp><span
class="command">awk</span></samp> programs, profiling, enabling</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Long.html#index-_0040command_007bawk_007d-programs_002c-running-95"><samp><span
class="command">awk</span></samp> programs, running</a>: <a
href="Long.html#Long">Long</a></li>
-<li><a
href="Running-gawk.html#index-_0040command_007bawk_007d-programs_002c-running-78"><samp><span
class="command">awk</span></samp> programs, running</a>: <a
href="Running-gawk.html#Running-gawk">Running gawk</a></li>
-<li><a
href="One_002dshot.html#index-_0040command_007bawk_007d-programs_002c-running_002c-from-shell-scripts-83"><samp><span
class="command">awk</span></samp> programs, running, from shell scripts</a>:
<a href="One_002dshot.html#One_002dshot">One-shot</a></li>
-<li><a
href="Read-Terminal.html#index-_0040command_007bawk_007d-programs_002c-running_002c-without-input-files-89"><samp><span
class="command">awk</span></samp> programs, running, without input files</a>:
<a href="Read-Terminal.html#Read-Terminal">Read Terminal</a></li>
-<li><a
href="Using-Shell-Variables.html#index-_0040command_007bawk_007d-programs_002c-shell-variables-in-929"><samp><span
class="command">awk</span></samp> programs, shell variables in</a>: <a
href="Using-Shell-Variables.html#Using-Shell-Variables">Using Shell
Variables</a></li>
-<li><a
href="Getting-Started.html#index-_0040command_007bawk_007d_002c-function-of-72"><samp><span
class="command">awk</span></samp>, function of</a>: <a
href="Getting-Started.html#Getting-Started">Getting Started</a></li>
-<li><a
href="This-Manual.html#index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-26"><samp><span
class="command">awk</span></samp>, <samp><span
class="command">gawk</span></samp> and</a>: <a
href="This-Manual.html#This-Manual">This Manual</a></li>
-<li><a
href="Preface.html#index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-5"><samp><span
class="command">awk</span></samp>, <samp><span
class="command">gawk</span></samp> and</a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="History.html#index-_0040command_007bawk_007d_002c-history-of-16"><samp><span
class="command">awk</span></samp>, history of</a>: <a
href="History.html#History">History</a></li>
-<li><a
href="Redirection.html#index-_0040command_007bawk_007d_002c-implementation-issues_002c-pipes-563"><samp><span
class="command">awk</span></samp>, implementation issues, pipes</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Other-Versions.html#index-_0040command_007bawk_007d_002c-implementations-1936"><samp><span
class="command">awk</span></samp>, implementations</a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="Getline-Notes.html#index-_0040command_007bawk_007d_002c-implementations_002c-limits-490"><samp><span
class="command">awk</span></samp>, implementations, limits</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Command-Line.html#index-_0040command_007bawk_007d_002c-invoking-1468"><samp><span
class="command">awk</span></samp>, invoking</a>: <a
href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a
href="Names.html#index-_0040command_007bawk_007d_002c-new-vs_002e-old-20"><samp><span
class="command">awk</span></samp>, new vs. old</a>: <a
href="Names.html#Names">Names</a></li>
-<li><a
href="Conversion.html#index-_0040command_007bawk_007d_002c-new-vs_002e-old_002c-_0040code_007bOFMT_007d-variable-651"><samp><span
class="command">awk</span></samp>, new vs. old, <code>OFMT</code>
variable</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Preface.html#index-_0040command_007bawk_007d_002c-POSIX-and-2"><samp><span
class="command">awk</span></samp>, POSIX and</a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="Preface.html#index-_0040command_007bawk_007d_002c-POSIX-and_002c-See-Also-POSIX-_0040command_007bawk_007d-1"><samp><span
class="command">awk</span></samp>, POSIX and, See Also POSIX <samp><span
class="command">awk</span></samp></a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040command_007bawk_007d_002c-regexp-constants-and-772"><samp><span
class="command">awk</span></samp>, regexp constants and</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Preface.html#index-_0040command_007bawk_007d_002c-See-Also-_0040command_007bgawk_007d-7"><samp><span
class="command">awk</span></samp>, See Also <samp><span
class="command">gawk</span></samp></a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="This-Manual.html#index-_0040command_007bawk_007d_002c-terms-describing-24"><samp><span
class="command">awk</span></samp>, terms describing</a>: <a
href="This-Manual.html#This-Manual">This Manual</a></li>
-<li><a
href="When.html#index-_0040command_007bawk_007d_002c-uses-for-166"><samp><span
class="command">awk</span></samp>, uses for</a>: <a
href="When.html#When">When</a></li>
-<li><a
href="Getting-Started.html#index-_0040command_007bawk_007d_002c-uses-for-73"><samp><span
class="command">awk</span></samp>, uses for</a>: <a
href="Getting-Started.html#Getting-Started">Getting Started</a></li>
-<li><a
href="Preface.html#index-_0040command_007bawk_007d_002c-uses-for-6"><samp><span
class="command">awk</span></samp>, uses for</a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="V7_002fSVR3_002e1.html#index-_0040command_007bawk_007d_002c-versions-of-1824"><samp><span
class="command">awk</span></samp>, versions of</a>: <a
href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a></li>
-<li><a
href="Names.html#index-_0040command_007bawk_007d_002c-versions-of-21"><samp><span
class="command">awk</span></samp>, versions of</a>: <a
href="Names.html#Names">Names</a></li>
-<li><a
href="SVR4.html#index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR3_002e1-and-SVR4-1826"><samp><span
class="command">awk</span></samp>, versions of, changes between SVR3.1 and
SVR4</a>: <a href="SVR4.html#SVR4">SVR4</a></li>
-<li><a
href="POSIX.html#index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR4-and-POSIX-_0040command_007bawk_007d-1827"><samp><span
class="command">awk</span></samp>, versions of, changes between SVR4 and POSIX
<samp><span class="command">awk</span></samp></a>: <a
href="POSIX.html#POSIX">POSIX</a></li>
-<li><a
href="V7_002fSVR3_002e1.html#index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-V7-and-SVR3_002e1-1825"><samp><span
class="command">awk</span></samp>, versions of, changes between V7 and
SVR3.1</a>: <a
href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a></li>
-<li><a
href="BTL.html#index-_0040command_007bawk_007d_002c-versions-of_002c-See-Also-Bell-Laboratories-_0040command_007bawk_007d-1829"><samp><span
class="command">awk</span></samp>, versions of, See Also Bell Laboratories
<samp><span class="command">awk</span></samp></a>: <a
href="BTL.html#BTL">BTL</a></li>
-<li><a
href="Internals.html#index-_0040code_007bawk_002eh_007d-file-_0028internal_0029-1970"><code>awk.h</code>
file (internal)</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Other-Versions.html#index-_0040command_007bawka_007d-compiler-for-_0040command_007bawk_007d-1945"><samp><span
class="command">awka</span></samp> compiler for <samp><span
class="command">awk</span></samp></a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="Internals.html#index-_0040code_007bAWKNUM_007d-internal-type-1973"><code>AWKNUM</code>
internal type</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="PC-Using.html#index-_0040code_007bAWKPATH_007d-environment-variable-1909"><code>AWKPATH</code>
environment variable</a>: <a href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="AWKPATH-Variable.html#index-_0040env_007bAWKPATH_007d-environment-variable-1568"><samp><span
class="env">AWKPATH</span></samp> environment variable</a>: <a
href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bawkprof_002eout_007d-file-1442"><code>awkprof.out</code>
file</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Simple-Sed.html#index-_0040command_007bawksed_002eawk_007d-program-1816"><samp><span
class="command">awksed.awk</span></samp> program</a>: <a
href="Simple-Sed.html#Simple-Sed">Simple Sed</a></li>
-<li><a
href="Options.html#index-_0040code_007bawkvars_002eout_007d-file-1507"><code>awkvars.out</code>
file</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029-222">backslash
(<code>\</code>)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Quoting.html#index-backslash-_0028_0040code_007b_005c_007d_0029-126">backslash
(<code>\</code>)</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Comments.html#index-backslash-_0028_0040code_007b_005c_007d_0029-121">backslash
(<code>\</code>)</a>: <a href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Read-Terminal.html#index-backslash-_0028_0040code_007b_005c_007d_0029-94">backslash
(<code>\</code>)</a>: <a href="Read-Terminal.html#Read-Terminal">Read
Terminal</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0022_007d-escape-sequence-208">backslash
(<code>\</code>), <code>\"</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0027_007d-operator-_0028_0040command_007bgawk_007d_0029-303">backslash
(<code>\</code>), <code>\'</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_002f_007d-escape-sequence-206">backslash
(<code>\</code>), <code>\/</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003c_007d-operator-_0028_0040command_007bgawk_007d_0029-289">backslash
(<code>\</code>), <code>\<</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_003e_007d-operator-_0028_0040command_007bgawk_007d_0029-291">backslash
(<code>\</code>), <code>\></code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_0060_007d-operator-_0028_0040command_007bgawk_007d_0029-301">backslash
(<code>\</code>), <code>\`</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ca_007d-escape-sequence-188">backslash
(<code>\</code>), <code>\a</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cb_007d-escape-sequence-190">backslash
(<code>\</code>), <code>\b</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cB_007d-operator-_0028_0040command_007bgawk_007d_0029-296">backslash
(<code>\</code>), <code>\B</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cf_007d-escape-sequence-192">backslash
(<code>\</code>), <code>\f</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cn_007d-escape-sequence-194">backslash
(<code>\</code>), <code>\n</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005c_007d_0040var_007bnnn_007d-escape-sequence-202">backslash
(<code>\</code>), <code>\</code><var>nnn</var> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cr_007d-escape-sequence-196">backslash
(<code>\</code>), <code>\r</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005ct_007d-escape-sequence-198">backslash
(<code>\</code>), <code>\t</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cv_007d-escape-sequence-200">backslash
(<code>\</code>), <code>\v</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cW_007d-operator-_0028_0040command_007bgawk_007d_0029-287">backslash
(<code>\</code>), <code>\W</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cw_007d-operator-_0028_0040command_007bgawk_007d_0029-285">backslash
(<code>\</code>), <code>\w</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cx_007d-escape-sequence-204">backslash
(<code>\</code>), <code>\x</code> escape sequence</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007b_005cy_007d-operator-_0028_0040command_007bgawk_007d_0029-293">backslash
(<code>\</code>), <code>\y</code> operator (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-as-field-separators-430">backslash
(<code>\</code>), as field separators</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Egrep-Program.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-1761">backslash
(<code>\</code>), continuing lines and</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Statements_002fLines.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-154">backslash
(<code>\</code>), continuing lines and</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Statements_002fLines.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-comments-and-159">backslash
(<code>\</code>), continuing lines and, comments and</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Statements_002fLines.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-157">backslash
(<code>\</code>), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="More-Complex.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-146">backslash
(<code>\</code>), continuing lines and, in <samp><span
class="command">csh</span></samp></a>: <a
href="More-Complex.html#More-Complex">More Complex</a></li>
-<li><a
href="Gory-Details.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-and-1202">backslash
(<code>\</code>), <code>gsub</code>/<code>gensub</code>/<code>sub</code>
functions and</a>: <a href="Gory-Details.html#Gory-Details">Gory
Details</a></li>
-<li><a
href="Character-Lists.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-character-lists-260">backslash
(<code>\</code>), in character lists</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences-185">backslash
(<code>\</code>), in escape sequences</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Escape-Sequences.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-in-escape-sequences_002c-POSIX-and-214">backslash
(<code>\</code>), in escape sequences, POSIX and</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Computed-Regexps.html#index-backslash-_0028_0040code_007b_005c_007d_0029_002c-regexp-constants-333">backslash
(<code>\</code>), regexp constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Sample-Data-Files.html#index-_0040code_007bBBS_002dlist_007d-file-136"><code>BBS-list</code>
file</a>: <a href="Sample-Data-Files.html#Sample-Data-Files">Sample Data
Files</a></li>
-<li><a href="Acknowledgments.html#index-Beebe_002c-Nelson-56">Beebe,
Nelson</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Other-Versions.html#index-Beebe_002c-Nelson-H_002eF_002e_0040_003a-1947">Beebe,
Nelson H.F.</a>: <a href="Other-Versions.html#Other-Versions">Other
Versions</a></li>
-<li><a
href="BEGIN_002fEND.html#index-_0040code_007bBEGIN_007d-pattern-912"><code>BEGIN</code>
pattern</a>: <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a></li>
-<li><a
href="Field-Separators.html#index-_0040code_007bBEGIN_007d-pattern-407"><code>BEGIN</code>
pattern</a>: <a href="Field-Separators.html#Field-Separators">Field
Separators</a></li>
-<li><a
href="Records.html#index-_0040code_007bBEGIN_007d-pattern-356"><code>BEGIN</code>
pattern</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Assert-Function.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1627"><code>BEGIN</code>
pattern, <code>assert</code> user-defined function and</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a
href="Expression-Patterns.html#index-_0040code_007bBEGIN_007d-pattern_002c-Boolean-patterns-and-902"><code>BEGIN</code>
pattern, Boolean patterns and</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Exit-Statement.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bexit_007d-statement-and-986"><code>BEGIN</code>
pattern, <code>exit</code> statement and</a>: <a
href="Exit-Statement.html#Exit-Statement">Exit Statement</a></li>
-<li><a
href="Getline-Notes.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bgetline_007d-and-496"><code>BEGIN</code>
pattern, <code>getline</code> and</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Print-Examples.html#index-_0040code_007bBEGIN_007d-pattern_002c-headings_0040comma_007b_007d-adding-509"><code>BEGIN</code>
pattern, headings, adding</a>: <a
href="Print-Examples.html#Print-Examples">Print Examples</a></li>
-<li><a
href="Next-Statement.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-972"><code>BEGIN</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="Next-Statement.html#Next-Statement">Next Statement</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-924"><code>BEGIN</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Output-Separators.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bOFS_007d_002f_0040code_007bORS_007d-variables_002c-assigning-values-to-518"><code>BEGIN</code>
pattern, <code>OFS</code>/<code>ORS</code> variables, assigning values to</a>:
<a href="Output-Separators.html#Output-Separators">Output Separators</a></li>
-<li><a
href="Using-BEGIN_002fEND.html#index-_0040code_007bBEGIN_007d-pattern_002c-operators-and-914"><code>BEGIN</code>
pattern, operators and</a>: <a
href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using BEGIN/END</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040command_007bpgawk_007d-program-1446"><code>BEGIN</code>
pattern, <samp><span class="command">pgawk</span></samp> program</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bprint_007d-statement-and-920"><code>BEGIN</code>
pattern, <code>print</code> statement and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bpwcat_007d-program-1707"><code>BEGIN</code>
pattern, <code>pwcat</code> program</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Cut-Program.html#index-_0040code_007bBEGIN_007d-pattern_002c-running-_0040command_007bawk_007d-programs-and-1748"><code>BEGIN</code>
pattern, running <samp><span class="command">awk</span></samp> programs
and</a>: <a href="Cut-Program.html#Cut-Program">Cut Program</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bTEXTDOMAIN_007d-variable-and-1353"><code>BEGIN</code>
pattern, <code>TEXTDOMAIN</code> variable and</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Filetrans-Function.html#index-_0040code_007bbeginfile_007d-user_002ddefined-function-1668"><code>beginfile</code>
user-defined function</a>: <a
href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a></li>
-<li><a
href="BTL.html#index-Bell-Laboratories-_0040command_007bawk_007d-extensions-1831">Bell
Laboratories <samp><span class="command">awk</span></samp> extensions</a>: <a
href="BTL.html#BTL">BTL</a></li>
-<li><a href="Contributors.html#index-Benzinger_002c-Michael-1866">Benzinger,
Michael</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="BeOS-Installation.html#index-BeOS-1898">BeOS</a>: <a
href="BeOS-Installation.html#BeOS-Installation">BeOS Installation</a></li>
-<li><a href="Acknowledgments.html#index-Berry_002c-Karl-45">Berry, Karl</a>:
<a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="User_002dmodified.html#index-binary-input_002foutput-996">binary
input/output</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bbindtextdomain_007d-function-_0028C-library_0029-1318"><code>bindtextdomain</code>
function (C library)</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1352"><code>bindtextdomain</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="I18N-Functions.html#index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1274"><code>bindtextdomain</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="I18N-Functions.html#I18N-Functions">I18N Functions</a></li>
-<li><a
href="I18N-Portability.html#index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1379"><code>bindtextdomain</code>
function (<samp><span class="command">gawk</span></samp>), portability
and</a>: <a href="I18N-Portability.html#I18N-Portability">I18N
Portability</a></li>
-<li><a
href="PC-Using.html#index-_0040code_007bBINMODE_007d-variable-1911"><code>BINMODE</code>
variable</a>: <a href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bBINMODE_007d-variable-995"><code>BINMODE</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007bbits2str_007d-user_002ddefined-function-1263"><code>bits2str</code>
user-defined function</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Bitwise-Functions.html#index-bitwise_002c-complement-1250">bitwise,
complement</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a
href="Bitwise-Functions.html#index-bitwise_002c-operations-1245">bitwise,
operations</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="Bitwise-Functions.html#index-bitwise_002c-shift-1252">bitwise,
shift</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="Statements.html#index-body_002c-in-actions-944">body, in
actions</a>: <a href="Statements.html#Statements">Statements</a></li>
-<li><a href="While-Statement.html#index-body_002c-in-loops-954">body, in
loops</a>: <a href="While-Statement.html#While-Statement">While
Statement</a></li>
-<li><a href="Boolean-Ops.html#index-Boolean-expressions-778">Boolean
expressions</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Expression-Patterns.html#index-Boolean-expressions_002c-as-patterns-901">Boolean
expressions, as patterns</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Boolean-Ops.html#index-Boolean-operators_002c-See-Boolean-expressions-780">Boolean
operators, See Boolean expressions</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Quoting.html#index-Bourne-shell_002c-quoting-rules-for-124">Bourne shell,
quoting rules for</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Action-Overview.html#index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-actions-and-933">braces
(<code>{}</code>), actions and</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="Profiling.html#index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-_0040command_007bpgawk_007d-program-1453">braces
(<code>{}</code>), <samp><span class="command">pgawk</span></samp>
program</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Statements.html#index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-statements_002c-grouping-946">braces
(<code>{}</code>), statements, grouping</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Regexp-Operators.html#index-bracket-expressions_002c-See-character-lists-237">bracket
expressions, See character lists</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Break-Statement.html#index-_0040code_007bbreak_007d-statement-961"><code>break</code>
statement</a>: <a href="Break-Statement.html#Break-Statement">Break
Statement</a></li>
-<li><a href="Other-Versions.html#index-Brennan_002c-Michael-1937">Brennan,
Michael</a>: <a href="Other-Versions.html#Other-Versions">Other
Versions</a></li>
-<li><a href="Simple-Sed.html#index-Brennan_002c-Michael-1815">Brennan,
Michael</a>: <a href="Simple-Sed.html#Simple-Sed">Simple Sed</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-Brennan_002c-Michael-1405">Brennan,
Michael</a>: <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way
I/O</a></li>
-<li><a href="Delete.html#index-Brennan_002c-Michael-1113">Brennan,
Michael</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Contributors.html#index-Broder_002c-Alan-J_002e_0040_003a-1863">Broder,
Alan J.</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Bugs.html#index-Brown_002c-Martin-1930">Brown, Martin</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Brown_002c-Martin-1861">Brown,
Martin</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Brown_002c-Martin-57">Brown,
Martin</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Portal-Files.html#index-BSD-portals-1431">BSD portals</a>: <a
href="Portal-Files.html#Portal-Files">Portal Files</a></li>
-<li><a
href="Glossary.html#index-BSD_002dbased-operating-systems-2083">BSD-based
operating systems</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Contributors.html#index-Buening_002c-Andreas-1864">Buening,
Andreas</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Buening_002c-Andreas-58">Buening,
Andreas</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-buffering_002c-input_002foutput-1415">buffering,
input/output</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="I_002fO-Functions.html#index-buffering_002c-input_002foutput-1226">buffering,
input/output</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="I_002fO-Functions.html#index-buffering_002c-interactive-vs_002e-noninteractive-1223">buffering,
interactive vs. noninteractive</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a href="I_002fO-Functions.html#index-buffers_002c-flushing-1215">buffers,
flushing</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-buffers_002c-operators-for-298">buffers,
operators for</a>: <a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="Bugs.html#index-bug-reports_002c-email-address_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1926">bug
reports, email address, <code>address@hidden</code></a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a
href="Bugs.html#index-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-bug-reporting-address-1924"><code>address@hidden</code>
bug reporting address</a>: <a href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Functions.html#index-built_002din-functions-1141">built-in
functions</a>: <a href="Functions.html#Functions">Functions</a></li>
-<li><a
href="Calling-Built_002din.html#index-built_002din-functions_002c-evaluation-order-1149">built-in
functions, evaluation order</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="Built_002din-Variables.html#index-built_002din-variables-990">built-in
variables</a>: <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a></li>
-<li><a
href="Options.html#index-built_002din-variables_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1491">built-in
variables, <code>-v</code> option, setting with</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Auto_002dset.html#index-built_002din-variables_002c-conveying-information-1041">built-in
variables, conveying information</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="User_002dmodified.html#index-built_002din-variables_002c-user_002dmodifiable-993">built-in
variables, user-modifiable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a href="Function-Caveats.html#index-call-by-reference-1291">call by
reference</a>: <a href="Function-Caveats.html#Function-Caveats">Function
Caveats</a></li>
-<li><a href="Function-Caveats.html#index-call-by-value-1290">call by
value</a>: <a href="Function-Caveats.html#Function-Caveats">Function
Caveats</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-caret-_0028_0040code_007b_005e_007d_0029-306">caret
(<code>^</code>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-caret-_0028_0040code_007b_005e_007d_0029-227">caret
(<code>^</code>)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Options.html#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-1538">caret
(<code>^</code>), <code>^</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-818">caret
(<code>^</code>), <code>^</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Options.html#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-1540">caret
(<code>^</code>), <code>^=</code> operator</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Precedence.html#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-884">caret
(<code>^</code>), <code>^=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-695">caret
(<code>^</code>), <code>^=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Character-Lists.html#index-caret-_0028_0040code_007b_005e_007d_0029_002c-in-character-lists-262">caret
(<code>^</code>), in character lists</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Switch-Statement.html#index-_0040code_007bcase_007d-keyword-959"><code>case</code>
keyword</a>: <a href="Switch-Statement.html#Switch-Statement">Switch
Statement</a></li>
-<li><a
href="Array-Intro.html#index-case-sensitivity_002c-array-indices-and-1087">case
sensitivity, array indices and</a>: <a
href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="String-Functions.html#index-case-sensitivity_002c-converting-case-1193">case
sensitivity, converting case</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Library-Functions.html#index-case-sensitivity_002c-example-programs-1595">case
sensitivity, example programs</a>: <a
href="Library-Functions.html#Library-Functions">Library Functions</a></li>
-<li><a
href="Case_002dsensitivity.html#index-case-sensitivity_002c-_0040command_007bgawk_007d-317">case
sensitivity, <samp><span class="command">gawk</span></samp></a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="User_002dmodified.html#index-case-sensitivity_002c-regexps-and-1016">case
sensitivity, regexps and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Case_002dsensitivity.html#index-case-sensitivity_002c-regexps-and-315">case
sensitivity, regexps and</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="User_002dmodified.html#index-case-sensitivity_002c-string-comparisons-and-1015">case
sensitivity, string comparisons and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a href="Ordinal-Functions.html#index-character-encodings-1649">character
encodings</a>: <a href="Ordinal-Functions.html#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a href="Character-Lists.html#index-character-lists-256">character
lists</a>: <a href="Character-Lists.html#Character-Lists">Character
Lists</a></li>
-<li><a href="Regexp-Operators.html#index-character-lists-235">character
lists</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Character-Lists.html#index-character-lists_002c-character-classes-269">character
lists, character classes</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Character-Lists.html#index-character-lists_002c-collating-elements-271">character
lists, collating elements</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Character-Lists.html#index-character-lists_002c-collating-symbols-274">character
lists, collating symbols</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Regexp-Operators.html#index-character-lists_002c-complemented-238">character
lists, complemented</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Character-Lists.html#index-character-lists_002c-equivalence-classes-276">character
lists, equivalence classes</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Character-Lists.html#index-character-lists_002c-non_002dASCII-272">character
lists, non-ASCII</a>: <a href="Character-Lists.html#Character-Lists">Character
Lists</a></li>
-<li><a
href="Character-Lists.html#index-character-lists_002c-range-expressions-257">character
lists, range expressions</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a href="Ordinal-Functions.html#index-character-sets-1648">character
sets</a>: <a href="Ordinal-Functions.html#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a
href="Glossary.html#index-character-sets-_0028machine-character-encodings_0029-2060">character
sets (machine character encodings)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Regexp-Operators.html#index-character-sets_002c-See-Also-character-lists-236">character
sets, See Also character lists</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a href="Wc-Program.html#index-characters_002c-counting-1782">characters,
counting</a>: <a href="Wc-Program.html#Wc-Program">Wc Program</a></li>
-<li><a
href="Translate-Program.html#index-characters_002c-transliterating-1797">characters,
transliterating</a>: <a
href="Translate-Program.html#Translate-Program">Translate Program</a></li>
-<li><a
href="Ordinal-Functions.html#index-characters_002c-values-of-as-numbers-1644">characters,
values of as numbers</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="Acknowledgments.html#index-Chassell_002c-Robert-J_002e_0040_003a-46">Chassell,
Robert J.</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Sample-Library.html#index-_0040code_007bchdir_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2011"><code>chdir</code>
function, implementing in <samp><span class="command">gawk</span></samp></a>:
<a href="Sample-Library.html#Sample-Library">Sample Library</a></li>
-<li><a
href="Glossary.html#index-_0040command_007bchem_007d-utility-2061"><samp><span
class="command">chem</span></samp> utility</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Ordinal-Functions.html#index-_0040code_007bchr_007d-user_002ddefined-function-1647"><code>chr</code>
user-defined function</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a href="Cliff-Random-Function.html#index-Cliff-random-numbers-1638">Cliff
random numbers</a>: <a
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a></li>
-<li><a
href="Cliff-Random-Function.html#index-_0040code_007bcliff_005frand_007d-user_002ddefined-function-1641"><code>cliff_rand</code>
user-defined function</a>: <a
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a></li>
-<li><a
href="I_002fO-Functions.html#index-_0040code_007bclose_007d-function-1211"><code>close</code>
function</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-_0040code_007bclose_007d-function-594"><code>close</code>
function</a>: <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close
Files And Pipes</a></li>
-<li><a
href="Getline_002fPipe.html#index-_0040code_007bclose_007d-function-475"><code>close</code>
function</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="Getline_002fVariable_002fFile.html#index-_0040code_007bclose_007d-function-469"><code>close</code>
function</a>: <a
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">Getline/Variable/File</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-_0040code_007bclose_007d-function_002c-return-values-600"><code>close</code>
function, return values</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-_0040code_007bclose_007d-function_002c-two_002dway-pipes-and-1417"><code>close</code>
function, two-way pipes and</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="Contributors.html#index-Close_002c-Diane-1843">Close, Diane</a>:
<a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Manual-History.html#index-Close_002c-Diane-43">Close, Diane</a>:
<a href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a href="Character-Lists.html#index-collating-elements-273">collating
elements</a>: <a href="Character-Lists.html#Character-Lists">Character
Lists</a></li>
-<li><a href="Character-Lists.html#index-collating-symbols-275">collating
symbols</a>: <a href="Character-Lists.html#Character-Lists">Character
Lists</a></li>
-<li><a href="Print-Examples.html#index-columns_002c-aligning-511">columns,
aligning</a>: <a href="Print-Examples.html#Print-Examples">Print
Examples</a></li>
-<li><a href="Cut-Program.html#index-columns_002c-cutting-1746">columns,
cutting</a>: <a href="Cut-Program.html#Cut-Program">Cut Program</a></li>
-<li><a
href="Ranges.html#index-comma-_0028_0040code_007b_002c_007d_0029_002c-in-range-patterns-908">comma
(<code>,</code>), in range patterns</a>: <a
href="Ranges.html#Ranges">Ranges</a></li>
-<li><a
href="Other-Arguments.html#index-command-line_002c-arguments-1561">command
line, arguments</a>: <a href="Other-Arguments.html#Other-Arguments">Other
Arguments</a></li>
-<li><a
href="ARGC-and-ARGV.html#index-command-line_002c-arguments-1073">command line,
arguments</a>: <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a></li>
-<li><a href="Auto_002dset.html#index-command-line_002c-arguments-1045">command
line, arguments</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Running-gawk.html#index-command-line_002c-formats-79">command
line, formats</a>: <a href="Running-gawk.html#Running-gawk">Running
gawk</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-command-line_002c-_0040code_007bFS_007d-on_0040comma_007b_007d-setting-427">command
line, <code>FS</code> on, setting</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Command-Line.html#index-command-line_002c-invoking-_0040command_007bawk_007d-from-1467">command
line, invoking <samp><span class="command">awk</span></samp> from</a>: <a
href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a href="Options.html#index-command-line_002c-options-1478">command line,
options</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-command-line_002c-options-425">command
line, options</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a href="Long.html#index-command-line_002c-options-99">command line,
options</a>: <a href="Long.html#Long">Long</a></li>
-<li><a
href="Options.html#index-command-line_002c-options_002c-end-of-1496">command
line, options, end of</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Assignment-Options.html#index-command-line_002c-variables_0040comma_007b_007d-assigning-on-637">command
line, variables, assigning on</a>: <a
href="Assignment-Options.html#Assignment-Options">Assignment Options</a></li>
-<li><a
href="Getopt-Function.html#index-command_002dline-options_002c-processing-1683">command-line
options, processing</a>: <a href="Getopt-Function.html#Getopt-Function">Getopt
Function</a></li>
-<li><a
href="String-Extraction.html#index-command_002dline-options_002c-string-extraction-1365">command-line
options, string extraction</a>: <a
href="String-Extraction.html#String-Extraction">String Extraction</a></li>
-<li><a href="Comments.html#index-commenting-115">commenting</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Statements_002fLines.html#index-commenting_002c-backslash-continuation-and-161">commenting,
backslash continuation and</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Bugs.html#index-_0040code_007bcomp_002elang_002eawk_007d-newsgroup-1928"><code>comp.lang.awk</code>
newsgroup</a>: <a href="Bugs.html#Bugs">Bugs</a></li>
-<li><a
href="Typing-and-Comparison.html#index-comparison-expressions-737">comparison
expressions</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Expression-Patterns.html#index-comparison-expressions_002c-as-patterns-891">comparison
expressions, as patterns</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Typing-and-Comparison.html#index-comparison-expressions_002c-string-vs_002e-regexp-767">comparison
expressions, string vs. regexp</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="POSIX_002fGNU.html#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-extensions-1833">compatibility
mode (<samp><span class="command">gawk</span></samp>), extensions</a>: <a
href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="Special-Caveats.html#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-_0040value_007bFN_007ds-585">compatibility
mode (<samp><span class="command">gawk</span></samp>), file names</a>: <a
href="Special-Caveats.html#Special-Caveats">Special Caveats</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-hexadecimal-numbers-617">compatibility
mode (<samp><span class="command">gawk</span></samp>), hexadecimal
numbers</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-octal-numbers-616">compatibility
mode (<samp><span class="command">gawk</span></samp>), octal numbers</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="Options.html#index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-specifying-1502">compatibility
mode (<samp><span class="command">gawk</span></samp>), specifying</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a href="Glossary.html#index-compiled-programs-2062">compiled
programs</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Basic-High-Level.html#index-compiled-programs-2026">compiled
programs</a>: <a href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007bcompl_007d-function-_0028_0040command_007bgawk_007d_0029-1260"><code>compl</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Bitwise-Functions.html#index-complement_002c-bitwise-1251">complement,
bitwise</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a
href="Statements.html#index-compound-statements_0040comma_007b_007d-control-statements-and-942">compound
statements, control statements and</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a href="Concatenation.html#index-concatenating-665">concatenating</a>: <a
href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="Conditional-Exp.html#index-conditional-expressions-797">conditional
expressions</a>: <a href="Conditional-Exp.html#Conditional-Exp">Conditional
Exp</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dlint_007d-1891">configuration
option, <code>--disable-lint</code></a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-configuration-option_002c-_0040code_007b_002d_002ddisable_002dnls_007d-1893">configuration
option, <code>--disable-nls</code></a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-configuration-option_002c-_0040code_007b_002d_002denable_002dportals_007d-1882">configuration
option, <code>--enable-portals</code></a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-configuration-option_002c-_0040code_007b_002d_002denable_002dswitch_007d-1884">configuration
option, <code>--enable-switch</code></a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1889">configuration
option, <code>--with-included-gettext</code></a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Gawk-I18N.html#index-configuration-option_002c-_0040code_007b_002d_002dwith_002dincluded_002dgettext_007d-1394">configuration
option, <code>--with-included-gettext</code></a>: <a
href="Gawk-I18N.html#Gawk-I18N">Gawk I18N</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-configuration-options_0040comma_007b_007d-_0040command_007bgawk_007d-1880">configuration
options, <samp><span class="command">gawk</span></samp></a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Nondecimal-Data.html#index-constants_002c-nondecimal-1401">constants,
nondecimal</a>: <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal
Data</a></li>
-<li><a href="Constants.html#index-constants_002c-types-of-605">constants,
types of</a>: <a href="Constants.html#Constants">Constants</a></li>
-<li><a
href="Continue-Statement.html#index-_0040code_007bcontinue_007d-statement-966"><code>continue</code>
statement</a>: <a href="Continue-Statement.html#Continue-Statement">Continue
Statement</a></li>
-<li><a href="Statements.html#index-control-statements-939">control
statements</a>: <a href="Statements.html#Statements">Statements</a></li>
-<li><a
href="String-Functions.html#index-converting_002c-case-1194">converting,
case</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="Time-Functions.html#index-converting_002c-dates-to-timestamps-1239">converting,
dates to timestamps</a>: <a href="Time-Functions.html#Time-Functions">Time
Functions</a></li>
-<li><a
href="Numeric-Array-Subscripts.html#index-converting_002c-during-subscripting-1119">converting,
during subscripting</a>: <a
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a href="Conversion.html#index-converting_002c-numbers-643">converting,
numbers</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Bitwise-Functions.html#index-converting_002c-numbers_002c-to-strings-1267">converting,
numbers, to strings</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Conversion.html#index-converting_002c-strings-to-numbers-640">converting,
strings to numbers</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bCONVFMT_007d-variable-999"><code>CONVFMT</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Conversion.html#index-_0040code_007bCONVFMT_007d-variable-646"><code>CONVFMT</code>
variable</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Numeric-Array-Subscripts.html#index-_0040code_007bCONVFMT_007d-variable_002c-array-subscripts-and-1118"><code>CONVFMT</code>
variable, array subscripts and</a>: <a
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a href="Two_002dway-I_002fO.html#index-coprocesses-1409">coprocesses</a>:
<a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="Redirection.html#index-coprocesses-556">coprocesses</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-coprocesses_002c-closing-592">coprocesses,
closing</a>: <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close
Files And Pipes</a></li>
-<li><a
href="Getline_002fCoprocess.html#index-coprocesses_002c-_0040code_007bgetline_007d-from-481">coprocesses,
<code>getline</code> from</a>: <a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007bcos_007d-function-1155"><code>cos</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a href="Wc-Program.html#index-counting-1779">counting</a>: <a
href="Wc-Program.html#Wc-Program">Wc Program</a></li>
-<li><a
href="Statements_002fLines.html#index-_0040command_007bcsh_007d-utility-156"><samp><span
class="command">csh</span></samp> utility</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="More-Complex.html#index-_0040command_007bcsh_007d-utility_002c-backslash-continuation-and-144"><samp><span
class="command">csh</span></samp> utility, backslash continuation and</a>: <a
href="More-Complex.html#More-Complex">More Complex</a></li>
-<li><a
href="Options.html#index-_0040command_007bcsh_007d-utility_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1559"><samp><span
class="command">csh</span></samp> utility, <code>POSIXLY_CORRECT</code>
environment variable</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-_0040command_007bcsh_007d-utility_002c-_0040code_007b_007c_0026_007d-operator_002c-comparison-with-1413"><samp><span
class="command">csh</span></samp> utility, <code>|&</code> operator,
comparison with</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Function-Example.html#index-_0040code_007bctime_007d-user_002ddefined-function-1288"><code>ctime</code>
user-defined function</a>: <a
href="Function-Example.html#Function-Example">Function Example</a></li>
-<li><a
href="Explaining-gettext.html#index-currency-symbols_002c-localization-1334">currency
symbols, localization</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Configuration-Philosophy.html#index-_0040code_007bcustom_002eh_007d-file-1895"><code>custom.h</code>
file</a>: <a
href="Configuration-Philosophy.html#Configuration-Philosophy">Configuration
Philosophy</a></li>
-<li><a
href="Cut-Program.html#index-_0040command_007bcut_007d-utility-1743"><samp><span
class="command">cut</span></samp> utility</a>: <a
href="Cut-Program.html#Cut-Program">Cut Program</a></li>
-<li><a
href="Cut-Program.html#index-_0040code_007bcut_002eawk_007d-program-1747"><code>cut.awk</code>
program</a>: <a href="Cut-Program.html#Cut-Program">Cut Program</a></li>
-<li><a
href="Conventions.html#index-d_002ec_002e_002c-See-dark-corner-30">d.c., See
dark corner</a>: <a href="Conventions.html#Conventions">Conventions</a></li>
-<li><a href="Glossary.html#index-dark-corner-2063">dark corner</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Truth-Values.html#index-dark-corner-736">dark corner</a>: <a
href="Truth-Values.html#Truth-Values">Truth Values</a></li>
-<li><a href="Assignment-Ops.html#index-dark-corner-707">dark corner</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="Format-Modifiers.html#index-dark-corner-541">dark corner</a>: <a
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a></li>
-<li><a href="Conventions.html#index-dark-corner-31">dark corner</a>: <a
href="Conventions.html#Conventions">Conventions</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-dark-corner_002c-array-subscripts-1125">dark
corner, array subscripts</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="Break-Statement.html#index-dark-corner_002c-_0040code_007bbreak_007d-statement-964">dark
corner, <code>break</code> statement</a>: <a
href="Break-Statement.html#Break-Statement">Break Statement</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-dark-corner_002c-_0040code_007bclose_007d-function-599">dark
corner, <code>close</code> function</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Assignment-Options.html#index-dark-corner_002c-command_002dline-arguments-639">dark
corner, command-line arguments</a>: <a
href="Assignment-Options.html#Assignment-Options">Assignment Options</a></li>
-<li><a
href="Continue-Statement.html#index-dark-corner_002c-_0040code_007bcontinue_007d-statement-968">dark
corner, <code>continue</code> statement</a>: <a
href="Continue-Statement.html#Continue-Statement">Continue Statement</a></li>
-<li><a
href="Conversion.html#index-dark-corner_002c-_0040code_007bCONVFMT_007d-variable-647">dark
corner, <code>CONVFMT</code> variable</a>: <a
href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Other-Arguments.html#index-dark-corner_002c-escape-sequences-1566">dark
corner, escape sequences</a>: <a
href="Other-Arguments.html#Other-Arguments">Other Arguments</a></li>
-<li><a
href="Escape-Sequences.html#index-dark-corner_002c-escape-sequences_002c-for-metacharacters-220">dark
corner, escape sequences, for metacharacters</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Exit-Statement.html#index-dark-corner_002c-_0040code_007bexit_007d-statement-988">dark
corner, <code>exit</code> statement</a>: <a
href="Exit-Statement.html#Exit-Statement">Exit Statement</a></li>
-<li><a
href="Field-Splitting-Summary.html#index-dark-corner_002c-field-separators-435">dark
corner, field separators</a>: <a
href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a
href="Auto_002dset.html#index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-1057">dark
corner, <code>FILENAME</code> variable</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Getline-Notes.html#index-dark-corner_002c-_0040code_007bFILENAME_007d-variable-494">dark
corner, <code>FILENAME</code> variable</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Auto_002dset.html#index-dark-corner_002c-_0040code_007bFNR_007d_002f_0040code_007bNR_007d-variables-1070">dark
corner, <code>FNR</code>/<code>NR</code> variables</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Control-Letters.html#index-dark-corner_002c-format_002dcontrol-characters-534">dark
corner, format-control characters</a>: <a
href="Control-Letters.html#Control-Letters">Control Letters</a></li>
-<li><a
href="Single-Character-Fields.html#index-dark-corner_002c-_0040code_007bFS_007d-as-null-string-421">dark
corner, <code>FS</code> as null string</a>: <a
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a></li>
-<li><a href="Records.html#index-dark-corner_002c-input-files-359">dark corner,
input files</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Command-Line.html#index-dark-corner_002c-invoking-_0040command_007bawk_007d-1474">dark
corner, invoking <samp><span class="command">awk</span></samp></a>: <a
href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a
href="Multiple-Line.html#index-dark-corner_002c-multiline-records-453">dark
corner, multiline records</a>: <a
href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a
href="Changing-Fields.html#index-dark-corner_002c-_0040code_007bNF_007d-variable_002c-decrementing-398">dark
corner, <code>NF</code> variable, decrementing</a>: <a
href="Changing-Fields.html#Changing-Fields">Changing Fields</a></li>
-<li><a
href="OFMT.html#index-dark-corner_002c-_0040code_007bOFMT_007d-variable-524">dark
corner, <code>OFMT</code> variable</a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-dark-corner_002c-regexp-constants-624">dark
corner, regexp constants</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="Assignment-Ops.html#index-dark-corner_002c-regexp-constants_002c-_0040code_007b_002f_003d_007d-operator-and-703">dark
corner, regexp constants, <code>/=</code> operator and</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-dark-corner_002c-regexp-constants_002c-as-arguments-to-user_002ddefined-functions-628">dark
corner, regexp constants, as arguments to user-defined functions</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="String-Functions.html#index-dark-corner_002c-_0040code_007bsplit_007d-function-1179">dark
corner, <code>split</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Records.html#index-dark-corner_002c-strings_002c-storing-373">dark
corner, strings, storing</a>: <a href="Records.html#Records">Records</a></li>
-<li><a href="Constant-Size.html#index-data_002c-fixed_002dwidth-438">data,
fixed-width</a>: <a href="Constant-Size.html#Constant-Size">Constant
Size</a></li>
-<li><a
href="Basic-High-Level.html#index-data_002ddriven-languages-2032">data-driven
languages</a>: <a href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a></li>
-<li><a
href="Group-Functions.html#index-database_002c-group_002c-reading-1720">database,
group, reading</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-database_002c-users_0040comma_007b_007d-reading-1693">database,
users, reading</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="Time-Functions.html#index-_0040command_007bdate_007d-utility_002c-GNU-1233"><samp><span
class="command">date</span></samp> utility, GNU</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Time-Functions.html#index-_0040code_007bdate_007d-utility_002c-POSIX-1243"><code>date</code>
utility, POSIX</a>: <a href="Time-Functions.html#Time-Functions">Time
Functions</a></li>
-<li><a
href="Time-Functions.html#index-dates_002c-converting-to-timestamps-1240">dates,
converting to timestamps</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Explaining-gettext.html#index-dates_002c-information-related-to_0040comma_007b_007d-localization-1339">dates,
information related to, localization</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="Bugs.html#index-Davies_002c-Stephen-1934">Davies, Stephen</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Davies_002c-Stephen-1860">Davies,
Stephen</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1346"><code>dcgettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="I18N-Functions.html#index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1272"><code>dcgettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="I18N-Functions.html#I18N-Functions">I18N Functions</a></li>
-<li><a
href="I18N-Portability.html#index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1380"><code>dcgettext</code>
function (<samp><span class="command">gawk</span></samp>), portability
and</a>: <a href="I18N-Portability.html#I18N-Portability">I18N
Portability</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1347"><code>dcngettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="I18N-Functions.html#index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1273"><code>dcngettext</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="I18N-Functions.html#I18N-Functions">I18N Functions</a></li>
-<li><a
href="I18N-Portability.html#index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029_002c-portability-and-1381"><code>dcngettext</code>
function (<samp><span class="command">gawk</span></samp>), portability
and</a>: <a href="I18N-Portability.html#I18N-Portability">I18N
Portability</a></li>
-<li><a href="Two_002dway-I_002fO.html#index-deadlocks-1414">deadlocks</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Known-Bugs.html#index-debugging-_0040command_007bgawk_007d-1585">debugging
<samp><span class="command">gawk</span></samp></a>: <a
href="Known-Bugs.html#Known-Bugs">Known Bugs</a></li>
-<li><a
href="Bugs.html#index-debugging-_0040command_007bgawk_007d_002c-bug-reports-1922">debugging
<samp><span class="command">gawk</span></samp>, bug reports</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Increment-Ops.html#index-decrement-operators-719">decrement
operators</a>: <a href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Switch-Statement.html#index-_0040code_007bdefault_007d-keyword-960"><code>default</code>
keyword</a>: <a href="Switch-Statement.html#Switch-Statement">Switch
Statement</a></li>
-<li><a href="Bugs.html#index-Deifik_002c-Scott-1931">Deifik, Scott</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Deifik_002c-Scott-1855">Deifik,
Scott</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Deifik_002c-Scott-59">Deifik,
Scott</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Delete.html#index-_0040code_007bdelete_007d-statement-1103"><code>delete</code>
statement</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a href="Delete.html#index-deleting-elements-in-arrays-1104">deleting
elements in arrays</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a href="Delete.html#index-deleting-entire-arrays-1110">deleting entire
arrays</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="ARGC-and-ARGV.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1074">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>ARGC</code>/<code>ARGV</code>
variables</a>: <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a></li>
-<li><a
href="Auto_002dset.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bARGIND_007d-variable-1048">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>ARGIND</code> variable</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Delete.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-array-elements_002c-deleting-1111">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, array elements, deleting</a>: <a
href="Delete.html#Delete">Delete</a></li>
-<li><a
href="AWKPATH-Variable.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bAWKPATH_007d-environment-variable-1571">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>AWKPATH</code> environment
variable</a>: <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH
Variable</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-917">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>BEGIN</code>/<code>END</code>
patterns</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="PC-Using.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-1910">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>BINMODE</code> variable</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="User_002dmodified.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-998">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>BINMODE</code> variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bclose_007d-function-595">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>close</code> function</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Auto_002dset.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bERRNO_007d-variable-1054">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>ERRNO</code> variable</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Special-FD.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-error-messages-575">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, error messages</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="User_002dmodified.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-1004">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>FIELDWIDTHS</code> variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Calling-Built_002din.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-function-arguments-_0028_0040command_007bgawk_007d_0029-1146">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, function arguments (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="Getline.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bgetline_007d-command-459">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>getline</code> command</a>: <a
href="Getline.html#Getline">Getline</a></li>
-<li><a
href="User_002dmodified.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-1014">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>IGNORECASE</code> variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Redirection.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-561">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, implementation limitations</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Getline-Notes.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-488">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, implementation limitations</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Redirection.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-559">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, input/output operators</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Getline_002fCoprocess.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-486">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, input/output operators</a>: <a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="Conditional-Exp.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-line-continuations-801">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, line continuations</a>: <a
href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="User_002dmodified.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-1020">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>LINT</code> variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="String-Functions.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bmatch_007d-function-1174">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>match</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Nextfile-Statement.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-978">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>next</code>/<code>nextfile</code>
statements</a>: <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a></li>
-<li><a
href="Format-Modifiers.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-538">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>print</code>/<code>printf</code>
statements</a>: <a href="Format-Modifiers.html#Format-Modifiers">Format
Modifiers</a></li>
-<li><a
href="Auto_002dset.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bPROCINFO_007d-array-1062">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>PROCINFO</code> array</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Records.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-record-separators-365">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, record separators</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regexp-constants-627">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, regexp constants</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="Case_002dsensitivity.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regular-expressions-318">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, regular expressions</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="Records.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRS_007d_002f_0040code_007bRT_007d-variables-369">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>RS</code>/<code>RT</code>
variables</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Auto_002dset.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRT_007d-variable-1066">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>RT</code> variable</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Single-Character-Fields.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-single_002dcharacter-fields-418">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, single-character fields</a>: <a
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a></li>
-<li><a
href="String-Functions.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bsplit_007d-function-1178">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>split</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Scalar-Constants.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings-608">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, strings</a>: <a
href="Scalar-Constants.html#Scalar-Constants">Scalar Constants</a></li>
-<li><a
href="Records.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings_002c-storing-372">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, strings, storing</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="String-Functions.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1181">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>strtonum</code> function (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="User_002dmodified.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bTEXTDOMAIN_007d-variable-1039">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, <code>TEXTDOMAIN</code> variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Arithmetic-Ops.html#index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-trunc_002dmod-operation-657">differences
in <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, trunc-mod operation</a>: <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="Sample-Library.html#index-directories_002c-changing-2014">directories,
changing</a>: <a href="Sample-Library.html#Sample-Library">Sample
Library</a></li>
-<li><a
href="Igawk-Program.html#index-directories_002c-searching-1823">directories,
searching</a>: <a href="Igawk-Program.html#Igawk-Program">Igawk Program</a></li>
-<li><a
href="AWKPATH-Variable.html#index-directories_002c-searching-1569">directories,
searching</a>: <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH
Variable</a></li>
-<li><a href="Arithmetic-Ops.html#index-division-656">division</a>: <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="Do-Statement.html#index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-955"><code>do</code>-<code>while</code>
statement</a>: <a href="Do-Statement.html#Do-Statement">Do Statement</a></li>
-<li><a
href="Regexp-Usage.html#index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-181"><code>do</code>-<code>while</code>
statement</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Library-Names.html#index-documentation_002c-of-_0040command_007bawk_007d-programs-1601">documentation,
of <samp><span class="command">awk</span></samp> programs</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Manual-History.html#index-documentation_002c-online-38">documentation,
online</a>: <a href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a
href="Dupword-Program.html#index-documents_0040comma_007b_007d-searching-1788">documents,
searching</a>: <a href="Dupword-Program.html#Dupword-Program">Dupword
Program</a></li>
-<li><a
href="Regexp-Operators.html#index-dollar-sign-_0028_0040code_007b_0024_007d_0029-229">dollar
sign (<code>$</code>)</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Precedence.html#index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-812">dollar
sign (<code>$</code>), <code>$</code> field operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Fields.html#index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-386">dollar
sign (<code>$</code>), <code>$</code> field operator</a>: <a
href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Increment-Ops.html#index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-incrementing-fields-and-arrays-718">dollar
sign (<code>$</code>), incrementing fields and arrays</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Quoting.html#index-double-quote-_0028_0040code_007b_0022_007d_0029-129">double
quote (<code>"</code>)</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Read-Terminal.html#index-double-quote-_0028_0040code_007b_0022_007d_0029-91">double
quote (<code>"</code>)</a>: <a href="Read-Terminal.html#Read-Terminal">Read
Terminal</a></li>
-<li><a
href="Computed-Regexps.html#index-double-quote-_0028_0040code_007b_0022_007d_0029_002c-regexp-constants-335">double
quote (<code>"</code>), regexp constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Basic-Data-Typing.html#index-double_002dprecision-floating_002dpoint-2043">double-precision
floating-point</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic
Data Typing</a></li>
-<li><a href="Acknowledgments.html#index-Drepper_002c-Ulrich-53">Drepper,
Ulrich</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Internals.html#index-_0040code_007bdupnode_007d-internal-function-1998"><code>dupnode</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Dupword-Program.html#index-_0040code_007bdupword_002eawk_007d-program-1790"><code>dupword.awk</code>
program</a>: <a href="Dupword-Program.html#Dupword-Program">Dupword
Program</a></li>
-<li><a href="Ordinal-Functions.html#index-EBCDIC-1651">EBCDIC</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="Egrep-Program.html#index-_0040command_007begrep_007d-utility-1754"><samp><span
class="command">egrep</span></samp> utility</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Character-Lists.html#index-_0040command_007begrep_007d-utility-268"><samp><span
class="command">egrep</span></samp> utility</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Egrep-Program.html#index-_0040code_007begrep_002eawk_007d-program-1755"><code>egrep.awk</code>
program</a>: <a href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Reference-to-Elements.html#index-elements-in-arrays-1091">elements in
arrays</a>: <a
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a></li>
-<li><a
href="Assigning-Elements.html#index-elements-in-arrays_002c-assigning-1095">elements
in arrays, assigning</a>: <a
href="Assigning-Elements.html#Assigning-Elements">Assigning Elements</a></li>
-<li><a href="Delete.html#index-elements-in-arrays_002c-deleting-1106">elements
in arrays, deleting</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Scanning-an-Array.html#index-elements-in-arrays_002c-order-of-1102">elements
in arrays, order of</a>: <a
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="Scanning-an-Array.html#index-elements-in-arrays_002c-scanning-1096">elements
in arrays, scanning</a>: <a
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="Bugs.html#index-email-address-for-bug-reports_002c-_0040code_007bbug_002dgawk_0040_0040gnu_002eorg_007d-1925">email
address for bug reports, <code>address@hidden</code></a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a
href="TCP_002fIP-Networking.html#index-_0040code_007bEMISTERED_007d-1424"><code>EMISTERED</code></a>:
<a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a href="Empty.html#index-empty-pattern-926">empty pattern</a>: <a
href="Empty.html#Empty">Empty</a></li>
-<li><a
href="Regexp-Field-Splitting.html#index-empty-strings_002c-See-null-strings-417">empty
strings, See null strings</a>: <a
href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a></li>
-<li><a
href="BEGIN_002fEND.html#index-_0040code_007bEND_007d-pattern-913"><code>END</code>
pattern</a>: <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a></li>
-<li><a
href="Assert-Function.html#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bassert_007d-user_002ddefined-function-and-1626"><code>END</code>
pattern, <code>assert</code> user-defined function and</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a
href="Egrep-Program.html#index-_0040code_007bEND_007d-pattern_002c-backslash-continuation-and-1759"><code>END</code>
pattern, backslash continuation and</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Expression-Patterns.html#index-_0040code_007bEND_007d-pattern_002c-Boolean-patterns-and-903"><code>END</code>
pattern, Boolean patterns and</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Exit-Statement.html#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bexit_007d-statement-and-987"><code>END</code>
pattern, <code>exit</code> statement and</a>: <a
href="Exit-Statement.html#Exit-Statement">Exit Statement</a></li>
-<li><a
href="Next-Statement.html#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-973"><code>END</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="Next-Statement.html#Next-Statement">Next Statement</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-925"><code>END</code>
pattern, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Using-BEGIN_002fEND.html#index-_0040code_007bEND_007d-pattern_002c-operators-and-915"><code>END</code>
pattern, operators and</a>: <a
href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using BEGIN/END</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bEND_007d-pattern_002c-_0040command_007bpgawk_007d-program-1447"><code>END</code>
pattern, <samp><span class="command">pgawk</span></samp> program</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bEND_007d-pattern_002c-_0040code_007bprint_007d-statement-and-921"><code>END</code>
pattern, <code>print</code> statement and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Filetrans-Function.html#index-_0040code_007bendfile_007d-user_002ddefined-function-1669"><code>endfile</code>
user-defined function</a>: <a
href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bendgrent_007d-function-_0028C-library_0029-1739"><code>endgrent</code>
function (C library)</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bendgrent_007d-user_002ddefined-function-1740"><code>endgrent</code>
user-defined function</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bendpwent_007d-function-_0028C-library_0029-1715"><code>endpwent</code>
function (C library)</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bendpwent_007d-user_002ddefined-function-1716"><code>endpwent</code>
user-defined function</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bENVIRON_007d-variable-1051"><code>ENVIRON</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Auto_002dset.html#index-environment-variables-1052">environment
variables</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Glossary.html#index-epoch_002c-definition-of-2064">epoch,
definition of</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Assignment-Ops.html#index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_007d-operator-674">equals
sign (<code>=</code>), <code>=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Precedence.html#index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-846">equals
sign (<code>=</code>), <code>==</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-757">equals
sign (<code>=</code>), <code>==</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Character-Lists.html#index-EREs-_0028Extended-Regular-Expressions_0029-267">EREs
(Extended Regular Expressions)</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Internals.html#index-_0040code_007bERRNO_007d-variable-2009"><code>ERRNO</code>
variable</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bERRNO_007d-variable-1053"><code>ERRNO</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Getline.html#index-_0040code_007bERRNO_007d-variable-458"><code>ERRNO</code>
variable</a>: <a href="Getline.html#Getline">Getline</a></li>
-<li><a href="Special-FD.html#index-error-handling-576">error handling</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="Auto_002dset.html#index-error-handling_002c-_0040code_007bERRNO_007d-variable-and-1055">error
handling, <code>ERRNO</code> variable and</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Special-FD.html#index-error-output-572">error output</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="Gory-Details.html#index-escape-processing_002c-_0040code_007bgsub_007d_002f_0040code_007bgensub_007d_002f_0040code_007bsub_007d-functions-1197">escape
processing, <code>gsub</code>/<code>gensub</code>/<code>sub</code>
functions</a>: <a href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a href="Escape-Sequences.html#index-escape-sequences-184">escape
sequences</a>: <a href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a></li>
-<li><a
href="Options.html#index-escape-sequences_002c-unrecognized-1530">escape
sequences, unrecognized</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Increment-Ops.html#index-evaluation-order-728">evaluation
order</a>: <a href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Concatenation.html#index-evaluation-order_002c-concatenation-668">evaluation
order, concatenation</a>: <a
href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="Calling-Built_002din.html#index-evaluation-order_002c-functions-1147">evaluation
order, functions</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a href="Fields.html#index-examining-fields-376">examining fields</a>: <a
href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Egrep-Program.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-1757">exclamation
point (<code>!</code>), <code>!</code> operator</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Precedence.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-826">exclamation
point (<code>!</code>), <code>!</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Boolean-Ops.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-792">exclamation
point (<code>!</code>), <code>!</code> operator</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Precedence.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-848">exclamation
point (<code>!</code>), <code>!=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-759">exclamation
point (<code>!</code>), <code>!=</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Expression-Patterns.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-898">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Precedence.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-863">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-763">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Regexp-Constants.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-623">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Regexp-Constants.html#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="Computed-Regexps.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-330">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Case_002dsensitivity.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-322">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="Regexp-Usage.html#index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-178">exclamation
point (<code>!</code>), <code>!~</code> operator</a>: <a
href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Exit-Statement.html#index-_0040code_007bexit_007d-statement-985"><code>exit</code>
statement</a>: <a href="Exit-Statement.html#Exit-Statement">Exit
Statement</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007bexp_007d-function-1152"><code>exp</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a
href="Very-Simple.html#index-_0040command_007bexpand_007d-utility-142"><samp><span
class="command">expand</span></samp> utility</a>: <a
href="Very-Simple.html#Very-Simple">Very Simple</a></li>
-<li><a href="Expressions.html#index-expressions-604">expressions</a>: <a
href="Expressions.html#Expressions">Expressions</a></li>
-<li><a
href="Expression-Patterns.html#index-expressions_002c-as-patterns-890">expressions,
as patterns</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Assignment-Ops.html#index-expressions_002c-assignment-672">expressions,
assignment</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a href="Boolean-Ops.html#index-expressions_002c-Boolean-777">expressions,
Boolean</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Typing-and-Comparison.html#index-expressions_002c-comparison-738">expressions,
comparison</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Conditional-Exp.html#index-expressions_002c-conditional-798">expressions,
conditional</a>: <a href="Conditional-Exp.html#Conditional-Exp">Conditional
Exp</a></li>
-<li><a
href="Typing-and-Comparison.html#index-expressions_002c-matching_002c-See-comparison-expressions-739">expressions,
matching, See comparison expressions</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Conditional-Exp.html#index-expressions_002c-selecting-799">expressions,
selecting</a>: <a href="Conditional-Exp.html#Conditional-Exp">Conditional
Exp</a></li>
-<li><a
href="Character-Lists.html#index-Extended-Regular-Expressions-_0028EREs_0029-266">Extended
Regular Expressions (EREs)</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Using-Internal-File-Ops.html#index-_0040code_007bextension_007d-function-_0028_0040command_007bgawk_007d_0029-2018"><code>extension</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Using-Internal-File-Ops.html#Using-Internal-File-Ops">Using Internal File
Ops</a></li>
-<li><a
href="BTL.html#index-extensions_002c-Bell-Laboratories-_0040command_007bawk_007d-1830">extensions,
Bell Laboratories <samp><span class="command">awk</span></samp></a>: <a
href="BTL.html#BTL">BTL</a></li>
-<li><a
href="POSIX_002fGNU.html#index-extensions_002c-in-_0040command_007bgawk_007d_002c-not-in-POSIX-_0040command_007bawk_007d-1834">extensions,
in <samp><span class="command">gawk</span></samp>, not in POSIX <samp><span
class="command">awk</span></samp></a>: <a
href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="Other-Versions.html#index-extensions_002c-_0040command_007bmawk_007d-1943">extensions,
<samp><span class="command">mawk</span></samp></a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="Extract-Program.html#index-_0040code_007bextract_002eawk_007d-program-1812"><code>extract.awk</code>
program</a>: <a href="Extract-Program.html#Extract-Program">Extract
Program</a></li>
-<li><a
href="String-Extraction.html#index-extraction_002c-of-marked-strings-_0028internationalization_0029-1368">extraction,
of marked strings (internationalization)</a>: <a
href="String-Extraction.html#String-Extraction">String Extraction</a></li>
-<li><a href="Truth-Values.html#index-false_002c-logical-733">false,
logical</a>: <a href="Truth-Values.html#Truth-Values">Truth Values</a></li>
-<li><a
href="GNU-Free-Documentation-License.html#index-FDL-_0028Free-Documentation-License_0029-2087">FDL
(Free Documentation License)</a>: <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a
href="Adding-Code.html#index-features_002c-adding-to-_0040command_007bgawk_007d-1956">features,
adding to <samp><span class="command">gawk</span></samp></a>: <a
href="Adding-Code.html#Adding-Code">Adding Code</a></li>
-<li><a
href="Obsolete.html#index-features_002c-advanced_002c-See-advanced-features-1572">features,
advanced, See advanced features</a>: <a
href="Obsolete.html#Obsolete">Obsolete</a></li>
-<li><a href="Obsolete.html#index-features_002c-deprecated-1574">features,
deprecated</a>: <a href="Obsolete.html#Obsolete">Obsolete</a></li>
-<li><a
href="Undocumented.html#index-features_002c-undocumented-1579">features,
undocumented</a>: <a href="Undocumented.html#Undocumented">Undocumented</a></li>
-<li><a href="Contributors.html#index-Fenlason_002c-Jay-1842">Fenlason,
Jay</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="History.html#index-Fenlason_002c-Jay-18">Fenlason, Jay</a>: <a
href="History.html#History">History</a></li>
-<li><a
href="I_002fO-Functions.html#index-_0040code_007bfflush_007d-function-1213"><code>fflush</code>
function</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="Options.html#index-_0040code_007bfflush_007d-function_0040comma_007b_007d-unsupported-1542"><code>fflush</code>
function, unsupported</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Nonconstant-Fields.html#index-field-numbers-391">field
numbers</a>: <a href="Nonconstant-Fields.html#Nonconstant-Fields">Nonconstant
Fields</a></li>
-<li><a
href="Fields.html#index-field-operator-_0040code_007b_0024_007d-384">field
operator <code>$</code></a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Fields.html#index-field-operators_0040comma_007b_007d-dollar-sign-as-387">field
operators, dollar sign as</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a href="User_002dmodified.html#index-field-separators-1010">field
separators</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a href="Field-Separators.html#index-field-separators-403">field
separators</a>: <a href="Field-Separators.html#Field-Separators">Field
Separators</a></li>
-<li><a
href="Field-Separators.html#index-field-separators_002c-choice-of-408">field
separators, choice of</a>: <a
href="Field-Separators.html#Field-Separators">Field Separators</a></li>
-<li><a
href="User_002dmodified.html#index-field-separators_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1005">field
separators, <code>FIELDWIDTHS</code> variable and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Multiple-Line.html#index-field-separators_002c-in-multiline-records-454">field
separators, in multiline records</a>: <a
href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-field-separators_002c-on-command-line-426">field
separators, on command line</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Field-Splitting-Summary.html#index-field-separators_002c-POSIX-and-434">field
separators, POSIX and</a>: <a
href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a href="Fields.html#index-field-separators_002c-POSIX-and-381">field
separators, POSIX and</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Regexp-Field-Splitting.html#index-field-separators_002c-regular-expressions-as-414">field
separators, regular expressions as</a>: <a
href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a></li>
-<li><a
href="Field-Separators.html#index-field-separators_002c-regular-expressions-as-410">field
separators, regular expressions as</a>: <a
href="Field-Separators.html#Field-Separators">Field Separators</a></li>
-<li><a
href="Changing-Fields.html#index-field-separators_002c-See-Also-_0040code_007bOFS_007d-397">field
separators, See Also <code>OFS</code></a>: <a
href="Changing-Fields.html#Changing-Fields">Changing Fields</a></li>
-<li><a
href="Cut-Program.html#index-field-separators_002c-spaces-as-1750">field
separators, spaces as</a>: <a href="Cut-Program.html#Cut-Program">Cut
Program</a></li>
-<li><a href="Basic-High-Level.html#index-fields-2031">fields</a>: <a
href="Basic-High-Level.html#Basic-High-Level">Basic High Level</a></li>
-<li><a href="Fields.html#index-fields-377">fields</a>: <a
href="Fields.html#Fields">Fields</a></li>
-<li><a href="Reading-Files.html#index-fields-346">fields</a>: <a
href="Reading-Files.html#Reading-Files">Reading Files</a></li>
-<li><a href="Changing-Fields.html#index-fields_002c-adding-394">fields,
adding</a>: <a href="Changing-Fields.html#Changing-Fields">Changing
Fields</a></li>
-<li><a
href="Changing-Fields.html#index-fields_002c-changing-contents-of-392">fields,
changing contents of</a>: <a
href="Changing-Fields.html#Changing-Fields">Changing Fields</a></li>
-<li><a href="Cut-Program.html#index-fields_002c-cutting-1745">fields,
cutting</a>: <a href="Cut-Program.html#Cut-Program">Cut Program</a></li>
-<li><a href="Fields.html#index-fields_002c-examining-379">fields,
examining</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a href="Fields.html#index-fields_002c-number-of-389">fields, number
of</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a href="Nonconstant-Fields.html#index-fields_002c-numbers-390">fields,
numbers</a>: <a href="Nonconstant-Fields.html#Nonconstant-Fields">Nonconstant
Fields</a></li>
-<li><a href="Print-Examples.html#index-fields_002c-printing-506">fields,
printing</a>: <a href="Print-Examples.html#Print-Examples">Print
Examples</a></li>
-<li><a href="Field-Separators.html#index-fields_002c-separating-402">fields,
separating</a>: <a href="Field-Separators.html#Field-Separators">Field
Separators</a></li>
-<li><a
href="Single-Character-Fields.html#index-fields_002c-single_002dcharacter-420">fields,
single-character</a>: <a
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bFIELDWIDTHS_007d-variable-1003"><code>FIELDWIDTHS</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Constant-Size.html#index-_0040code_007bFIELDWIDTHS_007d-variable-443"><code>FIELDWIDTHS</code>
variable</a>: <a href="Constant-Size.html#Constant-Size">Constant Size</a></li>
-<li><a href="Special-FD.html#index-file-descriptors-573">file descriptors</a>:
<a href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="Auto_002dset.html#index-_0040value_007bFN_007ds_002c-distinguishing-1050">file
names, distinguishing</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Special-Caveats.html#index-_0040value_007bFN_007ds_002c-in-compatibility-mode-586">file
names, in compatibility mode</a>: <a
href="Special-Caveats.html#Special-Caveats">Special Caveats</a></li>
-<li><a
href="Special-FD.html#index-_0040value_007bFN_007ds_002c-standard-streams-in-_0040command_007bgawk_007d-577">file
names, standard streams in <samp><span class="command">gawk</span></samp></a>:
<a href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bFILENAME_007d-variable-1056"><code>FILENAME</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Reading-Files.html#index-_0040code_007bFILENAME_007d-variable-344"><code>FILENAME</code>
variable</a>: <a href="Reading-Files.html#Reading-Files">Reading Files</a></li>
-<li><a
href="Getline-Notes.html#index-_0040code_007bFILENAME_007d-variable_002c-_0040code_007bgetline_007d_0040comma_007b_007d-setting-with-493"><code>FILENAME</code>
variable, <code>getline</code>, setting with</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Ignoring-Assigns.html#index-filenames_002c-assignments-as-1679">filenames,
assignments as</a>: <a href="Ignoring-Assigns.html#Ignoring-Assigns">Ignoring
Assigns</a></li>
-<li><a
href="Explaining-gettext.html#index-files_002c-_0040code_007b_002emo_007d-1315">files,
<code>.mo</code></a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Example.html#index-files_002c-_0040code_007b_002emo_007d_002c-converting-from-_0040code_007b_002epo_007d-1387">files,
<code>.mo</code>, converting from <code>.po</code></a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Programmer-i18n.html#index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1349">files,
<code>.mo</code>, specifying directory of</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1320">files,
<code>.mo</code>, specifying directory of</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Translator-i18n.html#index-files_002c-_0040code_007b_002epo_007d-1359">files,
<code>.po</code></a>: <a
href="Translator-i18n.html#Translator-i18n">Translator i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-files_002c-_0040code_007b_002epo_007d-1311">files,
<code>.po</code></a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Example.html#index-files_002c-_0040code_007b_002epo_007d_002c-converting-to-_0040code_007b_002emo_007d-1385">files,
<code>.po</code>, converting to <code>.mo</code></a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Special-FD.html#index-files_002c-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-579">files,
<code>/dev/...</code> special files</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="TCP_002fIP-Networking.html#index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-1423">files,
<code>/inet/</code> (<samp><span class="command">gawk</span></samp>)</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Portal-Files.html#index-files_002c-_0040code_007b_002fp_007d-_0028_0040command_007bgawk_007d_0029-1433">files,
<code>/p</code> (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Portal-Files.html#Portal-Files">Portal Files</a></li>
-<li><a href="Records.html#index-files_002c-as-single-records-375">files, as
single records</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Long.html#index-files_002c-_0040command_007bawk_007d-programs-in-97">files,
<samp><span class="command">awk</span></samp> programs in</a>: <a
href="Long.html#Long">Long</a></li>
-<li><a
href="Profiling.html#index-files_002c-_0040code_007bawkprof_002eout_007d-1443">files,
<code>awkprof.out</code></a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Options.html#index-files_002c-_0040code_007bawkvars_002eout_007d-1508">files,
<code>awkvars.out</code></a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="I_002fO-Functions.html#index-files_002c-closing-1212">files,
closing</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="Special-FD.html#index-files_002c-descriptors_002c-See-file-descriptors-574">files,
descriptors, See file descriptors</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="Special-Process.html#index-files_002c-for-process-information-581">files,
for process information</a>: <a
href="Special-Process.html#Special-Process">Special Process</a></li>
-<li><a href="Group-Functions.html#index-files_002c-group-1727">files,
group</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Sample-Library.html#index-files_002c-information-about_0040comma_007b_007d-retrieving-2013">files,
information about, retrieving</a>: <a
href="Sample-Library.html#Sample-Library">Sample Library</a></li>
-<li><a
href="Filetrans-Function.html#index-files_002c-initialization-and-cleanup-1667">files,
initialization and cleanup</a>: <a
href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a></li>
-<li><a
href="Read-Terminal.html#index-files_002c-input_002c-See-input-files-87">files,
input, See input files</a>: <a href="Read-Terminal.html#Read-Terminal">Read
Terminal</a></li>
-<li><a
href="Time-Functions.html#index-files_002c-log_0040comma_007b_007d-timestamps-in-1230">files,
log, timestamps in</a>: <a href="Time-Functions.html#Time-Functions">Time
Functions</a></li>
-<li><a href="Data-File-Management.html#index-files_002c-managing-1663">files,
managing</a>: <a href="Data-File-Management.html#Data-File-Management">Data
File Management</a></li>
-<li><a
href="Filetrans-Function.html#index-files_002c-managing_002c-_0040value_007bDF_007d-boundaries-1666">files,
managing, data file boundaries</a>: <a
href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a></li>
-<li><a
href="Explaining-gettext.html#index-files_002c-message-object-1317">files,
message object</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Example.html#index-files_002c-message-object_002c-converting-from-portable-object-files-1391">files,
message object, converting from portable object files</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Programmer-i18n.html#index-files_002c-message-object_002c-specifying-directory-of-1351">files,
message object, specifying directory of</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-files_002c-message-object_002c-specifying-directory-of-1322">files,
message object, specifying directory of</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Other-Arguments.html#index-files_002c-multiple-passes-over-1567">files,
multiple passes over</a>: <a href="Other-Arguments.html#Other-Arguments">Other
Arguments</a></li>
-<li><a
href="Tee-Program.html#index-files_002c-multiple_0040comma_007b_007d-duplicating-output-into-1770">files,
multiple, duplicating output into</a>: <a
href="Tee-Program.html#Tee-Program">Tee Program</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-files_002c-output_002c-See-output-files-588">files,
output, See output files</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a href="Passwd-Functions.html#index-files_002c-password-1701">files,
password</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="Translator-i18n.html#index-files_002c-portable-object-1361">files,
portable object</a>: <a href="Translator-i18n.html#Translator-i18n">Translator
i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-files_002c-portable-object-1313">files,
portable object</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Example.html#index-files_002c-portable-object_002c-converting-to-message-object-files-1389">files,
portable object, converting to message object files</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Options.html#index-files_002c-portable-object_002c-generating-1513">files,
portable object, generating</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a href="Portal-Files.html#index-files_002c-portal-1430">files,
portal</a>: <a href="Portal-Files.html#Portal-Files">Portal Files</a></li>
-<li><a
href="Auto_002dset.html#index-files_002c-processing_0040comma_007b_007d-_0040code_007bARGIND_007d-variable-and-1049">files,
processing, <code>ARGIND</code> variable and</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Rewind-Function.html#index-files_002c-reading-1670">files,
reading</a>: <a href="Rewind-Function.html#Rewind-Function">Rewind
Function</a></li>
-<li><a
href="Multiple-Line.html#index-files_002c-reading_002c-multiline-records-447">files,
reading, multiline records</a>: <a
href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a
href="Egrep-Program.html#index-files_002c-searching-for-regular-expressions-1753">files,
searching for regular expressions</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a href="File-Checking.html#index-files_002c-skipping-1674">files,
skipping</a>: <a href="File-Checking.html#File-Checking">File Checking</a></li>
-<li><a
href="Igawk-Program.html#index-files_002c-source_0040comma_007b_007d-search-path-for-1822">files,
source, search path for</a>: <a href="Igawk-Program.html#Igawk-Program">Igawk
Program</a></li>
-<li><a href="Split-Program.html#index-files_002c-splitting-1767">files,
splitting</a>: <a href="Split-Program.html#Split-Program">Split Program</a></li>
-<li><a
href="Extract-Program.html#index-files_002c-Texinfo_0040comma_007b_007d-extracting-programs-from-1810">files,
Texinfo, extracting programs from</a>: <a
href="Extract-Program.html#Extract-Program">Extract Program</a></li>
-<li><a href="Bugs.html#index-Fish_002c-Fred-1929">Fish, Fred</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Fish_002c-Fred-1854">Fish, Fred</a>: <a
href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Constant-Size.html#index-fixed_002dwidth-data-439">fixed-width
data</a>: <a href="Constant-Size.html#Constant-Size">Constant Size</a></li>
-<li><a href="Tee-Program.html#index-flag-variables-1773">flag variables</a>:
<a href="Tee-Program.html#Tee-Program">Tee Program</a></li>
-<li><a href="Boolean-Ops.html#index-flag-variables-795">flag variables</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Floating-Point-Issues.html#index-floating_002dpoint-2048">floating-point</a>:
<a href="Floating-Point-Issues.html#Floating-Point-Issues">Floating Point
Issues</a></li>
-<li><a
href="Basic-Data-Typing.html#index-floating_002dpoint_002c-numbers-2039">floating-point,
numbers</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a
href="Internals.html#index-floating_002dpoint_002c-numbers_002c-_0040code_007bAWKNUM_007d-internal-type-1971">floating-point,
numbers, <code>AWKNUM</code> internal type</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bFNR_007d-variable-1058"><code>FNR</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Records.html#index-_0040code_007bFNR_007d-variable-351"><code>FNR</code>
variable</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bFNR_007d-variable_002c-changing-1068"><code>FNR</code>
variable, changing</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="For-Statement.html#index-_0040code_007bfor_007d-statement-956"><code>for</code>
statement</a>: <a href="For-Statement.html#For-Statement">For
Statement</a></li>
-<li><a
href="Scanning-an-Array.html#index-_0040code_007bfor_007d-statement_002c-in-arrays-1100"><code>for</code>
statement, in arrays</a>: <a
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="Internals.html#index-_0040code_007bforce_005fnumber_007d-internal-function-1977"><code>force_number</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bforce_005fstring_007d-internal-function-1979"><code>force_string</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Printf-Ordering.html#index-format-specifiers_002c-mixing-regular-with-positional-specifiers-1375">format
specifiers, mixing regular with positional specifiers</a>: <a
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="Control-Letters.html#index-format-specifiers_002c-_0040code_007bprintf_007d-statement-533">format
specifiers, <code>printf</code> statement</a>: <a
href="Control-Letters.html#Control-Letters">Control Letters</a></li>
-<li><a
href="Time-Functions.html#index-format-specifiers_002c-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1242">format
specifiers, <code>strftime</code> function (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a href="Basic-Printf.html#index-format-strings-531">format strings</a>:
<a href="Basic-Printf.html#Basic-Printf">Basic Printf</a></li>
-<li><a
href="OFMT.html#index-formats_0040comma_007b_007d-numeric-output-520">formats,
numeric output</a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a href="Printf.html#index-formatting-output-529">formatting output</a>:
<a href="Printf.html#Printf">Printf</a></li>
-<li><a
href="Regexp.html#index-forward-slash-_0028_0040code_007b_002f_007d_0029-170">forward
slash (<code>/</code>)</a>: <a href="Regexp.html#Regexp">Regexp</a></li>
-<li><a
href="Precedence.html#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_007d-operator-830">forward
slash (<code>/</code>), <code>/</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-880">forward
slash (<code>/</code>), <code>/=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-691">forward
slash (<code>/</code>), <code>/=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator_002c-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-705">forward
slash (<code>/</code>), <code>/=</code> operator, vs. <code>/=.../</code>
regexp constant</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="Expression-Patterns.html#index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-patterns-and-894">forward
slash (<code>/</code>), patterns and</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="GNU-Free-Documentation-License.html#index-Free-Documentation-License-_0028FDL_0029-2088">Free
Documentation License (FDL)</a>: <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a
href="Glossary.html#index-Free-Software-Foundation-_0028FSF_0029-2066">Free
Software Foundation (FSF)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Getting.html#index-Free-Software-Foundation-_0028FSF_0029-1875">Free
Software Foundation (FSF)</a>: <a href="Getting.html#Getting">Getting</a></li>
-<li><a
href="Manual-History.html#index-Free-Software-Foundation-_0028FSF_0029-33">Free
Software Foundation (FSF)</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a
href="Internals.html#index-_0040code_007bfree_005ftemp_007d-internal-macro-2000"><code>free_temp</code>
internal macro</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Glossary.html#index-FreeBSD-2085">FreeBSD</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bFS_007d-variable-1008"><code>FS</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Field-Separators.html#index-_0040code_007bFS_007d-variable-401"><code>FS</code>
variable</a>: <a href="Field-Separators.html#Field-Separators">Field
Separators</a></li>
-<li><a
href="Options.html#index-_0040code_007bFS_007d-variable_002c-_0040code_007b_002d_002dfield_002dseparator_007d-option-and-1484"><code>FS</code>
variable, <code>--field-separator</code> option and</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Single-Character-Fields.html#index-FS-variable_002c-as-null-string-422">FS
variable, as null string</a>: <a
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a></li>
-<li><a
href="Options.html#index-_0040code_007bFS_007d-variable_002c-as-TAB-character-1541"><code>FS</code>
variable, as TAB character</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Known-Bugs.html#index-_0040code_007bFS_007d-variable_002c-changing-value-of-1589"><code>FS</code>
variable, changing value of</a>: <a href="Known-Bugs.html#Known-Bugs">Known
Bugs</a></li>
-<li><a
href="Field-Separators.html#index-_0040code_007bFS_007d-variable_002c-changing-value-of-406"><code>FS</code>
variable, changing value of</a>: <a
href="Field-Separators.html#Field-Separators">Field Separators</a></li>
-<li><a
href="Cut-Program.html#index-_0040code_007bFS_007d-variable_002c-running-_0040command_007bawk_007d-programs-and-1749"><code>FS</code>
variable, running <samp><span class="command">awk</span></samp> programs
and</a>: <a href="Cut-Program.html#Cut-Program">Cut Program</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-_0040code_007bFS_007d-variable_002c-setting-from-command-line-428"><code>FS</code>
variable, setting from command line</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Glossary.html#index-FSF-_0028Free-Software-Foundation_0029-2065">FSF
(Free Software Foundation)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Getting.html#index-FSF-_0028Free-Software-Foundation_0029-1874">FSF (Free
Software Foundation)</a>: <a href="Getting.html#Getting">Getting</a></li>
-<li><a
href="Manual-History.html#index-FSF-_0028Free-Software-Foundation_0029-32">FSF
(Free Software Foundation)</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a href="Function-Calls.html#index-function-calls-804">function calls</a>:
<a href="Function-Calls.html#Function-Calls">Function Calls</a></li>
-<li><a
href="Function-Caveats.html#index-functions_002c-arrays-as-parameters-to-1293">functions,
arrays as parameters to</a>: <a
href="Function-Caveats.html#Function-Caveats">Function Caveats</a></li>
-<li><a href="Functions.html#index-functions_002c-built_002din-1140">functions,
built-in</a>: <a href="Functions.html#Functions">Functions</a></li>
-<li><a
href="Function-Calls.html#index-functions_002c-built_002din-805">functions,
built-in</a>: <a href="Function-Calls.html#Function-Calls">Function
Calls</a></li>
-<li><a
href="Dynamic-Extensions.html#index-functions_002c-built_002din_002c-adding-to-_0040command_007bgawk_007d-1968">functions,
built-in, adding to <samp><span class="command">gawk</span></samp></a>: <a
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a
href="Calling-Built_002din.html#index-functions_002c-built_002din_002c-evaluation-order-1148">functions,
built-in, evaluation order</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="Definition-Syntax.html#index-functions_002c-defining-1277">functions,
defining</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a
href="Library-Functions.html#index-functions_002c-library-1591">functions,
library</a>: <a href="Library-Functions.html#Library-Functions">Library
Functions</a></li>
-<li><a
href="Assert-Function.html#index-functions_002c-library_002c-assertions-1623">functions,
library, assertions</a>: <a href="Assert-Function.html#Assert-Function">Assert
Function</a></li>
-<li><a
href="Library-Names.html#index-functions_002c-library_002c-associative-arrays-and-1611">functions,
library, associative arrays and</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Getopt-Function.html#index-functions_002c-library_002c-C-library-1685">functions,
library, C library</a>: <a href="Getopt-Function.html#Getopt-Function">Getopt
Function</a></li>
-<li><a
href="Ordinal-Functions.html#index-functions_002c-library_002c-character-values-as-numbers-1643">functions,
library, character values as numbers</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="Cliff-Random-Function.html#index-functions_002c-library_002c-Cliff-random-numbers-1640">functions,
library, Cliff random numbers</a>: <a
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a></li>
-<li><a
href="Getopt-Function.html#index-functions_002c-library_002c-command_002dline-options-1682">functions,
library, command-line options</a>: <a
href="Getopt-Function.html#Getopt-Function">Getopt Function</a></li>
-<li><a
href="Igawk-Program.html#index-functions_002c-library_002c-example-program-for-using-1818">functions,
library, example program for using</a>: <a
href="Igawk-Program.html#Igawk-Program">Igawk Program</a></li>
-<li><a
href="Group-Functions.html#index-functions_002c-library_002c-group-database_002c-reading-1718">functions,
library, group database, reading</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Data-File-Management.html#index-functions_002c-library_002c-managing-_0040value_007bDF_007ds-1665">functions,
library, managing data files</a>: <a
href="Data-File-Management.html#Data-File-Management">Data File
Management</a></li>
-<li><a
href="Gettimeofday-Function.html#index-functions_002c-library_002c-managing-time-1659">functions,
library, managing time</a>: <a
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a
href="Join-Function.html#index-functions_002c-library_002c-merging-arrays-into-strings-1654">functions,
library, merging arrays into strings</a>: <a
href="Join-Function.html#Join-Function">Join Function</a></li>
-<li><a
href="Nextfile-Function.html#index-functions_002c-library_002c-_0040code_007bnextfile_007d-statement-1615">functions,
library, <code>nextfile</code> statement</a>: <a
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="Round-Function.html#index-functions_002c-library_002c-rounding-numbers-1632">functions,
library, rounding numbers</a>: <a
href="Round-Function.html#Round-Function">Round Function</a></li>
-<li><a
href="Passwd-Functions.html#index-functions_002c-library_002c-user-database_002c-reading-1691">functions,
library, user database, reading</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Definition-Syntax.html#index-functions_002c-names-of-1279">functions,
names of</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a href="Arrays.html#index-functions_002c-names-of-1077">functions, names
of</a>: <a href="Arrays.html#Arrays">Arrays</a></li>
-<li><a
href="Definition-Syntax.html#index-functions_002c-recursive-1284">functions,
recursive</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a
href="Internals.html#index-functions_002c-return-values_0040comma_007b_007d-setting-2007">functions,
return values, setting</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a
href="I18N-Functions.html#index-functions_002c-string_002dtranslation-1269">functions,
string-translation</a>: <a href="I18N-Functions.html#I18N-Functions">I18N
Functions</a></li>
-<li><a
href="Function-Caveats.html#index-functions_002c-undefined-1295">functions,
undefined</a>: <a href="Function-Caveats.html#Function-Caveats">Function
Caveats</a></li>
-<li><a
href="User_002ddefined.html#index-functions_002c-user_002ddefined-1276">functions,
user-defined</a>: <a
href="User_002ddefined.html#User_002ddefined">User-defined</a></li>
-<li><a
href="Function-Caveats.html#index-functions_002c-user_002ddefined_002c-calling-1289">functions,
user-defined, calling</a>: <a
href="Function-Caveats.html#Function-Caveats">Function Caveats</a></li>
-<li><a
href="Profiling.html#index-functions_002c-user_002ddefined_002c-counts-1450">functions,
user-defined, counts</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Library-Functions.html#index-functions_002c-user_002ddefined_002c-library-of-1592">functions,
user-defined, library of</a>: <a
href="Library-Functions.html#Library-Functions">Library Functions</a></li>
-<li><a
href="Nextfile-Statement.html#index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-979">functions,
user-defined, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="Next-Statement.html#index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-976">functions,
user-defined, <code>next</code>/<code>nextfile</code> statements and</a>: <a
href="Next-Statement.html#Next-Statement">Next Statement</a></li>
-<li><a href="Acknowledgments.html#index-G_002dd-71">G-d</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Contributors.html#index-Garfinkle_002c-Scott-1849">Garfinkle,
Scott</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="This-Manual.html#index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-25"><samp><span
class="command">gawk</span></samp>, <samp><span
class="command">awk</span></samp> and</a>: <a
href="This-Manual.html#This-Manual">This Manual</a></li>
-<li><a
href="Preface.html#index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-4"><samp><span
class="command">gawk</span></samp>, <samp><span
class="command">awk</span></samp> and</a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040command_007bgawk_007d_002c-bitwise-operations-in-1256"><samp><span
class="command">gawk</span></samp>, bitwise operations in</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Break-Statement.html#index-_0040command_007bgawk_007d_002c-_0040code_007bbreak_007d-statement-in-965"><samp><span
class="command">gawk</span></samp>, <code>break</code> statement in</a>: <a
href="Break-Statement.html#Break-Statement">Break Statement</a></li>
-<li><a
href="Built_002din-Variables.html#index-_0040command_007bgawk_007d_002c-built_002din-variables-and-992"><samp><span
class="command">gawk</span></samp>, built-in variables and</a>: <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a></li>
-<li><a
href="Character-Lists.html#index-_0040command_007bgawk_007d_002c-character-classes-and-278"><samp><span
class="command">gawk</span></samp>, character classes and</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Adding-Code.html#index-_0040command_007bgawk_007d_002c-coding-style-in-1958"><samp><span
class="command">gawk</span></samp>, coding style in</a>: <a
href="Adding-Code.html#Adding-Code">Adding Code</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040command_007bgawk_007d_002c-command_002dline-options-313"><samp><span
class="command">gawk</span></samp>, command-line options</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040command_007bgawk_007d_002c-comparison-operators-and-766"><samp><span
class="command">gawk</span></samp>, comparison operators and</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Configuration-Philosophy.html#index-_0040command_007bgawk_007d_002c-configuring-1894"><samp><span
class="command">gawk</span></samp>, configuring</a>: <a
href="Configuration-Philosophy.html#Configuration-Philosophy">Configuration
Philosophy</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-_0040command_007bgawk_007d_002c-configuring_002c-options-1879"><samp><span
class="command">gawk</span></samp>, configuring, options</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a
href="Continue-Statement.html#index-_0040command_007bgawk_007d_002c-_0040code_007bcontinue_007d-statement-in-969"><samp><span
class="command">gawk</span></samp>, <code>continue</code> statement in</a>: <a
href="Continue-Statement.html#Continue-Statement">Continue Statement</a></li>
-<li><a
href="Known-Bugs.html#index-_0040command_007bgawk_007d_002c-debugging-1584"><samp><span
class="command">gawk</span></samp>, debugging</a>: <a
href="Known-Bugs.html#Known-Bugs">Known Bugs</a></li>
-<li><a
href="Distribution-contents.html#index-_0040command_007bgawk_007d_002c-distribution-1876"><samp><span
class="command">gawk</span></samp>, distribution</a>: <a
href="Distribution-contents.html#Distribution-contents">Distribution
contents</a></li>
-<li><a
href="Escape-Sequences.html#index-_0040command_007bgawk_007d_002c-escape-sequences-217"><samp><span
class="command">gawk</span></samp>, escape sequences</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Options.html#index-_0040command_007bgawk_007d_002c-extensions_0040comma_007b_007d-disabling-1529"><samp><span
class="command">gawk</span></samp>, extensions, disabling</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Adding-Code.html#index-_0040command_007bgawk_007d_002c-features_002c-adding-1957"><samp><span
class="command">gawk</span></samp>, features, adding</a>: <a
href="Adding-Code.html#Adding-Code">Adding Code</a></li>
-<li><a
href="Advanced-Features.html#index-_0040command_007bgawk_007d_002c-features_002c-advanced-1396"><samp><span
class="command">gawk</span></samp>, features, advanced</a>: <a
href="Advanced-Features.html#Advanced-Features">Advanced Features</a></li>
-<li><a
href="I_002fO-Functions.html#index-_0040command_007bgawk_007d_002c-_0040code_007bfflush_007d-function-in-1217"><samp><span
class="command">gawk</span></samp>, <code>fflush</code> function in</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="User_002dmodified.html#index-_0040command_007bgawk_007d_002c-field-separators-and-1012"><samp><span
class="command">gawk</span></samp>, field separators and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="User_002dmodified.html#index-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-in-1007"><samp><span
class="command">gawk</span></samp>, <code>FIELDWIDTHS</code> variable in</a>:
<a href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Special-Files.html#index-_0040command_007bgawk_007d_002c-_0040value_007bFN_007ds-in-567"><samp><span
class="command">gawk</span></samp>, file names in</a>: <a
href="Special-Files.html#Special-Files">Special Files</a></li>
-<li><a
href="Control-Letters.html#index-_0040command_007bgawk_007d_002c-format_002dcontrol-characters-535"><samp><span
class="command">gawk</span></samp>, format-control characters</a>: <a
href="Control-Letters.html#Control-Letters">Control Letters</a></li>
-<li><a
href="Calling-Built_002din.html#index-_0040command_007bgawk_007d_002c-function-arguments-and-1145"><samp><span
class="command">gawk</span></samp>, function arguments and</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="Dynamic-Extensions.html#index-_0040command_007bgawk_007d_002c-functions_002c-adding-1966"><samp><span
class="command">gawk</span></samp>, functions, adding</a>: <a
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-_0040command_007bgawk_007d_002c-hexadecimal-numbers-and-615"><samp><span
class="command">gawk</span></samp>, hexadecimal numbers and</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="User_002dmodified.html#index-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-in-1018"><samp><span
class="command">gawk</span></samp>, <code>IGNORECASE</code> variable in</a>:
<a href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Notes.html#index-_0040command_007bgawk_007d_002c-implementation-issues-1949"><samp><span
class="command">gawk</span></samp>, implementation issues</a>: <a
href="Notes.html#Notes">Notes</a></li>
-<li><a
href="Compatibility-Mode.html#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-debugging-1952"><samp><span
class="command">gawk</span></samp>, implementation issues, debugging</a>: <a
href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="Compatibility-Mode.html#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-downward-compatibility-1951"><samp><span
class="command">gawk</span></samp>, implementation issues, downward
compatibility</a>: <a
href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="Getline-Notes.html#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-limits-491"><samp><span
class="command">gawk</span></samp>, implementation issues, limits</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Redirection.html#index-_0040command_007bgawk_007d_002c-implementation-issues_002c-pipes-564"><samp><span
class="command">gawk</span></samp>, implementation issues, pipes</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Installation.html#index-_0040command_007bgawk_007d_002c-installing-1870"><samp><span
class="command">gawk</span></samp>, installing</a>: <a
href="Installation.html#Installation">Installation</a></li>
-<li><a
href="Internals.html#index-_0040command_007bgawk_007d_002c-internals-1969"><samp><span
class="command">gawk</span></samp>, internals</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internationalization.html#index-_0040command_007bgawk_007d_002c-internationalization-and_002c-See-internationalization-1301"><samp><span
class="command">gawk</span></samp>, internationalization and, See
internationalization</a>: <a
href="Internationalization.html#Internationalization">Internationalization</a></li>
-<li><a
href="Future-Extensions.html#index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2022"><samp><span
class="command">gawk</span></samp>, interpreter, adding code to</a>: <a
href="Future-Extensions.html#Future-Extensions">Future Extensions</a></li>
-<li><a
href="Using-Internal-File-Ops.html#index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2017"><samp><span
class="command">gawk</span></samp>, interpreter, adding code to</a>: <a
href="Using-Internal-File-Ops.html#Using-Internal-File-Ops">Using Internal File
Ops</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040command_007bgawk_007d_002c-interval-expressions-and-251"><samp><span
class="command">gawk</span></samp>, interval expressions and</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Conditional-Exp.html#index-_0040command_007bgawk_007d_002c-line-continuation-in-803"><samp><span
class="command">gawk</span></samp>, line continuation in</a>: <a
href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="User_002dmodified.html#index-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-in-1022"><samp><span
class="command">gawk</span></samp>, <code>LINT</code> variable in</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Contributors.html#index-_0040command_007bgawk_007d_002c-list-of-contributors-to-1837"><samp><span
class="command">gawk</span></samp>, list of contributors to</a>: <a
href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="PC-Using.html#index-_0040command_007bgawk_007d_002c-MS_002dDOS-version-of-1906"><samp><span
class="command">gawk</span></samp>, MS-DOS version of</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="Statements_002fLines.html#index-_0040command_007bgawk_007d_002c-newlines-in-152"><samp><span
class="command">gawk</span></samp>, newlines in</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Nextfile-Statement.html#index-_0040command_007bgawk_007d_002c-_0040code_007bnext-file_007d-statement-in-982"><samp><span
class="command">gawk</span></samp>, <code>next file</code> statement in</a>:
<a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="Nextfile-Function.html#index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-1617"><samp><span
class="command">gawk</span></samp>, <code>nextfile</code> statement in</a>: <a
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="Nextfile-Statement.html#index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-984"><samp><span
class="command">gawk</span></samp>, <code>nextfile</code> statement in</a>: <a
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-_0040command_007bgawk_007d_002c-octal-numbers-and-614"><samp><span
class="command">gawk</span></samp>, octal numbers and</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="PC-Using.html#index-_0040command_007bgawk_007d_002c-OS_002f2-version-of-1905"><samp><span
class="command">gawk</span></samp>, OS/2 version of</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-_0040command_007bgawk_007d_002c-regexp-constants-and-625"><samp><span
class="command">gawk</span></samp>, regexp constants and</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="Case_002dsensitivity.html#index-_0040command_007bgawk_007d_002c-regular-expressions_002c-case-sensitivity-316"><samp><span
class="command">gawk</span></samp>, regular expressions, case sensitivity</a>:
<a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040command_007bgawk_007d_002c-regular-expressions_002c-operators-281"><samp><span
class="command">gawk</span></samp>, regular expressions, operators</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040command_007bgawk_007d_002c-regular-expressions_002c-precedence-255"><samp><span
class="command">gawk</span></samp>, regular expressions, precedence</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Preface.html#index-_0040command_007bgawk_007d_002c-See-Also-_0040command_007bawk_007d-8"><samp><span
class="command">gawk</span></samp>, See Also <samp><span
class="command">awk</span></samp></a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="Getting.html#index-_0040command_007bgawk_007d_002c-source-code_0040comma_007b_007d-obtaining-1873"><samp><span
class="command">gawk</span></samp>, source code, obtaining</a>: <a
href="Getting.html#Getting">Getting</a></li>
-<li><a
href="Constant-Size.html#index-_0040command_007bgawk_007d_002c-splitting-fields-and-444"><samp><span
class="command">gawk</span></samp>, splitting fields and</a>: <a
href="Constant-Size.html#Constant-Size">Constant Size</a></li>
-<li><a
href="I18N-Functions.html#index-_0040command_007bgawk_007d_002c-string_002dtranslation-functions-1268"><samp><span
class="command">gawk</span></samp>, string-translation functions</a>: <a
href="I18N-Functions.html#I18N-Functions">I18N Functions</a></li>
-<li><a
href="Time-Functions.html#index-_0040command_007bgawk_007d_002c-timestamps-1231"><samp><span
class="command">gawk</span></samp>, timestamps</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Preface.html#index-_0040command_007bgawk_007d_002c-uses-for-9"><samp><span
class="command">gawk</span></samp>, uses for</a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="Options.html#index-_0040command_007bgawk_007d_002c-versions-of_002c-information-about_0040comma_007b_007d-printing-1552"><samp><span
class="command">gawk</span></samp>, versions of, information about,
printing</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-_0040command_007bgawk_007d_002c-word_002dboundary-operator-309"><samp><span
class="command">gawk</span></samp>, word-boundary operator</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Glossary.html#index-General-Public-License-_0028GPL_0029-2069">General
Public License (GPL)</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Manual-History.html#index-General-Public-License_002c-See-GPL-37">General
Public License, See GPL</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-1189"><code>gensub</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-629"><code>gensub</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="Gory-Details.html#index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029_002c-escape-processing-1200"><code>gensub</code>
function (<samp><span class="command">gawk</span></samp>), escape
processing</a>: <a href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Internals.html#index-_0040code_007bget_005factual_005fargument_007d-internal-function-2004"><code>get_actual_argument</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bget_005fargument_007d-internal-function-2003"><code>get_argument</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bget_005farray_005fargument_007d-internal-macro-2006"><code>get_array_argument</code>
internal macro</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bget_005fcurfunc_005farg_005fcount_007d-internal-function-1980"><code>get_curfunc_arg_count</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bget_005fscalar_005fargument_007d-internal-macro-2005"><code>get_scalar_argument</code>
internal macro</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgrent_007d-function-_0028C-library_0029-1722"><code>getgrent</code>
function (C library)</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgrent_007d-user_002ddefined-function-1723"><code>getgrent</code>
user-defined function</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgrgid_007d-function-_0028C-library_0029-1733"><code>getgrgid</code>
function (C library)</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgrgid_007d-user_002ddefined-function-1734"><code>getgrgid</code>
user-defined function</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgrnam_007d-function-_0028C-library_0029-1731"><code>getgrnam</code>
function (C library)</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgrnam_007d-user_002ddefined-function-1732"><code>getgrnam</code>
user-defined function</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgruser_007d-function-_0028C-library_0029-1735"><code>getgruser</code>
function (C library)</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetgruser_007d-function_002c-user_002ddefined-1736"><code>getgruser</code>
function, user-defined</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Reading-Files.html#index-_0040code_007bgetline_007d-command-347"><code>getline</code>
command</a>: <a href="Reading-Files.html#Reading-Files">Reading Files</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fgr_005finit_007d-user_002ddefined-function-1729"><code>getline</code>
command, <code>_gr_init</code> user-defined function</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fpw_005finit_007d-function-1708"><code>getline</code>
command, <code>_pw_init</code> function</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-593"><code>getline</code>
command, coprocesses, using from</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Getline_002fCoprocess.html#index-_0040code_007bgetline_007d-command_002c-coprocesses_0040comma_007b_007d-using-from-482"><code>getline</code>
command, coprocesses, using from</a>: <a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-_0040code_007bgetline_007d-command_002c-deadlock-and-1416"><code>getline</code>
command, deadlock and</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Getline.html#index-_0040code_007bgetline_007d-command_002c-explicit-input-with-456"><code>getline</code>
command, explicit input with</a>: <a
href="Getline.html#Getline">Getline</a></li>
-<li><a
href="Getline-Notes.html#index-_0040code_007bgetline_007d-command_002c-_0040code_007bFILENAME_007d-variable-and-495"><code>getline</code>
command, <code>FILENAME</code> variable and</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Getline.html#index-_0040code_007bgetline_007d-command_002c-return-values-460"><code>getline</code>
command, return values</a>: <a href="Getline.html#Getline">Getline</a></li>
-<li><a
href="Getline-Summary.html#index-_0040code_007bgetline_007d-command_002c-variants-497"><code>getline</code>
command, variants</a>: <a href="Getline-Summary.html#Getline-Summary">Getline
Summary</a></li>
-<li><a
href="Getopt-Function.html#index-_0040code_007bgetopt_007d-function-_0028C-library_0029-1687"><code>getopt</code>
function (C library)</a>: <a
href="Getopt-Function.html#Getopt-Function">Getopt Function</a></li>
-<li><a
href="Getopt-Function.html#index-_0040code_007bgetopt_007d-user_002ddefined-function-1688"><code>getopt</code>
user-defined function</a>: <a
href="Getopt-Function.html#Getopt-Function">Getopt Function</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetpwent_007d-function-_0028C-library_0029-1695"><code>getpwent</code>
function (C library)</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetpwent_007d-user_002ddefined-function-1696"><code>getpwent</code>
user-defined function</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetpwnam_007d-function-_0028C-library_0029-1709"><code>getpwnam</code>
function (C library)</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetpwnam_007d-user_002ddefined-function-1710"><code>getpwnam</code>
user-defined function</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetpwuid_007d-function-_0028C-library_0029-1711"><code>getpwuid</code>
function (C library)</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bgetpwuid_007d-user_002ddefined-function-1712"><code>getpwuid</code>
user-defined function</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="TCP_002fIP-Networking.html#index-_0040code_007bgetservbyname_007d-function-_0028C-library_0029-1427"><code>getservbyname</code>
function (C library)</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bgettext_007d-function-_0028C-library_0029-1323"><code>gettext</code>
function (C library)</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bgettext_007d-library-1307"><code>gettext</code>
library</a>: <a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bgettext_007d-library_002c-locale-categories-1327"><code>gettext</code>
library, locale categories</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Gettimeofday-Function.html#index-_0040code_007bgettimeofday_007d-user_002ddefined-function-1662"><code>gettimeofday</code>
user-defined function</a>: <a
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a href="Acknowledgments.html#index-GNITS-mailing-list-54">GNITS mailing
list</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Preface.html#index-GNU-_0040command_007bawk_007d_002c-See-_0040command_007bgawk_007d-10">GNU
<samp><span class="command">awk</span></samp>, See <samp><span
class="command">gawk</span></samp></a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="GNU-Free-Documentation-License.html#index-GNU-Free-Documentation-License-2089">GNU
Free Documentation License</a>: <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a></li>
-<li><a href="Glossary.html#index-GNU-General-Public-License-2070">GNU General
Public License</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Glossary.html#index-GNU-Lesser-General-Public-License-2078">GNU
Lesser General Public License</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Options.html#index-GNU-long-options-1479">GNU long options</a>:
<a href="Options.html#Options">Options</a></li>
-<li><a href="Command-Line.html#index-GNU-long-options-1471">GNU long
options</a>: <a href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a
href="Options.html#index-GNU-long-options_002c-printing-list-of-1516">GNU long
options, printing list of</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Glossary.html#index-GNU-Project-2073">GNU Project</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Manual-History.html#index-GNU-Project-35">GNU Project</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a href="Glossary.html#index-GNU_002fLinux-2081">GNU/Linux</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Atari-Compiling.html#index-GNU_002fLinux-1918">GNU/Linux</a>: <a
href="Atari-Compiling.html#Atari-Compiling">Atari Compiling</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-GNU_002fLinux-1886">GNU/Linux</a>:
<a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a href="I18N-Example.html#index-GNU_002fLinux-1383">GNU/Linux</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a href="Manual-History.html#index-GNU_002fLinux-40">GNU/Linux</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a
href="Glossary.html#index-GPL-_0028General-Public-License_0029-2068">GPL
(General Public License)</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Manual-History.html#index-GPL-_0028General-Public-License_0029-36">GPL
(General Public License)</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a
href="Options.html#index-GPL-_0028General-Public-License_0029_002c-printing-1504">GPL
(General Public License), printing</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Group-Functions.html#index-_0040command_007bgrcat_007d-program-1728"><samp><span
class="command">grcat</span></samp> program</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a href="Bugs.html#index-Grigera_002c-Juan-1933">Grigera, Juan</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Grigera_002c-Juan-1856">Grigera,
Juan</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="Group-Functions.html#index-group-database_002c-reading-1719">group
database, reading</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a href="Group-Functions.html#index-group-file-1726">group file</a>: <a
href="Group-Functions.html#Group-Functions">Group Functions</a></li>
-<li><a
href="Group-Functions.html#index-groups_0040comma_007b_007d-information-about-1724">groups,
information about</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bgsub_007d-function-1188"><code>gsub</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-_0040code_007bgsub_007d-function-631"><code>gsub</code>
function</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bgsub_007d-function_002c-arguments-of-1186"><code>gsub</code>
function, arguments of</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Gory-Details.html#index-_0040code_007bgsub_007d-function_002c-escape-processing-1199"><code>gsub</code>
function, escape processing</a>: <a href="Gory-Details.html#Gory-Details">Gory
Details</a></li>
-<li><a href="Bugs.html#index-Hankerson_002c-Darrel-1932">Hankerson,
Darrel</a>: <a href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Hankerson_002c-Darrel-1857">Hankerson,
Darrel</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Hankerson_002c-Darrel-60">Hankerson,
Darrel</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Acknowledgments.html#index-Hartholz_002c-Elaine-48">Hartholz,
Elaine</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Acknowledgments.html#index-Hartholz_002c-Marshall-47">Hartholz,
Marshall</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Contributors.html#index-Hasegawa_002c-Isamu-1865">Hasegawa,
Isamu</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Hasegawa_002c-Isamu-61">Hasegawa,
Isamu</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-hexadecimal-numbers-611">hexadecimal
numbers</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="Options.html#index-hexadecimal-values_0040comma_007b_007d-enabling-interpretation-of-1524">hexadecimal
values, enabling interpretation of</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="History-Sorting.html#index-_0040code_007bhistsort_002eawk_007d-program-1808"><code>histsort.awk</code>
program</a>: <a href="History-Sorting.html#History-Sorting">History
Sorting</a></li>
-<li><a href="Acknowledgments.html#index-Hughes_002c-Phil-51">Hughes, Phil</a>:
<a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bHUP_007d-signal-1461"><code>HUP</code>
signal</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Precedence.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_007d-operator-824">hyphen
(<code>-</code>), <code>-</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operators-816">hyphen
(<code>-</code>), <code>--</code> (decrement/increment) operators</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Increment-Ops.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-operator-723">hyphen
(<code>-</code>), <code>--</code> operator</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Precedence.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-874">hyphen
(<code>-</code>), <code>-=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-687">hyphen
(<code>-</code>), <code>-=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Options.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-filenames-beginning-with-1499">hyphen
(<code>-</code>), filenames beginning with</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Character-Lists.html#index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-in-character-lists-264">hyphen
(<code>-</code>), in character lists</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Id-Program.html#index-_0040command_007bid_007d-utility-1764"><samp><span
class="command">id</span></samp> utility</a>: <a
href="Id-Program.html#Id-Program">Id Program</a></li>
-<li><a
href="Id-Program.html#index-_0040code_007bid_002eawk_007d-program-1765"><code>id.awk</code>
program</a>: <a href="Id-Program.html#Id-Program">Id Program</a></li>
-<li><a
href="If-Statement.html#index-_0040code_007bif_007d-statement-950"><code>if</code>
statement</a>: <a href="If-Statement.html#If-Statement">If Statement</a></li>
-<li><a
href="Regexp-Usage.html#index-_0040code_007bif_007d-statement-179"><code>if</code>
statement</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Ranges.html#index-_0040code_007bif_007d-statement_002c-actions_0040comma_007b_007d-changing-909"><code>if</code>
statement, actions, changing</a>: <a href="Ranges.html#Ranges">Ranges</a></li>
-<li><a
href="Igawk-Program.html#index-_0040code_007bigawk_002esh_007d-program-1819"><code>igawk.sh</code>
program</a>: <a href="Igawk-Program.html#Igawk-Program">Igawk Program</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bIGNORECASE_007d-variable-1013"><code>IGNORECASE</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Case_002dsensitivity.html#index-_0040code_007bIGNORECASE_007d-variable-323"><code>IGNORECASE</code>
variable</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="Array-Sorting.html#index-_0040code_007bIGNORECASE_007d-variable_002c-array-sorting-and-1139"><code>IGNORECASE</code>
variable, array sorting and</a>: <a
href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a
href="Array-Intro.html#index-_0040code_007bIGNORECASE_007d-variable_002c-array-subscripts-and-1089"><code>IGNORECASE</code>
variable, array subscripts and</a>: <a
href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="Library-Functions.html#index-_0040code_007bIGNORECASE_007d-variable_002c-in-example-programs-1596"><code>IGNORECASE</code>
variable, in example programs</a>: <a
href="Library-Functions.html#Library-Functions">Library Functions</a></li>
-<li><a
href="Notes.html#index-implementation-issues_002c-_0040command_007bgawk_007d-1950">implementation
issues, <samp><span class="command">gawk</span></samp></a>: <a
href="Notes.html#Notes">Notes</a></li>
-<li><a
href="Compatibility-Mode.html#index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-debugging-1954">implementation
issues, <samp><span class="command">gawk</span></samp>, debugging</a>: <a
href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="Redirection.html#index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-limits-562">implementation
issues, <samp><span class="command">gawk</span></samp>, limits</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Getline-Notes.html#index-implementation-issues_002c-_0040command_007bgawk_007d_002c-limits-489">implementation
issues, <samp><span class="command">gawk</span></samp>, limits</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Id-Program.html#index-_0040code_007bin_007d-operator-1766"><code>in</code>
operator</a>: <a href="Id-Program.html#Id-Program">Id Program</a></li>
-<li><a
href="Precedence.html#index-_0040code_007bin_007d-operator-864"><code>in</code>
operator</a>: <a href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007bin_007d-operator-764"><code>in</code>
operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Scanning-an-Array.html#index-_0040code_007bin_007d-operator_002c-arrays-and-1098"><code>in</code>
operator, arrays and</a>: <a
href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a></li>
-<li><a
href="Reference-to-Elements.html#index-_0040code_007bin_007d-operator_002c-arrays-and-1092"><code>in</code>
operator, arrays and</a>: <a
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a></li>
-<li><a href="Increment-Ops.html#index-increment-operators-711">increment
operators</a>: <a href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bindex_007d-function-1165"><code>index</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a href="Array-Intro.html#index-indexing-arrays-1082">indexing arrays</a>:
<a href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a
href="More-Complex.html#index-initialization_002c-automatic-149">initialization,
automatic</a>: <a href="More-Complex.html#More-Complex">More Complex</a></li>
-<li><a href="Reading-Files.html#index-input-files-343">input files</a>: <a
href="Reading-Files.html#Reading-Files">Reading Files</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-input-files_002c-closing-589">input
files, closing</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Wc-Program.html#index-input-files_002c-counting-elements-in-1780">input
files, counting elements in</a>: <a href="Wc-Program.html#Wc-Program">Wc
Program</a></li>
-<li><a href="Sample-Data-Files.html#index-input-files_002c-examples-135">input
files, examples</a>: <a href="Sample-Data-Files.html#Sample-Data-Files">Sample
Data Files</a></li>
-<li><a href="Reading-Files.html#index-input-files_002c-reading-342">input
files, reading</a>: <a href="Reading-Files.html#Reading-Files">Reading
Files</a></li>
-<li><a
href="Read-Terminal.html#index-input-files_002c-running-_0040command_007bawk_007d-without-86">input
files, running <samp><span class="command">awk</span></samp> without</a>: <a
href="Read-Terminal.html#Read-Terminal">Read Terminal</a></li>
-<li><a
href="Nextfile-Function.html#index-input-files_002c-skipping-1613">input files,
skipping</a>: <a href="Nextfile-Function.html#Nextfile-Function">Nextfile
Function</a></li>
-<li><a
href="Other-Arguments.html#index-input-files_002c-variable-assignments-and-1565">input
files, variable assignments and</a>: <a
href="Other-Arguments.html#Other-Arguments">Other Arguments</a></li>
-<li><a href="Getline_002fPipe.html#index-input-pipeline-472">input
pipeline</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="Getline_002fFile.html#index-input-redirection-462">input
redirection</a>: <a
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a></li>
-<li><a
href="Nondecimal-Data.html#index-input_002c-data_0040comma_007b_007d-nondecimal-1400">input,
data, nondecimal</a>: <a
href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a href="Getline.html#index-input_002c-explicit-457">input, explicit</a>:
<a href="Getline.html#Getline">Getline</a></li>
-<li><a
href="Multiple-Line.html#index-input_002c-files_002c-See-input-files-448">input,
files, See input files</a>: <a
href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a href="Multiple-Line.html#index-input_002c-multiline-records-446">input,
multiline records</a>: <a href="Multiple-Line.html#Multiple-Line">Multiple
Line</a></li>
-<li><a href="Records.html#index-input_002c-splitting-into-records-348">input,
splitting into records</a>: <a href="Records.html#Records">Records</a></li>
-<li><a href="Special-FD.html#index-input_002c-standard-569">input,
standard</a>: <a href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a href="Read-Terminal.html#index-input_002c-standard-85">input,
standard</a>: <a href="Read-Terminal.html#Read-Terminal">Read Terminal</a></li>
-<li><a
href="User_002dmodified.html#index-input_002foutput_002c-binary-997">input/output,
binary</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-input_002foutput_002c-from-_0040code_007bBEGIN_007d-and-_0040code_007bEND_007d-916">input/output,
from <code>BEGIN</code> and <code>END</code></a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-input_002foutput_002c-two_002dway-1410">input/output,
two-way</a>: <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way
I/O</a></li>
-<li><a href="Alarm-Program.html#index-insomnia_002c-cure-for-1791">insomnia,
cure for</a>: <a href="Alarm-Program.html#Alarm-Program">Alarm Program</a></li>
-<li><a
href="Amiga-Installation.html#index-installation_002c-amiga-1897">installation,
amiga</a>: <a href="Amiga-Installation.html#Amiga-Installation">Amiga
Installation</a></li>
-<li><a
href="Atari-Installation.html#index-installation_002c-atari-1916">installation,
atari</a>: <a href="Atari-Installation.html#Atari-Installation">Atari
Installation</a></li>
-<li><a
href="BeOS-Installation.html#index-installation_002c-beos-1899">installation,
beos</a>: <a href="BeOS-Installation.html#BeOS-Installation">BeOS
Installation</a></li>
-<li><a
href="Tandem-Installation.html#index-installation_002c-tandem-1920">installation,
tandem</a>: <a href="Tandem-Installation.html#Tandem-Installation">Tandem
Installation</a></li>
-<li><a
href="VMS-Installation.html#index-installation_002c-vms-1912">installation,
vms</a>: <a href="VMS-Installation.html#VMS-Installation">VMS
Installation</a></li>
-<li><a
href="Installation.html#index-installing-_0040command_007bgawk_007d-1871">installing
<samp><span class="command">gawk</span></samp></a>: <a
href="Installation.html#Installation">Installation</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007bint_007d-function-1150"><code>int</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bINT_007d-signal-_0028MS_002dDOS_0029-1463"><code>INT</code>
signal (MS-DOS)</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Basic-Data-Typing.html#index-integers-2038">integers</a>: <a
href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a
href="Basic-Data-Typing.html#index-integers_002c-unsigned-2042">integers,
unsigned</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a
href="I_002fO-Functions.html#index-interacting-with-other-programs-1220">interacting
with other programs</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="I18N-and-L10N.html#index-internationalization-1303">internationalization</a>:
<a href="I18N-and-L10N.html#I18N-and-L10N">I18N and L10N</a></li>
-<li><a
href="I18N-Functions.html#index-internationalization-1270">internationalization</a>:
<a href="I18N-Functions.html#I18N-Functions">I18N Functions</a></li>
-<li><a
href="Internationalization.html#index-internationalization_002c-localization-1300">internationalization,
localization</a>: <a
href="Internationalization.html#Internationalization">Internationalization</a></li>
-<li><a
href="User_002dmodified.html#index-internationalization_002c-localization-1040">internationalization,
localization</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Character-Lists.html#index-internationalization_002c-localization_002c-character-classes-277">internationalization,
localization, character classes</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Internationalization.html#index-internationalization_002c-localization_002c-_0040command_007bgawk_007d-and-1302">internationalization,
localization, <samp><span class="command">gawk</span></samp> and</a>: <a
href="Internationalization.html#Internationalization">Internationalization</a></li>
-<li><a
href="Explaining-gettext.html#index-internationalization_002c-localization_002c-locale-categories-1326">internationalization,
localization, locale categories</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Programmer-i18n.html#index-internationalization_002c-localization_002c-marked-strings-1344">internationalization,
localization, marked strings</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="I18N-Portability.html#index-internationalization_002c-localization_002c-portability-and-1377">internationalization,
localization, portability and</a>: <a
href="I18N-Portability.html#I18N-Portability">I18N Portability</a></li>
-<li><a
href="Explaining-gettext.html#index-internationalizing-a-program-1306">internationalizing
a program</a>: <a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a></li>
-<li><a href="Glossary.html#index-interpreted-programs-2074">interpreted
programs</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Basic-High-Level.html#index-interpreted-programs-2027">interpreted
programs</a>: <a href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a></li>
-<li><a href="Regexp-Operators.html#index-interval-expressions-249">interval
expressions</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Sample-Data-Files.html#index-_0040code_007binventory_002dshipped_007d-file-137"><code>inventory-shipped</code>
file</a>: <a href="Sample-Data-Files.html#Sample-Data-Files">Sample Data
Files</a></li>
-<li><a href="Glossary.html#index-ISO-2075">ISO</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Glossary.html#index-ISO-8859_002d1-2058">ISO 8859-1</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Glossary.html#index-ISO-Latin_002d1-2059">ISO Latin-1</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Passwd-Functions.html#index-Jacobs_002c-Andrew-1703">Jacobs,
Andrew</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Contributors.html#index-Jaegermann_002c-Michal-1853">Jaegermann,
Michal</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Jaegermann_002c-Michal-62">Jaegermann,
Michal</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Undocumented.html#index-Jedi-knights-1582">Jedi knights</a>: <a
href="Undocumented.html#Undocumented">Undocumented</a></li>
-<li><a
href="Join-Function.html#index-_0040code_007bjoin_007d-user_002ddefined-function-1657"><code>join</code>
user-defined function</a>: <a href="Join-Function.html#Join-Function">Join
Function</a></li>
-<li><a href="Contributors.html#index-Kahrs_002c-J_0040_0022urgen-1859">Kahrs,
Jürgen</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Kahrs_002c-J_0040_0022urgen-63">Kahrs,
Jürgen</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Undocumented.html#index-Kenobi_002c-Obi_002dWan-1581">Kenobi,
Obi-Wan</a>: <a href="Undocumented.html#Undocumented">Undocumented</a></li>
-<li><a
href="Basic-Data-Typing.html#index-Kernighan_002c-Brian-2046">Kernighan,
Brian</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a href="Other-Versions.html#index-Kernighan_002c-Brian-1938">Kernighan,
Brian</a>: <a href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a href="Contributors.html#index-Kernighan_002c-Brian-1840">Kernighan,
Brian</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="BTL.html#index-Kernighan_002c-Brian-1832">Kernighan, Brian</a>:
<a href="BTL.html#BTL">BTL</a></li>
-<li><a href="Concatenation.html#index-Kernighan_002c-Brian-662">Kernighan,
Brian</a>: <a href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a href="Acknowledgments.html#index-Kernighan_002c-Brian-67">Kernighan,
Brian</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Conventions.html#index-Kernighan_002c-Brian-29">Kernighan,
Brian</a>: <a href="Conventions.html#Conventions">Conventions</a></li>
-<li><a href="History.html#index-Kernighan_002c-Brian-15">Kernighan, Brian</a>:
<a href="History.html#History">History</a></li>
-<li><a
href="Profiling.html#index-_0040command_007bkill_007d-command_0040comma_007b_007d-dynamic-profiling-1458"><samp><span
class="command">kill</span></samp> command, dynamic profiling</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Undocumented.html#index-Knights_002c-jedi-1583">Knights,
jedi</a>: <a href="Undocumented.html#Undocumented">Undocumented</a></li>
-<li><a href="Contributors.html#index-Kwok_002c-Conrad-1848">Kwok, Conrad</a>:
<a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="Labels-Program.html#index-_0040code_007blabels_002eawk_007d-program-1802"><code>labels.awk</code>
program</a>: <a href="Labels-Program.html#Labels-Program">Labels
Program</a></li>
-<li><a
href="Basic-High-Level.html#index-languages_0040comma_007b_007d-data_002ddriven-2033">languages,
data-driven</a>: <a href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fALL_007d-locale-category-1341"><code>LC_ALL</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fCOLLATE_007d-locale-category-1331"><code>LC_COLLATE</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fCTYPE_007d-locale-category-1332"><code>LC_CTYPE</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fMESSAGES_007d-locale-category-1329"><code>LC_MESSAGES</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bLC_005fMESSAGES_007d-locale-category_002c-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1357"><code>LC_MESSAGES</code>
locale category, <code>bindtextdomain</code> function (<samp><span
class="command">gawk</span></samp>)</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fMONETARY_007d-locale-category-1335"><code>LC_MONETARY</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fNUMERIC_007d-locale-category-1336"><code>LC_NUMERIC</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fRESPONSE_007d-locale-category-1337"><code>LC_RESPONSE</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007bLC_005fTIME_007d-locale-category-1340"><code>LC_TIME</code>
locale category</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Precedence.html#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-838">left
angle bracket (<code><</code>), <code><</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-749">left
angle bracket (<code><</code>), <code><</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Getline_002fFile.html#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-_0028I_002fO_0029-465">left
angle bracket (<code><</code>), <code><</code> operator (I/O)</a>: <a
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a></li>
-<li><a
href="Precedence.html#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-840">left
angle bracket (<code><</code>), <code><=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-751">left
angle bracket (<code><</code>), <code><=</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a href="Bitwise-Functions.html#index-left-shift_002c-bitwise-1253">left
shift, bitwise</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="Multiple-Line.html#index-leftmost-longest-match-451">leftmost
longest match</a>: <a href="Multiple-Line.html#Multiple-Line">Multiple
Line</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007blength_007d-function-1167"><code>length</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="Glossary.html#index-Lesser-General-Public-License-_0028LGPL_0029-2077">Lesser
General Public License (LGPL)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Glossary.html#index-LGPL-_0028Lesser-General-Public-License_0029-2076">LGPL
(Lesser General Public License)</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Library-Functions.html#index-libraries-of-_0040command_007bawk_007d-functions-1590">libraries
of <samp><span class="command">awk</span></samp> functions</a>: <a
href="Library-Functions.html#Library-Functions">Library Functions</a></li>
-<li><a
href="Assert-Function.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-assertions-1622">libraries
of <samp><span class="command">awk</span></samp> functions, assertions</a>: <a
href="Assert-Function.html#Assert-Function">Assert Function</a></li>
-<li><a
href="Library-Names.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-associative-arrays-and-1610">libraries
of <samp><span class="command">awk</span></samp> functions, associative arrays
and</a>: <a href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Ordinal-Functions.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-character-values-as-numbers-1642">libraries
of <samp><span class="command">awk</span></samp> functions, character values
as numbers</a>: <a href="Ordinal-Functions.html#Ordinal-Functions">Ordinal
Functions</a></li>
-<li><a
href="Getopt-Function.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-command_002dline-options-1681">libraries
of <samp><span class="command">awk</span></samp> functions, command-line
options</a>: <a href="Getopt-Function.html#Getopt-Function">Getopt
Function</a></li>
-<li><a
href="Igawk-Program.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-example-program-for-using-1817">libraries
of <samp><span class="command">awk</span></samp> functions, example program
for using</a>: <a href="Igawk-Program.html#Igawk-Program">Igawk Program</a></li>
-<li><a
href="Group-Functions.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-group-database_002c-reading-1717">libraries
of <samp><span class="command">awk</span></samp> functions, group database,
reading</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Data-File-Management.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-_0040value_007bDF_007ds-1664">libraries
of <samp><span class="command">awk</span></samp> functions, managing, data
files</a>: <a href="Data-File-Management.html#Data-File-Management">Data File
Management</a></li>
-<li><a
href="Gettimeofday-Function.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-managing_002c-time-1658">libraries
of <samp><span class="command">awk</span></samp> functions, managing,
time</a>: <a
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a
href="Join-Function.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-merging-arrays-into-strings-1653">libraries
of <samp><span class="command">awk</span></samp> functions, merging arrays
into strings</a>: <a href="Join-Function.html#Join-Function">Join
Function</a></li>
-<li><a
href="Nextfile-Function.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-_0040code_007bnextfile_007d-statement-1614">libraries
of <samp><span class="command">awk</span></samp> functions,
<code>nextfile</code> statement</a>: <a
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="Round-Function.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-rounding-numbers-1631">libraries
of <samp><span class="command">awk</span></samp> functions, rounding
numbers</a>: <a href="Round-Function.html#Round-Function">Round
Function</a></li>
-<li><a
href="Passwd-Functions.html#index-libraries-of-_0040command_007bawk_007d-functions_002c-user-database_002c-reading-1690">libraries
of <samp><span class="command">awk</span></samp> functions, user database,
reading</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Statements_002fLines.html#index-line-breaks-150">line breaks</a>:
<a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a href="Boolean-Ops.html#index-line-continuations-790">line
continuations</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Conditional-Exp.html#index-line-continuations_002c-_0040command_007bgawk_007d-802">line
continuations, <samp><span class="command">gawk</span></samp></a>: <a
href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="Print-Examples.html#index-line-continuations_002c-in-_0040code_007bprint_007d-statement-512">line
continuations, in <code>print</code> statement</a>: <a
href="Print-Examples.html#Print-Examples">Print Examples</a></li>
-<li><a
href="More-Complex.html#index-line-continuations_002c-with-C-shell-148">line
continuations, with C shell</a>: <a href="More-Complex.html#More-Complex">More
Complex</a></li>
-<li><a href="Print.html#index-lines_002c-blank_002c-printing-503">lines,
blank, printing</a>: <a href="Print.html#Print">Print</a></li>
-<li><a href="Wc-Program.html#index-lines_002c-counting-1783">lines,
counting</a>: <a href="Wc-Program.html#Wc-Program">Wc Program</a></li>
-<li><a
href="History-Sorting.html#index-lines_002c-duplicate_0040comma_007b_007d-removing-1806">lines,
duplicate, removing</a>: <a
href="History-Sorting.html#History-Sorting">History Sorting</a></li>
-<li><a href="Ranges.html#index-lines_002c-matching-ranges-of-906">lines,
matching ranges of</a>: <a href="Ranges.html#Ranges">Ranges</a></li>
-<li><a href="Ranges.html#index-lines_002c-skipping-between-markers-910">lines,
skipping between markers</a>: <a href="Ranges.html#Ranges">Ranges</a></li>
-<li><a href="User_002dmodified.html#index-lint-checking-1021">lint
checking</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a href="Delete.html#index-lint-checking_002c-array-elements-1108">lint
checking, array elements</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-lint-checking_002c-array-subscripts-1126">lint
checking, array subscripts</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="Command-Line.html#index-lint-checking_002c-empty-programs-1475">lint
checking, empty programs</a>: <a href="Command-Line.html#Command-Line">Command
Line</a></li>
-<li><a href="Options.html#index-lint-checking_002c-issuing-warnings-1520">lint
checking, issuing warnings</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Options.html#index-lint-checking_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1557">lint
checking, <code>POSIXLY_CORRECT</code> environment variable</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Function-Caveats.html#index-lint-checking_002c-undefined-functions-1296">lint
checking, undefined functions</a>: <a
href="Function-Caveats.html#Function-Caveats">Function Caveats</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bLINT_007d-variable-1019"><code>LINT</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a href="Glossary.html#index-Linux-2080">Linux</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Atari-Compiling.html#index-Linux-1917">Linux</a>: <a
href="Atari-Compiling.html#Atari-Compiling">Atari Compiling</a></li>
-<li><a
href="Additional-Configuration-Options.html#index-Linux-1885">Linux</a>: <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a></li>
-<li><a href="I18N-Example.html#index-Linux-1382">Linux</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a href="Manual-History.html#index-Linux-39">Linux</a>: <a
href="Manual-History.html#Manual-History">Manual History</a></li>
-<li><a href="Explaining-gettext.html#index-locale-categories-1328">locale
categories</a>: <a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a></li>
-<li><a href="I18N-and-L10N.html#index-localization-1305">localization</a>: <a
href="I18N-and-L10N.html#I18N-and-L10N">I18N and L10N</a></li>
-<li><a
href="I18N-and-L10N.html#index-localization_002c-See-internationalization_0040comma_007b_007d-localization-1304">localization,
See internationalization, localization</a>: <a
href="I18N-and-L10N.html#I18N-and-L10N">I18N and L10N</a></li>
-<li><a href="Time-Functions.html#index-log-files_002c-timestamps-in-1229">log
files, timestamps in</a>: <a href="Time-Functions.html#Time-Functions">Time
Functions</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007blog_007d-function-1153"><code>log</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a href="Truth-Values.html#index-logical-false_002ftrue-732">logical
false/true</a>: <a href="Truth-Values.html#Truth-Values">Truth Values</a></li>
-<li><a
href="Boolean-Ops.html#index-logical-operators_002c-See-Boolean-expressions-781">logical
operators, See Boolean expressions</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="Passwd-Functions.html#index-login-information-1698">login
information</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Command-Line.html#index-long-options-1472">long options</a>: <a
href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a href="While-Statement.html#index-loops-952">loops</a>: <a
href="While-Statement.html#While-Statement">While Statement</a></li>
-<li><a
href="For-Statement.html#index-loops_002c-_0040code_007bcontinue_007d-statements-and-957">loops,
<code>continue</code> statements and</a>: <a
href="For-Statement.html#For-Statement">For Statement</a></li>
-<li><a href="Profiling.html#index-loops_002c-count-for-header-1449">loops,
count for header</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Break-Statement.html#index-loops_002c-exiting-962">loops,
exiting</a>: <a href="Break-Statement.html#Break-Statement">Break
Statement</a></li>
-<li><a
href="While-Statement.html#index-loops_002c-See-Also-_0040code_007bwhile_007d-statement-953">loops,
See Also <code>while</code> statement</a>: <a
href="While-Statement.html#While-Statement">While Statement</a></li>
-<li><a href="Dynamic-Extensions.html#index-Lost-In-Space-1965">Lost In
Space</a>: <a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a></li>
-<li><a
href="More-Complex.html#index-_0040command_007bls_007d-utility-145"><samp><span
class="command">ls</span></samp> utility</a>: <a
href="More-Complex.html#More-Complex">More Complex</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007blshift_007d-function-_0028_0040command_007bgawk_007d_0029-1261"><code>lshift</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Assignment-Ops.html#index-lvalues_002frvalues-676">lvalues/rvalues</a>:
<a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Labels-Program.html#index-mailing-labels_0040comma_007b_007d-printing-1801">mailing
labels, printing</a>: <a href="Labels-Program.html#Labels-Program">Labels
Program</a></li>
-<li><a href="Acknowledgments.html#index-mailing-list_002c-GNITS-55">mailing
list, GNITS</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Internals.html#index-_0040code_007bmake_005fbuiltin_007d-internal-function-2001"><code>make_builtin</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bmake_005fnumber_007d-internal-function-1994"><code>make_number</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bmake_005fstring_007d-internal-function-1992"><code>make_string</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Ordinal-Functions.html#index-mark-parity-1652">mark parity</a>:
<a href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="String-Extraction.html#index-marked-string-extraction-_0028internationalization_0029-1367">marked
string extraction (internationalization)</a>: <a
href="String-Extraction.html#String-Extraction">String Extraction</a></li>
-<li><a
href="String-Extraction.html#index-marked-strings_0040comma_007b_007d-extracting-1363">marked
strings, extracting</a>: <a
href="String-Extraction.html#String-Extraction">String Extraction</a></li>
-<li><a href="Increment-Ops.html#index-Marx_002c-Groucho-729">Marx,
Groucho</a>: <a href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bmatch_007d-function-1170"><code>match</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bmatch_007d-function_002c-_0040code_007bRSTART_007d_002f_0040code_007bRLENGTH_007d-variables-1173"><code>match</code>
function, <code>RSTART</code>/<code>RLENGTH</code> variables</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Typing-and-Comparison.html#index-matching_002c-expressions_002c-See-comparison-expressions-740">matching,
expressions, See comparison expressions</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Multiple-Line.html#index-matching_002c-leftmost-longest-452">matching,
leftmost longest</a>: <a href="Multiple-Line.html#Multiple-Line">Multiple
Line</a></li>
-<li><a
href="Gory-Details.html#index-matching_002c-null-strings-1207">matching, null
strings</a>: <a href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="Other-Versions.html#index-_0040command_007bmawk_007d-program-1941"><samp><span
class="command">mawk</span></samp> program</a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a href="Contributors.html#index-McPhee_002c-Patrick-1867">McPhee,
Patrick</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Internals.html#index-memory_002c-releasing-1999">memory,
releasing</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Options.html#index-memory_002c-setting-limits-1494">memory,
setting limits</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Explaining-gettext.html#index-message-object-files-1316">message
object files</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Example.html#index-message-object-files_002c-converting-from-portable-object-files-1390">message
object files, converting from portable object files</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Programmer-i18n.html#index-message-object-files_002c-specifying-directory-of-1350">message
object files, specifying directory of</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-message-object-files_002c-specifying-directory-of-1321">message
object files, specifying directory of</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Escape-Sequences.html#index-metacharacters_002c-escape-sequences-for-219">metacharacters,
escape sequences for</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Time-Functions.html#index-_0040code_007bmktime_007d-function-_0028_0040command_007bgawk_007d_0029-1237"><code>mktime</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Format-Modifiers.html#index-modifiers_0040comma_007b_007d-in-format-specifiers-537">modifiers,
in format specifiers</a>: <a
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="Explaining-gettext.html#index-monetary-information_002c-localization-1333">monetary
information, localization</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Example.html#index-_0040command_007bmsgfmt_007d-utility-1392"><samp><span
class="command">msgfmt</span></samp> utility</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Library-Names.html#index-names_002c-arrays_002fvariables-1597">names,
arrays/variables</a>: <a href="Library-Names.html#Library-Names">Library
Names</a></li>
-<li><a href="Arrays.html#index-names_002c-arrays_002fvariables-1079">names,
arrays/variables</a>: <a href="Arrays.html#Arrays">Arrays</a></li>
-<li><a href="Library-Names.html#index-names_002c-functions-1598">names,
functions</a>: <a href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a href="Definition-Syntax.html#index-names_002c-functions-1278">names,
functions</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a href="Library-Names.html#index-namespace-issues-1599">namespace
issues</a>: <a href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a href="Arrays.html#index-namespace-issues-1080">namespace issues</a>: <a
href="Arrays.html#Arrays">Arrays</a></li>
-<li><a
href="Definition-Syntax.html#index-namespace-issues_002c-functions-1280">namespace
issues, functions</a>: <a
href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a></li>
-<li><a
href="Names.html#index-_0040command_007bnawk_007d-utility-22"><samp><span
class="command">nawk</span></samp> utility</a>: <a
href="Names.html#Names">Names</a></li>
-<li><a href="Floating-Point-Issues.html#index-negative-zero-2049">negative
zero</a>: <a href="Floating-Point-Issues.html#Floating-Point-Issues">Floating
Point Issues</a></li>
-<li><a href="Glossary.html#index-NetBSD-2084">NetBSD</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="TCP_002fIP-Networking.html#index-networks_002c-programming-1420">networks,
programming</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Special-Network.html#index-networks_002c-support-for-583">networks,
support for</a>: <a href="Special-Network.html#Special-Network">Special
Network</a></li>
-<li><a href="Options.html#index-newlines-1531">newlines</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a href="Boolean-Ops.html#index-newlines-793">newlines</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="Statements_002fLines.html#index-newlines-151">newlines</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Field-Separators.html#index-newlines_002c-as-field-separators-411">newlines,
as field separators</a>: <a
href="Field-Separators.html#Field-Separators">Field Separators</a></li>
-<li><a
href="Records.html#index-newlines_002c-as-record-separators-354">newlines, as
record separators</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Computed-Regexps.html#index-newlines_002c-in-dynamic-regexps-340">newlines,
in dynamic regexps</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Computed-Regexps.html#index-newlines_002c-in-regexp-constants-341">newlines,
in regexp constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a href="Print-Examples.html#index-newlines_002c-printing-505">newlines,
printing</a>: <a href="Print-Examples.html#Print-Examples">Print
Examples</a></li>
-<li><a
href="Statements.html#index-newlines_002c-separating-statements-in-actions-947">newlines,
separating statements in actions</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Action-Overview.html#index-newlines_002c-separating-statements-in-actions-935">newlines,
separating statements in actions</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="POSIX_002fGNU.html#index-_0040code_007bnext-file_007d-statement-1836"><code>next
file</code> statement</a>: <a
href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="Obsolete.html#index-_0040code_007bnext-file_007d-statement_002c-deprecated-1576"><code>next
file</code> statement, deprecated</a>: <a
href="Obsolete.html#Obsolete">Obsolete</a></li>
-<li><a
href="Nextfile-Statement.html#index-_0040code_007bnext-file_007d-statement_002c-in-_0040command_007bgawk_007d-981"><code>next
file</code> statement, in <samp><span class="command">gawk</span></samp></a>:
<a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="Next-Statement.html#index-_0040code_007bnext_007d-statement-970"><code>next</code>
statement</a>: <a href="Next-Statement.html#Next-Statement">Next
Statement</a></li>
-<li><a
href="Boolean-Ops.html#index-_0040code_007bnext_007d-statement-796"><code>next</code>
statement</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bnext_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-922"><code>next</code>
statement, <code>BEGIN</code>/<code>END</code> patterns and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Next-Statement.html#index-_0040code_007bnext_007d-statement_002c-user_002ddefined-functions-and-975"><code>next</code>
statement, user-defined functions and</a>: <a
href="Next-Statement.html#Next-Statement">Next Statement</a></li>
-<li><a
href="Nextfile-Statement.html#index-_0040code_007bnextfile_007d-statement-977"><code>nextfile</code>
statement</a>: <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-923"><code>nextfile</code>
statement, <code>BEGIN</code>/<code>END</code> patterns and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Nextfile-Function.html#index-_0040code_007bnextfile_007d-statement_002c-implementing-1616"><code>nextfile</code>
statement, implementing</a>: <a
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="Nextfile-Statement.html#index-_0040code_007bnextfile_007d-statement_002c-in-_0040command_007bgawk_007d-983"><code>nextfile</code>
statement, in <samp><span class="command">gawk</span></samp></a>: <a
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="Obsolete.html#index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bnext-file_007d-statement-and-1577"><code>nextfile</code>
statement, <code>next file</code> statement and</a>: <a
href="Obsolete.html#Obsolete">Obsolete</a></li>
-<li><a
href="Nextfile-Statement.html#index-_0040code_007bnextfile_007d-statement_002c-user_002ddefined-functions-and-980"><code>nextfile</code>
statement, user-defined functions and</a>: <a
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a></li>
-<li><a
href="Nextfile-Function.html#index-_0040code_007bnextfile_007d-user_002ddefined-function-1619"><code>nextfile</code>
user-defined function</a>: <a
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bNF_007d-variable-1059"><code>NF</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Fields.html#index-_0040code_007bNF_007d-variable-388"><code>NF</code>
variable</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a
href="Changing-Fields.html#index-_0040code_007bNF_007d-variable_002c-decrementing-399"><code>NF</code>
variable, decrementing</a>: <a
href="Changing-Fields.html#Changing-Fields">Changing Fields</a></li>
-<li><a
href="Ignoring-Assigns.html#index-_0040code_007bnoassign_002eawk_007d-program-1680"><code>noassign.awk</code>
program</a>: <a href="Ignoring-Assigns.html#Ignoring-Assigns">Ignoring
Assigns</a></li>
-<li><a
href="Internals.html#index-_0040code_007bNODE_007d-internal-type-1974"><code>NODE</code>
internal type</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-nodes_0040comma_007b_007d-duplicating-1997">nodes,
duplicating</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Boolean-Ops.html#index-not-Boolean_002dlogic-operator-776">not
Boolean-logic operator</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean
Ops</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bNR_007d-variable-1060"><code>NR</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Records.html#index-_0040code_007bNR_007d-variable-350"><code>NR</code>
variable</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bNR_007d-variable_002c-changing-1067"><code>NR</code>
variable, changing</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Basic-Data-Typing.html#index-null-strings-2045">null strings</a>:
<a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="Truth-Values.html#index-null-strings-735">null strings</a>: <a
href="Truth-Values.html#Truth-Values">Truth Values</a></li>
-<li><a href="Regexp-Field-Splitting.html#index-null-strings-415">null
strings</a>: <a
href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a></li>
-<li><a href="Records.html#index-null-strings-360">null strings</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a href="Delete.html#index-null-strings_002c-array-elements-and-1107">null
strings, array elements and</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-null-strings_002c-as-array-subscripts-1124">null
strings, as array subscripts</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="Conversion.html#index-null-strings_002c-converting-numbers-to-strings-644">null
strings, converting numbers to strings</a>: <a
href="Conversion.html#Conversion">Conversion</a></li>
-<li><a href="Gory-Details.html#index-null-strings_002c-matching-1208">null
strings, matching</a>: <a href="Gory-Details.html#Gory-Details">Gory
Details</a></li>
-<li><a href="Quoting.html#index-null-strings_002c-quoting-and-133">null
strings, quoting and</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Executable-Scripts.html#index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-106">number
sign (<code>#</code>), <code>#!</code> (executable scripts)</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Executable-Scripts.html#index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029_002c-portability-issues-with-109">number
sign (<code>#</code>), <code>#!</code> (executable scripts), portability
issues with</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Comments.html#index-number-sign-_0028_0040code_007b_0023_007d_0029_002c-commenting-114">number
sign (<code>#</code>), commenting</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a href="Internals.html#index-numbers-1993">numbers</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Numeric-Array-Subscripts.html#index-numbers_002c-as-array-subscripts-1115">numbers,
as array subscripts</a>: <a
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a
href="Ordinal-Functions.html#index-numbers_002c-as-values-of-characters-1645">numbers,
as values of characters</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="Cliff-Random-Function.html#index-numbers_002c-Cliff-random-1639">numbers,
Cliff random</a>: <a
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a></li>
-<li><a href="Conversion.html#index-numbers_002c-converting-642">numbers,
converting</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Bitwise-Functions.html#index-numbers_002c-converting_002c-to-strings-1265">numbers,
converting, to strings</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="User_002dmodified.html#index-numbers_002c-converting_002c-to-strings-1001">numbers,
converting, to strings</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Basic-Data-Typing.html#index-numbers_002c-floating_002dpoint-2040">numbers,
floating-point</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic
Data Typing</a></li>
-<li><a
href="Internals.html#index-numbers_002c-floating_002dpoint_002c-_0040code_007bAWKNUM_007d-internal-type-1972">numbers,
floating-point, <code>AWKNUM</code> internal type</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-numbers_002c-hexadecimal-613">numbers,
hexadecimal</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="Internals.html#index-numbers_002c-_0040code_007bNODE_007d-internal-type-1976">numbers,
<code>NODE</code> internal type</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Nondecimal_002dnumbers.html#index-numbers_002c-octal-612">numbers,
octal</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a href="Numeric-Functions.html#index-numbers_002c-random-1159">numbers,
random</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a href="Round-Function.html#index-numbers_002c-rounding-1630">numbers,
rounding</a>: <a href="Round-Function.html#Round-Function">Round
Function</a></li>
-<li><a href="Scalar-Constants.html#index-numeric_002c-constants-606">numeric,
constants</a>: <a href="Scalar-Constants.html#Scalar-Constants">Scalar
Constants</a></li>
-<li><a href="OFMT.html#index-numeric_002c-output-format-519">numeric, output
format</a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a
href="Typing-and-Comparison.html#index-numeric_002c-strings-745">numeric,
strings</a>: <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing
and Comparison</a></li>
-<li><a href="Internals.html#index-numeric_002c-values-1978">numeric,
values</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Names.html#index-_0040command_007boawk_007d-utility-23"><samp><span
class="command">oawk</span></samp> utility</a>: <a
href="Names.html#Names">Names</a></li>
-<li><a href="Obsolete.html#index-obsolete-features-1575">obsolete
features</a>: <a href="Obsolete.html#Obsolete">Obsolete</a></li>
-<li><a href="Nondecimal_002dnumbers.html#index-octal-numbers-610">octal
numbers</a>: <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a></li>
-<li><a
href="Options.html#index-octal-values_0040comma_007b_007d-enabling-interpretation-of-1525">octal
values, enabling interpretation of</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bOFMT_007d-variable-1023"><code>OFMT</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Conversion.html#index-_0040code_007bOFMT_007d-variable-649"><code>OFMT</code>
variable</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="OFMT.html#index-_0040code_007bOFMT_007d-variable-522"><code>OFMT</code>
variable</a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a
href="OFMT.html#index-_0040code_007bOFMT_007d-variable_002c-POSIX-_0040command_007bawk_007d-and-526"><code>OFMT</code>
variable, POSIX <samp><span class="command">awk</span></samp> and</a>: <a
href="OFMT.html#OFMT">OFMT</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bOFS_007d-variable-1028"><code>OFS</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Output-Separators.html#index-_0040code_007bOFS_007d-variable-514"><code>OFS</code>
variable</a>: <a href="Output-Separators.html#Output-Separators">Output
Separators</a></li>
-<li><a
href="Changing-Fields.html#index-_0040code_007bOFS_007d-variable-395"><code>OFS</code>
variable</a>: <a href="Changing-Fields.html#Changing-Fields">Changing
Fields</a></li>
-<li><a href="Glossary.html#index-OpenBSD-2086">OpenBSD</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Portal-Files.html#index-operating-systems_002c-BSD_002dbased-1435">operating
systems, BSD-based</a>: <a href="Portal-Files.html#Portal-Files">Portal
Files</a></li>
-<li><a
href="Manual-History.html#index-operating-systems_002c-BSD_002dbased-41">operating
systems, BSD-based</a>: <a href="Manual-History.html#Manual-History">Manual
History</a></li>
-<li><a
href="PC-Using.html#index-operating-systems_002c-PC_002c-_0040command_007bgawk_007d-on-1902">operating
systems, PC, <samp><span class="command">gawk</span></samp> on</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="PC-Installation.html#index-operating-systems_002c-PC_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1901">operating
systems, PC, <samp><span class="command">gawk</span></samp> on,
installing</a>: <a href="PC-Installation.html#PC-Installation">PC
Installation</a></li>
-<li><a
href="New-Ports.html#index-operating-systems_002c-porting-_0040command_007bgawk_007d-to-1961">operating
systems, porting <samp><span class="command">gawk</span></samp> to</a>: <a
href="New-Ports.html#New-Ports">New Ports</a></li>
-<li><a
href="Installation.html#index-operating-systems_002c-See-Also-GNU_002fLinux_002c-PC-operating-systems_002c-Unix-1869">operating
systems, See Also GNU/Linux, PC operating systems, Unix</a>: <a
href="Installation.html#Installation">Installation</a></li>
-<li><a
href="Bitwise-Functions.html#index-operations_002c-bitwise-1249">operations,
bitwise</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a
href="Arithmetic-Ops.html#index-operators_002c-arithmetic-653">operators,
arithmetic</a>: <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic
Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-operators_002c-assignment-671">operators,
assignment</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-operators_002c-assignment_002c-evaluation-order-684">operators,
assignment, evaluation order</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Boolean-Ops.html#index-operators_002c-Boolean_002c-See-Boolean-expressions-779">operators,
Boolean, See Boolean expressions</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Increment-Ops.html#index-operators_002c-decrement_002fincrement-712">operators,
decrement/increment</a>: <a href="Increment-Ops.html#Increment-Ops">Increment
Ops</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-operators_002c-GNU_002dspecific-282">operators,
GNU-specific</a>: <a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="Precedence.html#index-operators_002c-input_002foutput-851">operators,
input/output</a>: <a href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Redirection.html#index-operators_002c-input_002foutput-550">operators,
input/output</a>: <a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Getline_002fCoprocess.html#index-operators_002c-input_002foutput-485">operators,
input/output</a>: <a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="Getline_002fPipe.html#index-operators_002c-input_002foutput-474">operators,
input/output</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="Getline_002fFile.html#index-operators_002c-input_002foutput-466">operators,
input/output</a>: <a
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a></li>
-<li><a
href="Boolean-Ops.html#index-operators_002c-logical_002c-See-Boolean-expressions-782">operators,
logical, See Boolean expressions</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="Precedence.html#index-operators_002c-precedence-810">operators,
precedence</a>: <a href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Increment-Ops.html#index-operators_002c-precedence-726">operators,
precedence</a>: <a href="Increment-Ops.html#Increment-Ops">Increment
Ops</a></li>
-<li><a
href="Typing-and-Comparison.html#index-operators_002c-relational_002c-See-operators_0040comma_007b_007d-comparison-742">operators,
relational, See operators, comparison</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Boolean-Ops.html#index-operators_002c-short_002dcircuit-785">operators,
short-circuit</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="Concatenation.html#index-operators_002c-string-664">operators,
string</a>: <a href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="Regexp-Usage.html#index-operators_002c-string_002dmatching-174">operators,
string-matching</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp
Usage</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-operators_002c-string_002dmatching_002c-for-buffers-300">operators,
string-matching, for buffers</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-operators_002c-word_002dboundary-_0028_0040command_007bgawk_007d_0029-311">operators,
word-boundary (<samp><span class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a href="Options.html#index-options_002c-command_002dline-1477">options,
command-line</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-options_002c-command_002dline-424">options,
command-line</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a href="Long.html#index-options_002c-command_002dline-100">options,
command-line</a>: <a href="Long.html#Long">Long</a></li>
-<li><a
href="Options.html#index-options_002c-command_002dline_002c-end-of-1497">options,
command-line, end of</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Command-Line.html#index-options_002c-command_002dline_002c-invoking-_0040command_007bawk_007d-1470">options,
command-line, invoking <samp><span class="command">awk</span></samp></a>: <a
href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a
href="Getopt-Function.html#index-options_002c-command_002dline_002c-processing-1684">options,
command-line, processing</a>: <a
href="Getopt-Function.html#Getopt-Function">Getopt Function</a></li>
-<li><a href="Obsolete.html#index-options_002c-deprecated-1573">options,
deprecated</a>: <a href="Obsolete.html#Obsolete">Obsolete</a></li>
-<li><a href="Options.html#index-options_002c-long-1480">options, long</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a href="Command-Line.html#index-options_002c-long-1473">options,
long</a>: <a href="Command-Line.html#Command-Line">Command Line</a></li>
-<li><a href="Options.html#index-options_002c-printing-list-of-1517">options,
printing list of</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Bitwise-Functions.html#index-OR-bitwise-operation-1247">OR
bitwise operation</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="Boolean-Ops.html#index-or-Boolean_002dlogic-operator-775">or
Boolean-logic operator</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean
Ops</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007bor_007d-function-_0028_0040command_007bgawk_007d_0029-1258"><code>or</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Ordinal-Functions.html#index-_0040code_007bord_007d-user_002ddefined-function-1646"><code>ord</code>
user-defined function</a>: <a
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a></li>
-<li><a
href="Concatenation.html#index-order-of-evaluation_002c-concatenation-667">order
of evaluation, concatenation</a>: <a
href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bORS_007d-variable-1031"><code>ORS</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Output-Separators.html#index-_0040code_007bORS_007d-variable-517"><code>ORS</code>
variable</a>: <a href="Output-Separators.html#Output-Separators">Output
Separators</a></li>
-<li><a
href="Changing-Fields.html#index-output-field-separator_002c-See-_0040code_007bOFS_007d-variable-396">output
field separator, See <code>OFS</code> variable</a>: <a
href="Changing-Fields.html#Changing-Fields">Changing Fields</a></li>
-<li><a
href="Output-Separators.html#index-output-record-separator_002c-See-_0040code_007bORS_007d-variable-516">output
record separator, See <code>ORS</code> variable</a>: <a
href="Output-Separators.html#Output-Separators">Output Separators</a></li>
-<li><a href="Redirection.html#index-output-redirection-544">output
redirection</a>: <a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a href="I_002fO-Functions.html#index-output_002c-buffering-1216">output,
buffering</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="Tee-Program.html#index-output_002c-duplicating-into-files-1771">output,
duplicating into files</a>: <a href="Tee-Program.html#Tee-Program">Tee
Program</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-output_002c-files_0040comma_007b_007d-closing-590">output,
files, closing</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="OFMT.html#index-output_002c-format-specifier_0040comma_007b_007d-_0040code_007bOFMT_007d-523">output,
format specifier, <code>OFMT</code></a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a href="Printf.html#index-output_002c-formatted-528">output,
formatted</a>: <a href="Printf.html#Printf">Printf</a></li>
-<li><a href="Redirection.html#index-output_002c-pipes-555">output, pipes</a>:
<a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Printing.html#index-output_002c-printing_002c-See-printing-499">output,
printing, See printing</a>: <a href="Printing.html#Printing">Printing</a></li>
-<li><a href="Output-Separators.html#index-output_002c-records-515">output,
records</a>: <a href="Output-Separators.html#Output-Separators">Output
Separators</a></li>
-<li><a href="Special-FD.html#index-output_002c-standard-571">output,
standard</a>: <a href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a href="Glossary.html#index-P1003_002e2-POSIX-standard-2079">P1003.2
POSIX standard</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Internals.html#index-_0040code_007bparam_005fcnt_007d-internal-variable-1982"><code>param_cnt</code>
internal variable</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-parameters_0040comma_007b_007d-number-of-1981">parameters,
number of</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Regexp-Operators.html#index-parentheses-_0040code_007b_0028_0029_007d-242">parentheses
<code>()</code></a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Profiling.html#index-parentheses-_0040code_007b_0028_0029_007d_002c-_0040command_007bpgawk_007d-program-1455">parentheses
<code>()</code>, <samp><span class="command">pgawk</span></samp> program</a>:
<a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Passwd-Functions.html#index-password-file-1700">password
file</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Patterns-and-Actions.html#index-patterns-886">patterns</a>: <a
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and
Actions</a></li>
-<li><a
href="Expression-Patterns.html#index-patterns_002c-comparison-expressions-as-892">patterns,
comparison expressions as</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a href="Profiling.html#index-patterns_002c-counts-1448">patterns,
counts</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Very-Simple.html#index-patterns_002c-default-139">patterns,
default</a>: <a href="Very-Simple.html#Very-Simple">Very Simple</a></li>
-<li><a href="Empty.html#index-patterns_002c-empty-927">patterns, empty</a>: <a
href="Empty.html#Empty">Empty</a></li>
-<li><a
href="Regexp-Patterns.html#index-patterns_002c-expressions-as-888">patterns,
expressions as</a>: <a href="Regexp-Patterns.html#Regexp-Patterns">Regexp
Patterns</a></li>
-<li><a href="Ranges.html#index-patterns_002c-ranges-in-905">patterns, ranges
in</a>: <a href="Ranges.html#Ranges">Ranges</a></li>
-<li><a
href="Expression-Patterns.html#index-patterns_002c-regexp-constants-as-900">patterns,
regexp constants as</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a href="Pattern-Overview.html#index-patterns_002c-types-of-887">patterns,
types of</a>: <a href="Pattern-Overview.html#Pattern-Overview">Pattern
Overview</a></li>
-<li><a
href="Other-Versions.html#index-_0040command_007bpawk_007d-profiling-Bell-Labs-_0040command_007bawk_007d-1948"><samp><span
class="command">pawk</span></samp> profiling Bell Labs <samp><span
class="command">awk</span></samp></a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="PC-Using.html#index-PC-operating-systems_002c-_0040command_007bgawk_007d-on-1903">PC
operating systems, <samp><span class="command">gawk</span></samp> on</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="PC-Installation.html#index-PC-operating-systems_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1900">PC
operating systems, <samp><span class="command">gawk</span></samp> on,
installing</a>: <a href="PC-Installation.html#PC-Installation">PC
Installation</a></li>
-<li><a
href="Precedence.html#index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_007d-operator-832">percent
sign (<code>%</code>), <code>%</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-882">percent
sign (<code>%</code>), <code>%=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-693">percent
sign (<code>%</code>), <code>%=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Regexp-Operators.html#index-period-_0028_0040code_007b_002e_007d_0029-231">period
(<code>.</code>)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a href="Future-Extensions.html#index-PERL-2019">PERL</a>: <a
href="Future-Extensions.html#Future-Extensions">Future Extensions</a></li>
-<li><a href="Contributors.html#index-Peters_002c-Arno-1862">Peters, Arno</a>:
<a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Contributors.html#index-Peterson_002c-Hal-1851">Peterson,
Hal</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="Profiling.html#index-_0040command_007bpgawk_007d-program-1440"><samp><span
class="command">pgawk</span></samp> program</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-_0040command_007bpgawk_007d-program_002c-_0040code_007bawkprof_002eout_007d-file-1444"><samp><span
class="command">pgawk</span></samp> program, <code>awkprof.out</code>
file</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-_0040command_007bpgawk_007d-program_002c-dynamic-profiling-1457"><samp><span
class="command">pgawk</span></samp> program, dynamic profiling</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Close-Files-And-Pipes.html#index-pipes_002c-closing-591">pipes,
closing</a>: <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close
Files And Pipes</a></li>
-<li><a href="Getline_002fPipe.html#index-pipes_002c-input-473">pipes,
input</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="Redirection.html#index-pipes_002c-output-554">pipes, output</a>:
<a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Regexp-Operators.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029-246">plus
sign (<code>+</code>)</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Precedence.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_007d-operator-822">plus
sign (<code>+</code>), <code>+</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Precedence.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-814">plus
sign (<code>+</code>), <code>++</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Increment-Ops.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-721">plus
sign (<code>+</code>), <code>++</code> operator</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Precedence.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-872">plus
sign (<code>+</code>), <code>+=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Assignment-Ops.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-682">plus
sign (<code>+</code>), <code>+=</code> operator</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Increment-Ops.html#index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-decrement_002fincrement-operators-715">plus
sign (<code>+</code>), decrement/increment operators</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a href="Escape-Sequences.html#index-portability-211">portability</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Executable-Scripts.html#index-portability_002c-_0040code_007b_0023_0021_007d-_0028executable-scripts_0029-110">portability,
<code>#!</code> (executable scripts)</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Arithmetic-Ops.html#index-portability_002c-_0040code_007b_002a_002a_007d-operator-and-659">portability,
<code>**</code> operator and</a>: <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="Assignment-Ops.html#index-portability_002c-_0040code_007b_002a_002a_003d_007d-operator-and-701">portability,
<code>**=</code> operator and</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Executable-Scripts.html#index-portability_002c-_0040code_007bARGV_007d-variable-112">portability,
<code>ARGV</code> variable</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a
href="Statements_002fLines.html#index-portability_002c-backslash-continuation-and-155">portability,
backslash continuation and</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Escape-Sequences.html#index-portability_002c-backslash-in-escape-sequences-212">portability,
backslash in escape sequences</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-portability_002c-_0040code_007bclose_007d-function-and-596">portability,
<code>close</code> function and</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Records.html#index-portability_002c-_0040value_007bDF_007ds-as-single-record-371">portability,
data files as single record</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="Delete.html#index-portability_002c-deleting-array-elements-1112">portability,
deleting array elements</a>: <a href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Library-Functions.html#index-portability_002c-example-programs-1594">portability,
example programs</a>: <a
href="Library-Functions.html#Library-Functions">Library Functions</a></li>
-<li><a
href="I_002fO-Functions.html#index-portability_002c-_0040code_007bfflush_007d-function-and-1214">portability,
<code>fflush</code> function and</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="Definition-Syntax.html#index-portability_002c-functions_0040comma_007b_007d-defining-1286">portability,
functions, defining</a>: <a
href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a></li>
-<li><a
href="New-Ports.html#index-portability_002c-_0040command_007bgawk_007d-1960">portability,
<samp><span class="command">gawk</span></samp></a>: <a
href="New-Ports.html#New-Ports">New Ports</a></li>
-<li><a
href="Explaining-gettext.html#index-portability_002c-_0040code_007bgettext_007d-library-and-1308">portability,
<code>gettext</code> library and</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="I18N-Portability.html#index-portability_002c-internationalization-and-1376">portability,
internationalization and</a>: <a
href="I18N-Portability.html#I18N-Portability">I18N Portability</a></li>
-<li><a
href="String-Functions.html#index-portability_002c-_0040code_007blength_007d-function-1168">portability,
<code>length</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Conversion.html#index-portability_002c-new-_0040command_007bawk_007d-vs_002e-old-_0040command_007bawk_007d-650">portability,
new <samp><span class="command">awk</span></samp> vs. old <samp><span
class="command">awk</span></samp></a>: <a
href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Function-Caveats.html#index-portability_002c-_0040code_007bnext_007d-statement-in-user_002ddefined-functions-1297">portability,
<code>next</code> statement in user-defined functions</a>: <a
href="Function-Caveats.html#Function-Caveats">Function Caveats</a></li>
-<li><a
href="Changing-Fields.html#index-portability_002c-_0040code_007bNF_007d-variable_0040comma_007b_007d-decrementing-400">portability,
<code>NF</code> variable, decrementing</a>: <a
href="Changing-Fields.html#Changing-Fields">Changing Fields</a></li>
-<li><a
href="Increment-Ops.html#index-portability_002c-operators-727">portability,
operators</a>: <a href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Precedence.html#index-portability_002c-operators_002c-not-in-POSIX-_0040command_007bawk_007d-885">portability,
operators, not in POSIX <samp><span class="command">awk</span></samp></a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Options.html#index-portability_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1560">portability,
<code>POSIXLY_CORRECT</code> environment variable</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="String-Functions.html#index-portability_002c-_0040code_007bsubstr_007d-function-1192">portability,
<code>substr</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a href="Translator-i18n.html#index-portable-object-files-1360">portable
object files</a>: <a href="Translator-i18n.html#Translator-i18n">Translator
i18n</a></li>
-<li><a
href="Explaining-gettext.html#index-portable-object-files-1312">portable object
files</a>: <a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a></li>
-<li><a
href="I18N-Example.html#index-portable-object-files_002c-converting-to-message-object-files-1388">portable
object files, converting to message object files</a>: <a
href="I18N-Example.html#I18N-Example">I18N Example</a></li>
-<li><a
href="Options.html#index-portable-object-files_002c-generating-1512">portable
object files, generating</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Portal-Files.html#index-portal-files-1429">portal files</a>: <a
href="Portal-Files.html#Portal-Files">Portal Files</a></li>
-<li><a
href="New-Ports.html#index-porting-_0040command_007bgawk_007d-1962">porting
<samp><span class="command">gawk</span></samp></a>: <a
href="New-Ports.html#New-Ports">New Ports</a></li>
-<li><a
href="Printf-Ordering.html#index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement-1372">positional
specifiers, <code>printf</code> statement</a>: <a
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="Format-Modifiers.html#index-positional-specifiers_002c-_0040code_007bprintf_007d-statement-540">positional
specifiers, <code>printf</code> statement</a>: <a
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="Printf-Ordering.html#index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement_002c-mixing-with-regular-formats-1374">positional
specifiers, <code>printf</code> statement, mixing with regular formats</a>: <a
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a></li>
-<li><a href="Floating-Point-Issues.html#index-positive-zero-2050">positive
zero</a>: <a href="Floating-Point-Issues.html#Floating-Point-Issues">Floating
Point Issues</a></li>
-<li><a
href="Assignment-Ops.html#index-POSIX-_0040command_007bawk_007d-699">POSIX
<samp><span class="command">awk</span></samp></a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="This-Manual.html#index-POSIX-_0040command_007bawk_007d-27">POSIX
<samp><span class="command">awk</span></samp></a>: <a
href="This-Manual.html#This-Manual">This Manual</a></li>
-<li><a
href="Assignment-Ops.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_002a_002a_003d_007d-operator-and-700">POSIX
<samp><span class="command">awk</span></samp>, <code>**=</code> operator
and</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Getline_002fFile.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_003c_007d-operator-and-467">POSIX
<samp><span class="command">awk</span></samp>, <code><</code> operator
and</a>: <a href="Getline_002fFile.html#Getline_002fFile">Getline/File</a></li>
-<li><a
href="Arithmetic-Ops.html#index-POSIX-_0040command_007bawk_007d_002c-arithmetic-operators-and-654">POSIX
<samp><span class="command">awk</span></samp>, arithmetic operators and</a>:
<a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a></li>
-<li><a
href="Escape-Sequences.html#index-POSIX-_0040command_007bawk_007d_002c-backslashes-in-string-constants-213">POSIX
<samp><span class="command">awk</span></samp>, backslashes in string
constants</a>: <a href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-918">POSIX
<samp><span class="command">awk</span></samp>,
<code>BEGIN</code>/<code>END</code> patterns</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Break-Statement.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bbreak_007d-statement-and-963">POSIX
<samp><span class="command">awk</span></samp>, <code>break</code> statement
and</a>: <a href="Break-Statement.html#Break-Statement">Break Statement</a></li>
-<li><a
href="POSIX.html#index-POSIX-_0040command_007bawk_007d_002c-changes-in-_0040command_007bawk_007d-versions-1828">POSIX
<samp><span class="command">awk</span></samp>, changes in <samp><span
class="command">awk</span></samp> versions</a>: <a
href="POSIX.html#POSIX">POSIX</a></li>
-<li><a
href="Character-Lists.html#index-POSIX-_0040command_007bawk_007d_002c-character-lists-and-265">POSIX
<samp><span class="command">awk</span></samp>, character lists and</a>: <a
href="Character-Lists.html#Character-Lists">Character Lists</a></li>
-<li><a
href="Character-Lists.html#index-POSIX-_0040command_007bawk_007d_002c-character-lists-and_002c-character-classes-270">POSIX
<samp><span class="command">awk</span></samp>, character lists and, character
classes</a>: <a href="Character-Lists.html#Character-Lists">Character
Lists</a></li>
-<li><a
href="Continue-Statement.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bcontinue_007d-statement-and-967">POSIX
<samp><span class="command">awk</span></samp>, <code>continue</code> statement
and</a>: <a href="Continue-Statement.html#Continue-Statement">Continue
Statement</a></li>
-<li><a
href="User_002dmodified.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bCONVFMT_007d-variable-and-1000">POSIX
<samp><span class="command">awk</span></samp>, <code>CONVFMT</code> variable
and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Time-Functions.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bdate_007d-utility-and-1244">POSIX
<samp><span class="command">awk</span></samp>, <code>date</code> utility
and</a>: <a href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Field-Splitting-Summary.html#index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-433">POSIX
<samp><span class="command">awk</span></samp>, field separators and</a>: <a
href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a
href="Fields.html#index-POSIX-_0040command_007bawk_007d_002c-field-separators-and-380">POSIX
<samp><span class="command">awk</span></samp>, field separators and</a>: <a
href="Fields.html#Fields">Fields</a></li>
-<li><a
href="User_002dmodified.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bFS_007d-variable-and-1011">POSIX
<samp><span class="command">awk</span></samp>, <code>FS</code> variable
and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Definition-Syntax.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bfunction_007d-keyword-in-1285">POSIX
<samp><span class="command">awk</span></samp>, <code>function</code> keyword
in</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a
href="Gory-Details.html#index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-1205">POSIX
<samp><span class="command">awk</span></samp>, functions and,
<code>gsub</code>/<code>sub</code></a>: <a
href="Gory-Details.html#Gory-Details">Gory Details</a></li>
-<li><a
href="String-Functions.html#index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007blength_007d-1169">POSIX
<samp><span class="command">awk</span></samp>, functions and,
<code>length</code></a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Options.html#index-POSIX-_0040command_007bawk_007d_002c-GNU-long-options-and-1481">POSIX
<samp><span class="command">awk</span></samp>, GNU long options and</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Regexp-Operators.html#index-POSIX-_0040command_007bawk_007d_002c-interval-expressions-in-250">POSIX
<samp><span class="command">awk</span></samp>, interval expressions in</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Next-Statement.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-974">POSIX
<samp><span class="command">awk</span></samp>,
<code>next</code>/<code>nextfile</code> statements and</a>: <a
href="Next-Statement.html#Next-Statement">Next Statement</a></li>
-<li><a
href="Typing-and-Comparison.html#index-POSIX-_0040command_007bawk_007d_002c-numeric-strings-and-747">POSIX
<samp><span class="command">awk</span></samp>, numeric strings and</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Conversion.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-648">POSIX
<samp><span class="command">awk</span></samp>, <code>OFMT</code> variable
and</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="OFMT.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-525">POSIX
<samp><span class="command">awk</span></samp>, <code>OFMT</code> variable
and</a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a
href="Regexp-Operators.html#index-POSIX-_0040command_007bawk_007d_002c-period-_0028_0040code_007b_002e_007d_0029_0040comma_007b_007d-using-232">POSIX
<samp><span class="command">awk</span></samp>, period (<code>.</code>),
using</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Format-Modifiers.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bprintf_007d-format-strings-and-543">POSIX
<samp><span class="command">awk</span></samp>, <code>printf</code> format
strings and</a>: <a href="Format-Modifiers.html#Format-Modifiers">Format
Modifiers</a></li>
-<li><a
href="Regexp-Operators.html#index-POSIX-_0040command_007bawk_007d_002c-regular-expressions-and-254">POSIX
<samp><span class="command">awk</span></samp>, regular expressions and</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Time-Functions.html#index-POSIX-_0040command_007bawk_007d_002c-timestamps-and-1232">POSIX
<samp><span class="command">awk</span></samp>, timestamps and</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Getline_002fPipe.html#index-POSIX-_0040command_007bawk_007d_002c-_0040code_007b_007c_007d-I_002fO-operator-and-479">POSIX
<samp><span class="command">awk</span></samp>, <code>|</code> I/O operator
and</a>: <a href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="Options.html#index-POSIX-mode-1528">POSIX mode</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Preface.html#index-POSIX_002c-_0040command_007bawk_007d-and-3">POSIX,
<samp><span class="command">awk</span></samp> and</a>: <a
href="Preface.html#Preface">Preface</a></li>
-<li><a
href="POSIX_002fGNU.html#index-POSIX_002c-_0040command_007bgawk_007d-extensions-not-included-in-1835">POSIX,
<samp><span class="command">gawk</span></samp> extensions not included in</a>:
<a href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a></li>
-<li><a
href="Clones.html#index-POSIX_002c-programs_0040comma_007b_007d-implementing-in-_0040command_007bawk_007d-1742">POSIX,
programs, implementing in <samp><span class="command">awk</span></samp></a>:
<a href="Clones.html#Clones">Clones</a></li>
-<li><a
href="Options.html#index-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1556"><code>POSIXLY_CORRECT</code>
environment variable</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Precedence.html#index-precedence-809">precedence</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a href="Increment-Ops.html#index-precedence-725">precedence</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Regexp-Operators.html#index-precedence_002c-regexp-operators-252">precedence,
regexp operators</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Printing.html#index-_0040code_007bprint_007d-statement-500"><code>print</code>
statement</a>: <a href="Printing.html#Printing">Printing</a></li>
-<li><a
href="I_002fO-And-BEGIN_002fEND.html#index-_0040code_007bprint_007d-statement_002c-_0040code_007bBEGIN_007d_002f_0040code_007bEND_007d-patterns-and-919"><code>print</code>
statement, <code>BEGIN</code>/<code>END</code> patterns and</a>: <a
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a></li>
-<li><a
href="Print-Examples.html#index-_0040code_007bprint_007d-statement_002c-commas_002c-omitting-507"><code>print</code>
statement, commas, omitting</a>: <a
href="Print-Examples.html#Print-Examples">Print Examples</a></li>
-<li><a
href="Precedence.html#index-_0040code_007bprint_007d-statement_002c-I_002fO-operators-in-858"><code>print</code>
statement, I/O operators in</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Print-Examples.html#index-_0040code_007bprint_007d-statement_002c-line-continuations-and-513"><code>print</code>
statement, line continuations and</a>: <a
href="Print-Examples.html#Print-Examples">Print Examples</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bprint_007d-statement_002c-_0040code_007bOFMT_007d-variable-and-1027"><code>print</code>
statement, <code>OFMT</code> variable and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Redirection.html#index-_0040code_007bprint_007d-statement_002c-See-Also-redirection_002c-of-output-546"><code>print</code>
statement, See Also redirection, of output</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Round-Function.html#index-_0040code_007bprint_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1633"><code>print</code>
statement, <code>sprintf</code> function and</a>: <a
href="Round-Function.html#Round-Function">Round Function</a></li>
-<li><a
href="Printf.html#index-_0040code_007bprintf_007d-statement-527"><code>printf</code>
statement</a>: <a href="Printf.html#Printf">Printf</a></li>
-<li><a
href="Printing.html#index-_0040code_007bprintf_007d-statement-501"><code>printf</code>
statement</a>: <a href="Printing.html#Printing">Printing</a></li>
-<li><a
href="Print-Examples.html#index-_0040code_007bprintf_007d-statement_002c-columns_0040comma_007b_007d-aligning-510"><code>printf</code>
statement, columns, aligning</a>: <a
href="Print-Examples.html#Print-Examples">Print Examples</a></li>
-<li><a
href="Control-Letters.html#index-_0040code_007bprintf_007d-statement_002c-format_002dcontrol-characters-532"><code>printf</code>
statement, format-control characters</a>: <a
href="Control-Letters.html#Control-Letters">Control Letters</a></li>
-<li><a
href="Precedence.html#index-_0040code_007bprintf_007d-statement_002c-I_002fO-operators-in-859"><code>printf</code>
statement, I/O operators in</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Format-Modifiers.html#index-_0040code_007bprintf_007d-statement_002c-modifiers-536"><code>printf</code>
statement, modifiers</a>: <a
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="Printf-Ordering.html#index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-1371"><code>printf</code>
statement, positional specifiers</a>: <a
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="Format-Modifiers.html#index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-539"><code>printf</code>
statement, positional specifiers</a>: <a
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="Printf-Ordering.html#index-_0040code_007bprintf_007d-statement_002c-positional-specifiers_002c-mixing-with-regular-formats-1373"><code>printf</code>
statement, positional specifiers, mixing with regular formats</a>: <a
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a></li>
-<li><a
href="Redirection.html#index-_0040code_007bprintf_007d-statement_002c-See-Also-redirection_002c-of-output-547"><code>printf</code>
statement, See Also redirection, of output</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Round-Function.html#index-_0040code_007bprintf_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1634"><code>printf</code>
statement, <code>sprintf</code> function and</a>: <a
href="Round-Function.html#Round-Function">Round Function</a></li>
-<li><a
href="Basic-Printf.html#index-_0040code_007bprintf_007d-statement_002c-syntax-of-530"><code>printf</code>
statement, syntax of</a>: <a href="Basic-Printf.html#Basic-Printf">Basic
Printf</a></li>
-<li><a href="Printing.html#index-printing-498">printing</a>: <a
href="Printing.html#Printing">Printing</a></li>
-<li><a href="Options.html#index-printing_002c-list-of-options-1518">printing,
list of options</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Labels-Program.html#index-printing_002c-mailing-labels-1800">printing,
mailing labels</a>: <a href="Labels-Program.html#Labels-Program">Labels
Program</a></li>
-<li><a
href="Uniq-Program.html#index-printing_002c-unduplicated-lines-of-text-1775">printing,
unduplicated lines of text</a>: <a href="Uniq-Program.html#Uniq-Program">Uniq
Program</a></li>
-<li><a
href="Id-Program.html#index-printing_002c-user-information-1762">printing, user
information</a>: <a href="Id-Program.html#Id-Program">Id Program</a></li>
-<li><a href="Library-Names.html#index-private-variables-1603">private
variables</a>: <a href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Special-Process.html#index-process-information_002c-files-for-582">process
information, files for</a>: <a
href="Special-Process.html#Special-Process">Special Process</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-processes_002c-two_002dway-communications-with-1408">processes,
two-way communications with</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a href="Basic-High-Level.html#index-processing-data-2025">processing
data</a>: <a href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a></li>
-<li><a
href="Group-Functions.html#index-_0040code_007bPROCINFO_007d-array-1721"><code>PROCINFO</code>
array</a>: <a href="Group-Functions.html#Group-Functions">Group
Functions</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040code_007bPROCINFO_007d-array-1694"><code>PROCINFO</code>
array</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bPROCINFO_007d-array-1061"><code>PROCINFO</code>
array</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Special-Caveats.html#index-_0040code_007bPROCINFO_007d-array-587"><code>PROCINFO</code>
array</a>: <a href="Special-Caveats.html#Special-Caveats">Special
Caveats</a></li>
-<li><a
href="Profiling.html#index-profiling-_0040command_007bawk_007d-programs-1439">profiling
<samp><span class="command">awk</span></samp> programs</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-profiling-_0040command_007bawk_007d-programs_002c-dynamically-1456">profiling
<samp><span class="command">awk</span></samp> programs, dynamically</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-profiling-_0040command_007bgawk_007d_002c-See-_0040command_007bpgawk_007d-program-1441">profiling
<samp><span class="command">gawk</span></samp>, See <samp><span
class="command">pgawk</span></samp> program</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Getting-Started.html#index-program_002c-definition-of-76">program,
definition of</a>: <a href="Getting-Started.html#Getting-Started">Getting
Started</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-programmers_002c-attractiveness-of-1406">programmers,
attractiveness of</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Nondecimal-Data.html#index-programming-conventions_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1402">programming
conventions, <code>--non-decimal-data</code> option</a>: <a
href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="Auto_002dset.html#index-programming-conventions_002c-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables-1046">programming
conventions, <code>ARGC</code>/<code>ARGV</code> variables</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Exit-Statement.html#index-programming-conventions_002c-_0040code_007bexit_007d-statement-989">programming
conventions, <code>exit</code> statement</a>: <a
href="Exit-Statement.html#Exit-Statement">Exit Statement</a></li>
-<li><a
href="Return-Statement.html#index-programming-conventions_002c-function-parameters-1299">programming
conventions, function parameters</a>: <a
href="Return-Statement.html#Return-Statement">Return Statement</a></li>
-<li><a
href="Calling-Built_002din.html#index-programming-conventions_002c-functions_002c-calling-1142">programming
conventions, functions, calling</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a
href="Definition-Syntax.html#index-programming-conventions_002c-functions_002c-writing-1281">programming
conventions, functions, writing</a>: <a
href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a></li>
-<li><a
href="Internal-File-Ops.html#index-programming-conventions_002c-_0040command_007bgawk_007d-internals-2015">programming
conventions, <samp><span class="command">gawk</span></samp> internals</a>: <a
href="Internal-File-Ops.html#Internal-File-Ops">Internal File Ops</a></li>
-<li><a
href="Nextfile-Function.html#index-programming-conventions_002c-_0040code_007bnextfile_007d-statement-1618">programming
conventions, <code>nextfile</code> statement</a>: <a
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a></li>
-<li><a
href="Library-Names.html#index-programming-conventions_002c-private-variable-names-1605">programming
conventions, private variable names</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="History.html#index-programming-language_002c-recipe-for-12">programming
language, recipe for</a>: <a href="History.html#History">History</a></li>
-<li><a
href="Getting-Started.html#index-programming-languages_0040comma_007b_007d-data_002ddriven-vs_002e-procedural-74">programming
languages, data-driven vs. procedural</a>: <a
href="Getting-Started.html#Getting-Started">Getting Started</a></li>
-<li><a
href="Basic-High-Level.html#index-programming_002c-basic-steps-2028">programming,
basic steps</a>: <a href="Basic-High-Level.html#Basic-High-Level">Basic High
Level</a></li>
-<li><a
href="Basic-Concepts.html#index-programming_002c-concepts-2023">programming,
concepts</a>: <a href="Basic-Concepts.html#Basic-Concepts">Basic
Concepts</a></li>
-<li><a
href="Passwd-Functions.html#index-_0040command_007bpwcat_007d-program-1702"><samp><span
class="command">pwcat</span></samp> program</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-question-mark-_0028_0040code_007b_003f_007d_0029-308">question
mark (<code>?</code>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-question-mark-_0028_0040code_007b_003f_007d_0029-248">question
mark (<code>?</code>)</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Precedence.html#index-question-mark-_0028_0040code_007b_003f_007d_0029_002c-_0040code_007b_003f_003a_007d-operator-870">question
mark (<code>?</code>), <code>?:</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bQUIT_007d-signal-_0028MS_002dDOS_0029-1465"><code>QUIT</code>
signal (MS-DOS)</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Comments.html#index-quoting-117">quoting</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a href="Long.html#index-quoting-101">quoting</a>: <a
href="Long.html#Long">Long</a></li>
-<li><a href="Read-Terminal.html#index-quoting-90">quoting</a>: <a
href="Read-Terminal.html#Read-Terminal">Read Terminal</a></li>
-<li><a href="Quoting.html#index-quoting_002c-rules-for-122">quoting, rules
for</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a href="Quoting.html#index-quoting_002c-tricks-for-134">quoting, tricks
for</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a href="History-Sorting.html#index-Rakitzis_002c-Byron-1807">Rakitzis,
Byron</a>: <a href="History-Sorting.html#History-Sorting">History
Sorting</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007brand_007d-function-1157"><code>rand</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a
href="Cliff-Random-Function.html#index-random-numbers_002c-Cliff-1637">random
numbers, Cliff</a>: <a
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a></li>
-<li><a
href="Numeric-Functions.html#index-random-numbers_002c-_0040code_007brand_007d_002f_0040code_007bsrand_007d-functions-1158">random
numbers, <code>rand</code>/<code>srand</code> functions</a>: <a
href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a></li>
-<li><a
href="Numeric-Functions.html#index-random-numbers_002c-seed-of-1160">random
numbers, seed of</a>: <a
href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a></li>
-<li><a href="Character-Lists.html#index-range-expressions-258">range
expressions</a>: <a href="Character-Lists.html#Character-Lists">Character
Lists</a></li>
-<li><a href="Ranges.html#index-range-patterns-904">range patterns</a>: <a
href="Ranges.html#Ranges">Ranges</a></li>
-<li><a href="Bugs.html#index-Rankin_002c-Pat-1935">Rankin, Pat</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Rankin_002c-Pat-1847">Rankin, Pat</a>: <a
href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Assignment-Ops.html#index-Rankin_002c-Pat-683">Rankin, Pat</a>:
<a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="Acknowledgments.html#index-Rankin_002c-Pat-64">Rankin, Pat</a>:
<a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="TCP_002fIP-Networking.html#index-raw-sockets-1425">raw
sockets</a>: <a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="File-Checking.html#index-readable-_0040value_007bDF_007ds_0040comma_007b_007d-checking-1673">readable
data files, checking</a>: <a href="File-Checking.html#File-Checking">File
Checking</a></li>
-<li><a
href="File-Checking.html#index-_0040code_007breadable_002eawk_007d-program-1675"><code>readable.awk</code>
program</a>: <a href="File-Checking.html#File-Checking">File Checking</a></li>
-<li><a href="History.html#index-recipe-for-a-programming-language-11">recipe
for a programming language</a>: <a href="History.html#History">History</a></li>
-<li><a href="User_002dmodified.html#index-record-separators-1034">record
separators</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a href="Records.html#index-record-separators-353">record separators</a>:
<a href="Records.html#Records">Records</a></li>
-<li><a href="Records.html#index-record-separators_002c-changing-357">record
separators, changing</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Records.html#index-record-separators_002c-regular-expressions-as-367">record
separators, regular expressions as</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="Multiple-Line.html#index-record-separators_002c-with-multiline-records-449">record
separators, with multiline records</a>: <a
href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a href="Basic-High-Level.html#index-records-2030">records</a>: <a
href="Basic-High-Level.html#Basic-High-Level">Basic High Level</a></li>
-<li><a href="Reading-Files.html#index-records-345">records</a>: <a
href="Reading-Files.html#Reading-Files">Reading Files</a></li>
-<li><a href="Multiple-Line.html#index-records_002c-multiline-445">records,
multiline</a>: <a href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a href="Print.html#index-records_002c-printing-502">records,
printing</a>: <a href="Print.html#Print">Print</a></li>
-<li><a
href="Records.html#index-records_002c-splitting-input-into-349">records,
splitting input into</a>: <a href="Records.html#Records">Records</a></li>
-<li><a href="Records.html#index-records_002c-terminating-363">records,
terminating</a>: <a href="Records.html#Records">Records</a></li>
-<li><a href="Records.html#index-records_002c-treating-files-as-374">records,
treating files as</a>: <a href="Records.html#Records">Records</a></li>
-<li><a href="Definition-Syntax.html#index-recursive-functions-1283">recursive
functions</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a href="Getline_002fFile.html#index-redirection-of-input-463">redirection
of input</a>: <a
href="Getline_002fFile.html#Getline_002fFile">Getline/File</a></li>
-<li><a href="Redirection.html#index-redirection-of-output-545">redirection of
output</a>: <a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Array-Sorting.html#index-reference-counting_002c-sorting-arrays-1137">reference
counting, sorting arrays</a>: <a href="Array-Sorting.html#Array-Sorting">Array
Sorting</a></li>
-<li><a href="Typing-and-Comparison.html#index-regexp-constants-773">regexp
constants</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a href="Regexp-Constants.html#index-regexp-constants-619">regexp
constants</a>: <a href="Regexp-Constants.html#Regexp-Constants">Regexp
Constants</a></li>
-<li><a href="Regexp-Usage.html#index-regexp-constants-182">regexp
constants</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Assignment-Ops.html#index-regexp-constants_002c-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d_002c-_0040code_007b_002f_003d_007d-operator-and-706">regexp
constants, <code>/=.../</code>, <code>/=</code> operator and</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Expression-Patterns.html#index-regexp-constants_002c-as-patterns-899">regexp
constants, as patterns</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-regexp-constants_002c-in-_0040command_007bgawk_007d-626">regexp
constants, in <samp><span class="command">gawk</span></samp></a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="Computed-Regexps.html#index-regexp-constants_002c-slashes-vs_002e-quotes-331">regexp
constants, slashes vs. quotes</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Computed-Regexps.html#index-regexp-constants_002c-vs_002e-string-constants-337">regexp
constants, vs. string constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Regexp.html#index-regexp_002c-See-regular-expressions-168">regexp, See
regular expressions</a>: <a href="Regexp.html#Regexp">Regexp</a></li>
-<li><a href="Regexp.html#index-regular-expressions-169">regular
expressions</a>: <a href="Regexp.html#Regexp">Regexp</a></li>
-<li><a
href="Field-Separators.html#index-regular-expressions-as-field-separators-409">regular
expressions as field separators</a>: <a
href="Field-Separators.html#Field-Separators">Field Separators</a></li>
-<li><a
href="Regexp-Operators.html#index-regular-expressions_002c-anchors-in-224">regular
expressions, anchors in</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Regexp-Field-Splitting.html#index-regular-expressions_002c-as-field-separators-413">regular
expressions, as field separators</a>: <a
href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a></li>
-<li><a
href="Regexp-Patterns.html#index-regular-expressions_002c-as-patterns-889">regular
expressions, as patterns</a>: <a
href="Regexp-Patterns.html#Regexp-Patterns">Regexp Patterns</a></li>
-<li><a
href="Regexp-Usage.html#index-regular-expressions_002c-as-patterns-172">regular
expressions, as patterns</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp
Usage</a></li>
-<li><a
href="Records.html#index-regular-expressions_002c-as-record-separators-366">regular
expressions, as record separators</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="User_002dmodified.html#index-regular-expressions_002c-case-sensitivity-1017">regular
expressions, case sensitivity</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Case_002dsensitivity.html#index-regular-expressions_002c-case-sensitivity-314">regular
expressions, case sensitivity</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="Computed-Regexps.html#index-regular-expressions_002c-computed-325">regular
expressions, computed</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Regexp-Usage.html#index-regular-expressions_002c-constants_002c-See-regexp-constants-183">regular
expressions, constants, See regexp constants</a>: <a
href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Computed-Regexps.html#index-regular-expressions_002c-dynamic-326">regular
expressions, dynamic</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Computed-Regexps.html#index-regular-expressions_002c-dynamic_002c-with-embedded-newlines-339">regular
expressions, dynamic, with embedded newlines</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-regular-expressions_002c-_0040command_007bgawk_007d_002c-command_002dline-options-312">regular
expressions, <samp><span class="command">gawk</span></samp>, command-line
options</a>: <a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU
Regexp Operators</a></li>
-<li><a
href="Options.html#index-regular-expressions_002c-interval-expressions-and-1548">regular
expressions, interval expressions and</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Leftmost-Longest.html#index-regular-expressions_002c-leftmost-longest-match-324">regular
expressions, leftmost longest match</a>: <a
href="Leftmost-Longest.html#Leftmost-Longest">Leftmost Longest</a></li>
-<li><a
href="Regexp-Operators.html#index-regular-expressions_002c-operators-221">regular
expressions, operators</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Regexp-Usage.html#index-regular-expressions_002c-operators-173">regular
expressions, operators</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp
Usage</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-regular-expressions_002c-operators_002c-for-buffers-299">regular
expressions, operators, for buffers</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-regular-expressions_002c-operators_002c-for-words-283">regular
expressions, operators, for words</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-regular-expressions_002c-operators_002c-_0040command_007bgawk_007d-280">regular
expressions, operators, <samp><span class="command">gawk</span></samp></a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Regexp-Operators.html#index-regular-expressions_002c-operators_002c-precedence-of-253">regular
expressions, operators, precedence of</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Egrep-Program.html#index-regular-expressions_002c-searching-for-1751">regular
expressions, searching for</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Typing-and-Comparison.html#index-relational-operators_002c-See-comparison-operators-741">relational
operators, See comparison operators</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Return-Statement.html#index-_0040code_007breturn_007d-statement_0040comma_007b_007d-user_002ddefined-functions-1298"><code>return</code>
statement, user-defined functions</a>: <a
href="Return-Statement.html#Return-Statement">Return Statement</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-return-values_0040comma_007b_007d-_0040code_007bclose_007d-function-601">return
values, <code>close</code> function</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Function-Example.html#index-_0040code_007brev_007d-user_002ddefined-function-1287"><code>rev</code>
user-defined function</a>: <a
href="Function-Example.html#Function-Example">Function Example</a></li>
-<li><a
href="Rewind-Function.html#index-_0040code_007brewind_007d-user_002ddefined-function-1671"><code>rewind</code>
user-defined function</a>: <a
href="Rewind-Function.html#Rewind-Function">Rewind Function</a></li>
-<li><a
href="Precedence.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-844">right
angle bracket (<code>></code>), <code>></code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-755">right
angle bracket (<code>></code>), <code>></code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Redirection.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-549">right
angle bracket (<code>></code>), <code>></code> operator (I/O)</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Precedence.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-842">right
angle bracket (<code>></code>), <code>>=</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-753">right
angle bracket (<code>></code>), <code>>=</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Precedence.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-850">right
angle bracket (<code>></code>), <code>>></code> operator (I/O)</a>:
<a href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Redirection.html#index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-552">right
angle bracket (<code>></code>), <code>>></code> operator (I/O)</a>:
<a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a href="Bitwise-Functions.html#index-right-shift_002c-bitwise-1254">right
shift, bitwise</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="Basic-Data-Typing.html#index-Ritchie_002c-Dennis-2047">Ritchie,
Dennis</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bRLENGTH_007d-variable-1063"><code>RLENGTH</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bRLENGTH_007d-variable_002c-_0040code_007bmatch_007d-function-and-1172"><code>RLENGTH</code>
variable, <code>match</code> function and</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a href="Future-Extensions.html#index-Robbins_002c-Arnold-2021">Robbins,
Arnold</a>: <a href="Future-Extensions.html#Future-Extensions">Future
Extensions</a></li>
-<li><a href="Bugs.html#index-Robbins_002c-Arnold-1927">Robbins, Arnold</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a href="Contributors.html#index-Robbins_002c-Arnold-1868">Robbins,
Arnold</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Alarm-Program.html#index-Robbins_002c-Arnold-1792">Robbins,
Arnold</a>: <a href="Alarm-Program.html#Alarm-Program">Alarm Program</a></li>
-<li><a href="Passwd-Functions.html#index-Robbins_002c-Arnold-1704">Robbins,
Arnold</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Getline_002fPipe.html#index-Robbins_002c-Arnold-478">Robbins,
Arnold</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-Robbins_002c-Arnold-432">Robbins,
Arnold</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a href="Getline_002fPipe.html#index-Robbins_002c-Bill-476">Robbins,
Bill</a>: <a href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="Acknowledgments.html#index-Robbins_002c-Harry-70">Robbins,
Harry</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Acknowledgments.html#index-Robbins_002c-Jean-69">Robbins,
Jean</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Passwd-Functions.html#index-Robbins_002c-Miriam-1705">Robbins,
Miriam</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a href="Getline_002fPipe.html#index-Robbins_002c-Miriam-477">Robbins,
Miriam</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a href="Acknowledgments.html#index-Robbins_002c-Miriam-68">Robbins,
Miriam</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Dynamic-Extensions.html#index-Robinson_002c-Will-1963">Robinson,
Will</a>: <a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a></li>
-<li><a href="Dynamic-Extensions.html#index-robot_002c-the-1964">robot,
the</a>: <a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a></li>
-<li><a href="Contributors.html#index-Rommel_002c-Kai-Uwe-1852">Rommel, Kai
Uwe</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Rommel_002c-Kai-Uwe-65">Rommel, Kai
Uwe</a>: <a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Round-Function.html#index-_0040code_007bround_007d-user_002ddefined-function-1636"><code>round</code>
user-defined function</a>: <a href="Round-Function.html#Round-Function">Round
Function</a></li>
-<li><a href="Round-Function.html#index-rounding-1628">rounding</a>: <a
href="Round-Function.html#Round-Function">Round Function</a></li>
-<li><a href="Round-Function.html#index-rounding-numbers-1629">rounding
numbers</a>: <a href="Round-Function.html#Round-Function">Round
Function</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bRS_007d-variable-1032"><code>RS</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Records.html#index-_0040code_007bRS_007d-variable-355"><code>RS</code>
variable</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Multiple-Line.html#index-_0040code_007bRS_007d-variable_002c-multiline-records-and-450"><code>RS</code>
variable, multiline records and</a>: <a
href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007brshift_007d-function-_0028_0040command_007bgawk_007d_0029-1262"><code>rshift</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bRSTART_007d-variable-1064"><code>RSTART</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bRSTART_007d-variable_002c-_0040code_007bmatch_007d-function-and-1171"><code>RSTART</code>
variable, <code>match</code> function and</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Auto_002dset.html#index-_0040code_007bRT_007d-variable-1065"><code>RT</code>
variable</a>: <a href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a
href="Multiple-Line.html#index-_0040code_007bRT_007d-variable-455"><code>RT</code>
variable</a>: <a href="Multiple-Line.html#Multiple-Line">Multiple Line</a></li>
-<li><a
href="Records.html#index-_0040code_007bRT_007d-variable-362"><code>RT</code>
variable</a>: <a href="Records.html#Records">Records</a></li>
-<li><a href="Contributors.html#index-Rubin_002c-Paul-1841">Rubin, Paul</a>: <a
href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="History.html#index-Rubin_002c-Paul-17">Rubin, Paul</a>: <a
href="History.html#History">History</a></li>
-<li><a href="Getting-Started.html#index-rule_002c-definition-of-77">rule,
definition of</a>: <a href="Getting-Started.html#Getting-Started">Getting
Started</a></li>
-<li><a
href="Assignment-Ops.html#index-rvalues_002flvalues-677">rvalues/lvalues</a>:
<a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a href="Basic-Data-Typing.html#index-scalar-values-2037">scalar
values</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a href="Acknowledgments.html#index-Schreiber_002c-Bert-49">Schreiber,
Bert</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Acknowledgments.html#index-Schreiber_002c-Rita-50">Schreiber,
Rita</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="VMS-Running.html#index-search-paths-1913">search paths</a>: <a
href="VMS-Running.html#VMS-Running">VMS Running</a></li>
-<li><a href="PC-Using.html#index-search-paths-1904">search paths</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="VMS-Running.html#index-search-paths_002c-for-source-files-1914">search
paths, for source files</a>: <a href="VMS-Running.html#VMS-Running">VMS
Running</a></li>
-<li><a
href="Igawk-Program.html#index-search-paths_002c-for-source-files-1820">search
paths, for source files</a>: <a href="Igawk-Program.html#Igawk-Program">Igawk
Program</a></li>
-<li><a
href="AWKPATH-Variable.html#index-search-paths_002c-for-source-files-1570">search
paths, for source files</a>: <a
href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a></li>
-<li><a href="String-Functions.html#index-searching-1166">searching</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Egrep-Program.html#index-searching_002c-files-for-regular-expressions-1752">searching,
files for regular expressions</a>: <a
href="Egrep-Program.html#Egrep-Program">Egrep Program</a></li>
-<li><a
href="Dupword-Program.html#index-searching_002c-for-words-1787">searching, for
words</a>: <a href="Dupword-Program.html#Dupword-Program">Dupword
Program</a></li>
-<li><a
href="Glossary.html#index-_0040command_007bsed_007d-utility-2053"><samp><span
class="command">sed</span></samp> utility</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Simple-Sed.html#index-_0040command_007bsed_007d-utility-1813"><samp><span
class="command">sed</span></samp> utility</a>: <a
href="Simple-Sed.html#Simple-Sed">Simple Sed</a></li>
-<li><a
href="Field-Splitting-Summary.html#index-_0040command_007bsed_007d-utility-436"><samp><span
class="command">sed</span></samp> utility</a>: <a
href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a
href="Statements_002fLines.html#index-semicolon-_0028_0040code_007b_003b_007d_0029-164">semicolon
(<code>;</code>)</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="PC-Using.html#index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1908">semicolon
(<code>;</code>), <code>AWKPATH</code> variable and</a>: <a
href="PC-Using.html#PC-Using">PC Using</a></li>
-<li><a
href="Statements.html#index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-949">semicolon
(<code>;</code>), separating statements in actions</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Action-Overview.html#index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-937">semicolon
(<code>;</code>), separating statements in actions</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="User_002dmodified.html#index-separators_002c-field-1009">separators,
field</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="User_002dmodified.html#index-separators_002c-field_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1006">separators,
field, <code>FIELDWIDTHS</code> variable and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Fields.html#index-separators_002c-field_002c-POSIX-and-382">separators,
field, POSIX and</a>: <a href="Fields.html#Fields">Fields</a></li>
-<li><a href="Records.html#index-separators_002c-for-records-352">separators,
for records</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Records.html#index-separators_002c-for-records_002c-regular-expressions-as-368">separators,
for records, regular expressions as</a>: <a
href="Records.html#Records">Records</a></li>
-<li><a
href="Action-Overview.html#index-separators_002c-for-statements-in-actions-934">separators,
for statements in actions</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="User_002dmodified.html#index-separators_002c-record-1033">separators,
record</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="User_002dmodified.html#index-separators_002c-subscript-1036">separators,
subscript</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Internals.html#index-_0040code_007bset_005fvalue_007d-internal-function-2008"><code>set_value</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Redirection.html#index-shells_002c-piping-commands-into-566">shells,
piping commands into</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a href="Using-Shell-Variables.html#index-shells_002c-quoting-930">shells,
quoting</a>: <a href="Using-Shell-Variables.html#Using-Shell-Variables">Using
Shell Variables</a></li>
-<li><a
href="Quoting.html#index-shells_002c-quoting_002c-rules-for-123">shells,
quoting, rules for</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a href="One_002dshot.html#index-shells_002c-scripts-82">shells,
scripts</a>: <a href="One_002dshot.html#One_002dshot">One-shot</a></li>
-<li><a
href="Using-Shell-Variables.html#index-shells_002c-variables-928">shells,
variables</a>: <a href="Using-Shell-Variables.html#Using-Shell-Variables">Using
Shell Variables</a></li>
-<li><a href="Bitwise-Functions.html#index-shift_002c-bitwise-1255">shift,
bitwise</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a
href="Boolean-Ops.html#index-short_002dcircuit-operators-784">short-circuit
operators</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a href="Increment-Ops.html#index-side-effects-713">side effects</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a href="Concatenation.html#index-side-effects-669">side effects</a>: <a
href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="Reference-to-Elements.html#index-side-effects_002c-array-indexing-1093">side
effects, array indexing</a>: <a
href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a></li>
-<li><a
href="Array-Sorting.html#index-side-effects_002c-_0040code_007basort_007d-function-1136">side
effects, <code>asort</code> function</a>: <a
href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a
href="Assignment-Ops.html#index-side-effects_002c-assignment-expressions-675">side
effects, assignment expressions</a>: <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a></li>
-<li><a
href="Boolean-Ops.html#index-side-effects_002c-Boolean-operators-783">side
effects, Boolean operators</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean
Ops</a></li>
-<li><a
href="Conditional-Exp.html#index-side-effects_002c-conditional-expressions-800">side
effects, conditional expressions</a>: <a
href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a></li>
-<li><a
href="Increment-Ops.html#index-side-effects_002c-decrement_002fincrement-operators-716">side
effects, decrement/increment operators</a>: <a
href="Increment-Ops.html#Increment-Ops">Increment Ops</a></li>
-<li><a
href="Getline-Notes.html#index-side-effects_002c-_0040code_007bFILENAME_007d-variable-492">side
effects, <code>FILENAME</code> variable</a>: <a
href="Getline-Notes.html#Getline-Notes">Getline Notes</a></li>
-<li><a
href="Function-Calls.html#index-side-effects_002c-function-calls-808">side
effects, function calls</a>: <a
href="Function-Calls.html#Function-Calls">Function Calls</a></li>
-<li><a href="Action-Overview.html#index-side-effects_002c-statements-938">side
effects, statements</a>: <a href="Action-Overview.html#Action-Overview">Action
Overview</a></li>
-<li><a
href="Profiling.html#index-signals_002c-_0040code_007bHUP_007d_002f_0040code_007bSIGHUP_007d-1462">signals,
<code>HUP</code>/<code>SIGHUP</code></a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-signals_002c-_0040code_007bINT_007d_002f_0040code_007bSIGINT_007d-_0028MS_002dDOS_0029-1464">signals,
<code>INT</code>/<code>SIGINT</code> (MS-DOS)</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-signals_002c-_0040code_007bQUIT_007d_002f_0040code_007bSIGQUIT_007d-_0028MS_002dDOS_0029-1466">signals,
<code>QUIT</code>/<code>SIGQUIT</code> (MS-DOS)</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Profiling.html#index-signals_002c-_0040code_007bUSR1_007d_002f_0040code_007bSIGUSR1_007d-1460">signals,
<code>USR1</code>/<code>SIGUSR1</code></a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007bsin_007d-function-1154"><code>sin</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a
href="Quoting.html#index-single-quote-_0028_0040code_007b_0027_007d_0029-127">single
quote (<code>'</code>)</a>: <a href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Long.html#index-single-quote-_0028_0040code_007b_0027_007d_0029-102">single
quote (<code>'</code>)</a>: <a href="Long.html#Long">Long</a></li>
-<li><a
href="One_002dshot.html#index-single-quote-_0028_0040code_007b_0027_007d_0029-80">single
quote (<code>'</code>)</a>: <a
href="One_002dshot.html#One_002dshot">One-shot</a></li>
-<li><a
href="Comments.html#index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-vs_002e-apostrophe-118">single
quote (<code>'</code>), vs. apostrophe</a>: <a
href="Comments.html#Comments">Comments</a></li>
-<li><a
href="Quoting.html#index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-with-double-quotes-131">single
quote (<code>'</code>), with double quotes</a>: <a
href="Quoting.html#Quoting">Quoting</a></li>
-<li><a
href="Single-Character-Fields.html#index-single_002dcharacter-fields-419">single-character
fields</a>: <a
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a></li>
-<li><a
href="Basic-Data-Typing.html#index-single_002dprecision-floating_002dpoint-2044">single-precision
floating-point</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic
Data Typing</a></li>
-<li><a href="Undocumented.html#index-Skywalker_002c-Luke-1580">Skywalker,
Luke</a>: <a href="Undocumented.html#Undocumented">Undocumented</a></li>
-<li><a
href="Alarm-Program.html#index-_0040command_007bsleep_007d-utility-1796"><samp><span
class="command">sleep</span></samp> utility</a>: <a
href="Alarm-Program.html#Alarm-Program">Alarm Program</a></li>
-<li><a href="TCP_002fIP-Networking.html#index-sockets-1426">sockets</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Array-Sorting.html#index-sort-function_002c-arrays_002c-sorting-1135">sort
function, arrays, sorting</a>: <a
href="Array-Sorting.html#Array-Sorting">Array Sorting</a></li>
-<li><a
href="Word-Sorting.html#index-_0040command_007bsort_007d-utility-1804"><samp><span
class="command">sort</span></samp> utility</a>: <a
href="Word-Sorting.html#Word-Sorting">Word Sorting</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-_0040command_007bsort_007d-utility_002c-coprocesses-and-1418"><samp><span
class="command">sort</span></samp> utility, coprocesses and</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Explaining-gettext.html#index-sorting-characters-in-different-languages-1330">sorting
characters in different languages</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Other-Versions.html#index-source-code_002c-_0040command_007bawka_007d-1946">source
code, <samp><span class="command">awka</span></samp></a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="Other-Versions.html#index-source-code_002c-Bell-Laboratories-_0040command_007bawk_007d-1939">source
code, Bell Laboratories <samp><span class="command">awk</span></samp></a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="Gawk-Distribution.html#index-source-code_002c-_0040command_007bgawk_007d-1872">source
code, <samp><span class="command">gawk</span></samp></a>: <a
href="Gawk-Distribution.html#Gawk-Distribution">Gawk Distribution</a></li>
-<li><a
href="Other-Versions.html#index-source-code_002c-_0040command_007bmawk_007d-1942">source
code, <samp><span class="command">mawk</span></samp></a>: <a
href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a href="Options.html#index-source-code_002c-mixing-1550">source code,
mixing</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Igawk-Program.html#index-source-files_0040comma_007b_007d-search-path-for-1821">source
files, search path for</a>: <a href="Igawk-Program.html#Igawk-Program">Igawk
Program</a></li>
-<li><a href="Array-Intro.html#index-sparse-arrays-1085">sparse arrays</a>: <a
href="Array-Intro.html#Array-Intro">Array Intro</a></li>
-<li><a href="Glossary.html#index-Spencer_002c-Henry-2052">Spencer, Henry</a>:
<a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bsplit_007d-function-1176"><code>split</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="Delete.html#index-_0040code_007bsplit_007d-function_002c-array-elements_0040comma_007b_007d-deleting-1114"><code>split</code>
function, array elements, deleting</a>: <a
href="Delete.html#Delete">Delete</a></li>
-<li><a
href="Split-Program.html#index-_0040code_007bsplit_007d-utility-1768"><code>split</code>
utility</a>: <a href="Split-Program.html#Split-Program">Split Program</a></li>
-<li><a
href="Split-Program.html#index-_0040code_007bsplit_002eawk_007d-program-1769"><code>split.awk</code>
program</a>: <a href="Split-Program.html#Split-Program">Split Program</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bsprintf_007d-function-1180"><code>sprintf</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="OFMT.html#index-_0040code_007bsprintf_007d-function-521"><code>sprintf</code>
function</a>: <a href="OFMT.html#OFMT">OFMT</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bsprintf_007d-function_002c-_0040code_007bOFMT_007d-variable-and-1026"><code>sprintf</code>
function, <code>OFMT</code> variable and</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Round-Function.html#index-_0040code_007bsprintf_007d-function_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-and-1635"><code>sprintf</code>
function, <code>print</code>/<code>printf</code> statements and</a>: <a
href="Round-Function.html#Round-Function">Round Function</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007bsqrt_007d-function-1151"><code>sqrt</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a
href="Regexp-Operators.html#index-square-brackets-_0028_0040code_007b_005b_005d_007d_0029-234">square
brackets (<code>[]</code>)</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Numeric-Functions.html#index-_0040code_007bsrand_007d-function-1161"><code>srand</code>
function</a>: <a href="Numeric-Functions.html#Numeric-Functions">Numeric
Functions</a></li>
-<li><a href="Glossary.html#index-Stallman_002c-Richard-2067">Stallman,
Richard</a>: <a href="Glossary.html#Glossary">Glossary</a></li>
-<li><a href="Contributors.html#index-Stallman_002c-Richard-1844">Stallman,
Richard</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Stallman_002c-Richard-44">Stallman,
Richard</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="Manual-History.html#index-Stallman_002c-Richard-34">Stallman,
Richard</a>: <a href="Manual-History.html#Manual-History">Manual
History</a></li>
-<li><a href="Special-FD.html#index-standard-input-568">standard input</a>: <a
href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a href="Read-Terminal.html#index-standard-input-84">standard input</a>:
<a href="Read-Terminal.html#Read-Terminal">Read Terminal</a></li>
-<li><a href="Special-FD.html#index-standard-output-570">standard output</a>:
<a href="Special-FD.html#Special-FD">Special FD</a></li>
-<li><a
href="Sample-Library.html#index-_0040code_007bstat_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2012"><code>stat</code>
function, implementing in <samp><span class="command">gawk</span></samp></a>:
<a href="Sample-Library.html#Sample-Library">Sample Library</a></li>
-<li><a
href="Statements.html#index-statements_002c-compound_0040comma_007b_007d-control-statements-and-943">statements,
compound, control statements and</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Statements.html#index-statements_002c-control_002c-in-actions-940">statements,
control, in actions</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Statements_002fLines.html#index-statements_002c-multiple-162">statements,
multiple</a>: <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a></li>
-<li><a
href="Internals.html#index-_0040code_007bstlen_007d-internal-variable-1984"><code>stlen</code>
internal variable</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007bstptr_007d-internal-variable-1983"><code>stptr</code>
internal variable</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Simple-Sed.html#index-stream-editors-1814">stream editors</a>: <a
href="Simple-Sed.html#Simple-Sed">Simple Sed</a></li>
-<li><a href="Field-Splitting-Summary.html#index-stream-editors-437">stream
editors</a>: <a
href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field Splitting
Summary</a></li>
-<li><a
href="Time-Functions.html#index-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1238"><code>strftime</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a href="Scalar-Constants.html#index-string-constants-607">string
constants</a>: <a href="Scalar-Constants.html#Scalar-Constants">Scalar
Constants</a></li>
-<li><a
href="Computed-Regexps.html#index-string-constants_002c-vs_002e-regexp-constants-338">string
constants, vs. regexp constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="String-Extraction.html#index-string-extraction-_0028internationalization_0029-1366">string
extraction (internationalization)</a>: <a
href="String-Extraction.html#String-Extraction">String Extraction</a></li>
-<li><a href="Concatenation.html#index-string-operators-663">string
operators</a>: <a href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="Regexp-Usage.html#index-string_002dmatching-operators-175">string-matching
operators</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a href="Internals.html#index-strings-1991">strings</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a href="Conversion.html#index-strings_002c-converting-641">strings,
converting</a>: <a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Bitwise-Functions.html#index-strings_002c-converting_002c-numbers-to-1266">strings,
converting, numbers to</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="User_002dmodified.html#index-strings_002c-converting_002c-numbers-to-1002">strings,
converting, numbers to</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Records.html#index-strings_002c-empty_002c-See-null-strings-361">strings,
empty, See null strings</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="String-Extraction.html#index-strings_002c-extracting-1362">strings,
extracting</a>: <a href="String-Extraction.html#String-Extraction">String
Extraction</a></li>
-<li><a
href="Programmer-i18n.html#index-strings_002c-for-localization-1345">strings,
for localization</a>: <a href="Programmer-i18n.html#Programmer-i18n">Programmer
i18n</a></li>
-<li><a href="Scalar-Constants.html#index-strings_002c-length-of-609">strings,
length of</a>: <a href="Scalar-Constants.html#Scalar-Constants">Scalar
Constants</a></li>
-<li><a
href="Join-Function.html#index-strings_002c-merging-arrays-into-1655">strings,
merging arrays into</a>: <a href="Join-Function.html#Join-Function">Join
Function</a></li>
-<li><a
href="Internals.html#index-strings_002c-_0040code_007bNODE_007d-internal-type-1975">strings,
<code>NODE</code> internal type</a>: <a
href="Internals.html#Internals">Internals</a></li>
-<li><a href="Regexp-Field-Splitting.html#index-strings_002c-null-416">strings,
null</a>: <a href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp
Field Splitting</a></li>
-<li><a
href="Typing-and-Comparison.html#index-strings_002c-numeric-746">strings,
numeric</a>: <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing
and Comparison</a></li>
-<li><a href="String-Functions.html#index-strings_002c-splitting-1177">strings,
splitting</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1182"><code>strtonum</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Nondecimal-Data.html#index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-and-1404"><code>strtonum</code>
function (<samp><span class="command">gawk</span></samp>),
<code>--non-decimal-data</code> option and</a>: <a
href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bsub_007d-function-1184"><code>sub</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="Using-Constant-Regexps.html#index-_0040code_007bsub_007d-function-630"><code>sub</code>
function</a>: <a
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bsub_007d-function_002c-arguments-of-1185"><code>sub</code>
function, arguments of</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Gory-Details.html#index-_0040code_007bsub_007d-function_002c-escape-processing-1198"><code>sub</code>
function, escape processing</a>: <a href="Gory-Details.html#Gory-Details">Gory
Details</a></li>
-<li><a href="User_002dmodified.html#index-subscript-separators-1037">subscript
separators</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Multi_002ddimensional.html#index-subscripts-in-arrays_002c-multidimensional-1127">subscripts
in arrays, multidimensional</a>: <a
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a></li>
-<li><a
href="Multi_002dscanning.html#index-subscripts-in-arrays_002c-multidimensional_002c-scanning-1130">subscripts
in arrays, multidimensional, scanning</a>: <a
href="Multi_002dscanning.html#Multi_002dscanning">Multi-scanning</a></li>
-<li><a
href="Numeric-Array-Subscripts.html#index-subscripts-in-arrays_002c-numbers-as-1117">subscripts
in arrays, numbers as</a>: <a
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-subscripts-in-arrays_002c-uninitialized-variables-as-1122">subscripts
in arrays, uninitialized variables as</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bSUBSEP_007d-variable-1035"><code>SUBSEP</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Multi_002ddimensional.html#index-_0040code_007bSUBSEP_007d-variable_002c-multidimensional-arrays-1129"><code>SUBSEP</code>
variable, multidimensional arrays</a>: <a
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007bsubstr_007d-function-1190"><code>substr</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a href="Other-Versions.html#index-Sumner_002c-Andrew-1944">Sumner,
Andrew</a>: <a href="Other-Versions.html#Other-Versions">Other Versions</a></li>
-<li><a
href="Switch-Statement.html#index-_0040code_007bswitch_007d-statement-958"><code>switch</code>
statement</a>: <a href="Switch-Statement.html#Switch-Statement">Switch
Statement</a></li>
-<li><a
href="Assignment-Ops.html#index-syntactic-ambiguity_003a-_0040code_007b_002f_003d_007d-operator-vs_002e-_0040code_007b_002f_003d_0040dots_007b_007d_002f_007d-regexp-constant-709">syntactic
ambiguity: <code>/=</code> operator vs. <code>/=.../</code> regexp
constant</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="I_002fO-Functions.html#index-_0040code_007bsystem_007d-function-1219"><code>system</code>
function</a>: <a href="I_002fO-Functions.html#I_002fO-Functions">I/O
Functions</a></li>
-<li><a
href="Time-Functions.html#index-_0040code_007bsystime_007d-function-_0028_0040command_007bgawk_007d_0029-1235"><code>systime</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a href="Tandem-Installation.html#index-tandem-1919">tandem</a>: <a
href="Tandem-Installation.html#Tandem-Installation">Tandem Installation</a></li>
-<li><a href="Library-Names.html#index-Tcl-1612">Tcl</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a href="TCP_002fIP-Networking.html#index-TCP_002fIP-1421">TCP/IP</a>: <a
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a></li>
-<li><a
href="Special-Network.html#index-TCP_002fIP_002c-support-for-584">TCP/IP,
support for</a>: <a href="Special-Network.html#Special-Network">Special
Network</a></li>
-<li><a
href="Tee-Program.html#index-_0040code_007btee_007d-utility-1772"><code>tee</code>
utility</a>: <a href="Tee-Program.html#Tee-Program">Tee Program</a></li>
-<li><a
href="Tee-Program.html#index-_0040code_007btee_002eawk_007d-program-1774"><code>tee.awk</code>
program</a>: <a href="Tee-Program.html#Tee-Program">Tee Program</a></li>
-<li><a href="Records.html#index-terminating-records-364">terminating
records</a>: <a href="Records.html#Records">Records</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007btestbits_002eawk_007d-program-1264"><code>testbits.awk</code>
program</a>: <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise
Functions</a></li>
-<li><a href="Adding-Code.html#index-Texinfo-1959">Texinfo</a>: <a
href="Adding-Code.html#Adding-Code">Adding Code</a></li>
-<li><a href="Distribution-contents.html#index-Texinfo-1878">Texinfo</a>: <a
href="Distribution-contents.html#Distribution-contents">Distribution
contents</a></li>
-<li><a href="Extract-Program.html#index-Texinfo-1811">Texinfo</a>: <a
href="Extract-Program.html#Extract-Program">Extract Program</a></li>
-<li><a href="Dupword-Program.html#index-Texinfo-1789">Texinfo</a>: <a
href="Dupword-Program.html#Dupword-Program">Dupword Program</a></li>
-<li><a href="Library-Functions.html#index-Texinfo-1593">Texinfo</a>: <a
href="Library-Functions.html#Library-Functions">Library Functions</a></li>
-<li><a href="Conventions.html#index-Texinfo-28">Texinfo</a>: <a
href="Conventions.html#Conventions">Conventions</a></li>
-<li><a
href="Regexp-Operators.html#index-Texinfo_002c-chapter-beginnings-in-files-225">Texinfo,
chapter beginnings in files</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Extract-Program.html#index-Texinfo_002c-extracting-programs-from-source-files-1809">Texinfo,
extracting programs from source files</a>: <a
href="Extract-Program.html#Extract-Program">Extract Program</a></li>
-<li><a href="Print.html#index-text_002c-printing-504">text, printing</a>: <a
href="Print.html#Print">Print</a></li>
-<li><a
href="Uniq-Program.html#index-text_0040comma_007b_007d-printing_002c-unduplicated-lines-of-1776">text,
printing, unduplicated lines of</a>: <a
href="Uniq-Program.html#Uniq-Program">Uniq Program</a></li>
-<li><a
href="Explaining-gettext.html#index-_0040code_007btextdomain_007d-function-_0028C-library_0029-1309"><code>textdomain</code>
function (C library)</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bTEXTDOMAIN_007d-variable-1343"><code>TEXTDOMAIN</code>
variable</a>: <a href="Programmer-i18n.html#Programmer-i18n">Programmer
i18n</a></li>
-<li><a
href="User_002dmodified.html#index-_0040code_007bTEXTDOMAIN_007d-variable-1038"><code>TEXTDOMAIN</code>
variable</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Programmer-i18n.html#index-_0040code_007bTEXTDOMAIN_007d-variable_002c-_0040code_007bBEGIN_007d-pattern-and-1354"><code>TEXTDOMAIN</code>
variable, <code>BEGIN</code> pattern and</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a
href="I18N-Portability.html#index-_0040code_007bTEXTDOMAIN_007d-variable_002c-portability-and-1378"><code>TEXTDOMAIN</code>
variable, portability and</a>: <a
href="I18N-Portability.html#I18N-Portability">I18N Portability</a></li>
-<li><a
href="Expression-Patterns.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-896">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Precedence.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-861">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-761">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Regexp-Constants.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-621">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Regexp-Constants.html#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="Computed-Regexps.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-328">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Case_002dsensitivity.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-320">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
-<li><a
href="Regexp-Usage.html#index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-176">tilde
(<code>~</code>), <code>~</code> operator</a>: <a
href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Alarm-Program.html#index-time_002c-alarm-clock-example-program-1793">time,
alarm clock example program</a>: <a
href="Alarm-Program.html#Alarm-Program">Alarm Program</a></li>
-<li><a
href="Explaining-gettext.html#index-time_002c-localization-and-1338">time,
localization and</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a href="Gettimeofday-Function.html#index-time_002c-managing-1661">time,
managing</a>: <a
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a href="Time-Functions.html#index-time_002c-retrieving-1234">time,
retrieving</a>: <a href="Time-Functions.html#Time-Functions">Time
Functions</a></li>
-<li><a href="Time-Functions.html#index-timestamps-1228">timestamps</a>: <a
href="Time-Functions.html#Time-Functions">Time Functions</a></li>
-<li><a
href="Time-Functions.html#index-timestamps_002c-converting-dates-to-1241">timestamps,
converting dates to</a>: <a href="Time-Functions.html#Time-Functions">Time
Functions</a></li>
-<li><a
href="Gettimeofday-Function.html#index-timestamps_002c-formatted-1660">timestamps,
formatted</a>: <a
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a></li>
-<li><a
href="Internals.html#index-_0040code_007btmp_005fnumber_007d-internal-function-1996"><code>tmp_number</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Internals.html#index-_0040code_007btmp_005fstring_007d-internal-function-1995"><code>tmp_string</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007btolower_007d-function-1195"><code>tolower</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="String-Functions.html#index-_0040code_007btoupper_007d-function-1196"><code>toupper</code>
function</a>: <a href="String-Functions.html#String-Functions">String
Functions</a></li>
-<li><a
href="Translate-Program.html#index-_0040command_007btr_007d-utility-1798"><samp><span
class="command">tr</span></samp> utility</a>: <a
href="Translate-Program.html#Translate-Program">Translate Program</a></li>
-<li><a
href="Translate-Program.html#index-_0040code_007btranslate_002eawk_007d-program-1799"><code>translate.awk</code>
program</a>: <a href="Translate-Program.html#Translate-Program">Translate
Program</a></li>
-<li><a
href="Options.html#index-troubleshooting_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1526">troubleshooting,
<code>--non-decimal-data</code> option</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Known-Bugs.html#index-troubleshooting_002c-_0040code_007b_002dF_007d-option-1587">troubleshooting,
<code>-F</code> option</a>: <a href="Known-Bugs.html#Known-Bugs">Known
Bugs</a></li>
-<li><a
href="Typing-and-Comparison.html#index-troubleshooting_002c-_0040code_007b_003d_003d_007d-operator-765">troubleshooting,
<code>==</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Field-Separators.html#index-troubleshooting_002c-_0040command_007bawk_007d-uses-_0040code_007bFS_007d-not-_0040code_007bIFS_007d-405">troubleshooting,
<samp><span class="command">awk</span></samp> uses <code>FS</code> not
<code>IFS</code></a>: <a href="Field-Separators.html#Field-Separators">Field
Separators</a></li>
-<li><a
href="Escape-Sequences.html#index-troubleshooting_002c-backslash-before-nonspecial-character-216">troubleshooting,
backslash before nonspecial character</a>: <a
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a></li>
-<li><a
href="Arithmetic-Ops.html#index-troubleshooting_002c-division-655">troubleshooting,
division</a>: <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic
Ops</a></li>
-<li><a
href="Constant-Size.html#index-troubleshooting_002c-fatal-errors_002c-field-widths_0040comma_007b_007d-specifying-441">troubleshooting,
fatal errors, field widths, specifying</a>: <a
href="Constant-Size.html#Constant-Size">Constant Size</a></li>
-<li><a
href="Format-Modifiers.html#index-troubleshooting_002c-fatal-errors_002c-_0040code_007bprintf_007d-format-strings-542">troubleshooting,
fatal errors, <code>printf</code> format strings</a>: <a
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a></li>
-<li><a
href="I_002fO-Functions.html#index-troubleshooting_002c-_0040code_007bfflush_007d-function-1218">troubleshooting,
<code>fflush</code> function</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="Function-Calls.html#index-troubleshooting_002c-function-call-syntax-807">troubleshooting,
function call syntax</a>: <a
href="Function-Calls.html#Function-Calls">Function Calls</a></li>
-<li><a
href="Compatibility-Mode.html#index-troubleshooting_002c-_0040command_007bgawk_007d-1953">troubleshooting,
<samp><span class="command">gawk</span></samp></a>: <a
href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a></li>
-<li><a
href="Known-Bugs.html#index-troubleshooting_002c-_0040command_007bgawk_007d-1586">troubleshooting,
<samp><span class="command">gawk</span></samp></a>: <a
href="Known-Bugs.html#Known-Bugs">Known Bugs</a></li>
-<li><a
href="Bugs.html#index-troubleshooting_002c-_0040command_007bgawk_007d_002c-bug-reports-1923">troubleshooting,
<samp><span class="command">gawk</span></samp>, bug reports</a>: <a
href="Bugs.html#Bugs">Bugs</a></li>
-<li><a
href="Calling-Built_002din.html#index-troubleshooting_002c-_0040command_007bgawk_007d_002c-fatal-errors_0040comma_007b_007d-function-arguments-1144">troubleshooting,
<samp><span class="command">gawk</span></samp>, fatal errors, function
arguments</a>: <a href="Calling-Built_002din.html#Calling-Built_002din">Calling
Built-in</a></li>
-<li><a
href="File-Checking.html#index-troubleshooting_002c-_0040code_007bgetline_007d-function-1676">troubleshooting,
<code>getline</code> function</a>: <a
href="File-Checking.html#File-Checking">File Checking</a></li>
-<li><a
href="String-Functions.html#index-troubleshooting_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-functions-1187">troubleshooting,
<code>gsub</code>/<code>sub</code> functions</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="String-Functions.html#index-troubleshooting_002c-_0040code_007bmatch_007d-function-1175">troubleshooting,
<code>match</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="Print-Examples.html#index-troubleshooting_002c-_0040code_007bprint_007d-statement_0040comma_007b_007d-omitting-commas-508">troubleshooting,
<code>print</code> statement, omitting commas</a>: <a
href="Print-Examples.html#Print-Examples">Print Examples</a></li>
-<li><a
href="Redirection.html#index-troubleshooting_002c-printing-560">troubleshooting,
printing</a>: <a href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Special-FD.html#index-troubleshooting_002c-quotes-with-_0040value_007bFN_007ds-580">troubleshooting,
quotes with file names</a>: <a href="Special-FD.html#Special-FD">Special
FD</a></li>
-<li><a
href="File-Checking.html#index-troubleshooting_002c-readable-_0040value_007bDF_007ds-1672">troubleshooting,
readable data files</a>: <a href="File-Checking.html#File-Checking">File
Checking</a></li>
-<li><a
href="Computed-Regexps.html#index-troubleshooting_002c-regexp-constants-vs_002e-string-constants-336">troubleshooting,
regexp constants vs. string constants</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Concatenation.html#index-troubleshooting_002c-string-concatenation-666">troubleshooting,
string concatenation</a>: <a
href="Concatenation.html#Concatenation">Concatenation</a></li>
-<li><a
href="String-Functions.html#index-troubleshooting_002c-_0040code_007bsubstr_007d-function-1191">troubleshooting,
<code>substr</code> function</a>: <a
href="String-Functions.html#String-Functions">String Functions</a></li>
-<li><a
href="I_002fO-Functions.html#index-troubleshooting_002c-_0040code_007bsystem_007d-function-1221">troubleshooting,
<code>system</code> function</a>: <a
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a></li>
-<li><a
href="Options.html#index-troubleshooting_002c-typographical-errors_0040comma_007b_007d-global-variables-1510">troubleshooting,
typographical errors, global variables</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a href="Truth-Values.html#index-true_002c-logical-734">true, logical</a>:
<a href="Truth-Values.html#Truth-Values">Truth Values</a></li>
-<li><a href="Contributors.html#index-Trueman_002c-David-1846">Trueman,
David</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Acknowledgments.html#index-Trueman_002c-David-52">Trueman,
David</a>: <a
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a href="History.html#index-Trueman_002c-David-19">Trueman, David</a>: <a
href="History.html#History">History</a></li>
-<li><a href="Arithmetic-Ops.html#index-trunc_002dmod-operation-658">trunc-mod
operation</a>: <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic
Ops</a></li>
-<li><a href="Truth-Values.html#index-truth-values-731">truth values</a>: <a
href="Truth-Values.html#Truth-Values">Truth Values</a></li>
-<li><a href="Conversion.html#index-type-conversion-645">type conversion</a>:
<a href="Conversion.html#Conversion">Conversion</a></li>
-<li><a
href="Internals.html#index-_0040code_007btype_007d-internal-variable-1985"><code>type</code>
internal variable</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a href="Function-Caveats.html#index-undefined-functions-1294">undefined
functions</a>: <a href="Function-Caveats.html#Function-Caveats">Function
Caveats</a></li>
-<li><a
href="Explaining-gettext.html#index-underscore-_0028_0040code_007b_005f_007d_0029_002c-_0040code_007b_005f_007d-C-macro-1325">underscore
(<code>_</code>), <code>_</code> C macro</a>: <a
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a></li>
-<li><a
href="Library-Names.html#index-underscore-_0028_0040code_007b_005f_007d_0029_002c-in-names-of-private-variables-1607">underscore
(<code>_</code>), in names of private variables</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Programmer-i18n.html#index-underscore-_0028_0040code_007b_005f_007d_0029_002c-translatable-string-1356">underscore
(<code>_</code>), translatable string</a>: <a
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a></li>
-<li><a href="Undocumented.html#index-undocumented-features-1578">undocumented
features</a>: <a href="Undocumented.html#Undocumented">Undocumented</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-uninitialized-variables_002c-as-array-subscripts-1121">uninitialized
variables, as array subscripts</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="Uniq-Program.html#index-_0040command_007buniq_007d-utility-1777"><samp><span
class="command">uniq</span></samp> utility</a>: <a
href="Uniq-Program.html#Uniq-Program">Uniq Program</a></li>
-<li><a
href="Uniq-Program.html#index-_0040code_007buniq_002eawk_007d-program-1778"><code>uniq.awk</code>
program</a>: <a href="Uniq-Program.html#Uniq-Program">Uniq Program</a></li>
-<li><a href="Glossary.html#index-Unix-2082">Unix</a>: <a
href="Glossary.html#Glossary">Glossary</a></li>
-<li><a
href="Escape-Sequences.html#index-Unix-_0040command_007bawk_007d_002c-backslashes-in-escape-sequences-218">Unix
<samp><span class="command">awk</span></samp>, backslashes in escape
sequences</a>: <a href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-Unix-_0040command_007bawk_007d_002c-_0040code_007bclose_007d-function-and-603">Unix
<samp><span class="command">awk</span></samp>, <code>close</code> function
and</a>: <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files
And Pipes</a></li>
-<li><a
href="Command-Line-Field-Separator.html#index-Unix-_0040command_007bawk_007d_002c-password-files_0040comma_007b_007d-field-separators-and-431">Unix
<samp><span class="command">awk</span></samp>, password files, field
separators and</a>: <a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a></li>
-<li><a
href="Executable-Scripts.html#index-Unix_002c-_0040command_007bawk_007d-scripts-and-107">Unix,
<samp><span class="command">awk</span></samp> scripts and</a>: <a
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a></li>
-<li><a href="Basic-Data-Typing.html#index-unsigned-integers-2041">unsigned
integers</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a
href="Internals.html#index-_0040code_007bupdate_005fERRNO_007d-internal-function-2010"><code>update_ERRNO</code>
internal function</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Passwd-Functions.html#index-user-database_0040comma_007b_007d-reading-1692">user
database, reading</a>: <a href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a></li>
-<li><a
href="User_002ddefined.html#index-user_002ddefined_002c-functions-1275">user-defined,
functions</a>: <a
href="User_002ddefined.html#User_002ddefined">User-defined</a></li>
-<li><a
href="Profiling.html#index-user_002ddefined_002c-functions_002c-counts-1451">user-defined,
functions, counts</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Variables.html#index-user_002ddefined_002c-variables-633">user-defined,
variables</a>: <a href="Variables.html#Variables">Variables</a></li>
-<li><a
href="User_002dmodified.html#index-user_002dmodifiable-variables-994">user-modifiable
variables</a>: <a
href="User_002dmodified.html#User_002dmodified">User-modified</a></li>
-<li><a
href="Id-Program.html#index-users_002c-information-about_002c-printing-1763">users,
information about, printing</a>: <a href="Id-Program.html#Id-Program">Id
Program</a></li>
-<li><a
href="Passwd-Functions.html#index-users_002c-information-about_002c-retrieving-1697">users,
information about, retrieving</a>: <a
href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a></li>
-<li><a
href="Profiling.html#index-_0040code_007bUSR1_007d-signal-1459"><code>USR1</code>
signal</a>: <a href="Profiling.html#Profiling">Profiling</a></li>
-<li><a href="Basic-Data-Typing.html#index-values_002c-numeric-2035">values,
numeric</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a href="Basic-Data-Typing.html#index-values_002c-string-2036">values,
string</a>: <a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data
Typing</a></li>
-<li><a href="Typing-and-Comparison.html#index-variable-typing-743">variable
typing</a>: <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing
and Comparison</a></li>
-<li><a href="Basic-Data-Typing.html#index-variables-2034">variables</a>: <a
href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data Typing</a></li>
-<li><a href="Other-Features.html#index-variables-165">variables</a>: <a
href="Other-Features.html#Other-Features">Other Features</a></li>
-<li><a
href="Assignment-Options.html#index-variables_002c-assigning-on-command-line-636">variables,
assigning on command line</a>: <a
href="Assignment-Options.html#Assignment-Options">Assignment Options</a></li>
-<li><a
href="Built_002din-Variables.html#index-variables_002c-built_002din-991">variables,
built-in</a>: <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a></li>
-<li><a
href="Using-Variables.html#index-variables_002c-built_002din-634">variables,
built-in</a>: <a href="Using-Variables.html#Using-Variables">Using
Variables</a></li>
-<li><a
href="Options.html#index-variables_002c-built_002din_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1492">variables,
built-in, <code>-v</code> option, setting with</a>: <a
href="Options.html#Options">Options</a></li>
-<li><a
href="Auto_002dset.html#index-variables_002c-built_002din_002c-conveying-information-1042">variables,
built-in, conveying information</a>: <a
href="Auto_002dset.html#Auto_002dset">Auto-set</a></li>
-<li><a href="Boolean-Ops.html#index-variables_002c-flag-794">variables,
flag</a>: <a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Getline_002fVariable_002fCoprocess.html#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-487">variables,
<code>getline</code> command into, using</a>: <a
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a></li>
-<li><a
href="Getline_002fVariable_002fPipe.html#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-480">variables,
<code>getline</code> command into, using</a>: <a
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a></li>
-<li><a
href="Getline_002fVariable_002fFile.html#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-468">variables,
<code>getline</code> command into, using</a>: <a
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">Getline/Variable/File</a></li>
-<li><a
href="Getline_002fVariable.html#index-variables_002c-_0040code_007bgetline_007d-command-into_0040comma_007b_007d-using-461">variables,
<code>getline</code> command into, using</a>: <a
href="Getline_002fVariable.html#Getline_002fVariable">Getline/Variable</a></li>
-<li><a
href="Library-Names.html#index-variables_002c-global_002c-for-library-functions-1602">variables,
global, for library functions</a>: <a
href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a
href="Options.html#index-variables_002c-global_002c-printing-list-of-1509">variables,
global, printing list of</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Using-Variables.html#index-variables_002c-initializing-635">variables,
initializing</a>: <a href="Using-Variables.html#Using-Variables">Using
Variables</a></li>
-<li><a href="Arrays.html#index-variables_002c-names-of-1076">variables, names
of</a>: <a href="Arrays.html#Arrays">Arrays</a></li>
-<li><a href="Library-Names.html#index-variables_002c-private-1604">variables,
private</a>: <a href="Library-Names.html#Library-Names">Library Names</a></li>
-<li><a href="Options.html#index-variables_002c-setting-1490">variables,
setting</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Definition-Syntax.html#index-variables_002c-shadowing-1282">variables,
shadowing</a>: <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a></li>
-<li><a href="Assignment-Ops.html#index-variables_002c-types-of-680">variables,
types of</a>: <a href="Assignment-Ops.html#Assignment-Ops">Assignment
Ops</a></li>
-<li><a
href="Typing-and-Comparison.html#index-variables_002c-types-of_002c-comparison-expressions-and-744">variables,
types of, comparison expressions and</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Uninitialized-Subscripts.html#index-variables_002c-uninitialized_0040comma_007b_007d-as-array-subscripts-1120">variables,
uninitialized, as array subscripts</a>: <a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a></li>
-<li><a
href="Variables.html#index-variables_002c-user_002ddefined-632">variables,
user-defined</a>: <a href="Variables.html#Variables">Variables</a></li>
-<li><a
href="Regexp-Operators.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029-240">vertical
bar (<code>|</code>)</a>: <a
href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a></li>
-<li><a
href="Precedence.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-853">vertical
bar (<code>|</code>), <code>|</code> operator (I/O)</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Getline_002fPipe.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-471">vertical
bar (<code>|</code>), <code>|</code> operator (I/O)</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-I_002fO-operator-_0028I_002fO_0029-1412">vertical
bar (<code>|</code>), <code>|&</code> I/O operator (I/O)</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Precedence.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-856">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O)</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Getline_002fCoprocess.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-484">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O)</a>: <a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="Portal-Files.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1437">vertical
bar (<code>|</code>), <code>|&</code> operator (I/O), two-way
communications</a>: <a href="Portal-Files.html#Portal-Files">Portal
Files</a></li>
-<li><a
href="Precedence.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-868">vertical
bar (<code>|</code>), <code>||</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Boolean-Ops.html#index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-789">vertical
bar (<code>|</code>), <code>||</code> operator</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Internals.html#index-_0040code_007bvname_007d-internal-variable-1986"><code>vname</code>
internal variable</a>: <a href="Internals.html#Internals">Internals</a></li>
-<li><a
href="Constant-Size.html#index-_0040command_007bw_007d-utility-442"><samp><span
class="command">w</span></samp> utility</a>: <a
href="Constant-Size.html#Constant-Size">Constant Size</a></li>
-<li><a href="Future-Extensions.html#index-Wall_002c-Larry-2020">Wall,
Larry</a>: <a href="Future-Extensions.html#Future-Extensions">Future
Extensions</a></li>
-<li><a href="Options.html#index-warnings_002c-issuing-1521">warnings,
issuing</a>: <a href="Options.html#Options">Options</a></li>
-<li><a
href="Wc-Program.html#index-_0040command_007bwc_007d-utility-1784"><samp><span
class="command">wc</span></samp> utility</a>: <a
href="Wc-Program.html#Wc-Program">Wc Program</a></li>
-<li><a
href="Wc-Program.html#index-_0040code_007bwc_002eawk_007d-program-1785"><code>wc.awk</code>
program</a>: <a href="Wc-Program.html#Wc-Program">Wc Program</a></li>
-<li><a href="Contributors.html#index-Weinberger_002c-Peter-1839">Weinberger,
Peter</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="History.html#index-Weinberger_002c-Peter-14">Weinberger,
Peter</a>: <a href="History.html#History">History</a></li>
-<li><a
href="While-Statement.html#index-_0040code_007bwhile_007d-statement-951"><code>while</code>
statement</a>: <a href="While-Statement.html#While-Statement">While
Statement</a></li>
-<li><a
href="Regexp-Usage.html#index-_0040code_007bwhile_007d-statement-180"><code>while</code>
statement</a>: <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a></li>
-<li><a
href="Field-Separators.html#index-whitespace_002c-as-field-separators-412">whitespace,
as field separators</a>: <a
href="Field-Separators.html#Field-Separators">Field Separators</a></li>
-<li><a
href="Calling-Built_002din.html#index-whitespace_002c-functions_0040comma_007b_007d-calling-1143">whitespace,
functions, calling</a>: <a
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a></li>
-<li><a href="Options.html#index-whitespace_002c-newlines-as-1532">whitespace,
newlines as</a>: <a href="Options.html#Options">Options</a></li>
-<li><a href="Contributors.html#index-Williams_002c-Kent-1850">Williams,
Kent</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a href="Contributors.html#index-Woods_002c-John-1845">Woods, John</a>: <a
href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-word-boundaries_0040comma_007b_007d-matching-295">word
boundaries, matching</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-word_002c-regexp-definition-of-284">word,
regexp definition of</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="GNU-Regexp-Operators.html#index-word_002dboundary-operator-_0028_0040command_007bgawk_007d_0029-310">word-boundary
operator (<samp><span class="command">gawk</span></samp>)</a>: <a
href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a></li>
-<li><a
href="Word-Sorting.html#index-_0040code_007bwordfreq_002eawk_007d-program-1805"><code>wordfreq.awk</code>
program</a>: <a href="Word-Sorting.html#Word-Sorting">Word Sorting</a></li>
-<li><a href="Wc-Program.html#index-words_002c-counting-1781">words,
counting</a>: <a href="Wc-Program.html#Wc-Program">Wc Program</a></li>
-<li><a
href="Dupword-Program.html#index-words_002c-duplicate_0040comma_007b_007d-searching-for-1786">words,
duplicate, searching for</a>: <a
href="Dupword-Program.html#Dupword-Program">Dupword Program</a></li>
-<li><a
href="Word-Sorting.html#index-words_002c-usage-counts_0040comma_007b_007d-generating-1803">words,
usage counts, generating</a>: <a href="Word-Sorting.html#Word-Sorting">Word
Sorting</a></li>
-<li><a
href="String-Extraction.html#index-_0040code_007bxgettext_007d-utility-1370"><code>xgettext</code>
utility</a>: <a href="String-Extraction.html#String-Extraction">String
Extraction</a></li>
-<li><a href="Bitwise-Functions.html#index-XOR-bitwise-operation-1248">XOR
bitwise operation</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a
href="Bitwise-Functions.html#index-_0040code_007bxor_007d-function-_0028_0040command_007bgawk_007d_0029-1259"><code>xor</code>
function (<samp><span class="command">gawk</span></samp>)</a>: <a
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a></li>
-<li><a href="Acknowledgments.html#index-Zaretskii_002c-Eli-66">Zaretskii,
Eli</a>: <a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a></li>
-<li><a
href="Floating-Point-Issues.html#index-zero_0040comma_007b_007d-negative-vs_002e_0040_003a-positive-2051">zero,
negative vs. positive</a>: <a
href="Floating-Point-Issues.html#Floating-Point-Issues">Floating Point
Issues</a></li>
-<li><a
href="Empty-Files.html#index-_0040code_007bzerofile_002eawk_007d-program-1677"><code>zerofile.awk</code>
program</a>: <a href="Empty-Files.html#Empty-Files">Empty Files</a></li>
-<li><a href="Contributors.html#index-Zoulas_002c-Christos-1858">Zoulas,
Christos</a>: <a href="Contributors.html#Contributors">Contributors</a></li>
-<li><a
href="Action-Overview.html#index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-actions-and-932"><code>{}</code>
(braces), actions and</a>: <a
href="Action-Overview.html#Action-Overview">Action Overview</a></li>
-<li><a
href="Profiling.html#index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-_0040command_007bpgawk_007d-program-1452"><code>{}</code>
(braces), <samp><span class="command">pgawk</span></samp> program</a>: <a
href="Profiling.html#Profiling">Profiling</a></li>
-<li><a
href="Statements.html#index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-statements_002c-grouping-945"><code>{}</code>
(braces), statements, grouping</a>: <a
href="Statements.html#Statements">Statements</a></li>
-<li><a
href="Regexp-Operators.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029-239"><code>|</code>
(vertical bar)</a>: <a href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-852"><code>|</code>
(vertical bar), <code>|</code> operator (I/O)</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Redirection.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-553"><code>|</code>
(vertical bar), <code>|</code> operator (I/O)</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Getline_002fPipe.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-470"><code>|</code>
(vertical bar), <code>|</code> operator (I/O)</a>: <a
href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a></li>
-<li><a
href="Two_002dway-I_002fO.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-1411"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-855"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Redirection.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-557"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="Redirection.html#Redirection">Redirection</a></li>
-<li><a
href="Getline_002fCoprocess.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-483"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O)</a>: <a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a></li>
-<li><a
href="Close-Files-And-Pipes.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-pipes_0040comma_007b_007d-closing-597"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O), pipes, closing</a>: <a
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a></li>
-<li><a
href="Portal-Files.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1436"><code>|</code>
(vertical bar), <code>|&</code> operator (I/O), two-way
communications</a>: <a href="Portal-Files.html#Portal-Files">Portal
Files</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-867"><code>|</code>
(vertical bar), <code>||</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Boolean-Ops.html#index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-788"><code>|</code>
(vertical bar), <code>||</code> operator</a>: <a
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a></li>
-<li><a
href="Expression-Patterns.html#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-895"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a></li>
-<li><a
href="Precedence.html#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-860"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="Precedence.html#Precedence">Precedence</a></li>
-<li><a
href="Typing-and-Comparison.html#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-760"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a></li>
-<li><a
href="Regexp-Constants.html#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-620"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="Regexp-Constants.html#Regexp-Constants">Regexp Constants</a></li>
-<li><a
href="Computed-Regexps.html#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-327"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a></li>
-<li><a
href="Case_002dsensitivity.html#index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-319"><code>~</code>
(tilde), <code>~</code> operator</a>: <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a></li>
- </ul></body></html>
-
Index: manual/html_node/Installation.html
===================================================================
RCS file: manual/html_node/Installation.html
diff -N manual/html_node/Installation.html
--- manual/html_node/Installation.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-<html lang="en">
-<head>
-<title>Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Language-History.html#Language-History" title="Language
History">
-<link rel="next" href="Notes.html#Notes" title="Notes">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Installation"></a>Next: <a rel="next" accesskey="n"
href="Notes.html#Notes">Notes</a>,
-Previous: <a rel="previous" accesskey="p"
href="Language-History.html#Language-History">Language History</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="appendix">Appendix B Installing <samp><span
class="command">gawk</span></samp></h2>
-
-<!-- last two commas are part of see also -->
-<p><a
name="index-operating-systems_002c-See-Also-GNU_002fLinux_002c-PC-operating-systems_002c-Unix-1869"></a><!--
STARTOFRANGE gligawk -->
-<a name="index-_0040command_007bgawk_007d_002c-installing-1870"></a><!--
STARTOFRANGE ingawk -->
-<a name="index-installing-_0040command_007bgawk_007d-1871"></a>This appendix
provides instructions for installing <samp><span
class="command">gawk</span></samp> on the
-various platforms that are supported by the developers. The primary
-developer supports GNU/Linux (and Unix), whereas the other ports are
-contributed.
-See <a href="Bugs.html#Bugs">Bugs</a>,
-for the electronic mail addresses of the people who did
-the respective ports.
-
-<ul class="menu">
-<li><a accesskey="1" href="Gawk-Distribution.html#Gawk-Distribution">Gawk
Distribution</a>: What is in the <samp><span
class="command">gawk</span></samp> distribution.
-<li><a accesskey="2" href="Unix-Installation.html#Unix-Installation">Unix
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> under various
- versions of Unix.
-<li><a accesskey="3"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>: Installation on Other Operating Systems.
-<li><a accesskey="4" href="Unsupported.html#Unsupported">Unsupported</a>:
Systems whose ports are no longer supported.
-<li><a accesskey="5" href="Bugs.html#Bugs">Bugs</a>:
Reporting Problems and Bugs.
-<li><a accesskey="6" href="Other-Versions.html#Other-Versions">Other
Versions</a>: Other freely available <samp><span
class="command">awk</span></samp>
- implementations.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Internal-File-Description.html
===================================================================
RCS file: manual/html_node/Internal-File-Description.html
diff -N manual/html_node/Internal-File-Description.html
--- manual/html_node/Internal-File-Description.html 7 Feb 2007 02:36:56
-0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,159 +0,0 @@
-<html lang="en">
-<head>
-<title>Internal File Description - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Sample-Library.html#Sample-Library" title="Sample
Library">
-<link rel="next" href="Internal-File-Ops.html#Internal-File-Ops"
title="Internal File Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Internal-File-Description"></a>Next: <a rel="next" accesskey="n"
href="Internal-File-Ops.html#Internal-File-Ops">Internal File Ops</a>,
-Up: <a rel="up" accesskey="u"
href="Sample-Library.html#Sample-Library">Sample Library</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">C.3.2.1 Using <code>chdir</code> and
<code>stat</code></h5>
-
-<p>This section shows how to use the new functions at the <samp><span
class="command">awk</span></samp>
-level once they've been integrated into the running <samp><span
class="command">gawk</span></samp>
-interpreter.
-Using <code>chdir</code> is very straightforward. It takes one argument,
-the new directory to change to:
-
-<pre class="example"> ...
- newdir = "/home/arnold/funstuff"
- ret = chdir(newdir)
- if (ret < 0) {
- printf("could not change to %s: %s\n",
- newdir, ERRNO) > "/dev/stderr"
- exit 1
- }
- ...
-</pre>
- <p>The return value is negative if the <code>chdir</code> failed,
-and <code>ERRNO</code>
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>)
-is set to a string indicating the error.
-
- <p>Using <code>stat</code> is a bit more complicated.
-The C <code>stat</code> function fills in a structure that has a fair
-amount of information.
-The right way to model this in <samp><span class="command">awk</span></samp>
is to fill in an associative
-array with the appropriate information:
-
-<!-- broke printf for page breaking -->
-<pre class="example"> file = "/home/arnold/.profile"
- fdata[1] = "x" # force `fdata' to be an array
- ret = stat(file, fdata)
- if (ret < 0) {
- printf("could not stat %s: %s\n",
- file, ERRNO) > "/dev/stderr"
- exit 1
- }
- printf("size of %s is %d bytes\n", file, fdata["size"])
-</pre>
- <p>The <code>stat</code> function always clears the data array, even if
-the <code>stat</code> fails. It fills in the following elements:
-
- <dl>
-<dt><code>"name"</code><dd>The name of the file that was <code>stat</code>'ed.
-
- <br><dt><code>"dev"</code><dt><code>"ino"</code><dd>The file's device and
inode numbers, respectively.
-
- <br><dt><code>"mode"</code><dd>The file's mode, as a numeric value. This
includes both the file's
-type and its permissions.
-
- <br><dt><code>"nlink"</code><dd>The number of hard links (directory
entries) the file has.
-
- <br><dt><code>"uid"</code><dt><code>"gid"</code><dd>The numeric user and
group ID numbers of the file's owner.
-
- <br><dt><code>"size"</code><dd>The size in bytes of the file.
-
- <br><dt><code>"blocks"</code><dd>The number of disk blocks the file
actually occupies. This may not
-be a function of the file's size if the file has holes.
-
-
<br><dt><code>"atime"</code><dt><code>"mtime"</code><dt><code>"ctime"</code><dd>The
file's last access, modification, and inode update times,
-respectively. These are numeric timestamps, suitable for formatting
-with <code>strftime</code>
-(see <a href="Built_002din.html#Built_002din">Built-in</a>).
-
- <br><dt><code>"pmode"</code><dd>The file's “printable mode.”
This is a string representation of
-the file's type and permissions, such as what is produced by
-`<samp><span class="samp">ls -l</span></samp>'—for example,
<code>"drwxr-xr-x"</code>.
-
- <br><dt><code>"type"</code><dd>A printable string representation of the
file's type. The value
-is one of the following:
-
- <dl>
-<dt><code>"blockdev"</code><dt><code>"chardev"</code><dd>The file is a block
or character device (“special file”).
-
- <br><dt><code>"directory"</code><dd>The file is a directory.
-
- <br><dt><code>"fifo"</code><dd>The file is a named-pipe (also known
as a FIFO).
-
- <br><dt><code>"file"</code><dd>The file is just a regular file.
-
- <br><dt><code>"socket"</code><dd>The file is an <code>AF_Unix</code>
(“Unix domain”) socket in the
-filesystem.
-
- <br><dt><code>"symlink"</code><dd>The file is a symbolic link.
-</dl>
- </dl>
-
- <p>Several additional elements may be present depending upon the operating
-system and the type of the file. You can test for them in your <samp><span
class="command">awk</span></samp>
-program by using the <code>in</code> operator
-(see <a href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>):
-
- <dl>
-<dt><code>"blksize"</code><dd>The preferred block size for I/O to the file.
This field is not
-present on all POSIX-like systems in the C <code>stat</code> structure.
-
- <br><dt><code>"linkval"</code><dd>If the file is a symbolic link, this
element is the name of the
-file the link points to (i.e., the value of the link).
-
-
<br><dt><code>"rdev"</code><dt><code>"major"</code><dt><code>"minor"</code><dd>If
the file is a block or character device file, then these values
-represent the numeric device number and the major and minor components
-of that number, respectively.
-</dl>
-
- </body></html>
-
Index: manual/html_node/Internal-File-Ops.html
===================================================================
RCS file: manual/html_node/Internal-File-Ops.html
diff -N manual/html_node/Internal-File-Ops.html
--- manual/html_node/Internal-File-Ops.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,230 +0,0 @@
-<html lang="en">
-<head>
-<title>Internal File Ops - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Sample-Library.html#Sample-Library" title="Sample
Library">
-<link rel="prev"
href="Internal-File-Description.html#Internal-File-Description" title="Internal
File Description">
-<link rel="next" href="Using-Internal-File-Ops.html#Using-Internal-File-Ops"
title="Using Internal File Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Internal-File-Ops"></a>Next: <a rel="next" accesskey="n"
href="Using-Internal-File-Ops.html#Using-Internal-File-Ops">Using Internal File
Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="Internal-File-Description.html#Internal-File-Description">Internal File
Description</a>,
-Up: <a rel="up" accesskey="u"
href="Sample-Library.html#Sample-Library">Sample Library</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">C.3.2.2 C Code for <code>chdir</code> and
<code>stat</code></h5>
-
-<p>Here is the C code for these extensions. They were written for
-GNU/Linux. The code needs some more work for complete portability
-to other POSIX-compliant systems:<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
-<!-- break line for page breaking -->
-<pre class="example"> #include "awk.h"
-
- #include <sys/sysmacros.h>
-
- /* do_chdir --- provide dynamically loaded
- chdir() builtin for gawk */
-
- static NODE *
- do_chdir(tree)
- NODE *tree;
- {
- NODE *newdir;
- int ret = -1;
-
- if (do_lint && get_curfunc_arg_count() != 1)
- lintwarn("chdir: called with incorrect number of arguments");
-
- newdir = get_scalar_argument(tree, 0);
-</pre>
- <p>The file includes the <code>"awk.h"</code> header file for definitions
-for the <samp><span class="command">gawk</span></samp> internals. It includes
<code><sys/sysmacros.h></code>
-for access to the <code>major</code> and <code>minor</code> macros.
-
- <p><a
name="index-programming-conventions_002c-_0040command_007bgawk_007d-internals-2015"></a>By
convention, for an <samp><span class="command">awk</span></samp> function
<code>foo</code>, the function that
-implements it is called `<samp><span class="samp">do_foo</span></samp>'. The
function should take
-a `<samp><span class="samp">NODE *</span></samp>' argument, usually called
<code>tree</code>, that
-represents the argument list to the function. The <code>newdir</code>
-variable represents the new directory to change to, retrieved
-with <code>get_argument</code>. Note that the first argument is
-numbered zero.
-
- <p>This code actually accomplishes the <code>chdir</code>. It first forces
-the argument to be a string and passes the string value to the
-<code>chdir</code> system call. If the <code>chdir</code> fails,
<code>ERRNO</code>
-is updated.
-The result of <code>force_string</code> has to be freed with
<code>free_temp</code>:
-
-<pre class="example"> (void) force_string(newdir);
- ret = chdir(newdir->stptr);
- if (ret < 0)
- update_ERRNO();
- free_temp(newdir);
-</pre>
- <p>Finally, the function returns the return value to the <samp><span
class="command">awk</span></samp> level,
-using <code>set_value</code>. Then it must return a value from the call to
-the new built-in (this value ignored by the interpreter):
-
-<pre class="example"> /* Set the return value */
- set_value(tmp_number((AWKNUM) ret));
-
- /* Just to make the interpreter happy */
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p>The <code>stat</code> built-in is more involved. First comes a function
-that turns a numeric mode into a printable representation
-(e.g., 644 becomes `<samp><span class="samp">-rw-r--r--</span></samp>'). This
is omitted here for brevity:
-
-<!-- break line for page breaking -->
-<pre class="example"> /* format_mode --- turn a stat mode field
- into something readable */
-
- static char *
- format_mode(fmode)
- unsigned long fmode;
- {
- ...
- }
-</pre>
- <p>Next comes the actual <code>do_stat</code> function itself. First come
the
-variable declarations and argument checking:
-
-<pre class="example"> /* do_stat --- provide a stat() function for gawk */
-
- static NODE *
- do_stat(tree)
- NODE *tree;
- {
- NODE *file, *array;
- struct stat sbuf;
- int ret;
- NODE **aptr;
- char *pmode; /* printable mode */
- char *type = "unknown";
-
-
- if (do_lint && get_curfunc_arg_count() > 2)
- lintwarn("stat: called with too many arguments");
-</pre>
- <p>Then comes the actual work. First, we get the arguments.
-Then, we always clear the array. To get the file information,
-we use <code>lstat</code>, in case the file is a symbolic link.
-If there's an error, we set <code>ERRNO</code> and return:
-
-<!-- comment made multiline for page breaking -->
-<pre class="example"> /* directory is first arg, array to hold results
is second */
- file = get_scalar_argument(tree, 0, FALSE);
- array = get_array_argument(tree, 1, FALSE);
-
- /* empty out the array */
- assoc_clear(array);
-
- /* lstat the file, if error, set ERRNO and return */
- (void) force_string(file);
- ret = lstat(file->stptr, & sbuf);
- if (ret < 0) {
- update_ERRNO();
-
- set_value(tmp_number((AWKNUM) ret));
-
- free_temp(file);
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p>Now comes the tedious part: filling in the array. Only a few of the
-calls are shown here, since they all follow the same pattern:
-
-<pre class="example"> /* fill in the array */
- aptr = assoc_lookup(array, tmp_string("name", 4), FALSE);
- *aptr = dupnode(file);
-
- aptr = assoc_lookup(array, tmp_string("mode", 4), FALSE);
- *aptr = make_number((AWKNUM) sbuf.st_mode);
-
- aptr = assoc_lookup(array, tmp_string("pmode", 5), FALSE);
- pmode = format_mode(sbuf.st_mode);
- *aptr = make_string(pmode, strlen(pmode));
-</pre>
- <p>When done, we free the temporary value containing the file name,
-set the return value, and return:
-
-<pre class="example"> free_temp(file);
-
- /* Set the return value */
- set_value(tmp_number((AWKNUM) ret));
-
- /* Just to make the interpreter happy */
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p><a
name="index-programming-conventions_002c-_0040command_007bgawk_007d-internals-2016"></a>Finally,
it's necessary to provide the “glue” that loads the
-new function(s) into <samp><span class="command">gawk</span></samp>. By
convention, each library has
-a routine named <code>dlload</code> that does the job:
-
-<pre class="example"> /* dlload --- load new builtins in this library */
-
- NODE *
- dlload(tree, dl)
- NODE *tree;
- void *dl;
- {
- make_builtin("chdir", do_chdir, 1);
- make_builtin("stat", do_stat, 2);
- return tmp_number((AWKNUM) 0);
- }
-</pre>
- <p>And that's it! As an exercise, consider adding functions to
-implement system calls such as <code>chown</code>, <code>chmod</code>, and
<code>umask</code>.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This version is edited
-slightly for presentation. The complete version can be found in
-<samp><span class="file">extension/filefuncs.c</span></samp> in the
<samp><span class="command">gawk</span></samp> distribution.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Internals.html
===================================================================
RCS file: manual/html_node/Internals.html
diff -N manual/html_node/Internals.html
--- manual/html_node/Internals.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,246 +0,0 @@
-<html lang="en">
-<head>
-<title>Internals - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Dynamic-Extensions.html#Dynamic-Extensions"
title="Dynamic Extensions">
-<link rel="next" href="Sample-Library.html#Sample-Library" title="Sample
Library">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Internals"></a>Next: <a rel="next" accesskey="n"
href="Sample-Library.html#Sample-Library">Sample Library</a>,
-Up: <a rel="up" accesskey="u"
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">C.3.1 A Minimal Introduction to <samp><span
class="command">gawk</span></samp> Internals</h4>
-
-<!-- STARTOFRANGE gawint -->
-<p><a name="index-_0040command_007bgawk_007d_002c-internals-1969"></a>
-The truth is that <samp><span class="command">gawk</span></samp> was not
designed for simple extensibility.
-The facilities for adding functions using shared libraries work, but
-are something of a “bag on the side.” Thus, this tour is
-brief and simplistic; would-be <samp><span class="command">gawk</span></samp>
hackers are encouraged to
-spend some time reading the source code before trying to write
-extensions based on the material presented here. Of particular note
-are the files <samp><span class="file">awk.h</span></samp>, <samp><span
class="file">builtin.c</span></samp>, and <samp><span
class="file">eval.c</span></samp>.
-Reading <samp><span class="file">awk.y</span></samp> in order to see how the
parse tree is built
-would also be of use.
-
- <p><a
name="index-_0040code_007bawk_002eh_007d-file-_0028internal_0029-1970"></a>With
the disclaimers out of the way, the following types, structure
-members, functions, and macros are declared in <samp><span
class="file">awk.h</span></samp> and are of
-use when writing extensions. The next section
-shows how they are used:
-
-
-<a
name="index-floating_002dpoint_002c-numbers_002c-_0040code_007bAWKNUM_007d-internal-type-1971"></a>
-<a
name="index-numbers_002c-floating_002dpoint_002c-_0040code_007bAWKNUM_007d-internal-type-1972"></a>
-<a name="index-_0040code_007bAWKNUM_007d-internal-type-1973"></a>
-<dl><dt><code>AWKNUM</code><dd>An <code>AWKNUM</code> is the internal type of
<samp><span class="command">awk</span></samp>
-floating-point numbers. Typically, it is a C <code>double</code>.
-
- <p><a name="index-_0040code_007bNODE_007d-internal-type-1974"></a><a
name="index-strings_002c-_0040code_007bNODE_007d-internal-type-1975"></a><a
name="index-numbers_002c-_0040code_007bNODE_007d-internal-type-1976"></a><br><dt><code>NODE</code><dd>Just
about everything is done using objects of type <code>NODE</code>.
-These contain both strings and numbers, as well as variables and arrays.
-
- <p><a
name="index-_0040code_007bforce_005fnumber_007d-internal-function-1977"></a><a
name="index-numeric_002c-values-1978"></a><br><dt><code>AWKNUM
force_number(NODE *n)</code><dd>This macro forces a value to be numeric. It
returns the actual
-numeric value contained in the node.
-It may end up calling an internal <samp><span
class="command">gawk</span></samp> function.
-
- <p><a
name="index-_0040code_007bforce_005fstring_007d-internal-function-1979"></a><br><dt><code>void
force_string(NODE *n)</code><dd>This macro guarantees that a
<code>NODE</code>'s string value is current.
-It may end up calling an internal <samp><span
class="command">gawk</span></samp> function.
-It also guarantees that the string is zero-terminated.
-
- <p><a
name="index-_0040code_007bget_005fcurfunc_005farg_005fcount_007d-internal-function-1980"></a><br><dt><code>size_t
get_curfunc_arg_count(void)</code><dd>This function returns the actual number
of parameters passed
-to the current function. Inside the code of an extension
-this can be used to determine the maximum index which is
-safe to use with <code>stack_ptr</code>. If this value is
-greater than <code>tree->param_cnt</code>, the function was
-called incorrectly from the <samp><span class="command">awk</span></samp>
program.
-
- <p><strong>Caution:</strong> This function is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a name="index-parameters_0040comma_007b_007d-number-of-1981"></a><a
name="index-_0040code_007bparam_005fcnt_007d-internal-variable-1982"></a><br><dt><code>n->param_cnt</code><dd>Inside
an extension function, this is the maximum number of
-expected parameters, as set by the <code>make_builtin</code> function.
-
- <p><a name="index-_0040code_007bstptr_007d-internal-variable-1983"></a><a
name="index-_0040code_007bstlen_007d-internal-variable-1984"></a><br><dt><code>n->stptr</code><dt><code>n->stlen</code><dd>The
data and length of a <code>NODE</code>'s string value, respectively.
-The string is <em>not</em> guaranteed to be zero-terminated.
-If you need to pass the string value to a C library function, save
-the value in <code>n->stptr[n->stlen]</code>, assign <code>'\0'</code>
to it,
-call the routine, and then restore the value.
-
- <p><a
name="index-_0040code_007btype_007d-internal-variable-1985"></a><br><dt><code>n->type</code><dd>The
type of the <code>NODE</code>. This is a C <code>enum</code>. Values should
-be either <code>Node_var</code> or <code>Node_var_array</code> for function
-parameters.
-
- <p><a
name="index-_0040code_007bvname_007d-internal-variable-1986"></a><br><dt><code>n->vname</code><dd>The
“variable name” of a node. This is not of much use inside
-externally written extensions.
-
- <p><a name="index-arrays_002c-associative_002c-clearing-1987"></a><a
name="index-_0040code_007bassoc_005fclear_007d-internal-function-1988"></a><br><dt><code>void
assoc_clear(NODE *n)</code><dd>Clears the associative array pointed to by
<code>n</code>.
-Make sure that `<samp><span class="samp">n->type ==
Node_var_array</span></samp>' first.
-
- <p><a name="index-arrays_002c-elements_002c-installing-1989"></a><a
name="index-_0040code_007bassoc_005flookup_007d-internal-function-1990"></a><br><dt><code>NODE
**assoc_lookup(NODE *symbol, NODE *subs, int reference)</code><dd>Finds, and
installs if necessary, array elements.
-<code>symbol</code> is the array, <code>subs</code> is the subscript.
-This is usually a value created with <code>tmp_string</code> (see below).
-<code>reference</code> should be <code>TRUE</code> if it is an error to use the
-value before it is created. Typically, <code>FALSE</code> is the
-correct value to use from extension functions.
-
- <p><a name="index-strings-1991"></a><a
name="index-_0040code_007bmake_005fstring_007d-internal-function-1992"></a><br><dt><code>NODE
*make_string(char *s, size_t len)</code><dd>Take a C string and turn it into a
pointer to a <code>NODE</code> that
-can be stored appropriately. This is permanent storage; understanding
-of <samp><span class="command">gawk</span></samp> memory management is helpful.
-
- <p><a name="index-numbers-1993"></a><a
name="index-_0040code_007bmake_005fnumber_007d-internal-function-1994"></a><br><dt><code>NODE
*make_number(AWKNUM val)</code><dd>Take an <code>AWKNUM</code> and turn it
into a pointer to a <code>NODE</code> that
-can be stored appropriately. This is permanent storage; understanding
-of <samp><span class="command">gawk</span></samp> memory management is helpful.
-
- <p><a
name="index-_0040code_007btmp_005fstring_007d-internal-function-1995"></a><br><dt><code>NODE
*tmp_string(char *s, size_t len);</code><dd>Take a C string and turn it into a
pointer to a <code>NODE</code> that
-can be stored appropriately. This is temporary storage; understanding
-of <samp><span class="command">gawk</span></samp> memory management is helpful.
-
- <p><a
name="index-_0040code_007btmp_005fnumber_007d-internal-function-1996"></a><br><dt><code>NODE
*tmp_number(AWKNUM val)</code><dd>Take an <code>AWKNUM</code> and turn it into
a pointer to a <code>NODE</code> that
-can be stored appropriately. This is temporary storage;
-understanding of <samp><span class="command">gawk</span></samp> memory
management is helpful.
-
- <p><a name="index-nodes_0040comma_007b_007d-duplicating-1997"></a><a
name="index-_0040code_007bdupnode_007d-internal-function-1998"></a><br><dt><code>NODE
*dupnode(NODE *n)</code><dd>Duplicate a node. In most cases, this increments
an internal
-reference count instead of actually duplicating the entire <code>NODE</code>;
-understanding of <samp><span class="command">gawk</span></samp> memory
management is helpful.
-
- <p><a name="index-memory_002c-releasing-1999"></a><a
name="index-_0040code_007bfree_005ftemp_007d-internal-macro-2000"></a><br><dt><code>void
free_temp(NODE *n)</code><dd>This macro releases the memory associated with a
<code>NODE</code>
-allocated with <code>tmp_string</code> or <code>tmp_number</code>.
-Understanding of <samp><span class="command">gawk</span></samp> memory
management is helpful.
-
- <p><a
name="index-_0040code_007bmake_005fbuiltin_007d-internal-function-2001"></a><br><dt><code>void
make_builtin(char *name, NODE *(*func)(NODE *), int count)</code><dd>Register
a C function pointed to by <code>func</code> as new built-in
-function <code>name</code>. <code>name</code> is a regular C string.
<code>count</code>
-is the maximum number of arguments that the function takes.
-The function should be written in the following manner:
-
- <pre class="example"> /* do_xxx --- do xxx function for gawk */
-
- NODE *
- do_xxx(NODE *tree)
- {
- ...
- }
- </pre>
- <p><a name="index-arguments_002c-retrieving-2002"></a><a
name="index-_0040code_007bget_005fargument_007d-internal-function-2003"></a><br><dt><code>NODE
*get_argument(NODE *tree, int i)</code><dd>This function is called from within
a C extension function to get
-the <code>i</code>-th argument from the function call.
-The first argument is argument zero.
-
- <p><a
name="index-_0040code_007bget_005factual_005fargument_007d-internal-function-2004"></a><br><dt><code>NODE
*get_actual_argument(NODE *tree, unsigned int i,</code><dt><code>
int optional, int wantarray);</code><dd>This function retrieves a
particular argument <code>i</code>. <code>wantarray</code> is <code>TRUE</code>
-if the argument should be an array, <code>FALSE</code> otherwise. If
<code>optional</code> is
-<code>TRUE</code>, the argument need not have been supplied. If it wasn't,
the return
-value is <code>NULL</code>. It is a fatal error if <code>optional</code> is
<code>TRUE</code> but
-the argument was not provided.
-
- <p><strong>Caution:</strong> This function is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a
name="index-_0040code_007bget_005fscalar_005fargument_007d-internal-macro-2005"></a><br><dt><code>get_scalar_argument(t,
i, opt)</code><dd>This is a convenience macro that calls
<code>get_actual_argument</code>.
-
- <p><strong>Caution:</strong> This macro is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a
name="index-_0040code_007bget_005farray_005fargument_007d-internal-macro-2006"></a><br><dt><code>get_array_argument(t,
i, opt)</code><dd>This is a convenience macro that calls
<code>get_actual_argument</code>.
-
- <p><strong>Caution:</strong> This macro is new as of <samp><span
class="command">gawk</span></samp> 3.1.4.
-
- <p><a
name="index-functions_002c-return-values_0040comma_007b_007d-setting-2007"></a><a
name="index-_0040code_007bset_005fvalue_007d-internal-function-2008"></a><br><dt><code>void
set_value(NODE *tree)</code><dd>This function is called from within a C
extension function to set
-the return value from the extension function. This value is
-what the <samp><span class="command">awk</span></samp> program sees as the
return value from the
-new <samp><span class="command">awk</span></samp> function.
-
- <p><a name="index-_0040code_007bERRNO_007d-variable-2009"></a><a
name="index-_0040code_007bupdate_005fERRNO_007d-internal-function-2010"></a><br><dt><code>void
update_ERRNO(void)</code><dd>This function is called from within a C extension
function to set
-the value of <samp><span class="command">gawk</span></samp>'s
<code>ERRNO</code> variable, based on the current
-value of the C <code>errno</code> variable.
-It is provided as a convenience.
-</dl>
-
- <p>An argument that is supposed to be an array needs to be handled with
-some extra code, in case the array being passed in is actually
-from a function parameter.
-
- <p>In versions of <samp><span class="command">gawk</span></samp> up to and
including 3.1.2, the
-following boilerplate code shows how to do this:
-
-<pre class="smallexample"> NODE *the_arg;
-
- the_arg = get_argument(tree, 2); /* assume need 3rd arg, 0-based */
-
- /* if a parameter, get it off the stack */
- if (the_arg->type == Node_param_list)
- the_arg = stack_ptr[the_arg->param_cnt];
-
- /* parameter referenced an array, get it */
- if (the_arg->type == Node_array_ref)
- the_arg = the_arg->orig_array;
-
- /* check type */
- if (the_arg->type != Node_var && the_arg->type !=
Node_var_array)
- fatal("newfunc: third argument is not an array");
-
- /* force it to be an array, if necessary, clear it */
- the_arg->type = Node_var_array;
- assoc_clear(the_arg);
-</pre>
- <p>For versions 3.1.3 and later, the internals changed. In particular,
-the interface was actually <em>simplified</em> drastically. The
-following boilerplate code now suffices:
-
-<pre class="smallexample"> NODE *the_arg;
-
- the_arg = get_argument(tree, 2); /* assume need 3rd arg, 0-based */
-
- /* force it to be an array: */
- the_arg = get_array(the_arg);
-
- /* if necessary, clear it: */
- assoc_clear(the_arg);
-</pre>
- <p>As of version 3.1.4, the internals improved again, and became
-even simpler:
-
-<pre class="smallexample"> NODE *the_arg;
-
- the_arg = get_array_argument(tree, 2, FALSE); /* assume need 3rd arg,
0-based */
-</pre>
- <p>Again, you should spend time studying the <samp><span
class="command">gawk</span></samp> internals;
-don't just blindly copy this code.
-<!-- ENDOFRANGE gawint -->
-
- </body></html>
-
Index: manual/html_node/Internationalization.html
===================================================================
RCS file: manual/html_node/Internationalization.html
diff -N manual/html_node/Internationalization.html
--- manual/html_node/Internationalization.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,86 +0,0 @@
-<html lang="en">
-<head>
-<title>Internationalization - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Functions.html#Functions" title="Functions">
-<link rel="next" href="Advanced-Features.html#Advanced-Features"
title="Advanced Features">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Internationalization"></a>Next: <a rel="next" accesskey="n"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>,
-Previous: <a rel="previous" accesskey="p"
href="Functions.html#Functions">Functions</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">9 Internationalization with <samp><span
class="command">gawk</span></samp></h2>
-
-<p>Once upon a time, computer makers
-wrote software that worked only in English.
-Eventually, hardware and software vendors noticed that if their
-systems worked in the native languages of non-English-speaking
-countries, they were able to sell more systems.
-As a result, internationalization and localization
-of programs and software systems became a common practice.
-
-<!-- STARTOFRANGE inloc -->
-<p><a name="index-internationalization_002c-localization-1300"></a><a
name="index-_0040command_007bgawk_007d_002c-internationalization-and_002c-See-internationalization-1301"></a><a
name="index-internationalization_002c-localization_002c-_0040command_007bgawk_007d-and-1302"></a>Until
recently, the ability to provide internationalization
-was largely restricted to programs written in C and C++.
-This chapter describes the underlying library <samp><span
class="command">gawk</span></samp>
-uses for internationalization, as well as how
-<samp><span class="command">gawk</span></samp> makes internationalization
-features available at the <samp><span class="command">awk</span></samp>
program level.
-Having internationalization available at the <samp><span
class="command">awk</span></samp> level
-gives software developers additional flexibility—they are no
-longer required to write in C when internationalization is
-a requirement.
-
-<ul class="menu">
-<li><a accesskey="1" href="I18N-and-L10N.html#I18N-and-L10N">I18N and
L10N</a>: Internationalization and Localization.
-<li><a accesskey="2"
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a>:
How GNU <code>gettext</code> works.
-<li><a accesskey="3" href="Programmer-i18n.html#Programmer-i18n">Programmer
i18n</a>: Features for the programmer.
-<li><a accesskey="4" href="Translator-i18n.html#Translator-i18n">Translator
i18n</a>: Features for the translator.
-<li><a accesskey="5" href="I18N-Example.html#I18N-Example">I18N Example</a>:
A simple i18n example.
-<li><a accesskey="6" href="Gawk-I18N.html#Gawk-I18N">Gawk I18N</a>:
<samp><span class="command">gawk</span></samp> is also
internationalized.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Invoking-Gawk.html
===================================================================
RCS file: manual/html_node/Invoking-Gawk.html
diff -N manual/html_node/Invoking-Gawk.html
--- manual/html_node/Invoking-Gawk.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-<html lang="en">
-<head>
-<title>Invoking Gawk - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Advanced-Features.html#Advanced-Features"
title="Advanced Features">
-<link rel="next" href="Library-Functions.html#Library-Functions"
title="Library Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Invoking-Gawk"></a>Next: <a rel="next" accesskey="n"
href="Library-Functions.html#Library-Functions">Library Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">11 Running <samp><span class="command">awk</span></samp>
and <samp><span class="command">gawk</span></samp></h2>
-
-<p>This chapter covers how to run awk, both POSIX-standard
-and <samp><span class="command">gawk</span></samp>-specific command-line
options, and what
-<samp><span class="command">awk</span></samp> and
-<samp><span class="command">gawk</span></samp> do with non-option arguments.
-It then proceeds to cover how <samp><span class="command">gawk</span></samp>
searches for source files,
-obsolete options and/or features, and known bugs in <samp><span
class="command">gawk</span></samp>.
-This chapter rounds out the discussion of <samp><span
class="command">awk</span></samp>
-as a program and as a language.
-
- <p>While a number of the options and features described here were
-discussed in passing earlier in the book, this chapter provides the
-full details.
-
-<ul class="menu">
-<li><a accesskey="1" href="Command-Line.html#Command-Line">Command Line</a>:
How to run <samp><span class="command">awk</span></samp>.
-<li><a accesskey="2" href="Options.html#Options">Options</a>:
Command-line options and their meanings.
-<li><a accesskey="3" href="Other-Arguments.html#Other-Arguments">Other
Arguments</a>: Input file names and variable assignments.
-<li><a accesskey="4" href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH
Variable</a>: Searching directories for <samp><span
class="command">awk</span></samp>
- programs.
-<li><a accesskey="5" href="Obsolete.html#Obsolete">Obsolete</a>:
Obsolete Options and/or features.
-<li><a accesskey="6" href="Undocumented.html#Undocumented">Undocumented</a>:
Undocumented Options and Features.
-<li><a accesskey="7" href="Known-Bugs.html#Known-Bugs">Known Bugs</a>:
Known Bugs in <samp><span class="command">gawk</span></samp>.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Join-Function.html
===================================================================
RCS file: manual/html_node/Join-Function.html
diff -N manual/html_node/Join-Function.html
--- manual/html_node/Join-Function.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-<html lang="en">
-<head>
-<title>Join Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Ordinal-Functions.html#Ordinal-Functions"
title="Ordinal Functions">
-<link rel="next" href="Gettimeofday-Function.html#Gettimeofday-Function"
title="Gettimeofday Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Join-Function"></a>Next: <a rel="next" accesskey="n"
href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.7 Merging an Array into a String</h4>
-
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-merging-arrays-into-strings-1653"></a><a
name="index-functions_002c-library_002c-merging-arrays-into-strings-1654"></a><a
name="index-strings_002c-merging-arrays-into-1655"></a><a
name="index-arrays_002c-merging-into-strings-1656"></a>When doing string
processing, it is often useful to be able to join
-all the strings in an array into one long string. The following function,
-<code>join</code>, accomplishes this task. It is used later in several of
-the application programs
-(see <a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>).
-
- <p>Good function design is important; this function needs to be general but
it
-should also have a reasonable default behavior. It is called with an array
-as well as the beginning and ending indices of the elements in the array to be
-merged. This assumes that the array indices are numeric—a reasonable
-assumption since the array was likely created with <code>split</code>
-(see <a href="String-Functions.html#String-Functions">String Functions</a>):
-
- <p><a
name="index-_0040code_007bjoin_007d-user_002ddefined-function-1657"></a>
-<pre class="example"> <!-- file eg/lib/join.awk -->
- # join.awk --- join an array into a string
- <!-- endfile -->
- <!-- file eg/lib/join.awk -->
- function join(array, start, end, sep, result, i)
- {
- if (sep == "")
- sep = " "
- else if (sep == SUBSEP) # magic value
- sep = ""
- result = array[start]
- for (i = start + 1; i <= end; i++)
- result = result sep array[i]
- return result
- }
- <!-- endfile -->
-</pre>
- <p>An optional additional argument is the separator to use when joining the
-strings back together. If the caller supplies a nonempty value,
-<code>join</code> uses it; if it is not supplied, it has a null
-value. In this case, <code>join</code> uses a single blank as a default
-separator for the strings. If the value is equal to <code>SUBSEP</code>,
-then <code>join</code> joins the strings with no separator between them.
-<code>SUBSEP</code> serves as a “magic” value to indicate that
there should
-be no separation between the component strings.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> It would
-be nice if <samp><span class="command">awk</span></samp> had an assignment
operator for concatenation.
-The lack of an explicit operator for concatenation makes string operations
-more difficult than they really need to be.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Known-Bugs.html
===================================================================
RCS file: manual/html_node/Known-Bugs.html
diff -N manual/html_node/Known-Bugs.html
--- manual/html_node/Known-Bugs.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-<html lang="en">
-<head>
-<title>Known Bugs - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="prev" href="Undocumented.html#Undocumented" title="Undocumented">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Known-Bugs"></a>Previous: <a rel="previous" accesskey="p"
href="Undocumented.html#Undocumented">Undocumented</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.7 Known Bugs in <samp><span
class="command">gawk</span></samp></h3>
-
-<p><a name="index-_0040command_007bgawk_007d_002c-debugging-1584"></a><a
name="index-debugging-_0040command_007bgawk_007d-1585"></a><a
name="index-troubleshooting_002c-_0040command_007bgawk_007d-1586"></a>
-
-<a name="index-troubleshooting_002c-_0040code_007b_002dF_007d-option-1587"></a>
-<a name="index-_0040code_007b_002dF_007d-option_002c-troubleshooting-1588"></a>
-<a name="index-_0040code_007bFS_007d-variable_002c-changing-value-of-1589"></a>
-<ul><li>The <samp><span class="option">-F</span></samp> option for changing
the value of <code>FS</code>
-(see <a href="Options.html#Options">Options</a>)
-is not necessary given the command-line variable
-assignment feature; it remains only for backward compatibility.
-
- <li>Syntactically invalid single-character programs tend to overflow
-the parse stack, generating a rather unhelpful message. Such programs
-are surprisingly difficult to diagnose in the completely general case,
-and the effort to do so really is not worth it.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Labels-Program.html
===================================================================
RCS file: manual/html_node/Labels-Program.html
diff -N manual/html_node/Labels-Program.html
--- manual/html_node/Labels-Program.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,170 +0,0 @@
-<html lang="en">
-<head>
-<title>Labels Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Translate-Program.html#Translate-Program"
title="Translate Program">
-<link rel="next" href="Word-Sorting.html#Word-Sorting" title="Word Sorting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Labels-Program"></a>Next: <a rel="next" accesskey="n"
href="Word-Sorting.html#Word-Sorting">Word Sorting</a>,
-Previous: <a rel="previous" accesskey="p"
href="Translate-Program.html#Translate-Program">Translate Program</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.4 Printing Mailing Labels</h4>
-
-<!-- STARTOFRANGE prml -->
-<p><a name="index-printing_002c-mailing-labels-1800"></a><!-- STARTOFRANGE
mlprint -->
-<a name="index-mailing-labels_0040comma_007b_007d-printing-1801"></a>Here is a
“real world”<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-program. This
-script reads lists of names and
-addresses and generates mailing labels. Each page of labels has 20 labels
-on it, 2 across and 10 down. The addresses are guaranteed to be no more
-than 5 lines of data. Each address is separated from the next by a blank
-line.
-
- <p>The basic idea is to read 20 labels worth of data. Each line of each
label
-is stored in the <code>line</code> array. The single rule takes care of
filling
-the <code>line</code> array and printing the page when 20 labels have been
read.
-
- <p>The <code>BEGIN</code> rule simply sets <code>RS</code> to the empty
string, so that
-<samp><span class="command">awk</span></samp> splits records at blank lines
-(see <a href="Records.html#Records">Records</a>).
-It sets <code>MAXLINES</code> to 100, since 100 is the maximum number
-of lines on the page (20 * 5 = 100).
-
- <p>Most of the work is done in the <code>printpage</code> function.
-The label lines are stored sequentially in the <code>line</code> array. But
they
-have to print horizontally; <code>line[1]</code> next to <code>line[6]</code>,
-<code>line[2]</code> next to <code>line[7]</code>, and so on. Two loops are
used to
-accomplish this. The outer loop, controlled by <code>i</code>, steps through
-every 10 lines of data; this is each row of labels. The inner loop,
-controlled by <code>j</code>, goes through the lines within the row.
-As <code>j</code> goes from 0 to 4, `<samp><span
class="samp">i+j</span></samp>' is the <code>j</code>-th line in
-the row, and `<samp><span class="samp">i+j+5</span></samp>' is the entry next
to it. The output ends up
-looking something like this:
-
-<pre class="example"> line 1 line 6
- line 2 line 7
- line 3 line 8
- line 4 line 9
- line 5 line 10
- ...
-</pre>
- <p>As a final note, an extra blank line is printed at lines 21 and 61, to
keep
-the output lined up on the labels. This is dependent on the particular
-brand of labels in use when the program was written. You will also note
-that there are 2 blank lines at the top and 2 blank lines at the bottom.
-
- <p>The <code>END</code> rule arranges to flush the final page of labels;
there may
-not have been an even multiple of 20 labels in the data:
-
- <p><a name="index-_0040code_007blabels_002eawk_007d-program-1802"></a>
-<pre class="example"> <!-- file eg/prog/labels.awk -->
- # labels.awk --- print mailing labels
- <!-- endfile -->
- <!-- file eg/prog/labels.awk -->
-
- # Each label is 5 lines of data that may have blank lines.
- # The label sheets have 2 blank lines at the top and 2 at
- # the bottom.
-
- BEGIN { RS = "" ; MAXLINES = 100 }
-
- function printpage( i, j)
- {
- if (Nlines <= 0)
- return
-
- printf "\n\n" # header
-
- for (i = 1; i <= Nlines; i += 10) {
- if (i == 21 || i == 61)
- print ""
- for (j = 0; j < 5; j++) {
- if (i + j > MAXLINES)
- break
- printf " %-41s %s\n", line[i+j], line[i+j+5]
- }
- print ""
- }
-
- printf "\n\n" # footer
-
- for (i in line)
- line[i] = ""
- }
-
- # main rule
- {
- if (Count >= 20) {
- printpage()
- Count = 0
- Nlines = 0
- }
- n = split($0, a, "\n")
- for (i = 1; i <= n; i++)
- line[++Nlines] = a[i]
- for (; i <= 5; i++)
- line[++Nlines] = ""
- Count++
- }
-
- END \
- {
- printpage()
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE prml -->
-<!-- ENDOFRANGE mlprint -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> “Real world” is defined as
-“a program actually used to get something done.”</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Language-History.html
===================================================================
RCS file: manual/html_node/Language-History.html
diff -N manual/html_node/Language-History.html
--- manual/html_node/Language-History.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-<html lang="en">
-<head>
-<title>Language History - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Sample-Programs.html#Sample-Programs" title="Sample
Programs">
-<link rel="next" href="Installation.html#Installation" title="Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Language-History"></a>Next: <a rel="next" accesskey="n"
href="Installation.html#Installation">Installation</a>,
-Previous: <a rel="previous" accesskey="p"
href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="appendix">Appendix A The Evolution of the <samp><span
class="command">awk</span></samp> Language</h2>
-
-<p>This Web page describes the GNU implementation of <samp><span
class="command">awk</span></samp>, which follows
-the POSIX specification.
-Many long-time <samp><span class="command">awk</span></samp> users learned
<samp><span class="command">awk</span></samp> programming
-with the original <samp><span class="command">awk</span></samp> implementation
in Version 7 Unix.
-(This implementation was the basis for <samp><span
class="command">awk</span></samp> in Berkeley Unix,
-through 4.3-Reno. Subsequent versions of Berkeley Unix, and systems
-derived from 4.4BSD-Lite, use various versions of <samp><span
class="command">gawk</span></samp>
-for their <samp><span class="command">awk</span></samp>.)
-This chapter briefly describes the
-evolution of the <samp><span class="command">awk</span></samp> language, with
cross-references to other parts
-of the Web page where you can find more information.
-
-<ul class="menu">
-<li><a accesskey="1"
href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a>:
The major changes between V7 and System V
- Release 3.1.
-<li><a accesskey="2" href="SVR4.html#SVR4">SVR4</a>:
Minor changes between System V Releases 3.1
- and 4.
-<li><a accesskey="3" href="POSIX.html#POSIX">POSIX</a>:
New features from the POSIX standard.
-<li><a accesskey="4" href="BTL.html#BTL">BTL</a>: New
features from the Bell Laboratories
- version of <samp><span
class="command">awk</span></samp>.
-<li><a accesskey="5" href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a>:
The extensions in <samp><span
class="command">gawk</span></samp> not in POSIX
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="6" href="Contributors.html#Contributors">Contributors</a>:
The major contributors to <samp><span
class="command">gawk</span></samp>.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Leftmost-Longest.html
===================================================================
RCS file: manual/html_node/Leftmost-Longest.html
diff -N manual/html_node/Leftmost-Longest.html
--- manual/html_node/Leftmost-Longest.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-<html lang="en">
-<head>
-<title>Leftmost Longest - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Case_002dsensitivity.html#Case_002dsensitivity"
title="Case-sensitivity">
-<link rel="next" href="Computed-Regexps.html#Computed-Regexps" title="Computed
Regexps">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Leftmost-Longest"></a>Next: <a rel="next" accesskey="n"
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>,
-Previous: <a rel="previous" accesskey="p"
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.7 How Much Text Matches?</h3>
-
-<p><a
name="index-regular-expressions_002c-leftmost-longest-match-324"></a><!--
@cindex matching, leftmost longest -->
-Consider the following:
-
-<pre class="example"> echo aaaabcd | awk '{ sub(/a+/, "<A>"); print
}'
-</pre>
- <p>This example uses the <code>sub</code> function (which we haven't
discussed yet;
-see <a href="String-Functions.html#String-Functions">String Functions</a>)
-to make a change to the input record. Here, the regexp <code>/a+/</code>
-indicates “one or more `<samp><span class="samp">a</span></samp>'
characters,” and the replacement
-text is `<samp><span class="samp"><A></span></samp>'.
-
- <p>The input contains four `<samp><span class="samp">a</span></samp>'
characters.
-<samp><span class="command">awk</span></samp> (and POSIX) regular expressions
always match
-the leftmost, <em>longest</em> sequence of input characters that can
-match. Thus, all four `<samp><span class="samp">a</span></samp>' characters
are
-replaced with `<samp><span class="samp"><A></span></samp>' in this
example:
-
-<pre class="example"> $ echo aaaabcd | awk '{ sub(/a+/, "<A>");
print }'
- -| <A>bcd
-</pre>
- <p>For simple match/no-match tests, this is not so important. But when doing
-text matching and substitutions with the <code>match</code>, <code>sub</code>,
<code>gsub</code>,
-and <code>gensub</code> functions, it is very important.
-Understanding this principle is also important for regexp-based record
-and field splitting (see <a href="Records.html#Records">Records</a>,
-and also see <a href="Field-Separators.html#Field-Separators">Field
Separators</a>).
-
- </body></html>
-
Index: manual/html_node/Library-Functions.html
===================================================================
RCS file: manual/html_node/Library-Functions.html
diff -N manual/html_node/Library-Functions.html
--- manual/html_node/Library-Functions.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,138 +0,0 @@
-<html lang="en">
-<head>
-<title>Library Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="next" href="Sample-Programs.html#Sample-Programs" title="Sample
Programs">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Library-Functions"></a>Next: <a rel="next" accesskey="n"
href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-Previous: <a rel="previous" accesskey="p"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">12 A Library of <samp><span
class="command">awk</span></samp> Functions</h2>
-
-<!-- STARTOFRANGE libf -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions-1590"></a><!--
STARTOFRANGE flib -->
-<a name="index-functions_002c-library-1591"></a><!-- STARTOFRANGE fudlib -->
-<a name="index-functions_002c-user_002ddefined_002c-library-of-1592"></a>
-<a href="User_002ddefined.html#User_002ddefined">User-defined</a>, describes
how to write
-your own <samp><span class="command">awk</span></samp> functions. Writing
functions is important, because
-it allows you to encapsulate algorithms and program tasks in a single
-place. It simplifies programming, making program development more
-manageable, and making programs more readable.
-
- <p>One valuable way to learn a new programming language is to <em>read</em>
-programs in that language. To that end, this chapter
-and <a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-provide a good-sized body of code for you to read,
-and hopefully, to learn from.
-
-<!-- 2e: USE TEXINFO-2 FUNCTION DEFINITION STUFF!!!!!!!!!!!!! -->
-<p>This chapter presents a library of useful <samp><span
class="command">awk</span></samp> functions.
-Many of the sample programs presented later in this Web page
-use these functions.
-The functions are presented here in a progression from simple to complex.
-
- <p><a name="index-Texinfo-1593"></a><a
href="Extract-Program.html#Extract-Program">Extract Program</a>,
-presents a program that you can use to extract the source code for
-these example library functions and programs from the Texinfo source
-for this Web page.
-(This has already been done as part of the <samp><span
class="command">gawk</span></samp> distribution.)
-
- <p>If you have written one or more useful, general-purpose <samp><span
class="command">awk</span></samp> functions
-and would like to contribute them to the author's collection of <samp><span
class="command">awk</span></samp>
-programs, see
-<a href="How-To-Contribute.html#How-To-Contribute">How To Contribute</a>, for
more information.
-
- <p><a name="index-portability_002c-example-programs-1594"></a>The programs
in this chapter and in
-<a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-freely use features that are <samp><span
class="command">gawk</span></samp>-specific.
-Rewriting these programs for different implementations of awk is pretty
straightforward.
-
- <p>Diagnostic error messages are sent to <samp><span
class="file">/dev/stderr</span></samp>.
-Use `<samp><span class="samp">| "cat 1>&2"</span></samp>' instead of
`<samp><span class="samp">> "/dev/stderr"</span></samp>' if your system
-does not have a <samp><span class="file">/dev/stderr</span></samp>, or if you
cannot use <samp><span class="command">gawk</span></samp>.
-
- <p>A number of programs use <code>nextfile</code>
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>)
-to skip any remaining input in the input file.
-<a href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a>,
-shows you how to write a function that does the same thing.
-
-<!-- 12/2000: Thanks to Nelson Beebe for pointing out the output issue. -->
-<p><a name="index-case-sensitivity_002c-example-programs-1595"></a><a
name="index-_0040code_007bIGNORECASE_007d-variable_002c-in-example-programs-1596"></a>Finally,
some of the programs choose to ignore upper- and lowercase
-distinctions in their input. They do so by assigning one to
<code>IGNORECASE</code>.
-You can achieve almost the same effect<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> by adding the following rule to the
-beginning of the program:
-
-<pre class="example"> # ignore case
- { $0 = tolower($0) }
-</pre>
- <p class="noindent">Also, verify that all regexp and string constants used
in
-comparisons use only lowercase letters.
-
-<ul class="menu">
-<li><a accesskey="1" href="Library-Names.html#Library-Names">Library
Names</a>: How to best name private global variables in
- library functions.
-<li><a accesskey="2" href="General-Functions.html#General-Functions">General
Functions</a>: Functions that are of general use.
-<li><a accesskey="3"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>:
Functions for managing command-line data
- files.
-<li><a accesskey="4" href="Getopt-Function.html#Getopt-Function">Getopt
Function</a>: A function for processing command-line
- arguments.
-<li><a accesskey="5" href="Passwd-Functions.html#Passwd-Functions">Passwd
Functions</a>: Functions for getting user information.
-<li><a accesskey="6" href="Group-Functions.html#Group-Functions">Group
Functions</a>: Functions for getting group information.
-</ul>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The effects are
-not identical. Output of the transformed
-record will be in all lowercase, while <code>IGNORECASE</code> preserves the
original
-contents of the input record.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Library-Names.html
===================================================================
RCS file: manual/html_node/Library-Names.html
diff -N manual/html_node/Library-Names.html
--- manual/html_node/Library-Names.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,137 +0,0 @@
-<html lang="en">
-<head>
-<title>Library Names - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Library-Functions.html#Library-Functions" title="Library
Functions">
-<link rel="next" href="General-Functions.html#General-Functions"
title="General Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Library-Names"></a>Next: <a rel="next" accesskey="n"
href="General-Functions.html#General-Functions">General Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Library-Functions.html#Library-Functions">Library Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">12.1 Naming Library Function Global Variables</h3>
-
-<p><a name="index-names_002c-arrays_002fvariables-1597"></a><a
name="index-names_002c-functions-1598"></a><a
name="index-namespace-issues-1599"></a><a
name="index-_0040command_007bawk_007d-programs_002c-documenting-1600"></a><a
name="index-documentation_002c-of-_0040command_007bawk_007d-programs-1601"></a>Due
to the way the <samp><span class="command">awk</span></samp> language evolved,
variables are either
-<dfn>global</dfn> (usable by the entire program) or <dfn>local</dfn> (usable
just by
-a specific function). There is no intermediate state analogous to
-<code>static</code> variables in C.
-
- <p><a
name="index-variables_002c-global_002c-for-library-functions-1602"></a><a
name="index-private-variables-1603"></a><a
name="index-variables_002c-private-1604"></a>Library functions often need to
have global variables that they can use to
-preserve state information between calls to the function—for example,
-<code>getopt</code>'s variable <code>_opti</code>
-(see <a href="Getopt-Function.html#Getopt-Function">Getopt Function</a>).
-Such variables are called <dfn>private</dfn>, since the only functions that
need to
-use them are the ones in the library.
-
- <p>When writing a library function, you should try to choose names for your
-private variables that will not conflict with any variables used by
-either another library function or a user's main program. For example, a
-name like `<samp><span class="samp">i</span></samp>' or `<samp><span
class="samp">j</span></samp>' is not a good choice, because user programs
-often use variable names like these for their own purposes.
-
- <p><a
name="index-programming-conventions_002c-private-variable-names-1605"></a>The
example programs shown in this chapter all start the names of their
-private variables with an underscore (`<samp><span
class="samp">_</span></samp>'). Users generally don't use
-leading underscores in their variable names, so this convention immediately
-decreases the chances that the variable name will be accidentally shared
-with the user's program.
-
- <p><a
name="index-_0040code_007b_005f_007d-_0028underscore_0029_002c-in-names-of-private-variables-1606"></a><a
name="index-underscore-_0028_0040code_007b_005f_007d_0029_002c-in-names-of-private-variables-1607"></a>In
addition, several of the library functions use a prefix that helps
-indicate what function or set of functions use the variables—for example,
-<code>_pw_byname</code> in the user database routines
-(see <a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>).
-This convention is recommended, since it even further decreases the
-chance of inadvertent conflict among variable names. Note that this
-convention is used equally well for variable names and for private
-function names as well.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
- <p>As a final note on variable naming, if a function makes global variables
-available for use by a main program, it is a good convention to start that
-variable's name with a capital letter—for
-example, <code>getopt</code>'s <code>Opterr</code> and <code>Optind</code>
variables
-(see <a href="Getopt-Function.html#Getopt-Function">Getopt Function</a>).
-The leading capital letter indicates that it is global, while the fact that
-the variable name is not all capital letters indicates that the variable is
-not one of <samp><span class="command">awk</span></samp>'s built-in variables,
such as <code>FS</code>.
-
- <p><a
name="index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1608"></a>It
is also important that <em>all</em> variables in library
-functions that do not need to save state are, in fact, declared
-local.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a> If this is
not done, the variable
-could accidentally be used in the user's program, leading to bugs that
-are very difficult to track down:
-
-<pre class="example"> function lib_func(x, y, l1, l2)
- {
- ...
- <var>use variable</var> some_var # some_var should be local
- ... # but is not by oversight
- }
-</pre>
- <p><a
name="index-arrays_002c-associative_002c-library-functions-and-1609"></a><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-associative-arrays-and-1610"></a><a
name="index-functions_002c-library_002c-associative-arrays-and-1611"></a><a
name="index-Tcl-1612"></a>A different convention, common in the Tcl community,
is to use a single
-associative array to hold the values needed by the library function(s), or
-“package.” This significantly decreases the number of actual
global names
-in use. For example, the functions described in
-<a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>,
-might have used array elements <code>PW_data["inited"]<!-- /@w --></code>,
<code>PW_data["total"]<!-- /@w --></code>,
-<code>PW_data["count"]<!-- /@w --></code>, and <code>PW_data["awklib"]<!-- /@w
--></code>, instead of
-<code>_pw_inited<!-- /@w --></code>, <code>_pw_awklib<!-- /@w --></code>,
<code>_pw_total<!-- /@w --></code>,
-and <code>_pw_count<!-- /@w --></code>.
-
- <p>The conventions presented in this section are exactly
-that: conventions. You are not required to write your programs this
-way—we merely recommend that you do so.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> While all the library routines could have
-been rewritten to use this convention, this was not done, in order to
-show how my own <samp><span class="command">awk</span></samp> programming
style has evolved and to
-provide some basis for this discussion.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
<samp><span class="command">gawk</span></samp>'s <samp><span
class="option">--dump-variables</span></samp> command-line
-option is useful for verifying this.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Locales.html
===================================================================
RCS file: manual/html_node/Locales.html
diff -N manual/html_node/Locales.html
--- manual/html_node/Locales.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-<html lang="en">
-<head>
-<title>Locales - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Computed-Regexps.html#Computed-Regexps" title="Computed
Regexps">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Locales"></a>Previous: <a rel="previous" accesskey="p"
href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.9 Where You Are Makes A Difference</h3>
-
-<p>Modern systems support the notion of <dfn>locales</dfn>: a way to tell
-the system about the local character set and language. The current
-locale setting can affect the way regexp matching works, often
-in surprising ways. In particular, many locales do case-insensitive
-matching, even when you may have specified characters of only
-one particular case.
-
- <p>The following example uses the <code>sub</code> function, which
-does text replacement
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-Here, the intent is to remove trailing uppercase characters:
-
-<pre class="example"> $ echo something1234abc | gawk '{ sub("[A-Z]*$",
""); print }'
- -| something1234
-</pre>
- <p class="noindent">This output is unexpected, since the `<samp><span
class="samp">abc</span></samp>' at the end of `<samp><span
class="samp">something1234abc</span></samp>'
-should not normally match `<samp><span class="samp">[A-Z]*</span></samp>'.
This result is due to the
-locale setting (and thus you may not see it on your system).
-There are two fixes. The first is to use the POSIX character
-class `<samp><span class="samp">[[:upper:]]</span></samp>', instead of
`<samp><span class="samp">[A-Z]</span></samp>'.
-The second is to change the locale setting in the environment,
-before running <samp><span class="command">gawk</span></samp>,
-by using the shell statements:
-
-<pre class="example"> LANG=C LC_ALL=C
- export LANG LC_ALL
-</pre>
- <p>The setting `<samp><span class="samp">C</span></samp>' forces
<samp><span class="command">gawk</span></samp> to behave in the traditional
-Unix manner, where case distinctions do matter.
-You may wish to put these statements into your shell startup file,
-e.g., <samp><span class="file">$HOME/.profile</span></samp>.
-
- <p>Similar considerations apply to other ranges. For example,
-`<samp><span class="samp">["-/]</span></samp>' is perfectly valid in ASCII,
but is not valid in many
-Unicode locales, such as `<samp><span class="samp">en_US.UTF-8</span></samp>'.
(In general, such
-ranges should be avoided; either list the characters individually,
-or use a POSIX character class such as `<samp><span
class="samp">[[:punct:]]</span></samp>'.)
-
- <p>For the normal case of `<samp><span class="samp">RS =
"\n"</span></samp>', the locale is largely irrelevant.
-For other single byte record separators, using `<samp><span
class="samp">LC_ALL=C</span></samp>' will give you
-much better performance when reading records. Otherwise, <samp><span
class="command">gawk</span></samp> has
-to make several function calls, <em>per input character</em> to find the record
-terminator.
-
- </body></html>
-
Index: manual/html_node/Long.html
===================================================================
RCS file: manual/html_node/Long.html
diff -N manual/html_node/Long.html
--- manual/html_node/Long.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,93 +0,0 @@
-<html lang="en">
-<head>
-<title>Long - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="prev" href="Read-Terminal.html#Read-Terminal" title="Read Terminal">
-<link rel="next" href="Executable-Scripts.html#Executable-Scripts"
title="Executable Scripts">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Long"></a>Next: <a rel="next" accesskey="n"
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a>,
-Previous: <a rel="previous" accesskey="p"
href="Read-Terminal.html#Read-Terminal">Read Terminal</a>,
-Up: <a rel="up" accesskey="u"
href="Running-gawk.html#Running-gawk">Running gawk</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.1.3 Running Long Programs</h4>
-
-<p><a name="index-_0040command_007bawk_007d-programs_002c-running-95"></a><a
name="index-_0040command_007bawk_007d-programs_002c-lengthy-96"></a><a
name="index-files_002c-_0040command_007bawk_007d-programs-in-97"></a>Sometimes
your <samp><span class="command">awk</span></samp> programs can be very long.
In this case, it is
-more convenient to put the program into a separate file. In order to tell
-<samp><span class="command">awk</span></samp> to use that file for its
program, you type:
-
-<pre class="example"> awk -f <var>source-file</var> <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p><a name="index-_0040code_007b_002df_007d-option-98"></a><a
name="index-command-line_002c-options-99"></a><a
name="index-options_002c-command_002dline-100"></a>The <samp><span
class="option">-f</span></samp> instructs the <samp><span
class="command">awk</span></samp> utility to get the <samp><span
class="command">awk</span></samp> program
-from the file <var>source-file</var>. Any file name can be used for
-<var>source-file</var>. For example, you could put the program:
-
-<pre class="example"> BEGIN { print "Don't Panic!" }
-</pre>
- <p class="noindent">into the file <samp><span
class="file">advice</span></samp>. Then this command:
-
-<pre class="example"> awk -f advice
-</pre>
- <p class="noindent">does the same thing as this one:
-
-<pre class="example"> awk "BEGIN { print \"Don't Panic!\" }"
-</pre>
- <p><a name="index-quoting-101"></a>This was explained earlier
-(see <a href="Read-Terminal.html#Read-Terminal">Read Terminal</a>).
-Note that you don't usually need single quotes around the file name that you
-specify with <samp><span class="option">-f</span></samp>, because most file
names don't contain any of the shell's
-special characters. Notice that in <samp><span
class="file">advice</span></samp>, the <samp><span
class="command">awk</span></samp>
-program did not have single quotes around it. The quotes are only needed
-for programs that are provided on the <samp><span
class="command">awk</span></samp> command line.
-
-<!-- STARTOFRANGE sq1x -->
-<p><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029-102"></a><!--
STARTOFRANGE qs2x -->
-<a name="index-_0040code_007b_0027_007d-_0028single-quote_0029-103"></a>If you
want to identify your <samp><span class="command">awk</span></samp> program
files clearly as such,
-you can add the extension <samp><span class="file">.awk</span></samp> to the
file name. This doesn't
-affect the execution of the <samp><span class="command">awk</span></samp>
program but it does make
-“housekeeping” easier.
-
- </body></html>
-
Index: manual/html_node/Manual-History.html
===================================================================
RCS file: manual/html_node/Manual-History.html
diff -N manual/html_node/Manual-History.html
--- manual/html_node/Manual-History.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,157 +0,0 @@
-<html lang="en">
-<head>
-<title>Manual History - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="prev" href="Conventions.html#Conventions" title="Conventions">
-<link rel="next" href="How-To-Contribute.html#How-To-Contribute" title="How To
Contribute">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Manual-History"></a>Next: <a rel="next" accesskey="n"
href="How-To-Contribute.html#How-To-Contribute">How To Contribute</a>,
-Previous: <a rel="previous" accesskey="p"
href="Conventions.html#Conventions">Conventions</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="unnumberedsec">The GNU Project and This Book</h3>
-
-<p><a name="index-FSF-_0028Free-Software-Foundation_0029-32"></a><a
name="index-Free-Software-Foundation-_0028FSF_0029-33"></a><a
name="index-Stallman_002c-Richard-34"></a>The Free Software Foundation (FSF) is
a nonprofit organization dedicated
-to the production and distribution of freely distributable software.
-It was founded by Richard M. Stallman, the author of the original
-Emacs editor. GNU Emacs is the most widely used version of Emacs today.
-
- <p><a name="index-GNU-Project-35"></a><a
name="index-GPL-_0028General-Public-License_0029-36"></a><a
name="index-General-Public-License_002c-See-GPL-37"></a><a
name="index-documentation_002c-online-38"></a>The GNU<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a>
-Project is an ongoing effort on the part of the Free Software
-Foundation to create a complete, freely distributable, POSIX-compliant
-computing environment.
-The FSF uses the “GNU General Public License” (GPL) to ensure that
-their software's
-source code is always available to the end user. A
-copy of the GPL is included
-in this Web page
-for your reference
-(see <a href="Copying.html#Copying">Copying</a>).
-The GPL applies to the C language source code for <samp><span
class="command">gawk</span></samp>.
-To find out more about the FSF and the GNU Project online,
-see <a href="http://www.gnu.org">the GNU Project's home page</a>.
-This Web page may also be read from
-<a href="http://www.gnu.org/manual/gawk/">their web site</a>.
-
- <p>A shell, an editor (Emacs), highly portable optimizing C, C++, and
-Objective-C compilers, a symbolic debugger and dozens of large and
-small utilities (such as <samp><span class="command">gawk</span></samp>), have
all been completed and are
-freely available. The GNU operating
-system kernel (the HURD), has been released but is still in an early
-stage of development.
-
- <p><a name="index-Linux-39"></a><a name="index-GNU_002fLinux-40"></a><a
name="index-operating-systems_002c-BSD_002dbased-41"></a><a
name="index-Alpha-_0028DEC_0029-42"></a>Until the GNU operating system is more
fully developed, you should
-consider using GNU/Linux, a freely distributable, Unix-like operating
-system for Intel 80386, DEC Alpha, Sun SPARC, IBM S/390, and other
-systems.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
-There are
-many books on GNU/Linux. One that is freely available is <cite>Linux
-Installation and Getting Started</cite>, by Matt Welsh.
-Many GNU/Linux distributions are often available in computer stores or
-bundled on CD-ROMs with books about Linux.
-(There are three other freely available, Unix-like operating systems for
-80386 and other systems: NetBSD, FreeBSD, and OpenBSD. All are based on the
-4.4-Lite Berkeley Software Distribution, and they use recent versions
-of <samp><span class="command">gawk</span></samp> for their versions of
<samp><span class="command">awk</span></samp>.)
-
- <p>The Web page you are reading is actually free—at least, the
-information in it is free to anyone. The machine-readable
-source code for the Web page comes with <samp><span
class="command">gawk</span></samp>; anyone
-may take this Web page to a copying machine and make as many
-copies as they like. (Take a moment to check the Free Documentation
-License in <a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>.)
-
- <p>Although you could just print it out yourself, bound books are much
-easier to read and use. Furthermore,
-the proceeds from sales of this book go back to the FSF
-to help fund development of more free software.
-
- <p><a name="index-Close_002c-Diane-43"></a>The Web page itself has gone
through a number of previous editions.
-Paul Rubin wrote the very first draft of <cite>The GAWK Manual</cite>;
-it was around 40 pages in size.
-Diane Close and Richard Stallman improved it, yielding a
-version that was
-around 90 pages long and barely described the original, “old”
-version of <samp><span class="command">awk</span></samp>.
-
- <p>I started working with that version in the fall of 1988.
-As work on it progressed,
-the FSF published several preliminary versions (numbered 0.<var>x</var>).
-In 1996, Edition 1.0 was released with <samp><span
class="command">gawk</span></samp> 3.0.0.
-The FSF published the first two editions under
-the title <cite>The GNU Awk User's Guide</cite>.
-
- <p>This edition maintains the basic structure of Edition 1.0,
-but with significant additional material, reflecting the host of new features
-in <samp><span class="command">gawk</span></samp> version 3.1.
-Of particular note is
-<a href="Array-Sorting.html#Array-Sorting">Array Sorting</a>,
-as well as
-<a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>,
-<a
href="Internationalization.html#Internationalization">Internationalization</a>,
-and also
-<a href="Advanced-Features.html#Advanced-Features">Advanced Features</a>,
-and
-<a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a>.
-
- <p><cite>GAWK: Effective AWK Programming</cite> will undoubtedly continue
to evolve.
-An electronic version
-comes with the <samp><span class="command">gawk</span></samp> distribution
from the FSF.
-If you find an error in this Web page, please report it!
-See <a href="Bugs.html#Bugs">Bugs</a>, for information on submitting
-problem reports electronically, or write to me in care of the publisher.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> GNU stands for “GNU's not Unix.”</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> The
terminology “GNU/Linux” is explained
-in the <a href="Glossary.html#Glossary">Glossary</a>.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Miscellaneous-Programs.html
===================================================================
RCS file: manual/html_node/Miscellaneous-Programs.html
diff -N manual/html_node/Miscellaneous-Programs.html
--- manual/html_node/Miscellaneous-Programs.html 31 Aug 2004 22:04:11
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-<html lang="en">
-<head>
-<title>Miscellaneous Programs - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Sample-Programs.html#Sample-Programs" title="Sample
Programs">
-<link rel="prev" href="Clones.html#Clones" title="Clones">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Miscellaneous-Programs"></a>Previous: <a rel="previous"
accesskey="p" href="Clones.html#Clones">Clones</a>,
-Up: <a rel="up" accesskey="u"
href="Sample-Programs.html#Sample-Programs">Sample Programs</a>
-<hr><br>
-</div>
-
-<h3 class="section">13.3 A Grab Bag of <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<p>This section is a large “grab bag” of miscellaneous programs.
-We hope you find them both interesting and enjoyable.
-
-<ul class="menu">
-<li><a accesskey="1" href="Dupword-Program.html#Dupword-Program">Dupword
Program</a>: Finding duplicated words in a document.
-<li><a accesskey="2" href="Alarm-Program.html#Alarm-Program">Alarm
Program</a>: An alarm clock.
-<li><a accesskey="3" href="Translate-Program.html#Translate-Program">Translate
Program</a>: A program similar to the <samp><span
class="command">tr</span></samp> utility.
-<li><a accesskey="4" href="Labels-Program.html#Labels-Program">Labels
Program</a>: Printing mailing labels.
-<li><a accesskey="5" href="Word-Sorting.html#Word-Sorting">Word Sorting</a>:
A program to produce a word usage count.
-<li><a accesskey="6" href="History-Sorting.html#History-Sorting">History
Sorting</a>: Eliminating duplicate entries from a history
- file.
-<li><a accesskey="7" href="Extract-Program.html#Extract-Program">Extract
Program</a>: Pulling out programs from Texinfo source
- files.
-<li><a accesskey="8" href="Simple-Sed.html#Simple-Sed">Simple Sed</a>:
A Simple Stream Editor.
-<li><a accesskey="9" href="Igawk-Program.html#Igawk-Program">Igawk
Program</a>: A wrapper for <samp><span
class="command">awk</span></samp> that includes
- files.
-</ul>
-
- </body></html>
-
Index: manual/html_node/More-Complex.html
===================================================================
RCS file: manual/html_node/More-Complex.html
diff -N manual/html_node/More-Complex.html
--- manual/html_node/More-Complex.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,130 +0,0 @@
-<html lang="en">
-<head>
-<title>More Complex - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="Two-Rules.html#Two-Rules" title="Two Rules">
-<link rel="next" href="Statements_002fLines.html#Statements_002fLines"
title="Statements/Lines">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="More-Complex"></a>Next: <a rel="next" accesskey="n"
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>,
-Previous: <a rel="previous" accesskey="p"
href="Two-Rules.html#Two-Rules">Two Rules</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.5 A More Complex Example</h3>
-
-<p>Now that we've mastered some simple tasks, let's look at
-what typical <samp><span class="command">awk</span></samp>
-programs do. This example shows how <samp><span
class="command">awk</span></samp> can be used to
-summarize, select, and rearrange the output of another utility. It uses
-features that haven't been covered yet, so don't worry if you don't
-understand all the details:
-
-<pre class="example"> ls -l | awk '$6 == "Nov" { sum += $5 }
- END { print sum }'
-</pre>
- <p><a
name="index-_0040command_007bcsh_007d-utility_002c-backslash-continuation-and-144"></a><a
name="index-_0040command_007bls_007d-utility-145"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-146"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-147"></a>This
command prints the total number of bytes in all the files in the
-current directory that were last modified in November (of any year).
-<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-The `<samp><span class="samp">ls -l</span></samp>'<!-- /@w --> part of
this example is a system command that gives
-you a listing of the files in a directory, including each file's size and the
date
-the file was last modified. Its output looks like this:
-
-<pre class="example"> -rw-r--r-- 1 arnold user 1933 Nov 7 13:05
Makefile
- -rw-r--r-- 1 arnold user 10809 Nov 7 13:03 awk.h
- -rw-r--r-- 1 arnold user 983 Apr 13 12:14 awk.tab.h
- -rw-r--r-- 1 arnold user 31869 Jun 15 12:20 awk.y
- -rw-r--r-- 1 arnold user 22414 Nov 7 13:03 awk1.c
- -rw-r--r-- 1 arnold user 37455 Nov 7 13:03 awk2.c
- -rw-r--r-- 1 arnold user 27511 Dec 9 13:07 awk3.c
- -rw-r--r-- 1 arnold user 7989 Nov 7 13:03 awk4.c
-</pre>
- <p class="noindent"><a
name="index-line-continuations_002c-with-C-shell-148"></a>The first field
contains read-write permissions, the second field contains
-the number of links to the file, and the third field identifies the owner of
-the file. The fourth field identifies the group of the file.
-The fifth field contains the size of the file in bytes. The
-sixth, seventh, and eighth fields contain the month, day, and time,
-respectively, that the file was last modified. Finally, the ninth field
-contains the name of the file.<a rel="footnote" href="#fn-2"
name="fnd-2"><sup>2</sup></a>
-
-<!-- @cindex automatic initialization -->
-<p><a name="index-initialization_002c-automatic-149"></a>The `<samp><span
class="samp">$6 == "Nov"</span></samp>' in our <samp><span
class="command">awk</span></samp> program is an expression that
-tests whether the sixth field of the output from `<samp><span
class="samp">ls -l</span></samp>'<!-- /@w -->
-matches the string `<samp><span class="samp">Nov</span></samp>'. Each time a
line has the string
-`<samp><span class="samp">Nov</span></samp>' for its sixth field, the action
`<samp><span class="samp">sum += $5</span></samp>' is
-performed. This adds the fifth field (the file's size) to the variable
-<code>sum</code>. As a result, when <samp><span
class="command">awk</span></samp> has finished reading all the
-input lines, <code>sum</code> is the total of the sizes of the files whose
-lines matched the pattern. (This works because <samp><span
class="command">awk</span></samp> variables
-are automatically initialized to zero.)
-
- <p>After the last line of output from <samp><span
class="command">ls</span></samp> has been processed, the
-<code>END</code> rule executes and prints the value of <code>sum</code>.
-In this example, the value of <code>sum</code> is 80600.
-
- <p>These more advanced <samp><span class="command">awk</span></samp>
techniques are covered in later sections
-(see <a href="Action-Overview.html#Action-Overview">Action Overview</a>).
Before you can move on to more
-advanced <samp><span class="command">awk</span></samp> programming, you have
to know how <samp><span class="command">awk</span></samp> interprets
-your input and displays your output. By manipulating fields and using
-<code>print</code> statements, you can produce some very useful and
-impressive-looking reports.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> In the C shell (<samp><span
class="command">csh</span></samp>), you need to type
-a semicolon and then a backslash at the end of the first line; see
-<a href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>,
for an
-explanation. In a POSIX-compliant shell, such as the Bourne
-shell or <samp><span class="command">bash</span></samp>, you can type the
example as shown. If the command
-`<samp><span class="samp">echo $path</span></samp>' produces an empty output
line, you are most likely
-using a POSIX-compliant shell. Otherwise, you are probably using the
-C shell or a shell derived from it.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> On
some
-very old systems, you may need to use `<samp><span class="samp">ls
-lg</span></samp>' to get this output.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Multi_002ddimensional.html
===================================================================
RCS file: manual/html_node/Multi_002ddimensional.html
diff -N manual/html_node/Multi_002ddimensional.html
--- manual/html_node/Multi_002ddimensional.html 31 Aug 2004 22:04:11 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-<html lang="en">
-<head>
-<title>Multi-dimensional - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Uninitialized-Subscripts.html#Uninitialized-Subscripts"
title="Uninitialized Subscripts">
-<link rel="next" href="Multi_002dscanning.html#Multi_002dscanning"
title="Multi-scanning">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Multi_002ddimensional"></a>Next: <a rel="next" accesskey="n"
href="Multi_002dscanning.html#Multi_002dscanning">Multi-scanning</a>,
-Previous: <a rel="previous" accesskey="p"
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.9 Multidimensional Arrays</h3>
-
-<p><a name="index-subscripts-in-arrays_002c-multidimensional-1127"></a><a
name="index-arrays_002c-multidimensional-1128"></a>A multidimensional array is
an array in which an element is identified
-by a sequence of indices instead of a single index. For example, a
-two-dimensional array requires two indices. The usual way (in most
-languages, including <samp><span class="command">awk</span></samp>) to refer
to an element of a
-two-dimensional array named <code>grid</code> is with
-<code>grid[</code><var>x</var><code>,</code><var>y</var><code>]</code>.
-
- <p><a
name="index-_0040code_007bSUBSEP_007d-variable_002c-multidimensional-arrays-1129"></a>Multidimensional
arrays are supported in <samp><span class="command">awk</span></samp> through
-concatenation of indices into one string.
-<samp><span class="command">awk</span></samp> converts the indices into strings
-(see <a href="Conversion.html#Conversion">Conversion</a>) and
-concatenates them together, with a separator between them. This creates
-a single string that describes the values of the separate indices. The
-combined string is used as a single index into an ordinary,
-one-dimensional array. The separator used is the value of the built-in
-variable <code>SUBSEP</code>.
-
- <p>For example, suppose we evaluate the expression `<samp><span
class="samp">foo[5,12] = "value"</span></samp>'
-when the value of <code>SUBSEP</code> is <code>"@"</code>. The numbers 5 and
12 are
-converted to strings and
-concatenated with an `<samp><span class="samp">@</span></samp>' between them,
yielding <code>"address@hidden"</code>; thus,
-the array element <code>foo["address@hidden"]</code> is set to
<code>"value"</code>.
-
- <p>Once the element's value is stored, <samp><span
class="command">awk</span></samp> has no record of whether
-it was stored with a single index or a sequence of indices. The two
-expressions `<samp><span class="samp">foo[5,12]</span></samp>' and
`<samp><span class="samp">foo[5 SUBSEP 12]</span></samp>'<!-- /@w -->
are always
-equivalent.
-
- <p>The default value of <code>SUBSEP</code> is the string
<code>"\034"</code>,
-which contains a nonprinting character that is unlikely to appear in an
-<samp><span class="command">awk</span></samp> program or in most input data.
-The usefulness of choosing an unlikely character comes from the fact
-that index values that contain a string matching <code>SUBSEP</code> can lead
to
-combined strings that are ambiguous. Suppose that <code>SUBSEP</code> is
-<code>"@"</code>; then `<samp><span
class="samp">foo["address@hidden", "c"]</span></samp>'<!-- /@w --> and
`<samp><span class="samp">foo["a", "address@hidden"]</span></samp>'<!--
/@w --> are indistinguishable because both are actually
-stored as `<samp><span class="samp">foo["address@hidden@c"]</span></samp>'.
-
- <p>To test whether a particular index sequence exists in a
-multidimensional array, use the same operator (`<samp><span
class="samp">in</span></samp>') that is
-used for single dimensional arrays. Write the whole sequence of indices
-in parentheses, separated by commas, as the left operand:
-
-<pre class="example"> (<var>subscript1</var>, <var>subscript2</var>, ...)
in <var>array</var>
-</pre>
- <p>The following example treats its input as a two-dimensional array of
-fields; it rotates this array 90 degrees clockwise and prints the
-result. It assumes that all lines have the same number of
-elements:
-
-<pre class="example"> {
- if (max_nf < NF)
- max_nf = NF
- max_nr = NR
- for (x = 1; x <= NF; x++)
- vector[x, NR] = $x
- }
-
- END {
- for (x = 1; x <= max_nf; x++) {
- for (y = max_nr; y >= 1; --y)
- printf("%s ", vector[x, y])
- printf("\n")
- }
- }
-</pre>
- <p class="noindent">When given the input:
-
-<pre class="example"> 1 2 3 4 5 6
- 2 3 4 5 6 1
- 3 4 5 6 1 2
- 4 5 6 1 2 3
-</pre>
- <p class="noindent">the program produces the following output:
-
-<pre class="example"> 4 3 2 1
- 5 4 3 2
- 6 5 4 3
- 1 6 5 4
- 2 1 6 5
- 3 2 1 6
-</pre>
- </body></html>
-
Index: manual/html_node/Multi_002dscanning.html
===================================================================
RCS file: manual/html_node/Multi_002dscanning.html
diff -N manual/html_node/Multi_002dscanning.html
--- manual/html_node/Multi_002dscanning.html 31 Aug 2004 22:04:11 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,95 +0,0 @@
-<html lang="en">
-<head>
-<title>Multi-scanning - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Multi_002ddimensional.html#Multi_002ddimensional"
title="Multi-dimensional">
-<link rel="next" href="Array-Sorting.html#Array-Sorting" title="Array Sorting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Multi_002dscanning"></a>Next: <a rel="next" accesskey="n"
href="Array-Sorting.html#Array-Sorting">Array Sorting</a>,
-Previous: <a rel="previous" accesskey="p"
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.10 Scanning Multidimensional Arrays</h3>
-
-<p>There is no special <code>for</code> statement for scanning a
-“multidimensional” array. There cannot be one, because, in truth,
there
-are no multidimensional arrays or elements—there is only a
-multidimensional <em>way of accessing</em> an array.
-
- <p><a
name="index-subscripts-in-arrays_002c-multidimensional_002c-scanning-1130"></a><a
name="index-arrays_002c-multidimensional_002c-scanning-1131"></a>However, if
your program has an array that is always accessed as
-multidimensional, you can get the effect of scanning it by combining
-the scanning <code>for</code> statement
-(see <a href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a>)
with the
-built-in <code>split</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-It works in the following manner:
-
-<pre class="example"> for (combined in array) {
- split(combined, separate, SUBSEP)
- ...
- }
-</pre>
- <p class="noindent">This sets the variable <code>combined</code> to
-each concatenated combined index in the array, and splits it
-into the individual indices by breaking it apart where the value of
-<code>SUBSEP</code> appears. The individual indices then become the elements
of
-the array <code>separate</code>.
-
- <p>Thus, if a value is previously stored in <code>array[1, "foo"]</code>;
then
-an element with index <code>"1\034foo"</code> exists in <code>array</code>.
(Recall
-that the default value of <code>SUBSEP</code> is the character with code 034.)
-Sooner or later, the <code>for</code> statement finds that index and does an
-iteration with the variable <code>combined</code> set to
<code>"1\034foo"</code>.
-Then the <code>split</code> function is called as follows:
-
-<pre class="example"> split("1\034foo", separate, "\034")
-</pre>
- <p class="noindent">The result is to set <code>separate[1]</code> to
<code>"1"</code> and
-<code>separate[2]</code> to <code>"foo"</code>. Presto! The original sequence
of
-separate indices is recovered.
-
- </body></html>
-
Index: manual/html_node/Multiple-Line.html
===================================================================
RCS file: manual/html_node/Multiple-Line.html
diff -N manual/html_node/Multiple-Line.html
--- manual/html_node/Multiple-Line.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,208 +0,0 @@
-<html lang="en">
-<head>
-<title>Multiple Line - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Constant-Size.html#Constant-Size" title="Constant Size">
-<link rel="next" href="Getline.html#Getline" title="Getline">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Multiple-Line"></a>Next: <a rel="next" accesskey="n"
href="Getline.html#Getline">Getline</a>,
-Previous: <a rel="previous" accesskey="p"
href="Constant-Size.html#Constant-Size">Constant Size</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.7 Multiple-Line Records</h3>
-
-<!-- STARTOFRANGE recm -->
-<p><a name="index-records_002c-multiline-445"></a><!-- STARTOFRANGE imr -->
-<a name="index-input_002c-multiline-records-446"></a><!-- STARTOFRANGE frm -->
-<a name="index-files_002c-reading_002c-multiline-records-447"></a><a
name="index-input_002c-files_002c-See-input-files-448"></a>In some databases, a
single line cannot conveniently hold all the
-information in one entry. In such cases, you can use multiline
-records. The first step in doing this is to choose your data format.
-
- <p><a
name="index-record-separators_002c-with-multiline-records-449"></a>One
technique is to use an unusual character or string to separate
-records. For example, you could use the formfeed character (written
-`<samp><span class="samp">\f</span></samp>' in <samp><span
class="command">awk</span></samp>, as in C) to separate them, making each record
-a page of the file. To do this, just set the variable <code>RS</code> to
-<code>"\f"</code> (a string containing the formfeed character). Any
-other character could equally well be used, as long as it won't be part
-of the data in a record.
-
- <p><a
name="index-_0040code_007bRS_007d-variable_002c-multiline-records-and-450"></a>Another
technique is to have blank lines separate records. By a special
-dispensation, an empty string as the value of <code>RS</code> indicates that
-records are separated by one or more blank lines. When <code>RS</code> is set
-to the empty string, each record always ends at the first blank line
-encountered. The next record doesn't start until the first nonblank
-line that follows. No matter how many blank lines appear in a row, they
-all act as one record separator.
-(Blank lines must be completely empty; lines that contain only
-whitespace do not count.)
-
- <p><a name="index-leftmost-longest-match-451"></a><a
name="index-matching_002c-leftmost-longest-452"></a>You can achieve the same
effect as `<samp><span class="samp">RS = ""</span></samp>' by assigning the
-string <code>"\n\n+"</code> to <code>RS</code>. This regexp matches the newline
-at the end of the record and one or more blank lines after the record.
-In addition, a regular expression always matches the longest possible
-sequence when there is a choice
-(see <a href="Leftmost-Longest.html#Leftmost-Longest">Leftmost Longest</a>).
-So the next record doesn't start until
-the first nonblank line that follows—no matter how many blank lines
-appear in a row, they are considered one record separator.
-
- <p><a name="index-dark-corner_002c-multiline-records-453"></a>There is an
important difference between `<samp><span class="samp">RS = ""</span></samp>'
and
-`<samp><span class="samp">RS = "\n\n+"</span></samp>'. In the first case,
leading newlines in the input
-data file are ignored, and if a file ends without extra blank lines
-after the last record, the final newline is removed from the record.
-In the second case, this special processing is not done.
-(d.c.)
-
- <p><a name="index-field-separators_002c-in-multiline-records-454"></a>Now
that the input is separated into records, the second step is to
-separate the fields in the record. One way to do this is to divide each
-of the lines into fields in the normal manner. This happens by default
-as the result of a special feature. When <code>RS</code> is set to the empty
-string, <em>and</em> <code>FS</code> is a set to a single character,
-the newline character <em>always</em> acts as a field separator.
-This is in addition to whatever field separations result from
-<code>FS</code>.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p>The original motivation for this special exception was probably to
provide
-useful behavior in the default case (i.e., <code>FS</code> is equal
-to <code>" "</code><!-- /@w -->). This feature can be a problem if you
really don't
-want the newline character to separate fields, because there is no way to
-prevent it. However, you can work around this by using the <code>split</code>
-function to break up the record manually
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-If you have a single character field separator, you can work around
-the special feature in a different way, by making <code>FS</code> into a
-regexp for that single character. For example, if the field
-separator is a percent character, instead of
-`<samp><span class="samp">FS = "%"</span></samp>', use `<samp><span
class="samp">FS = "[%]"</span></samp>'.
-
- <p>Another way to separate fields is to
-put each field on a separate line: to do this, just set the
-variable <code>FS</code> to the string <code>"\n"</code>. (This single
-character seperator matches a single newline.)
-A practical example of a data file organized this way might be a mailing
-list, where each entry is separated by blank lines. Consider a mailing
-list in a file named <samp><span class="file">addresses</span></samp>, which
looks like this:
-
-<pre class="example"> Jane Doe
- 123 Main Street
- Anywhere, SE 12345-6789
-
- John Smith
- 456 Tree-lined Avenue
- Smallville, MW 98765-4321
- ...
-</pre>
- <p class="noindent">A simple program to process this file is as follows:
-
-<pre class="example"> # addrs.awk --- simple mailing list program
-
- # Records are separated by blank lines.
- # Each line is one field.
- BEGIN { RS = "" ; FS = "\n" }
-
- {
- print "Name is:", $1
- print "Address is:", $2
- print "City and State are:", $3
- print ""
- }
-</pre>
- <p>Running the program produces the following output:
-
-<pre class="example"> $ awk -f addrs.awk addresses
- -| Name is: Jane Doe
- -| Address is: 123 Main Street
- -| City and State are: Anywhere, SE 12345-6789
- -|
- -| Name is: John Smith
- -| Address is: 456 Tree-lined Avenue
- -| City and State are: Smallville, MW 98765-4321
- -|
- ...
-</pre>
- <p>See <a href="Labels-Program.html#Labels-Program">Labels Program</a>, for
a more realistic
-program that deals with address lists.
-The following
-table
-summarizes how records are split, based on the
-value of
-<code>RS</code>:
-
- <dl>
-<dt><code>RS == "\n"</code><dd>Records are separated by the newline character
(`<samp><span class="samp">\n</span></samp>'). In effect,
-every line in the data file is a separate record, including blank lines.
-This is the default.
-
- <br><dt><code>RS == </code><var>any single character</var><dd>Records are
separated by each occurrence of the character. Multiple
-successive occurrences delimit empty records.
-
- <br><dt><code>RS == ""</code><dd>Records are separated by runs of blank
lines. The newline character
-always serves as a field separator, in addition to whatever value
-<code>FS</code> may have. Leading and trailing newlines in a file are ignored.
-
- <br><dt><code>RS == </code><var>regexp</var><dd>Records are separated by
occurrences of characters that match <var>regexp</var>.
-Leading and trailing matches of <var>regexp</var> delimit empty records.
-(This is a <samp><span class="command">gawk</span></samp> extension; it is not
specified by the
-POSIX standard.)
-</dl>
-
- <p><a name="index-_0040code_007bRT_007d-variable-455"></a>In all cases,
<samp><span class="command">gawk</span></samp> sets <code>RT</code> to the
input text that matched the
-value specified by <code>RS</code>.
-<!-- ENDOFRANGE recm -->
-<!-- ENDOFRANGE imr -->
-<!-- ENDOFRANGE frm -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> When <code>FS</code> is the null string
(<code>""</code>)
-or a regexp, this special feature of <code>RS</code> does not apply.
-It does apply to the default field separator of a single space:
-`<samp><span class="samp">FS = " "</span></samp>'.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Names.html
===================================================================
RCS file: manual/html_node/Names.html
diff -N manual/html_node/Names.html
--- manual/html_node/Names.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,94 +0,0 @@
-<html lang="en">
-<head>
-<title>Names - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="prev" href="History.html#History" title="History">
-<link rel="next" href="This-Manual.html#This-Manual" title="This Manual">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Names"></a>Next: <a rel="next" accesskey="n"
href="This-Manual.html#This-Manual">This Manual</a>,
-Previous: <a rel="previous" accesskey="p"
href="History.html#History">History</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="section">A Rose by Any Other Name</h3>
-
-<p><a name="index-_0040command_007bawk_007d_002c-new-vs_002e-old-20"></a>The
<samp><span class="command">awk</span></samp> language has evolved over the
years. Full details are
-provided in <a href="Language-History.html#Language-History">Language
History</a>.
-The language described in this Web page
-is often referred to as “new <samp><span
class="command">awk</span></samp>” (<samp><span
class="command">nawk</span></samp>).
-
- <p><a
name="index-_0040command_007bawk_007d_002c-versions-of-21"></a>Because of this,
many systems have multiple
-versions of <samp><span class="command">awk</span></samp>.
-Some systems have an <samp><span class="command">awk</span></samp> utility
that implements the
-original version of the <samp><span class="command">awk</span></samp> language
and a <samp><span class="command">nawk</span></samp> utility
-for the new
-version.
-Others have an <samp><span class="command">oawk</span></samp> version for the
“old <samp><span class="command">awk</span></samp>”
-language and plain <samp><span class="command">awk</span></samp> for the new
one. Still others only
-have one version, which is usually the new one.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
- <p><a name="index-_0040command_007bnawk_007d-utility-22"></a><a
name="index-_0040command_007boawk_007d-utility-23"></a>All in all, this makes
it difficult for you to know which version of
-<samp><span class="command">awk</span></samp> you should run when writing your
programs. The best advice
-I can give here is to check your local documentation. Look for <samp><span
class="command">awk</span></samp>,
-<samp><span class="command">oawk</span></samp>, and <samp><span
class="command">nawk</span></samp>, as well as for <samp><span
class="command">gawk</span></samp>.
-It is likely that you already
-have some version of new <samp><span class="command">awk</span></samp> on your
system, which is what
-you should use when running your programs. (Of course, if you're reading
-this Web page, chances are good that you have <samp><span
class="command">gawk</span></samp>!)
-
- <p>Throughout this Web page, whenever we refer to a language feature
-that should be available in any complete implementation of POSIX <samp><span
class="command">awk</span></samp>,
-we simply use the term <samp><span class="command">awk</span></samp>. When
referring to a feature that is
-specific to the GNU implementation, we use the term <samp><span
class="command">gawk</span></samp>.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Often, these systems
-use <samp><span class="command">gawk</span></samp> for their <samp><span
class="command">awk</span></samp> implementation!</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/New-Ports.html
===================================================================
RCS file: manual/html_node/New-Ports.html
diff -N manual/html_node/New-Ports.html
--- manual/html_node/New-Ports.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,134 +0,0 @@
-<html lang="en">
-<head>
-<title>New Ports - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Additions.html#Additions" title="Additions">
-<link rel="prev" href="Adding-Code.html#Adding-Code" title="Adding Code">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="New-Ports"></a>Previous: <a rel="previous" accesskey="p"
href="Adding-Code.html#Adding-Code">Adding Code</a>,
-Up: <a rel="up" accesskey="u"
href="Additions.html#Additions">Additions</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">C.2.2 Porting <samp><span
class="command">gawk</span></samp> to a New Operating System</h4>
-
-<p><a name="index-portability_002c-_0040command_007bgawk_007d-1960"></a><a
name="index-operating-systems_002c-porting-_0040command_007bgawk_007d-to-1961"></a>
-<a name="index-porting-_0040command_007bgawk_007d-1962"></a>If you want to
port <samp><span class="command">gawk</span></samp> to a new operating system,
there are
-several steps:
-
- <ol type=1 start=1>
-<li>Follow the guidelines in
-the previous section
-concerning coding style, submission of diffs, and so on.
-
- <li>When doing a port, bear in mind that your code must coexist peacefully
-with the rest of <samp><span class="command">gawk</span></samp> and the other
ports. Avoid gratuitous
-changes to the system-independent parts of the code. If at all possible,
-avoid sprinkling `<samp><span class="samp">#ifdef</span></samp>'s just for
your port throughout the
-code.
-
- <p>If the changes needed for a particular system affect too much of the
-code, I probably will not accept them. In such a case, you can, of course,
-distribute your changes on your own, as long as you comply
-with the GPL
-(see <a href="Copying.html#Copying">Copying</a>).
-
- <li>A number of the files that come with <samp><span
class="command">gawk</span></samp> are maintained by other
-people at the Free Software Foundation. Thus, you should not change them
-unless it is for a very good reason; i.e., changes are not out of the
-question, but changes to these files are scrutinized extra carefully.
-The files are <samp><span class="file">getopt.h</span></samp>, <samp><span
class="file">getopt.c</span></samp>,
-<samp><span class="file">getopt1.c</span></samp>, <samp><span
class="file">regex.h</span></samp>, <samp><span
class="file">regex.c</span></samp>, <samp><span
class="file">dfa.h</span></samp>,
-<samp><span class="file">dfa.c</span></samp>, <samp><span
class="file">install-sh</span></samp>, and <samp><span
class="file">mkinstalldirs</span></samp>.
-
- <li>Be willing to continue to maintain the port.
-Non-Unix operating systems are supported by volunteers who maintain
-the code needed to compile and run <samp><span
class="command">gawk</span></samp> on their systems. If noone
-volunteers to maintain a port, it becomes unsupported and it may
-be necessary to remove it from the distribution.
-
- <li>Supply an appropriate <samp><span
class="file">gawkmisc.???</span></samp> file.
-Each port has its own <samp><span class="file">gawkmisc.???</span></samp> that
implements certain
-operating system specific functions. This is cleaner than a plethora of
-`<samp><span class="samp">#ifdef</span></samp>'s scattered throughout the
code. The <samp><span class="file">gawkmisc.c</span></samp> in
-the main source directory includes the appropriate
-<samp><span class="file">gawkmisc.???</span></samp> file from each
subdirectory.
-Be sure to update it as well.
-
- <p>Each port's <samp><span class="file">gawkmisc.???</span></samp> file
has a suffix reminiscent of the machine
-or operating system for the port—for example, <samp><span
class="file">pc/gawkmisc.pc</span></samp> and
-<samp><span class="file">vms/gawkmisc.vms</span></samp>. The use of separate
suffixes, instead of plain
-<samp><span class="file">gawkmisc.c</span></samp>, makes it possible to move
files from a port's subdirectory
-into the main subdirectory, without accidentally destroying the real
-<samp><span class="file">gawkmisc.c</span></samp> file. (Currently, this is
only an issue for the
-PC operating system ports.)
-
- <li>Supply a <samp><span class="file">Makefile</span></samp> as well as
any other C source and header files that are
-necessary for your operating system. All your code should be in a
-separate subdirectory, with a name that is the same as, or reminiscent
-of, either your operating system or the computer system. If possible,
-try to structure things so that it is not necessary to move files out
-of the subdirectory into the main source directory. If that is not
-possible, then be sure to avoid using names for your files that
-duplicate the names of files in the main source directory.
-
- <li>Update the documentation.
-Please write a section (or sections) for this Web page describing the
-installation and compilation steps needed to compile and/or install
-<samp><span class="command">gawk</span></samp> for your system.
-
- <li>Be prepared to sign the appropriate paperwork.
-In order for the FSF to distribute your code, you must either place
-your code in the public domain and submit a signed statement to that
-effect, or assign the copyright in your code to the FSF.
- </ol>
-
- <p>Following these steps makes it much easier to integrate your changes
-into <samp><span class="command">gawk</span></samp> and have them coexist
happily with other
-operating systems' code that is already there.
-
- <p>In the code that you supply and maintain, feel free to use a
-coding style and brace layout that suits your taste.
-
- </body></html>
-
Index: manual/html_node/Next-Statement.html
===================================================================
RCS file: manual/html_node/Next-Statement.html
diff -N manual/html_node/Next-Statement.html
--- manual/html_node/Next-Statement.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-<html lang="en">
-<head>
-<title>Next Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="Continue-Statement.html#Continue-Statement"
title="Continue Statement">
-<link rel="next" href="Nextfile-Statement.html#Nextfile-Statement"
title="Nextfile Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Next-Statement"></a>Next: <a rel="next" accesskey="n"
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="Continue-Statement.html#Continue-Statement">Continue Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.8 The <code>next</code> Statement</h4>
-
-<p><a name="index-_0040code_007bnext_007d-statement-970"></a>
-The <code>next</code> statement forces <samp><span
class="command">awk</span></samp> to immediately stop processing
-the current record and go on to the next record. This means that no
-further rules are executed for the current record, and the rest of the
-current rule's action isn't executed.
-
- <p>Contrast this with the effect of the <code>getline</code> function
-(see <a href="Getline.html#Getline">Getline</a>). That also causes
-<samp><span class="command">awk</span></samp> to read the next record
immediately, but it does not alter the
-flow of control in any way (i.e., the rest of the current action executes
-with a new input record).
-
- <p><a
name="index-_0040command_007bawk_007d-programs_002c-execution-of-971"></a>At
the highest level, <samp><span class="command">awk</span></samp> program
execution is a loop that reads
-an input record and then tests each rule's pattern against it. If you
-think of this loop as a <code>for</code> statement whose body contains the
-rules, then the <code>next</code> statement is analogous to a
<code>continue</code>
-statement. It skips to the end of the body of this implicit loop and
-executes the increment (which reads another record).
-
- <p>For example, suppose an <samp><span class="command">awk</span></samp>
program works only on records
-with four fields, and it shouldn't fail when given bad input. To avoid
-complicating the rest of the program, write a “weed out” rule near
-the beginning, in the following manner:
-
-<pre class="example"> NF != 4 {
- err = sprintf("%s:%d: skipped: NF != 4\n", FILENAME, FNR)
- print err > "/dev/stderr"
- next
- }
-</pre>
- <p class="noindent">Because of the <code>next</code> statement,
-the program's subsequent rules won't see the bad record. The error
-message is redirected to the standard error output stream, as error
-messages should be.
-For more detail see
-<a href="Special-Files.html#Special-Files">Special Files</a>.
-
-<!-- @cindex @command{awk} language, POSIX version -->
-<!-- @cindex @code{next}, inside a user-defined function -->
-<p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-972"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-973"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-974"></a><a
name="index-_0040code_007bnext_007d-statement_002c-user_002ddefined-functions-and-975"></a><a
name="index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-976"></a>According
to the POSIX standard, the behavior is undefined if
-the <code>next</code> statement is used in a <code>BEGIN</code> or
<code>END</code> rule.
-<samp><span class="command">gawk</span></samp> treats it as a syntax error.
-Although POSIX permits it,
-some other <samp><span class="command">awk</span></samp> implementations don't
allow the <code>next</code>
-statement inside function bodies
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>).
-Just as with any other <code>next</code> statement, a <code>next</code>
statement inside a
-function body reads the next record and starts processing it with the
-first rule in the program.
-If the <code>next</code> statement causes the end of the input to be reached,
-then the code in any <code>END</code> rules is executed.
-See <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>.
-
- </body></html>
-
Index: manual/html_node/Nextfile-Function.html
===================================================================
RCS file: manual/html_node/Nextfile-Function.html
diff -N manual/html_node/Nextfile-Function.html
--- manual/html_node/Nextfile-Function.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,158 +0,0 @@
-<html lang="en">
-<head>
-<title>Nextfile Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="next" href="Strtonum-Function.html#Strtonum-Function"
title="Strtonum Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Nextfile-Function"></a>Next: <a rel="next" accesskey="n"
href="Strtonum-Function.html#Strtonum-Function">Strtonum Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.1 Implementing <code>nextfile</code> as a
Function</h4>
-
-<p><a name="index-input-files_002c-skipping-1613"></a><!-- STARTOFRANGE
libfnex -->
-<a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-_0040code_007bnextfile_007d-statement-1614"></a><!--
STARTOFRANGE flibnex -->
-<a
name="index-functions_002c-library_002c-_0040code_007bnextfile_007d-statement-1615"></a><!--
STARTOFRANGE nexim -->
-<a
name="index-_0040code_007bnextfile_007d-statement_002c-implementing-1616"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-1617"></a>The
<code>nextfile</code> statement, presented in
-<a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a>,
-is a <samp><span class="command">gawk</span></samp>-specific
extension—it is not available in most other
-implementations of <samp><span class="command">awk</span></samp>. This
section shows two versions of a
-<code>nextfile</code> function that you can use to simulate <samp><span
class="command">gawk</span></samp>'s
-<code>nextfile</code> statement if you cannot use <samp><span
class="command">gawk</span></samp>.
-
- <p>A first attempt at writing a <code>nextfile</code> function is as
follows:
-
-<pre class="example"> # nextfile --- skip remaining records in current file
- # this should be read in before the "main" awk program
-
- function nextfile() { _abandon_ = FILENAME; next }
- _abandon_ == FILENAME { next }
-</pre>
- <p><a
name="index-programming-conventions_002c-_0040code_007bnextfile_007d-statement-1618"></a>Because
it supplies a rule that must be executed first, this file should
-be included before the main program. This rule compares the current
-data file's name (which is always in the <code>FILENAME</code> variable) to
-a private variable named <code>_abandon_</code>. If the file name matches,
-then the action part of the rule executes a <code>next</code> statement to
-go on to the next record. (The use of `<samp><span
class="samp">_</span></samp>' in the variable name is
-a convention. It is discussed more fully in
-<a href="Library-Names.html#Library-Names">Library Names</a>.)
-
- <p>The use of the <code>next</code> statement effectively creates a loop
that reads
-all the records from the current data file.
-The end of the file is eventually reached and
-a new data file is opened, changing the value of <code>FILENAME</code>.
-Once this happens, the comparison of <code>_abandon_</code> to
<code>FILENAME</code>
-fails, and execution continues with the first rule of the “real”
program.
-
- <p>The <code>nextfile</code> function itself simply sets the value of
<code>_abandon_</code>
-and then executes a <code>next</code> statement to start the
-loop.
-
- <p><a
name="index-_0040code_007bnextfile_007d-user_002ddefined-function-1619"></a>This
initial version has a subtle problem.
-If the same data file is listed <em>twice</em> on the commandline,
-one right after the other
-or even with just a variable assignment between them,
-this code skips right through the file a second time, even though
-it should stop when it gets to the end of the first occurrence.
-A second version of <code>nextfile</code> that remedies this problem
-is shown here:
-
-<pre class="example"> <!-- file eg/lib/nextfile.awk -->
- # nextfile --- skip remaining records in current file
- # correctly handle successive occurrences of the same file
- <!-- endfile -->
- <!-- file eg/lib/nextfile.awk -->
- # this should be read in before the "main" awk program
-
- function nextfile() { _abandon_ = FILENAME; next }
-
- _abandon_ == FILENAME {
- if (FNR == 1)
- _abandon_ = ""
- else
- next
- }
- <!-- endfile -->
-</pre>
- <p>The <code>nextfile</code> function has not changed. It makes
<code>_abandon_</code>
-equal to the current file name and then executes a <code>next</code>
statement.
-The <code>next</code> statement reads the next record and increments
<code>FNR</code>
-so that <code>FNR</code> is guaranteed to have a value of at least two.
-However, if <code>nextfile</code> is called for the last record in the file,
-then <samp><span class="command">awk</span></samp> closes the current data
file and moves on to the next
-one. Upon doing so, <code>FILENAME</code> is set to the name of the new file
-and <code>FNR</code> is reset to one. If this next file is the same as
-the previous one, <code>_abandon_</code> is still equal to
<code>FILENAME</code>.
-However, <code>FNR</code> is equal to one, telling us that this is a new
-occurrence of the file and not the one we were reading when the
-<code>nextfile</code> function was executed. In that case,
<code>_abandon_</code>
-is reset to the empty string, so that further executions of this rule
-fail (until the next time that <code>nextfile</code> is called).
-
- <p>If <code>FNR</code> is not one, then we are still in the original data
file
-and the program executes a <code>next</code> statement to skip through it.
-
- <p>An important question to ask at this point is: given that the
-functionality of <code>nextfile</code> can be provided with a library file,
-why is it built into <samp><span class="command">gawk</span></samp>? Adding
-features for little reason leads to larger, slower programs that are
-harder to maintain.
-The answer is that building <code>nextfile</code> into <samp><span
class="command">gawk</span></samp> provides
-significant gains in efficiency. If the <code>nextfile</code> function is
executed
-at the beginning of a large data file, <samp><span
class="command">awk</span></samp> still has to scan the entire
-file, splitting it up into records,
-<!-- at least conceptually -->
-just to skip over it. The built-in
-<code>nextfile</code> can simply close the file immediately and proceed to the
-next one, which saves a lot of time. This is particularly important in
-<samp><span class="command">awk</span></samp>, because <samp><span
class="command">awk</span></samp> programs are generally I/O-bound (i.e.,
-they spend most of their time doing input and output, instead of performing
-computations).
-<!-- ENDOFRANGE libfnex -->
-<!-- ENDOFRANGE flibnex -->
-<!-- ENDOFRANGE nexim -->
-
- </body></html>
-
Index: manual/html_node/Nextfile-Statement.html
===================================================================
RCS file: manual/html_node/Nextfile-Statement.html
diff -N manual/html_node/Nextfile-Statement.html
--- manual/html_node/Nextfile-Statement.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,115 +0,0 @@
-<html lang="en">
-<head>
-<title>Nextfile Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="Next-Statement.html#Next-Statement" title="Next
Statement">
-<link rel="next" href="Exit-Statement.html#Exit-Statement" title="Exit
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Nextfile-Statement"></a>Next: <a rel="next" accesskey="n"
href="Exit-Statement.html#Exit-Statement">Exit Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="Next-Statement.html#Next-Statement">Next Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.9 Using <samp><span
class="command">gawk</span></samp>'s <code>nextfile</code> Statement</h4>
-
-<p><a name="index-_0040code_007bnextfile_007d-statement-977"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-978"></a>
-<samp><span class="command">gawk</span></samp> provides the
<code>nextfile</code> statement,
-which is similar to the <code>next</code> statement.
-However, instead of abandoning processing of the current record, the
-<code>nextfile</code> statement instructs <samp><span
class="command">gawk</span></samp> to stop processing the
-current data file.
-
- <p>The <code>nextfile</code> statement is a <samp><span
class="command">gawk</span></samp> extension.
-In most other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-<code>nextfile</code> is not special.
-
- <p>Upon execution of the <code>nextfile</code> statement,
<code>FILENAME</code> is
-updated to the name of the next data file listed on the command line,
-<code>FNR</code> is reset to one, <code>ARGIND</code> is incremented, and
processing
-starts over with the first rule in the program.
-(<code>ARGIND</code> hasn't been introduced yet. See <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>.)
-If the <code>nextfile</code> statement causes the end of the input to be
reached,
-then the code in any <code>END</code> rules is executed.
-See <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>.
-
- <p>The <code>nextfile</code> statement is useful when there are many data
files
-to process but it isn't necessary to process every record in every file.
-Normally, in order to move on to the next data file, a program
-has to continue scanning the unwanted records. The <code>nextfile</code>
-statement accomplishes this much more efficiently.
-
- <p>While one might think that `<samp><span
class="samp">close(FILENAME)</span></samp>' would accomplish
-the same as <code>nextfile</code>, this isn't true. <code>close</code> is
-reserved for closing files, pipes, and coprocesses that are
-opened with redirections. It is not related to the main processing that
-<samp><span class="command">awk</span></samp> does with the files listed in
<code>ARGV</code>.
-
- <p>If it's necessary to use an <samp><span
class="command">awk</span></samp> version that doesn't support
-<code>nextfile</code>, see
-<a href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a>,
-for a user-defined function that simulates the <code>nextfile</code>
-statement.
-
- <p><a
name="index-functions_002c-user_002ddefined_002c-_0040code_007bnext_007d_002f_0040code_007bnextfile_007d-statements-and-979"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-user_002ddefined-functions-and-980"></a>The
current version of the Bell Laboratories <samp><span
class="command">awk</span></samp>
-(see <a href="Other-Versions.html#Other-Versions">Other Versions</a>)
-also supports <code>nextfile</code>. However, it doesn't allow the
<code>nextfile</code>
-statement inside function bodies
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>).
-<samp><span class="command">gawk</span></samp> does; a <code>nextfile</code>
inside a
-function body reads the next record and starts processing it with the
-first rule in the program, just as any other <code>nextfile</code> statement.
-
- <p><a
name="index-_0040code_007bnext-file_007d-statement_002c-in-_0040command_007bgawk_007d-981"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bnext-file_007d-statement-in-982"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-in-_0040command_007bgawk_007d-983"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bnextfile_007d-statement-in-984"></a><strong>Caution:</strong>
Versions of <samp><span class="command">gawk</span></samp> prior to 3.0 used
two
-words (`<samp><span class="samp">next file</span></samp>') for the
<code>nextfile</code> statement.
-In version 3.0, this was changed
-to one word, because the treatment of `<samp><span
class="samp">file</span></samp>' was
-inconsistent. When it appeared after <code>next</code>, `<samp><span
class="samp">file</span></samp>' was a keyword;
-otherwise, it was a regular identifier. The old usage is no longer
-accepted; `<samp><span class="samp">next file</span></samp>' generates a
syntax error.
-
- </body></html>
-
Index: manual/html_node/Non_002dUnix-Installation.html
===================================================================
RCS file: manual/html_node/Non_002dUnix-Installation.html
diff -N manual/html_node/Non_002dUnix-Installation.html
--- manual/html_node/Non_002dUnix-Installation.html 31 Aug 2004 22:04:11
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,69 +0,0 @@
-<html lang="en">
-<head>
-<title>Non-Unix Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Installation.html#Installation" title="Installation">
-<link rel="prev" href="Unix-Installation.html#Unix-Installation" title="Unix
Installation">
-<link rel="next" href="Unsupported.html#Unsupported" title="Unsupported">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Non_002dUnix-Installation"></a>Next: <a rel="next" accesskey="n"
href="Unsupported.html#Unsupported">Unsupported</a>,
-Previous: <a rel="previous" accesskey="p"
href="Unix-Installation.html#Unix-Installation">Unix Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Installation.html#Installation">Installation</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">B.3 Installation on Other Operating Systems</h3>
-
-<p>This section describes how to install <samp><span
class="command">gawk</span></samp> on
-various non-Unix systems.
-
-<ul class="menu">
-<li><a accesskey="1" href="Amiga-Installation.html#Amiga-Installation">Amiga
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on an Amiga.
-<li><a accesskey="2" href="BeOS-Installation.html#BeOS-Installation">BeOS
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on BeOS.
-<li><a accesskey="3" href="PC-Installation.html#PC-Installation">PC
Installation</a>: Installing and Compiling <samp><span
class="command">gawk</span></samp> on
- MS-DOS and OS/2.
-<li><a accesskey="4" href="VMS-Installation.html#VMS-Installation">VMS
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on VMS.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Nonconstant-Fields.html
===================================================================
RCS file: manual/html_node/Nonconstant-Fields.html
diff -N manual/html_node/Nonconstant-Fields.html
--- manual/html_node/Nonconstant-Fields.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,101 +0,0 @@
-<html lang="en">
-<head>
-<title>Nonconstant Fields - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="prev" href="Fields.html#Fields" title="Fields">
-<link rel="next" href="Changing-Fields.html#Changing-Fields" title="Changing
Fields">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Nonconstant-Fields"></a>Next: <a rel="next" accesskey="n"
href="Changing-Fields.html#Changing-Fields">Changing Fields</a>,
-Previous: <a rel="previous" accesskey="p"
href="Fields.html#Fields">Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.3 Nonconstant Field Numbers</h3>
-
-<p><a name="index-fields_002c-numbers-390"></a><a
name="index-field-numbers-391"></a>
-The number of a field does not need to be a constant. Any expression in
-the <samp><span class="command">awk</span></samp> language can be used after a
`<samp><span class="samp">$</span></samp>' to refer to a
-field. The value of the expression specifies the field number. If the
-value is a string, rather than a number, it is converted to a number.
-Consider this example:
-
-<pre class="example"> awk '{ print $NR }'
-</pre>
- <p class="noindent">Recall that <code>NR</code> is the number of records
read so far: one in the
-first record, two in the second, etc. So this example prints the first
-field of the first record, the second field of the second record, and so
-on. For the twentieth record, field number 20 is printed; most likely,
-the record has fewer than 20 fields, so this prints a blank line.
-Here is another example of using expressions as field numbers:
-
-<pre class="example"> awk '{ print $(2*2) }' BBS-list
-</pre>
- <p><samp><span class="command">awk</span></samp> evaluates the expression
`<samp><span class="samp">(2*2)</span></samp>' and uses
-its value as the number of the field to print. The `<samp><span
class="samp">*</span></samp>' sign
-represents multiplication, so the expression `<samp><span
class="samp">2*2</span></samp>' evaluates to four.
-The parentheses are used so that the multiplication is done before the
-`<samp><span class="samp">$</span></samp>' operation; they are necessary
whenever there is a binary
-operator in the field-number expression. This example, then, prints the
-hours of operation (the fourth field) for every line of the file
-<samp><span class="file">BBS-list</span></samp>. (All of the <samp><span
class="command">awk</span></samp> operators are listed, in
-order of decreasing precedence, in
-<a href="Precedence.html#Precedence">Precedence</a>.)
-
- <p>If the field number you compute is zero, you get the entire record.
-Thus, `<samp><span class="samp">$(2-2)</span></samp>' has the same value as
<code>$0</code>. Negative field
-numbers are not allowed; trying to reference one usually terminates
-the program. (The POSIX standard does not define
-what happens when you reference a negative field number. <samp><span
class="command">gawk</span></samp>
-notices this and terminates your program. Other <samp><span
class="command">awk</span></samp>
-implementations may behave differently.)
-
- <p>As mentioned in <a href="Fields.html#Fields">Fields</a>,
-<samp><span class="command">awk</span></samp> stores the current record's
number of fields in the built-in
-variable <code>NF</code> (also see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>). The expression
-<code>$NF</code> is not a special feature—it is the direct consequence of
-evaluating <code>NF</code> and using its value as a field number.
-
- </body></html>
-
Index: manual/html_node/Nondecimal-Data.html
===================================================================
RCS file: manual/html_node/Nondecimal-Data.html
diff -N manual/html_node/Nondecimal-Data.html
--- manual/html_node/Nondecimal-Data.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>Nondecimal Data - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Advanced-Features.html#Advanced-Features" title="Advanced
Features">
-<link rel="next" href="Two_002dway-I_002fO.html#Two_002dway-I_002fO"
title="Two-way I/O">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Nondecimal-Data"></a>Next: <a rel="next" accesskey="n"
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>,
-Up: <a rel="up" accesskey="u"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>
-<hr><br>
-</div>
-
-<h3 class="section">10.1 Allowing Nondecimal Input Data</h3>
-
-<p><a
name="index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1398"></a><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-nondecimal-input-data-1399"></a><a
name="index-input_002c-data_0040comma_007b_007d-nondecimal-1400"></a><a
name="index-constants_002c-nondecimal-1401"></a>
-If you run <samp><span class="command">gawk</span></samp> with the <samp><span
class="option">--non-decimal-data</span></samp> option,
-you can have nondecimal constants in your input data:
-
-<!-- line break here for small book format -->
-<pre class="example"> $ echo 0123 123 0x123 |
- > gawk --non-decimal-data '{ printf "%d, %d, %d\n",
- > $1, $2, $3 }'
- -| 83, 123, 291
-</pre>
- <p>For this feature to work, write your program so that
-<samp><span class="command">gawk</span></samp> treats your data as numeric:
-
-<pre class="example"> $ echo 0123 123 0x123 | gawk '{ print $1, $2, $3 }'
- -| 0123 123 0x123
-</pre>
- <p class="noindent">The <code>print</code> statement treats its expressions
as strings.
-Although the fields can act as numbers when necessary,
-they are still strings, so <code>print</code> does not try to treat them
-numerically. You may need to add zero to a field to force it to
-be treated as a number. For example:
-
-<pre class="example"> $ echo 0123 123 0x123 | gawk --non-decimal-data '
- > { print $1, $2, $3
- > print $1 + 0, $2 + 0, $3 + 0 }'
- -| 0123 123 0x123
- -| 83 123 291
-</pre>
- <p>Because it is common to have decimal data with leading zeros, and because
-using it could lead to surprising results, the default is to leave this
-facility disabled. If you want it, you must explicitly request it.
-
- <p><a
name="index-programming-conventions_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1402"></a><a
name="index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option_002c-_0040code_007bstrtonum_007d-function-and-1403"></a><a
name="index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-and-1404"></a><strong>Caution:</strong>
-<em>Use of this option is not recommended.</em>
-It can break old programs very badly.
-Instead, use the <code>strtonum</code> function to convert your data
-(see <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>).
-This makes your programs easier to write and easier to read, and
-leads to less surprising results.
-
- </body></html>
-
Index: manual/html_node/Nondecimal_002dnumbers.html
===================================================================
RCS file: manual/html_node/Nondecimal_002dnumbers.html
diff -N manual/html_node/Nondecimal_002dnumbers.html
--- manual/html_node/Nondecimal_002dnumbers.html 31 Aug 2004 22:04:11
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-<html lang="en">
-<head>
-<title>Nondecimal-numbers - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Constants.html#Constants" title="Constants">
-<link rel="prev" href="Scalar-Constants.html#Scalar-Constants" title="Scalar
Constants">
-<link rel="next" href="Regexp-Constants.html#Regexp-Constants" title="Regexp
Constants">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Nondecimal_002dnumbers"></a>Next: <a rel="next" accesskey="n"
href="Regexp-Constants.html#Regexp-Constants">Regexp Constants</a>,
-Previous: <a rel="previous" accesskey="p"
href="Scalar-Constants.html#Scalar-Constants">Scalar Constants</a>,
-Up: <a rel="up" accesskey="u"
href="Constants.html#Constants">Constants</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">5.1.2 Octal and Hexadecimal Numbers</h4>
-
-<p><a name="index-octal-numbers-610"></a><a
name="index-hexadecimal-numbers-611"></a><a
name="index-numbers_002c-octal-612"></a><a
name="index-numbers_002c-hexadecimal-613"></a>
-In <samp><span class="command">awk</span></samp>, all numbers are in decimal;
i.e., base 10. Many other
-programming languages allow you to specify numbers in other bases, often
-octal (base 8) and hexadecimal (base 16).
-In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc.
-Just as `<samp><span class="samp">11</span></samp>', in decimal, is 1 times 10
plus 1, so
-`<samp><span class="samp">11</span></samp>', in octal, is 1 times 8, plus 1.
This equals 9 in decimal.
-In hexadecimal, there are 16 digits. Since the everyday decimal
-number system only has ten digits (`<samp><span
class="samp">0</span></samp>'–`<samp><span
class="samp">9</span></samp>'), the letters
-`<samp><span class="samp">a</span></samp>' through `<samp><span
class="samp">f</span></samp>' are used to represent the rest.
-(Case in the letters is usually irrelevant; hexadecimal `<samp><span
class="samp">a</span></samp>' and `<samp><span class="samp">A</span></samp>'
-have the same value.)
-Thus, `<samp><span class="samp">11</span></samp>', in
-hexadecimal, is 1 times 16 plus 1, which equals 17 in decimal.
-
- <p>Just by looking at plain `<samp><span class="samp">11</span></samp>',
you can't tell what base it's in.
-So, in C, C++, and other languages derived from C,
-<!-- such as PERL, but we won't mention that.... -->
-there is a special notation to help signify the base.
-Octal numbers start with a leading `<samp><span class="samp">0</span></samp>',
-and hexadecimal numbers start with a leading `<samp><span
class="samp">0x</span></samp>' or `<samp><span class="samp">0X</span></samp>':
-
- <dl>
-<dt><code>11</code><dd>Decimal value 11.
-
- <br><dt><code>011</code><dd>Octal 11, decimal value 9.
-
- <br><dt><code>0x11</code><dd>Hexadecimal 11, decimal value 17.
-</dl>
-
- <p>This example shows the difference:
-
-<pre class="example"> $ gawk 'BEGIN { printf "%d, %d, %d\n", 011, 11, 0x11
}'
- -| 9, 11, 17
-</pre>
- <p>Being able to use octal and hexadecimal constants in your programs is
most
-useful when working with data that cannot be represented conveniently as
-characters or as regular numbers, such as binary data of various sorts.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-octal-numbers-and-614"></a><a
name="index-_0040command_007bgawk_007d_002c-hexadecimal-numbers-and-615"></a><samp><span
class="command">gawk</span></samp> allows the use of octal and hexadecimal
-constants in your program text. However, such numbers in the input data
-are not treated differently; doing so by default would break old
-programs.
-(If you really need to do this, use the <samp><span
class="option">--non-decimal-data</span></samp>
-command-line option;
-see <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a>.)
-If you have octal or hexadecimal data,
-you can use the <code>strtonum</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>)
-to convert the data into a number.
-Most of the time, you will want to use octal or hexadecimal constants
-when working with the built-in bit manipulation functions;
-see <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>,
-for more information.
-
- <p>Unlike some early C implementations, `<samp><span
class="samp">8</span></samp>' and `<samp><span class="samp">9</span></samp>'
are not valid
-in octal constants; e.g., <samp><span class="command">gawk</span></samp>
treats `<samp><span class="samp">018</span></samp>' as decimal 18:
-
-<pre class="example"> $ gawk 'BEGIN { print "021 is", 021 ; print 018 }'
- -| 021 is 17
- -| 18
-</pre>
- <p><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-octal-numbers-616"></a><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-hexadecimal-numbers-617"></a>Octal
and hexadecimal source code constants are a <samp><span
class="command">gawk</span></samp> extension.
-If <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-they are not available.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: A Constant's Base Does Not Affect Its
Value</h4>
-
-<p><a
name="index-advanced-features_002c-constants_0040comma_007b_007d-values-of-618"></a>
-Once a numeric constant has
-been converted internally into a number,
-<samp><span class="command">gawk</span></samp> no longer remembers
-what the original form of the constant was; the internal value is
-always used. This has particular consequences for conversion of
-numbers to strings:
-
-<pre class="example"> $ gawk 'BEGIN { printf "0x11 is <%s>\n", 0x11
}'
- -| 0x11 is <17>
-</pre>
- </body></html>
-
Index: manual/html_node/Notes.html
===================================================================
RCS file: manual/html_node/Notes.html
diff -N manual/html_node/Notes.html
--- manual/html_node/Notes.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-<html lang="en">
-<head>
-<title>Notes - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Installation.html#Installation" title="Installation">
-<link rel="next" href="Basic-Concepts.html#Basic-Concepts" title="Basic
Concepts">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Notes"></a>Next: <a rel="next" accesskey="n"
href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>,
-Previous: <a rel="previous" accesskey="p"
href="Installation.html#Installation">Installation</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="appendix">Appendix C Implementation Notes</h2>
-
-<!-- STARTOFRANGE gawii -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues-1949"></a><!--
STARTOFRANGE impis -->
-<a name="index-implementation-issues_002c-_0040command_007bgawk_007d-1950"></a>
-This appendix contains information mainly of interest to implementors and
-maintainers of <samp><span class="command">gawk</span></samp>. Everything in
it applies specifically to
-<samp><span class="command">gawk</span></samp> and not to other
implementations.
-
-<ul class="menu">
-<li><a accesskey="1"
href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a>:
How to disable certain <samp><span class="command">gawk</span></samp>
- extensions.
-<li><a accesskey="2" href="Additions.html#Additions">Additions</a>:
Making Additions To <samp><span class="command">gawk</span></samp>.
-<li><a accesskey="3" href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a>: Adding new built-in functions to
- <samp><span
class="command">gawk</span></samp>.
-<li><a accesskey="4" href="Future-Extensions.html#Future-Extensions">Future
Extensions</a>: New features that may be implemented one day.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Numeric-Array-Subscripts.html
===================================================================
RCS file: manual/html_node/Numeric-Array-Subscripts.html
diff -N manual/html_node/Numeric-Array-Subscripts.html
--- manual/html_node/Numeric-Array-Subscripts.html 31 Aug 2004 22:04:11
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-<html lang="en">
-<head>
-<title>Numeric Array Subscripts - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Delete.html#Delete" title="Delete">
-<link rel="next" href="Uninitialized-Subscripts.html#Uninitialized-Subscripts"
title="Uninitialized Subscripts">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Numeric-Array-Subscripts"></a>Next: <a rel="next" accesskey="n"
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a>,
-Previous: <a rel="previous" accesskey="p"
href="Delete.html#Delete">Delete</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.7 Using Numbers to Subscript Arrays</h3>
-
-<p><a name="index-numbers_002c-as-array-subscripts-1115"></a><a
name="index-arrays_002c-subscripts-1116"></a><a
name="index-subscripts-in-arrays_002c-numbers-as-1117"></a><a
name="index-_0040code_007bCONVFMT_007d-variable_002c-array-subscripts-and-1118"></a>An
important aspect about arrays to remember is that <em>array subscripts
-are always strings</em>. When a numeric value is used as a subscript,
-it is converted to a string value before being used for subscripting
-(see <a href="Conversion.html#Conversion">Conversion</a>).
-This means that the value of the built-in variable <code>CONVFMT</code> can
-affect how your program accesses elements of an array. For example:
-
-<pre class="example"> xyz = 12.153
- data[xyz] = 1
- CONVFMT = "%2.2f"
- if (xyz in data)
- printf "%s is in data\n", xyz
- else
- printf "%s is not in data\n", xyz
-</pre>
- <p class="noindent">This prints `<samp><span class="samp">12.15 is not in
data</span></samp>'. The first statement gives
-<code>xyz</code> a numeric value. Assigning to
-<code>data[xyz]</code> subscripts <code>data</code> with the string value
<code>"12.153"</code>
-(using the default conversion value of <code>CONVFMT</code>,
<code>"%.6g"</code>).
-Thus, the array element <code>data["12.153"]</code> is assigned the value one.
-The program then changes
-the value of <code>CONVFMT</code>. The test `<samp><span class="samp">(xyz in
data)</span></samp>' generates a new
-string value from <code>xyz</code>—this time
<code>"12.15"</code>—because the value of
-<code>CONVFMT</code> only allows two significant digits. This test fails,
-since <code>"12.15"</code> is a different string from <code>"12.153"</code>.
-
- <p><a name="index-converting_002c-during-subscripting-1119"></a>According
to the rules for conversions
-(see <a href="Conversion.html#Conversion">Conversion</a>), integer
-values are always converted to strings as integers, no matter what the
-value of <code>CONVFMT</code> may happen to be. So the usual case of
-the following works:
-
-<pre class="example"> for (i = 1; i <= maxsub; i++)
- <i>do something with</i> array[i]
-</pre>
- <p>The “integer values always convert to strings as integers”
rule
-has an additional consequence for array indexing.
-Octal and hexadecimal constants
-(see <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>)
-are converted internally into numbers, and their original form
-is forgotten.
-This means, for example, that
-<code>array[17]</code>,
-<code>array[021]</code>,
-and
-<code>array[0x11]</code>
-all refer to the same element!
-
- <p>As with many things in <samp><span class="command">awk</span></samp>,
the majority of the time
-things work as one would expect them to. But it is useful to have a precise
-knowledge of the actual rules which sometimes can have a subtle
-effect on your programs.
-
- </body></html>
-
Index: manual/html_node/Numeric-Functions.html
===================================================================
RCS file: manual/html_node/Numeric-Functions.html
diff -N manual/html_node/Numeric-Functions.html
--- manual/html_node/Numeric-Functions.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,164 +0,0 @@
-<html lang="en">
-<head>
-<title>Numeric Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="prev" href="Calling-Built_002din.html#Calling-Built_002din"
title="Calling Built-in">
-<link rel="next" href="String-Functions.html#String-Functions" title="String
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Numeric-Functions"></a>Next: <a rel="next" accesskey="n"
href="String-Functions.html#String-Functions">String Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Calling-Built_002din.html#Calling-Built_002din">Calling Built-in</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.2 Numeric Functions</h4>
-
-<p>The following list describes all of
-the built-in functions that work with numbers.
-Optional parameters are enclosed in square brackets ([ ]):<!-- /@w
-->
-
- <dl>
-<dt><code>int(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bint_007d-function-1150"></a>This returns the nearest
integer to <var>x</var>, located between <var>x</var> and zero and
-truncated toward zero.
-
- <p>For example, <code>int(3)</code> is 3, <code>int(3.9)</code> is 3,
<code>int(-3.9)</code>
-is −3, and <code>int(-3)</code> is −3 as well.
-
- <br><dt><code>sqrt(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bsqrt_007d-function-1151"></a>This returns the
positive square root of <var>x</var>.
-<samp><span class="command">gawk</span></samp> reports an error
-if <var>x</var> is negative. Thus, <code>sqrt(4)</code> is 2.
-
- <br><dt><code>exp(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bexp_007d-function-1152"></a>This returns the
exponential of <var>x</var> (<code>e ^ </code><var>x</var>) or reports
-an error if <var>x</var> is out of range. The range of values <var>x</var>
can have
-depends on your machine's floating-point representation.
-
- <br><dt><code>log(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007blog_007d-function-1153"></a>This returns the natural
logarithm of <var>x</var>, if <var>x</var> is positive;
-otherwise, it reports an error.
-
- <br><dt><code>sin(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bsin_007d-function-1154"></a>This returns the sine of
<var>x</var>, with <var>x</var> in radians.
-
- <br><dt><code>cos(</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007bcos_007d-function-1155"></a>This returns the cosine
of <var>x</var>, with <var>x</var> in radians.
-
- <br><dt><code>atan2(</code><var>y</var><code>,
</code><var>x</var><code>)</code><dd><a
name="index-_0040code_007batan2_007d-function-1156"></a>This returns the
arctangent of <var>y</var><code> / </code><var>x</var> in radians.
-
- <br><dt><code>rand()</code><dd><a
name="index-_0040code_007brand_007d-function-1157"></a><a
name="index-random-numbers_002c-_0040code_007brand_007d_002f_0040code_007bsrand_007d-functions-1158"></a>This
returns a random number. The values of <code>rand</code> are
-uniformly distributed between zero and one.
-The value could be zero but is never one.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
- <p>Often random integers are needed instead. Following is a user-defined
function
-that can be used to obtain a random non-negative integer less than
<var>n</var>:
-
- <pre class="example"> function randint(n) {
- return int(n * rand())
- }
- </pre>
- <p class="noindent">The multiplication produces a random number greater
than zero and less
-than <code>n</code>. Using <code>int</code>, this result is made into
-an integer between zero and <code>n</code> − 1, inclusive.
-
- <p>The following example uses a similar function to produce random
integers
-between one and <var>n</var>. This program prints a new random number for
-each input record:
-
- <pre class="example"> # Function to roll a simulated die.
- function roll(n) { return 1 + int(rand() * n) }
-
- # Roll 3 six-sided dice and
- # print total number of points.
- {
- printf("%d points\n",
- roll(6)+roll(6)+roll(6))
- }
- </pre>
- <p><a name="index-numbers_002c-random-1159"></a><a
name="index-random-numbers_002c-seed-of-1160"></a><!-- MAWK uses a different
seed each time. -->
-<strong>Caution:</strong> In most <samp><span
class="command">awk</span></samp> implementations, including <samp><span
class="command">gawk</span></samp>,
-<code>rand</code> starts generating numbers from the same
-starting number, or <dfn>seed</dfn>, each time you run <samp><span
class="command">awk</span></samp>. Thus,
-a program generates the same results each time you run it.
-The numbers are random within one <samp><span
class="command">awk</span></samp> run but predictable
-from run to run. This is convenient for debugging, but if you want
-a program to do different things each time it is used, you must change
-the seed to a value that is different in each run. To do this,
-use <code>srand</code>.
-
- <br><dt><code>srand(</code><span class="roman">[</span><var>x</var><span
class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsrand_007d-function-1161"></a>The function
<code>srand</code> sets the starting point, or seed,
-for generating random numbers to the value <var>x</var>.
-
- <p>Each seed value leads to a particular sequence of random
-numbers.<a rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
-Thus, if the seed is set to the same value a second time,
-the same sequence of random numbers is produced again.
-
- <p>Different <samp><span class="command">awk</span></samp>
implementations use different random-number
-generators internally. Don't expect the same <samp><span
class="command">awk</span></samp> program
-to produce the same series of random numbers when executed by
-different versions of <samp><span class="command">awk</span></samp>.
-
- <p>If the argument <var>x</var> is omitted, as in `<samp><span
class="samp">srand()</span></samp>', then the current
-date and time of day are used for a seed. This is the way to get random
-numbers that are truly unpredictable.
-
- <p>The return value of <code>srand</code> is the previous seed. This
makes it
-easy to keep track of the seeds in case you need to consistently reproduce
-sequences of random numbers.
-</dl>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The C version of <code>rand</code>
-is known to produce fairly poor sequences of random numbers.
-However, nothing requires that an <samp><span
class="command">awk</span></samp> implementation use the C
-<code>rand</code> to implement the <samp><span
class="command">awk</span></samp> version of <code>rand</code>.
-In fact, <samp><span class="command">gawk</span></samp> uses the BSD
<code>random</code> function, which is
-considerably better than <code>rand</code>, to produce random numbers.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
Computer-generated random numbers really are not truly
-random. They are technically known as “pseudorandom.” This means
-that while the numbers in a sequence appear to be random, you can in
-fact generate the same sequence of random numbers over and over again.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/OFMT.html
===================================================================
RCS file: manual/html_node/OFMT.html
diff -N manual/html_node/OFMT.html
--- manual/html_node/OFMT.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-<html lang="en">
-<head>
-<title>OFMT - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="Output-Separators.html#Output-Separators" title="Output
Separators">
-<link rel="next" href="Printf.html#Printf" title="Printf">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="OFMT"></a>Next: <a rel="next" accesskey="n"
href="Printf.html#Printf">Printf</a>,
-Previous: <a rel="previous" accesskey="p"
href="Output-Separators.html#Output-Separators">Output Separators</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.4 Controlling Numeric Output with <code>print</code></h3>
-
-<p><a name="index-numeric_002c-output-format-519"></a><a
name="index-formats_0040comma_007b_007d-numeric-output-520"></a>When the
<code>print</code> statement is used to print numeric values,
-<samp><span class="command">awk</span></samp> internally converts the number
to a string of characters
-and prints that string. <samp><span class="command">awk</span></samp> uses
the <code>sprintf</code> function
-to do this conversion
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-For now, it suffices to say that the <code>sprintf</code>
-function accepts a <dfn>format specification</dfn> that tells it how to format
-numbers (or strings), and that there are a number of different ways in which
-numbers can be formatted. The different format specifications are discussed
-more fully in
-<a href="Control-Letters.html#Control-Letters">Control Letters</a>.
-
- <p><a name="index-_0040code_007bsprintf_007d-function-521"></a><a
name="index-_0040code_007bOFMT_007d-variable-522"></a><a
name="index-output_002c-format-specifier_0040comma_007b_007d-_0040code_007bOFMT_007d-523"></a>The
built-in variable <code>OFMT</code> contains the default format specification
-that <code>print</code> uses with <code>sprintf</code> when it wants to
convert a
-number to a string for printing.
-The default value of <code>OFMT</code> is <code>"%.6g"</code>.
-The way <code>print</code> prints numbers can be changed
-by supplying different format specifications
-as the value of <code>OFMT</code>, as shown in the following example:
-
-<pre class="example"> $ awk 'BEGIN {
- > OFMT = "%.0f" # print numbers as integers (rounds)
- > print 17.23, 17.54 }'
- -| 17 18
-</pre>
- <p class="noindent"><a
name="index-dark-corner_002c-_0040code_007bOFMT_007d-variable-524"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bOFMT_007d-variable-and-525"></a><a
name="index-_0040code_007bOFMT_007d-variable_002c-POSIX-_0040command_007bawk_007d-and-526"></a>According
to the POSIX standard, <samp><span class="command">awk</span></samp>'s
behavior is undefined
-if <code>OFMT</code> contains anything but a floating-point conversion
specification.
-(d.c.)
-
- </body></html>
-
Index: manual/html_node/Obsolete.html
===================================================================
RCS file: manual/html_node/Obsolete.html
diff -N manual/html_node/Obsolete.html
--- manual/html_node/Obsolete.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-<html lang="en">
-<head>
-<title>Obsolete - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="prev" href="AWKPATH-Variable.html#AWKPATH-Variable" title="AWKPATH
Variable">
-<link rel="next" href="Undocumented.html#Undocumented" title="Undocumented">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Obsolete"></a>Next: <a rel="next" accesskey="n"
href="Undocumented.html#Undocumented">Undocumented</a>,
-Previous: <a rel="previous" accesskey="p"
href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.5 Obsolete Options and/or Features</h3>
-
-<p><a
name="index-features_002c-advanced_002c-See-advanced-features-1572"></a><a
name="index-options_002c-deprecated-1573"></a><a
name="index-features_002c-deprecated-1574"></a><a
name="index-obsolete-features-1575"></a>This section describes features and/or
command-line options from
-previous releases of <samp><span class="command">gawk</span></samp> that are
either not available in the
-current version or that are still supported but deprecated (meaning that
-they will <em>not</em> be in the next release).
-
-<!-- update this section for each release! -->
-<p><a
name="index-_0040code_007bnext-file_007d-statement_002c-deprecated-1576"></a><a
name="index-_0040code_007bnextfile_007d-statement_002c-_0040code_007bnext-file_007d-statement-and-1577"></a>For
version 3.1 of <samp><span class="command">gawk</span></samp>, there are no
-deprecated command-line options
-<!-- or other deprecated features -->
-from the previous version of <samp><span class="command">gawk</span></samp>.
-The use of `<samp><span class="samp">next file</span></samp>' (two words) for
<code>nextfile</code> was deprecated
-in <samp><span class="command">gawk</span></samp> 3.0 but still worked.
Starting with version 3.1, the
-two-word usage is no longer accepted.
-
- <p>The process-related special files described in
-<a href="Special-Process.html#Special-Process">Special Process</a>,
-work as described, but
-are now considered deprecated.
-<samp><span class="command">gawk</span></samp> prints a warning message every
time they are used.
-(Use <code>PROCINFO</code> instead; see
-<a href="Auto_002dset.html#Auto_002dset">Auto-set</a>.)
-They will be removed from the next release of <samp><span
class="command">gawk</span></samp>.
-
- </body></html>
-
Index: manual/html_node/One_002dshot.html
===================================================================
RCS file: manual/html_node/One_002dshot.html
diff -N manual/html_node/One_002dshot.html
--- manual/html_node/One_002dshot.html 31 Aug 2004 22:04:11 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,84 +0,0 @@
-<html lang="en">
-<head>
-<title>One-shot - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="next" href="Read-Terminal.html#Read-Terminal" title="Read Terminal">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="One_002dshot"></a>Next: <a rel="next" accesskey="n"
href="Read-Terminal.html#Read-Terminal">Read Terminal</a>,
-Up: <a rel="up" accesskey="u"
href="Running-gawk.html#Running-gawk">Running gawk</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.1.1 One-Shot Throwaway <samp><span
class="command">awk</span></samp> Programs</h4>
-
-<p>Once you are familiar with <samp><span class="command">awk</span></samp>,
you will often type in simple
-programs the moment you want to use them. Then you can write the
-program as the first argument of the <samp><span
class="command">awk</span></samp> command, like this:
-
-<pre class="example"> awk '<var>program</var>' <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p class="noindent">where <var>program</var> consists of a series of
<var>patterns</var> and
-<var>actions</var>, as described earlier.
-
- <p><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029-80"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029-81"></a>This
command format instructs the <dfn>shell</dfn>, or command interpreter,
-to start <samp><span class="command">awk</span></samp> and use the
<var>program</var> to process records in the
-input file(s). There are single quotes around <var>program</var> so
-the shell won't interpret any <samp><span class="command">awk</span></samp>
characters as special shell
-characters. The quotes also cause the shell to treat all of
<var>program</var> as
-a single argument for <samp><span class="command">awk</span></samp>, and allow
<var>program</var> to be more
-than one line long.
-
- <p><a name="index-shells_002c-scripts-82"></a><a
name="index-_0040command_007bawk_007d-programs_002c-running_002c-from-shell-scripts-83"></a>This
format is also useful for running short or medium-sized <samp><span
class="command">awk</span></samp>
-programs from shell scripts, because it avoids the need for a separate
-file for the <samp><span class="command">awk</span></samp> program. A
self-contained shell script is more
-reliable because there are no other files to misplace.
-
- <p><a href="Very-Simple.html#Very-Simple">Very Simple</a>,
-later in this chapter,
-presents several short,
-self-contained programs.
-
-<!-- Removed for gawk 3.1, doesn't really add anything here. -->
-</body></html>
-
Index: manual/html_node/Options.html
===================================================================
RCS file: manual/html_node/Options.html
diff -N manual/html_node/Options.html
--- manual/html_node/Options.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,331 +0,0 @@
-<html lang="en">
-<head>
-<title>Options - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="prev" href="Command-Line.html#Command-Line" title="Command Line">
-<link rel="next" href="Other-Arguments.html#Other-Arguments" title="Other
Arguments">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Options"></a>Next: <a rel="next" accesskey="n"
href="Other-Arguments.html#Other-Arguments">Other Arguments</a>,
-Previous: <a rel="previous" accesskey="p"
href="Command-Line.html#Command-Line">Command Line</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.2 Command-Line Options</h3>
-
-<!-- STARTOFRANGE ocl -->
-<p><a name="index-options_002c-command_002dline-1477"></a><!-- STARTOFRANGE
clo -->
-<a name="index-command-line_002c-options-1478"></a><!-- STARTOFRANGE gnulo -->
-<a name="index-GNU-long-options-1479"></a><!-- STARTOFRANGE longo -->
-<a name="index-options_002c-long-1480"></a>
-Options begin with a dash and consist of a single character.
-GNU-style long options consist of two dashes and a keyword.
-The keyword can be abbreviated, as long as the abbreviation allows the option
-to be uniquely identified. If the option takes an argument, then the
-keyword is either immediately followed by an equals sign (`<samp><span
class="samp">=</span></samp>') and the
-argument's value, or the keyword and the argument's value are separated
-by whitespace.
-If a particular option with a value is given more than once, it is the
-last value that counts.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-GNU-long-options-and-1481"></a>Each
long option for <samp><span class="command">gawk</span></samp> has a
corresponding
-POSIX-style option.
-The long and short options are
-interchangeable in all contexts.
-The options and their meanings are as follows:
-
- <dl>
-<dt><code>-F </code><var>fs</var><dt><code>--field-separator
</code><var>fs</var><dd><a
name="index-_0040code_007b_002dF_007d-option-1482"></a><a
name="index-_0040code_007b_002d_002dfield_002dseparator_007d-option-1483"></a><a
name="index-_0040code_007bFS_007d-variable_002c-_0040code_007b_002d_002dfield_002dseparator_007d-option-and-1484"></a>Sets
the <code>FS</code> variable to <var>fs</var>
-(see <a href="Field-Separators.html#Field-Separators">Field Separators</a>).
-
- <br><dt><code>-f </code><var>source-file</var><dt><code>--file
</code><var>source-file</var><dd><a
name="index-_0040code_007b_002df_007d-option-1485"></a><a
name="index-_0040code_007b_002d_002dfile_007d-option-1486"></a><a
name="index-_0040command_007bawk_007d-programs_002c-location-of-1487"></a>Indicates
that the <samp><span class="command">awk</span></samp> program is to be found
in <var>source-file</var>
-instead of in the first non-option argument.
-
- <br><dt><code>-v
</code><var>var</var><code>=</code><var>val</var><dt><code>--assign
</code><var>var</var><code>=</code><var>val</var><dd><a
name="index-_0040code_007b_002dv_007d-option-1488"></a><a
name="index-_0040code_007b_002d_002dassign_007d-option-1489"></a><a
name="index-variables_002c-setting-1490"></a>Sets the variable <var>var</var>
to the value <var>val</var> <em>before</em>
-execution of the program begins. Such variable values are available
-inside the <code>BEGIN</code> rule
-(see <a href="Other-Arguments.html#Other-Arguments">Other Arguments</a>).
-
- <p>The <samp><span class="option">-v</span></samp> option can only set
one variable, but it can be used
-more than once, setting another variable each time, like this:
-`<samp><span class="samp">awk -v foo=1<!-- /@w --> -v bar=2<!-- /@w
--> ...</span></samp>'.
-
- <p><a
name="index-built_002din-variables_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1491"></a><a
name="index-variables_002c-built_002din_002c-_0040code_007b_002dv_007d-option_0040comma_007b_007d-setting-with-1492"></a><strong>Caution:</strong>
Using <samp><span class="option">-v</span></samp> to set the values of the
built-in
-variables may lead to surprising results. <samp><span
class="command">awk</span></samp> will reset the
-values of those variables as it needs to, possibly ignoring any
-predefined value you may have given.
-
- <br><dt><code>-mf </code><var>N</var><dt><code>-mr
</code><var>N</var><dd><a
name="index-_0040code_007b_002dmf_007d_002f_0040code_007b_002dmr_007d-options-1493"></a><a
name="index-memory_002c-setting-limits-1494"></a>Sets various memory limits to
the value <var>N</var>. The `<samp><span class="samp">f</span></samp>' flag
sets
-the maximum number of fields and the `<samp><span
class="samp">r</span></samp>' flag sets the maximum
-record size. These two flags and the <samp><span
class="option">-m</span></samp> option are from the
-Bell Laboratories research version of Unix <samp><span
class="command">awk</span></samp>. They are provided
-for compatibility but otherwise ignored by
-<samp><span class="command">gawk</span></samp>, since <samp><span
class="command">gawk</span></samp> has no predefined limits.
-(The Bell Laboratories <samp><span class="command">awk</span></samp> no longer
needs these options;
-it continues to accept them to avoid breaking old programs.)
-
- <br><dt><code>-W </code><var>gawk-opt</var><dd><a
name="index-_0040code_007b_002dW_007d-option-1495"></a>Following the POSIX
standard, implementation-specific
-options are supplied as arguments to the <samp><span
class="option">-W</span></samp> option. These options
-also have corresponding GNU-style long options.
-Note that the long options may be abbreviated, as long as
-the abbreviations remain unique.
-The full list of <samp><span class="command">gawk</span></samp>-specific
options is provided next.
-
- <br><dt><code>--</code><dd><a
name="index-command-line_002c-options_002c-end-of-1496"></a><a
name="index-options_002c-command_002dline_002c-end-of-1497"></a>Signals the end
of the command-line options. The following arguments
-are not treated as options even if they begin with `<samp><span
class="samp">-</span></samp>'. This
-interpretation of <samp><span class="option">--</span></samp> follows the
POSIX argument parsing
-conventions.
-
- <p><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-filenames-beginning-with-1498"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-filenames-beginning-with-1499"></a>This
is useful if you have file names that start with `<samp><span
class="samp">-</span></samp>',
-or in shell scripts, if you have file names that will be specified
-by the user that could start with `<samp><span class="samp">-</span></samp>'.
-</dl>
- <!-- ENDOFRANGE gnulo -->
-<!-- ENDOFRANGE longo -->
-
- <p>The previous list described options mandated by the POSIX standard,
-as well as options available in the Bell Laboratories version of <samp><span
class="command">awk</span></samp>.
-The following list describes <samp><span
class="command">gawk</span></samp>-specific options:
-
- <dl>
-<dt><code>-W compat</code><dt><code>-W
traditional</code><dt><code>--compat</code><dt><code>--traditional</code><dd><a
name="index-_0040code_007b_002d_002dcompat_007d-option-1500"></a><a
name="index-_0040code_007b_002d_002dtraditional_007d-option-1501"></a><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-specifying-1502"></a>Specifies
<dfn>compatibility mode</dfn>, in which the GNU extensions to
-the <samp><span class="command">awk</span></samp> language are disabled, so
that <samp><span class="command">gawk</span></samp> behaves just
-like the Bell Laboratories research version of Unix <samp><span
class="command">awk</span></samp>.
-<samp><span class="option">--traditional</span></samp> is the preferred form
of this option.
-See <a href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a>,
-which summarizes the extensions. Also see
-<a href="Compatibility-Mode.html#Compatibility-Mode">Compatibility Mode</a>.
-
- <br><dt><code>-W copyright</code><dt><code>--copyright</code><dd><a
name="index-_0040code_007b_002d_002dcopyright_007d-option-1503"></a><a
name="index-GPL-_0028General-Public-License_0029_002c-printing-1504"></a>Print
the short version of the General Public License and then exit.
-
- <br><dt><code>-W copyleft</code><dt><code>--copyleft</code><dd><a
name="index-_0040code_007b_002d_002dcopyleft_007d-option-1505"></a>Just like
<samp><span class="option">--copyright</span></samp>.
-This option may disappear in a future version of <samp><span
class="command">gawk</span></samp>.
-
- <p><a
name="index-_0040code_007b_002d_002ddump_002dvariables_007d-option-1506"></a><a
name="index-_0040code_007bawkvars_002eout_007d-file-1507"></a><a
name="index-files_002c-_0040code_007bawkvars_002eout_007d-1508"></a><a
name="index-variables_002c-global_002c-printing-list-of-1509"></a><br><dt><code>-W
dump-variables</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dt><code>--dump-variables</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dd>Prints a sorted list of global variables, their
types, and final values
-to <var>file</var>. If no <var>file</var> is provided, <samp><span
class="command">gawk</span></samp> prints this
-list to the file named <samp><span class="file">awkvars.out</span></samp> in
the current directory.
-
- <p><a
name="index-troubleshooting_002c-typographical-errors_0040comma_007b_007d-global-variables-1510"></a>Having
a list of all global variables is a good way to look for
-typographical errors in your programs.
-You would also use this option if you have a large program with a lot of
-functions, and you want to be sure that your functions don't
-inadvertently use global variables that you meant to be local.
-(This is a particularly easy mistake to make with simple variable
-names like <code>i</code>, <code>j</code>, etc.)
-
- <br><dt><code>-W gen-po</code><dt><code>--gen-po</code><dd><a
name="index-_0040code_007b_002d_002dgen_002dpo_007d-option-1511"></a><a
name="index-portable-object-files_002c-generating-1512"></a><a
name="index-files_002c-portable-object_002c-generating-1513"></a>Analyzes the
source program and
-generates a GNU <code>gettext</code> Portable Object file on standard
-output for all string constants that have been marked for translation.
-See <a
href="Internationalization.html#Internationalization">Internationalization</a>,
-for information about this option.
-
- <br><dt><code>-W help</code><dt><code>-W
usage</code><dt><code>--help</code><dt><code>--usage</code><dd><a
name="index-_0040code_007b_002d_002dhelp_007d-option-1514"></a><a
name="index-_0040code_007b_002d_002dusage_007d-option-1515"></a><a
name="index-GNU-long-options_002c-printing-list-of-1516"></a><a
name="index-options_002c-printing-list-of-1517"></a><a
name="index-printing_002c-list-of-options-1518"></a>Prints a
“usage” message summarizing the short and long style options
-that <samp><span class="command">gawk</span></samp> accepts and then exit.
-
- <br><dt><code>-W lint</code><span
class="roman">[</span><code>=fatal</code><span
class="roman">]</span><dt><code>--lint</code><span
class="roman">[</span><code>=fatal</code><span class="roman">]</span><dd><a
name="index-_0040code_007b_002d_002dlint_007d-option-1519"></a><a
name="index-lint-checking_002c-issuing-warnings-1520"></a><a
name="index-warnings_002c-issuing-1521"></a>Warns about constructs that are
dubious or nonportable to
-other <samp><span class="command">awk</span></samp> implementations.
-Some warnings are issued when <samp><span class="command">gawk</span></samp>
first reads your program. Others
-are issued at runtime, as your program executes.
-With an optional argument of `<samp><span class="samp">fatal</span></samp>',
-lint warnings become fatal errors.
-This may be drastic, but its use will certainly encourage the
-development of cleaner <samp><span class="command">awk</span></samp> programs.
-With an optional argument of `<samp><span class="samp">invalid</span></samp>',
only warnings about things that are
-actually invalid are issued. (This is not fully implemented yet.)
-
- <br><dt><code>-W lint-old</code><dt><code>--lint-old</code><dd><a
name="index-_0040code_007b_002d_002dlint_002dold_007d-option-1522"></a>Warns
about constructs that are not available in the original version of
-<samp><span class="command">awk</span></samp> from Version 7 Unix
-(see <a href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a>).
-
- <br><dt><code>-W
non-decimal-data</code><dt><code>--non-decimal-data</code><dd><a
name="index-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1523"></a><a
name="index-hexadecimal-values_0040comma_007b_007d-enabling-interpretation-of-1524"></a><a
name="index-octal-values_0040comma_007b_007d-enabling-interpretation-of-1525"></a>Enable
automatic interpretation of octal and hexadecimal
-values in input data
-(see <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a>).
-
- <p><a
name="index-troubleshooting_002c-_0040code_007b_002d_002dnon_002ddecimal_002ddata_007d-option-1526"></a><strong>Caution:</strong>
This option can severely break old programs.
-Use with care.
-
- <br><dt><code>-W posix</code><dt><code>--posix</code><dd><a
name="index-_0040code_007b_002d_002dposix_007d-option-1527"></a><a
name="index-POSIX-mode-1528"></a><a
name="index-_0040command_007bgawk_007d_002c-extensions_0040comma_007b_007d-disabling-1529"></a>Operates
in strict POSIX mode. This disables all <samp><span
class="command">gawk</span></samp>
-extensions (just like <samp><span class="option">--traditional</span></samp>)
and adds the following additional
-restrictions:
-
- <!-- IMPORTANT! Keep this list in sync with the one in node POSIX -->
-
-<a name="index-escape-sequences_002c-unrecognized-1530"></a>
-<ul><li><code>\x</code> escape sequences are not recognized
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-
- <p><a name="index-newlines-1531"></a><a
name="index-whitespace_002c-newlines-as-1532"></a><li>Newlines do not act as
whitespace to separate fields when <code>FS</code> is
-equal to a single space
-(see <a href="Fields.html#Fields">Fields</a>).
-
- <li>Newlines are not allowed after `<samp><span
class="samp">?</span></samp>' or `<samp><span class="samp">:</span></samp>'
-(see <a href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>).
-
- <li>The synonym <code>func</code> for the keyword
<code>function</code> is not
-recognized (see <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a>).
-
- <p><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-1533"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-1534"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1535"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-1536"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-1537"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-1538"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-1539"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-1540"></a><li>The
`<samp><span class="samp">**</span></samp>' and `<samp><span
class="samp">**=</span></samp>' operators cannot be used in
-place of `<samp><span class="samp">^</span></samp>' and `<samp><span
class="samp">^=</span></samp>' (see <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>,
-and also see <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-
- <p><a
name="index-_0040code_007bFS_007d-variable_002c-as-TAB-character-1541"></a><li>Specifying
`<samp><span class="samp">-Ft</span></samp>' on the command-line does not set
the value
-of <code>FS</code> to be a single TAB character
-(see <a href="Field-Separators.html#Field-Separators">Field Separators</a>).
-
- <p><a
name="index-_0040code_007bfflush_007d-function_0040comma_007b_007d-unsupported-1542"></a><li>The
<code>fflush</code> built-in function is not supported
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-</ul>
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a
name="index-_0040code_007b_002d_002dtraditional_007d-option_002c-_0040code_007b_002d_002dposix_007d-option-and-1543"></a><a
name="index-_0040code_007b_002d_002dposix_007d-option_002c-_0040code_007b_002d_002dtraditional_007d-option-and-1544"></a>If
you supply both <samp><span class="option">--traditional</span></samp> and
<samp><span class="option">--posix</span></samp> on the
-command line, <samp><span class="option">--posix</span></samp> takes
precedence. <samp><span class="command">gawk</span></samp>
-also issues a warning if both options are supplied.
-
- <br><dt><code>-W profile</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dt><code>--profile</code><span
class="roman">[</span><code>=</code><var>file</var><span
class="roman">]</span><dd><a
name="index-_0040code_007b_002d_002dprofile_007d-option-1545"></a><a
name="index-_0040command_007bawk_007d-programs_002c-profiling_002c-enabling-1546"></a>Enable
profiling of <samp><span class="command">awk</span></samp> programs
-(see <a href="Profiling.html#Profiling">Profiling</a>).
-By default, profiles are created in a file named <samp><span
class="file">awkprof.out</span></samp>.
-The optional <var>file</var> argument allows you to specify a different
-file name for the profile file.
-
- <p>When run with <samp><span class="command">gawk</span></samp>, the
profile is just a “pretty printed” version
-of the program. When run with <samp><span
class="command">pgawk</span></samp>, the profile contains execution
-counts for each statement in the program in the left margin, and function
-call counts for each function.
-
- <br><dt><code>-W re-interval</code><dt><code>--re-interval</code><dd><a
name="index-_0040code_007b_002d_002dre_002dinterval_007d-option-1547"></a><a
name="index-regular-expressions_002c-interval-expressions-and-1548"></a>Allows
interval expressions
-(see <a href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>)
-in regexps.
-Because interval expressions were traditionally not available in <samp><span
class="command">awk</span></samp>,
-<samp><span class="command">gawk</span></samp> does not provide them by
default. This prevents old <samp><span class="command">awk</span></samp>
-programs from breaking.
-
- <br><dt><code>-W source </code><var>program-text</var><dt><code>--source
</code><var>program-text</var><dd><a
name="index-_0040code_007b_002d_002dsource_007d-option-1549"></a><a
name="index-source-code_002c-mixing-1550"></a>Allows you to mix source code in
files with source
-code that you enter on the command line.
-Program source code is taken from the <var>program-text</var>.
-This is particularly useful
-when you have library functions that you want to use from your command-line
-programs (see <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH
Variable</a>).
-
- <br><dt><code>-W version</code><dt><code>--version</code><dd><a
name="index-_0040code_007b_002d_002dversion_007d-option-1551"></a><a
name="index-_0040command_007bgawk_007d_002c-versions-of_002c-information-about_0040comma_007b_007d-printing-1552"></a>Prints
version information for this particular copy of <samp><span
class="command">gawk</span></samp>.
-This allows you to determine if your copy of <samp><span
class="command">gawk</span></samp> is up to date
-with respect to whatever the Free Software Foundation is currently
-distributing.
-It is also useful for bug reports
-(see <a href="Bugs.html#Bugs">Bugs</a>).
-</dl>
-
- <p>As long as program text has been supplied,
-any other options are flagged as invalid with a warning message but
-are otherwise ignored.
-
- <p><a
name="index-_0040code_007b_002dF_007d-option_002c-_0040code_007b_002dFt_007d-sets-_0040code_007bFS_007d-to-TAB-1553"></a>In
compatibility mode, as a special case, if the value of <var>fs</var> supplied
-to the <samp><span class="option">-F</span></samp> option is `<samp><span
class="samp">t</span></samp>', then <code>FS</code> is set to the TAB
-character (<code>"\t"</code>). This is true only for <samp><span
class="option">--traditional</span></samp> and not
-for <samp><span class="option">--posix</span></samp>
-(see <a href="Field-Separators.html#Field-Separators">Field Separators</a>).
-
- <p><a
name="index-_0040code_007b_002df_007d-option_002c-on-command-line-1554"></a>The
<samp><span class="option">-f</span></samp> option may be used more than once
on the command line.
-If it is, <samp><span class="command">awk</span></samp> reads its program
source from all of the named files, as
-if they had been concatenated together into one big file. This is
-useful for creating libraries of <samp><span class="command">awk</span></samp>
functions. These functions
-can be written once and then retrieved from a standard place, instead
-of having to be included into each individual program.
-(As mentioned in
-<a href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a>,
-function names must be unique.)
-
- <p>Library functions can still be used, even if the program is entered at
the terminal,
-by specifying `<samp><span class="samp">-f /dev/tty</span></samp>'. After
typing your program,
-type <kbd>Ctrl-d</kbd> (the end-of-file character) to terminate it.
-(You may also use `<samp><span class="samp">-f -</span></samp>' to read
program source from the standard
-input but then you will not be able to also use the standard input as a
-source of data.)
-
- <p>Because it is clumsy using the standard <samp><span
class="command">awk</span></samp> mechanisms to mix source
-file and command-line <samp><span class="command">awk</span></samp> programs,
<samp><span class="command">gawk</span></samp> provides the
-<samp><span class="option">--source</span></samp> option. This does not
require you to pre-empt the standard
-input for your source code; it allows you to easily mix command-line
-and library source code
-(see <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>).
-
- <p><a name="index-_0040code_007b_002d_002dsource_007d-option-1555"></a>If
no <samp><span class="option">-f</span></samp> or <samp><span
class="option">--source</span></samp> option is specified, then <samp><span
class="command">gawk</span></samp>
-uses the first non-option command-line argument as the text of the
-program source code.
-
- <p><a
name="index-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1556"></a><a
name="index-lint-checking_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1557"></a><a
name="index-POSIX-mode-1558"></a>If the environment variable <samp><span
class="env">POSIXLY_CORRECT</span></samp> exists,
-then <samp><span class="command">gawk</span></samp> behaves in strict POSIX
mode, exactly as if
-you had supplied the <samp><span class="option">--posix</span></samp>
command-line option.
-Many GNU programs look for this environment variable to turn on
-strict POSIX mode. If <samp><span class="option">--lint</span></samp> is
supplied on the command line
-and <samp><span class="command">gawk</span></samp> turns on POSIX mode because
of <samp><span class="env">POSIXLY_CORRECT</span></samp>,
-then it issues a warning message indicating that POSIX
-mode is in effect.
-You would typically set this variable in your shell's startup file.
-For a Bourne-compatible shell (such as <samp><span
class="command">bash</span></samp>), you would add these
-lines to the <samp><span class="file">.profile</span></samp> file in your home
directory:
-
-<pre class="example"> POSIXLY_CORRECT=true
- export POSIXLY_CORRECT
-</pre>
- <p><a
name="index-_0040command_007bcsh_007d-utility_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1559"></a>For
a <samp><span class="command">csh</span></samp>-compatible
-shell,<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-you would add this line to the <samp><span class="file">.login</span></samp>
file in your home directory:
-
-<pre class="example"> setenv POSIXLY_CORRECT true
-</pre>
- <p><a
name="index-portability_002c-_0040code_007bPOSIXLY_005fCORRECT_007d-environment-variable-1560"></a>Having
<samp><span class="env">POSIXLY_CORRECT</span></samp> set is not recommended
for daily use,
-but it is good for testing the portability of your programs to other
-environments.
-<!-- ENDOFRANGE ocl -->
-<!-- ENDOFRANGE clo -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Not recommended.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Ordinal-Functions.html
===================================================================
RCS file: manual/html_node/Ordinal-Functions.html
diff -N manual/html_node/Ordinal-Functions.html
--- manual/html_node/Ordinal-Functions.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,158 +0,0 @@
-<html lang="en">
-<head>
-<title>Ordinal Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Cliff-Random-Function.html#Cliff-Random-Function"
title="Cliff Random Function">
-<link rel="next" href="Join-Function.html#Join-Function" title="Join Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Ordinal-Functions"></a>Next: <a rel="next" accesskey="n"
href="Join-Function.html#Join-Function">Join Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.6 Translating Between Characters and Numbers</h4>
-
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-character-values-as-numbers-1642"></a><a
name="index-functions_002c-library_002c-character-values-as-numbers-1643"></a><a
name="index-characters_002c-values-of-as-numbers-1644"></a><a
name="index-numbers_002c-as-values-of-characters-1645"></a>One commercial
implementation of <samp><span class="command">awk</span></samp> supplies a
built-in function,
-<code>ord</code>, which takes a character and returns the numeric value for
that
-character in the machine's character set. If the string passed to
-<code>ord</code> has more than one character, only the first one is used.
-
- <p>The inverse of this function is <code>chr</code> (from the function of
the same
-name in Pascal), which takes a number and returns the corresponding character.
-Both functions are written very nicely in <samp><span
class="command">awk</span></samp>; there is no real
-reason to build them into the <samp><span class="command">awk</span></samp>
interpreter:
-
- <p><a
name="index-_0040code_007bord_007d-user_002ddefined-function-1646"></a><a
name="index-_0040code_007bchr_007d-user_002ddefined-function-1647"></a>
-<pre class="example"> <!-- file eg/lib/ord.awk -->
- # ord.awk --- do ord and chr
-
- # Global identifiers:
- # _ord_: numerical values indexed by characters
- # _ord_init: function to initialize _ord_
- <!-- endfile -->
- <!-- file eg/lib/ord.awk -->
- BEGIN { _ord_init() }
-
- function _ord_init( low, high, i, t)
- {
- low = sprintf("%c", 7) # BEL is ascii 7
- if (low == "\a") { # regular ascii
- low = 0
- high = 127
- } else if (sprintf("%c", 128 + 7) == "\a") {
- # ascii, mark parity
- low = 128
- high = 255
- } else { # ebcdic(!)
- low = 0
- high = 255
- }
-
- for (i = low; i <= high; i++) {
- t = sprintf("%c", i)
- _ord_[t] = i
- }
- }
- <!-- endfile -->
-</pre>
- <p><a name="index-character-sets-1648"></a><a
name="index-character-encodings-1649"></a><a name="index-ASCII-1650"></a><a
name="index-EBCDIC-1651"></a><a name="index-mark-parity-1652"></a>Some
explanation of the numbers used by <code>chr</code> is worthwhile.
-The most prominent character set in use today is ASCII. Although an
-8-bit byte can hold 256 distinct values (from 0 to 255), ASCII only
-defines characters that use the values from 0 to 127.<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a>
-In the now distant past,
-at least one minicomputer manufacturer
-<!-- Pr1me, blech -->
-used ASCII, but with mark parity, meaning that the leftmost bit in the byte
-is always 1. This means that on those systems, characters
-have numeric values from 128 to 255.
-Finally, large mainframe systems use the EBCDIC character set, which
-uses all 256 values.
-While there are other character sets in use on some older systems,
-they are not really worth worrying about:
-
-<pre class="example"> <!-- file eg/lib/ord.awk -->
- function ord(str, c)
- {
- # only first character is of interest
- c = substr(str, 1, 1)
- return _ord_[c]
- }
-
- function chr(c)
- {
- # force c to be numeric by adding 0
- return sprintf("%c", c + 0)
- }
- <!-- endfile -->
-
- #### test code ####
- # BEGIN \
- # {
- # for (;;) {
- # printf("enter a character: ")
- # if (getline var <= 0)
- # break
- # printf("ord(%s) = %d\n", var, ord(var))
- # }
- # }
- <!-- endfile -->
-</pre>
- <p>An obvious improvement to these functions is to move the code for the
-<code>_ord_init<!-- /@w --></code> function into the body of the
<code>BEGIN</code> rule. It was
-written this way initially for ease of development.
-There is a “test program” in a <code>BEGIN</code> rule, to test the
-function. It is commented out for production use.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> ASCII
-has been extended in many countries to use the values from 128 to 255
-for country-specific characters. If your system uses these extensions,
-you can simplify <code>_ord_init</code> to simply loop from 0 to 255.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Other-Arguments.html
===================================================================
RCS file: manual/html_node/Other-Arguments.html
diff -N manual/html_node/Other-Arguments.html
--- manual/html_node/Other-Arguments.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,116 +0,0 @@
-<html lang="en">
-<head>
-<title>Other Arguments - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="prev" href="Options.html#Options" title="Options">
-<link rel="next" href="AWKPATH-Variable.html#AWKPATH-Variable" title="AWKPATH
Variable">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Other-Arguments"></a>Next: <a rel="next" accesskey="n"
href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>,
-Previous: <a rel="previous" accesskey="p"
href="Options.html#Options">Options</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.3 Other Command-Line Arguments</h3>
-
-<p><a name="index-command-line_002c-arguments-1561"></a><a
name="index-arguments_002c-command_002dline-1562"></a>
-Any additional arguments on the command line are normally treated as
-input files to be processed in the order specified. However, an
-argument that has the form <var>var</var><code>=</code><var>value</var>,
assigns
-the value <var>value</var> to the variable <var>var</var>—it does not
specify a
-file at all.
-(This was discussed earlier in
-<a href="Assignment-Options.html#Assignment-Options">Assignment Options</a>.)
-
- <p><a
name="index-_0040code_007bARGIND_007d-variable_002c-command_002dline-arguments-1563"></a><a
name="index-_0040code_007bARGC_007d_002f_0040code_007bARGV_007d-variables_002c-command_002dline-arguments-1564"></a>All
these arguments are made available to your <samp><span
class="command">awk</span></samp> program in the
-<code>ARGV</code> array (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>). Command-line options
-and the program text (if present) are omitted from <code>ARGV</code>.
-All other arguments, including variable assignments, are
-included. As each element of <code>ARGV</code> is processed, <samp><span
class="command">gawk</span></samp>
-sets the variable <code>ARGIND</code> to the index in <code>ARGV</code> of the
-current element.
-
- <p><a name="index-input-files_002c-variable-assignments-and-1565"></a>The
distinction between file name arguments and variable-assignment
-arguments is made when <samp><span class="command">awk</span></samp> is about
to open the next input file.
-At that point in execution, it checks the file name to see whether
-it is really a variable assignment; if so, <samp><span
class="command">awk</span></samp> sets the variable
-instead of reading a file.
-
- <p>Therefore, the variables actually receive the given values after all
-previously specified files have been read. In particular, the values of
-variables assigned in this fashion are <em>not</em> available inside a
-<code>BEGIN</code> rule
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>),
-because such rules are run before <samp><span
class="command">awk</span></samp> begins scanning the argument list.
-
- <p><a name="index-dark-corner_002c-escape-sequences-1566"></a>The variable
values given on the command line are processed for escape
-sequences (see <a href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a>).
-(d.c.)
-
- <p>In some earlier implementations of <samp><span
class="command">awk</span></samp>, when a variable assignment
-occurred before any file names, the assignment would happen <em>before</em>
-the <code>BEGIN</code> rule was executed. <samp><span
class="command">awk</span></samp>'s behavior was thus
-inconsistent; some command-line assignments were available inside the
-<code>BEGIN</code> rule, while others were not. Unfortunately,
-some applications came to depend
-upon this “feature.” When <samp><span
class="command">awk</span></samp> was changed to be more consistent,
-the <samp><span class="option">-v</span></samp> option was added to
accommodate applications that depended
-upon the old behavior.
-
- <p>The variable assignment feature is most useful for assigning to variables
-such as <code>RS</code>, <code>OFS</code>, and <code>ORS</code>, which control
input and
-output formats before scanning the data files. It is also useful for
-controlling state if multiple passes are needed over a data file. For
-example:
-
- <p><a name="index-files_002c-multiple-passes-over-1567"></a>
-<pre class="example"> awk 'pass == 1 { <var>pass 1 stuff</var> }
- pass == 2 { <var>pass 2 stuff</var> }' pass=1 mydata pass=2 mydata
-</pre>
- <p>Given the variable assignment feature, the <samp><span
class="option">-F</span></samp> option for setting
-the value of <code>FS</code> is not
-strictly necessary. It remains for historical compatibility.
-
- </body></html>
-
Index: manual/html_node/Other-Features.html
===================================================================
RCS file: manual/html_node/Other-Features.html
diff -N manual/html_node/Other-Features.html
--- manual/html_node/Other-Features.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,73 +0,0 @@
-<html lang="en">
-<head>
-<title>Other Features - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="Statements_002fLines.html#Statements_002fLines"
title="Statements/Lines">
-<link rel="next" href="When.html#When" title="When">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Other-Features"></a>Next: <a rel="next" accesskey="n"
href="When.html#When">When</a>,
-Previous: <a rel="previous" accesskey="p"
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.7 Other Features of <samp><span
class="command">awk</span></samp></h3>
-
-<p><a name="index-variables-165"></a>The <samp><span
class="command">awk</span></samp> language provides a number of predefined, or
-<dfn>built-in</dfn>, variables that your programs can use to get information
-from <samp><span class="command">awk</span></samp>. There are other variables
your program can set
-as well to control how <samp><span class="command">awk</span></samp> processes
your data.
-
- <p>In addition, <samp><span class="command">awk</span></samp> provides a
number of built-in functions for doing
-common computational and string-related operations.
-<samp><span class="command">gawk</span></samp> provides built-in functions for
working with timestamps,
-performing bit manipulation, and for runtime string translation.
-
- <p>As we develop our presentation of the <samp><span
class="command">awk</span></samp> language, we introduce
-most of the variables and many of the functions. They are defined
-systematically in <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>, and
-<a href="Built_002din.html#Built_002din">Built-in</a>.
-
- </body></html>
-
Index: manual/html_node/Other-Versions.html
===================================================================
RCS file: manual/html_node/Other-Versions.html
diff -N manual/html_node/Other-Versions.html
--- manual/html_node/Other-Versions.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,176 +0,0 @@
-<html lang="en">
-<head>
-<title>Other Versions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Installation.html#Installation" title="Installation">
-<link rel="prev" href="Bugs.html#Bugs" title="Bugs">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Other-Versions"></a>Previous: <a rel="previous" accesskey="p"
href="Bugs.html#Bugs">Bugs</a>,
-Up: <a rel="up" accesskey="u"
href="Installation.html#Installation">Installation</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">B.6 Other Freely Available <samp><span
class="command">awk</span></samp> Implementations</h3>
-
-<!-- STARTOFRANGE awkim -->
-<p><a name="index-_0040command_007bawk_007d_002c-implementations-1936"></a><a
name="index-Brennan_002c-Michael-1937"></a><blockquote>
-<i>It's kind of fun to put comments like this in your awk code.</i><br>
- <code>// Do C++ comments work? answer: yes! of course</code><br>
-Michael Brennan
-</blockquote>
-
- <p>There are three other freely available <samp><span
class="command">awk</span></samp> implementations.
-This section briefly describes where to get them:
-
-
-<a name="index-Kernighan_002c-Brian-1938"></a>
-<a
name="index-source-code_002c-Bell-Laboratories-_0040command_007bawk_007d-1939"></a>
-<dl><dt>Unix <samp><span class="command">awk</span></samp><dd>Brian Kernighan
has made his implementation of
-<samp><span class="command">awk</span></samp> freely available.
-You can retrieve this version via the World Wide Web from
-his home page.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-It is available in several archive formats:
-
- <dl>
-<dt>Shell archive<dd><a
href="http://cm.bell-labs.com/who/bwk/awk.shar">http://cm.bell-labs.com/who/bwk/awk.shar</a>
-
- <br><dt>Compressed <samp><span class="command">tar</span></samp>
file<dd><a
href="http://cm.bell-labs.com/who/bwk/awk.tar.gz">http://cm.bell-labs.com/who/bwk/awk.tar.gz</a>
-
- <br><dt>Zip file<dd><a
href="http://cm.bell-labs.com/who/bwk/awk.zip">http://cm.bell-labs.com/who/bwk/awk.zip</a>
-</dl>
-
- <p>This version requires an ISO C (1990 standard) compiler;
-the C compiler from
-GCC (the GNU Compiler Collection)
-works quite nicely.
-
- <p>See <a href="BTL.html#BTL">BTL</a>,
-for a list of extensions in this <samp><span class="command">awk</span></samp>
that are not in POSIX <samp><span class="command">awk</span></samp>.
-
- <p><a name="index-Brennan_002c-Michael-1940"></a><a
name="index-_0040command_007bmawk_007d-program-1941"></a><a
name="index-source-code_002c-_0040command_007bmawk_007d-1942"></a><br><dt><samp><span
class="command">mawk</span></samp><dd>Michael Brennan has written an
independent implementation of <samp><span class="command">awk</span></samp>,
-called <samp><span class="command">mawk</span></samp>. It is available under
the GPL
-(see <a href="Copying.html#Copying">Copying</a>),
-just as <samp><span class="command">gawk</span></samp> is.
-
- <p>You can get it via anonymous <samp><span
class="command">ftp</span></samp> to the host
-<code>ftp.whidbey.net<!-- /@w --></code>. Change directory to <samp><span
class="file">/pub/brennan</span></samp>.
-Use “binary” or “image” mode, and retrieve <samp><span
class="file">mawk1.3.3.tar.gz</span></samp>
-(or the latest version that is there).
-
- <p><samp><span class="command">gunzip</span></samp> may be used to
decompress this file. Installation
-is similar to <samp><span class="command">gawk</span></samp>'s
-(see <a href="Unix-Installation.html#Unix-Installation">Unix Installation</a>).
-
- <p><a
name="index-extensions_002c-_0040command_007bmawk_007d-1943"></a><samp><span
class="command">mawk</span></samp> has the following extensions that are not in
POSIX <samp><span class="command">awk</span></samp>:
-
- <ul>
-<li>The <code>fflush</code> built-in function for flushing buffered output
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-
- <li>The `<samp><span class="samp">**</span></samp>' and `<samp><span
class="samp">**=</span></samp>' operators
-(see <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>
-and also see
-<a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-
- <li>The use of <code>func</code> as an abbreviation for
<code>function</code>
-(see <a href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a>).
-
- <li>The `<samp><span class="samp">\x</span></samp>' escape sequence
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-
- <li>The <samp><span class="file">/dev/stdout</span></samp>, and
<samp><span class="file">/dev/stderr</span></samp>
-special files
-(see <a href="Special-Files.html#Special-Files">Special Files</a>).
-Use <code>"-"</code> instead of <code>"/dev/stdin"</code> with <samp><span
class="command">mawk</span></samp>.
-
- <li>The ability for <code>FS</code> and for the third
-argument to <code>split</code> to be null strings
-(see <a href="Single-Character-Fields.html#Single-Character-Fields">Single
Character Fields</a>).
-
- <li>The ability to delete all of an array at once with `<samp><span
class="samp">delete </span><var>array</var></samp>'
-(see <a href="Delete.html#Delete">Delete</a>).
-
- <li>The ability for <code>RS</code> to be a regexp
-(see <a href="Records.html#Records">Records</a>).
-
- <li>The <code>BINMODE</code> special variable for non-Unix operating
systems
-(see <a href="PC-Using.html#PC-Using">PC Using</a>).
-</ul>
-
- <p>The next version of <samp><span class="command">mawk</span></samp>
will support <code>nextfile</code>.
-
- <p><a name="index-Sumner_002c-Andrew-1944"></a><a
name="index-_0040command_007bawka_007d-compiler-for-_0040command_007bawk_007d-1945"></a><a
name="index-source-code_002c-_0040command_007bawka_007d-1946"></a><br><dt><samp><span
class="command">awka</span></samp><dd>Written by Andrew Sumner,
-<samp><span class="command">awka</span></samp> translates <samp><span
class="command">awk</span></samp> programs into C, compiles them,
-and links them with a library of functions that provides the core
-<samp><span class="command">awk</span></samp> functionality.
-It also has a number of extensions.
-
- <p>The <samp><span class="command">awk</span></samp> translator is
released under the GPL, and the library
-is under the LGPL.
-
- <p>To get <samp><span class="command">awka</span></samp>, go to <a
href="http://awka.sourceforge.net">http://awka.sourceforge.net</a>.
-You can reach Andrew Sumner at <a
href="mailto:address@hidden">address@hidden</a>.
-
- <p><a name="index-Beebe_002c-Nelson-H_002eF_002e_0040_003a-1947"></a><a
name="index-_0040command_007bpawk_007d-profiling-Bell-Labs-_0040command_007bawk_007d-1948"></a><br><dt><samp><span
class="command">pawk</span></samp><dd>Nelson H.F. Beebe at the University of
Utah has modified
-the Bell Labs <samp><span class="command">awk</span></samp> to provide timing
and profiling information.
-It is different from <samp><span class="command">pgawk</span></samp>
-(see <a href="Profiling.html#Profiling">Profiling</a>),
-in that it uses CPU-based profiling, not line-count
-profiling. You may find it at either
-<a
href="ftp://ftp.math.utah.edu/pub/pawk/pawk-20020210.tar.gz">ftp://ftp.math.utah.edu/pub/pawk/pawk-20020210.tar.gz</a>
-or
-<a
href="http://www.math.utah.edu/pub/pawk/pawk-20020210.tar.gz">http://www.math.utah.edu/pub/pawk/pawk-20020210.tar.gz</a>.
-
- </dl>
- <!-- ENDOFRANGE gligawk -->
-<!-- ENDOFRANGE ingawk -->
-<!-- ENDOFRANGE awkim -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <a
href="http://cm.bell-labs.com/who/bwk">http://cm.bell-labs.com/who/bwk</a></p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Output-Separators.html
===================================================================
RCS file: manual/html_node/Output-Separators.html
diff -N manual/html_node/Output-Separators.html
--- manual/html_node/Output-Separators.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,97 +0,0 @@
-<html lang="en">
-<head>
-<title>Output Separators - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="Print-Examples.html#Print-Examples" title="Print
Examples">
-<link rel="next" href="OFMT.html#OFMT" title="OFMT">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Output-Separators"></a>Next: <a rel="next" accesskey="n"
href="OFMT.html#OFMT">OFMT</a>,
-Previous: <a rel="previous" accesskey="p"
href="Print-Examples.html#Print-Examples">Print Examples</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.3 Output Separators</h3>
-
-<p><a name="index-_0040code_007bOFS_007d-variable-514"></a>As mentioned
previously, a <code>print</code> statement contains a list
-of items separated by commas. In the output, the items are normally
-separated by single spaces. However, this doesn't need to be the case;
-a single space is only the default. Any string of
-characters may be used as the <dfn>output field separator</dfn> by setting the
-built-in variable <code>OFS</code>. The initial value of this variable
-is the string <code>" "</code><!-- /@w -->—that is, a single space.
-
- <p>The output from an entire <code>print</code> statement is called an
-<dfn>output record</dfn>. Each <code>print</code> statement outputs one output
-record, and then outputs a string called the <dfn>output record separator</dfn>
-(or <code>ORS</code>). The initial
-value of <code>ORS</code> is the string <code>"\n"</code>; i.e., a newline
-character. Thus, each <code>print</code> statement normally makes a separate
line.
-
- <p><a name="index-output_002c-records-515"></a><a
name="index-output-record-separator_002c-See-_0040code_007bORS_007d-variable-516"></a><a
name="index-_0040code_007bORS_007d-variable-517"></a><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bOFS_007d_002f_0040code_007bORS_007d-variables_002c-assigning-values-to-518"></a>In
order to change how output fields and records are separated, assign
-new values to the variables <code>OFS</code> and <code>ORS</code>. The usual
-place to do this is in the <code>BEGIN</code> rule
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>), so
-that it happens before any input is processed. It can also be done
-with assignments on the command line, before the names of the input
-files, or using the <samp><span class="option">-v</span></samp> command-line
option
-(see <a href="Options.html#Options">Options</a>).
-The following example prints the first and second fields of each input
-record, separated by a semicolon, with a blank line added after each
-newline:
-
-<pre class="example"> $ awk 'BEGIN { OFS = ";"; ORS = "\n\n" }
- > { print $1, $2 }' BBS-list
- -| aardvark;555-5553
- -|
- -| alpo-net;555-3412
- -|
- -| barfly;555-7685
- ...
-</pre>
- <p>If the value of <code>ORS</code> does not contain a newline, the
program's output
-is run together on a single line.
-
- </body></html>
-
Index: manual/html_node/PC-Binary-Installation.html
===================================================================
RCS file: manual/html_node/PC-Binary-Installation.html
diff -N manual/html_node/PC-Binary-Installation.html
--- manual/html_node/PC-Binary-Installation.html 7 Feb 2007 02:36:56
-0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,89 +0,0 @@
-<html lang="en">
-<head>
-<title>PC Binary Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link rel="next" href="PC-Compiling.html#PC-Compiling" title="PC Compiling">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PC-Binary-Installation"></a>Next: <a rel="next" accesskey="n"
href="PC-Compiling.html#PC-Compiling">PC Compiling</a>,
-Up: <a rel="up" accesskey="u"
href="PC-Installation.html#PC-Installation">PC Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.1 Installing a Prepared Distribution for
PC Systems</h5>
-
-<p>If you have received a binary distribution prepared by the DOS
-maintainers, then <samp><span class="command">gawk</span></samp> and the
necessary support files appear
-under the <samp><span class="file">gnu</span></samp> directory, with
executables in <samp><span class="file">gnu/bin</span></samp>,
-libraries in <samp><span class="file">gnu/lib/awk</span></samp>, and manual
pages under <samp><span class="file">gnu/man</span></samp>.
-This is designed for easy installation to a <samp><span
class="file">/gnu</span></samp> directory on your
-drive—however, the files can be installed anywhere provided <samp><span
class="env">AWKPATH</span></samp> is
-set properly. Regardless of the installation directory, the first line of
-<samp><span class="file">igawk.cmd</span></samp> and <samp><span
class="file">igawk.bat</span></samp> (in <samp><span
class="file">gnu/bin</span></samp>) may need to be
-edited.
-
- <p>The binary distribution contains a separate file describing the
-contents. In particular, it may include more than one version of the
-<samp><span class="command">gawk</span></samp> executable.
-
- <p>OS/2 (32 bit, EMX) binary distributions are prepared for the <samp><span
class="file">/usr</span></samp>
-directory of your preferred drive. Set <samp><span
class="env">UnixROOT</span></samp> to your installation
-drive (e.g., `<samp><span class="samp">e:</span></samp>') if you want to
install <samp><span class="command">gawk</span></samp> onto another drive
-than the hardcoded default `<samp><span class="samp">c:</span></samp>'.
Executables appear in <samp><span class="file">/usr/bin</span></samp>,
-libraries under <samp><span class="file">/usr/share/awk</span></samp>, manual
pages under <samp><span class="file">/usr/man</span></samp>,
-Texinfo documentation under <samp><span class="file">/usr/info</span></samp>
and NLS files under <samp><span class="file">/usr/share/locale</span></samp>.
-If you already have a file <samp><span
class="file">/usr/info/dir</span></samp> from another package
-<em>do not overwrite it!</em> Instead enter the following commands at your
prompt
-(replace `<samp><span class="samp">x:</span></samp>' by your installation
drive):
-
-<pre class="example"> install-info --info-dir=x:/usr/info
x:/usr/info/gawk.info
- install-info --info-dir=x:/usr/info x:/usr/info/gawkinet.info
-</pre>
- <p>However, the files can be installed anywhere provided <samp><span
class="env">AWKPATH</span></samp> is
-set properly.
-
- <p>The binary distribution may contain a separate file containing additional
-or more detailed installation instructions.
-
- </body></html>
-
Index: manual/html_node/PC-Compiling.html
===================================================================
RCS file: manual/html_node/PC-Compiling.html
diff -N manual/html_node/PC-Compiling.html
--- manual/html_node/PC-Compiling.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,166 +0,0 @@
-<html lang="en">
-<head>
-<title>PC Compiling - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link rel="prev" href="PC-Binary-Installation.html#PC-Binary-Installation"
title="PC Binary Installation">
-<link rel="next" href="PC-Dynamic.html#PC-Dynamic" title="PC Dynamic">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PC-Compiling"></a>Next: <a rel="next" accesskey="n"
href="PC-Dynamic.html#PC-Dynamic">PC Dynamic</a>,
-Previous: <a rel="previous" accesskey="p"
href="PC-Binary-Installation.html#PC-Binary-Installation">PC Binary
Installation</a>,
-Up: <a rel="up" accesskey="u"
href="PC-Installation.html#PC-Installation">PC Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.2 Compiling <samp><span
class="command">gawk</span></samp> for PC Operating Systems</h5>
-
-<p><samp><span class="command">gawk</span></samp> can be compiled for MS-DOS,
Windows32, and OS/2 using the GNU
-development tools from DJ Delorie (DJGPP; MS-DOS only) or Eberhard
-Mattes (EMX; MS-DOS, Windows32 and OS/2). Microsoft Visual C/C++ can be used
-to build a Windows32 version, and Microsoft C/C++ can be
-used to build 16-bit versions for MS-DOS and OS/2.
-<!-- FIXME: -->
-(As of <samp><span class="command">gawk</span></samp> 3.1.2, the MSC version
doesn't work. However,
-the maintainer is working on fixing it.)
-The file
-<samp><span class="file">README_d/README.pc</span></samp> in the <samp><span
class="command">gawk</span></samp> distribution contains
-additional notes, and <samp><span class="file">pc/Makefile</span></samp>
contains important information on
-compilation options.
-
- <p>To build <samp><span class="command">gawk</span></samp> for MS-DOS,
Windows32, and OS/2 (16 bit only; for 32 bit
-(EMX) you can use the <samp><span class="command">configure</span></samp>
script and skip the following paragraphs;
-for details see below), copy the files in the <samp><span
class="file">pc</span></samp> directory (<em>except</em>
-for <samp><span class="file">ChangeLog</span></samp>) to the directory with
the rest of the <samp><span class="command">gawk</span></samp>
-sources. The <samp><span class="file">Makefile</span></samp> contains a
configuration section with comments and
-may need to be edited in order to work with your <samp><span
class="command">make</span></samp> utility.
-
- <p>The <samp><span class="file">Makefile</span></samp> contains a number of
targets for building various MS-DOS,
-Windows32, and OS/2 versions. A list of targets is printed if the <samp><span
class="command">make</span></samp>
-command is given without a target. As an example, to build <samp><span
class="command">gawk</span></samp>
-using the DJGPP tools, enter `<samp><span class="samp">make
djgpp</span></samp>'.
-(The DJGPP tools may be found at
-<a
href="ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/">ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/</a>.)
-
- <p>Using <samp><span class="command">make</span></samp> to run the standard
tests and to install <samp><span class="command">gawk</span></samp>
-requires additional Unix-like tools, including <samp><span
class="command">sh</span></samp>, <samp><span
class="command">sed</span></samp>, and
-<samp><span class="command">cp</span></samp>. In order to run the tests, the
<samp><span class="file">test/*.ok</span></samp> files may need to
-be converted so that they have the usual DOS-style end-of-line markers. Most
-of the tests work properly with Stewartson's shell along with the
-companion utilities or appropriate GNU utilities. However, some editing of
-<samp><span class="file">test/Makefile</span></samp> is required. It is
recommended that you copy the file
-<samp><span class="file">pc/Makefile.tst</span></samp> over the file
<samp><span class="file">test/Makefile</span></samp> as a
-replacement. Details can be found in <samp><span
class="file">README_d/README.pc</span></samp>
-and in the file <samp><span class="file">pc/Makefile.tst</span></samp>.
-
- <p>The 32 bit EMX version of <samp><span class="command">gawk</span></samp>
works “out of the box” under OS/2.
-In principle, it is possible to compile <samp><span
class="command">gawk</span></samp> the following way:
-
-<pre class="example"> $ ./configure
- $ make
-</pre>
- <p>This is not recommended, though. To get an OMF executable you should
-use the following commands at your <samp><span
class="command">sh</span></samp> prompt:
-
-<pre class="example"> $ CPPFLAGS="-D__ST_MT_ERRNO__"
- $ export CPPFLAGS
- $ CFLAGS="-O2 -Zomf -Zmt"
- $ export CFLAGS
- $ LDFLAGS="-s -Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack
0x8000"
- $ export LDFLAGS
- $ RANLIB="echo"
- $ export RANLIB
- $ ./configure --prefix=c:/usr --without-included-gettext
- $ make AR=emxomfar
-</pre>
- <p>These are just suggestions. You may use any other set of
(self-consistent)
-environment variables and compiler flags.
-
- <p>To get an FHS-compliant file hierarchy it is recommended to use the
additional
-<samp><span class="command">configure</span></samp> options <samp><span
class="option">--infodir=c:/usr/share/info</span></samp>, <samp><span
class="option">--mandir=c:/usr/share/man</span></samp>
-and <samp><span class="option">--libexecdir=c:/usr/lib</span></samp>.
-
- <p>The internal <code>gettext</code> library tends to be problematic. It is
therefore recommended
-to use either an external one (<samp><span
class="option">--without-included-gettext</span></samp>) or to disable
-NLS entirely (<samp><span class="option">--disable-nls</span></samp>).
-
- <p>If you use GCC 2.95 or newer it is recommended to use also:
-
-<pre class="example"> $ LIBS="-lgcc"
- $ export LIBS
-</pre>
- <p>You can also get an <code>a.out</code> executable if you prefer:
-
-<pre class="example"> $ CPPFLAGS="-D__ST_MT_ERRNO__"
- $ export CPPFLAGS
- $ CFLAGS="-O2 -Zmt"
- $ export CFLAGS
- $ LDFLAGS="-s -Zstack 0x8000"
- $ LIBS="-lgcc"
- $ unset RANLIB
- $ ./configure --prefix=c:/usr --without-included-gettext
- $ make
-</pre>
- <blockquote>
-<b>NOTE:</b> Even if the compiled <samp><span
class="command">gawk.exe</span></samp> (<code>a.out</code>) executable
-contains a DOS header, it does <em>not</em> work under DOS. To compile an
executable
-that runs under DOS, <code>"-DPIPES_SIMULATED"</code> must be added to
<samp><span class="env">CPPFLAGS</span></samp>.
-But then some nonstandard extensions of <samp><span
class="command">gawk</span></samp> (e.g., `<samp><span
class="samp">|&</span></samp>') do not work!
-</blockquote>
-
- <p>After compilation the internal tests can be performed. Enter
-`<samp><span class="samp">make check CMP="diff -a"</span></samp>' at your
command prompt. All tests
-but the <code>pid</code> test are expected to work properly. The
<code>pid</code>
-test fails because child processes are not started by <code>fork()</code>.
-
- <p>`<samp><span class="samp">make install</span></samp>' works as expected.
-
- <blockquote>
-<b>NOTE:</b> Most OS/2 ports of GNU <samp><span
class="command">make</span></samp> are not able to handle
-the Makefiles of this package. If you encounter any problems with <samp><span
class="command">make</span></samp>
-try GNU Make 3.79.1 or later versions. You should find the latest
-version on <a
href="http://www.unixos2.org/sw/pub/binary/make/">http://www.unixos2.org/sw/pub/binary/make/</a>
or on
-<a href="ftp://hobbes.nmsu.edu/pub/os2/">ftp://hobbes.nmsu.edu/pub/os2/</a>.
-</blockquote>
-
- </body></html>
-
Index: manual/html_node/PC-Dynamic.html
===================================================================
RCS file: manual/html_node/PC-Dynamic.html
diff -N manual/html_node/PC-Dynamic.html
--- manual/html_node/PC-Dynamic.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,103 +0,0 @@
-<html lang="en">
-<head>
-<title>PC Dynamic - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link rel="prev" href="PC-Compiling.html#PC-Compiling" title="PC Compiling">
-<link rel="next" href="PC-Using.html#PC-Using" title="PC Using">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PC-Dynamic"></a>Next: <a rel="next" accesskey="n"
href="PC-Using.html#PC-Using">PC Using</a>,
-Previous: <a rel="previous" accesskey="p"
href="PC-Compiling.html#PC-Compiling">PC Compiling</a>,
-Up: <a rel="up" accesskey="u"
href="PC-Installation.html#PC-Installation">PC Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.3 Compiling <samp><span
class="command">gawk</span></samp> For Dynamic Libraries</h5>
-
-<!-- From README_d/README.pcdynamic -->
-<!-- 11 June 2003 -->
-<p>To compile <samp><span class="command">gawk</span></samp> with dynamic
extension support,
-uncomment the definitions of <code>DYN_FLAGS</code>, <code>DYN_EXP</code>,
-<code>DYN_OBJ</code>, and <code>DYN_MAKEXP</code> in the configuration section
of
-the <samp><span class="file">Makefile</span></samp>. There are two definitions
for <code>DYN_MAKEXP</code>:
-pick the one that matches your target.
-
- <p>To build some of the example extension libraries, <samp><span
class="command">cd</span></samp> to the
-extension directory and copy <samp><span
class="file">Makefile.pc</span></samp> to <samp><span
class="file">Makefile</span></samp>. You
-can then build using the same two targets. To run the example
-<samp><span class="command">awk</span></samp> scripts, you'll need to either
change the call to
-the <code>extension</code> function to match the name of the library (for
-instance, change <code>"./ordchr.so"</code> to <code>"ordchr.dll"</code> or
simply
-<code>"ordchr"</code>), or rename the library to match the call (for instance,
-rename <samp><span class="file">ordchr.dll</span></samp> to <samp><span
class="file">ordchr.so</span></samp>).
-
- <p>If you build <samp><span class="command">gawk.exe</span></samp> with one
compiler but want to build
-an extension library with the other, you need to copy the import
-library. Visual C uses a library called <samp><span
class="file">gawk.lib</span></samp>, while MinGW uses
-a library called <samp><span class="file">libgawk.a</span></samp>. These files
are equivalent and will
-interoperate if you give them the correct name. The resulting shared
-libraries are also interoperable.
-
- <p>To create your own extension library, you can use the examples as models,
-but you're essentially on your own. Post to <code>comp.lang.awk</code> or
-send electronic mail to <a href="mailto:address@hidden">address@hidden</a> if
you have problems getting
-started. If you need to access functions or variables which are not
-exported by <samp><span class="command">gawk.exe</span></samp>, add them to
<samp><span class="file">gawkw32.def</span></samp> and
-rebuild. You should also add <code>ATTRIBUTE_EXPORTED</code> to the declaration
-in <samp><span class="file">awk.h</span></samp> of any variables you add to
<samp><span class="file">gawkw32.def</span></samp>.
-
- <p>Note that extension libraries have the name of the <samp><span
class="command">awk</span></samp>
-executable embedded in them at link time, so they will work only
-with <samp><span class="command">gawk.exe</span></samp>. In particular, they
won't work if you
-rename <samp><span class="command">gawk.exe</span></samp> to <samp><span
class="command">awk.exe</span></samp> or if you try to use
-<samp><span class="command">pgawk.exe</span></samp>. You can perform profiling
by temporarily renaming
-<samp><span class="command">pgawk.exe</span></samp> to <samp><span
class="command">gawk.exe</span></samp>. You can resolve this problem
-by changing the program name in the definition of <code>DYN_MAKEXP</code>
-for your compiler.
-
- <p>On Windows32, libraries are sought first in the current directory, then
in
-the directory containing <samp><span class="command">gawk.exe</span></samp>,
and finally through the
-<samp><span class="env">PATH</span></samp> environment variable.
-
- </body></html>
-
Index: manual/html_node/PC-Installation.html
===================================================================
RCS file: manual/html_node/PC-Installation.html
diff -N manual/html_node/PC-Installation.html
--- manual/html_node/PC-Installation.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-<html lang="en">
-<head>
-<title>PC Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Non_002dUnix-Installation.html#Non_002dUnix-Installation"
title="Non-Unix Installation">
-<link rel="prev" href="BeOS-Installation.html#BeOS-Installation" title="BeOS
Installation">
-<link rel="next" href="VMS-Installation.html#VMS-Installation" title="VMS
Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PC-Installation"></a>Next: <a rel="next" accesskey="n"
href="VMS-Installation.html#VMS-Installation">VMS Installation</a>,
-Previous: <a rel="previous" accesskey="p"
href="BeOS-Installation.html#BeOS-Installation">BeOS Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.3.3 Installation on PC Operating Systems</h4>
-
-<p><a
name="index-PC-operating-systems_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1900"></a><a
name="index-operating-systems_002c-PC_0040comma_007b_007d-_0040command_007bgawk_007d-on_002c-installing-1901"></a>This
section covers installation and usage of <samp><span
class="command">gawk</span></samp> on x86 machines
-running DOS, any version of Windows, or OS/2.
-In this section, the term “Windows32”
-refers to any of Windows-95/98/ME/NT/2000.
-
- <p>The limitations of DOS (and DOS shells under Windows or OS/2) has meant
-that various “DOS extenders” are often used with programs such as
-<samp><span class="command">gawk</span></samp>. The varying capabilities of
Microsoft Windows 3.1
-and Windows32 can add to the confusion. For an overview of the
-considerations, please refer to <samp><span
class="file">README_d/README.pc</span></samp> in the
-distribution.
-
-<ul class="menu">
-<li><a accesskey="1"
href="PC-Binary-Installation.html#PC-Binary-Installation">PC Binary
Installation</a>: Installing a prepared distribution.
-<li><a accesskey="2" href="PC-Compiling.html#PC-Compiling">PC Compiling</a>:
Compiling <samp><span class="command">gawk</span></samp> for
MS-DOS, Windows32,
- and OS/2.
-<li><a accesskey="3" href="PC-Dynamic.html#PC-Dynamic">PC Dynamic</a>:
Compiling <samp><span class="command">gawk</span></samp> for dynamic
libraries.
-<li><a accesskey="4" href="PC-Using.html#PC-Using">PC Using</a>:
Running <samp><span class="command">gawk</span></samp> on MS-DOS,
Windows32 and
- OS/2.
-<li><a accesskey="5" href="Cygwin.html#Cygwin">Cygwin</a>:
Building and running <samp><span class="command">gawk</span></samp> for
- Cygwin.
-</ul>
-
- </body></html>
-
Index: manual/html_node/PC-Using.html
===================================================================
RCS file: manual/html_node/PC-Using.html
diff -N manual/html_node/PC-Using.html
--- manual/html_node/PC-Using.html 7 Feb 2007 02:36:56 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,166 +0,0 @@
-<html lang="en">
-<head>
-<title>PC Using - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link rel="prev" href="PC-Dynamic.html#PC-Dynamic" title="PC Dynamic">
-<link rel="next" href="Cygwin.html#Cygwin" title="Cygwin">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="PC-Using"></a>Next: <a rel="next" accesskey="n"
href="Cygwin.html#Cygwin">Cygwin</a>,
-Previous: <a rel="previous" accesskey="p"
href="PC-Dynamic.html#PC-Dynamic">PC Dynamic</a>,
-Up: <a rel="up" accesskey="u"
href="PC-Installation.html#PC-Installation">PC Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.3.4 Using <samp><span
class="command">gawk</span></samp> on PC Operating Systems</h5>
-
-<!-- STARTOFRANGE opgawx -->
-<p><a
name="index-operating-systems_002c-PC_002c-_0040command_007bgawk_007d-on-1902"></a><!--
STARTOFRANGE pcgawon -->
-<a
name="index-PC-operating-systems_002c-_0040command_007bgawk_007d-on-1903"></a>
-With the exception of the Cygwin environment,
-the `<samp><span class="samp">|&</span></samp>' operator and TCP/IP
networking
-(see <a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a>)
-are not supported for MS-DOS or MS-Windows. EMX (OS/2 only) does support
-at least the `<samp><span class="samp">|&</span></samp>' operator.
-
- <p><a name="index-search-paths-1904"></a><a
name="index-_0040command_007bgawk_007d_002c-OS_002f2-version-of-1905"></a><a
name="index-_0040command_007bgawk_007d_002c-MS_002dDOS-version-of-1906"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1907"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-_0040code_007bAWKPATH_007d-variable-and-1908"></a><a
name="index-_0040code_007bAWKPATH_007d-environment-variable-1909"></a>The OS/2
and MS-DOS versions of <samp><span class="command">gawk</span></samp> search
for program files as
-described in <a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH
Variable</a>.
-However, semicolons (rather than colons) separate elements
-in the <samp><span class="env">AWKPATH</span></samp> variable. If <samp><span
class="env">AWKPATH</span></samp> is not set or is empty,
-then the default search path for OS/2 (16 bit) and MS-DOS versions is
-<code>".;c:/lib/awk;c:/gnu/lib/awk"<!-- /@w --></code>.
-
- <p>The search path for OS/2 (32 bit, EMX) is determined by the prefix
directory
-(most likely <samp><span class="file">/usr</span></samp> or <samp><span
class="file">c:/usr</span></samp>) that has been specified as an option of
-the <samp><span class="command">configure</span></samp> script like it is the
case for the Unix versions.
-If <samp><span class="file">c:/usr</span></samp> is the prefix directory then
the default search path contains <samp><span class="file">.</span></samp>
-and <samp><span class="file">c:/usr/share/awk</span></samp>.
-Additionally, to support binary distributions of <samp><span
class="command">gawk</span></samp> for OS/2
-systems whose drive `<samp><span class="samp">c:</span></samp>' might not
support long file names or might not exist
-at all, there is a special environment variable. If <samp><span
class="env">UnixROOT</span></samp> specifies
-a drive then this specific drive is also searched for program files.
-E.g., if <samp><span class="env">UnixROOT</span></samp> is set to <samp><span
class="file">e:</span></samp> the complete default search path is
-<code>".;c:/usr/share/awk;e:/usr/share/awk"<!-- /@w --></code>.
-
- <p>An <samp><span class="command">sh</span></samp>-like shell (as opposed
to <samp><span class="command">command.com</span></samp> under MS-DOS
-or <samp><span class="command">cmd.exe</span></samp> under OS/2) may be useful
for <samp><span class="command">awk</span></samp> programming.
-Ian Stewartson has written an excellent shell for MS-DOS and OS/2,
-Daisuke Aoyama has ported GNU <samp><span class="command">bash</span></samp>
to MS-DOS using the DJGPP tools,
-and several shells are available for OS/2, including <samp><span
class="command">ksh</span></samp>. The file
-<samp><span class="file">README_d/README.pc</span></samp> in the <samp><span
class="command">gawk</span></samp> distribution contains
-information on these shells. Users of Stewartson's shell on DOS should
-examine its documentation for handling command lines; in particular,
-the setting for <samp><span class="command">gawk</span></samp> in the shell
configuration may need to be
-changed and the <code>ignoretype</code> option may also be of interest.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-1910"></a><a
name="index-_0040code_007bBINMODE_007d-variable-1911"></a>Under OS/2 and DOS,
<samp><span class="command">gawk</span></samp> (and many other text programs)
silently
-translate end-of-line <code>"\r\n"</code> to <code>"\n"</code> on input and
<code>"\n"</code>
-to <code>"\r\n"</code> on output. A special <code>BINMODE</code> variable
allows
-control over these translations and is interpreted as follows:
-
- <ul>
-<li>If <code>BINMODE</code> is `<samp><span class="samp">"r"</span></samp>', or
-<code>(BINMODE & 1)</code> is nonzero, then
-binary mode is set on read (i.e., no translations on reads).
-
- <li>If <code>BINMODE</code> is <code>"w"</code>, or
-<code>(BINMODE & 2)</code> is nonzero, then
-binary mode is set on write (i.e., no translations on writes).
-
- <li>If <code>BINMODE</code> is <code>"rw"</code> or <code>"wr"</code>,
-binary mode is set for both read and write
-(same as <code>(BINMODE & 3)</code>).
-
- <li><code>BINMODE=</code><var>non-null-string</var> is
-the same as `<samp><span class="samp">BINMODE=3</span></samp>' (i.e., no
translations on
-reads or writes). However, <samp><span class="command">gawk</span></samp>
issues a warning
-message if the string is not one of <code>"rw"</code> or <code>"wr"</code>.
-</ul>
-
-<p class="noindent">The modes for standard input and standard output are set
one time
-only (after the
-command line is read, but before processing any of the <samp><span
class="command">awk</span></samp> program).
-Setting <code>BINMODE</code> for standard input or
-standard output is accomplished by using an
-appropriate `<samp><span class="samp">-v BINMODE=</span><var>N</var></samp>'
option on the command line.
-<code>BINMODE</code> is set at the time a file or pipe is opened and cannot be
-changed mid-stream.
-
- <p>The name <code>BINMODE</code> was chosen to match <samp><span
class="command">mawk</span></samp>
-(see <a href="Other-Versions.html#Other-Versions">Other Versions</a>).
-Both <samp><span class="command">mawk</span></samp> and <samp><span
class="command">gawk</span></samp> handle <code>BINMODE</code> similarly;
however,
-<samp><span class="command">mawk</span></samp> adds a `<samp><span
class="samp">-W BINMODE=</span><var>N</var></samp>' option and an environment
-variable that can set <code>BINMODE</code>, <code>RS</code>, and
<code>ORS</code>. The
-files <samp><span class="file">binmode[1-3].awk</span></samp> (under
<samp><span class="file">gnu/lib/awk</span></samp> in some of the
-prepared distributions) have been chosen to match <samp><span
class="command">mawk</span></samp>'s `<samp><span class="samp">-W
-BINMODE=</span><var>N</var></samp>' option. These can be changed or
discarded; in particular,
-the setting of <code>RS</code> giving the fewest “surprises” is
open to debate.
-<samp><span class="command">mawk</span></samp> uses `<samp><span
class="samp">RS = "\r\n"</span></samp>' if binary mode is set on read, which is
-appropriate for files with the DOS-style end-of-line.
-
- <p>To illustrate, the following examples set binary mode on writes for
standard
-output and other files, and set <code>ORS</code> as the “usual”
DOS-style
-end-of-line:
-
-<pre class="example"> gawk -v BINMODE=2 -v ORS="\r\n" ...
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> gawk -v BINMODE=w -f binmode2.awk ...
-</pre>
- <p class="noindent">These give the same result as the `<samp><span
class="samp">-W BINMODE=2</span></samp>' option in
-<samp><span class="command">mawk</span></samp>.
-The following changes the record separator to <code>"\r\n"</code> and sets
binary
-mode on reads, but does not affect the mode on standard input:
-
-<pre class="example"> gawk -v RS="\r\n" --source "BEGIN { BINMODE = 1 }"
...
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> gawk -f binmode1.awk ...
-</pre>
- <p class="noindent">With proper quoting, in the first example the setting
of <code>RS</code> can be
-moved into the <code>BEGIN</code> rule.
-
- </body></html>
-
Index: manual/html_node/POSIX.html
===================================================================
RCS file: manual/html_node/POSIX.html
diff -N manual/html_node/POSIX.html
--- manual/html_node/POSIX.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-<html lang="en">
-<head>
-<title>POSIX - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Language-History.html#Language-History" title="Language
History">
-<link rel="prev" href="SVR4.html#SVR4" title="SVR4">
-<link rel="next" href="BTL.html#BTL" title="BTL">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="POSIX"></a>Next: <a rel="next" accesskey="n"
href="BTL.html#BTL">BTL</a>,
-Previous: <a rel="previous" accesskey="p" href="SVR4.html#SVR4">SVR4</a>,
-Up: <a rel="up" accesskey="u"
href="Language-History.html#Language-History">Language History</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">A.3 Changes Between SVR4 and POSIX <samp><span
class="command">awk</span></samp></h3>
-
-<p><a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR4-and-POSIX-_0040command_007bawk_007d-1827"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-changes-in-_0040command_007bawk_007d-versions-1828"></a>
-The POSIX Command Language and Utilities standard for <samp><span
class="command">awk</span></samp> (1992)
-introduced the following changes into the language:
-
- <ul>
-<li>The use of <samp><span class="option">-W</span></samp> for
implementation-specific options
-(see <a href="Options.html#Options">Options</a>).
-
- <li>The use of <code>CONVFMT</code> for controlling the conversion of
numbers
-to strings (see <a href="Conversion.html#Conversion">Conversion</a>).
-
- <li>The concept of a numeric string and tighter comparison rules to go
-with it (see <a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing
and Comparison</a>).
-
- <li>More complete documentation of many of the previously undocumented
-features of the language.
-</ul>
-
- <p>The following common extensions are not permitted by the POSIX
-standard:
-
-<!-- IMPORTANT! Keep this list in sync with the one in node Options -->
-<ul>
-<li><code>\x</code> escape sequences are not recognized
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-
- <li>Newlines do not act as whitespace to separate fields when
<code>FS</code> is
-equal to a single space
-(see <a href="Fields.html#Fields">Fields</a>).
-
- <li>Newlines are not allowed after `<samp><span
class="samp">?</span></samp>' or `<samp><span class="samp">:</span></samp>'
-(see <a href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>).
-
- <li>The synonym <code>func</code> for the keyword <code>function</code>
is not
-recognized (see <a href="Definition-Syntax.html#Definition-Syntax">Definition
Syntax</a>).
-
- <li>The operators `<samp><span class="samp">**</span></samp>' and
`<samp><span class="samp">**=</span></samp>' cannot be used in
-place of `<samp><span class="samp">^</span></samp>' and `<samp><span
class="samp">^=</span></samp>' (see <a
href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>,
-and <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-
- <li>Specifying `<samp><span class="samp">-Ft</span></samp>' on the
command line does not set the value
-of <code>FS</code> to be a single TAB character
-(see <a href="Field-Separators.html#Field-Separators">Field Separators</a>).
-
- <li>The <code>fflush</code> built-in function is not supported
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-</ul>
- <!-- ENDOFRANGE gawkv -->
-
- </body></html>
-
Index: manual/html_node/POSIX_002fGNU.html
===================================================================
RCS file: manual/html_node/POSIX_002fGNU.html
diff -N manual/html_node/POSIX_002fGNU.html
--- manual/html_node/POSIX_002fGNU.html 31 Aug 2004 22:04:11 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,311 +0,0 @@
-<html lang="en">
-<head>
-<title>POSIX/GNU - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Language-History.html#Language-History" title="Language
History">
-<link rel="prev" href="BTL.html#BTL" title="BTL">
-<link rel="next" href="Contributors.html#Contributors" title="Contributors">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="POSIX_002fGNU"></a>Next: <a rel="next" accesskey="n"
href="Contributors.html#Contributors">Contributors</a>,
-Previous: <a rel="previous" accesskey="p" href="BTL.html#BTL">BTL</a>,
-Up: <a rel="up" accesskey="u"
href="Language-History.html#Language-History">Language History</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">A.5 Extensions in <samp><span
class="command">gawk</span></samp> Not in POSIX <samp><span
class="command">awk</span></samp></h3>
-
-<!-- STARTOFRANGE fripls -->
-<p><a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-extensions-1833"></a><!--
STARTOFRANGE exgnot -->
-<a
name="index-extensions_002c-in-_0040command_007bgawk_007d_002c-not-in-POSIX-_0040command_007bawk_007d-1834"></a><!--
STARTOFRANGE posnot -->
-<a
name="index-POSIX_002c-_0040command_007bgawk_007d-extensions-not-included-in-1835"></a>The
GNU implementation, <samp><span class="command">gawk</span></samp>, adds a
large number of features.
-This section lists them in the order they were added to <samp><span
class="command">gawk</span></samp>.
-They can all be disabled with either the <samp><span
class="option">--traditional</span></samp> or
-<samp><span class="option">--posix</span></samp> options
-(see <a href="Options.html#Options">Options</a>).
-
- <p>Version 2.10 of <samp><span class="command">gawk</span></samp>
introduced the following features:
-
- <ul>
-<li>The <samp><span class="env">AWKPATH</span></samp> environment variable for
specifying a path search for
-the <samp><span class="option">-f</span></samp> command-line option
-(see <a href="Options.html#Options">Options</a>).
-
- <li>The <code>IGNORECASE</code> variable and its effects
-(see <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>).
-
- <li>The <samp><span class="file">/dev/stdin</span></samp>, <samp><span
class="file">/dev/stdout</span></samp>, <samp><span
class="file">/dev/stderr</span></samp> and
-<samp><span class="file">/dev/fd/</span><var>N</var></samp> special file names
-(see <a href="Special-Files.html#Special-Files">Special Files</a>).
-</ul>
-
- <p>Version 2.13 of <samp><span class="command">gawk</span></samp>
introduced the following features:
-
- <ul>
-<li>The <code>FIELDWIDTHS</code> variable and its effects
-(see <a href="Constant-Size.html#Constant-Size">Constant Size</a>).
-
- <li>The <code>systime</code> and <code>strftime</code> built-in functions
for obtaining
-and printing timestamps
-(see <a href="Time-Functions.html#Time-Functions">Time Functions</a>).
-
- <li>The <samp><span class="option">-W lint</span></samp> option to
provide error and portability checking
-for both the source code and at runtime
-(see <a href="Options.html#Options">Options</a>).
-
- <li>The <samp><span class="option">-W compat</span></samp> option to turn
off the GNU extensions
-(see <a href="Options.html#Options">Options</a>).
-
- <li>The <samp><span class="option">-W posix</span></samp> option for full
POSIX compliance
-(see <a href="Options.html#Options">Options</a>).
-</ul>
-
- <p>Version 2.14 of <samp><span class="command">gawk</span></samp>
introduced the following feature:
-
- <ul>
-<li>The <code>next file</code> statement for skipping to the next data file
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-</ul>
-
- <p>Version 2.15 of <samp><span class="command">gawk</span></samp>
introduced the following features:
-
- <ul>
-<li>The <code>ARGIND</code> variable, which tracks the movement of
<code>FILENAME</code>
-through <code>ARGV</code> (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-
- <li>The <code>ERRNO</code> variable, which contains the system error
message when
-<code>getline</code> returns −1 or <code>close</code> fails
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-
- <li>The <samp><span class="file">/dev/pid</span></samp>, <samp><span
class="file">/dev/ppid</span></samp>, <samp><span
class="file">/dev/pgrpid</span></samp>, and
-<samp><span class="file">/dev/user</span></samp> file name interpretation
-(see <a href="Special-Files.html#Special-Files">Special Files</a>).
-
- <li>The ability to delete all of an array at once with `<samp><span
class="samp">delete </span><var>array</var></samp>'
-(see <a href="Delete.html#Delete">Delete</a>).
-
- <li>The ability to use GNU-style long-named options that start with
<samp><span class="option">--</span></samp>
-(see <a href="Options.html#Options">Options</a>).
-
- <li>The <samp><span class="option">--source</span></samp> option for
mixing command-line and library-file
-source code
-(see <a href="Options.html#Options">Options</a>).
-</ul>
-
- <p>Version 3.0 of <samp><span class="command">gawk</span></samp> introduced
the following features:
-
- <ul>
-<li><code>IGNORECASE</code> changed, now applying to string comparison as well
-as regexp operations
-(see <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>).
-
- <li>The <code>RT</code> variable that contains the input text that
-matched <code>RS</code>
-(see <a href="Records.html#Records">Records</a>).
-
- <li>Full support for both POSIX and GNU regexps
-(see <a href="Regexp.html#Regexp">Regexp</a>).
-
- <li>The <code>gensub</code> function for more powerful text manipulation
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <li>The <code>strftime</code> function acquired a default time format,
-allowing it to be called with no arguments
-(see <a href="Time-Functions.html#Time-Functions">Time Functions</a>).
-
- <li>The ability for <code>FS</code> and for the third
-argument to <code>split</code> to be null strings
-(see <a href="Single-Character-Fields.html#Single-Character-Fields">Single
Character Fields</a>).
-
- <li>The ability for <code>RS</code> to be a regexp
-(see <a href="Records.html#Records">Records</a>).
-
- <li>The <code>next file</code> statement became <code>nextfile</code>
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-
- <li>The <samp><span class="option">--lint-old</span></samp> option to
-warn about constructs that are not available in
-the original Version 7 Unix version of <samp><span
class="command">awk</span></samp>
-(see <a href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a>).
-
- <li>The <samp><span class="option">-m</span></samp> option and the
<code>fflush</code> function from the
-Bell Laboratories research version of <samp><span
class="command">awk</span></samp>
-(see <a href="Options.html#Options">Options</a>; also
-see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-
- <li>The <samp><span class="option">--re-interval</span></samp> option to
provide interval expressions in regexps
-(see <a href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>).
-
- <li>The <samp><span class="option">--traditional</span></samp> option was
added as a better name for
-<samp><span class="option">--compat</span></samp> (see <a
href="Options.html#Options">Options</a>).
-
- <li>The use of GNU Autoconf to control the configuration process
-(see <a href="Quick-Installation.html#Quick-Installation">Quick
Installation</a>).
-
- <li>Amiga support
-(see <a href="Amiga-Installation.html#Amiga-Installation">Amiga
Installation</a>).
-
- </ul>
-
- <p>Version 3.1 of <samp><span class="command">gawk</span></samp> introduced
the following features:
-
- <ul>
-<li>The <code>BINMODE</code> special variable for non-POSIX systems,
-which allows binary I/O for input and/or output files
-(see <a href="PC-Using.html#PC-Using">PC Using</a>).
-
- <li>The <code>LINT</code> special variable, which dynamically controls
lint warnings
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-
- <li>The <code>PROCINFO</code> array for providing process-related
information
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-
- <li>The <code>TEXTDOMAIN</code> special variable for setting an
application's
-internationalization text domain
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>,
-and
-<a
href="Internationalization.html#Internationalization">Internationalization</a>).
-
- <li>The ability to use octal and hexadecimal constants in <samp><span
class="command">awk</span></samp>
-program source code
-(see <a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>).
-
- <li>The `<samp><span class="samp">|&</span></samp>' operator for
two-way I/O to a coprocess
-(see <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>).
-
- <li>The <samp><span class="file">/inet</span></samp> special files for
TCP/IP networking using `<samp><span class="samp">|&</span></samp>'
-(see <a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a>).
-
- <li>The optional second argument to <code>close</code> that allows
closing one end
-of a two-way pipe to a coprocess
-(see <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>).
-
- <li>The optional third argument to the <code>match</code> function
-for capturing text-matching subexpressions within a regexp
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <li>Positional specifiers in <code>printf</code> formats for
-making translations easier
-(see <a href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a>).
-
- <li>The <code>asort</code> and <code>asorti</code> functions for sorting
arrays
-(see <a href="Array-Sorting.html#Array-Sorting">Array Sorting</a>).
-
- <li>The <code>bindtextdomain</code>, <code>dcgettext</code> and
<code>dcngettext</code> functions
-for internationalization
-(see <a href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a>).
-
- <li>The <code>extension</code> built-in function and the ability to add
-new built-in functions dynamically
-(see <a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a>).
-
- <li>The <code>mktime</code> built-in function for creating timestamps
-(see <a href="Time-Functions.html#Time-Functions">Time Functions</a>).
-
- <li>The
-<code>and</code>,
-<code>or</code>,
-<code>xor</code>,
-<code>compl</code>,
-<code>lshift</code>,
-<code>rshift</code>,
-and
-<code>strtonum</code> built-in
-functions
-(see <a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>).
-
- <li><a name="index-_0040code_007bnext-file_007d-statement-1836"></a>The
support for `<samp><span class="samp">next file</span></samp>' as two words was
removed completely
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-
- <li>The <samp><span class="option">--dump-variables</span></samp> option
to print a list of all global variables
-(see <a href="Options.html#Options">Options</a>).
-
- <li>The <samp><span class="option">--gen-po</span></samp> command-line
option and the use of a leading
-underscore to mark strings that should be translated
-(see <a href="String-Extraction.html#String-Extraction">String Extraction</a>).
-
- <li>The <samp><span class="option">--non-decimal-data</span></samp>
option to allow non-decimal
-input data
-(see <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a>).
-
- <li>The <samp><span class="option">--profile</span></samp> option and
<samp><span class="command">pgawk</span></samp>, the
-profiling version of <samp><span class="command">gawk</span></samp>, for
producing execution
-profiles of <samp><span class="command">awk</span></samp> programs
-(see <a href="Profiling.html#Profiling">Profiling</a>).
-
- <li>The <samp><span class="option">--enable-portals</span></samp>
configuration option to enable special treatment of
-pathnames that begin with <samp><span class="file">/p</span></samp> as BSD
portals
-(see <a href="Portal-Files.html#Portal-Files">Portal Files</a>).
-
- <li>The use of GNU Automake to help in standardizing the configuration
process
-(see <a href="Quick-Installation.html#Quick-Installation">Quick
Installation</a>).
-
- <li>The use of GNU <code>gettext</code> for <samp><span
class="command">gawk</span></samp>'s own message output
-(see <a href="Gawk-I18N.html#Gawk-I18N">Gawk I18N</a>).
-
- <li>BeOS support
-(see <a href="BeOS-Installation.html#BeOS-Installation">BeOS Installation</a>).
-
- <li>Tandem support
-(see <a href="Tandem-Installation.html#Tandem-Installation">Tandem
Installation</a>).
-
- <li>The Atari port became officially unsupported
-(see <a href="Atari-Installation.html#Atari-Installation">Atari
Installation</a>).
-
- <li>The source code now uses new-style function definitions, with
-<samp><span class="command">ansi2knr</span></samp> to convert the code on
systems with old compilers.
-
- <li>The <samp><span class="option">--disable-lint</span></samp>
configuration option to disable lint checking
-at compile time
-(see <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>).
-
- <li>POSIX compliance for <code>sub</code> and <code>gsub</code>
-(see <a href="Gory-Details.html#Gory-Details">Gory Details</a>).
-
- </ul>
-
-<!-- XXX ADD MORE STUFF HERE -->
-<!-- ENDOFRANGE fripls -->
-<!-- ENDOFRANGE exgnot -->
-<!-- ENDOFRANGE posnot -->
-</body></html>
-
Index: manual/html_node/Passwd-Functions.html
===================================================================
RCS file: manual/html_node/Passwd-Functions.html
diff -N manual/html_node/Passwd-Functions.html
--- manual/html_node/Passwd-Functions.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,330 +0,0 @@
-<html lang="en">
-<head>
-<title>Passwd Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Library-Functions.html#Library-Functions" title="Library
Functions">
-<link rel="prev" href="Getopt-Function.html#Getopt-Function" title="Getopt
Function">
-<link rel="next" href="Group-Functions.html#Group-Functions" title="Group
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Passwd-Functions"></a>Next: <a rel="next" accesskey="n"
href="Group-Functions.html#Group-Functions">Group Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getopt-Function.html#Getopt-Function">Getopt Function</a>,
-Up: <a rel="up" accesskey="u"
href="Library-Functions.html#Library-Functions">Library Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">12.5 Reading the User Database</h3>
-
-<!-- STARTOFRANGE libfudata -->
-<p><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-user-database_002c-reading-1690"></a><!--
STARTOFRANGE flibudata -->
-<a
name="index-functions_002c-library_002c-user-database_002c-reading-1691"></a><!--
STARTOFRANGE udatar -->
-<a name="index-user-database_0040comma_007b_007d-reading-1692"></a><!--
STARTOFRANGE dataur -->
-<a name="index-database_002c-users_0040comma_007b_007d-reading-1693"></a><a
name="index-_0040code_007bPROCINFO_007d-array-1694"></a>The
<code>PROCINFO</code> array
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>)
-provides access to the current user's real and effective user and group ID
-numbers, and if available, the user's supplementary group set.
-However, because these are numbers, they do not provide very useful
-information to the average user. There needs to be some way to find the
-user information associated with the user and group ID numbers. This
-section presents a suite of functions for retrieving information from the
-user database. See <a href="Group-Functions.html#Group-Functions">Group
Functions</a>,
-for a similar suite that retrieves information from the group database.
-
- <p><a
name="index-_0040code_007bgetpwent_007d-function-_0028C-library_0029-1695"></a><a
name="index-_0040code_007bgetpwent_007d-user_002ddefined-function-1696"></a><a
name="index-users_002c-information-about_002c-retrieving-1697"></a><a
name="index-login-information-1698"></a><a
name="index-account-information-1699"></a><a
name="index-password-file-1700"></a><a
name="index-files_002c-password-1701"></a>The POSIX standard does not define
the file where user information is
-kept. Instead, it provides the <code><pwd.h></code> header file
-and several C language subroutines for obtaining user information.
-The primary function is <code>getpwent</code>, for “get password
entry.”
-The “password” comes from the original user database file,
-<samp><span class="file">/etc/passwd</span></samp>, which stores user
information, along with the
-encrypted passwords (hence the name).
-
- <p><a name="index-_0040command_007bpwcat_007d-program-1702"></a>While an
<samp><span class="command">awk</span></samp> program could simply read
<samp><span class="file">/etc/passwd</span></samp>
-directly, this file may not contain complete information about the
-system's set of users.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> To be sure you are able to
-produce a readable and complete version of the user database, it is necessary
-to write a small C program that calls <code>getpwent</code>.
<code>getpwent</code>
-is defined as returning a pointer to a <code>struct passwd</code>. Each time
it
-is called, it returns the next entry in the database. When there are
-no more entries, it returns <code>NULL</code>, the null pointer. When this
-happens, the C program should call <code>endpwent</code> to close the
database.
-Following is <samp><span class="command">pwcat</span></samp>, a C program that
“cats” the password database:
-
-<!-- Use old style function header for portability to old systems (SunOS,
HP/UX). -->
-<pre class="example"> <!-- file eg/lib/pwcat.c -->
- /*
- * pwcat.c
- *
- * Generate a printable version of the password database
- */
- <!-- endfile -->
- <!-- file eg/lib/pwcat.c -->
- #include <stdio.h>
- #include <pwd.h>
-
- <!-- endfile -->
- <!-- file eg/lib/pwcat.c -->
- int
- main(argc, argv)
- int argc;
- char **argv;
- {
- struct passwd *p;
-
- while ((p = getpwent()) != NULL)
- printf("%s:%s:%ld:%ld:%s:%s:%s\n",
- p->pw_name, p->pw_passwd, (long) p->pw_uid,
- (long) p->pw_gid, p->pw_gecos, p->pw_dir,
p->pw_shell);
-
- endpwent();
- return 0;
- }
- <!-- endfile -->
-</pre>
- <p>If you don't understand C, don't worry about it.
-The output from <samp><span class="command">pwcat</span></samp> is the user
database, in the traditional
-<samp><span class="file">/etc/passwd</span></samp> format of colon-separated
fields. The fields are:
-
- <p><table summary=""><tr align="left"><td valign="top">Login name </td><td
valign="top">The user's login name.
-
-<p><br></td></tr><tr align="left"><td valign="top">Encrypted password </td><td
valign="top">The user's encrypted password. This may not be available on some
systems.
-
-<p><br></td></tr><tr align="left"><td valign="top">User-ID </td><td
valign="top">The user's numeric user ID number.
-
-<p><br></td></tr><tr align="left"><td valign="top">Group-ID </td><td
valign="top">The user's numeric group ID number.
-
-<p><br></td></tr><tr align="left"><td valign="top">Full name </td><td
valign="top">The user's full name, and perhaps other information associated
with the
-user.
-
-<p><br></td></tr><tr align="left"><td valign="top">Home directory </td><td
valign="top">The user's login (or “home”) directory (familiar to
shell programmers as
-<code>$HOME</code>).
-
-<p><br></td></tr><tr align="left"><td valign="top">Login shell </td><td
valign="top">The program that is run when the user logs in. This is usually a
-shell, such as <samp><span class="command">bash</span></samp>.
- <br></td></tr></table>
-
- <p>A few lines representative of <samp><span
class="command">pwcat</span></samp>'s output are as follows:
-
- <p><a name="index-Jacobs_002c-Andrew-1703"></a><a
name="index-Robbins_002c-Arnold-1704"></a><a
name="index-Robbins_002c-Miriam-1705"></a>
-<pre class="example"> $ pwcat
- -| root:3Ov02d5VaUPB6:0:1:Operator:/:/bin/sh
- -| nobody:*:65534:65534::/:
- -| daemon:*:1:1::/:
- -| sys:*:2:2::/:/bin/csh
- -| bin:*:3:3::/bin:
- -| arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/sh
- -| miriam:yxaay:112:10:Miriam Robbins:/home/miriam:/bin/sh
- -| andy:abcca2:113:10:Andy Jacobs:/home/andy:/bin/sh
- ...
-</pre>
- <p>With that introduction, following is a group of functions for getting
user
-information. There are several functions here, corresponding to the C
-functions of the same names:
-
-<!-- Exercise: simplify all these functions that return values. -->
-<!-- Answer: return foo[key] returns "" if key not there, no need to check
with `in'. -->
-<p><a
name="index-_0040code_007b_005fpw_005finit_007d-user_002ddefined-function-1706"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- # passwd.awk --- access password file information
- <!-- endfile -->
- <!-- file eg/lib/passwdawk.in -->
- BEGIN {
- # tailor this to suit your system
- _pw_awklib = "/usr/local/libexec/awk/"
- }
-
- function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw)
- {
- if (_pw_inited)
- return
-
- oldfs = FS
- oldrs = RS
- olddol0 = $0
- using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
- FS = ":"
- RS = "\n"
-
- pwcat = _pw_awklib "pwcat"
- while ((pwcat | getline) > 0) {
- _pw_byname[$1] = $0
- _pw_byuid[$3] = $0
- _pw_bycount[++_pw_total] = $0
- }
- close(pwcat)
- _pw_count = 0
- _pw_inited = 1
- FS = oldfs
- if (using_fw)
- FIELDWIDTHS = FIELDWIDTHS
- RS = oldrs
- $0 = olddol0
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bpwcat_007d-program-1707"></a>The
<code>BEGIN</code> rule sets a private variable to the directory where
-<samp><span class="command">pwcat</span></samp> is stored. Because it is used
to help out an <samp><span class="command">awk</span></samp> library
-routine, we have chosen to put it in <samp><span
class="file">/usr/local/libexec/awk</span></samp>;
-however, you might want it to be in a different directory on your system.
-
- <p>The function <code>_pw_init</code> keeps three copies of the user
information
-in three associative arrays. The arrays are indexed by username
-(<code>_pw_byname</code>), by user ID number (<code>_pw_byuid</code>), and by
order of
-occurrence (<code>_pw_bycount</code>).
-The variable <code>_pw_inited</code> is used for efficiency;
<code>_pw_init</code>
-needs only to be called once.
-
- <p><a
name="index-_0040code_007bgetline_007d-command_002c-_0040code_007b_005fpw_005finit_007d-function-1708"></a>Because
this function uses <code>getline</code> to read information from
-<samp><span class="command">pwcat</span></samp>, it first saves the values of
<code>FS</code>, <code>RS</code>, and <code>$0</code>.
-It notes in the variable <code>using_fw</code> whether field splitting
-with <code>FIELDWIDTHS</code> is in effect or not.
-Doing so is necessary, since these functions could be called
-from anywhere within a user's program, and the user may have his
-or her
-own way of splitting records and fields.
-
- <p>The <code>using_fw</code> variable checks <code>PROCINFO["FS"]</code>,
which
-is <code>"FIELDWIDTHS"</code> if field splitting is being done with
-<code>FIELDWIDTHS</code>. This makes it possible to restore the correct
-field-splitting mechanism later. The test can only be true for
-<samp><span class="command">gawk</span></samp>. It is false if using
<code>FS</code> or on some other
-<samp><span class="command">awk</span></samp> implementation.
-
- <p>The main part of the function uses a loop to read database lines, split
-the line into fields, and then store the line into each array as necessary.
-When the loop is done, <code>_pw_init<!-- /@w --></code> cleans up by closing
the pipeline,
-setting <code>_pw_inited<!-- /@w --></code> to one, and restoring
<code>FS</code> (and <code>FIELDWIDTHS</code>
-if necessary), <code>RS</code>, and <code>$0</code>.
-The use of <code>_pw_count<!-- /@w --></code> is explained shortly.
-
-<!-- NEXT ED: All of these functions don't need the ... in ... test. Just -->
-<!-- return the array element, which will be "" if not already there. Duh. -->
-<p><a
name="index-_0040code_007bgetpwnam_007d-function-_0028C-library_0029-1709"></a>The
<code>getpwnam</code> function takes a username as a string argument. If that
-user is in the database, it returns the appropriate line. Otherwise, it
-returns the null string:
-
- <p><a
name="index-_0040code_007bgetpwnam_007d-user_002ddefined-function-1710"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function getpwnam(name)
- {
- _pw_init()
- if (name in _pw_byname)
- return _pw_byname[name]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetpwuid_007d-function-_0028C-library_0029-1711"></a>Similarly,
-the <code>getpwuid</code> function takes a user ID number argument. If that
-user number is in the database, it returns the appropriate line. Otherwise, it
-returns the null string:
-
- <p><a
name="index-_0040code_007bgetpwuid_007d-user_002ddefined-function-1712"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function getpwuid(uid)
- {
- _pw_init()
- if (uid in _pw_byuid)
- return _pw_byuid[uid]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bgetpwent_007d-function-_0028C-library_0029-1713"></a>The
<code>getpwent</code> function simply steps through the database, one entry at
-a time. It uses <code>_pw_count</code> to track its current position in the
-<code>_pw_bycount</code> array:
-
- <p><a
name="index-_0040code_007bgetpwent_007d-user_002ddefined-function-1714"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function getpwent()
- {
- _pw_init()
- if (_pw_count < _pw_total)
- return _pw_bycount[++_pw_count]
- return ""
- }
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007bendpwent_007d-function-_0028C-library_0029-1715"></a>The
<code>endpwent<!-- /@w --></code> function resets <code>_pw_count<!-- /@w
--></code> to zero, so that
-subsequent calls to <code>getpwent</code> start over again:
-
- <p><a
name="index-_0040code_007bendpwent_007d-user_002ddefined-function-1716"></a>
-<pre class="example"> <!-- file eg/lib/passwdawk.in -->
- function endpwent()
- {
- _pw_count = 0
- }
- <!-- endfile -->
-</pre>
- <p>A conscious design decision in this suite was made that each subroutine
calls
-<code>_pw_init<!-- /@w --></code> to initialize the database arrays. The
overhead of running
-a separate process to generate the user database, and the I/O to scan it,
-are only incurred if the user's main program actually calls one of these
-functions. If this library file is loaded along with a user's program, but
-none of the routines are ever called, then there is no extra runtime overhead.
-(The alternative is move the body of <code>_pw_init<!-- /@w --></code> into a
-<code>BEGIN</code> rule, which always runs <samp><span
class="command">pwcat</span></samp>. This simplifies the
-code but runs an extra process that may never be needed.)
-
- <p>In turn, calling <code>_pw_init</code> is not too expensive, because the
-<code>_pw_inited</code> variable keeps the program from reading the data more
than
-once. If you are worried about squeezing every last cycle out of your
-<samp><span class="command">awk</span></samp> program, the check of
<code>_pw_inited</code> could be moved out of
-<code>_pw_init</code> and duplicated in all the other functions. In practice,
-this is not necessary, since most <samp><span
class="command">awk</span></samp> programs are I/O-bound, and it
-clutters up the code.
-
- <p>The <samp><span class="command">id</span></samp> program in <a
href="Id-Program.html#Id-Program">Id Program</a>,
-uses these functions.
-<!-- ENDOFRANGE libfudata -->
-<!-- ENDOFRANGE flibudata -->
-<!-- ENDOFRANGE udatar -->
-<!-- ENDOFRANGE dataur -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> It is often the case that password
-information is stored in a network database.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Pattern-Overview.html
===================================================================
RCS file: manual/html_node/Pattern-Overview.html
diff -N manual/html_node/Pattern-Overview.html
--- manual/html_node/Pattern-Overview.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,90 +0,0 @@
-<html lang="en">
-<head>
-<title>Pattern Overview - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link rel="next" href="Using-Shell-Variables.html#Using-Shell-Variables"
title="Using Shell Variables">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Pattern-Overview"></a>Next: <a rel="next" accesskey="n"
href="Using-Shell-Variables.html#Using-Shell-Variables">Using Shell
Variables</a>,
-Up: <a rel="up" accesskey="u"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>
-<hr><br>
-</div>
-
-<h3 class="section">6.1 Pattern Elements</h3>
-
-<ul class="menu">
-<li><a accesskey="1" href="Regexp-Patterns.html#Regexp-Patterns">Regexp
Patterns</a>: Using regexps as patterns.
-<li><a accesskey="2"
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a>:
Any expression can be used as a pattern.
-<li><a accesskey="3" href="Ranges.html#Ranges">Ranges</a>:
Pairs of patterns specify record ranges.
-<li><a accesskey="4" href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>:
Specifying initialization and cleanup rules.
-<li><a accesskey="5" href="Empty.html#Empty">Empty</a>:
The empty pattern, which matches every record.
-</ul>
-
-<p><a name="index-patterns_002c-types-of-887"></a>Patterns in <samp><span
class="command">awk</span></samp> control the execution of rules—a rule is
-executed when its pattern matches the current input record.
-The following is a summary of the types of <samp><span
class="command">awk</span></samp> patterns:
-
- <dl>
-<dt><code>/</code><var>regular expression</var><code>/</code><dd>A regular
expression. It matches when the text of the
-input record fits the regular expression.
-(See <a href="Regexp.html#Regexp">Regexp</a>.)
-
- <br><dt><var>expression</var><dd>A single expression. It matches when
its value
-is nonzero (if a number) or non-null (if a string).
-(See <a href="Expression-Patterns.html#Expression-Patterns">Expression
Patterns</a>.)
-
- <br><dt><var>pat1</var><code>, </code><var>pat2</var><dd>A pair of
patterns separated by a comma, specifying a range of records.
-The range includes both the initial record that matches <var>pat1</var> and
-the final record that matches <var>pat2</var>.
-(See <a href="Ranges.html#Ranges">Ranges</a>.)
-
- <br><dt><code>BEGIN</code><dt><code>END</code><dd>Special patterns for
you to supply startup or cleanup actions for your
-<samp><span class="command">awk</span></samp> program.
-(See <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>.)
-
- <br><dt><var>empty</var><dd>The empty pattern matches every input record.
-(See <a href="Empty.html#Empty">Empty</a>.)
-</dl>
-
- </body></html>
-
Index: manual/html_node/Patterns-and-Actions.html
===================================================================
RCS file: manual/html_node/Patterns-and-Actions.html
diff -N manual/html_node/Patterns-and-Actions.html
--- manual/html_node/Patterns-and-Actions.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,80 +0,0 @@
-<html lang="en">
-<head>
-<title>Patterns and Actions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Expressions.html#Expressions" title="Expressions">
-<link rel="next" href="Arrays.html#Arrays" title="Arrays">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Patterns-and-Actions"></a>Next: <a rel="next" accesskey="n"
href="Arrays.html#Arrays">Arrays</a>,
-Previous: <a rel="previous" accesskey="p"
href="Expressions.html#Expressions">Expressions</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">6 Patterns, Actions, and Variables</h2>
-
-<!-- STARTOFRANGE pat -->
-<p><a name="index-patterns-886"></a>
-As you have already seen, each <samp><span class="command">awk</span></samp>
statement consists of
-a pattern with an associated action. This chapter describes how
-you build patterns and actions, what kinds of things you can do within
-actions, and <samp><span class="command">awk</span></samp>'s built-in
variables.
-
- <p>The pattern-action rules and the statements available for use
-within actions form the core of <samp><span class="command">awk</span></samp>
programming.
-In a sense, everything covered
-up to here has been the foundation
-that programs are built on top of. Now it's time to start
-building something useful.
-
-<ul class="menu">
-<li><a accesskey="1" href="Pattern-Overview.html#Pattern-Overview">Pattern
Overview</a>: What goes into a pattern.
-<li><a accesskey="2"
href="Using-Shell-Variables.html#Using-Shell-Variables">Using Shell
Variables</a>: How to use shell variables with <samp><span
class="command">awk</span></samp>.
-<li><a accesskey="3" href="Action-Overview.html#Action-Overview">Action
Overview</a>: What goes into an action.
-<li><a accesskey="4" href="Statements.html#Statements">Statements</a>:
Describes the various control statements in
- detail.
-<li><a accesskey="5"
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>: Summarizes the built-in variables.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Plain-Getline.html
===================================================================
RCS file: manual/html_node/Plain-Getline.html
diff -N manual/html_node/Plain-Getline.html
--- manual/html_node/Plain-Getline.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,104 +0,0 @@
-<html lang="en">
-<head>
-<title>Plain Getline - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getline.html#Getline" title="Getline">
-<link rel="next" href="Getline_002fVariable.html#Getline_002fVariable"
title="Getline/Variable">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Plain-Getline"></a>Next: <a rel="next" accesskey="n"
href="Getline_002fVariable.html#Getline_002fVariable">Getline/Variable</a>,
-Up: <a rel="up" accesskey="u" href="Getline.html#Getline">Getline</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.8.1 Using <code>getline</code> with No Arguments</h4>
-
-<p>The <code>getline</code> command can be used without arguments to read input
-from the current input file. All it does in this case is read the next
-input record and split it up into fields. This is useful if you've
-finished processing the current record, but want to do some special
-processing on the next record <em>right now</em>. For example:
-
-<pre class="example"> {
- if ((t = index($0, "/*")) != 0) {
- # value of `tmp' will be "" if t is 1
- tmp = substr($0, 1, t - 1)
- u = index(substr($0, t + 2), "*/")
- while (u == 0) {
- if (getline <= 0) {
- m = "unexpected EOF or error"
- m = (m ": " ERRNO)
- print m > "/dev/stderr"
- exit
- }
- t = -1
- u = index($0, "*/")
- }
- # substr expression will be "" if */
- # occurred at end of line
- $0 = tmp substr($0, u + 2)
- }
- print $0
- }
-</pre>
- <p>This <samp><span class="command">awk</span></samp> program deletes all
C-style comments (`<samp><span class="samp">/* ...
-*/</span></samp>') from the input. By replacing the `<samp><span
class="samp">print $0</span></samp>' with other
-statements, you could perform more complicated processing on the
-decommented input, such as searching for matches of a regular
-expression. (This program has a subtle problem—it does not work if one
-comment ends and another begins on the same line.)
-
- <p>This form of the <code>getline</code> command sets <code>NF</code>,
-<code>NR</code>, <code>FNR</code>, and the value of <code>$0</code>.
-
- <blockquote>
-<b>NOTE:</b> The new value of <code>$0</code> is used to test
-the patterns of any subsequent rules. The original value
-of <code>$0</code> that triggered the rule that executed <code>getline</code>
-is lost.
-By contrast, the <code>next</code> statement reads a new record
-but immediately begins processing it normally, starting with the first
-rule in the program. See <a href="Next-Statement.html#Next-Statement">Next
Statement</a>.
-</blockquote>
-
- </body></html>
-
Index: manual/html_node/Portal-Files.html
===================================================================
RCS file: manual/html_node/Portal-Files.html
diff -N manual/html_node/Portal-Files.html
--- manual/html_node/Portal-Files.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-<html lang="en">
-<head>
-<title>Portal Files - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Advanced-Features.html#Advanced-Features" title="Advanced
Features">
-<link rel="prev" href="TCP_002fIP-Networking.html#TCP_002fIP-Networking"
title="TCP/IP Networking">
-<link rel="next" href="Profiling.html#Profiling" title="Profiling">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Portal-Files"></a>Next: <a rel="next" accesskey="n"
href="Profiling.html#Profiling">Profiling</a>,
-Previous: <a rel="previous" accesskey="p"
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP Networking</a>,
-Up: <a rel="up" accesskey="u"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>
-<hr><br>
-</div>
-
-<h3 class="section">10.4 Using <samp><span class="command">gawk</span></samp>
with BSD Portals</h3>
-
-<p><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-BSD-portals-1428"></a><a
name="index-portal-files-1429"></a><a
name="index-files_002c-portal-1430"></a><a name="index-BSD-portals-1431"></a><a
name="index-_0040code_007b_002fp_007d-files-_0028_0040command_007bgawk_007d_0029-1432"></a><a
name="index-files_002c-_0040code_007b_002fp_007d-_0028_0040command_007bgawk_007d_0029-1433"></a><a
name="index-_0040code_007b_002d_002denable_002dportals_007d-configuration-option-1434"></a><a
name="index-operating-systems_002c-BSD_002dbased-1435"></a>
-Similar to the <samp><span class="file">/inet</span></samp> special files, if
<samp><span class="command">gawk</span></samp>
-is configured with the <samp><span
class="option">--enable-portals</span></samp> option
-(see <a href="Quick-Installation.html#Quick-Installation">Quick
Installation</a>),
-then <samp><span class="command">gawk</span></samp> treats
-files whose pathnames begin with <code>/p</code> as 4.4 BSD-style portals.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1436"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029_002c-two_002dway-communications-1437"></a>When
used with the `<samp><span class="samp">|&</span></samp>' operator,
<samp><span class="command">gawk</span></samp> opens the file
-for two-way communications. The operating system's portal mechanism
-then manages creating the process associated with the portal and
-the corresponding communications with the portal's process.
-<!-- ENDOFRANGE tcpip -->
-
- </body></html>
-
Index: manual/html_node/Precedence.html
===================================================================
RCS file: manual/html_node/Precedence.html
diff -N manual/html_node/Precedence.html
--- manual/html_node/Precedence.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,148 +0,0 @@
-<html lang="en">
-<head>
-<title>Precedence - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Function-Calls.html#Function-Calls" title="Function
Calls">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Precedence"></a>Previous: <a rel="previous" accesskey="p"
href="Function-Calls.html#Function-Calls">Function Calls</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.14 Operator Precedence (How Operators Nest)</h3>
-
-<!-- STARTOFRANGE prec -->
-<p><a name="index-precedence-809"></a><!-- STARTOFRANGE oppr -->
-<a name="index-operators_002c-precedence-810"></a>
-<dfn>Operator precedence</dfn> determines how operators are grouped when
-different operators appear close by in one expression. For example,
-`<samp><span class="samp">*</span></samp>' has higher precedence than
`<samp><span class="samp">+</span></samp>'; thus, `<samp><span class="samp">a +
b * c</span></samp>'
-means to multiply <code>b</code> and <code>c</code>, and then add
<code>a</code> to the
-product (i.e., `<samp><span class="samp">a + (b * c)</span></samp>').
-
- <p>The normal precedence of the operators can be overruled by using
parentheses.
-Think of the precedence rules as saying where the
-parentheses are assumed to be. In
-fact, it is wise to always use parentheses whenever there is an unusual
-combination of operators, because other people who read the program may
-not remember what the precedence is in this case.
-Even experienced programmers occasionally forget the exact rules,
-which leads to mistakes.
-Explicit parentheses help prevent
-any such mistakes.
-
- <p>When operators of equal precedence are used together, the leftmost
-operator groups first, except for the assignment, conditional, and
-exponentiation operators, which group in the opposite order.
-Thus, `<samp><span class="samp">a - b + c</span></samp>' groups as
`<samp><span class="samp">(a - b) + c</span></samp>' and
-`<samp><span class="samp">a = b = c</span></samp>' groups as `<samp><span
class="samp">a = (b = c)</span></samp>'.
-
- <p>The precedence of prefix unary operators does not matter as long as only
-unary operators are involved, because there is only one way to interpret
-them: innermost first. Thus, `<samp><span class="samp">$++i</span></samp>'
means `<samp><span class="samp">$(++i)</span></samp>' and
-`<samp><span class="samp">++$x</span></samp>' means `<samp><span
class="samp">++($x)</span></samp>'. However, when another operator follows
-the operand, then the precedence of the unary operators can matter.
-`<samp><span class="samp">$x^2</span></samp>' means `<samp><span
class="samp">($x)^2</span></samp>', but `<samp><span
class="samp">-x^2</span></samp>' means
-`<samp><span class="samp">-(x^2)</span></samp>', because `<samp><span
class="samp">-</span></samp>' has lower precedence than `<samp><span
class="samp">^</span></samp>',
-whereas `<samp><span class="samp">$</span></samp>' has higher precedence.
-This table presents <samp><span class="command">awk</span></samp>'s operators,
in order of highest
-to lowest precedence:
-
-<!-- use @code in the items, looks better in TeX w/o all the quotes -->
-<dl>
-<dt><code>(...)</code><dd>Grouping.
-
- <p><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029_002c-_0040code_007b_0024_007d-field-operator-811"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029_002c-_0040code_007b_0024_007d-field-operator-812"></a><br><dt><code>$</code><dd>Field.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_002b_007d-operator-813"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_002b_007d-operator-814"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operator-815"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_002d_007d-_0028decrement_002fincrement_0029-operators-816"></a><br><dt><code>++
--</code><dd>Increment, decrement.
-
- <p><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_007d-operator-817"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_007d-operator-818"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_007d-operator-819"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_007d-operator-820"></a><br><dt><code>^
**</code><dd>Exponentiation. These operators group right-to-left.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_007d-operator-821"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_007d-operator-822"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_007d-operator-823"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_007d-operator-824"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007d-operator-825"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007d-operator-826"></a><br><dt><code>+
- !</code><dd>Unary plus, minus, logical “not.”
-
- <p><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-827"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-multiplication-operator-828"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_007d-operator-829"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_007d-operator-830"></a><a
name="index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_007d-operator-831"></a><a
name="index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_007d-operator-832"></a><br><dt><code>*
/ %</code><dd>Multiplication, division, modulus.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_007d-operator-833"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_007d-operator-834"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_007d-operator-835"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_007d-operator-836"></a><br><dt><code>+
-</code><dd>Addition, subtraction.
-
- <br><dt><span class="roman">String Concatenation</span><dd>No special
symbol is used to indicate concatenation.
-The operands are simply written side by side
-(see <a href="Concatenation.html#Concatenation">Concatenation</a>).
-
- <p><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-837"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-838"></a><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-839"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-840"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-841"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-842"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-843"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-844"></a><a
name="index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-845"></a><a
name="index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-846"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-847"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-848"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-849"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-850"></a><a
name="index-operators_002c-input_002foutput-851"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-852"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-853"></a><a
name="index-operators_002c-input_002foutput-854"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-855"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-856"></a><a
name="index-operators_002c-input_002foutput-857"></a><br><dt><code>< <=
== !=</code><dt><code>> >= >> | |&</code><dd>Relational and
redirection.
-The relational operators and the redirections have the same precedence
-level. Characters such as `<samp><span class="samp">></span></samp>' serve
both as relationals and as
-redirections; the context distinguishes between the two meanings.
-
- <p><a
name="index-_0040code_007bprint_007d-statement_002c-I_002fO-operators-in-858"></a><a
name="index-_0040code_007bprintf_007d-statement_002c-I_002fO-operators-in-859"></a>Note
that the I/O redirection operators in <code>print</code> and
<code>printf</code>
-statements belong to the statement level, not to expressions. The
-redirection does not produce an expression that could be the operand of
-another operator. As a result, it does not make sense to use a
-redirection operator near another operator of lower precedence without
-parentheses. Such combinations (for example, `<samp><span class="samp">print
foo > a ? b : c</span></samp>'),
-result in syntax errors.
-The correct way to write this statement is `<samp><span class="samp">print foo
> (a ? b : c)</span></samp>'.
-
- <p><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-860"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-861"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-862"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-863"></a><br><dt><code>~
!~</code><dd>Matching, nonmatching.
-
- <p><a
name="index-_0040code_007bin_007d-operator-864"></a><br><dt><code>in</code><dd>Array
membership.
-
- <p><a
name="index-_0040code_007b_0026_007d-_0028ampersand_0029_002c-_0040code_007b_0026_0026_007d-operator-865"></a><a
name="index-ampersand-_0028_0040code_007b_0026_007d_0029_002c-_0040code_007b_0026_0026_007doperator-866"></a><br><dt><code>&&</code><dd>Logical
“and”.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007c_007d-operator-867"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_007c_007d-operator-868"></a><br><dt><code>||</code><dd>Logical
“or”.
-
- <p><a
name="index-_0040code_007b_003f_007d-_0028question-mark_0029_002c-_0040code_007b_003f_003a_007d-operator-869"></a><a
name="index-question-mark-_0028_0040code_007b_003f_007d_0029_002c-_0040code_007b_003f_003a_007d-operator-870"></a><br><dt><code>?:</code><dd>Conditional.
This operator groups right-to-left.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029_002c-_0040code_007b_002b_003d_007d-operator-871"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029_002c-_0040code_007b_002b_003d_007d-operator-872"></a><a
name="index-_0040code_007b_002d_007d-_0028hyphen_0029_002c-_0040code_007b_002d_003d_007d-operator-873"></a><a
name="index-hyphen-_0028_0040code_007b_002d_007d_0029_002c-_0040code_007b_002d_003d_007d-operator-874"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_003d_007d-operator-875"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_003d_007d-operator-876"></a><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-877"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_002a_003d_007d-operator-878"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029_002c-_0040code_007b_002f_003d_007d-operator-879"></a><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029_002c-_0040code_007b_002f_003d_007d-operator-880"></a><a
name="index-_0040code_007b_0025_007d-_0028percent-sign_0029_002c-_0040code_007b_0025_003d_007d-operator-881"></a><a
name="index-percent-sign-_0028_0040code_007b_0025_007d_0029_002c-_0040code_007b_0025_003d_007d-operator-882"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029_002c-_0040code_007b_005e_003d_007d-operator-883"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029_002c-_0040code_007b_005e_003d_007d-operator-884"></a><br><dt><code>=
+= -= *=</code><dt><code>/= %= ^= **=</code><dd>Assignment. These operators
group right to left.
-</dl>
-
- <p><a
name="index-portability_002c-operators_002c-not-in-POSIX-_0040command_007bawk_007d-885"></a><blockquote>
-<b>NOTE:</b> The `<samp><span class="samp">|&</span></samp>', `<samp><span
class="samp">**</span></samp>', and `<samp><span
class="samp">**=</span></samp>' operators are not specified by POSIX.
-For maximum portability, do not use them.
-</blockquote>
- <!-- ENDOFRANGE prec -->
-<!-- ENDOFRANGE oppr -->
-<!-- ENDOFRANGE exps -->
-
- </body></html>
-
Index: manual/html_node/Preface.html
===================================================================
RCS file: manual/html_node/Preface.html
diff -N manual/html_node/Preface.html
--- manual/html_node/Preface.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-<html lang="en">
-<head>
-<title>Preface - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Foreword.html#Foreword" title="Foreword">
-<link rel="next" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Preface"></a>Next: <a rel="next" accesskey="n"
href="Getting-Started.html#Getting-Started">Getting Started</a>,
-Previous: <a rel="previous" accesskey="p"
href="Foreword.html#Foreword">Foreword</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">Preface</h2>
-
-<!-- I saw a comment somewhere that the preface should describe the book
itself, -->
-<!-- and the introduction should describe what the book covers. -->
-<!-- 12/2000: Chuck wants the preface & intro combined. -->
-<p>Several kinds of tasks occur repeatedly
-when working with text files.
-You might want to extract certain lines and discard the rest.
-Or you may need to make changes wherever certain patterns appear,
-but leave the rest of the file alone.
-Writing single-use programs for these tasks in languages such as C, C++, or
Pascal
-is time-consuming and inconvenient.
-Such jobs are often easier with <samp><span class="command">awk</span></samp>.
-The <samp><span class="command">awk</span></samp> utility interprets a
special-purpose programming language
-that makes it easy to handle simple data-reformatting jobs.
-
- <p>The GNU implementation of <samp><span class="command">awk</span></samp>
is called <samp><span class="command">gawk</span></samp>; it is fully
-compatible with the System V Release 4 version of
-<samp><span class="command">awk</span></samp>. <samp><span
class="command">gawk</span></samp> is also compatible with the POSIX
-specification of the <samp><span class="command">awk</span></samp> language.
This means that all
-properly written <samp><span class="command">awk</span></samp> programs should
work with <samp><span class="command">gawk</span></samp>.
-Thus, we usually don't distinguish between <samp><span
class="command">gawk</span></samp> and other
-<samp><span class="command">awk</span></samp> implementations.
-
- <p><a
name="index-_0040command_007bawk_007d_002c-POSIX-and_002c-See-Also-POSIX-_0040command_007bawk_007d-1"></a><a
name="index-_0040command_007bawk_007d_002c-POSIX-and-2"></a><a
name="index-POSIX_002c-_0040command_007bawk_007d-and-3"></a><a
name="index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-4"></a><a
name="index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-5"></a><a
name="index-_0040command_007bawk_007d_002c-uses-for-6"></a>Using <samp><span
class="command">awk</span></samp> allows you to:
-
- <ul>
-<li>Manage small, personal databases
-
- <li>Generate reports
-
- <li>Validate data
-
- <li>Produce indexes and perform other document preparation tasks
-
- <li>Experiment with algorithms that you can adapt later to other computer
-languages
-</ul>
-
- <p><a
name="index-_0040command_007bawk_007d_002c-See-Also-_0040command_007bgawk_007d-7"></a><a
name="index-_0040command_007bgawk_007d_002c-See-Also-_0040command_007bawk_007d-8"></a><a
name="index-_0040command_007bgawk_007d_002c-uses-for-9"></a>In addition,
-<samp><span class="command">gawk</span></samp>
-provides facilities that make it easy to:
-
- <ul>
-<li>Extract bits and pieces of data for processing
-
- <li>Sort data
-
- <li>Perform simple network communications
-</ul>
-
- <p>This Web page teaches you about the <samp><span
class="command">awk</span></samp> language and
-how you can use it effectively. You should already be familiar with basic
-system commands, such as <samp><span class="command">cat</span></samp> and
<samp><span class="command">ls</span></samp>,<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> as well as basic shell
-facilities, such as input/output (I/O) redirection and pipes.
-
- <p><a
name="index-GNU-_0040command_007bawk_007d_002c-See-_0040command_007bgawk_007d-10"></a>Implementations
of the <samp><span class="command">awk</span></samp> language are available
for many
-different computing environments. This Web page, while describing
-the <samp><span class="command">awk</span></samp> language in general, also
describes the particular
-implementation of <samp><span class="command">awk</span></samp> called
<samp><span class="command">gawk</span></samp> (which stands for
-“GNU awk”). <samp><span class="command">gawk</span></samp> runs
on a broad range of Unix systems,
-ranging from 80386 PC-based computers up through large-scale systems,
-such as Crays. <samp><span class="command">gawk</span></samp> has also been
ported to Mac OS X,
-MS-DOS, Microsoft Windows (all versions) and OS/2 PCs, Atari and Amiga
-microcomputers, BeOS, Tandem D20, and VMS.
-
-<ul class="menu">
-<li><a accesskey="1" href="History.html#History">History</a>:
The history of <samp><span class="command">gawk</span></samp> and
- <samp><span class="command">awk</span></samp>.
-<li><a accesskey="2" href="Names.html#Names">Names</a>:
What name to use to find <samp><span class="command">awk</span></samp>.
-<li><a accesskey="3" href="This-Manual.html#This-Manual">This Manual</a>:
Using this Web page. Includes sample
- input files that you can use.
-<li><a accesskey="4" href="Conventions.html#Conventions">Conventions</a>:
Typographical Conventions.
-<li><a accesskey="5" href="Manual-History.html#Manual-History">Manual
History</a>: Brief history of the GNU project and this
- Web page.
-<li><a accesskey="6" href="How-To-Contribute.html#How-To-Contribute">How To
Contribute</a>: Helping to save the world.
-<li><a accesskey="7"
href="Acknowledgments.html#Acknowledgments">Acknowledgments</a>:
Acknowledgments.
-</ul>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> These commands
-are available on POSIX-compliant systems, as well as on traditional
-Unix-based systems. If you are using some other operating system, you still
need to
-be familiar with the ideas of I/O redirection and pipes.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Print-Examples.html
===================================================================
RCS file: manual/html_node/Print-Examples.html
diff -N manual/html_node/Print-Examples.html
--- manual/html_node/Print-Examples.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,137 +0,0 @@
-<html lang="en">
-<head>
-<title>Print Examples - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="Print.html#Print" title="Print">
-<link rel="next" href="Output-Separators.html#Output-Separators" title="Output
Separators">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Print-Examples"></a>Next: <a rel="next" accesskey="n"
href="Output-Separators.html#Output-Separators">Output Separators</a>,
-Previous: <a rel="previous" accesskey="p"
href="Print.html#Print">Print</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.2 Examples of <code>print</code> Statements</h3>
-
-<p>Each <code>print</code> statement makes at least one line of output.
However, it
-isn't limited to only one line. If an item value is a string that contains a
-newline, the newline is output along with the rest of the string. A
-single <code>print</code> statement can make any number of lines this way.
-
- <p><a name="index-newlines_002c-printing-505"></a>The following is an
example of printing a string that contains embedded newlines
-(the `<samp><span class="samp">\n</span></samp>' is an escape sequence, used
to represent the newline
-character; see <a href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a>):
-
-<pre class="example"> $ awk 'BEGIN { print "line one\nline two\nline
three" }'
- -| line one
- -| line two
- -| line three
-</pre>
- <p><a name="index-fields_002c-printing-506"></a>The next example, which is
run on the <samp><span class="file">inventory-shipped</span></samp> file,
-prints the first two fields of each input record, with a space between
-them:
-
-<pre class="example"> $ awk '{ print $1, $2 }' inventory-shipped
- -| Jan 13
- -| Feb 15
- -| Mar 15
- ...
-</pre>
- <p><a
name="index-_0040code_007bprint_007d-statement_002c-commas_002c-omitting-507"></a><a
name="index-troubleshooting_002c-_0040code_007bprint_007d-statement_0040comma_007b_007d-omitting-commas-508"></a>A
common mistake in using the <code>print</code> statement is to omit the comma
-between two items. This often has the effect of making the items run
-together in the output, with no space. The reason for this is that
-juxtaposing two string expressions in <samp><span
class="command">awk</span></samp> means to concatenate
-them. Here is the same program, without the comma:
-
-<pre class="example"> $ awk '{ print $1 $2 }' inventory-shipped
- -| Jan13
- -| Feb15
- -| Mar15
- ...
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-headings_0040comma_007b_007d-adding-509"></a>To
someone unfamiliar with the <samp><span
class="file">inventory-shipped</span></samp> file, neither
-example's output makes much sense. A heading line at the beginning
-would make it clearer. Let's add some headings to our table of months
-(<code>$1</code>) and green crates shipped (<code>$2</code>). We do this
using the
-<code>BEGIN</code> pattern
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>)
-so that the headings are only printed once:
-
-<pre class="example"> awk 'BEGIN { print "Month Crates"
- print "----- ------" }
- { print $1, $2 }' inventory-shipped
-</pre>
- <p class="noindent">When run, the program prints the following:
-
-<pre class="example"> Month Crates
- ----- ------
- Jan 13
- Feb 15
- Mar 15
- ...
-</pre>
- <p class="noindent">The only problem, however, is that the headings and the
table data
-don't line up! We can fix this by printing some spaces between the
-two fields:
-
-<pre class="example"> awk 'BEGIN { print "Month Crates"
- print "----- ------" }
- { print $1, " ", $2 }' inventory-shipped
-</pre>
- <p><a
name="index-_0040code_007bprintf_007d-statement_002c-columns_0040comma_007b_007d-aligning-510"></a><a
name="index-columns_002c-aligning-511"></a>Lining up columns this way can get
pretty
-complicated when there are many columns to fix. Counting spaces for two
-or three columns is simple, but any more than this can take up
-a lot of time. This is why the <code>printf</code> statement was
-created (see <a href="Printf.html#Printf">Printf</a>);
-one of its specialties is lining up columns of data.
-
- <p><a
name="index-line-continuations_002c-in-_0040code_007bprint_007d-statement-512"></a><a
name="index-_0040code_007bprint_007d-statement_002c-line-continuations-and-513"></a><blockquote>
-<b>NOTE:</b> You can continue either a <code>print</code> or
-<code>printf</code> statement simply by putting a newline after any comma
-(see <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>).
-</blockquote>
- <!-- ENDOFRANGE prnts -->
-
- </body></html>
-
Index: manual/html_node/Print.html
===================================================================
RCS file: manual/html_node/Print.html
diff -N manual/html_node/Print.html
--- manual/html_node/Print.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,81 +0,0 @@
-<html lang="en">
-<head>
-<title>Print - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="next" href="Print-Examples.html#Print-Examples" title="Print
Examples">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Print"></a>Next: <a rel="next" accesskey="n"
href="Print-Examples.html#Print-Examples">Print Examples</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.1 The <code>print</code> Statement</h3>
-
-<p>The <code>print</code> statement is used to produce output with simple,
standardized
-formatting. Specify only the strings or numbers to print, in a
-list separated by commas. They are output, separated by single spaces,
-followed by a newline. The statement looks like this:
-
-<pre class="example"> print <var>item1</var>, <var>item2</var>, ...
-</pre>
- <p class="noindent">The entire list of items may be optionally enclosed in
parentheses. The
-parentheses are necessary if any of the item expressions uses the `<samp><span
class="samp">></span></samp>'
-relational operator; otherwise it could be confused with a redirection
-(see <a href="Redirection.html#Redirection">Redirection</a>).
-
- <p>The items to print can be constant strings or numbers, fields of the
-current record (such as <code>$1</code>), variables, or any <samp><span
class="command">awk</span></samp>
-expression. Numeric values are converted to strings and then printed.
-
- <p><a name="index-records_002c-printing-502"></a><a
name="index-lines_002c-blank_002c-printing-503"></a><a
name="index-text_002c-printing-504"></a>The simple statement `<samp><span
class="samp">print</span></samp>' with no items is equivalent to
-`<samp><span class="samp">print $0</span></samp>': it prints the entire
current record. To print a blank
-line, use `<samp><span class="samp">print ""</span></samp>', where
<code>""</code> is the empty string.
-To print a fixed piece of text, use a string constant, such as
-<code>"Don't Panic"</code><!-- /@w -->, as one item. If you forget to
use the
-double-quote characters, your text is taken as an <samp><span
class="command">awk</span></samp>
-expression, and you will probably get an error. Keep in mind that a
-space is printed between any two items.
-
- </body></html>
-
Index: manual/html_node/Printf-Examples.html
===================================================================
RCS file: manual/html_node/Printf-Examples.html
diff -N manual/html_node/Printf-Examples.html
--- manual/html_node/Printf-Examples.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,128 +0,0 @@
-<html lang="en">
-<head>
-<title>Printf Examples - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printf.html#Printf" title="Printf">
-<link rel="prev" href="Format-Modifiers.html#Format-Modifiers" title="Format
Modifiers">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Printf-Examples"></a>Previous: <a rel="previous" accesskey="p"
href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a>,
-Up: <a rel="up" accesskey="u" href="Printf.html#Printf">Printf</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.5.4 Examples Using <code>printf</code></h4>
-
-<p>The following is a simple example of
-how to use <code>printf</code> to make an aligned table:
-
-<pre class="example"> awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list
-</pre>
- <p class="noindent">This command
-prints the names of the bulletin boards (<code>$1</code>) in the file
-<samp><span class="file">BBS-list</span></samp> as a string of 10 characters
that are left-justified. It also
-prints the phone numbers (<code>$2</code>) next on the line. This
-produces an aligned two-column table of names and phone numbers,
-as shown here:
-
-<pre class="example"> $ awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list
- -| aardvark 555-5553
- -| alpo-net 555-3412
- -| barfly 555-7685
- -| bites 555-1675
- -| camelot 555-0542
- -| core 555-2912
- -| fooey 555-1234
- -| foot 555-6699
- -| macfoo 555-6480
- -| sdace 555-3430
- -| sabafoo 555-2127
-</pre>
- <p>In this case, the phone numbers had to be printed as strings because
-the numbers are separated by a dash. Printing the phone numbers as
-numbers would have produced just the first three digits: `<samp><span
class="samp">555</span></samp>'.
-This would have been pretty confusing.
-
- <p>It wasn't necessary to specify a width for the phone numbers because
-they are last on their lines. They don't need to have spaces
-after them.
-
- <p>The table could be made to look even nicer by adding headings to the
-tops of the columns. This is done using the <code>BEGIN</code> pattern
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>)
-so that the headers are only printed once, at the beginning of
-the <samp><span class="command">awk</span></samp> program:
-
-<pre class="example"> awk 'BEGIN { print "Name Number"
- print "---- ------" }
- { printf "%-10s %s\n", $1, $2 }' BBS-list
-</pre>
- <p>The above example mixed <code>print</code> and <code>printf</code>
statements in
-the same program. Using just <code>printf</code> statements can produce the
-same results:
-
-<pre class="example"> awk 'BEGIN { printf "%-10s %s\n", "Name", "Number"
- printf "%-10s %s\n", "----", "------" }
- { printf "%-10s %s\n", $1, $2 }' BBS-list
-</pre>
- <p class="noindent">Printing each column heading with the same format
specification
-used for the column elements ensures that the headings
-are aligned just like the columns.
-
- <p>The fact that the same format specification is used three times can be
-emphasized by storing it in a variable, like this:
-
-<pre class="example"> awk 'BEGIN { format = "%-10s %s\n"
- printf format, "Name", "Number"
- printf format, "----", "------" }
- { printf format, $1, $2 }' BBS-list
-</pre>
- <!-- !!! exercise -->
-<p>At this point, it would be a worthwhile exercise to use the
-<code>printf</code> statement to line up the headings and table data for the
-<samp><span class="file">inventory-shipped</span></samp> example that was
covered earlier in the section
-on the <code>print</code> statement
-(see <a href="Print.html#Print">Print</a>).
-<!-- ENDOFRANGE printfs -->
-
- </body></html>
-
Index: manual/html_node/Printf-Ordering.html
===================================================================
RCS file: manual/html_node/Printf-Ordering.html
diff -N manual/html_node/Printf-Ordering.html
--- manual/html_node/Printf-Ordering.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-<html lang="en">
-<head>
-<title>Printf Ordering - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Translator-i18n.html#Translator-i18n" title="Translator
i18n">
-<link rel="prev" href="String-Extraction.html#String-Extraction" title="String
Extraction">
-<link rel="next" href="I18N-Portability.html#I18N-Portability" title="I18N
Portability">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Printf-Ordering"></a>Next: <a rel="next" accesskey="n"
href="I18N-Portability.html#I18N-Portability">I18N Portability</a>,
-Previous: <a rel="previous" accesskey="p"
href="String-Extraction.html#String-Extraction">String Extraction</a>,
-Up: <a rel="up" accesskey="u"
href="Translator-i18n.html#Translator-i18n">Translator i18n</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">9.4.2 Rearranging <code>printf</code> Arguments</h4>
-
-<p><a
name="index-_0040code_007bprintf_007d-statement_002c-positional-specifiers-1371"></a><a
name="index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement-1372"></a>Format
strings for <code>printf</code> and <code>sprintf</code>
-(see <a href="Printf.html#Printf">Printf</a>)
-present a special problem for translation.
-Consider the following:<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
-<!-- line broken here only for smallbook format -->
-<pre class="example"> printf(_"String `%s' has %d characters\n",
- string, length(string)))
-</pre>
- <p>A possible German translation for this might be:
-
-<pre class="example"> "%d Zeichen lang ist die Zeichenkette `%s'\n"
-</pre>
- <p>The problem should be obvious: the order of the format
-specifications is different from the original!
-Even though <code>gettext</code> can return the translated string
-at runtime,
-it cannot change the argument order in the call to <code>printf</code>.
-
- <p>To solve this problem, <code>printf</code> format specificiers may have
-an additional optional element, which we call a <dfn>positional
specifier</dfn>.
-For example:
-
-<pre class="example"> "%2$d Zeichen lang ist die Zeichenkette `%1$s'\n"
-</pre>
- <p>Here, the positional specifier consists of an integer count, which
indicates which
-argument to use, and a `<samp><span class="samp">$</span></samp>'. Counts are
one-based, and the
-format string itself is <em>not</em> included. Thus, in the following
-example, `<samp><span class="samp">string</span></samp>' is the first argument
and `<samp><span class="samp">length(string)</span></samp>' is the second:
-
-<pre class="example"> $ gawk 'BEGIN {
- > string = "Dont Panic"
- > printf _"%2$d characters live in \"%1$s\"\n",
- > string, length(string)
- > }'
- -| 10 characters live in "Dont Panic"
-</pre>
- <p>If present, positional specifiers come first in the format specification,
-before the flags, the field width, and/or the precision.
-
- <p>Positional specifiers can be used with the dynamic field width and
-precision capability:
-
-<pre class="example"> $ gawk 'BEGIN {
- > printf("%*.*s\n", 10, 20, "hello")
- > printf("%3$*2$.*1$s\n", 20, 10, "hello")
- > }'
- -| hello
- -| hello
-</pre>
- <blockquote>
-<b>NOTE:</b> When using `<samp><span class="samp">*</span></samp>' with a
positional specifier, the `<samp><span class="samp">*</span></samp>'
-comes first, then the integer position, and then the `<samp><span
class="samp">$</span></samp>'.
-This is somewhat counterintutive.
-</blockquote>
-
- <p><a
name="index-_0040code_007bprintf_007d-statement_002c-positional-specifiers_002c-mixing-with-regular-formats-1373"></a><a
name="index-positional-specifiers_0040comma_007b_007d-_0040code_007bprintf_007d-statement_002c-mixing-with-regular-formats-1374"></a><a
name="index-format-specifiers_002c-mixing-regular-with-positional-specifiers-1375"></a><samp><span
class="command">gawk</span></samp> does not allow you to mix regular format
specifiers
-and those with positional specifiers in the same string:
-
-<pre class="smallexample"> $ gawk 'BEGIN { printf _"%d %3$s\n", 1, 2, "hi"
}'
- error--> gawk: cmd. line:1: fatal: must use `count$' on all formats or
none
-</pre>
- <blockquote>
-<b>NOTE:</b> There are some pathological cases that <samp><span
class="command">gawk</span></samp> may fail to
-diagnose. In such cases, the output may not be what you expect.
-It's still a bad idea to try mixing them, even if <samp><span
class="command">gawk</span></samp>
-doesn't detect it.
-</blockquote>
-
- <p>Although positional specifiers can be used directly in <samp><span
class="command">awk</span></samp> programs,
-their primary purpose is to help in producing correct translations of
-format strings into languages different from the one in which the program
-is first written.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This example is borrowed
-from the GNU <code>gettext</code> manual.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Printf.html
===================================================================
RCS file: manual/html_node/Printf.html
diff -N manual/html_node/Printf.html
--- manual/html_node/Printf.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-<html lang="en">
-<head>
-<title>Printf - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="OFMT.html#OFMT" title="OFMT">
-<link rel="next" href="Redirection.html#Redirection" title="Redirection">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Printf"></a>Next: <a rel="next" accesskey="n"
href="Redirection.html#Redirection">Redirection</a>,
-Previous: <a rel="previous" accesskey="p" href="OFMT.html#OFMT">OFMT</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.5 Using <code>printf</code> Statements for Fancier
Printing</h3>
-
-<!-- STARTOFRANGE printfs -->
-<p><a name="index-_0040code_007bprintf_007d-statement-527"></a><a
name="index-output_002c-formatted-528"></a><a
name="index-formatting-output-529"></a>For more precise control over the output
format than what is
-normally provided by <code>print</code>, use <code>printf</code>.
-<code>printf</code> can be used to
-specify the width to use for each item, as well as various
-formatting choices for numbers (such as what output base to use, whether to
-print an exponent, whether to print a sign, and how many digits to print
-after the decimal point). This is done by supplying a string, called
-the <dfn>format string</dfn>, that controls how and where to print the other
-arguments.
-
-<ul class="menu">
-<li><a accesskey="1" href="Basic-Printf.html#Basic-Printf">Basic Printf</a>:
Syntax of the <code>printf</code> statement.
-<li><a accesskey="2" href="Control-Letters.html#Control-Letters">Control
Letters</a>: Format-control letters.
-<li><a accesskey="3" href="Format-Modifiers.html#Format-Modifiers">Format
Modifiers</a>: Format-specification modifiers.
-<li><a accesskey="4" href="Printf-Examples.html#Printf-Examples">Printf
Examples</a>: Several examples.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Printing.html
===================================================================
RCS file: manual/html_node/Printing.html
diff -N manual/html_node/Printing.html
--- manual/html_node/Printing.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-<html lang="en">
-<head>
-<title>Printing - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="next" href="Expressions.html#Expressions" title="Expressions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Printing"></a>Next: <a rel="next" accesskey="n"
href="Expressions.html#Expressions">Expressions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Reading-Files.html#Reading-Files">Reading Files</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">4 Printing Output</h2>
-
-<!-- STARTOFRANGE prnt -->
-<p><a name="index-printing-498"></a><a
name="index-output_002c-printing_002c-See-printing-499"></a>One of the most
common programming actions is to <dfn>print</dfn>, or output,
-some or all of the input. Use the <code>print</code> statement
-for simple output, and the <code>printf</code> statement
-for fancier formatting.
-The <code>print</code> statement is not limited when
-computing <em>which</em> values to print. However, with two exceptions,
-you cannot specify <em>how</em> to print them—how many
-columns, whether to use exponential notation or not, and so on.
-(For the exceptions, see <a
href="Output-Separators.html#Output-Separators">Output Separators</a>, and
-<a href="OFMT.html#OFMT">OFMT</a>.)
-For printing with specifications, you need the <code>printf</code> statement
-(see <a href="Printf.html#Printf">Printf</a>).
-
-<!-- STARTOFRANGE prnts -->
-<p><a name="index-_0040code_007bprint_007d-statement-500"></a><a
name="index-_0040code_007bprintf_007d-statement-501"></a>Besides basic and
formatted printing, this chapter
-also covers I/O redirections to files and pipes, introduces
-the special file names that <samp><span class="command">gawk</span></samp>
processes internally,
-and discusses the <code>close</code> built-in function.
-
-<ul class="menu">
-<li><a accesskey="1" href="Print.html#Print">Print</a>:
The <code>print</code> statement.
-<li><a accesskey="2" href="Print-Examples.html#Print-Examples">Print
Examples</a>: Simple examples of <code>print</code> statements.
-<li><a accesskey="3" href="Output-Separators.html#Output-Separators">Output
Separators</a>: The output separators and how to change them.
-<li><a accesskey="4" href="OFMT.html#OFMT">OFMT</a>:
Controlling Numeric Output With <code>print</code>.
-<li><a accesskey="5" href="Printf.html#Printf">Printf</a>:
The <code>printf</code> statement.
-<li><a accesskey="6" href="Redirection.html#Redirection">Redirection</a>:
How to redirect output to multiple files and
- pipes.
-<li><a accesskey="7" href="Special-Files.html#Special-Files">Special
Files</a>: File name interpretation in <samp><span
class="command">gawk</span></samp>.
- <samp><span class="command">gawk</span></samp>
allows access to inherited file
- descriptors.
-<li><a accesskey="8"
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>: Closing Input and Output Files and Pipes.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Profiling.html
===================================================================
RCS file: manual/html_node/Profiling.html
diff -N manual/html_node/Profiling.html
--- manual/html_node/Profiling.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,297 +0,0 @@
-<html lang="en">
-<head>
-<title>Profiling - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Advanced-Features.html#Advanced-Features" title="Advanced
Features">
-<link rel="prev" href="Portal-Files.html#Portal-Files" title="Portal Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Profiling"></a>Previous: <a rel="previous" accesskey="p"
href="Portal-Files.html#Portal-Files">Portal Files</a>,
-Up: <a rel="up" accesskey="u"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>
-<hr><br>
-</div>
-
-<h3 class="section">10.5 Profiling Your <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<!-- STARTOFRANGE awkp -->
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-profiling-1438"></a><!--
STARTOFRANGE proawk -->
-<a name="index-profiling-_0040command_007bawk_007d-programs-1439"></a><!--
STARTOFRANGE pgawk -->
-<a name="index-_0040command_007bpgawk_007d-program-1440"></a><a
name="index-profiling-_0040command_007bgawk_007d_002c-See-_0040command_007bpgawk_007d-program-1441"></a>
-Beginning with version 3.1 of <samp><span class="command">gawk</span></samp>,
you may produce execution
-traces of your <samp><span class="command">awk</span></samp> programs.
-This is done with a specially compiled version of <samp><span
class="command">gawk</span></samp>,
-called <samp><span class="command">pgawk</span></samp> (“profiling
<samp><span class="command">gawk</span></samp>”).
-
- <p><a name="index-_0040code_007bawkprof_002eout_007d-file-1442"></a><a
name="index-files_002c-_0040code_007bawkprof_002eout_007d-1443"></a><a
name="index-_0040command_007bpgawk_007d-program_002c-_0040code_007bawkprof_002eout_007d-file-1444"></a><samp><span
class="command">pgawk</span></samp> is identical in every way to <samp><span
class="command">gawk</span></samp>, except that when
-it has finished running, it creates a profile of your program in a file
-named <samp><span class="file">awkprof.out</span></samp>.
-Because it is profiling, it also executes up to 45% slower than
-<samp><span class="command">gawk</span></samp> normally does.
-
- <p><a name="index-_0040code_007b_002d_002dprofile_007d-option-1445"></a>As
shown in the following example,
-the <samp><span class="option">--profile</span></samp> option can be used to
change the name of the file
-where <samp><span class="command">pgawk</span></samp> will write the profile:
-
-<pre class="example"> $ pgawk --profile=myprog.prof -f myprog.awk data1
data2
-</pre>
- <p class="noindent">In the above example, <samp><span
class="command">pgawk</span></samp> places the profile in
-<samp><span class="file">myprog.prof</span></samp> instead of in <samp><span
class="file">awkprof.out</span></samp>.
-
- <p>Regular <samp><span class="command">gawk</span></samp> also accepts this
option. When called with just
-<samp><span class="option">--profile</span></samp>, <samp><span
class="command">gawk</span></samp> “pretty prints” the program into
-<samp><span class="file">awkprof.out</span></samp>, without any execution
counts. You may supply an
-option to <samp><span class="option">--profile</span></samp> to change the
file name. Here is a sample
-session showing a simple <samp><span class="command">awk</span></samp>
program, its input data, and the
-results from running <samp><span class="command">pgawk</span></samp>. First,
the <samp><span class="command">awk</span></samp> program:
-
-<pre class="example"> BEGIN { print "First BEGIN rule" }
-
- END { print "First END rule" }
-
- /foo/ {
- print "matched /foo/, gosh"
- for (i = 1; i <= 3; i++)
- sing()
- }
-
- {
- if (/foo/)
- print "if is true"
- else
- print "else is true"
- }
-
- BEGIN { print "Second BEGIN rule" }
-
- END { print "Second END rule" }
-
- function sing( dummy)
- {
- print "I gotta be me!"
- }
-</pre>
- <p>Following is the input data:
-
-<pre class="example"> foo
- bar
- baz
- foo
- junk
-</pre>
- <p>Here is the <samp><span class="file">awkprof.out</span></samp> that
results from running <samp><span class="command">pgawk</span></samp>
-on this program and data (this example also illustrates that <samp><span
class="command">awk</span></samp>
-programmers sometimes have to work late):
-
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040command_007bpgawk_007d-program-1446"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-_0040command_007bpgawk_007d-program-1447"></a>
-<pre class="example"> # gawk profile, created Sun Aug 13 00:00:15
2000
-
- # BEGIN block(s)
-
- BEGIN {
- 1 print "First BEGIN rule"
- 1 print "Second BEGIN rule"
- }
-
- # Rule(s)
-
- 5 /foo/ { # 2
- 2 print "matched /foo/, gosh"
- 6 for (i = 1; i <= 3; i++) {
- 6 sing()
- }
- }
-
- 5 {
- 5 if (/foo/) { # 2
- 2 print "if is true"
- 3 } else {
- 3 print "else is true"
- }
- }
-
- # END block(s)
-
- END {
- 1 print "First END rule"
- 1 print "Second END rule"
- }
-
- # Functions, listed alphabetically
-
- 6 function sing(dummy)
- {
- 6 print "I gotta be me!"
- }
-</pre>
- <p>This example illustrates many of the basic rules for profiling output.
-The rules are as follows:
-
- <ul>
-<li>The program is printed in the order <code>BEGIN</code> rule,
-pattern/action rules, <code>END</code> rule and functions, listed
-alphabetically.
-Multiple <code>BEGIN</code> and <code>END</code> rules are merged together.
-
- <p><a name="index-patterns_002c-counts-1448"></a><li>Pattern-action rules
have two counts.
-The first count, to the left of the rule, shows how many times
-the rule's pattern was <em>tested</em>.
-The second count, to the right of the rule's opening left brace
-in a comment,
-shows how many times the rule's action was <em>executed</em>.
-The difference between the two indicates how many times the rule's
-pattern evaluated to false.
-
- <li>Similarly,
-the count for an <code>if</code>-<code>else</code> statement shows how many
times
-the condition was tested.
-To the right of the opening left brace for the <code>if</code>'s body
-is a count showing how many times the condition was true.
-The count for the <code>else</code>
-indicates how many times the test failed.
-
- <p><a name="index-loops_002c-count-for-header-1449"></a><li>The count for
a loop header (such as <code>for</code>
-or <code>while</code>) shows how many times the loop test was executed.
-(Because of this, you can't just look at the count on the first
-statement in a rule to determine how many times the rule was executed.
-If the first statement is a loop, the count is misleading.)
-
- <p><a
name="index-functions_002c-user_002ddefined_002c-counts-1450"></a><a
name="index-user_002ddefined_002c-functions_002c-counts-1451"></a><li>For
user-defined functions, the count next to the <code>function</code>
-keyword indicates how many times the function was called.
-The counts next to the statements in the body show how many times
-those statements were executed.
-
- <p><a
name="index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-_0040command_007bpgawk_007d-program-1452"></a><a
name="index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-_0040command_007bpgawk_007d-program-1453"></a><li>The
layout uses “K&R” style with tabs.
-Braces are used everywhere, even when
-the body of an <code>if</code>, <code>else</code>, or loop is only a single
statement.
-
- <p><a
name="index-_0040code_007b_0028_0029_007d-_0028parentheses_0029_002c-_0040command_007bpgawk_007d-program-1454"></a><a
name="index-parentheses-_0040code_007b_0028_0029_007d_002c-_0040command_007bpgawk_007d-program-1455"></a><li>Parentheses
are used only where needed, as indicated by the structure
-of the program and the precedence rules.
-<!-- extra verbiage here satisfies the copyeditor. ugh. -->
-For example, `<samp><span class="samp">(3 + 5) * 4</span></samp>' means add
three plus five, then multiply
-the total by four. However, `<samp><span class="samp">3 + 5 *
4</span></samp>' has no parentheses, and
-means `<samp><span class="samp">3 + (5 * 4)</span></samp>'.
-
- <li>All string concatenations are parenthesized too.
-(This could be made a bit smarter.)
-
- <li>Parentheses are used around the arguments to <code>print</code>
-and <code>printf</code> only when
-the <code>print</code> or <code>printf</code> statement is followed by a
redirection.
-Similarly, if
-the target of a redirection isn't a scalar, it gets parenthesized.
-
- <li><samp><span class="command">pgawk</span></samp> supplies leading
comments in
-front of the <code>BEGIN</code> and <code>END</code> rules,
-the pattern/action rules, and the functions.
-
- </ul>
-
- <p>The profiled version of your program may not look exactly like what you
-typed when you wrote it. This is because <samp><span
class="command">pgawk</span></samp> creates the
-profiled version by “pretty printing” its internal representation
of
-the program. The advantage to this is that <samp><span
class="command">pgawk</span></samp> can produce
-a standard representation. The disadvantage is that all source-code
-comments are lost, as are the distinctions among multiple <code>BEGIN</code>
-and <code>END</code> rules. Also, things such as:
-
-<pre class="example"> /foo/
-</pre>
- <p class="noindent">come out as:
-
-<pre class="example"> /foo/ {
- print $0
- }
-</pre>
- <p class="noindent">which is correct, but possibly surprising.
-
- <p><a
name="index-profiling-_0040command_007bawk_007d-programs_002c-dynamically-1456"></a><a
name="index-_0040command_007bpgawk_007d-program_002c-dynamic-profiling-1457"></a>Besides
creating profiles when a program has completed,
-<samp><span class="command">pgawk</span></samp> can produce a profile while it
is running.
-This is useful if your <samp><span class="command">awk</span></samp> program
goes into an
-infinite loop and you want to see what has been executed.
-To use this feature, run <samp><span class="command">pgawk</span></samp> in
the background:
-
-<pre class="example"> $ pgawk -f myprog &
- [1] 13992
-</pre>
- <p><a
name="index-_0040command_007bkill_007d-command_0040comma_007b_007d-dynamic-profiling-1458"></a><a
name="index-_0040code_007bUSR1_007d-signal-1459"></a><a
name="index-signals_002c-_0040code_007bUSR1_007d_002f_0040code_007bSIGUSR1_007d-1460"></a>The
shell prints a job number and process ID number; in this case, 13992.
-Use the <samp><span class="command">kill</span></samp> command to send the
<code>USR1</code> signal
-to <samp><span class="command">pgawk</span></samp>:
-
-<pre class="example"> $ kill -USR1 13992
-</pre>
- <p class="noindent">As usual, the profiled version of the program is
written to
-<samp><span class="file">awkprof.out</span></samp>, or to a different file if
you use the <samp><span class="option">--profile</span></samp>
-option.
-
- <p>Along with the regular profile, as shown earlier, the profile
-includes a trace of any active functions:
-
-<pre class="example"> # Function Call Stack:
-
- # 3. baz
- # 2. bar
- # 1. foo
- # -- main --
-</pre>
- <p>You may send <samp><span class="command">pgawk</span></samp> the
<code>USR1</code> signal as many times as you like.
-Each time, the profile and function call trace are appended to the output
-profile file.
-
- <p><a name="index-_0040code_007bHUP_007d-signal-1461"></a><a
name="index-signals_002c-_0040code_007bHUP_007d_002f_0040code_007bSIGHUP_007d-1462"></a>If
you use the <code>HUP</code> signal instead of the <code>USR1</code> signal,
-<samp><span class="command">pgawk</span></samp> produces the profile and the
function call trace and then exits.
-
- <p><a
name="index-_0040code_007bINT_007d-signal-_0028MS_002dDOS_0029-1463"></a><a
name="index-signals_002c-_0040code_007bINT_007d_002f_0040code_007bSIGINT_007d-_0028MS_002dDOS_0029-1464"></a><a
name="index-_0040code_007bQUIT_007d-signal-_0028MS_002dDOS_0029-1465"></a><a
name="index-signals_002c-_0040code_007bQUIT_007d_002f_0040code_007bSIGQUIT_007d-_0028MS_002dDOS_0029-1466"></a>When
<samp><span class="command">pgawk</span></samp> runs on MS-DOS or MS-Windows,
it uses the
-<code>INT</code> and <code>QUIT</code> signals for producing the profile and,
in
-the case of the <code>INT</code> signal, <samp><span
class="command">pgawk</span></samp> exits. This is
-because these systems don't support the <samp><span
class="command">kill</span></samp> command, so the
-only signals you can deliver to a program are those generated by the
-keyboard. The <code>INT</code> signal is generated by the
-<kbd>Ctrl-<C></kbd> or <kbd>Ctrl-<BREAK></kbd> key, while the
-<code>QUIT</code> signal is generated by the <kbd>Ctrl-<\></kbd> key.
-<!-- ENDOFRANGE advgaw -->
-<!-- ENDOFRANGE gawadv -->
-<!-- ENDOFRANGE pgawk -->
-<!-- ENDOFRANGE awkp -->
-<!-- ENDOFRANGE proawk -->
-
- </body></html>
-
Index: manual/html_node/Programmer-i18n.html
===================================================================
RCS file: manual/html_node/Programmer-i18n.html
diff -N manual/html_node/Programmer-i18n.html
--- manual/html_node/Programmer-i18n.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,170 +0,0 @@
-<html lang="en">
-<head>
-<title>Programmer i18n - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="prev" href="Explaining-gettext.html#Explaining-gettext"
title="Explaining gettext">
-<link rel="next" href="Translator-i18n.html#Translator-i18n" title="Translator
i18n">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Programmer-i18n"></a>Next: <a rel="next" accesskey="n"
href="Translator-i18n.html#Translator-i18n">Translator i18n</a>,
-Previous: <a rel="previous" accesskey="p"
href="Explaining-gettext.html#Explaining-gettext">Explaining gettext</a>,
-Up: <a rel="up" accesskey="u"
href="Internationalization.html#Internationalization">Internationalization</a>
-<hr><br>
-</div>
-
-<h3 class="section">9.3 Internationalizing <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<!-- STARTOFRANGE inap -->
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-internationalizing-1342"></a>
-<samp><span class="command">gawk</span></samp> provides the following
variables and functions for
-internationalization:
-
-
-<a name="index-_0040code_007bTEXTDOMAIN_007d-variable-1343"></a>
-<dl><dt><code>TEXTDOMAIN</code><dd>This variable indicates the application's
text domain.
-For compatibility with GNU <code>gettext</code>, the default
-value is <code>"messages"</code>.
-
- <p><a
name="index-internationalization_002c-localization_002c-marked-strings-1344"></a><a
name="index-strings_002c-for-localization-1345"></a><br><dt><code>_"your
message here"</code><dd>String constants marked with a leading underscore
-are candidates for translation at runtime.
-String constants without a leading underscore are not translated.
-
- <p><a
name="index-_0040code_007bdcgettext_007d-function-_0028_0040command_007bgawk_007d_0029-1346"></a><br><dt><code>dcgettext(</code><var>string</var>
<span class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This built-in function returns the
translation of <var>string</var> in
-text domain <var>domain</var> for locale category <var>category</var>.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p>If you supply a value for <var>category</var>, it must be a string
equal to
-one of the known locale categories described in
-the previous section.
-You must also supply a text domain. Use <code>TEXTDOMAIN</code> if
-you want to use the current domain.
-
- <p><strong>Caution:</strong> The order of arguments to the <samp><span
class="command">awk</span></samp> version
-of the <code>dcgettext</code> function is purposely different from the order
for
-the C version. The <samp><span class="command">awk</span></samp> version's
order was
-chosen to be simple and to allow for reasonable <samp><span
class="command">awk</span></samp>-style
-default arguments.
-
- <p><a
name="index-_0040code_007bdcngettext_007d-function-_0028_0040command_007bgawk_007d_0029-1347"></a><br><dt><code>dcngettext(</code><var>string1</var><code>,
</code><var>string2</var><code>, </code><var>number</var> <span
class="roman">[</span><code>, </code><var>domain</var> <span
class="roman">[</span><code>, </code><var>category</var><span
class="roman">]]</span><code>)</code><dd>This built-in function returns the
plural form used for <var>number</var> of the
-translation of <var>string1</var> and <var>string2</var> in text domain
-<var>domain</var> for locale category <var>category</var>. <var>string1</var>
is the
-English singular variant of a message, and <var>string2</var> the English
plural
-variant of the same message.
-The default value for <var>domain</var> is the current value of
<code>TEXTDOMAIN</code>.
-The default value for <var>category</var> is <code>"LC_MESSAGES"</code>.
-
- <p>The same remarks as for the <code>dcgettext</code> function apply.
-
- <p><a
name="index-_0040code_007b_002emo_007d-files_002c-specifying-directory-of-1348"></a><a
name="index-files_002c-_0040code_007b_002emo_007d_002c-specifying-directory-of-1349"></a><a
name="index-message-object-files_002c-specifying-directory-of-1350"></a><a
name="index-files_002c-message-object_002c-specifying-directory-of-1351"></a><a
name="index-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1352"></a><br><dt><code>bindtextdomain(</code><var>directory</var>
<span class="roman">[</span><code>, </code><var>domain</var><span
class="roman">]</span><code>)</code><dd>This built-in function allows you to
specify the directory in which
-<code>gettext</code> looks for <samp><span class="file">.mo</span></samp>
files, in case they
-will not or cannot be placed in the standard locations
-(e.g., during testing).
-It returns the directory in which <var>domain</var> is “bound.”
-
- <p>The default <var>domain</var> is the value of <code>TEXTDOMAIN</code>.
-If <var>directory</var> is the null string (<code>""</code>), then
-<code>bindtextdomain</code> returns the current binding for the
-given <var>domain</var>.
-</dl>
-
- <p>To use these facilities in your <samp><span
class="command">awk</span></samp> program, follow the steps
-outlined in
-the previous section,
-like so:
-
- <ol type=1 start=1>
-<a
name="index-_0040code_007bBEGIN_007d-pattern_002c-_0040code_007bTEXTDOMAIN_007d-variable-and-1353"></a><a
name="index-_0040code_007bTEXTDOMAIN_007d-variable_002c-_0040code_007bBEGIN_007d-pattern-and-1354"></a><li>Set
the variable <code>TEXTDOMAIN</code> to the text domain of
-your program. This is best done in a <code>BEGIN</code> rule
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>),
-or it can also be done via the <samp><span class="option">-v</span></samp>
command-line
-option (see <a href="Options.html#Options">Options</a>):
-
- <pre class="example"> BEGIN {
- TEXTDOMAIN = "guide"
- ...
- }
- </pre>
- <p><a
name="index-_0040code_007b_005f_007d-_0028underscore_0029_002c-translatable-string-1355"></a><a
name="index-underscore-_0028_0040code_007b_005f_007d_0029_002c-translatable-string-1356"></a><li>Mark
all translatable strings with a leading underscore (`<samp><span
class="samp">_</span></samp>')
-character. It <em>must</em> be adjacent to the opening
-quote of the string. For example:
-
- <pre class="example"> print _"hello, world"
- x = _"you goofed"
- printf(_"Number of users is %d\n", nusers)
- </pre>
- <li>If you are creating strings dynamically, you can
-still translate them, using the <code>dcgettext</code>
-built-in function:
-
- <pre class="example"> message = nusers " users logged in"
- message = dcgettext(message, "adminprog")
- print message
- </pre>
- <p>Here, the call to <code>dcgettext</code> supplies a different
-text domain (<code>"adminprog"</code>) in which to find the
-message, but it uses the default <code>"LC_MESSAGES"</code> category.
-
- <p><a
name="index-_0040code_007bLC_005fMESSAGES_007d-locale-category_002c-_0040code_007bbindtextdomain_007d-function-_0028_0040command_007bgawk_007d_0029-1357"></a><li>During
development, you might want to put the <samp><span
class="file">.mo</span></samp>
-file in a private directory for testing. This is done
-with the <code>bindtextdomain</code> built-in function:
-
- <pre class="example"> BEGIN {
- TEXTDOMAIN = "guide" # our text domain
- if (Testing) {
- # where to find our files
- bindtextdomain("testdir")
- # joe is in charge of adminprog
- bindtextdomain("../joe/testdir", "adminprog")
- }
- ...
- }
- </pre>
- </ol>
-
- <p>See <a href="I18N-Example.html#I18N-Example">I18N Example</a>,
-for an example program showing the steps to create
-and use translations from <samp><span class="command">awk</span></samp>.
-
- </body></html>
-
Index: manual/html_node/Quick-Installation.html
===================================================================
RCS file: manual/html_node/Quick-Installation.html
diff -N manual/html_node/Quick-Installation.html
--- manual/html_node/Quick-Installation.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,103 +0,0 @@
-<html lang="en">
-<head>
-<title>Quick Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Unix-Installation.html#Unix-Installation" title="Unix
Installation">
-<link rel="next"
href="Additional-Configuration-Options.html#Additional-Configuration-Options"
title="Additional Configuration Options">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Quick-Installation"></a>Next: <a rel="next" accesskey="n"
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>,
-Up: <a rel="up" accesskey="u"
href="Unix-Installation.html#Unix-Installation">Unix Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.2.1 Compiling <samp><span
class="command">gawk</span></samp> for Unix</h4>
-
-<!-- @cindex installation, unix -->
-<p>After you have extracted the <samp><span class="command">gawk</span></samp>
distribution, <samp><span class="command">cd</span></samp>
-to <samp><span class="file">gawk-3.1.4</span></samp>. Like most GNU software,
-<samp><span class="command">gawk</span></samp> is configured
-automatically for your Unix system by running the <samp><span
class="command">configure</span></samp> program.
-This program is a Bourne shell script that is generated automatically using
-GNU <samp><span class="command">autoconf</span></samp>.
-(The <samp><span class="command">autoconf</span></samp> software is
-described fully in
-<cite>Autoconf—Generating Automatic Configuration Scripts</cite>,
-which is available from the Free Software Foundation.)
-
- <p>To configure <samp><span class="command">gawk</span></samp>, simply run
<samp><span class="command">configure</span></samp>:
-
-<pre class="example"> sh ./configure
-</pre>
- <p>This produces a <samp><span class="file">Makefile</span></samp> and
<samp><span class="file">config.h</span></samp> tailored to your system.
-The <samp><span class="file">config.h</span></samp> file describes various
facts about your system.
-You might want to edit the <samp><span class="file">Makefile</span></samp> to
-change the <code>CFLAGS</code> variable, which controls
-the command-line options that are passed to the C compiler (such as
-optimization levels or compiling for debugging).
-
- <p>Alternatively, you can add your own values for most <samp><span
class="command">make</span></samp>
-variables on the command line, such as <code>CC</code> and
<code>CFLAGS</code>, when
-running <samp><span class="command">configure</span></samp>:
-
-<pre class="example"> CC=cc CFLAGS=-g sh ./configure
-</pre>
- <p class="noindent">See the file <samp><span
class="file">INSTALL</span></samp> in the <samp><span
class="command">gawk</span></samp> distribution for
-all the details.
-
- <p>After you have run <samp><span class="command">configure</span></samp>
and possibly edited the <samp><span class="file">Makefile</span></samp>,
-type:
-
-<pre class="example"> make
-</pre>
- <p class="noindent">Shortly thereafter, you should have an executable
version of <samp><span class="command">gawk</span></samp>.
-That's all there is to it!
-To verify that <samp><span class="command">gawk</span></samp> is working
properly,
-run `<samp><span class="samp">make check</span></samp>'. All of the tests
should succeed.
-If these steps do not work, or if any of the tests fail,
-check the files in the <samp><span class="file">README_d</span></samp>
directory to see if you've
-found a known problem. If the failure is not described there,
-please send in a bug report
-(see <a href="Bugs.html#Bugs">Bugs</a>.)
-
- </body></html>
-
Index: manual/html_node/Quoting.html
===================================================================
RCS file: manual/html_node/Quoting.html
diff -N manual/html_node/Quoting.html
--- manual/html_node/Quoting.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,169 +0,0 @@
-<html lang="en">
-<head>
-<title>Quoting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="prev" href="Comments.html#Comments" title="Comments">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Quoting"></a>Previous: <a rel="previous" accesskey="p"
href="Comments.html#Comments">Comments</a>,
-Up: <a rel="up" accesskey="u"
href="Running-gawk.html#Running-gawk">Running gawk</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.1.6 Shell-Quoting Issues</h4>
-
-<p><a name="index-quoting_002c-rules-for-122"></a>
-For short to medium length <samp><span class="command">awk</span></samp>
programs, it is most convenient
-to enter the program on the <samp><span class="command">awk</span></samp>
command line.
-This is best done by enclosing the entire program in single quotes.
-This is true whether you are entering the program interactively at
-the shell prompt, or writing it as part of a larger shell script:
-
-<pre class="example"> awk '<var>program text</var>' <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p><a name="index-shells_002c-quoting_002c-rules-for-123"></a><a
name="index-Bourne-shell_002c-quoting-rules-for-124"></a>Once you are working
with the shell, it is helpful to have a basic
-knowledge of shell quoting rules. The following rules apply only to
-POSIX-compliant, Bourne-style shells (such as <samp><span
class="command">bash</span></samp>, the GNU Bourne-Again
-Shell). If you use <samp><span class="command">csh</span></samp>, you're on
your own.
-
- <ul>
-<li>Quoted items can be concatenated with nonquoted items as well as with other
-quoted items. The shell turns everything into one argument for
-the command.
-
- <li>Preceding any single character with a backslash (`<samp><span
class="samp">\</span></samp>') quotes
-that character. The shell removes the backslash and passes the quoted
-character on to the command.
-
- <li><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029-125"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029-126"></a><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029-127"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029-128"></a>Single
quotes protect everything between the opening and closing quotes.
-The shell does no interpretation of the quoted text, passing it on verbatim
-to the command.
-It is <em>impossible</em> to embed a single quote inside single-quoted text.
-Refer back to
-<a href="Comments.html#Comments">Comments</a>,
-for an example of what happens if you try.
-
- <li><a
name="index-double-quote-_0028_0040code_007b_0022_007d_0029-129"></a><a
name="index-_0040code_007b_0022_007d-_0028double-quote_0029-130"></a>Double
quotes protect most things between the opening and closing quotes.
-The shell does at least variable and command substitution on the quoted text.
-Different shells may do additional kinds of processing on double-quoted text.
-
- <p>Since certain characters within double-quoted text are processed by
the shell,
-they must be <dfn>escaped</dfn> within the text. Of note are the characters
-`<samp><span class="samp">$</span></samp>', `<samp><span
class="samp">`</span></samp>', `<samp><span class="samp">\</span></samp>', and
`<samp><span class="samp">"</span></samp>', all of which must be preceded by
-a backslash within double-quoted text if they are to be passed on literally
-to the program. (The leading backslash is stripped first.)
-Thus, the example seen
-previously
-in <a href="Read-Terminal.html#Read-Terminal">Read Terminal</a>,
-is applicable:
-
- <pre class="example"> $ awk "BEGIN { print \"Don't Panic!\" }"
- -| Don't Panic!
- </pre>
- <p><a
name="index-single-quote-_0028_0040code_007b_0027_007d_0029_002c-with-double-quotes-131"></a><a
name="index-_0040code_007b_0027_007d-_0028single-quote_0029_002c-with-double-quotes-132"></a>Note
that the single quote is not special within double quotes.
-
- <li>Null strings are removed when they occur as part of a non-null
-command-line argument, while explicit non-null objects are kept.
-For example, to specify that the field separator <code>FS</code> should
-be set to the null string, use:
-
- <pre class="example"> awk -F "" '<var>program</var>'
<var>files</var> # correct
- </pre>
- <p class="noindent"><a
name="index-null-strings_002c-quoting-and-133"></a>Don't use this:
-
- <pre class="example"> awk -F"" '<var>program</var>'
<var>files</var> # wrong!
- </pre>
- <p class="noindent">In the second case, <samp><span
class="command">awk</span></samp> will attempt to use the text of the program
-as the value of <code>FS</code>, and the first file name as the text of the
program!
-This results in syntax errors at best, and confusing behavior at worst.
-</ul>
-
- <p><a name="index-quoting_002c-tricks-for-134"></a>Mixing single and double
quotes is difficult. You have to resort
-to shell quoting tricks, like this:
-
-<pre class="example"> $ awk 'BEGIN { print "Here is a single quote
<'"'"'>" }'
- -| Here is a single quote <'>
-</pre>
- <p class="noindent">This program consists of three concatenated quoted
strings. The first and the
-third are single-quoted, the second is double-quoted.
-
- <p>This can be “simplified” to:
-
-<pre class="example"> $ awk 'BEGIN { print "Here is a single quote
<'\''>" }'
- -| Here is a single quote <'>
-</pre>
- <p class="noindent">Judge for yourself which of these two is the more
readable.
-
- <p>Another option is to use double quotes, escaping the embedded,
<samp><span class="command">awk</span></samp>-level
-double quotes:
-
-<pre class="example"> $ awk "BEGIN { print \"Here is a single quote
<'>\" }"
- -| Here is a single quote <'>
-</pre>
- <p class="noindent"><!-- ENDOFRANGE sq1x -->
-<!-- ENDOFRANGE qs2x -->
-This option is also painful, because double quotes, backslashes, and dollar
signs
-are very common in <samp><span class="command">awk</span></samp> programs.
-
- <p>A third option is to use the octal escape sequence equivalents for the
-single- and double-quote characters, like so:
-
-<pre class="example"> $ awk 'BEGIN { print "Here is a single quote
<\47>" }'
- -| Here is a single quote <'>
- $ awk 'BEGIN { print "Here is a double quote <\42>" }'
- -| Here is a double quote <">
-</pre>
- <p class="noindent">This works nicely, except that you should comment
clearly what the
-escapes mean.
-
- <p>A fourth option is to use command-line variable assignment, like this:
-
-<pre class="example"> $ awk -v sq="'" 'BEGIN { print "Here is a single
quote <" sq ">" }'
- -| Here is a single quote <'>
-</pre>
- <p>If you really need both single and double quotes in your <samp><span
class="command">awk</span></samp>
-program, it is probably best to move it into a separate file, where
-the shell won't be part of the picture, and you can say what you mean.
-
- </body></html>
-
Index: manual/html_node/Ranges.html
===================================================================
RCS file: manual/html_node/Ranges.html
diff -N manual/html_node/Ranges.html
--- manual/html_node/Ranges.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,124 +0,0 @@
-<html lang="en">
-<head>
-<title>Ranges - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Pattern-Overview.html#Pattern-Overview" title="Pattern
Overview">
-<link rel="prev" href="Expression-Patterns.html#Expression-Patterns"
title="Expression Patterns">
-<link rel="next" href="BEGIN_002fEND.html#BEGIN_002fEND" title="BEGIN/END">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Ranges"></a>Next: <a rel="next" accesskey="n"
href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>,
-Previous: <a rel="previous" accesskey="p"
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a>,
-Up: <a rel="up" accesskey="u"
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.1.3 Specifying Record Ranges with Patterns</h4>
-
-<p><a name="index-range-patterns-904"></a><a
name="index-patterns_002c-ranges-in-905"></a><a
name="index-lines_002c-matching-ranges-of-906"></a><a
name="index-_0040code_007b_002c_007d-_0028comma_0029_002c-in-range-patterns-907"></a><a
name="index-comma-_0028_0040code_007b_002c_007d_0029_002c-in-range-patterns-908"></a>A
<dfn>range pattern</dfn> is made of two patterns separated by a comma, in
-the form `<samp><var>begpat</var><span class="samp">,
</span><var>endpat</var></samp>'. It is used to match ranges of
-consecutive input records. The first pattern, <var>begpat</var>, controls
-where the range begins, while <var>endpat</var> controls where
-the pattern ends. For example, the following:
-
-<pre class="example"> awk '$1 == "on", $1 == "off"' myfile
-</pre>
- <p class="noindent">prints every record in <samp><span
class="file">myfile</span></samp> between `<samp><span
class="samp">on</span></samp>'/`<samp><span class="samp">off</span></samp>'
pairs, inclusive.
-
- <p>A range pattern starts out by matching <var>begpat</var> against every
-input record. When a record matches <var>begpat</var>, the range pattern is
-<dfn>turned on</dfn> and the range pattern matches this record as well. As
long as
-the range pattern stays turned on, it automatically matches every input
-record read. The range pattern also matches <var>endpat</var> against every
-input record; when this succeeds, the range pattern is turned off again
-for the following record. Then the range pattern goes back to checking
-<var>begpat</var> against each record.
-
- <p><a
name="index-_0040code_007bif_007d-statement_002c-actions_0040comma_007b_007d-changing-909"></a>The
record that turns on the range pattern and the one that turns it
-off both match the range pattern. If you don't want to operate on
-these records, you can write <code>if</code> statements in the rule's action
-to distinguish them from the records you are interested in.
-
- <p>It is possible for a pattern to be turned on and off by the same
-record. If the record satisfies both conditions, then the action is
-executed for just that record.
-For example, suppose there is text between two identical markers (e.g.,
-the `<samp><span class="samp">%</span></samp>' symbol), each on its own line,
that should be ignored.
-A first attempt would be to
-combine a range pattern that describes the delimited text with the
-<code>next</code> statement
-(not discussed yet, see <a href="Next-Statement.html#Next-Statement">Next
Statement</a>).
-This causes <samp><span class="command">awk</span></samp> to skip any further
processing of the current
-record and start over again with the next input record. Such a program
-looks like this:
-
-<pre class="example"> /^%$/,/^%$/ { next }
- { print }
-</pre>
- <p class="noindent"><a
name="index-lines_002c-skipping-between-markers-910"></a><!-- @cindex flag
variables -->
-This program fails because the range pattern is both turned on and turned off
-by the first line, which just has a `<samp><span class="samp">%</span></samp>'
on it. To accomplish this task,
-write the program in the following manner, using a flag:
-
- <p><a name="index-_0040code_007b_0021_007d-operator-911"></a>
-<pre class="example"> /^%$/ { skip = ! skip; next }
- skip == 1 { next } # skip lines with `skip' set
-</pre>
- <p>In a range pattern, the comma (`<samp><span
class="samp">,</span></samp>') has the lowest precedence of
-all the operators (i.e., it is evaluated last). Thus, the following
-program attempts to combine a range pattern with another, simpler test:
-
-<pre class="example"> echo Yes | awk '/1/,/2/ || /Yes/'
-</pre>
- <p>The intent of this program is `<samp><span class="samp">(/1/,/2/) ||
/Yes/</span></samp>'.
-However, <samp><span class="command">awk</span></samp> interprets this as
`<samp><span class="samp">/1/, (/2/ || /Yes/)</span></samp>'.
-This cannot be changed or worked around; range patterns do not combine
-with other patterns:
-
-<pre class="example"> $ echo Yes | gawk '(/1/,/2/) || /Yes/'
- error--> gawk: cmd. line:1: (/1/,/2/) || /Yes/
- error--> gawk: cmd. line:1: ^ parse error
- error--> gawk: cmd. line:2: (/1/,/2/) || /Yes/
- error--> gawk: cmd. line:2: ^ unexpected newline
-</pre>
- </body></html>
-
Index: manual/html_node/Read-Terminal.html
===================================================================
RCS file: manual/html_node/Read-Terminal.html
diff -N manual/html_node/Read-Terminal.html
--- manual/html_node/Read-Terminal.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-<html lang="en">
-<head>
-<title>Read Terminal - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="prev" href="One_002dshot.html#One_002dshot" title="One-shot">
-<link rel="next" href="Long.html#Long" title="Long">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Read-Terminal"></a>Next: <a rel="next" accesskey="n"
href="Long.html#Long">Long</a>,
-Previous: <a rel="previous" accesskey="p"
href="One_002dshot.html#One_002dshot">One-shot</a>,
-Up: <a rel="up" accesskey="u"
href="Running-gawk.html#Running-gawk">Running gawk</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">1.1.2 Running <samp><span
class="command">awk</span></samp> Without Input Files</h4>
-
-<p><a name="index-standard-input-84"></a><a
name="index-input_002c-standard-85"></a><a
name="index-input-files_002c-running-_0040command_007bawk_007d-without-86"></a>You
can also run <samp><span class="command">awk</span></samp> without any input
files. If you type the
-following command line:
-
-<pre class="example"> awk '<var>program</var>'
-</pre>
- <p class="noindent"><samp><span class="command">awk</span></samp> applies
the <var>program</var> to the <dfn>standard input</dfn>,
-which usually means whatever you type on the terminal. This continues
-until you indicate end-of-file by typing <kbd>Ctrl-d</kbd>.
-(On other operating systems, the end-of-file character may be different.
-For example, on OS/2 and MS-DOS, it is <kbd>Ctrl-z</kbd>.)
-
- <p><a name="index-files_002c-input_002c-See-input-files-87"></a><a
name="index-input-files_002c-running-_0040command_007bawk_007d-without-88"></a><a
name="index-_0040command_007bawk_007d-programs_002c-running_002c-without-input-files-89"></a>As
an example, the following program prints a friendly piece of advice
-(from Douglas Adams's <cite>The Hitchhiker's Guide to the Galaxy</cite>),
-to keep you from worrying about the complexities of computer programming
-(<code>BEGIN</code> is a feature we haven't discussed yet):
-
-<pre class="example"> $ awk "BEGIN { print \"Don't Panic!\" }"
- -| Don't Panic!
-</pre>
- <p><a name="index-quoting-90"></a><a
name="index-double-quote-_0028_0040code_007b_0022_007d_0029-91"></a><a
name="index-_0040code_007b_0022_007d-_0028double-quote_0029-92"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029-93"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029-94"></a>This program
does not read any input. The `<samp><span class="samp">\</span></samp>' before
each of the
-inner double quotes is necessary because of the shell's quoting
-rules—in particular because it mixes both single quotes and
-double quotes.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p>This next simple <samp><span class="command">awk</span></samp> program
-emulates the <samp><span class="command">cat</span></samp> utility; it copies
whatever you type on the
-keyboard to its standard output (why this works is explained shortly).
-
-<pre class="example"> $ awk '{ print }'
- Now is the time for all good men
- -| Now is the time for all good men
- to come to the aid of their country.
- -| to come to the aid of their country.
- Four score and seven years ago, ...
- -| Four score and seven years ago, ...
- What, me worry?
- -| What, me worry?
- <kbd>Ctrl-d</kbd>
-</pre>
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Although we generally recommend the use of single
-quotes around the program text, double quotes are needed here in order to
-put the single quote into the message.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Reading-Files.html
===================================================================
RCS file: manual/html_node/Reading-Files.html
diff -N manual/html_node/Reading-Files.html
--- manual/html_node/Reading-Files.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,91 +0,0 @@
-<html lang="en">
-<head>
-<title>Reading Files - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Regexp.html#Regexp" title="Regexp">
-<link rel="next" href="Printing.html#Printing" title="Printing">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Reading-Files"></a>Next: <a rel="next" accesskey="n"
href="Printing.html#Printing">Printing</a>,
-Previous: <a rel="previous" accesskey="p"
href="Regexp.html#Regexp">Regexp</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">3 Reading Input Files</h2>
-
-<!-- STARTOFRANGE infir -->
-<p><a name="index-input-files_002c-reading-342"></a><a
name="index-input-files-343"></a><a
name="index-_0040code_007bFILENAME_007d-variable-344"></a>In the typical
<samp><span class="command">awk</span></samp> program, all input is read either
from the
-standard input (by default, this is the keyboard, but often it is a pipe from
another
-command) or from files whose names you specify on the <samp><span
class="command">awk</span></samp>
-command line. If you specify input files, <samp><span
class="command">awk</span></samp> reads them
-in order, processing all the data from one before going on to the next.
-The name of the current input file can be found in the built-in variable
-<code>FILENAME</code>
-(see <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-
- <p><a name="index-records-345"></a><a name="index-fields-346"></a>The input
is read in units called <dfn>records</dfn>, and is processed by the
-rules of your program one record at a time.
-By default, each record is one line. Each
-record is automatically split into chunks called <dfn>fields</dfn>.
-This makes it more convenient for programs to work on the parts of a record.
-
- <p><a name="index-_0040code_007bgetline_007d-command-347"></a>On rare
occasions, you may need to use the <code>getline</code> command.
-The <code>getline</code> command is valuable, both because it
-can do explicit input from any number of files, and because the files
-used with it do not have to be named on the <samp><span
class="command">awk</span></samp> command line
-(see <a href="Getline.html#Getline">Getline</a>).
-
-<ul class="menu">
-<li><a accesskey="1" href="Records.html#Records">Records</a>:
Controlling how data is split into records.
-<li><a accesskey="2" href="Fields.html#Fields">Fields</a>:
An introduction to fields.
-<li><a accesskey="3"
href="Nonconstant-Fields.html#Nonconstant-Fields">Nonconstant Fields</a>:
Nonconstant Field Numbers.
-<li><a accesskey="4" href="Changing-Fields.html#Changing-Fields">Changing
Fields</a>: Changing the Contents of a Field.
-<li><a accesskey="5" href="Field-Separators.html#Field-Separators">Field
Separators</a>: The field separator and how to change it.
-<li><a accesskey="6" href="Constant-Size.html#Constant-Size">Constant
Size</a>: Reading constant width data.
-<li><a accesskey="7" href="Multiple-Line.html#Multiple-Line">Multiple
Line</a>: Reading multi-line records.
-<li><a accesskey="8" href="Getline.html#Getline">Getline</a>:
Reading files under explicit program control
- using the <code>getline</code> function.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Records.html
===================================================================
RCS file: manual/html_node/Records.html
diff -N manual/html_node/Records.html
--- manual/html_node/Records.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,270 +0,0 @@
-<html lang="en">
-<head>
-<title>Records - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link rel="next" href="Fields.html#Fields" title="Fields">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Records"></a>Next: <a rel="next" accesskey="n"
href="Fields.html#Fields">Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Reading-Files.html#Reading-Files">Reading Files</a>
-<hr><br>
-</div>
-
-<h3 class="section">3.1 How Input Is Split into Records</h3>
-
-<!-- STARTOFRANGE inspl -->
-<p><a name="index-input_002c-splitting-into-records-348"></a><!-- STARTOFRANGE
recspl -->
-<a name="index-records_002c-splitting-input-into-349"></a><a
name="index-_0040code_007bNR_007d-variable-350"></a><a
name="index-_0040code_007bFNR_007d-variable-351"></a>The <samp><span
class="command">awk</span></samp> utility divides the input for your
<samp><span class="command">awk</span></samp>
-program into records and fields.
-<samp><span class="command">awk</span></samp> keeps track of the number of
records that have
-been read
-so far
-from the current input file. This value is stored in a
-built-in variable called <code>FNR</code>. It is reset to zero when a new
-file is started. Another built-in variable, <code>NR</code>, is the total
-number of input records read so far from all data files. It starts at zero,
-but is never automatically reset to zero.
-
- <p><a name="index-separators_002c-for-records-352"></a><a
name="index-record-separators-353"></a>Records are separated by a character
called the <dfn>record separator</dfn>.
-By default, the record separator is the newline character.
-This is why records are, by default, single lines.
-A different character can be used for the record separator by
-assigning the character to the built-in variable <code>RS</code>.
-
- <p><a name="index-newlines_002c-as-record-separators-354"></a><a
name="index-_0040code_007bRS_007d-variable-355"></a>Like any other variable,
-the value of <code>RS</code> can be changed in the <samp><span
class="command">awk</span></samp> program
-with the assignment operator, `<samp><span class="samp">=</span></samp>'
-(see <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-The new record-separator character should be enclosed in quotation marks,
-which indicate a string constant. Often the right time to do this is
-at the beginning of execution, before any input is processed,
-so that the very first record is read with the proper separator.
-To do this, use the special <code>BEGIN</code> pattern
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-For example:
-
- <p><a name="index-_0040code_007bBEGIN_007d-pattern-356"></a>
-<pre class="example"> awk 'BEGIN { RS = "/" }
- { print $0 }' BBS-list
-</pre>
- <p class="noindent">changes the value of <code>RS</code> to
<code>"/"</code>, before reading any input.
-This is a string whose first character is a slash; as a result, records
-are separated by slashes. Then the input file is read, and the second
-rule in the <samp><span class="command">awk</span></samp> program (the action
with no pattern) prints each
-record. Because each <code>print</code> statement adds a newline at the end of
-its output, this <samp><span class="command">awk</span></samp> program copies
the input
-with each slash changed to a newline. Here are the results of running
-the program on <samp><span class="file">BBS-list</span></samp>:
-
-<pre class="example"> $ awk 'BEGIN { RS = "/" }
- > { print $0 }' BBS-list
- -| aardvark 555-5553 1200
- -| 300 B
- -| alpo-net 555-3412 2400
- -| 1200
- -| 300 A
- -| barfly 555-7685 1200
- -| 300 A
- -| bites 555-1675 2400
- -| 1200
- -| 300 A
- -| camelot 555-0542 300 C
- -| core 555-2912 1200
- -| 300 C
- -| fooey 555-1234 2400
- -| 1200
- -| 300 B
- -| foot 555-6699 1200
- -| 300 B
- -| macfoo 555-6480 1200
- -| 300 A
- -| sdace 555-3430 2400
- -| 1200
- -| 300 A
- -| sabafoo 555-2127 1200
- -| 300 C
- -|
-</pre>
- <p class="noindent">Note that the entry for the `<samp><span
class="samp">camelot</span></samp>' BBS is not split.
-In the original data file
-(see <a href="Sample-Data-Files.html#Sample-Data-Files">Sample Data Files</a>),
-the line looks like this:
-
-<pre class="example"> camelot 555-0542 300 C
-</pre>
- <p class="noindent">It has one baud rate only, so there are no slashes in
the record,
-unlike the others which have two or more baud rates.
-In fact, this record is treated as part of the record
-for the `<samp><span class="samp">core</span></samp>' BBS; the newline
separating them in the output
-is the original newline in the data file, not the one added by
-<samp><span class="command">awk</span></samp> when it printed the record!
-
- <p><a name="index-record-separators_002c-changing-357"></a><a
name="index-separators_002c-for-records-358"></a>Another way to change the
record separator is on the command line,
-using the variable-assignment feature
-(see <a href="Other-Arguments.html#Other-Arguments">Other Arguments</a>):
-
-<pre class="example"> awk '{ print $0 }' RS="/" BBS-list
-</pre>
- <p class="noindent">This sets <code>RS</code> to `<samp><span
class="samp">/</span></samp>' before processing <samp><span
class="file">BBS-list</span></samp>.
-
- <p>Using an unusual character such as `<samp><span
class="samp">/</span></samp>' for the record separator
-produces correct behavior in the vast majority of cases. However,
-the following (extreme) pipeline prints a surprising `<samp><span
class="samp">1</span></samp>':
-
-<pre class="example"> $ echo | awk 'BEGIN { RS = "a" } ; { print NF }'
- -| 1
-</pre>
- <p>There is one field, consisting of a newline. The value of the built-in
-variable <code>NF</code> is the number of fields in the current record.
-
- <p><a name="index-dark-corner_002c-input-files-359"></a>Reaching the end of
an input file terminates the current input record,
-even if the last character in the file is not the character in
<code>RS</code>.
-(d.c.)
-
- <p><a name="index-null-strings-360"></a><a
name="index-strings_002c-empty_002c-See-null-strings-361"></a>The empty string
<code>""</code> (a string without any characters)
-has a special meaning
-as the value of <code>RS</code>. It means that records are separated
-by one or more blank lines and nothing else.
-See <a href="Multiple-Line.html#Multiple-Line">Multiple Line</a>, for more
details.
-
- <p>If you change the value of <code>RS</code> in the middle of an
<samp><span class="command">awk</span></samp> run,
-the new value is used to delimit subsequent records, but the record
-currently being processed, as well as records already processed, are not
-affected.
-
- <p><a name="index-_0040code_007bRT_007d-variable-362"></a><a
name="index-records_002c-terminating-363"></a><a
name="index-terminating-records-364"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-record-separators-365"></a><a
name="index-regular-expressions_002c-as-record-separators-366"></a><a
name="index-record-separators_002c-regular-expressions-as-367"></a><a
name="index-separators_002c-for-records_002c-regular-expressions-as-368"></a>After
the end of the record has been determined, <samp><span
class="command">gawk</span></samp>
-sets the variable <code>RT</code> to the text in the input that matched
-<code>RS</code>.
-When using <samp><span class="command">gawk</span></samp>,
-the value of <code>RS</code> is not limited to a one-character
-string. It can be any regular expression
-(see <a href="Regexp.html#Regexp">Regexp</a>).
-In general, each record
-ends at the next string that matches the regular expression; the next
-record starts at the end of the matching string. This general rule is
-actually at work in the usual case, where <code>RS</code> contains just a
-newline: a record ends at the beginning of the next matching string (the
-next newline in the input), and the following record starts just after
-the end of this string (at the first character of the following line).
-The newline, because it matches <code>RS</code>, is not part of either record.
-
- <p>When <code>RS</code> is a single character, <code>RT</code>
-contains the same single character. However, when <code>RS</code> is a
-regular expression, <code>RT</code> contains
-the actual input text that matched the regular expression.
-
- <p>The following example illustrates both of these features.
-It sets <code>RS</code> equal to a regular expression that
-matches either a newline or a series of one or more uppercase letters
-with optional leading and/or trailing whitespace:
-
-<pre class="example"> $ echo record 1 AAAA record 2 BBBB record 3 |
- > gawk 'BEGIN { RS = "\n|( *[[:upper:]]+ *)" }
- > { print "Record =", $0, "and RT =", RT }'
- -| Record = record 1 and RT = AAAA
- -| Record = record 2 and RT = BBBB
- -| Record = record 3 and RT =
- -|
-</pre>
- <p class="noindent">The final line of output has an extra blank line. This
is because the
-value of <code>RT</code> is a newline, and the <code>print</code> statement
-supplies its own terminating newline.
-See <a href="Simple-Sed.html#Simple-Sed">Simple Sed</a>, for a more useful
example
-of <code>RS</code> as a regexp and <code>RT</code>.
-
- <p>If you set <code>RS</code> to a regular expression that allows optional
-trailing text, such as `<samp><span class="samp">RS =
"abc(XYZ)?"</span></samp>' it is possible, due
-to implementation constraints, that <samp><span
class="command">gawk</span></samp> may match the leading
-part of the regular expression, but not the trailing part, particularly
-if the input text that could match the trailing part is fairly long.
-<samp><span class="command">gawk</span></samp> attempts to avoid this problem,
but currently, there's
-no guarantee that this will never happen.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bRS_007d_002f_0040code_007bRT_007d-variables-369"></a>The
use of <code>RS</code> as a regular expression and the <code>RT</code>
-variable are <samp><span class="command">gawk</span></samp> extensions; they
are not available in
-compatibility mode
-(see <a href="Options.html#Options">Options</a>).
-In compatibility mode, only the first character of the value of
-<code>RS</code> is used to determine the end of the record.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: <code>RS = "\0"</code> Is Not
Portable</h4>
-
-<p><a
name="index-advanced-features_002c-_0040value_007bDF_007ds-as-single-record-370"></a><a
name="index-portability_002c-_0040value_007bDF_007ds-as-single-record-371"></a>There
are times when you might want to treat an entire data file as a
-single record. The only way to make this happen is to give <code>RS</code>
-a value that you know doesn't occur in the input file. This is hard
-to do in a general way, such that a program always works for arbitrary
-input files.
-<!-- can you say `understatement' boys and girls? -->
-
- <p>You might think that for text files, the <span class="sc">nul</span>
character, which
-consists of a character with all bits equal to zero, is a good
-value to use for <code>RS</code> in this case:
-
-<pre class="example"> BEGIN { RS = "\0" } # whole file becomes one record?
-</pre>
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings_002c-storing-372"></a><samp><span
class="command">gawk</span></samp> in fact accepts this, and uses the <span
class="sc">nul</span>
-character for the record separator.
-However, this usage is <em>not</em> portable
-to other <samp><span class="command">awk</span></samp> implementations.
-
- <p><a name="index-dark-corner_002c-strings_002c-storing-373"></a>All other
<samp><span class="command">awk</span></samp> implementations<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a> store strings internally as C-style
strings. C strings use the
-<span class="sc">nul</span> character as the string terminator. In effect,
this means that
-`<samp><span class="samp">RS = "\0"</span></samp>' is the same as `<samp><span
class="samp">RS = ""</span></samp>'.
-(d.c.)
-
- <p><a name="index-records_002c-treating-files-as-374"></a><a
name="index-files_002c-as-single-records-375"></a>The best way to treat a whole
file as a single record is to
-simply read the file in, one record at a time, concatenating each
-record onto the end of the previous ones.
-<!-- ENDOFRANGE inspl -->
-<!-- ENDOFRANGE recspl -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> At least that we know
-about.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Redirection.html
===================================================================
RCS file: manual/html_node/Redirection.html
diff -N manual/html_node/Redirection.html
--- manual/html_node/Redirection.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,221 +0,0 @@
-<html lang="en">
-<head>
-<title>Redirection - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="Printf.html#Printf" title="Printf">
-<link rel="next" href="Special-Files.html#Special-Files" title="Special Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Redirection"></a>Next: <a rel="next" accesskey="n"
href="Special-Files.html#Special-Files">Special Files</a>,
-Previous: <a rel="previous" accesskey="p"
href="Printf.html#Printf">Printf</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.6 Redirecting Output of <code>print</code> and
<code>printf</code></h3>
-
-<p><a name="index-output-redirection-544"></a><a
name="index-redirection-of-output-545"></a>So far, the output from
<code>print</code> and <code>printf</code> has gone
-to the standard
-output, usually the terminal. Both <code>print</code> and <code>printf</code>
can
-also send their output to other places.
-This is called <dfn>redirection</dfn>.
-
- <p>A redirection appears after the <code>print</code> or
<code>printf</code> statement.
-Redirections in <samp><span class="command">awk</span></samp> are written just
like redirections in shell
-commands, except that they are written inside the <samp><span
class="command">awk</span></samp> program.
-
-<!-- the commas here are part of the see also -->
-<p><a
name="index-_0040code_007bprint_007d-statement_002c-See-Also-redirection_002c-of-output-546"></a><a
name="index-_0040code_007bprintf_007d-statement_002c-See-Also-redirection_002c-of-output-547"></a>There
are four forms of output redirection: output to a file, output
-appended to a file, output through a pipe to another command, and output
-to a coprocess. They are all shown for the <code>print</code> statement,
-but they work identically for <code>printf</code>:
-
-
-<a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-548"></a>
-<a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-_0028I_002fO_0029-549"></a>
-<a name="index-operators_002c-input_002foutput-550"></a>
-<dl><dt><code>print </code><var>items</var><code> >
</code><var>output-file</var><dd>This type of redirection prints the items into
the output file named
-<var>output-file</var>. The file name <var>output-file</var> can be any
-expression. Its value is changed to a string and then used as a
-file name (see <a href="Expressions.html#Expressions">Expressions</a>).
-
- <p>When this type of redirection is used, the <var>output-file</var> is
erased
-before the first output is written to it. Subsequent writes to the same
-<var>output-file</var> do not erase <var>output-file</var>, but append to it.
-(This is different from how you use redirections in shell scripts.)
-If <var>output-file</var> does not exist, it is created. For example, here
-is how an <samp><span class="command">awk</span></samp> program can write a
list of BBS names to one
-file named <samp><span class="file">name-list</span></samp>, and a list of
phone numbers to another file
-named <samp><span class="file">phone-list</span></samp>:
-
- <pre class="example"> $ awk '{ print $2 > "phone-list"
- > print $1 > "name-list" }' BBS-list
- $ cat phone-list
- -| 555-5553
- -| 555-3412
- ...
- $ cat name-list
- -| aardvark
- -| alpo-net
- ...
- </pre>
- <p class="noindent">Each output file contains one name or number per line.
-
- <p><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-551"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003e_007d-operator-_0028I_002fO_0029-552"></a><br><dt><code>print
</code><var>items</var><code> >> </code><var>output-file</var><dd>This
type of redirection prints the items into the pre-existing output file
-named <var>output-file</var>. The difference between this and the
-single-`<samp><span class="samp">></span></samp>' redirection is that the
old contents (if any) of
-<var>output-file</var> are not erased. Instead, the <samp><span
class="command">awk</span></samp> output is
-appended to the file.
-If <var>output-file</var> does not exist, then it is created.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_007d-operator-_0028I_002fO_0029-553"></a><a
name="index-pipes_002c-output-554"></a><a
name="index-output_002c-pipes-555"></a><br><dt><code>print
</code><var>items</var><code> | </code><var>command</var><dd>It is also
possible to send output to another program through a pipe
-instead of into a file. This type of redirection opens a pipe to
-<var>command</var>, and writes the values of <var>items</var> through this pipe
-to another process created to execute <var>command</var>.
-
- <p>The redirection argument <var>command</var> is actually an <samp><span
class="command">awk</span></samp>
-expression. Its value is converted to a string whose contents give
-the shell command to be run. For example, the following produces two
-files, one unsorted list of BBS names, and one list sorted in reverse
-alphabetical order:
-
- <pre class="example"> awk '{ print $1 > "names.unsorted"
- command = "sort -r > names.sorted"
- print $1 | command }' BBS-list
- </pre>
- <p>The unsorted list is written with an ordinary redirection, while
-the sorted list is written by piping through the <samp><span
class="command">sort</span></samp> utility.
-
- <p>The next example uses redirection to mail a message to the mailing
-list `<samp><span class="samp">bug-system</span></samp>'. This might be
useful when trouble is encountered
-in an <samp><span class="command">awk</span></samp> script run periodically
for system maintenance:
-
- <pre class="example"> report = "mail bug-system"
- print "Awk script failed:", $0 | report
- m = ("at record number " FNR " of " FILENAME)
- print m | report
- close(report)
- </pre>
- <p>The message is built using string concatenation and saved in the
variable
-<code>m</code>. It's then sent down the pipeline to the <samp><span
class="command">mail</span></samp> program.
-(The parentheses group the items to concatenate—see
-<a href="Concatenation.html#Concatenation">Concatenation</a>.)
-
- <p>The <code>close</code> function is called here because it's a good
idea to close
-the pipe as soon as all the intended output has been sent to it.
-See <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>,
-for more information.
-
- <p>This example also illustrates the use of a variable to represent
-a <var>file</var> or <var>command</var>—it is not necessary to always
-use a string constant. Using a variable is generally a good idea,
-because <samp><span class="command">awk</span></samp> requires that the string
value be spelled identically
-every time.
-
- <p><a name="index-coprocesses-556"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-557"></a><a
name="index-operators_002c-input_002foutput-558"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-input_002foutput-operators-559"></a><br><dt><code>print
</code><var>items</var><code> |& </code><var>command</var><dd>This type of
redirection prints the items to the input of <var>command</var>.
-The difference between this and the
-single-`<samp><span class="samp">|</span></samp>' redirection is that the
output from <var>command</var>
-can be read with <code>getline</code>.
-Thus <var>command</var> is a <dfn>coprocess</dfn>, which works together with,
-but subsidiary to, the <samp><span class="command">awk</span></samp> program.
-
- <p>This feature is a <samp><span class="command">gawk</span></samp>
extension, and is not available in
-POSIX <samp><span class="command">awk</span></samp>.
-See <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>,
-for a more complete discussion.
-</dl>
-
- <p>Redirecting output using `<samp><span class="samp">></span></samp>',
`<samp><span class="samp">>></span></samp>', `<samp><span
class="samp">|</span></samp>', or `<samp><span
class="samp">|&</span></samp>'
-asks the system to open a file, pipe, or coprocess only if the particular
-<var>file</var> or <var>command</var> you specify has not already been written
-to by your program or if it has been closed since it was last written to.
-
- <p><a name="index-troubleshooting_002c-printing-560"></a>It is a common
error to use `<samp><span class="samp">></span></samp>' redirection for the
first <code>print</code>
-to a file, and then to use `<samp><span class="samp">>></span></samp>'
for subsequent output:
-
-<pre class="example"> # clear the file
- print "Don't panic" > "guide.txt"
- ...
- # append
- print "Avoid improbability generators" >> "guide.txt"
-</pre>
- <p class="noindent">This is indeed how redirections must be used from the
shell. But in
-<samp><span class="command">awk</span></samp>, it isn't necessary. In this
kind of case, a program should
-use `<samp><span class="samp">></span></samp>' for all the
<code>print</code> statements, since the output file
-is only opened once.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-implementation-limitations-561"></a><a
name="index-implementation-issues_0040comma_007b_007d-_0040command_007bgawk_007d_002c-limits-562"></a><a
name="index-_0040command_007bawk_007d_002c-implementation-issues_002c-pipes-563"></a><a
name="index-_0040command_007bgawk_007d_002c-implementation-issues_002c-pipes-564"></a>As
mentioned earlier
-(see <a href="Getline-Notes.html#Getline-Notes">Getline Notes</a>),
-many
-Many
-<samp><span class="command">awk</span></samp> implementations limit the number
of pipelines that an <samp><span class="command">awk</span></samp>
-program may have open to just one! In <samp><span
class="command">gawk</span></samp>, there is no such limit.
-<samp><span class="command">gawk</span></samp> allows a program to
-open as many pipelines as the underlying operating system permits.
-
-<!-- fakenode - for prepinfo -->
-<h4 class="subheading">Advanced Notes: Piping into <samp><span
class="command">sh</span></samp></h4>
-
-<p><a
name="index-advanced-features_002c-piping-into-_0040command_007bsh_007d-565"></a><a
name="index-shells_002c-piping-commands-into-566"></a>
-A particularly powerful way to use redirection is to build command lines
-and pipe them into the shell, <samp><span class="command">sh</span></samp>.
For example, suppose you
-have a list of files brought over from a system where all the file names
-are stored in uppercase, and you wish to rename them to have names in
-all lowercase. The following program is both simple and efficient:
-
-<!-- @cindex @command{mv} utility -->
-<pre class="example"> { printf("mv %s %s\n", $0, tolower($0)) | "sh" }
-
- END { close("sh") }
-</pre>
- <p>The <code>tolower</code> function returns its argument string with all
-uppercase characters converted to lowercase
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-The program builds up a list of command lines,
-using the <samp><span class="command">mv</span></samp> utility to rename the
files.
-It then sends the list to the shell for execution.
-<!-- ENDOFRANGE outre -->
-<!-- ENDOFRANGE reout -->
-
- </body></html>
-
Index: manual/html_node/Reference-to-Elements.html
===================================================================
RCS file: manual/html_node/Reference-to-Elements.html
diff -N manual/html_node/Reference-to-Elements.html
--- manual/html_node/Reference-to-Elements.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,104 +0,0 @@
-<html lang="en">
-<head>
-<title>Reference to Elements - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Array-Intro.html#Array-Intro" title="Array Intro">
-<link rel="next" href="Assigning-Elements.html#Assigning-Elements"
title="Assigning Elements">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Reference-to-Elements"></a>Next: <a rel="next" accesskey="n"
href="Assigning-Elements.html#Assigning-Elements">Assigning Elements</a>,
-Previous: <a rel="previous" accesskey="p"
href="Array-Intro.html#Array-Intro">Array Intro</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.2 Referring to an Array Element</h3>
-
-<p><a name="index-arrays_002c-elements_002c-referencing-1090"></a><a
name="index-elements-in-arrays-1091"></a>
-The principal way to use an array is to refer to one of its elements.
-An array reference is an expression as follows:
-
-<pre class="example"> <var>array</var>[<var>index</var>]
-</pre>
- <p class="noindent">Here, <var>array</var> is the name of an array. The
expression <var>index</var> is
-the index of the desired element of the array.
-
- <p>The value of the array reference is the current value of that array
-element. For example, <code>foo[4.3]</code> is an expression for the element
-of array <code>foo</code> at index `<samp><span
class="samp">4.3</span></samp>'.
-
- <p>A reference to an array element that has no recorded value yields a
value of
-<code>""</code>, the null string. This includes elements
-that have not been assigned any value as well as elements that have been
-deleted (see <a href="Delete.html#Delete">Delete</a>). Such a reference
-automatically creates that array element, with the null string as its value.
-(In some cases, this is unfortunate, because it might waste memory inside
-<samp><span class="command">awk</span></samp>.)
-
-<!-- @cindex arrays, @code{in} operator and -->
-<p><a name="index-_0040code_007bin_007d-operator_002c-arrays-and-1092"></a>To
determine whether an element exists in an array at a certain index, use
-the following expression:
-
-<pre class="example"> <var>index</var> in <var>array</var>
-</pre>
- <p><a name="index-side-effects_002c-array-indexing-1093"></a>This
expression tests whether the particular index exists,
-without the side effect of creating that element if it is not present.
-The expression has the value one (true) if
<var>array</var><code>[</code><var>index</var><code>]</code>
-exists and zero (false) if it does not exist.
-For example, this statement tests whether the array <code>frequencies</code>
-contains the index `<samp><span class="samp">2</span></samp>':
-
-<pre class="example"> if (2 in frequencies)
- print "Subscript 2 is present."
-</pre>
- <p>Note that this is <em>not</em> a test of whether the array
-<code>frequencies</code> contains an element whose <em>value</em> is two.
-There is no way to do that except to scan all the elements. Also, this
-<em>does not</em> create <code>frequencies[2]</code>, while the following
-(incorrect) alternative does:
-
-<pre class="example"> if (frequencies[2] != "")
- print "Subscript 2 is present."
-</pre>
- </body></html>
-
Index: manual/html_node/Regexp-Constants.html
===================================================================
RCS file: manual/html_node/Regexp-Constants.html
diff -N manual/html_node/Regexp-Constants.html
--- manual/html_node/Regexp-Constants.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,64 +0,0 @@
-<html lang="en">
-<head>
-<title>Regexp Constants - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Constants.html#Constants" title="Constants">
-<link rel="prev" href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers"
title="Nondecimal-numbers">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Regexp-Constants"></a>Previous: <a rel="previous" accesskey="p"
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>,
-Up: <a rel="up" accesskey="u"
href="Constants.html#Constants">Constants</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">5.1.3 Regular Expression Constants</h4>
-
-<!-- STARTOFRANGE rec -->
-<p><a name="index-regexp-constants-619"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-620"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-621"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-622"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-623"></a>A
regexp constant is a regular expression description enclosed in
-slashes, such as <code>/^beginning and end$/<!-- /@w --></code>.
Most regexps used in
-<samp><span class="command">awk</span></samp> programs are constant, but the
`<samp><span class="samp">~</span></samp>' and `<samp><span
class="samp">!~</span></samp>'
-matching operators can also match computed or “dynamic” regexps
-(which are just ordinary strings or variables that contain a regexp).
-<!-- ENDOFRANGE cnst -->
-
- </body></html>
-
Index: manual/html_node/Regexp-Field-Splitting.html
===================================================================
RCS file: manual/html_node/Regexp-Field-Splitting.html
diff -N manual/html_node/Regexp-Field-Splitting.html
--- manual/html_node/Regexp-Field-Splitting.html 31 Aug 2004 22:04:11
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,114 +0,0 @@
-<html lang="en">
-<head>
-<title>Regexp Field Splitting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Field-Separators.html#Field-Separators" title="Field
Separators">
-<link rel="next" href="Single-Character-Fields.html#Single-Character-Fields"
title="Single Character Fields">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Regexp-Field-Splitting"></a>Next: <a rel="next" accesskey="n"
href="Single-Character-Fields.html#Single-Character-Fields">Single Character
Fields</a>,
-Up: <a rel="up" accesskey="u"
href="Field-Separators.html#Field-Separators">Field Separators</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.5.1 Using Regular Expressions to Separate Fields</h4>
-
-<!-- STARTOFRANGE regexpfs -->
-<p><a name="index-regular-expressions_002c-as-field-separators-413"></a><!--
STARTOFRANGE fsregexp -->
-<a name="index-field-separators_002c-regular-expressions-as-414"></a>The
previous subsection
-discussed the use of single characters or simple strings as the
-value of <code>FS</code>.
-More generally, the value of <code>FS</code> may be a string containing any
-regular expression. In this case, each match in the record for the regular
-expression separates fields. For example, the assignment:
-
-<pre class="example"> FS = ", \t"
-</pre>
- <p class="noindent">makes every area of an input line that consists of a
comma followed by a
-space and a TAB into a field separator.
-
- <p>For a less trivial example of a regular expression, try using
-single spaces to separate fields the way single commas are used.
-<code>FS</code> can be set to <code>"[ ]"</code><!-- /@w --> (left
bracket, space, right
-bracket). This regular expression matches a single space and nothing else
-(see <a href="Regexp.html#Regexp">Regexp</a>).
-
- <p>There is an important difference between the two cases of `<samp><span
class="samp">FS = " "<!-- /@w --></span></samp>'
-(a single space) and `<samp><span class="samp">FS = "[ \t\n]+"<!-- /@w
--></span></samp>'
-(a regular expression matching one or more spaces, tabs, or newlines).
-For both values of <code>FS</code>, fields are separated by <dfn>runs</dfn>
-(multiple adjacent occurrences) of spaces, tabs,
-and/or newlines. However, when the value of <code>FS</code> is
<code>" "</code><!-- /@w -->,
-<samp><span class="command">awk</span></samp> first strips leading and
trailing whitespace from
-the record and then decides where the fields are.
-For example, the following pipeline prints `<samp><span
class="samp">b</span></samp>':
-
-<pre class="example"> $ echo ' a b c d ' | awk '{ print $2 }'
- -| b
-</pre>
- <p class="noindent">However, this pipeline prints `<samp><span
class="samp">a</span></samp>' (note the extra spaces around
-each letter):
-
-<pre class="example"> $ echo ' a b c d ' | awk 'BEGIN { FS = "[ \t\n]+"
}
- > { print $2 }'
- -| a
-</pre>
- <p class="noindent"><a name="index-null-strings-415"></a><a
name="index-strings_002c-null-416"></a><a
name="index-empty-strings_002c-See-null-strings-417"></a>In this case, the
first field is <dfn>null</dfn> or empty.
-
- <p>The stripping of leading and trailing whitespace also comes into
-play whenever <code>$0</code> is recomputed. For instance, study this
pipeline:
-
-<pre class="example"> $ echo ' a b c d' | awk '{ print; $2 = $2; print }'
- -| a b c d
- -| a b c d
-</pre>
- <p class="noindent">The first <code>print</code> statement prints the
record as it was read,
-with leading whitespace intact. The assignment to <code>$2</code> rebuilds
-<code>$0</code> by concatenating <code>$1</code> through <code>$NF</code>
together,
-separated by the value of <code>OFS</code>. Because the leading whitespace
-was ignored when finding <code>$1</code>, it is not part of the new
<code>$0</code>.
-Finally, the last <code>print</code> statement prints the new <code>$0</code>.
-<!-- ENDOFRANGE regexpfs -->
-<!-- ENDOFRANGE fsregexp -->
-
- </body></html>
-
Index: manual/html_node/Regexp-Operators.html
===================================================================
RCS file: manual/html_node/Regexp-Operators.html
diff -N manual/html_node/Regexp-Operators.html
--- manual/html_node/Regexp-Operators.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,234 +0,0 @@
-<html lang="en">
-<head>
-<title>Regexp Operators - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="prev" href="Escape-Sequences.html#Escape-Sequences" title="Escape
Sequences">
-<link rel="next" href="Character-Lists.html#Character-Lists" title="Character
Lists">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Regexp-Operators"></a>Next: <a rel="next" accesskey="n"
href="Character-Lists.html#Character-Lists">Character Lists</a>,
-Previous: <a rel="previous" accesskey="p"
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.3 Regular Expression Operators</h3>
-
-<!-- STARTOFRANGE regexpo -->
-<p><a name="index-regular-expressions_002c-operators-221"></a>
-You can combine regular expressions with special characters,
-called <dfn>regular expression operators</dfn> or <dfn>metacharacters</dfn>, to
-increase the power and versatility of regular expressions.
-
- <p>The escape sequences described
-earlier
-in <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>,
-are valid inside a regexp. They are introduced by a `<samp><span
class="samp">\</span></samp>' and
-are recognized and converted into corresponding real characters as
-the very first step in processing regexps.
-
- <p>Here is a list of metacharacters. All characters that are not escape
-sequences and that are not listed in the table stand for themselves:
-
-
-<a name="index-backslash-_0028_0040code_007b_005c_007d_0029-222"></a>
-<a name="index-_0040code_007b_005c_007d-_0028backslash_0029-223"></a>
-<dl><dt><code>\</code><dd>This is used to suppress the special meaning of a
character when
-matching. For example, `<samp><span class="samp">\$</span></samp>'
-matches the character `<samp><span class="samp">$</span></samp>'.
-
- <p><a name="index-regular-expressions_002c-anchors-in-224"></a><a
name="index-Texinfo_002c-chapter-beginnings-in-files-225"></a><a
name="index-_0040code_007b_005e_007d-_0028caret_0029-226"></a><a
name="index-caret-_0028_0040code_007b_005e_007d_0029-227"></a><br><dt><code>^</code><dd>This
matches the beginning of a string. For example, `<samp><span
class="samp">address@hidden</span></samp>'
-matches `<samp><span class="samp">@chapter</span></samp>' at the beginning of
a string and can be used
-to identify chapter beginnings in Texinfo source files.
-The `<samp><span class="samp">^</span></samp>' is known as an
<dfn>anchor</dfn>, because it anchors the pattern to
-match only at the beginning of the string.
-
- <p>It is important to realize that `<samp><span
class="samp">^</span></samp>' does not match the beginning of
-a line embedded in a string.
-The condition is not true in the following example:
-
- <pre class="example"> if ("line1\nLINE 2" ~ /^L/) ...
- </pre>
- <p><a
name="index-_0040code_007b_0024_007d-_0028dollar-sign_0029-228"></a><a
name="index-dollar-sign-_0028_0040code_007b_0024_007d_0029-229"></a><br><dt><code>$</code><dd>This
is similar to `<samp><span class="samp">^</span></samp>', but it matches only
at the end of a string.
-For example, `<samp><span class="samp">p$</span></samp>'
-matches a record that ends with a `<samp><span class="samp">p</span></samp>'.
The `<samp><span class="samp">$</span></samp>' is an anchor
-and does not match the end of a line embedded in a string.
-The condition in the following example is not true:
-
- <pre class="example"> if ("line1\nLINE 2" ~ /1$/) ...
- </pre>
- <p><a name="index-_0040code_007b_002e_007d-_0028period_0029-230"></a><a
name="index-period-_0028_0040code_007b_002e_007d_0029-231"></a><br><dt><code>.</code><dd>This
matches any single character,
-<em>including</em> the newline character. For example, `<samp><span
class="samp">.P</span></samp>'
-matches any single character followed by a `<samp><span
class="samp">P</span></samp>' in a string. Using
-concatenation, we can make a regular expression such as `<samp><span
class="samp">U.A</span></samp>', which
-matches any three-character sequence that begins with `<samp><span
class="samp">U</span></samp>' and ends
-with `<samp><span class="samp">A</span></samp>'.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-period-_0028_0040code_007b_002e_007d_0029_0040comma_007b_007d-using-232"></a>In
strict POSIX mode (see <a href="Options.html#Options">Options</a>),
-`<samp><span class="samp">.</span></samp>' does not match the <span
class="sc">nul</span>
-character, which is a character with all bits equal to zero.
-Otherwise, <span class="sc">nul</span> is just another character. Other
versions of <samp><span class="command">awk</span></samp>
-may not be able to match the <span class="sc">nul</span> character.
-
- <p><a
name="index-_0040code_007b_005b_005d_007d-_0028square-brackets_0029-233"></a><a
name="index-square-brackets-_0028_0040code_007b_005b_005d_007d_0029-234"></a><a
name="index-character-lists-235"></a><a
name="index-character-sets_002c-See-Also-character-lists-236"></a><a
name="index-bracket-expressions_002c-See-character-lists-237"></a><br><dt><code>[...]</code><dd>This
is called a <dfn>character list</dfn>.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-It matches any <em>one</em> of the characters that are enclosed in
-the square brackets. For example, `<samp><span
class="samp">[MVX]</span></samp>' matches any one of
-the characters `<samp><span class="samp">M</span></samp>', `<samp><span
class="samp">V</span></samp>', or `<samp><span class="samp">X</span></samp>' in
a string. A full
-discussion of what can be inside the square brackets of a character list
-is given in
-<a href="Character-Lists.html#Character-Lists">Character Lists</a>.
-
- <p><a
name="index-character-lists_002c-complemented-238"></a><br><dt><code>[^
...]</code><dd>This is a <dfn>complemented character list</dfn>. The first
character after
-the `<samp><span class="samp">[</span></samp>' <em>must</em> be a `<samp><span
class="samp">^</span></samp>'. It matches any characters
-<em>except</em> those in the square brackets. For example, `<samp><span
class="samp">[^awk]</span></samp>'
-matches any character that is not an `<samp><span
class="samp">a</span></samp>', `<samp><span class="samp">w</span></samp>',
-or `<samp><span class="samp">k</span></samp>'.
-
- <p><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029-239"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029-240"></a><br><dt><code>|</code><dd>This
is the <dfn>alternation operator</dfn> and it is used to specify
-alternatives.
-The `<samp><span class="samp">|</span></samp>' has the lowest precedence of
all the regular
-expression operators.
-For example, `<samp><span class="samp">^P|[[:digit:]]</span></samp>'
-matches any string that matches either `<samp><span
class="samp">^P</span></samp>' or `<samp><span
class="samp">[[:digit:]]</span></samp>'. This
-means it matches any string that starts with `<samp><span
class="samp">P</span></samp>' or contains a digit.
-
- <p>The alternation applies to the largest possible regexps on either side.
-
- <p><a
name="index-_0040code_007b_0028_0029_007d-_0028parentheses_0029-241"></a><a
name="index-parentheses-_0040code_007b_0028_0029_007d-242"></a><br><dt><code>(...)</code><dd>Parentheses
are used for grouping in regular expressions, as in
-arithmetic. They can be used to concatenate regular expressions
-containing the alternation operator, `<samp><span
class="samp">|</span></samp>'. For example,
-`<samp><span class="samp">@(samp|code)\{[^}]+\}</span></samp>' matches both
`<samp><span class="samp">@code{foo}</span></samp>' and
-`<samp><span class="samp">@samp{bar}</span></samp>'.
-(These are Texinfo formatting control sequences. The `<samp><span
class="samp">+</span></samp>' is
-explained further on in this list.)
-
- <p><a
name="index-_0040code_007b_002a_007d-_0028asterisk_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-243"></a><a
name="index-asterisk-_0028_0040code_007b_002a_007d_0029_002c-_0040code_007b_002a_007d-operator_002c-as-regexp-operator-244"></a><br><dt><code>*</code><dd>This
symbol means that the preceding regular expression should be
-repeated as many times as necessary to find a match. For example,
`<samp><span class="samp">ph*</span></samp>'
-applies the `<samp><span class="samp">*</span></samp>' symbol to the preceding
`<samp><span class="samp">h</span></samp>' and looks for matches
-of one `<samp><span class="samp">p</span></samp>' followed by any number of
`<samp><span class="samp">h</span></samp>'s. This also matches
-just `<samp><span class="samp">p</span></samp>' if no `<samp><span
class="samp">h</span></samp>'s are present.
-
- <p>The `<samp><span class="samp">*</span></samp>' repeats the
<em>smallest</em> possible preceding expression.
-(Use parentheses if you want to repeat a larger expression.) It finds
-as many repetitions as possible. For example,
-`<samp><span class="samp">awk '/\(c[ad][ad]*r x\)/ { print }'
sample</span></samp>'
-prints every record in <samp><span class="file">sample</span></samp>
containing a string of the form
-`<samp><span class="samp">(car x)</span></samp>', `<samp><span
class="samp">(cdr x)</span></samp>', `<samp><span class="samp">(cadr
x)</span></samp>', and so on.
-Notice the escaping of the parentheses by preceding them
-with backslashes.
-
- <p><a
name="index-_0040code_007b_002b_007d-_0028plus-sign_0029-245"></a><a
name="index-plus-sign-_0028_0040code_007b_002b_007d_0029-246"></a><br><dt><code>+</code><dd>This
symbol is similar to `<samp><span class="samp">*</span></samp>', except that
the preceding expression must be
-matched at least once. This means that `<samp><span
class="samp">wh+y</span></samp>'
-would match `<samp><span class="samp">why</span></samp>' and `<samp><span
class="samp">whhy</span></samp>', but not `<samp><span
class="samp">wy</span></samp>', whereas
-`<samp><span class="samp">wh*y</span></samp>' would match all three of these
strings.
-The following is a simpler
-way of writing the last `<samp><span class="samp">*</span></samp>' example:
-
- <pre class="example"> awk '/\(c[ad]+r x\)/ { print }' sample
- </pre>
- <p><a
name="index-_0040code_007b_003f_007d-_0028question-mark_0029-247"></a><a
name="index-question-mark-_0028_0040code_007b_003f_007d_0029-248"></a><br><dt><code>?</code><dd>This
symbol is similar to `<samp><span class="samp">*</span></samp>', except that
the preceding expression can be
-matched either once or not at all. For example, `<samp><span
class="samp">fe?d</span></samp>'
-matches `<samp><span class="samp">fed</span></samp>' and `<samp><span
class="samp">fd</span></samp>', but nothing else.
-
- <p><a
name="index-interval-expressions-249"></a><br><dt><code>{</code><var>n</var><code>}</code><dt><code>{</code><var>n</var><code>,}</code><dt><code>{</code><var>n</var><code>,</code><var>m</var><code>}</code><dd>One
or two numbers inside braces denote an <dfn>interval expression</dfn>.
-If there is one number in the braces, the preceding regexp is repeated
-<var>n</var> times.
-If there are two numbers separated by a comma, the preceding regexp is
-repeated <var>n</var> to <var>m</var> times.
-If there is one number followed by a comma, then the preceding regexp
-is repeated at least <var>n</var> times:
-
- <dl>
-<dt><code>wh{3}y</code><dd>Matches `<samp><span
class="samp">whhhy</span></samp>', but not `<samp><span
class="samp">why</span></samp>' or `<samp><span
class="samp">whhhhy</span></samp>'.
-
- <br><dt><code>wh{3,5}y</code><dd>Matches `<samp><span
class="samp">whhhy</span></samp>', `<samp><span
class="samp">whhhhy</span></samp>', or `<samp><span
class="samp">whhhhhy</span></samp>', only.
-
- <br><dt><code>wh{2,}y</code><dd>Matches `<samp><span
class="samp">whhy</span></samp>' or `<samp><span
class="samp">whhhy</span></samp>', and so on.
-</dl>
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-interval-expressions-in-250"></a>Interval
expressions were not traditionally available in <samp><span
class="command">awk</span></samp>.
-They were added as part of the POSIX standard to make <samp><span
class="command">awk</span></samp>
-and <samp><span class="command">egrep</span></samp> consistent with each other.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-interval-expressions-and-251"></a>However,
because old programs may use `<samp><span class="samp">{</span></samp>' and
`<samp><span class="samp">}</span></samp>' in regexp
-constants, by default <samp><span class="command">gawk</span></samp> does
<em>not</em> match interval expressions
-in regexps. If either <samp><span class="option">--posix</span></samp> or
<samp><span class="option">--re-interval</span></samp> are specified
-(see <a href="Options.html#Options">Options</a>), then interval expressions
-are allowed in regexps.
-
- <p>For new programs that use `<samp><span class="samp">{</span></samp>'
and `<samp><span class="samp">}</span></samp>' in regexp constants,
-it is good practice to always escape them with a backslash. Then the
-regexp constants are valid and work the way you want them to, using
-any version of <samp><span class="command">awk</span></samp>.<a rel="footnote"
href="#fn-2" name="fnd-2"><sup>2</sup></a>
-</dl>
-
- <p><a name="index-precedence_002c-regexp-operators-252"></a><a
name="index-regular-expressions_002c-operators_002c-precedence-of-253"></a>In
regular expressions, the `<samp><span class="samp">*</span></samp>',
`<samp><span class="samp">+</span></samp>', and `<samp><span
class="samp">?</span></samp>' operators,
-as well as the braces `<samp><span class="samp">{</span></samp>' and
`<samp><span class="samp">}</span></samp>',
-have
-the highest precedence, followed by concatenation, and finally by `<samp><span
class="samp">|</span></samp>'.
-As in arithmetic, parentheses can change how operators are grouped.
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-regular-expressions-and-254"></a><a
name="index-_0040command_007bgawk_007d_002c-regular-expressions_002c-precedence-255"></a>In
POSIX <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp>, the `<samp><span
class="samp">*</span></samp>', `<samp><span class="samp">+</span></samp>', and
`<samp><span class="samp">?</span></samp>' operators
-stand for themselves when there is nothing in the regexp that precedes them.
-For example, `<samp><span class="samp">/+/</span></samp>' matches a literal
plus sign. However, many other versions of
-<samp><span class="command">awk</span></samp> treat such a usage as a syntax
error.
-
- <p>If <samp><span class="command">gawk</span></samp> is in compatibility
mode
-(see <a href="Options.html#Options">Options</a>),
-POSIX character classes and interval expressions are not available in
-regular expressions.
-<!-- ENDOFRANGE regexpo -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> In other literature,
-you may see a character list referred to as either a
-<dfn>character set</dfn>, a <dfn>character class</dfn>, or a <dfn>bracket
expression</dfn>.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> Use
two backslashes if you're
-using a string constant with a regexp operator or function.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Regexp-Patterns.html
===================================================================
RCS file: manual/html_node/Regexp-Patterns.html
diff -N manual/html_node/Regexp-Patterns.html
--- manual/html_node/Regexp-Patterns.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<html lang="en">
-<head>
-<title>Regexp Patterns - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Pattern-Overview.html#Pattern-Overview" title="Pattern
Overview">
-<link rel="next" href="Expression-Patterns.html#Expression-Patterns"
title="Expression Patterns">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Regexp-Patterns"></a>Next: <a rel="next" accesskey="n"
href="Expression-Patterns.html#Expression-Patterns">Expression Patterns</a>,
-Up: <a rel="up" accesskey="u"
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.1.1 Regular Expressions as Patterns</h4>
-
-<p><a name="index-patterns_002c-expressions-as-888"></a><a
name="index-regular-expressions_002c-as-patterns-889"></a>
-Regular expressions are one of the first kinds of patterns presented
-in this book.
-This kind of pattern is simply a regexp constant in the pattern part of
-a rule. Its meaning is `<samp><span class="samp">$0 ~
/</span><var>pattern</var><span class="samp">/</span></samp>'.
-The pattern matches when the input record matches the regexp.
-For example:
-
-<pre class="example"> /foo|bar|baz/ { buzzwords++ }
- END { print buzzwords, "buzzwords seen" }
-</pre>
- </body></html>
-
Index: manual/html_node/Regexp-Usage.html
===================================================================
RCS file: manual/html_node/Regexp-Usage.html
diff -N manual/html_node/Regexp-Usage.html
--- manual/html_node/Regexp-Usage.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,122 +0,0 @@
-<html lang="en">
-<head>
-<title>Regexp Usage - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Regexp.html#Regexp" title="Regexp">
-<link rel="next" href="Escape-Sequences.html#Escape-Sequences" title="Escape
Sequences">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Regexp-Usage"></a>Next: <a rel="next" accesskey="n"
href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>,
-Up: <a rel="up" accesskey="u" href="Regexp.html#Regexp">Regexp</a>
-<hr><br>
-</div>
-
-<h3 class="section">2.1 How to Use Regular Expressions</h3>
-
-<p><a name="index-regular-expressions_002c-as-patterns-172"></a>A regular
expression can be used as a pattern by enclosing it in
-slashes. Then the regular expression is tested against the
-entire text of each record. (Normally, it only needs
-to match some part of the text in order to succeed.) For example, the
-following prints the second field of each record that contains the string
-`<samp><span class="samp">foo</span></samp>' anywhere in it:
-
-<pre class="example"> $ awk '/foo/ { print $2 }' BBS-list
- -| 555-1234
- -| 555-6699
- -| 555-6480
- -| 555-2127
-</pre>
- <p><a name="index-regular-expressions_002c-operators-173"></a><a
name="index-operators_002c-string_002dmatching-174"></a><!-- @cindex operators,
@code{~} -->
-<a name="index-string_002dmatching-operators-175"></a><code>~</code> (tilde),
<code>~</code> operator
-<a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-176"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-177"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-178"></a><!--
@cindex operators, @code{!~} -->
-<a name="index-_0040code_007bif_007d-statement-179"></a><a
name="index-_0040code_007bwhile_007d-statement-180"></a><a
name="index-_0040code_007bdo_007d_002d_0040code_007bwhile_007d-statement-181"></a><!--
@cindex statements, @code{if} -->
-<!-- @cindex statements, @code{while} -->
-<!-- @cindex statements, @code{do} -->
-Regular expressions can also be used in matching expressions. These
-expressions allow you to specify the string to match against; it need
-not be the entire current input record. The two operators `<samp><span
class="samp">~</span></samp>'
-and `<samp><span class="samp">!~</span></samp>' perform regular expression
comparisons. Expressions
-using these operators can be used as patterns, or in <code>if</code>,
-<code>while</code>, <code>for</code>, and <code>do</code> statements.
-(See <a href="Statements.html#Statements">Statements</a>.)
-For example:
-
-<pre class="example"> <var>exp</var> ~ /<var>regexp</var>/
-</pre>
- <p class="noindent">is true if the expression <var>exp</var> (taken as a
string)
-matches <var>regexp</var>. The following example matches, or selects,
-all input records with the uppercase letter `<samp><span
class="samp">J</span></samp>' somewhere in the
-first field:
-
-<pre class="example"> $ awk '$1 ~ /J/' inventory-shipped
- -| Jan 13 25 15 115
- -| Jun 31 42 75 492
- -| Jul 24 34 67 436
- -| Jan 21 36 64 620
-</pre>
- <p>So does this:
-
-<pre class="example"> awk '{ if ($1 ~ /J/) print }' inventory-shipped
-</pre>
- <p>This next example is true if the expression <var>exp</var>
-(taken as a character string)
-does <em>not</em> match <var>regexp</var>:
-
-<pre class="example"> <var>exp</var> !~ /<var>regexp</var>/
-</pre>
- <p>The following example matches,
-or selects, all input records whose first field <em>does not</em> contain
-the uppercase letter `<samp><span class="samp">J</span></samp>':
-
-<pre class="example"> $ awk '$1 !~ /J/' inventory-shipped
- -| Feb 15 32 24 226
- -| Mar 15 24 34 228
- -| Apr 31 52 63 420
- -| May 16 34 29 208
- ...
-</pre>
- <p><a name="index-regexp-constants-182"></a><a
name="index-regular-expressions_002c-constants_002c-See-regexp-constants-183"></a>When
a regexp is enclosed in slashes, such as <code>/foo/</code>, we call it
-a <dfn>regexp constant</dfn>, much like <code>5.27</code> is a numeric
constant and
-<code>"foo"</code> is a string constant.
-
- </body></html>
-
Index: manual/html_node/Regexp.html
===================================================================
RCS file: manual/html_node/Regexp.html
diff -N manual/html_node/Regexp.html
--- manual/html_node/Regexp.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,90 +0,0 @@
-<html lang="en">
-<head>
-<title>Regexp - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="next" href="Reading-Files.html#Reading-Files" title="Reading Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Regexp"></a>Next: <a rel="next" accesskey="n"
href="Reading-Files.html#Reading-Files">Reading Files</a>,
-Previous: <a rel="previous" accesskey="p"
href="Getting-Started.html#Getting-Started">Getting Started</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">2 Regular Expressions</h2>
-
-<p><a name="index-regexp_002c-See-regular-expressions-168"></a><!--
STARTOFRANGE regexp -->
-<a name="index-regular-expressions-169"></a>
-A <dfn>regular expression</dfn>, or <dfn>regexp</dfn>, is a way of describing a
-set of strings.
-Because regular expressions are such a fundamental part of <samp><span
class="command">awk</span></samp>
-programming, their format and use deserve a separate chapter.
-
- <p><a
name="index-forward-slash-_0028_0040code_007b_002f_007d_0029-170"></a><a
name="index-_0040code_007b_002f_007d-_0028forward-slash_0029-171"></a>A regular
expression enclosed in slashes (`<samp><span class="samp">/</span></samp>')
-is an <samp><span class="command">awk</span></samp> pattern that matches every
input record whose text
-belongs to that set.
-The simplest regular expression is a sequence of letters, numbers, or
-both. Such a regexp matches any string that contains that sequence.
-Thus, the regexp `<samp><span class="samp">foo</span></samp>' matches any
string containing `<samp><span class="samp">foo</span></samp>'.
-Therefore, the pattern <code>/foo/</code> matches any input record containing
-the three characters `<samp><span class="samp">foo</span></samp>'
<em>anywhere</em> in the record. Other
-kinds of regexps let you specify more complicated classes of strings.
-
- <p>Initially, the examples in this chapter are simple.
-As we explain more about how
-regular expressions work, we will present more complicated instances.
-
-<ul class="menu">
-<li><a accesskey="1" href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>:
How to Use Regular Expressions.
-<li><a accesskey="2" href="Escape-Sequences.html#Escape-Sequences">Escape
Sequences</a>: How to write nonprinting characters.
-<li><a accesskey="3" href="Regexp-Operators.html#Regexp-Operators">Regexp
Operators</a>: Regular Expression Operators.
-<li><a accesskey="4" href="Character-Lists.html#Character-Lists">Character
Lists</a>: What can go between `<samp><span
class="samp">[...]</span></samp>'.
-<li><a accesskey="5" href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU
Regexp Operators</a>: Operators specific to GNU software.
-<li><a accesskey="6"
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>:
How to do case-insensitive matching.
-<li><a accesskey="7" href="Leftmost-Longest.html#Leftmost-Longest">Leftmost
Longest</a>: How much text matches.
-<li><a accesskey="8" href="Computed-Regexps.html#Computed-Regexps">Computed
Regexps</a>: Using Dynamic Regexps.
-<li><a accesskey="9" href="Locales.html#Locales">Locales</a>:
How the locale affects things.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Return-Statement.html
===================================================================
RCS file: manual/html_node/Return-Statement.html
diff -N manual/html_node/Return-Statement.html
--- manual/html_node/Return-Statement.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,134 +0,0 @@
-<html lang="en">
-<head>
-<title>Return Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="User_002ddefined.html#User_002ddefined"
title="User-defined">
-<link rel="prev" href="Function-Caveats.html#Function-Caveats" title="Function
Caveats">
-<link rel="next" href="Dynamic-Typing.html#Dynamic-Typing" title="Dynamic
Typing">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Return-Statement"></a>Next: <a rel="next" accesskey="n"
href="Dynamic-Typing.html#Dynamic-Typing">Dynamic Typing</a>,
-Previous: <a rel="previous" accesskey="p"
href="Function-Caveats.html#Function-Caveats">Function Caveats</a>,
-Up: <a rel="up" accesskey="u"
href="User_002ddefined.html#User_002ddefined">User-defined</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.2.4 The <code>return</code> Statement</h4>
-
-<p><a
name="index-_0040code_007breturn_007d-statement_0040comma_007b_007d-user_002ddefined-functions-1298"></a>
-The body of a user-defined function can contain a <code>return</code>
statement.
-This statement returns control to the calling part of the <samp><span
class="command">awk</span></samp> program. It
-can also be used to return a value for use in the rest of the <samp><span
class="command">awk</span></samp>
-program. It looks like this:
-
-<pre class="example"> return <span
class="roman">[</span><var>expression</var><span class="roman">]</span>
-</pre>
- <p>The <var>expression</var> part is optional. If it is omitted, then the
returned
-value is undefined, and therefore, unpredictable.
-
- <p>A <code>return</code> statement with no value expression is assumed at
the end of
-every function definition. So if control reaches the end of the function
-body, then the function returns an unpredictable value. <samp><span
class="command">awk</span></samp>
-does <em>not</em> warn you if you use the return value of such a function.
-
- <p>Sometimes, you want to write a function for what it does, not for
-what it returns. Such a function corresponds to a <code>void</code> function
-in C or to a <code>procedure</code> in Pascal. Thus, it may be appropriate to
not
-return any value; simply bear in mind that if you use the return
-value of such a function, you do so at your own risk.
-
- <p>The following is an example of a user-defined function that returns a
value
-for the largest number among the elements of an array:
-
-<pre class="example"> function maxelt(vec, i, ret)
- {
- for (i in vec) {
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- }
- return ret
- }
-</pre>
- <p><a
name="index-programming-conventions_002c-function-parameters-1299"></a>You call
<code>maxelt</code> with one argument, which is an array name. The local
-variables <code>i</code> and <code>ret</code> are not intended to be arguments;
-while there is nothing to stop you from passing more than one argument
-to <code>maxelt</code>, the results would be strange. The extra space before
-<code>i</code> in the function parameter list indicates that <code>i</code> and
-<code>ret</code> are not supposed to be arguments.
-You should follow this convention when defining functions.
-
- <p>The following program uses the <code>maxelt</code> function. It loads an
-array, calls <code>maxelt</code>, and then reports the maximum number in that
-array:
-
-<pre class="example"> function maxelt(vec, i, ret)
- {
- for (i in vec) {
- if (ret == "" || vec[i] > ret)
- ret = vec[i]
- }
- return ret
- }
-
- # Load all fields of each record into nums.
- {
- for(i = 1; i <= NF; i++)
- nums[NR, i] = $i
- }
-
- END {
- print maxelt(nums)
- }
-</pre>
- <p>Given the following input:
-
-<pre class="example"> 1 5 23 8 16
- 44 3 5 2 8 26
- 256 291 1396 2962 100
- -6 467 998 1101
- 99385 11 0 225
-</pre>
- <p class="noindent">the program reports (predictably) that
<code>99385</code> is the largest number
-in the array.
-
- </body></html>
-
Index: manual/html_node/Rewind-Function.html
===================================================================
RCS file: manual/html_node/Rewind-Function.html
diff -N manual/html_node/Rewind-Function.html
--- manual/html_node/Rewind-Function.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,105 +0,0 @@
-<html lang="en">
-<head>
-<title>Rewind Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Data-File-Management.html#Data-File-Management"
title="Data File Management">
-<link rel="prev" href="Filetrans-Function.html#Filetrans-Function"
title="Filetrans Function">
-<link rel="next" href="File-Checking.html#File-Checking" title="File Checking">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Rewind-Function"></a>Next: <a rel="next" accesskey="n"
href="File-Checking.html#File-Checking">File Checking</a>,
-Previous: <a rel="previous" accesskey="p"
href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a>,
-Up: <a rel="up" accesskey="u"
href="Data-File-Management.html#Data-File-Management">Data File Management</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.3.2 Rereading the Current File</h4>
-
-<p><a name="index-files_002c-reading-1670"></a>Another request for a new
built-in function was for a <code>rewind</code>
-function that would make it possible to reread the current file.
-The requesting user didn't want to have to use <code>getline</code>
-(see <a href="Getline.html#Getline">Getline</a>)
-inside a loop.
-
- <p>However, as long as you are not in the <code>END</code> rule, it is
-quite easy to arrange to immediately close the current input file
-and then start over with it from the top.
-For lack of a better name, we'll call it <code>rewind</code>:
-
- <p><a
name="index-_0040code_007brewind_007d-user_002ddefined-function-1671"></a>
-<pre class="example"> <!-- file eg/lib/rewind.awk -->
- # rewind.awk --- rewind the current file and start over
- <!-- endfile -->
- <!-- file eg/lib/rewind.awk -->
- function rewind( i)
- {
- # shift remaining arguments up
- for (i = ARGC; i > ARGIND; i--)
- ARGV[i] = ARGV[i-1]
-
- # make sure gawk knows to keep going
- ARGC++
-
- # make current file next to get done
- ARGV[ARGIND+1] = FILENAME
-
- # do it
- nextfile
- }
- <!-- endfile -->
-</pre>
- <p>This code relies on the <code>ARGIND</code> variable
-(see <a href="Auto_002dset.html#Auto_002dset">Auto-set</a>),
-which is specific to <samp><span class="command">gawk</span></samp>.
-If you are not using
-<samp><span class="command">gawk</span></samp>, you can use ideas presented in
-the previous section
-to either update <code>ARGIND</code> on your own
-or modify this code as appropriate.
-
- <p>The <code>rewind</code> function also relies on the
<code>nextfile</code> keyword
-(see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-See <a href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a>,
-for a function version of <code>nextfile</code>.
-
- </body></html>
-
Index: manual/html_node/Round-Function.html
===================================================================
RCS file: manual/html_node/Round-Function.html
diff -N manual/html_node/Round-Function.html
--- manual/html_node/Round-Function.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,104 +0,0 @@
-<html lang="en">
-<head>
-<title>Round Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Assert-Function.html#Assert-Function" title="Assert
Function">
-<link rel="next" href="Cliff-Random-Function.html#Cliff-Random-Function"
title="Cliff Random Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Round-Function"></a>Next: <a rel="next" accesskey="n"
href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="Assert-Function.html#Assert-Function">Assert Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.4 Rounding Numbers</h4>
-
-<p><a name="index-rounding-1628"></a><a
name="index-rounding-numbers-1629"></a><a
name="index-numbers_002c-rounding-1630"></a><a
name="index-libraries-of-_0040command_007bawk_007d-functions_002c-rounding-numbers-1631"></a><a
name="index-functions_002c-library_002c-rounding-numbers-1632"></a><a
name="index-_0040code_007bprint_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1633"></a><a
name="index-_0040code_007bprintf_007d-statement_002c-_0040code_007bsprintf_007d-function-and-1634"></a><a
name="index-_0040code_007bsprintf_007d-function_002c-_0040code_007bprint_007d_002f_0040code_007bprintf_007d-statements-and-1635"></a>The
way <code>printf</code> and <code>sprintf</code>
-(see <a href="Printf.html#Printf">Printf</a>)
-perform rounding often depends upon the system's C <code>sprintf</code>
-subroutine. On many machines, <code>sprintf</code> rounding is
“unbiased,”
-which means it doesn't always round a trailing `<samp><span
class="samp">.5</span></samp>' up, contrary
-to naive expectations. In unbiased rounding, `<samp><span
class="samp">.5</span></samp>' rounds to even,
-rather than always up, so 1.5 rounds to 2 but 4.5 rounds to 4. This means
-that if you are using a format that does rounding (e.g., <code>"%.0f"</code>),
-you should check what your system does. The following function does
-traditional rounding; it might be useful if your awk's <code>printf</code>
-does unbiased rounding:
-
- <p><a
name="index-_0040code_007bround_007d-user_002ddefined-function-1636"></a>
-<pre class="example"> <!-- file eg/lib/round.awk -->
- # round.awk --- do normal rounding
- <!-- endfile -->
- <!-- file eg/lib/round.awk -->
- function round(x, ival, aval, fraction)
- {
- ival = int(x) # integer part, int() truncates
-
- # see if fractional part
- if (ival == x) # no fraction
- return x
-
- if (x < 0) {
- aval = -x # absolute value
- ival = int(aval)
- fraction = aval - ival
- if (fraction >= .5)
- return int(x) - 1 # -2.5 --> -3
- else
- return int(x) # -2.3 --> -2
- } else {
- fraction = x - ival
- if (fraction >= .5)
- return ival + 1
- else
- return ival
- }
- }
-
- # test harness
- { print $0, round($0) }
- <!-- endfile -->
-</pre>
- </body></html>
-
Index: manual/html_node/Running-Examples.html
===================================================================
RCS file: manual/html_node/Running-Examples.html
diff -N manual/html_node/Running-Examples.html
--- manual/html_node/Running-Examples.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-<html lang="en">
-<head>
-<title>Running Examples - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Sample-Programs.html#Sample-Programs" title="Sample
Programs">
-<link rel="next" href="Clones.html#Clones" title="Clones">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Running-Examples"></a>Next: <a rel="next" accesskey="n"
href="Clones.html#Clones">Clones</a>,
-Up: <a rel="up" accesskey="u"
href="Sample-Programs.html#Sample-Programs">Sample Programs</a>
-<hr><br>
-</div>
-
-<h3 class="section">13.1 Running the Example Programs</h3>
-
-<p>To run a given program, you would typically do something like this:
-
-<pre class="example"> awk -f <var>program</var> -- <var>options</var>
<var>files</var>
-</pre>
- <p class="noindent">Here, <var>program</var> is the name of the <samp><span
class="command">awk</span></samp> program (such as
-<samp><span class="file">cut.awk</span></samp>), <var>options</var> are any
command-line options for the
-program that start with a `<samp><span class="samp">-</span></samp>', and
<var>files</var> are the actual data files.
-
- <p>If your system supports the `<samp><span class="samp">#!</span></samp>'
executable interpreter mechanism
-(see <a href="Executable-Scripts.html#Executable-Scripts">Executable
Scripts</a>),
-you can instead run your program directly:
-
-<pre class="example"> cut.awk -c1-8 myfiles > results
-</pre>
- <p>If your <samp><span class="command">awk</span></samp> is not <samp><span
class="command">gawk</span></samp>, you may instead need to use this:
-
-<pre class="example"> cut.awk -- -c1-8 myfiles > results
-</pre>
- </body></html>
-
Index: manual/html_node/Running-gawk.html
===================================================================
RCS file: manual/html_node/Running-gawk.html
diff -N manual/html_node/Running-gawk.html
--- manual/html_node/Running-gawk.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-<html lang="en">
-<head>
-<title>Running gawk - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="next" href="Sample-Data-Files.html#Sample-Data-Files" title="Sample
Data Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Running-gawk"></a>Next: <a rel="next" accesskey="n"
href="Sample-Data-Files.html#Sample-Data-Files">Sample Data Files</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.1 How to Run <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-running-78"></a>There are
several ways to run an <samp><span class="command">awk</span></samp> program.
If the program is
-short, it is easiest to include it in the command that runs <samp><span
class="command">awk</span></samp>,
-like this:
-
-<pre class="example"> awk '<var>program</var>' <var>input-file1</var>
<var>input-file2</var> ...
-</pre>
- <p><a name="index-command-line_002c-formats-79"></a>When the program is
long, it is usually more convenient to put it in a file
-and run it with a command like this:
-
-<pre class="example"> awk -f <var>program-file</var>
<var>input-file1</var> <var>input-file2</var> ...
-</pre>
- <p>This section discusses both mechanisms, along with several
-variations of each.
-
-<ul class="menu">
-<li><a accesskey="1" href="One_002dshot.html#One_002dshot">One-shot</a>:
Running a short throwaway <samp><span
class="command">awk</span></samp>
- program.
-<li><a accesskey="2" href="Read-Terminal.html#Read-Terminal">Read
Terminal</a>: Using no input files (input from terminal
- instead).
-<li><a accesskey="3" href="Long.html#Long">Long</a>:
Putting permanent <samp><span class="command">awk</span></samp> programs in
- files.
-<li><a accesskey="4"
href="Executable-Scripts.html#Executable-Scripts">Executable Scripts</a>:
Making self-contained <samp><span class="command">awk</span></samp>
programs.
-<li><a accesskey="5" href="Comments.html#Comments">Comments</a>:
Adding documentation to <samp><span class="command">gawk</span></samp>
- programs.
-<li><a accesskey="6" href="Quoting.html#Quoting">Quoting</a>:
More discussion of shell quoting issues.
-</ul>
-
- </body></html>
-
Index: manual/html_node/SVR4.html
===================================================================
RCS file: manual/html_node/SVR4.html
diff -N manual/html_node/SVR4.html
--- manual/html_node/SVR4.html 31 Aug 2004 22:04:11 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-<html lang="en">
-<head>
-<title>SVR4 - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Language-History.html#Language-History" title="Language
History">
-<link rel="prev" href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1"
title="V7/SVR3.1">
-<link rel="next" href="POSIX.html#POSIX" title="POSIX">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="SVR4"></a>Next: <a rel="next" accesskey="n"
href="POSIX.html#POSIX">POSIX</a>,
-Previous: <a rel="previous" accesskey="p"
href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a>,
-Up: <a rel="up" accesskey="u"
href="Language-History.html#Language-History">Language History</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">A.2 Changes Between SVR3.1 and SVR4</h3>
-
-<p><a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-SVR3_002e1-and-SVR4-1826"></a>The
System V Release 4 (1989) version of Unix <samp><span
class="command">awk</span></samp> added these features
-(some of which originated in <samp><span class="command">gawk</span></samp>):
-
- <ul>
-<li>The <code>ENVIRON</code> variable (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-<!-- gawk and MKS awk -->
-
- <li>Multiple <samp><span class="option">-f</span></samp> options on the
command line
-(see <a href="Options.html#Options">Options</a>).
-<!-- MKS awk -->
-
- <li>The <samp><span class="option">-v</span></samp> option for assigning
variables before program execution begins
-(see <a href="Options.html#Options">Options</a>).
-<!-- GNU, Bell Laboratories & MKS together -->
-
- <li>The <samp><span class="option">--</span></samp> option for
terminating command-line options.
-
- <li>The `<samp><span class="samp">\a</span></samp>', `<samp><span
class="samp">\v</span></samp>', and `<samp><span class="samp">\x</span></samp>'
escape sequences
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-<!-- GNU, for ANSI C compat -->
-
- <li>A defined return value for the <code>srand</code> built-in function
-(see <a href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a>).
-
- <li>The <code>toupper</code> and <code>tolower</code> built-in string
functions
-for case translation
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <li>A cleaner specification for the `<samp><span
class="samp">%c</span></samp>' format-control letter in the
-<code>printf</code> function
-(see <a href="Control-Letters.html#Control-Letters">Control Letters</a>).
-
- <li>The ability to dynamically pass the field width and precision
(<code>"%*.*d"</code>)
-in the argument list of the <code>printf</code> function
-(see <a href="Control-Letters.html#Control-Letters">Control Letters</a>).
-
- <li>The use of regexp constants, such as <code>/foo/</code>, as
expressions, where
-they are equivalent to using the matching operator, as in `<samp><span
class="samp">$0 ~ /foo/</span></samp>'
-(see <a href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using
Constant Regexps</a>).
-
- <li>Processing of escape sequences inside command-line variable
assignments
-(see <a href="Assignment-Options.html#Assignment-Options">Assignment
Options</a>).
-</ul>
-
- </body></html>
-
Index: manual/html_node/Sample-Data-Files.html
===================================================================
RCS file: manual/html_node/Sample-Data-Files.html
diff -N manual/html_node/Sample-Data-Files.html
--- manual/html_node/Sample-Data-Files.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,121 +0,0 @@
-<html lang="en">
-<head>
-<title>Sample Data Files - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="Running-gawk.html#Running-gawk" title="Running gawk">
-<link rel="next" href="Very-Simple.html#Very-Simple" title="Very Simple">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Sample-Data-Files"></a>Next: <a rel="next" accesskey="n"
href="Very-Simple.html#Very-Simple">Very Simple</a>,
-Previous: <a rel="previous" accesskey="p"
href="Running-gawk.html#Running-gawk">Running gawk</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.2 Data Files for the Examples</h3>
-
-<!-- For gawk >= 3.2, update these data files. No-one has such slow modems! -->
-<p><a name="index-input-files_002c-examples-135"></a><a
name="index-_0040code_007bBBS_002dlist_007d-file-136"></a>Many of the examples
in this Web page take their input from two sample
-data files. The first, <samp><span class="file">BBS-list</span></samp>,
represents a list of
-computer bulletin board systems together with information about those systems.
-The second data file, called <samp><span
class="file">inventory-shipped</span></samp>, contains
-information about monthly shipments. In both files,
-each line is considered to be one <dfn>record</dfn>.
-
- <p>In the data file <samp><span class="file">BBS-list</span></samp>, each
record contains the name of a computer
-bulletin board, its phone number, the board's baud rate(s), and a code for
-the number of hours it is operational. An `<samp><span
class="samp">A</span></samp>' in the last column
-means the board operates 24 hours a day. A `<samp><span
class="samp">B</span></samp>' in the last
-column means the board only operates on evening and weekend hours.
-A `<samp><span class="samp">C</span></samp>' means the board operates only on
weekends:
-
-<!-- 2e: Update the baud rates to reflect today's faster modems -->
-<pre class="example"> <!-- system if test ! -d eg ; then mkdir eg
; fi -->
- <!-- system if test ! -d eg/lib ; then mkdir eg/lib ; fi -->
- <!-- system if test ! -d eg/data ; then mkdir eg/data ; fi -->
- <!-- system if test ! -d eg/prog ; then mkdir eg/prog ; fi -->
- <!-- system if test ! -d eg/misc ; then mkdir eg/misc ; fi -->
- <!-- file eg/data/BBS-list -->
- aardvark 555-5553 1200/300 B
- alpo-net 555-3412 2400/1200/300 A
- barfly 555-7685 1200/300 A
- bites 555-1675 2400/1200/300 A
- camelot 555-0542 300 C
- core 555-2912 1200/300 C
- fooey 555-1234 2400/1200/300 B
- foot 555-6699 1200/300 B
- macfoo 555-6480 1200/300 A
- sdace 555-3430 2400/1200/300 A
- sabafoo 555-2127 1200/300 C
- <!-- endfile -->
-</pre>
- <p><a
name="index-_0040code_007binventory_002dshipped_007d-file-137"></a>The data
file <samp><span class="file">inventory-shipped</span></samp> represents
-information about shipments during the year.
-Each record contains the month, the number
-of green crates shipped, the number of red boxes shipped, the number of
-orange bags shipped, and the number of blue packages shipped,
-respectively. There are 16 entries, covering the 12 months of last year
-and the first four months of the current year.
-
-<pre class="example"> <!-- file eg/data/inventory-shipped -->
- Jan 13 25 15 115
- Feb 15 32 24 226
- Mar 15 24 34 228
- Apr 31 52 63 420
- May 16 34 29 208
- Jun 31 42 75 492
- Jul 24 34 67 436
- Aug 15 34 47 316
- Sep 13 55 37 277
- Oct 29 54 68 525
- Nov 20 87 82 577
- Dec 17 35 61 401
-
- Jan 21 36 64 620
- Feb 26 58 80 652
- Mar 24 75 70 495
- Apr 21 70 74 514
- <!-- endfile -->
-</pre>
- </body></html>
-
Index: manual/html_node/Sample-Library.html
===================================================================
RCS file: manual/html_node/Sample-Library.html
diff -N manual/html_node/Sample-Library.html
--- manual/html_node/Sample-Library.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,74 +0,0 @@
-<html lang="en">
-<head>
-<title>Sample Library - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Dynamic-Extensions.html#Dynamic-Extensions"
title="Dynamic Extensions">
-<link rel="prev" href="Internals.html#Internals" title="Internals">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Sample-Library"></a>Previous: <a rel="previous" accesskey="p"
href="Internals.html#Internals">Internals</a>,
-Up: <a rel="up" accesskey="u"
href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic Extensions</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">C.3.2 Directory and File Operation Built-ins</h4>
-
-<!-- STARTOFRANGE chdirg -->
-<p><a
name="index-_0040code_007bchdir_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2011"></a><!--
STARTOFRANGE statg -->
-<a
name="index-_0040code_007bstat_007d-function_0040comma_007b_007d-implementing-in-_0040command_007bgawk_007d-2012"></a><!--
STARTOFRANGE filre -->
-<a
name="index-files_002c-information-about_0040comma_007b_007d-retrieving-2013"></a><!--
STARTOFRANGE dirch -->
-<a name="index-directories_002c-changing-2014"></a>
-Two useful functions that are not in <samp><span
class="command">awk</span></samp> are <code>chdir</code>
-(so that an <samp><span class="command">awk</span></samp> program can change
its directory) and
-<code>stat</code> (so that an <samp><span class="command">awk</span></samp>
program can gather information about
-a file).
-This section implements these functions for <samp><span
class="command">gawk</span></samp> in an
-external extension library.
-
-<ul class="menu">
-<li><a accesskey="1"
href="Internal-File-Description.html#Internal-File-Description">Internal File
Description</a>: What the new functions will do.
-<li><a accesskey="2" href="Internal-File-Ops.html#Internal-File-Ops">Internal
File Ops</a>: The code for internal file operations.
-<li><a accesskey="3"
href="Using-Internal-File-Ops.html#Using-Internal-File-Ops">Using Internal File
Ops</a>: How to use an external extension.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Sample-Programs.html
===================================================================
RCS file: manual/html_node/Sample-Programs.html
diff -N manual/html_node/Sample-Programs.html
--- manual/html_node/Sample-Programs.html 31 Aug 2004 22:04:11 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,90 +0,0 @@
-<html lang="en">
-<head>
-<title>Sample Programs - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="prev" href="Library-Functions.html#Library-Functions"
title="Library Functions">
-<link rel="next" href="Language-History.html#Language-History" title="Language
History">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Sample-Programs"></a>Next: <a rel="next" accesskey="n"
href="Language-History.html#Language-History">Language History</a>,
-Previous: <a rel="previous" accesskey="p"
href="Library-Functions.html#Library-Functions">Library Functions</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr><br>
-</div>
-
-<h2 class="chapter">13 Practical <samp><span class="command">awk</span></samp>
Programs</h2>
-
-<!-- STARTOFRANGE awkpex -->
-<p><a
name="index-_0040command_007bawk_007d-programs_002c-examples-of-1741"></a>
-<a href="Library-Functions.html#Library-Functions">Library Functions</a>,
-presents the idea that reading programs in a language contributes to
-learning that language. This chapter continues that theme,
-presenting a potpourri of <samp><span class="command">awk</span></samp>
programs for your reading
-enjoyment.
-There are three sections.
-The first describes how to run the programs presented
-in this chapter.
-
- <p>The second presents <samp><span class="command">awk</span></samp>
-versions of several common POSIX utilities.
-These are programs that you are hopefully already familiar with,
-and therefore, whose problems are understood.
-By reimplementing these programs in <samp><span
class="command">awk</span></samp>,
-you can focus on the <samp><span class="command">awk</span></samp>-related
aspects of solving
-the programming problem.
-
- <p>The third is a grab bag of interesting programs.
-These solve a number of different data-manipulation and management
-problems. Many of the programs are short, which emphasizes <samp><span
class="command">awk</span></samp>'s
-ability to do a lot in just a few lines of code.
-
- <p>Many of these programs use the library functions presented in
-<a href="Library-Functions.html#Library-Functions">Library Functions</a>.
-
-<ul class="menu">
-<li><a accesskey="1" href="Running-Examples.html#Running-Examples">Running
Examples</a>: How to run these examples.
-<li><a accesskey="2" href="Clones.html#Clones">Clones</a>:
Clones of common utilities.
-<li><a accesskey="3"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>: Some interesting <samp><span
class="command">awk</span></samp> programs.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Scalar-Constants.html
===================================================================
RCS file: manual/html_node/Scalar-Constants.html
diff -N manual/html_node/Scalar-Constants.html
--- manual/html_node/Scalar-Constants.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,86 +0,0 @@
-<html lang="en">
-<head>
-<title>Scalar Constants - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Constants.html#Constants" title="Constants">
-<link rel="next" href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers"
title="Nondecimal-numbers">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Scalar-Constants"></a>Next: <a rel="next" accesskey="n"
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>,
-Up: <a rel="up" accesskey="u"
href="Constants.html#Constants">Constants</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">5.1.1 Numeric and String Constants</h4>
-
-<p><a name="index-numeric_002c-constants-606"></a>A <dfn>numeric
constant</dfn> stands for a number. This number can be an
-integer, a decimal fraction, or a number in scientific (exponential)
-notation.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-Here are some examples of numeric constants that all
-have the same value:
-
-<pre class="example"> 105
- 1.05e+2
- 1050e-1
-</pre>
- <p><a name="index-string-constants-607"></a>A string constant consists of a
sequence of characters enclosed in
-double-quotation marks. For example:
-
-<pre class="example"> "parrot"
-</pre>
- <p class="noindent"><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-strings-608"></a><a
name="index-strings_002c-length-of-609"></a>represents the string whose
contents are `<samp><span class="samp">parrot</span></samp>'. Strings in
-<samp><span class="command">gawk</span></samp> can be of any length, and they
can contain any of the possible
-eight-bit ASCII characters including ASCII <span class="sc">nul</span>
(character code zero).
-Other <samp><span class="command">awk</span></samp>
-implementations may have difficulty with some character codes.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The internal representation of all numbers,
-including integers, uses double-precision
-floating-point numbers.
-On most modern systems, these are in IEEE 754 standard format.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Scanning-an-Array.html
===================================================================
RCS file: manual/html_node/Scanning-an-Array.html
diff -N manual/html_node/Scanning-an-Array.html
--- manual/html_node/Scanning-an-Array.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,111 +0,0 @@
-<html lang="en">
-<head>
-<title>Scanning an Array - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Array-Example.html#Array-Example" title="Array Example">
-<link rel="next" href="Delete.html#Delete" title="Delete">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Scanning-an-Array"></a>Next: <a rel="next" accesskey="n"
href="Delete.html#Delete">Delete</a>,
-Previous: <a rel="previous" accesskey="p"
href="Array-Example.html#Array-Example">Array Example</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.5 Scanning All Elements of an Array</h3>
-
-<p><a name="index-elements-in-arrays_002c-scanning-1096"></a><a
name="index-arrays_002c-scanning-1097"></a>
-In programs that use arrays, it is often necessary to use a loop that
-executes once for each element of an array. In other languages, where
-arrays are contiguous and indices are limited to positive integers,
-this is easy: all the valid indices can be found by counting from
-the lowest index up to the highest. This technique won't do the job
-in <samp><span class="command">awk</span></samp>, because any number or string
can be an array index.
-So <samp><span class="command">awk</span></samp> has a special kind of
<code>for</code> statement for scanning
-an array:
-
-<pre class="example"> for (<var>var</var> in <var>array</var>)
- <var>body</var>
-</pre>
- <p class="noindent"><a
name="index-_0040code_007bin_007d-operator_002c-arrays-and-1098"></a>This loop
executes <var>body</var> once for each index in <var>array</var> that the
-program has previously used, with the variable <var>var</var> set to that
index.
-
- <p><a
name="index-arrays_002c-_0040code_007bfor_007d-statement-and-1099"></a><a
name="index-_0040code_007bfor_007d-statement_002c-in-arrays-1100"></a>The
following program uses this form of the <code>for</code> statement. The
-first rule scans the input records and notes which words appear (at
-least once) in the input, by storing a one into the array <code>used</code>
with
-the word as index. The second rule scans the elements of <code>used</code> to
-find all the distinct words that appear in the input. It prints each
-word that is more than 10 characters long and also prints the number of
-such words.
-See <a href="String-Functions.html#String-Functions">String Functions</a>,
-for more information on the built-in function <code>length</code>.
-
-<pre class="example"> # Record a 1 for each word that is used at least once
- {
- for (i = 1; i <= NF; i++)
- used[$i] = 1
- }
-
- # Find number of distinct words more than 10 characters long
- END {
- for (x in used)
- if (length(x) > 10) {
- ++num_long_words
- print x
- }
- print num_long_words, "words longer than 10 characters"
- }
-</pre>
- <p class="noindent">See <a href="Word-Sorting.html#Word-Sorting">Word
Sorting</a>,
-for a more detailed example of this type.
-
- <p><a name="index-arrays_002c-elements_002c-order-of-1101"></a><a
name="index-elements-in-arrays_002c-order-of-1102"></a>The order in which
elements of the array are accessed by this statement
-is determined by the internal arrangement of the array elements within
-<samp><span class="command">awk</span></samp> and cannot be controlled or
changed. This can lead to
-problems if new elements are added to <var>array</var> by statements in
-the loop body; it is not predictable whether the <code>for</code> loop will
-reach them. Similarly, changing <var>var</var> inside the loop may produce
-strange results. It is best to avoid such things.
-
- </body></html>
-
Index: manual/html_node/Simple-Sed.html
===================================================================
RCS file: manual/html_node/Simple-Sed.html
diff -N manual/html_node/Simple-Sed.html
--- manual/html_node/Simple-Sed.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,142 +0,0 @@
-<html lang="en">
-<head>
-<title>Simple Sed - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Extract-Program.html#Extract-Program" title="Extract
Program">
-<link rel="next" href="Igawk-Program.html#Igawk-Program" title="Igawk Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Simple-Sed"></a>Next: <a rel="next" accesskey="n"
href="Igawk-Program.html#Igawk-Program">Igawk Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Extract-Program.html#Extract-Program">Extract Program</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.8 A Simple Stream Editor</h4>
-
-<p><a name="index-_0040command_007bsed_007d-utility-1813"></a><a
name="index-stream-editors-1814"></a>The <samp><span
class="command">sed</span></samp> utility is a stream editor, a program that
reads a
-stream of data, makes changes to it, and passes it on.
-It is often used to make global changes to a large file or to a stream
-of data generated by a pipeline of commands.
-While <samp><span class="command">sed</span></samp> is a complicated program
in its own right, its most common
-use is to perform global substitutions in the middle of a pipeline:
-
-<pre class="example"> command1 < orig.data | sed 's/old/new/g' |
command2 > result
-</pre>
- <p>Here, `<samp><span class="samp">s/old/new/g</span></samp>' tells
<samp><span class="command">sed</span></samp> to look for the regexp
-`<samp><span class="samp">old</span></samp>' on each input line and globally
replace it with the text
-`<samp><span class="samp">new</span></samp>', i.e., all the occurrences on a
line. This is similar to
-<samp><span class="command">awk</span></samp>'s <code>gsub</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <p>The following program, <samp><span
class="file">awksed.awk</span></samp>, accepts at least two command-line
-arguments: the pattern to look for and the text to replace it with. Any
-additional arguments are treated as data file names to process. If none
-are provided, the standard input is used:
-
- <p><a name="index-Brennan_002c-Michael-1815"></a><a
name="index-_0040command_007bawksed_002eawk_007d-program-1816"></a><!-- @cindex
simple stream editor -->
-<!-- @cindex stream editor, simple -->
-<pre class="example"> <!-- file eg/prog/awksed.awk -->
- # awksed.awk --- do s/foo/bar/g using just print
- # Thanks to Michael Brennan for the idea
- <!-- endfile -->
- <!-- file eg/prog/awksed.awk -->
- function usage()
- {
- print "usage: awksed pat repl [files...]" > "/dev/stderr"
- exit 1
- }
-
- BEGIN {
- # validate arguments
- if (ARGC < 3)
- usage()
-
- RS = ARGV[1]
- ORS = ARGV[2]
-
- # don't use arguments as files
- ARGV[1] = ARGV[2] = ""
- }
-
- # look ma, no hands!
- {
- if (RT == "")
- printf "%s", $0
- else
- print
- }
- <!-- endfile -->
-</pre>
- <p>The program relies on <samp><span class="command">gawk</span></samp>'s
ability to have <code>RS</code> be a regexp,
-as well as on the setting of <code>RT</code> to the actual text that
terminates the
-record (see <a href="Records.html#Records">Records</a>).
-
- <p>The idea is to have <code>RS</code> be the pattern to look for.
<samp><span class="command">gawk</span></samp>
-automatically sets <code>$0</code> to the text between matches of the pattern.
-This is text that we want to keep, unmodified. Then, by setting
<code>ORS</code>
-to the replacement text, a simple <code>print</code> statement outputs the
-text we want to keep, followed by the replacement text.
-
- <p>There is one wrinkle to this scheme, which is what to do if the last
record
-doesn't end with text that matches <code>RS</code>. Using a <code>print</code>
-statement unconditionally prints the replacement text, which is not correct.
-However, if the file did not end in text that matches <code>RS</code>,
<code>RT</code>
-is set to the null string. In this case, we can print <code>$0</code> using
-<code>printf</code>
-(see <a href="Printf.html#Printf">Printf</a>).
-
- <p>The <code>BEGIN</code> rule handles the setup, checking for the right
number
-of arguments and calling <code>usage</code> if there is a problem. Then it sets
-<code>RS</code> and <code>ORS</code> from the command-line arguments and sets
-<code>ARGV[1]</code> and <code>ARGV[2]</code> to the null string, so that they
are
-not treated as file names
-(see <a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a>).
-
- <p>The <code>usage</code> function prints an error message and exits.
-Finally, the single rule handles the printing scheme outlined above,
-using <code>print</code> or <code>printf</code> as appropriate, depending upon
the
-value of <code>RT</code>.
-
- </body></html>
-
Index: manual/html_node/Single-Character-Fields.html
===================================================================
RCS file: manual/html_node/Single-Character-Fields.html
diff -N manual/html_node/Single-Character-Fields.html
--- manual/html_node/Single-Character-Fields.html 31 Aug 2004 22:04:12
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,82 +0,0 @@
-<html lang="en">
-<head>
-<title>Single Character Fields - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Field-Separators.html#Field-Separators" title="Field
Separators">
-<link rel="prev" href="Regexp-Field-Splitting.html#Regexp-Field-Splitting"
title="Regexp Field Splitting">
-<link rel="next"
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator"
title="Command Line Field Separator">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Single-Character-Fields"></a>Next: <a rel="next" accesskey="n"
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a>,
-Previous: <a rel="previous" accesskey="p"
href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a>,
-Up: <a rel="up" accesskey="u"
href="Field-Separators.html#Field-Separators">Field Separators</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">3.5.2 Making Each Character a Separate Field</h4>
-
-<p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-single_002dcharacter-fields-418"></a><a
name="index-single_002dcharacter-fields-419"></a><a
name="index-fields_002c-single_002dcharacter-420"></a>There are times when you
may want to examine each character
-of a record separately. This can be done in <samp><span
class="command">gawk</span></samp> by
-simply assigning the null string (<code>""</code>) to <code>FS</code>. In this
case,
-each individual character in the record becomes a separate field.
-For example:
-
-<pre class="example"> $ echo a b | gawk 'BEGIN { FS = "" }
- > {
- > for (i = 1; i <= NF; i = i + 1)
- > print "Field", i, "is", $i
- > }'
- -| Field 1 is a
- -| Field 2 is
- -| Field 3 is b
-</pre>
- <p><a
name="index-dark-corner_002c-_0040code_007bFS_007d-as-null-string-421"></a><a
name="index-FS-variable_002c-as-null-string-422"></a>Traditionally, the
behavior of <code>FS</code> equal to <code>""</code> was not defined.
-In this case, most versions of Unix <samp><span
class="command">awk</span></samp> simply treat the entire record
-as only having one field.
-(d.c.)
-In compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-if <code>FS</code> is the null string, then <samp><span
class="command">gawk</span></samp> also
-behaves this way.
-
- </body></html>
-
Index: manual/html_node/Special-Caveats.html
===================================================================
RCS file: manual/html_node/Special-Caveats.html
diff -N manual/html_node/Special-Caveats.html
--- manual/html_node/Special-Caveats.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,100 +0,0 @@
-<html lang="en">
-<head>
-<title>Special Caveats - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Special-Files.html#Special-Files" title="Special Files">
-<link rel="prev" href="Special-Network.html#Special-Network" title="Special
Network">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Special-Caveats"></a>Previous: <a rel="previous" accesskey="p"
href="Special-Network.html#Special-Network">Special Network</a>,
-Up: <a rel="up" accesskey="u"
href="Special-Files.html#Special-Files">Special Files</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.7.4 Special File Name Caveats</h4>
-
-<p>Here is a list of things to bear in mind when using the
-special file names that <samp><span class="command">gawk</span></samp>
provides:
-
-
-<a
name="index-compatibility-mode-_0028_0040command_007bgawk_007d_0029_002c-_0040value_007bFN_007ds-585"></a>
-<a name="index-_0040value_007bFN_007ds_002c-in-compatibility-mode-586"></a>
-<ul><li>Recognition of these special file names is disabled if <samp><span
class="command">gawk</span></samp> is in
-compatibility mode (see <a href="Options.html#Options">Options</a>).
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a name="index-_0040code_007bPROCINFO_007d-array-587"></a><li>The
-As mentioned earlier, the
-special files that provide process-related information are now considered
-obsolete and will disappear entirely
-in the next release of <samp><span class="command">gawk</span></samp>.
-<samp><span class="command">gawk</span></samp> prints a warning message every
time you use one of
-these files.
-To obtain process-related information, use the <code>PROCINFO</code> array.
-See <a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>.
-
- <li>Starting with version 3.1, <samp><span
class="command">gawk</span></samp> <em>always</em>
-interprets these special file names.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-For example, using `<samp><span class="samp">/dev/fd/4</span></samp>'
-for output actually writes on file descriptor 4, and not on a new
-file descriptor that is <code>dup</code>'ed from file descriptor 4. Most of
-the time this does not matter; however, it is important to <em>not</em>
-close any of the files related to file descriptors 0, 1, and 2.
-Doing so results in unpredictable behavior.
-</ul>
- <!-- ENDOFRANGE gfn -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Older versions of
-<samp><span class="command">gawk</span></samp> would interpret these names
internally only if the system
-did not actually have a <samp><span class="file">/dev/fd</span></samp>
directory or any of the other
-special files listed earlier. Usually this didn't make a difference,
-but sometimes it did; thus, it was decided to make <samp><span
class="command">gawk</span></samp>'s
-behavior consistent on all systems and to have it always interpret
-the special file names itself.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Special-FD.html
===================================================================
RCS file: manual/html_node/Special-FD.html
diff -N manual/html_node/Special-FD.html
--- manual/html_node/Special-FD.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,125 +0,0 @@
-<html lang="en">
-<head>
-<title>Special FD - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Special-Files.html#Special-Files" title="Special Files">
-<link rel="next" href="Special-Process.html#Special-Process" title="Special
Process">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Special-FD"></a>Next: <a rel="next" accesskey="n"
href="Special-Process.html#Special-Process">Special Process</a>,
-Up: <a rel="up" accesskey="u"
href="Special-Files.html#Special-Files">Special Files</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.7.1 Special Files for Standard Descriptors</h4>
-
-<p><a name="index-standard-input-568"></a><a
name="index-input_002c-standard-569"></a><a
name="index-standard-output-570"></a><a
name="index-output_002c-standard-571"></a><a
name="index-error-output-572"></a><a name="index-file-descriptors-573"></a><a
name="index-files_002c-descriptors_002c-See-file-descriptors-574"></a>
-Running programs conventionally have three input and output streams
-already available to them for reading and writing. These are known as
-the <dfn>standard input</dfn>, <dfn>standard output</dfn>, and <dfn>standard
error
-output</dfn>. These streams are, by default, connected to your terminal, but
-they are often redirected with the shell, via the `<samp><span
class="samp"><</span></samp>', `<samp><span
class="samp"><<</span></samp>',
-`<samp><span class="samp">></span></samp>', `<samp><span
class="samp">>></span></samp>', `<samp><span
class="samp">>&</span></samp>', and `<samp><span
class="samp">|</span></samp>' operators. Standard error
-is typically used for writing error messages; the reason there are two separate
-streams, standard output and standard error, is so that they can be
-redirected separately.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-error-messages-575"></a><a
name="index-error-handling-576"></a>In other implementations of <samp><span
class="command">awk</span></samp>, the only way to write an error
-message to standard error in an <samp><span class="command">awk</span></samp>
program is as follows:
-
-<pre class="example"> print "Serious error detected!" | "cat 1>&2"
-</pre>
- <p class="noindent">This works by opening a pipeline to a shell command
that can access the
-standard error stream that it inherits from the <samp><span
class="command">awk</span></samp> process.
-This is far from elegant, and it is also inefficient, because it requires a
-separate process. So people writing <samp><span
class="command">awk</span></samp> programs often
-don't do this. Instead, they send the error messages to the
-terminal, like this:
-
-<pre class="example"> print "Serious error detected!" > "/dev/tty"
-</pre>
- <p class="noindent">This usually has the same effect but not always:
although the
-standard error stream is usually the terminal, it can be redirected; when
-that happens, writing to the terminal is not correct. In fact, if
-<samp><span class="command">awk</span></samp> is run from a background job, it
may not have a terminal at all.
-Then opening <samp><span class="file">/dev/tty</span></samp> fails.
-
- <p><samp><span class="command">gawk</span></samp> provides special file
names for accessing the three standard
-streams, as well as any other inherited open files. If the file name matches
-one of these special names when <samp><span class="command">gawk</span></samp>
redirects input or output,
-then it directly uses the stream that the file name stands for.
-These special file names work for all operating systems that <samp><span
class="command">gawk</span></samp>
-has been ported to, not just those that are POSIX-compliant:
-
- <p><a
name="index-_0040value_007bFN_007ds_002c-standard-streams-in-_0040command_007bgawk_007d-577"></a><a
name="index-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-_0028_0040command_007bgawk_007d_0029-578"></a><a
name="index-files_002c-_0040code_007b_002fdev_002f_0040dots_007b_007d_007d-special-files-579"></a><!--
@cindex @code{/dev/stdin} special file -->
-<!-- @cindex @code{/dev/stdout} special file -->
-<!-- @cindex @code{/dev/stderr} special file -->
-<!-- @cindex @code{/dev/fd} special files -->
- <dl>
-<dt><samp><span class="file">/dev/stdin</span></samp><dd>The standard input
(file descriptor 0).
-
- <br><dt><samp><span class="file">/dev/stdout</span></samp><dd>The
standard output (file descriptor 1).
-
- <br><dt><samp><span class="file">/dev/stderr</span></samp><dd>The
standard error output (file descriptor 2).
-
- <br><dt><samp><span
class="file">/dev/fd/</span><var>N</var></samp><dd>The file associated with
file descriptor <var>N</var>. Such a file must
-be opened by the program initiating the <samp><span
class="command">awk</span></samp> execution (typically
-the shell). Unless special pains are taken in the shell from which
-<samp><span class="command">gawk</span></samp> is invoked, only descriptors 0,
1, and 2 are available.
-</dl>
-
- <p>The file names <samp><span class="file">/dev/stdin</span></samp>,
<samp><span class="file">/dev/stdout</span></samp>, and <samp><span
class="file">/dev/stderr</span></samp>
-are aliases for <samp><span class="file">/dev/fd/0</span></samp>, <samp><span
class="file">/dev/fd/1</span></samp>, and <samp><span
class="file">/dev/fd/2</span></samp>,
-respectively. However, they are more self-explanatory.
-The proper way to write an error message in a <samp><span
class="command">gawk</span></samp> program
-is to use <samp><span class="file">/dev/stderr</span></samp>, like this:
-
-<pre class="example"> print "Serious error detected!" > "/dev/stderr"
-</pre>
- <p><a
name="index-troubleshooting_002c-quotes-with-_0040value_007bFN_007ds-580"></a>Note
the use of quotes around the file name.
-Like any other redirection, the value must be a string.
-It is a common error to omit the quotes, which leads
-to confusing results.
-<!-- Exercise: What does it do? :-) -->
-
- </body></html>
-
Index: manual/html_node/Special-Files.html
===================================================================
RCS file: manual/html_node/Special-Files.html
diff -N manual/html_node/Special-Files.html
--- manual/html_node/Special-Files.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,71 +0,0 @@
-<html lang="en">
-<head>
-<title>Special Files - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Printing.html#Printing" title="Printing">
-<link rel="prev" href="Redirection.html#Redirection" title="Redirection">
-<link rel="next" href="Close-Files-And-Pipes.html#Close-Files-And-Pipes"
title="Close Files And Pipes">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Special-Files"></a>Next: <a rel="next" accesskey="n"
href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>,
-Previous: <a rel="previous" accesskey="p"
href="Redirection.html#Redirection">Redirection</a>,
-Up: <a rel="up" accesskey="u" href="Printing.html#Printing">Printing</a>
-<hr><br>
-</div>
-
-<h3 class="section">4.7 Special File Names in <samp><span
class="command">gawk</span></samp></h3>
-
-<!-- STARTOFRANGE gfn -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-_0040value_007bFN_007ds-in-567"></a>
-<samp><span class="command">gawk</span></samp> provides a number of special
file names that it interprets
-internally. These file names provide access to standard file descriptors,
-process-related information, and TCP/IP networking.
-
-<ul class="menu">
-<li><a accesskey="1" href="Special-FD.html#Special-FD">Special FD</a>:
Special files for I/O.
-<li><a accesskey="2" href="Special-Process.html#Special-Process">Special
Process</a>: Special files for process information.
-<li><a accesskey="3" href="Special-Network.html#Special-Network">Special
Network</a>: Special files for network communications.
-<li><a accesskey="4" href="Special-Caveats.html#Special-Caveats">Special
Caveats</a>: Things to watch out for.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Special-Network.html
===================================================================
RCS file: manual/html_node/Special-Network.html
diff -N manual/html_node/Special-Network.html
--- manual/html_node/Special-Network.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-<html lang="en">
-<head>
-<title>Special Network - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Special-Files.html#Special-Files" title="Special Files">
-<link rel="prev" href="Special-Process.html#Special-Process" title="Special
Process">
-<link rel="next" href="Special-Caveats.html#Special-Caveats" title="Special
Caveats">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Special-Network"></a>Next: <a rel="next" accesskey="n"
href="Special-Caveats.html#Special-Caveats">Special Caveats</a>,
-Previous: <a rel="previous" accesskey="p"
href="Special-Process.html#Special-Process">Special Process</a>,
-Up: <a rel="up" accesskey="u"
href="Special-Files.html#Special-Files">Special Files</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.7.3 Special Files for Network Communications</h4>
-
-<p><a name="index-networks_002c-support-for-583"></a><a
name="index-TCP_002fIP_002c-support-for-584"></a>
-Starting with version 3.1 of <samp><span class="command">gawk</span></samp>,
<samp><span class="command">awk</span></samp> programs
-can open a two-way
-TCP/IP connection, acting as either a client or a server.
-This is done using a special file name of the form:
-
-<pre class="example"> <samp><span
class="file">/inet/</span><var>protocol</var><span
class="file">/</span><var>local-port</var><span
class="file">/</span><var>remote-host</var><span
class="file">/</span><var>remote-port</var></samp>
-</pre>
- <p>The <var>protocol</var> is one of `<samp><span
class="samp">tcp</span></samp>', `<samp><span class="samp">udp</span></samp>',
or `<samp><span class="samp">raw</span></samp>',
-and the other fields represent the other essential pieces of information
-for making a networking connection.
-These file names are used with the `<samp><span
class="samp">|&</span></samp>' operator for communicating
-with a coprocess
-(see <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>).
-This is an advanced feature, mentioned here only for completeness.
-Full discussion is delayed until
-<a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a>.
-
- </body></html>
-
Index: manual/html_node/Special-Process.html
===================================================================
RCS file: manual/html_node/Special-Process.html
diff -N manual/html_node/Special-Process.html
--- manual/html_node/Special-Process.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,118 +0,0 @@
-<html lang="en">
-<head>
-<title>Special Process - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Special-Files.html#Special-Files" title="Special Files">
-<link rel="prev" href="Special-FD.html#Special-FD" title="Special FD">
-<link rel="next" href="Special-Network.html#Special-Network" title="Special
Network">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Special-Process"></a>Next: <a rel="next" accesskey="n"
href="Special-Network.html#Special-Network">Special Network</a>,
-Previous: <a rel="previous" accesskey="p"
href="Special-FD.html#Special-FD">Special FD</a>,
-Up: <a rel="up" accesskey="u"
href="Special-Files.html#Special-Files">Special Files</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">4.7.2 Special Files for Process-Related Information</h4>
-
-<p><a name="index-files_002c-for-process-information-581"></a><a
name="index-process-information_002c-files-for-582"></a><samp><span
class="command">gawk</span></samp> also provides special file names that give
access to information
-about the running <samp><span class="command">gawk</span></samp> process.
Each of these “files” provides
-a single record of information. To read them more than once, they must
-first be closed with the <code>close</code> function
-(see <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files
And Pipes</a>).
-The file names are:
-
-<!-- @cindex @code{/dev/pid} special file -->
-<!-- @cindex @code{/dev/pgrpid} special file -->
-<!-- @cindex @code{/dev/ppid} special file -->
-<!-- @cindex @code{/dev/user} special file -->
-<dl>
-<dt><samp><span class="file">/dev/pid</span></samp><dd>Reading this file
returns the process ID of the current process,
-in decimal form, terminated with a newline.
-
- <br><dt><samp><span class="file">/dev/ppid</span></samp><dd>Reading this
file returns the parent process ID of the current process,
-in decimal form, terminated with a newline.
-
- <br><dt><samp><span class="file">/dev/pgrpid</span></samp><dd>Reading
this file returns the process group ID of the current process,
-in decimal form, terminated with a newline.
-
- <br><dt><samp><span class="file">/dev/user</span></samp><dd>Reading this
file returns a single record terminated with a newline.
-The fields are separated with spaces. The fields represent the
-following information:
-
- <dl>
-<dt><code>$1</code><dd>The return value of the <code>getuid</code> system call
-(the real user ID number).
-
- <br><dt><code>$2</code><dd>The return value of the
<code>geteuid</code> system call
-(the effective user ID number).
-
- <br><dt><code>$3</code><dd>The return value of the
<code>getgid</code> system call
-(the real group ID number).
-
- <br><dt><code>$4</code><dd>The return value of the
<code>getegid</code> system call
-(the effective group ID number).
-</dl>
-
- <p>If there are any additional fields, they are the group IDs returned by
-the <code>getgroups</code> system call.
-(Multiple groups may not be supported on all systems.)
-</dl>
-
- <p>These special file names may be used on the command line as data files,
-as well as for I/O redirections within an <samp><span
class="command">awk</span></samp> program.
-They may not be used as source files with the <samp><span
class="option">-f</span></samp> option.
-
-<!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<blockquote>
-<b>NOTE:</b> The special files that provide process-related information are
now considered
-obsolete and will disappear entirely
-in the next release of <samp><span class="command">gawk</span></samp>.
-<samp><span class="command">gawk</span></samp> prints a warning message every
time you use one of
-these files.
-To obtain process-related information, use the <code>PROCINFO</code> array.
-See <a href="Auto_002dset.html#Auto_002dset">Auto-set</a>.
-</blockquote>
-
- </body></html>
-
Index: manual/html_node/Split-Program.html
===================================================================
RCS file: manual/html_node/Split-Program.html
diff -N manual/html_node/Split-Program.html
--- manual/html_node/Split-Program.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,172 +0,0 @@
-<html lang="en">
-<head>
-<title>Split Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="prev" href="Id-Program.html#Id-Program" title="Id Program">
-<link rel="next" href="Tee-Program.html#Tee-Program" title="Tee Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Split-Program"></a>Next: <a rel="next" accesskey="n"
href="Tee-Program.html#Tee-Program">Tee Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Id-Program.html#Id-Program">Id Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.4 Splitting a Large File into Pieces</h4>
-
-<!-- STARTOFRANGE filspl -->
-<p><a name="index-files_002c-splitting-1767"></a><a
name="index-_0040code_007bsplit_007d-utility-1768"></a>The <code>split</code>
program splits large text files into smaller pieces.
-Usage is as follows:
-
-<pre class="example"> split <span
class="roman">[</span>-<var>count</var><span class="roman">]</span> file <span
class="roman">[</span> <var>prefix</var> <span class="roman">]</span>
-</pre>
- <p>By default,
-the output files are named <samp><span class="file">xaa</span></samp>,
<samp><span class="file">xab</span></samp>, and so on. Each file has
-1000 lines in it, with the likely exception of the last file. To change the
-number of lines in each file, supply a number on the command line
-preceded with a minus; e.g., `<samp><span class="samp">-500</span></samp>' for
files with 500 lines in them
-instead of 1000. To change the name of the output files to something like
-<samp><span class="file">myfileaa</span></samp>, <samp><span
class="file">myfileab</span></samp>, and so on, supply an additional
-argument that specifies the file name prefix.
-
- <p>Here is a version of <code>split</code> in <samp><span
class="command">awk</span></samp>. It uses the <code>ord</code> and
-<code>chr</code> functions presented in
-<a href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a>.
-
- <p>The program first sets its defaults, and then tests to make sure there
are
-not too many arguments. It then looks at each argument in turn. The
-first argument could be a minus sign followed by a number. If it is, this
happens
-to look like a negative number, so it is made positive, and that is the
-count of lines. The data file name is skipped over and the final argument
-is used as the prefix for the output file names:
-
- <p><a name="index-_0040code_007bsplit_002eawk_007d-program-1769"></a>
-<pre class="example"> <!-- file eg/prog/split.awk -->
- # split.awk --- do split in awk
- #
- # Requires ord and chr library functions
- <!-- endfile -->
- <!-- file eg/prog/split.awk -->
- # usage: split [-num] [file] [outname]
-
- BEGIN {
- outfile = "x" # default
- count = 1000
- if (ARGC > 4)
- usage()
-
- i = 1
- if (ARGV[i] ~ /^-[0-9]+$/) {
- count = -ARGV[i]
- ARGV[i] = ""
- i++
- }
- # test argv in case reading from stdin instead of file
- if (i in ARGV)
- i++ # skip data file name
- if (i in ARGV) {
- outfile = ARGV[i]
- ARGV[i] = ""
- }
-
- s1 = s2 = "a"
- out = (outfile s1 s2)
- }
- <!-- endfile -->
-</pre>
- <p>The next rule does most of the work. <code>tcount</code> (temporary
count) tracks
-how many lines have been printed to the output file so far. If it is greater
-than <code>count</code>, it is time to close the current file and start a new
one.
-<code>s1</code> and <code>s2</code> track the current suffixes for the file
name. If
-they are both `<samp><span class="samp">z</span></samp>', the file is just too
big. Otherwise, <code>s1</code>
-moves to the next letter in the alphabet and <code>s2</code> starts over again
at
-`<samp><span class="samp">a</span></samp>':
-
-<!-- else on separate line here for page breaking -->
-<pre class="example"> <!-- file eg/prog/split.awk -->
- {
- if (++tcount > count) {
- close(out)
- if (s2 == "z") {
- if (s1 == "z") {
- printf("split: %s is too large to split\n",
- FILENAME) > "/dev/stderr"
- exit 1
- }
- s1 = chr(ord(s1) + 1)
- s2 = "a"
- }
- else
- s2 = chr(ord(s2) + 1)
- out = (outfile s1 s2)
- tcount = 1
- }
- print > out
- }
- <!-- endfile -->
-</pre>
- <!-- Exercise: do this with just awk builtin functions, index("abc..."),
substr, etc. -->
-<p class="noindent">The <code>usage</code> function simply prints an error
message and exits:
-
-<pre class="example"> <!-- file eg/prog/split.awk -->
- function usage( e)
- {
- e = "usage: split [-num] [file] [outname]"
- print e > "/dev/stderr"
- exit 1
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">The variable <code>e</code> is used so that the function
-fits nicely on the
-page.
-
- <p>This program is a bit sloppy; it relies on <samp><span
class="command">awk</span></samp> to automatically close the last file
-instead of doing it in an <code>END</code> rule.
-It also assumes that letters are contiguous in the character set,
-which isn't true for EBCDIC systems.
-<!-- BFD... -->
-<!-- ENDOFRANGE filspl -->
-
- </body></html>
-
Index: manual/html_node/Statements.html
===================================================================
RCS file: manual/html_node/Statements.html
diff -N manual/html_node/Statements.html
--- manual/html_node/Statements.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,93 +0,0 @@
-<html lang="en">
-<head>
-<title>Statements - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link rel="prev" href="Action-Overview.html#Action-Overview" title="Action
Overview">
-<link rel="next" href="Built_002din-Variables.html#Built_002din-Variables"
title="Built-in Variables">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Statements"></a>Next: <a rel="next" accesskey="n"
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>,
-Previous: <a rel="previous" accesskey="p"
href="Action-Overview.html#Action-Overview">Action Overview</a>,
-Up: <a rel="up" accesskey="u"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>
-<hr><br>
-</div>
-
-<h3 class="section">6.4 Control Statements in Actions</h3>
-
-<!-- STARTOFRANGE csta -->
-<p><a name="index-control-statements-939"></a><!-- STARTOFRANGE acs -->
-<a name="index-statements_002c-control_002c-in-actions-940"></a><!--
STARTOFRANGE accs -->
-<a name="index-actions_002c-control-statements-in-941"></a>
-<dfn>Control statements</dfn>, such as <code>if</code>, <code>while</code>,
and so on,
-control the flow of execution in <samp><span class="command">awk</span></samp>
programs. Most of the
-control statements in <samp><span class="command">awk</span></samp> are
patterned on similar statements in C.
-
- <p><a
name="index-compound-statements_0040comma_007b_007d-control-statements-and-942"></a><a
name="index-statements_002c-compound_0040comma_007b_007d-control-statements-and-943"></a><a
name="index-body_002c-in-actions-944"></a><a
name="index-_0040code_007b_0040_007b_0040_007d_007d-_0028braces_0029_002c-statements_002c-grouping-945"></a><a
name="index-braces-_0028_0040code_007b_0040_007b_0040_007d_007d_0029_002c-statements_002c-grouping-946"></a><a
name="index-newlines_002c-separating-statements-in-actions-947"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029_002c-separating-statements-in-actions-948"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029_002c-separating-statements-in-actions-949"></a>All
the control statements start with special keywords, such as <code>if</code>
-and <code>while</code>, to distinguish them from simple expressions.
-Many control statements contain other statements. For example, the
-<code>if</code> statement contains another statement that may or may not be
-executed. The contained statement is called the <dfn>body</dfn>.
-To include more than one statement in the body, group them into a
-single <dfn>compound statement</dfn> with curly braces, separating them with
-newlines or semicolons.
-
-<ul class="menu">
-<li><a accesskey="1" href="If-Statement.html#If-Statement">If Statement</a>:
Conditionally execute some <samp><span
class="command">awk</span></samp>
- statements.
-<li><a accesskey="2" href="While-Statement.html#While-Statement">While
Statement</a>: Loop until some condition is satisfied.
-<li><a accesskey="3" href="Do-Statement.html#Do-Statement">Do Statement</a>:
Do specified action while looping until some
- condition is satisfied.
-<li><a accesskey="4" href="For-Statement.html#For-Statement">For
Statement</a>: Another looping statement, that provides
- initialization and increment clauses.
-<li><a accesskey="5" href="Switch-Statement.html#Switch-Statement">Switch
Statement</a>: Switch/case evaluation for conditional
- execution of statements based on a value.
-<li><a accesskey="6" href="Break-Statement.html#Break-Statement">Break
Statement</a>: Immediately exit the innermost enclosing loop.
-<li><a accesskey="7"
href="Continue-Statement.html#Continue-Statement">Continue Statement</a>:
Skip to the end of the innermost enclosing
- loop.
-<li><a accesskey="8" href="Next-Statement.html#Next-Statement">Next
Statement</a>: Stop processing the current input record.
-<li><a accesskey="9"
href="Nextfile-Statement.html#Nextfile-Statement">Nextfile Statement</a>:
Stop processing the current file.
-<li><a href="Exit-Statement.html#Exit-Statement">Exit Statement</a>:
Stop execution of <samp><span class="command">awk</span></samp>.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Statements_002fLines.html
===================================================================
RCS file: manual/html_node/Statements_002fLines.html
diff -N manual/html_node/Statements_002fLines.html
--- manual/html_node/Statements_002fLines.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,172 +0,0 @@
-<html lang="en">
-<head>
-<title>Statements/Lines - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="More-Complex.html#More-Complex" title="More Complex">
-<link rel="next" href="Other-Features.html#Other-Features" title="Other
Features">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Statements_002fLines"></a>Next: <a rel="next" accesskey="n"
href="Other-Features.html#Other-Features">Other Features</a>,
-Previous: <a rel="previous" accesskey="p"
href="More-Complex.html#More-Complex">More Complex</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.6 <samp><span class="command">awk</span></samp>
Statements Versus Lines</h3>
-
-<p><a name="index-line-breaks-150"></a><a name="index-newlines-151"></a>
-Most often, each line in an <samp><span class="command">awk</span></samp>
program is a separate statement or
-separate rule, like this:
-
-<pre class="example"> awk '/12/ { print $0 }
- /21/ { print $0 }' BBS-list inventory-shipped
-</pre>
- <p><a
name="index-_0040command_007bgawk_007d_002c-newlines-in-152"></a>However,
<samp><span class="command">gawk</span></samp> ignores newlines after any of
the following
-symbols and keywords:
-
-<pre class="example"> , { ? : || && do else
-</pre>
- <p class="noindent">A newline at any other point is considered the end of
the
-statement.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and-153"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and-154"></a>If
you would like to split a single statement into two lines at a point
-where a newline would terminate it, you can <dfn>continue</dfn> it by ending
the
-first line with a backslash character (`<samp><span
class="samp">\</span></samp>'). The backslash must be
-the final character on the line in order to be recognized as a continuation
-character. A backslash is allowed anywhere in the statement, even
-in the middle of a string or regular expression. For example:
-
-<pre class="example"> awk '/This regular expression is too long, so
continue it\
- on the next line/ { print $1 }'
-</pre>
- <p class="noindent"><a
name="index-portability_002c-backslash-continuation-and-155"></a>We have
generally not used backslash continuation in the sample programs
-in this Web page. In <samp><span class="command">gawk</span></samp>, there is
no limit on the
-length of a line, so backslash continuation is never strictly necessary;
-it just makes programs more readable. For this same reason, as well as
-for clarity, we have kept most statements short in the sample programs
-presented throughout the Web page. Backslash continuation is
-most useful when your <samp><span class="command">awk</span></samp> program is
in a separate source file
-instead of entered from the command line. You should also note that
-many <samp><span class="command">awk</span></samp> implementations are more
particular about where you
-may use backslash continuation. For example, they may not allow you to
-split a string constant using backslash continuation. Thus, for maximum
-portability of your <samp><span class="command">awk</span></samp> programs, it
is best not to split your
-lines in the middle of a regular expression or a string.
-<!-- 10/2000: gawk, mawk, and current bell labs awk allow it, -->
-<!-- solaris 2.7 nawk does not. Solaris /usr/xpg4/bin/awk does though! sigh.
-->
-
- <p><a name="index-_0040command_007bcsh_007d-utility-156"></a><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-157"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-in-_0040command_007bcsh_007d-158"></a><strong>Caution:</strong>
<em>Backslash continuation does not work as described
-with the C shell.</em> It works for <samp><span
class="command">awk</span></samp> programs in files and
-for one-shot programs, <em>provided</em> you are using a POSIX-compliant
-shell, such as the Unix Bourne shell or <samp><span
class="command">bash</span></samp>. But the C shell behaves
-differently! There, you must use two backslashes in a row, followed by
-a newline. Note also that when using the C shell, <em>every</em> newline
-in your awk program must be escaped with a backslash. To illustrate:
-
-<pre class="example"> % awk 'BEGIN { \
- ? print \\
- ? "hello, world" \
- ? }'
- -| hello, world
-</pre>
- <p class="noindent">Here, the `<samp><span class="samp">%</span></samp>'
and `<samp><span class="samp">?</span></samp>' are the C shell's primary and
secondary
-prompts, analogous to the standard shell's `<samp><span
class="samp">$</span></samp>' and `<samp><span class="samp">></span></samp>'.
-
- <p>Compare the previous example to how it is done with a POSIX-compliant
shell:
-
-<pre class="example"> $ awk 'BEGIN {
- > print \
- > "hello, world"
- > }'
- -| hello, world
-</pre>
- <p><samp><span class="command">awk</span></samp> is a line-oriented
language. Each rule's action has to
-begin on the same line as the pattern. To have the pattern and action
-on separate lines, you <em>must</em> use backslash continuation; there
-is no other option.
-
- <p><a
name="index-backslash-_0028_0040code_007b_005c_007d_0029_002c-continuing-lines-and_002c-comments-and-159"></a><a
name="index-_0040code_007b_005c_007d-_0028backslash_0029_002c-continuing-lines-and_002c-comments-and-160"></a><a
name="index-commenting_002c-backslash-continuation-and-161"></a>Another thing
to keep in mind is that backslash continuation and
-comments do not mix. As soon as <samp><span class="command">awk</span></samp>
sees the `<samp><span class="samp">#</span></samp>' that
-starts a comment, it ignores <em>everything</em> on the rest of the
-line. For example:
-
-<pre class="example"> $ gawk 'BEGIN { print "dont panic" # a friendly \
- > BEGIN rule
- > }'
- error--> gawk: cmd. line:2: BEGIN rule
- error--> gawk: cmd. line:2: ^ parse error
-</pre>
- <p class="noindent">In this case, it looks like the backslash would
continue the comment onto the
-next line. However, the backslash-newline combination is never even
-noticed because it is “hidden” inside the comment. Thus, the
-<code>BEGIN</code> is noted as a syntax error.
-
- <p><a name="index-statements_002c-multiple-162"></a><a
name="index-_0040code_007b_003b_007d-_0028semicolon_0029-163"></a><a
name="index-semicolon-_0028_0040code_007b_003b_007d_0029-164"></a>When
<samp><span class="command">awk</span></samp> statements within one rule are
short, you might want to put
-more than one of them on a line. This is accomplished by separating the
statements
-with a semicolon (`<samp><span class="samp">;</span></samp>').
-This also applies to the rules themselves.
-Thus, the program shown at the start of this section
-could also be written this way:
-
-<pre class="example"> /12/ { print $0 } ; /21/ { print $0 }
-</pre>
- <blockquote>
-<b>NOTE:</b> The requirement that states that rules on the same line must be
-separated with a semicolon was not in the original <samp><span
class="command">awk</span></samp>
-language; it was added for consistency with the treatment of statements
-within an action.
-</blockquote>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The `<samp><span class="samp">?</span></samp>' and
`<samp><span class="samp">:</span></samp>' referred to here is the
-three-operand conditional expression described in
-<a href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>.
-Splitting lines after `<samp><span class="samp">?</span></samp>' and
`<samp><span class="samp">:</span></samp>' is a minor <samp><span
class="command">gawk</span></samp>
-extension; if <samp><span class="option">--posix</span></samp> is specified
-(see <a href="Options.html#Options">Options</a>), then this extension is
disabled.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/String-Extraction.html
===================================================================
RCS file: manual/html_node/String-Extraction.html
diff -N manual/html_node/String-Extraction.html
--- manual/html_node/String-Extraction.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-<html lang="en">
-<head>
-<title>String Extraction - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Translator-i18n.html#Translator-i18n" title="Translator
i18n">
-<link rel="next" href="Printf-Ordering.html#Printf-Ordering" title="Printf
Ordering">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="String-Extraction"></a>Next: <a rel="next" accesskey="n"
href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a>,
-Up: <a rel="up" accesskey="u"
href="Translator-i18n.html#Translator-i18n">Translator i18n</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">9.4.1 Extracting Marked Strings</h4>
-
-<p><a name="index-strings_002c-extracting-1362"></a><a
name="index-marked-strings_0040comma_007b_007d-extracting-1363"></a><a
name="index-_0040code_007b_002d_002dgen_002dpo_007d-option-1364"></a><a
name="index-command_002dline-options_002c-string-extraction-1365"></a><a
name="index-string-extraction-_0028internationalization_0029-1366"></a><a
name="index-marked-string-extraction-_0028internationalization_0029-1367"></a><a
name="index-extraction_002c-of-marked-strings-_0028internationalization_0029-1368"></a>
-<a name="index-_0040code_007b_002d_002dgen_002dpo_007d-option-1369"></a>Once
your <samp><span class="command">awk</span></samp> program is working, and all
the strings have
-been marked and you've set (and perhaps bound) the text domain,
-it is time to produce translations.
-First, use the <samp><span class="option">--gen-po</span></samp> command-line
option to create
-the initial <samp><span class="file">.po</span></samp> file:
-
-<pre class="example"> $ gawk --gen-po -f guide.awk > guide.po
-</pre>
- <p><a name="index-_0040code_007bxgettext_007d-utility-1370"></a>When run
with <samp><span class="option">--gen-po</span></samp>, <samp><span
class="command">gawk</span></samp> does not execute your
-program. Instead, it parses it as usual and prints all marked strings
-to standard output in the format of a GNU <code>gettext</code> Portable Object
-file. Also included in the output are any constant strings that
-appear as the first argument to <code>dcgettext</code> or as the first and
-second argument to <code>dcngettext</code>.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-See <a href="I18N-Example.html#I18N-Example">I18N Example</a>,
-for the full list of steps to go through to create and test
-translations for <samp><span class="command">guide</span></samp>.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Starting with <code>gettext</code>
-version 0.11.5, the <samp><span class="command">xgettext</span></samp> utility
that comes with GNU
-<code>gettext</code> can handle <samp><span class="file">.awk</span></samp>
files.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/String-Functions.html
===================================================================
RCS file: manual/html_node/String-Functions.html
diff -N manual/html_node/String-Functions.html
--- manual/html_node/String-Functions.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,543 +0,0 @@
-<html lang="en">
-<head>
-<title>String Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="prev" href="Numeric-Functions.html#Numeric-Functions"
title="Numeric Functions">
-<link rel="next" href="I_002fO-Functions.html#I_002fO-Functions" title="I/O
Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="String-Functions"></a>Next: <a rel="next" accesskey="n"
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.3 String-Manipulation Functions</h4>
-
-<p>The functions in this section look at or change the text of one or more
-strings.
-Optional parameters are enclosed in square brackets ([ ]).<!-- /@w
-->
-Those functions that are
-specific to <samp><span class="command">gawk</span></samp> are marked with a
pound sign (`<samp><span class="samp">#</span></samp>'):<!-- /@w -->
-
-<ul class="menu">
-<li><a accesskey="1" href="Gory-Details.html#Gory-Details">Gory Details</a>:
More than you want to know about `<samp><span
class="samp">\</span></samp>' and
- `<samp><span class="samp">&</span></samp>'
with <code>sub</code>, <code>gsub</code>, and
- <code>gensub</code>.
-</ul>
-
- <dl>
-<dt><code>asort(</code><var>source</var> <span class="roman">[</span><code>,
</code><var>dest</var><span class="roman">]</span><code>) #</code><dd><a
name="index-arrays_002c-elements_002c-retrieving-number-of-1162"></a><a
name="index-_0040code_007basort_007d-function-_0028_0040command_007bgawk_007d_0029-1163"></a><code>asort</code>
is a <samp><span class="command">gawk</span></samp>-specific extension,
returning the number of
-elements in the array <var>source</var>. The contents of <var>source</var> are
-sorted using <samp><span class="command">gawk</span></samp>'s normal rules for
comparing values
-(in particular, <code>IGNORECASE</code> affects the sorting)
-and the indices
-of the sorted values of <var>source</var> are replaced with sequential
-integers starting with one. If the optional array <var>dest</var> is specified,
-then <var>source</var> is duplicated into <var>dest</var>. <var>dest</var> is
then
-sorted, leaving the indices of <var>source</var> unchanged.
-For example, if the contents of <code>a</code> are as follows:
-
- <pre class="example"> a["last"] = "de"
- a["first"] = "sac"
- a["middle"] = "cul"
- </pre>
- <p class="noindent">A call to <code>asort</code>:
-
- <pre class="example"> asort(a)
- </pre>
- <p class="noindent">results in the following contents of <code>a</code>:
-
- <pre class="example"> a[1] = "cul"
- a[2] = "de"
- a[3] = "sac"
- </pre>
- <p>The <code>asort</code> function is described in more detail in
-<a href="Array-Sorting.html#Array-Sorting">Array Sorting</a>.
-<code>asort</code> is a <samp><span class="command">gawk</span></samp>
extension; it is not available
-in compatibility mode (see <a href="Options.html#Options">Options</a>).
-
- <br><dt><code>asorti(</code><var>source</var> <span
class="roman">[</span><code>, </code><var>dest</var><span
class="roman">]</span><code>) #</code><dd><a
name="index-_0040code_007basorti_007d-function-_0028_0040command_007bgawk_007d_0029-1164"></a><code>asorti</code>
is a <samp><span class="command">gawk</span></samp>-specific extension,
returning the number of
-elements in the array <var>source</var>.
-It works similarly to <code>asort</code>, however, the <em>indices</em>
-are sorted, instead of the values. As array indices are always strings,
-the comparison performed is always a string comparison. (Here too,
-<code>IGNORECASE</code> affects the sorting.)
-
- <p>The <code>asorti</code> function is described in more detail in
-<a href="Array-Sorting.html#Array-Sorting">Array Sorting</a>.
-It was added in <samp><span class="command">gawk</span></samp> 3.1.2.
-<code>asorti</code> is a <samp><span class="command">gawk</span></samp>
extension; it is not available
-in compatibility mode (see <a href="Options.html#Options">Options</a>).
-
- <br><dt><code>index(</code><var>in</var><code>,
</code><var>find</var><code>)</code><dd><a
name="index-_0040code_007bindex_007d-function-1165"></a><a
name="index-searching-1166"></a>This searches the string <var>in</var> for the
first occurrence of the string
-<var>find</var>, and returns the position in characters where that occurrence
-begins in the string <var>in</var>. Consider the following example:
-
- <pre class="example"> $ awk 'BEGIN { print index("peanut", "an")
}'
- -| 3
- </pre>
- <p class="noindent">If <var>find</var> is not found, <code>index</code>
returns zero.
-(Remember that string indices in <samp><span class="command">awk</span></samp>
start at one.)
-
- <br><dt><code>length(</code><span
class="roman">[</span><var>string</var><span
class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007blength_007d-function-1167"></a>This returns the
number of characters in <var>string</var>. If
-<var>string</var> is a number, the length of the digit string representing
-that number is returned. For example, <code>length("abcde")</code> is 5. By
-contrast, <code>length(15 * 35)</code> works out to 3. In this example, 15 *
35 =
-525, and 525 is then converted to the string <code>"525"</code>, which has
-three characters.
-
- <p>If no argument is supplied, <code>length</code> returns the length of
<code>$0</code>.
-
- <!-- @cindex historical features -->
-<p><a
name="index-portability_002c-_0040code_007blength_007d-function-1168"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-functions-and_002c-_0040code_007blength_007d-1169"></a><blockquote>
-<b>NOTE:</b> In older versions of <samp><span
class="command">awk</span></samp>, the <code>length</code> function could
-be called
-without any parentheses. Doing so is marked as “deprecated” in the
-POSIX standard. This means that while a program can do this,
-it is a feature that can eventually be removed from a future
-version of the standard. Therefore, for programs to be maximally portable,
-always supply the parentheses.
-</blockquote>
-
- <br><dt><code>match(</code><var>string</var><code>,
</code><var>regexp</var> <span class="roman">[</span><code>,
</code><var>array</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bmatch_007d-function-1170"></a>The <code>match</code>
function searches <var>string</var> for the
-longest, leftmost substring matched by the regular expression,
-<var>regexp</var>. It returns the character position, or <dfn>index</dfn>,
-at which that substring begins (one, if it starts at the beginning of
-<var>string</var>). If no match is found, it returns zero.
-
- <p>The <var>regexp</var> argument may be either a regexp constant
-(`<samp><span class="samp">/.../</span></samp>') or a string constant
(<var>"<small class="dots">...</small>"</var>).
-In the latter case, the string is treated as a regexp to be matched.
-<a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>, for a
-discussion of the difference between the two forms, and the
-implications for writing your program correctly.
-
- <p>The order of the first two arguments is backwards from most other
string
-functions that work with regular expressions, such as
-<code>sub</code> and <code>gsub</code>. It might help to remember that
-for <code>match</code>, the order is the same as for the `<samp><span
class="samp">~</span></samp>' operator:
-`<samp><var>string</var><span class="samp"> ~ </span><var>regexp</var></samp>'.
-
- <p><a
name="index-_0040code_007bRSTART_007d-variable_002c-_0040code_007bmatch_007d-function-and-1171"></a><a
name="index-_0040code_007bRLENGTH_007d-variable_002c-_0040code_007bmatch_007d-function-and-1172"></a><a
name="index-_0040code_007bmatch_007d-function_002c-_0040code_007bRSTART_007d_002f_0040code_007bRLENGTH_007d-variables-1173"></a>The
<code>match</code> function sets the built-in variable <code>RSTART</code> to
-the index. It also sets the built-in variable <code>RLENGTH</code> to the
-length in characters of the matched substring. If no match is found,
-<code>RSTART</code> is set to zero, and <code>RLENGTH</code> to −1.
-
- <p>For example:
-
- <pre class="example"> <!-- file eg/misc/findpat.awk -->
- {
- if ($1 == "FIND")
- regex = $2
- else {
- where = match($0, regex)
- if (where != 0)
- print "Match of", regex, "found at",
- where, "in", $0
- }
- }
- <!-- endfile -->
- </pre>
- <p class="noindent">This program looks for lines that match the regular
expression stored in
-the variable <code>regex</code>. This regular expression can be changed. If
the
-first word on a line is `<samp><span class="samp">FIND</span></samp>',
<code>regex</code> is changed to be the
-second word on that line. Therefore, if given:
-
- <pre class="example"> <!-- file eg/misc/findpat.data -->
- FIND ru+n
- My program runs
- but not very quickly
- FIND Melvin
- JF+KM
- This line is property of Reality Engineering Co.
- Melvin was here.
- <!-- endfile -->
- </pre>
- <p class="noindent"><samp><span class="command">awk</span></samp> prints:
-
- <pre class="example"> Match of ru+n found at 12 in My program
runs
- Match of Melvin found at 1 in Melvin was here.
- </pre>
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bmatch_007d-function-1174"></a>If
<var>array</var> is present, it is cleared, and then the 0th element
-of <var>array</var> is set to the entire portion of <var>string</var>
-matched by <var>regexp</var>. If <var>regexp</var> contains parentheses,
-the integer-indexed elements of <var>array</var> are set to contain the
-portion of <var>string</var> matching the corresponding parenthesized
-subexpression.
-For example:
-
- <pre class="example"> $ echo foooobazbarrrrr |
- > gawk '{ match($0, /(fo+).+(bar*)/, arr)
- > print arr[1], arr[2] }'
- -| foooo barrrrr
- </pre>
- <p>In addition,
-beginning with <samp><span class="command">gawk</span></samp> 3.1.2,
-multidimensional subscripts are available providing
-the start index and length of each matched subexpression:
-
- <pre class="example"> $ echo foooobazbarrrrr |
- > gawk '{ match($0, /(fo+).+(bar*)/, arr)
- > print arr[1], arr[2]
- > print arr[1, "start"], arr[1, "length"]
- > print arr[2, "start"], arr[2, "length"]
- > }'
- -| foooo barrrrr
- -| 1 5
- -| 9 7
- </pre>
- <p>There may not be subscripts for the start and index for every
parenthesized
-subexpressions, since they may not all have matched text; thus they
-should be tested for with the <code>in</code> operator
-(see <a href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>).
-
- <p><a
name="index-troubleshooting_002c-_0040code_007bmatch_007d-function-1175"></a>The
<var>array</var> argument to <code>match</code> is a
-<samp><span class="command">gawk</span></samp> extension. In compatibility
mode
-(see <a href="Options.html#Options">Options</a>),
-using a third argument is a fatal error.
-
- <br><dt><code>split(</code><var>string</var><code>,
</code><var>array</var> <span class="roman">[</span><code>,
</code><var>fieldsep</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsplit_007d-function-1176"></a>This function divides
<var>string</var> into pieces separated by <var>fieldsep</var>
-and stores the pieces in <var>array</var>. The first piece is stored in
-<var>array</var><code>[1]</code>, the second piece in
<var>array</var><code>[2]</code>, and so
-forth. The string value of the third argument, <var>fieldsep</var>, is
-a regexp describing where to split <var>string</var> (much as <code>FS</code>
can
-be a regexp describing where to split input records). If
-<var>fieldsep</var> is omitted, the value of <code>FS</code> is used.
-<code>split</code> returns the number of elements created.
-
- <p>The <code>split</code> function splits strings into pieces in a
-manner similar to the way input lines are split into fields. For example:
-
- <pre class="example"> split("cul-de-sac", a, "-")
- </pre>
- <p class="noindent"><a
name="index-strings_002c-splitting-1177"></a>splits the string `<samp><span
class="samp">cul-de-sac</span></samp>' into three fields using `<samp><span
class="samp">-</span></samp>' as the
-separator. It sets the contents of the array <code>a</code> as follows:
-
- <pre class="example"> a[1] = "cul"
- a[2] = "de"
- a[3] = "sac"
- </pre>
- <p class="noindent">The value returned by this call to <code>split</code>
is three.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bsplit_007d-function-1178"></a>As
with input field-splitting, when the value of <var>fieldsep</var> is
-<code>" "</code><!-- /@w -->, leading and trailing whitespace is ignored,
and the elements
-are separated by runs of whitespace.
-Also as with input field-splitting, if <var>fieldsep</var> is the null string,
each
-individual character in the string is split into its own array element.
-(This is a <samp><span class="command">gawk</span></samp>-specific extension.)
-
- <p>Note, however, that <code>RS</code> has no effect on the way
<code>split</code>
-works. Even though `<samp><span class="samp">RS = ""</span></samp>' causes
newline to also be an input
-field separator, this does not affect how <code>split</code> splits strings.
-
- <p><a
name="index-dark-corner_002c-_0040code_007bsplit_007d-function-1179"></a>Modern
implementations of <samp><span class="command">awk</span></samp>, including
<samp><span class="command">gawk</span></samp>, allow
-the third argument to be a regexp constant (<code>/abc/</code>) as well as a
-string.
-(d.c.)
-The POSIX standard allows this as well.
-<a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>, for a
-discussion of the difference between using a string constant or a regexp
constant,
-and the implications for writing your program correctly.
-
- <p>Before splitting the string, <code>split</code> deletes any previously
existing
-elements in the array <var>array</var>.
-
- <p>If <var>string</var> is null, the array has no elements. (So this is a
portable
-way to delete an entire array with one statement.
-See <a href="Delete.html#Delete">Delete</a>.)
-
- <p>If <var>string</var> does not match <var>fieldsep</var> at all (but is
not null),
-<var>array</var> has one element only. The value of that element is the
original
-<var>string</var>.
-
- <br><dt><code>sprintf(</code><var>format</var><code>,
</code><var>expression1</var><code>, ...)</code><dd><a
name="index-_0040code_007bsprintf_007d-function-1180"></a>This returns (without
printing) the string that <code>printf</code> would
-have printed out with the same arguments
-(see <a href="Printf.html#Printf">Printf</a>).
-For example:
-
- <pre class="example"> pival = sprintf("pi = %.2f (approx.)",
22/7)
- </pre>
- <p class="noindent">assigns the string
<code>"pi = 3.14 (approx.)"</code><!-- /@w --> to the variable
<code>pival</code>.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1181"></a><a
name="index-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1182"></a><br><dt><code>strtonum(</code><var>str</var><code>)
#</code><dd>Examines <var>str</var> and returns its numeric value. If
<var>str</var>
-begins with a leading `<samp><span class="samp">0</span></samp>',
<code>strtonum</code> assumes that <var>str</var>
-is an octal number. If <var>str</var> begins with a leading `<samp><span
class="samp">0x</span></samp>' or
-`<samp><span class="samp">0X</span></samp>', <code>strtonum</code> assumes
that <var>str</var> is a hexadecimal number.
-For example:
-
- <pre class="example"> $ echo 0x11 |
- > gawk '{ printf "%d\n", strtonum($1) }'
- -| 17
- </pre>
- <p>Using the <code>strtonum</code> function is <em>not</em> the same as
adding zero
-to a string value; the automatic coercion of strings to numbers
-works only for decimal data, not for octal or hexadecimal.<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a>
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bstrtonum_007d-function-_0028_0040command_007bgawk_007d_0029-1183"></a><code>strtonum</code>
is a <samp><span class="command">gawk</span></samp> extension; it is not
available
-in compatibility mode (see <a href="Options.html#Options">Options</a>).
-
- <br><dt><code>sub(</code><var>regexp</var><code>,
</code><var>replacement</var> <span class="roman">[</span><code>,
</code><var>target</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsub_007d-function-1184"></a>The <code>sub</code>
function alters the value of <var>target</var>.
-It searches this value, which is treated as a string, for the
-leftmost, longest substring matched by the regular expression
<var>regexp</var>.
-Then the entire string is
-changed by replacing the matched text with <var>replacement</var>.
-The modified string becomes the new value of <var>target</var>.
-
- <p>The <var>regexp</var> argument may be either a regexp constant
-(`<samp><span class="samp">/.../</span></samp>') or a string constant
(<var>"<small class="dots">...</small>"</var>).
-In the latter case, the string is treated as a regexp to be matched.
-<a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>, for a
-discussion of the difference between the two forms, and the
-implications for writing your program correctly.
-
- <p>This function is peculiar because <var>target</var> is not simply
-used to compute a value, and not just any expression will do—it
-must be a variable, field, or array element so that <code>sub</code> can
-store a modified value there. If this argument is omitted, then the
-default is to use and alter <code>$0</code>.<a rel="footnote" href="#fn-2"
name="fnd-2"><sup>2</sup></a>
-For example:
-
- <pre class="example"> str = "water, water, everywhere"
- sub(/at/, "ith", str)
- </pre>
- <p class="noindent">sets <code>str</code> to
<code>"wither, water, everywhere"</code><!-- /@w -->, by replacing the
-leftmost longest occurrence of `<samp><span class="samp">at</span></samp>'
with `<samp><span class="samp">ith</span></samp>'.
-
- <p>The <code>sub</code> function returns the number of substitutions made
(either
-one or zero).
-
- <p>If the special character `<samp><span
class="samp">&</span></samp>' appears in <var>replacement</var>, it
-stands for the precise substring that was matched by <var>regexp</var>. (If
-the regexp can match more than one string, then this precise substring
-may vary.) For example:
-
- <pre class="example"> { sub(/candidate/, "& and his wife");
print }
- </pre>
- <p class="noindent">changes the first occurrence of `<samp><span
class="samp">candidate</span></samp>' to `<samp><span class="samp">candidate
-and his wife</span></samp>' on each input line.
-Here is another example:
-
- <pre class="example"> $ awk 'BEGIN {
- > str = "daabaaa"
- > sub(/a+/, "C&C", str)
- > print str
- > }'
- -| dCaaCbaaa
- </pre>
- <p class="noindent">This shows how `<samp><span
class="samp">&</span></samp>' can represent a nonconstant string and also
-illustrates the “leftmost, longest” rule in regexp matching
-(see <a href="Leftmost-Longest.html#Leftmost-Longest">Leftmost Longest</a>).
-
- <p>The effect of this special character (`<samp><span
class="samp">&</span></samp>') can be turned off by putting a
-backslash before it in the string. As usual, to insert one backslash in
-the string, you must write two backslashes. Therefore, write `<samp><span
class="samp">\\&</span></samp>'
-in a string constant to include a literal `<samp><span
class="samp">&</span></samp>' in the replacement.
-For example, the following shows how to replace the first `<samp><span
class="samp">|</span></samp>' on each line with
-an `<samp><span class="samp">&</span></samp>':
-
- <pre class="example"> { sub(/\|/, "\\&"); print }
- </pre>
- <p><a
name="index-_0040code_007bsub_007d-function_002c-arguments-of-1185"></a><a
name="index-_0040code_007bgsub_007d-function_002c-arguments-of-1186"></a>As
mentioned, the third argument to <code>sub</code> must
-be a variable, field or array reference.
-Some versions of <samp><span class="command">awk</span></samp> allow the third
argument to
-be an expression that is not an lvalue. In such a case, <code>sub</code>
-still searches for the pattern and returns zero or one, but the result of
-the substitution (if any) is thrown away because there is no place
-to put it. Such versions of <samp><span class="command">awk</span></samp>
accept expressions
-such as the following:
-
- <pre class="example"> sub(/USA/, "United States", "the USA and
Canada")
- </pre>
- <p class="noindent"><a
name="index-troubleshooting_002c-_0040code_007bgsub_007d_002f_0040code_007bsub_007d-functions-1187"></a>For
historical compatibility, <samp><span class="command">gawk</span></samp>
accepts erroneous code,
-such as in the previous example. However, using any other nonchangeable
-object as the third parameter causes a fatal error and your program
-will not run.
-
- <p>Finally, if the <var>regexp</var> is not a regexp constant, it is
converted into a
-string, and then the value of that string is treated as the regexp to match.
-
- <br><dt><code>gsub(</code><var>regexp</var><code>,
</code><var>replacement</var> <span class="roman">[</span><code>,
</code><var>target</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bgsub_007d-function-1188"></a>This is similar to the
<code>sub</code> function, except <code>gsub</code> replaces
-<em>all</em> of the longest, leftmost, <em>nonoverlapping</em> matching
-substrings it can find. The `<samp><span class="samp">g</span></samp>' in
<code>gsub</code> stands for
-“global,” which means replace everywhere. For example:
-
- <pre class="example"> { gsub(/Britain/, "United Kingdom"); print
}
- </pre>
- <p class="noindent">replaces all occurrences of the string `<samp><span
class="samp">Britain</span></samp>' with `<samp><span class="samp">United
-Kingdom</span></samp>' for all input records.
-
- <p>The <code>gsub</code> function returns the number of substitutions
made. If
-the variable to search and alter (<var>target</var>) is
-omitted, then the entire input record (<code>$0</code>) is used.
-As in <code>sub</code>, the characters `<samp><span
class="samp">&</span></samp>' and `<samp><span
class="samp">\</span></samp>' are special,
-and the third argument must be assignable.
-
- <br><dt><code>gensub(</code><var>regexp</var><code>,
</code><var>replacement</var><code>, </code><var>how</var> <span
class="roman">[</span><code>, </code><var>target</var><span
class="roman">]</span><code>) #</code><dd><a
name="index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-1189"></a><code>gensub</code>
is a general substitution function. Like <code>sub</code> and
-<code>gsub</code>, it searches the target string <var>target</var> for matches
of
-the regular expression <var>regexp</var>. Unlike <code>sub</code> and
<code>gsub</code>,
-the modified string is returned as the result of the function and the
-original target string is <em>not</em> changed. If <var>how</var> is a string
-beginning with `<samp><span class="samp">g</span></samp>' or `<samp><span
class="samp">G</span></samp>', then it replaces all matches of
-<var>regexp</var> with <var>replacement</var>. Otherwise, <var>how</var> is
treated
-as a number that indicates which match of <var>regexp</var> to replace. If
-no <var>target</var> is supplied, <code>$0</code> is used.
-
- <p><code>gensub</code> provides an additional feature that is not
available
-in <code>sub</code> or <code>gsub</code>: the ability to specify components of
a
-regexp in the replacement text. This is done by using parentheses in
-the regexp to mark the components and then specifying `<samp><span
class="samp">\</span><var>N</var></samp>'
-in the replacement text, where <var>N</var> is a digit from 1 to 9.
-For example:
-
- <pre class="example"> $ gawk '
- > BEGIN {
- > a = "abc def"
- > b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a)
- > print b
- > }'
- -| def abc
- </pre>
- <p class="noindent">As with <code>sub</code>, you must type two
backslashes in order
-to get one into the string.
-In the replacement text, the sequence `<samp><span
class="samp">\0</span></samp>' represents the entire
-matched text, as does the character `<samp><span
class="samp">&</span></samp>'.
-
- <p>The following example shows how you can use the third argument to
control
-which match of the regexp should be changed:
-
- <pre class="example"> $ echo a b c a b c |
- > gawk '{ print gensub(/a/, "AA", 2) }'
- -| a b c AA b c
- </pre>
- <p>In this case, <code>$0</code> is used as the default target string.
-<code>gensub</code> returns the new string as its result, which is
-passed directly to <code>print</code> for printing.
-
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p>If the <var>how</var> argument is a string that does not begin with
`<samp><span class="samp">g</span></samp>' or
-`<samp><span class="samp">G</span></samp>', or if it is a number that is less
than or equal to zero, only one
-substitution is performed. If <var>how</var> is zero, <samp><span
class="command">gawk</span></samp> issues
-a warning message.
-
- <p>If <var>regexp</var> does not match <var>target</var>,
<code>gensub</code>'s return value
-is the original unchanged value of <var>target</var>.
-
- <p><code>gensub</code> is a <samp><span
class="command">gawk</span></samp> extension; it is not available
-in compatibility mode (see <a href="Options.html#Options">Options</a>).
-
- <br><dt><code>substr(</code><var>string</var><code>,
</code><var>start</var> <span class="roman">[</span><code>,
</code><var>length</var><span class="roman">]</span><code>)</code><dd><a
name="index-_0040code_007bsubstr_007d-function-1190"></a>This returns a
<var>length</var>-character-long substring of <var>string</var>,
-starting at character number <var>start</var>. The first character of a
-string is character number one.<a rel="footnote" href="#fn-3"
name="fnd-3"><sup>3</sup></a>
-For example, <code>substr("washington", 5, 3)</code> returns
<code>"ing"</code>.
-
- <p>If <var>length</var> is not present, this function returns the whole
suffix of
-<var>string</var> that begins at character number <var>start</var>. For
example,
-<code>substr("washington", 5)</code> returns <code>"ington"</code>. The whole
-suffix is also returned
-if <var>length</var> is greater than the number of characters remaining
-in the string, counting from character <var>start</var>.
-
- <p>If <var>start</var> is less than one, <code>substr</code> treats it as
-if it was one. (POSIX doesn't specify what to do in this case:
-Unix <samp><span class="command">awk</span></samp> acts this way, and
therefore <samp><span class="command">gawk</span></samp>
-does too.)
-If <var>start</var> is greater than the number of characters
-in the string, <code>substr</code> returns the null string.
-Similarly, if <var>length</var> is present but less than or equal to zero,
-the null string is returned.
-
- <p><a
name="index-troubleshooting_002c-_0040code_007bsubstr_007d-function-1191"></a>The
string returned by <code>substr</code> <em>cannot</em> be
-assigned. Thus, it is a mistake to attempt to change a portion of
-a string, as shown in the following example:
-
- <pre class="example"> string = "abcdef"
- # try to get "abCDEf", won't work
- substr(string, 3, 3) = "CDE"
- </pre>
- <p class="noindent">It is also a mistake to use <code>substr</code> as
the third argument
-of <code>sub</code> or <code>gsub</code>:
-
- <pre class="example"> gsub(/xyz/, "pdq", substr($0, 5, 20)) #
WRONG
- </pre>
- <p><a
name="index-portability_002c-_0040code_007bsubstr_007d-function-1192"></a>(Some
commercial versions of <samp><span class="command">awk</span></samp> do in fact
let you use
-<code>substr</code> this way, but doing so is not portable.)
-
- <p>If you need to replace bits and pieces of a string, combine
<code>substr</code>
-with string concatenation, in the following manner:
-
- <pre class="example"> string = "abcdef"
- ...
- string = substr(string, 1, 2) "CDE" substr(string, 6)
- </pre>
- <p><a name="index-case-sensitivity_002c-converting-case-1193"></a><a
name="index-converting_002c-case-1194"></a><br><dt><code>tolower(</code><var>string</var><code>)</code><dd><a
name="index-_0040code_007btolower_007d-function-1195"></a>This returns a copy
of <var>string</var>, with each uppercase character
-in the string replaced with its corresponding lowercase character.
-Nonalphabetic characters are left unchanged. For example,
-<code>tolower("MiXeD cAsE 123")</code> returns <code>"mixed case 123"</code>.
-
- <br><dt><code>toupper(</code><var>string</var><code>)</code><dd><a
name="index-_0040code_007btoupper_007d-function-1196"></a>This returns a copy
of <var>string</var>, with each lowercase character
-in the string replaced with its corresponding uppercase character.
-Nonalphabetic characters are left unchanged. For example,
-<code>toupper("MiXeD cAsE 123")</code> returns <code>"MIXED CASE 123"</code>.
-</dl>
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> Unless
-you use the <samp><span class="option">--non-decimal-data</span></samp>
option, which isn't recommended.
-See <a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a>, for
more information.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small>
Note that this means
-that the record will first be regenerated using the value of <code>OFS</code>
if
-any fields have been changed, and that the fields will be updated
-after the substituion, even if the operation is a “no-op” such
-as `<samp><span class="samp">sub(/^/, "")</span></samp>'.</p>
-
- <p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small>
This is different from
-C and C++, in which the first character is number zero.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Strtonum-Function.html
===================================================================
RCS file: manual/html_node/Strtonum-Function.html
diff -N manual/html_node/Strtonum-Function.html
--- manual/html_node/Strtonum-Function.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,139 +0,0 @@
-<html lang="en">
-<head>
-<title>Strtonum Function - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="General-Functions.html#General-Functions" title="General
Functions">
-<link rel="prev" href="Nextfile-Function.html#Nextfile-Function"
title="Nextfile Function">
-<link rel="next" href="Assert-Function.html#Assert-Function" title="Assert
Function">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Strtonum-Function"></a>Next: <a rel="next" accesskey="n"
href="Assert-Function.html#Assert-Function">Assert Function</a>,
-Previous: <a rel="previous" accesskey="p"
href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a>,
-Up: <a rel="up" accesskey="u"
href="General-Functions.html#General-Functions">General Functions</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">12.2.2 Converting Strings To Numbers</h4>
-
-<p>The <code>strtonum</code> function (see <a
href="String-Functions.html#String-Functions">String Functions</a>)
-is a <samp><span class="command">gawk</span></samp> extension. The following
function
-provides an implementation for other versions of <samp><span
class="command">awk</span></samp>:
-
-<pre class="example"> <!-- file eg/lib/strtonum.awk -->
- # strtonum --- convert string to number
- <!-- endfile -->
- <!-- file eg/lib/strtonum.awk -->
- function mystrtonum(str, ret, chars, n, i, k, c)
- {
- if (str ~ /^0[0-7]*$/) {
- # octal
- n = length(str)
- ret = 0
- for (i = 1; i <= n; i++) {
- c = substr(str, i, 1)
- if ((k = index("01234567", c)) > 0)
- k-- # adjust for 1-basing in awk
-
- ret = ret * 8 + k
- }
- } else if (str ~ /^0[xX][0-9a-fA-f]+/) {
- # hexadecimal
- str = substr(str, 3) # lop off leading 0x
- n = length(str)
- ret = 0
- for (i = 1; i <= n; i++) {
- c = substr(str, i, 1)
- c = tolower(c)
- if ((k = index("0123456789", c)) > 0)
- k-- # adjust for 1-basing in awk
- else if ((k = index("abcdef", c)) > 0)
- k += 9
-
- ret = ret * 16 + k
- }
- } else if (str ~
/^[-+]?([0-9]+([.][0-9]*([Ee][0-9]+)?)?|([.][0-9]+([Ee][-+]?[0-9]+)?))$/) {
- # decimal number, possibly floating point
- ret = str + 0
- } else
- ret = "NOT-A-NUMBER"
-
- return ret
- }
-
- # BEGIN { # gawk test harness
- # a[1] = "25"
- # a[2] = ".31"
- # a[3] = "0123"
- # a[4] = "0xdeadBEEF"
- # a[5] = "123.45"
- # a[6] = "1.e3"
- # a[7] = "1.32"
- # a[7] = "1.32E2"
- #
- # for (i = 1; i in a; i++)
- # print a[i], strtonum(a[i]), mystrtonum(a[i])
- # }
- <!-- endfile -->
-</pre>
- <p>The function first looks for C-style octal numbers (base 8).
-If the input string matches a regular expression describing octal
-numbers, then <code>mystrtonum</code> loops through each character in the
-string. It sets <code>k</code> to the index in <code>"01234567"</code> of the
current
-octal digit. Since the return value is one-based, the `<samp><span
class="samp">k--</span></samp>'
-adjusts <code>k</code> so it can be used in computing the return value.
-
- <p>Similar logic applies to the code that checks for and converts a
-hexadecimal value, which starts with `<samp><span
class="samp">0x</span></samp>' or `<samp><span class="samp">0X</span></samp>'.
-The use of <code>tolower</code> simplifies the computation for finding
-the correct numeric value for each hexadecimal digit.
-
- <p>Finally, if the string matches the (rather complicated) regex for a
-regular decimal integer or floating-point numer, the computation
-`<samp><span class="samp">ret = str + 0</span></samp>' lets <samp><span
class="command">awk</span></samp> convert the value to a
-number.
-
- <p>A commented-out test program is included, so that the function can
-be tested with <samp><span class="command">gawk</span></samp> and the results
compared to the built-in
-<code>strtonum</code> function.
-
- </body></html>
-
Index: manual/html_node/Switch-Statement.html
===================================================================
RCS file: manual/html_node/Switch-Statement.html
diff -N manual/html_node/Switch-Statement.html
--- manual/html_node/Switch-Statement.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,116 +0,0 @@
-<html lang="en">
-<head>
-<title>Switch Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="For-Statement.html#For-Statement" title="For Statement">
-<link rel="next" href="Break-Statement.html#Break-Statement" title="Break
Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Switch-Statement"></a>Next: <a rel="next" accesskey="n"
href="Break-Statement.html#Break-Statement">Break Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="For-Statement.html#For-Statement">For Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.5 The <code>switch</code> Statement</h4>
-
-<p><a name="index-_0040code_007bswitch_007d-statement-958"></a><a
name="index-_0040code_007bcase_007d-keyword-959"></a><a
name="index-_0040code_007bdefault_007d-keyword-960"></a>
-<strong>NOTE:</strong> This subsection describes an experimental feature
-added in <samp><span class="command">gawk</span></samp> 3.1.3. It is
<em>not</em> enabled by default. To
-enable it, use the <samp><span class="option">--enable-switch</span></samp>
option to <samp><span class="command">configure</span></samp>
-when <samp><span class="command">gawk</span></samp> is being configured and
built.
-See <a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>, for more information.
-
- <p>The <code>switch</code> statement allows the evaluation of an expression
and
-the execution of statements based on a <code>case</code> match. Case statements
-are checked for a match in the order they are defined. If no suitable
-<code>case</code> is found, the <code>default</code> section is executed, if
supplied.
-
- <p>Each <code>case</code> contains a single constant, be it numeric,
string, or
-regexp. The <code>switch</code> expression is evaluated, and then each
-<code>case</code>'s constant is compared against the result in turn. The type
of constant
-determines the comparison: numeric or string do the usual comparisons.
-A regexp constant does a regular expression match against the string
-value of the original expression. The general form of the <code>switch</code>
-statement looks like this:
-
-<pre class="example"> switch (<var>expression</var>) {
- case <var>value or regular expression</var>:
- <var>case-body</var>
- default:
- <var>default-body</var>
- }
-</pre>
- <p>Control flow in
-the <code>switch</code> statement works as it does in C. Once a match to a
given
-case is made, case statement bodies are executed until a <code>break</code>,
-<code>continue</code>, <code>next</code>, <code>nextfile</code> or
<code>exit</code> is encountered,
-or the end of the <code>switch</code> statement itself. For example:
-
-<pre class="example"> switch (NR * 2 + 1) {
- case 3:
- case "11":
- print NR - 1
- break
-
- case /2[[:digit:]]+/:
- print NR
-
- default:
- print NR + 1
-
- case -1:
- print NR * -1
- }
-</pre>
- <p>Note that if none of the statements specified above halt execution
-of a matched <code>case</code> statement, execution falls through to the
-next <code>case</code> until execution halts. In the above example, for
-any case value starting with `<samp><span class="samp">2</span></samp>'
followed by one or more digits,
-the <code>print</code> statement is executed and then falls through into the
-<code>default</code> section, executing its <code>print</code> statement. In
turn,
-the −1 case will also be executed since the <code>default</code> does
-not halt execution.
-
- </body></html>
-
Index: manual/html_node/TCP_002fIP-Networking.html
===================================================================
RCS file: manual/html_node/TCP_002fIP-Networking.html
diff -N manual/html_node/TCP_002fIP-Networking.html
--- manual/html_node/TCP_002fIP-Networking.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,124 +0,0 @@
-<html lang="en">
-<head>
-<title>TCP/IP Networking - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Advanced-Features.html#Advanced-Features" title="Advanced
Features">
-<link rel="prev" href="Two_002dway-I_002fO.html#Two_002dway-I_002fO"
title="Two-way I/O">
-<link rel="next" href="Portal-Files.html#Portal-Files" title="Portal Files">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="TCP_002fIP-Networking"></a>Next: <a rel="next" accesskey="n"
href="Portal-Files.html#Portal-Files">Portal Files</a>,
-Previous: <a rel="previous" accesskey="p"
href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>,
-Up: <a rel="up" accesskey="u"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>
-<hr><br>
-</div>
-
-<h3 class="section">10.3 Using <samp><span class="command">gawk</span></samp>
for Network Programming</h3>
-
-<p><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-network-programming-1419"></a><a
name="index-networks_002c-programming-1420"></a><!-- STARTOFRANGE tcpip -->
-<a name="index-TCP_002fIP-1421"></a><a
name="index-_0040code_007b_002finet_002f_007d-files-_0028_0040command_007bgawk_007d_0029-1422"></a><a
name="index-files_002c-_0040code_007b_002finet_002f_007d-_0028_0040command_007bgawk_007d_0029-1423"></a><a
name="index-_0040code_007bEMISTERED_007d-1424"></a><blockquote>
-<code>EMISTERED</code>: <i>A host is a host from coast to coast,<br>
-and no-one can talk to host that's close,<br>
-unless the host that isn't close<br>
-is busy hung or dead.</i>
-</blockquote>
-
- <p>In addition to being able to open a two-way pipeline to a coprocess
-on the same system
-(see <a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>),
-it is possible to make a two-way connection to
-another process on another system across an IP networking connection.
-
- <p>You can think of this as just a <em>very long</em> two-way pipeline to
-a coprocess.
-The way <samp><span class="command">gawk</span></samp> decides that you want
to use TCP/IP networking is
-by recognizing special file names that begin with `<samp><span
class="samp">/inet/</span></samp>'.
-
- <p>The full syntax of the special file name is
-<samp><span class="file">/inet/</span><var>protocol</var><span
class="file">/</span><var>local-port</var><span
class="file">/</span><var>remote-host</var><span
class="file">/</span><var>remote-port</var></samp>.
-The components are:
-
- <dl>
-<dt><var>protocol</var><dd>The protocol to use over IP. This must be either
`<samp><span class="samp">tcp</span></samp>',
-`<samp><span class="samp">udp</span></samp>', or `<samp><span
class="samp">raw</span></samp>', for a TCP, UDP, or raw IP connection,
-respectively. The use of TCP is recommended for most applications.
-
- <p><a name="index-raw-sockets-1425"></a><a
name="index-sockets-1426"></a><strong>Caution:</strong> The use of raw sockets
is not currently supported
-in version 3.1 of <samp><span class="command">gawk</span></samp>.
-
- <br><dt><var>local-port</var><dd><a
name="index-_0040code_007bgetservbyname_007d-function-_0028C-library_0029-1427"></a>The
local TCP or UDP port number to use. Use a port number of `<samp><span
class="samp">0</span></samp>'
-when you want the system to pick a port. This is what you should do
-when writing a TCP or UDP client.
-You may also use a well-known service name, such as `<samp><span
class="samp">smtp</span></samp>'
-or `<samp><span class="samp">http</span></samp>', in which case <samp><span
class="command">gawk</span></samp> attempts to determine
-the predefined port number using the C <code>getservbyname</code> function.
-
- <br><dt><var>remote-host</var><dd>The IP address or fully-qualified
domain name of the Internet
-host to which you want to connect.
-
- <br><dt><var>remote-port</var><dd>The TCP or UDP port number to use on
the given <var>remote-host</var>.
-Again, use `<samp><span class="samp">0</span></samp>' if you don't care, or
else a well-known
-service name.
-</dl>
-
- <p>Consider the following very simple example:
-
-<pre class="example"> BEGIN {
- Service = "/inet/tcp/0/localhost/daytime"
- Service |& getline
- print $0
- close(Service)
- }
-</pre>
- <p>This program reads the current date and time from the local system's
-TCP `<samp><span class="samp">daytime</span></samp>' server.
-It then prints the results and closes the connection.
-
- <p>Because this topic is extensive, the use of <samp><span
class="command">gawk</span></samp> for
-TCP/IP programming is documented separately.
-See <cite>TCP/IP Internetworking with <samp></cite><span
class="command">gawk</span><cite></samp></cite>,
-which comes as part of the <samp><span class="command">gawk</span></samp>
distribution,
-for a much more complete introduction and discussion, as well as
-extensive examples.
-
- </body></html>
-
Index: manual/html_node/Tandem-Installation.html
===================================================================
RCS file: manual/html_node/Tandem-Installation.html
diff -N manual/html_node/Tandem-Installation.html
--- manual/html_node/Tandem-Installation.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,96 +0,0 @@
-<html lang="en">
-<head>
-<title>Tandem Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Unsupported.html#Unsupported" title="Unsupported">
-<link rel="prev" href="Atari-Installation.html#Atari-Installation"
title="Atari Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Tandem-Installation"></a>Previous: <a rel="previous"
accesskey="p" href="Atari-Installation.html#Atari-Installation">Atari
Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Unsupported.html#Unsupported">Unsupported</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.4.2 Installing <samp><span
class="command">gawk</span></samp> on a Tandem</h4>
-
-<p><a name="index-tandem-1919"></a><a
name="index-installation_002c-tandem-1920"></a>
-The Tandem port is only minimally supported.
-The port's contributor no longer has access to a Tandem system.
-
-<!-- This section based on README.Tandem by Stephen Davies (address@hidden) -->
-<p>The Tandem port was done on a Cyclone machine running D20.
-The port is pretty clean and all facilities seem to work except for
-the I/O piping facilities
-(see <a href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a>,
-<a
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>,
-and
-<a href="Redirection.html#Redirection">Redirection</a>),
-which is just too foreign a concept for Tandem.
-
- <p>To build a Tandem executable from source, download all of the files so
-that the file names on the Tandem box conform to the restrictions of D20.
-For example, <samp><span class="file">array.c</span></samp> becomes
<samp><span class="file">ARRAYC</span></samp>, and <samp><span
class="file">awk.h</span></samp>
-becomes <samp><span class="file">AWKH</span></samp>. The totally
Tandem-specific files are in the
-<samp><span class="file">tandem</span></samp> “subvolume”
(<samp><span class="file">unsupported/tandem</span></samp> in the <samp><span
class="command">gawk</span></samp>
-distribution) and should be copied to the main source directory before
-building <samp><span class="command">gawk</span></samp>.
-
- <p>The file <samp><span class="file">compit</span></samp> can then be used
to compile and bind an executable.
-Alas, there is no <samp><span class="command">configure</span></samp> or
<samp><span class="command">make</span></samp>.
-
- <p>Usage is the same as for Unix, except that D20 requires all `<samp><span
class="samp">{</span></samp>' and
-`<samp><span class="samp">}</span></samp>' characters to be escaped with
`<samp><span class="samp">~</span></samp>' on the command line
-(but <em>not</em> in script files). Also, the standard Tandem syntax for
-`<samp><span class="samp">/in filename,out filename/</span></samp>' must be
used instead of the usual
-Unix `<samp><span class="samp"><</span></samp>' and `<samp><span
class="samp">></span></samp>' for file redirection. (Redirection options
-on <code>getline</code>, <code>print</code> etc., are supported.)
-
- <p>The `<samp><span class="samp">-mr </span><var>val</var></samp>' option
-(see <a href="Options.html#Options">Options</a>)
-has been “stolen” to enable Tandem users to process fixed-length
-records with no “end-of-line” character. That is, `<samp><span
class="samp">-mr 74</span></samp>' tells
-<samp><span class="command">gawk</span></samp> to read the input file as fixed
74-byte records.
-<!-- ENDOFRANGE opgawx -->
-<!-- ENDOFRANGE pcgawon -->
-
- </body></html>
-
Index: manual/html_node/Tee-Program.html
===================================================================
RCS file: manual/html_node/Tee-Program.html
diff -N manual/html_node/Tee-Program.html
--- manual/html_node/Tee-Program.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,148 +0,0 @@
-<html lang="en">
-<head>
-<title>Tee Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="prev" href="Split-Program.html#Split-Program" title="Split Program">
-<link rel="next" href="Uniq-Program.html#Uniq-Program" title="Uniq Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Tee-Program"></a>Next: <a rel="next" accesskey="n"
href="Uniq-Program.html#Uniq-Program">Uniq Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Split-Program.html#Split-Program">Split Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.5 Duplicating Output into Multiple Files</h4>
-
-<p><a
name="index-files_002c-multiple_0040comma_007b_007d-duplicating-output-into-1770"></a><a
name="index-output_002c-duplicating-into-files-1771"></a><a
name="index-_0040code_007btee_007d-utility-1772"></a>The <code>tee</code>
program is known as a “pipe fitting.” <code>tee</code> copies
-its standard input to its standard output and also duplicates it to the
-files named on the command line. Its usage is as follows:
-
-<pre class="example"> tee <span class="roman">[</span>-a<span
class="roman">]</span> file ...
-</pre>
- <p>The <samp><span class="option">-a</span></samp> option tells
<code>tee</code> to append to the named files, instead of
-truncating them and starting over.
-
- <p>The <code>BEGIN</code> rule first makes a copy of all the command-line
arguments
-into an array named <code>copy</code>.
-<code>ARGV[0]</code> is not copied, since it is not needed.
-<code>tee</code> cannot use <code>ARGV</code> directly, since <samp><span
class="command">awk</span></samp> attempts to
-process each file name in <code>ARGV</code> as input data.
-
- <p><a name="index-flag-variables-1773"></a>If the first argument is
<samp><span class="option">-a</span></samp>, then the flag variable
-<code>append</code> is set to true, and both <code>ARGV[1]</code> and
-<code>copy[1]</code> are deleted. If <code>ARGC</code> is less than two, then
no
-file names were supplied and <code>tee</code> prints a usage message and
exits.
-Finally, <samp><span class="command">awk</span></samp> is forced to read the
standard input by setting
-<code>ARGV[1]</code> to <code>"-"</code> and <code>ARGC</code> to two:
-
-<!-- NEXT ED: Add more leading commentary in this program -->
-<p><a name="index-_0040code_007btee_002eawk_007d-program-1774"></a>
-<pre class="example"> <!-- file eg/prog/tee.awk -->
- # tee.awk --- tee in awk
- <!-- endfile -->
- <!-- file eg/prog/tee.awk -->
- BEGIN \
- {
- for (i = 1; i < ARGC; i++)
- copy[i] = ARGV[i]
-
- if (ARGV[1] == "-a") {
- append = 1
- delete ARGV[1]
- delete copy[1]
- ARGC--
- }
- if (ARGC < 2) {
- print "usage: tee [-a] file ..." > "/dev/stderr"
- exit 1
- }
- ARGV[1] = "-"
- ARGC = 2
- }
- <!-- endfile -->
-</pre>
- <p>The single rule does all the work. Since there is no pattern, it is
-executed for each line of input. The body of the rule simply prints the
-line into each file on the command line, and then to the standard output:
-
-<pre class="example"> <!-- file eg/prog/tee.awk -->
- {
- # moving the if outside the loop makes it run faster
- if (append)
- for (i in copy)
- print >> copy[i]
- else
- for (i in copy)
- print > copy[i]
- print
- }
- <!-- endfile -->
-</pre>
- <p class="noindent">It is also possible to write the loop this way:
-
-<pre class="example"> for (i in copy)
- if (append)
- print >> copy[i]
- else
- print > copy[i]
-</pre>
- <p class="noindent">This is more concise but it is also less efficient.
The `<samp><span class="samp">if</span></samp>' is
-tested for each record and for each output file. By duplicating the loop
-body, the `<samp><span class="samp">if</span></samp>' is only tested once for
each input record. If there are
-<var>N</var> input records and <var>M</var> output files, the first method only
-executes <var>N</var> `<samp><span class="samp">if</span></samp>' statements,
while the second executes
-<var>N</var><code>*</code><var>M</var> `<samp><span
class="samp">if</span></samp>' statements.
-
- <p>Finally, the <code>END</code> rule cleans up by closing all the output
files:
-
-<pre class="example"> <!-- file eg/prog/tee.awk -->
- END \
- {
- for (i in copy)
- close(copy[i])
- }
- <!-- endfile -->
-</pre>
- </body></html>
-
Index: manual/html_node/This-Manual.html
===================================================================
RCS file: manual/html_node/This-Manual.html
diff -N manual/html_node/This-Manual.html
--- manual/html_node/This-Manual.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,203 +0,0 @@
-<html lang="en">
-<head>
-<title>This Manual - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Preface.html#Preface" title="Preface">
-<link rel="prev" href="Names.html#Names" title="Names">
-<link rel="next" href="Conventions.html#Conventions" title="Conventions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="This-Manual"></a>Next: <a rel="next" accesskey="n"
href="Conventions.html#Conventions">Conventions</a>,
-Previous: <a rel="previous" accesskey="p"
href="Names.html#Names">Names</a>,
-Up: <a rel="up" accesskey="u" href="Preface.html#Preface">Preface</a>
-<hr><br>
-</div>
-
-<h3 class="section">Using This Book</h3>
-
-<p><a name="index-_0040command_007bawk_007d_002c-terms-describing-24"></a>
-The term <samp><span class="command">awk</span></samp> refers to a particular
program as well as to the language you
-use to tell this program what to do. When we need to be careful, we call
-the language “the <samp><span class="command">awk</span></samp>
language,”
-and the program “the <samp><span class="command">awk</span></samp>
utility.”
-This Web page explains
-both the <samp><span class="command">awk</span></samp> language and how to run
the <samp><span class="command">awk</span></samp> utility.
-The term <dfn><samp></dfn><span class="command">awk</span><dfn></samp>
program</dfn> refers to a program written by you in
-the <samp><span class="command">awk</span></samp> programming language.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040command_007bawk_007d-and-25"></a><a
name="index-_0040command_007bawk_007d_002c-_0040command_007bgawk_007d-and-26"></a><a
name="index-POSIX-_0040command_007bawk_007d-27"></a>Primarily, this Web page
explains the features of <samp><span class="command">awk</span></samp>,
-as defined in the POSIX standard. It does so in the context of the
-<samp><span class="command">gawk</span></samp> implementation. While doing
so, it also
-attempts to describe important differences between <samp><span
class="command">gawk</span></samp>
-and other <samp><span class="command">awk</span></samp> implementations.<a
rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-Finally, any <samp><span class="command">gawk</span></samp> features that are
not in
-the POSIX standard for <samp><span class="command">awk</span></samp> are noted.
-
- <p>This Web page has the difficult task of being both a tutorial and a
reference.
-If you are a novice, feel free to skip over details that seem too complex.
-You should also ignore the many cross-references; they are for the
-expert user and for the online Info version of the document.
-
- <p>There are
-subsections labelled
-as <strong>Advanced Notes</strong>
-scattered throughout the Web page.
-They add a more complete explanation of points that are relevant, but not
likely
-to be of interest on first reading.
-All appear in the index, under the heading “advanced features.”
-
- <p>Most of the time, the examples use complete <samp><span
class="command">awk</span></samp> programs.
-In some of the more advanced sections, only the part of the <samp><span
class="command">awk</span></samp>
-program that illustrates the concept currently being described is shown.
-
- <p>While this Web page is aimed principally at people who have not been
-exposed
-to <samp><span class="command">awk</span></samp>, there is a lot of
information here that even the <samp><span class="command">awk</span></samp>
-expert should find useful. In particular, the description of POSIX
-<samp><span class="command">awk</span></samp> and the example programs in
-<a href="Library-Functions.html#Library-Functions">Library Functions</a>, and
in
-<a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-should be of interest.
-
- <p><a href="Getting-Started.html#Getting-Started">Getting Started</a>,
-provides the essentials you need to know to begin using <samp><span
class="command">awk</span></samp>.
-
- <p><a href="Regexp.html#Regexp">Regexp</a>,
-introduces regular expressions in general, and in particular the flavors
-supported by POSIX <samp><span class="command">awk</span></samp> and
<samp><span class="command">gawk</span></samp>.
-
- <p><a href="Reading-Files.html#Reading-Files">Reading Files</a>,
-describes how <samp><span class="command">awk</span></samp> reads your data.
-It introduces the concepts of records and fields, as well
-as the <code>getline</code> command.
-I/O redirection is first described here.
-
- <p><a href="Printing.html#Printing">Printing</a>,
-describes how <samp><span class="command">awk</span></samp> programs can
produce output with
-<code>print</code> and <code>printf</code>.
-
- <p><a href="Expressions.html#Expressions">Expressions</a>,
-describes expressions, which are the basic building blocks
-for getting most things done in a program.
-
- <p><a href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and
Actions</a>,
-describes how to write patterns for matching records, actions for
-doing something when a record is matched, and the built-in variables
-<samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp> use.
-
- <p><a href="Arrays.html#Arrays">Arrays</a>,
-covers <samp><span class="command">awk</span></samp>'s one-and-only data
structure: associative arrays.
-Deleting array elements and whole arrays is also described, as well as
-sorting arrays in <samp><span class="command">gawk</span></samp>.
-
- <p><a href="Functions.html#Functions">Functions</a>,
-describes the built-in functions <samp><span class="command">awk</span></samp>
and
-<samp><span class="command">gawk</span></samp> provide, as well as how to
define
-your own functions.
-
- <p><a
href="Internationalization.html#Internationalization">Internationalization</a>,
-describes special features in <samp><span class="command">gawk</span></samp>
for translating program
-messages into different languages at runtime.
-
- <p><a href="Advanced-Features.html#Advanced-Features">Advanced Features</a>,
-describes a number of <samp><span class="command">gawk</span></samp>-specific
advanced features.
-Of particular note
-are the abilities to have two-way communications with another process,
-perform TCP/IP networking, and
-profile your <samp><span class="command">awk</span></samp> programs.
-
- <p><a href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>,
-describes how to run <samp><span class="command">gawk</span></samp>, the
meaning of its
-command-line options, and how it finds <samp><span
class="command">awk</span></samp>
-program source files.
-
- <p><a href="Library-Functions.html#Library-Functions">Library
Functions</a>, and
-<a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>,
-provide many sample <samp><span class="command">awk</span></samp> programs.
-Reading them allows you to see <samp><span class="command">awk</span></samp>
-solving real problems.
-
- <p><a href="Language-History.html#Language-History">Language History</a>,
-describes how the <samp><span class="command">awk</span></samp> language has
evolved since
-first release to present. It also describes how <samp><span
class="command">gawk</span></samp>
-has acquired features over time.
-
- <p><a href="Installation.html#Installation">Installation</a>,
-describes how to get <samp><span class="command">gawk</span></samp>, how to
compile it
-under Unix, and how to compile and use it on different
-non-Unix systems. It also describes how to report bugs
-in <samp><span class="command">gawk</span></samp> and where to get three other
freely
-available implementations of <samp><span class="command">awk</span></samp>.
-
- <p><a href="Notes.html#Notes">Notes</a>,
-describes how to disable <samp><span class="command">gawk</span></samp>'s
extensions, as
-well as how to contribute new code to <samp><span
class="command">gawk</span></samp>,
-how to write extension libraries, and some possible
-future directions for <samp><span class="command">gawk</span></samp>
development.
-
- <p><a href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>,
-provides some very cursory background material for those who
-are completely unfamiliar with computer programming.
-Also centralized there is a discussion of some of the issues
-surrounding floating-point numbers.
-
- <p>The
-<a href="Glossary.html#Glossary">Glossary</a>,
-defines most, if not all, the significant terms used
-throughout the book.
-If you find terms that you aren't familiar with, try looking them up here.
-
- <p><a href="Copying.html#Copying">Copying</a>, and
-<a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>,
-present the licenses that cover the <samp><span
class="command">gawk</span></samp> source code
-and this Web page, respectively.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> All such differences
-appear in the index under the
-entry “differences in <samp><span class="command">awk</span></samp> and
<samp><span class="command">gawk</span></samp>.”</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Time-Functions.html
===================================================================
RCS file: manual/html_node/Time-Functions.html
diff -N manual/html_node/Time-Functions.html
--- manual/html_node/Time-Functions.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,370 +0,0 @@
-<html lang="en">
-<head>
-<title>Time Functions - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din.html#Built_002din" title="Built-in">
-<link rel="prev" href="I_002fO-Functions.html#I_002fO-Functions" title="I/O
Functions">
-<link rel="next" href="Bitwise-Functions.html#Bitwise-Functions"
title="Bitwise Functions">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Time-Functions"></a>Next: <a rel="next" accesskey="n"
href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>,
-Previous: <a rel="previous" accesskey="p"
href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din.html#Built_002din">Built-in</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">8.1.5 Using <samp><span
class="command">gawk</span></samp>'s Timestamp Functions</h4>
-
-<!-- STARTOFRANGE tst -->
-<p><a name="index-timestamps-1228"></a><!-- STARTOFRANGE logftst -->
-<a name="index-log-files_002c-timestamps-in-1229"></a><!-- STARTOFRANGE
filogtst -->
-<a name="index-files_002c-log_0040comma_007b_007d-timestamps-in-1230"></a><!--
STARTOFRANGE gawtst -->
-<a name="index-_0040command_007bgawk_007d_002c-timestamps-1231"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-timestamps-and-1232"></a><code>awk</code>
programs are commonly used to process log files
-containing timestamp information, indicating when a
-particular log record was written. Many programs log their timestamp
-in the form returned by the <code>time</code> system call, which is the
-number of seconds since a particular epoch. On POSIX-compliant systems,
-it is the number of seconds since
-1970-01-01 00:00:00 UTC, not counting leap seconds.<a rel="footnote"
href="#fn-1" name="fnd-1"><sup>1</sup></a>
-All known POSIX-compliant systems support timestamps from 0 through
-2^31 - 1, which is sufficient to represent times through
-2038-01-19 03:14:07 UTC. Many systems support a wider range of timestamps,
-including negative timestamps that represent times before the
-epoch.
-
- <p><a name="index-_0040command_007bdate_007d-utility_002c-GNU-1233"></a><a
name="index-time_002c-retrieving-1234"></a>In order to make it easier to
process such log files and to produce
-useful reports, <samp><span class="command">gawk</span></samp> provides the
following functions for
-working with timestamps. They are <samp><span
class="command">gawk</span></samp> extensions; they are
-not specified in the POSIX standard, nor are they in any other known
-version of <samp><span class="command">awk</span></samp>.<a rel="footnote"
href="#fn-2" name="fnd-2"><sup>2</sup></a>
-Optional parameters are enclosed in square brackets ([ ]):
-
- <dl>
-<dt><code>systime()</code><dd><a
name="index-_0040code_007bsystime_007d-function-_0028_0040command_007bgawk_007d_0029-1235"></a><a
name="index-timestamps-1236"></a>This function returns the current time as the
number of seconds since
-the system epoch. On POSIX systems, this is the number of seconds
-since 1970-01-01 00:00:00 UTC, not counting leap seconds.
-It may be a different number on
-other systems.
-
- <br><dt><code>mktime(</code><var>datespec</var><code>)</code><dd><a
name="index-_0040code_007bmktime_007d-function-_0028_0040command_007bgawk_007d_0029-1237"></a>This
function turns <var>datespec</var> into a timestamp in the same form
-as is returned by <code>systime</code>. It is similar to the function of the
-same name in ISO C. The argument, <var>datespec</var>, is a string of the form
-<code>"</code><var>YYYY</var><code> </code><var>MM</var><code> </code><var>DD</var><code> </code><var>HH</var><code> </code><var>MM</var><code> </code><var>SS</var><code> [</code><var>DST</var><code>]"</code><!--
/@w -->.
-The string consists of six or seven numbers representing, respectively,
-the full year including century, the month from 1 to 12, the day of the month
-from 1 to 31, the hour of the day from 0 to 23, the minute from 0 to
-59, the second from 0 to 60,<a rel="footnote" href="#fn-3"
name="fnd-3"><sup>3</sup></a>
-and an optional daylight-savings flag.
-
- <p>The values of these numbers need not be within the ranges specified;
-for example, an hour of −1 means 1 hour before midnight.
-The origin-zero Gregorian calendar is assumed, with year 0 preceding
-year 1 and year −1 preceding year 0.
-The time is assumed to be in the local timezone.
-If the daylight-savings flag is positive, the time is assumed to be
-daylight savings time; if zero, the time is assumed to be standard
-time; and if negative (the default), <code>mktime</code> attempts to determine
-whether daylight savings time is in effect for the specified time.
-
- <p>If <var>datespec</var> does not contain enough elements or if the
resulting time
-is out of range, <code>mktime</code> returns −1.
-
- <br><dt><code>strftime(</code><span
class="roman">[</span><var>format</var> <span class="roman">[</span><code>,
</code><var>timestamp</var><span class="roman">]]</span><code>)</code><dd><!--
STARTOFRANGE strf -->
-<a
name="index-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1238"></a>This
function returns a string. It is similar to the function of the
-same name in ISO C. The time specified by <var>timestamp</var> is used to
-produce a string, based on the contents of the <var>format</var> string.
-The <var>timestamp</var> is in the same format as the value returned by the
-<code>systime</code> function. If no <var>timestamp</var> argument is
supplied,
-<samp><span class="command">gawk</span></samp> uses the current time of day as
the timestamp.
-If no <var>format</var> argument is supplied, <code>strftime</code> uses
-<code>"%a %b %d %H:%M:%S %Z %Y"<!-- /@w --></code>.
This format string produces
-output that is (almost) equivalent to that of the <samp><span
class="command">date</span></samp> utility.
-(Versions of <samp><span class="command">gawk</span></samp> prior to 3.0
require the <var>format</var> argument.)
-</dl>
-
- <p>The <code>systime</code> function allows you to compare a timestamp from
a
-log file with the current time of day. In particular, it is easy to
-determine how long ago a particular record was logged. It also allows
-you to produce log records using the “seconds since the epoch”
format.
-
- <p><a name="index-converting_002c-dates-to-timestamps-1239"></a><a
name="index-dates_002c-converting-to-timestamps-1240"></a><a
name="index-timestamps_002c-converting-dates-to-1241"></a>The
<code>mktime</code> function allows you to convert a textual representation
-of a date and time into a timestamp. This makes it easy to do before/after
-comparisons of dates and times, particularly when dealing with date and
-time data coming from an external source, such as a log file.
-
- <p>The <code>strftime</code> function allows you to easily turn a timestamp
-into human-readable information. It is similar in nature to the
<code>sprintf</code>
-function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>),
-in that it copies nonformat specification characters verbatim to the
-returned string, while substituting date and time values for format
-specifications in the <var>format</var> string.
-
- <p><a
name="index-format-specifiers_002c-_0040code_007bstrftime_007d-function-_0028_0040command_007bgawk_007d_0029-1242"></a><code>strftime</code>
is guaranteed by the 1999 ISO C standard<a rel="footnote" href="#fn-4"
name="fnd-4"><sup>4</sup></a>
-to support the following date format specifications:
-
- <dl>
-<dt><code>%a</code><dd>The locale's abbreviated weekday name.
-
- <br><dt><code>%A</code><dd>The locale's full weekday name.
-
- <br><dt><code>%b</code><dd>The locale's abbreviated month name.
-
- <br><dt><code>%B</code><dd>The locale's full month name.
-
- <br><dt><code>%c</code><dd>The locale's “appropriate” date
and time representation.
-(This is `<samp><span class="samp">%A %B %d %T %Y</span></samp>' in the
<code>"C"</code> locale.)
-
- <br><dt><code>%C</code><dd>The century. This is the year divided by 100
and truncated to the next
-lower integer.
-
- <br><dt><code>%d</code><dd>The day of the month as a decimal number
(01–31).
-
- <br><dt><code>%D</code><dd>Equivalent to specifying `<samp><span
class="samp">%m/%d/%y</span></samp>'.
-
- <br><dt><code>%e</code><dd>The day of the month, padded with a space if
it is only one digit.
-
- <br><dt><code>%F</code><dd>Equivalent to specifying `<samp><span
class="samp">%Y-%m-%d</span></samp>'.
-This is the ISO 8601 date format.
-
- <br><dt><code>%g</code><dd>The year modulo 100 of the ISO week number, as
a decimal number (00–99).
-For example, January 1, 1993 is in week 53 of 1992. Thus, the year
-of its ISO week number is 1992, even though its year is 1993.
-Similarly, December 31, 1973 is in week 1 of 1974. Thus, the year
-of its ISO week number is 1974, even though its year is 1973.
-
- <br><dt><code>%G</code><dd>The full year of the ISO week number, as a
decimal number.
-
- <br><dt><code>%h</code><dd>Equivalent to `<samp><span
class="samp">%b</span></samp>'.
-
- <br><dt><code>%H</code><dd>The hour (24-hour clock) as a decimal number
(00–23).
-
- <br><dt><code>%I</code><dd>The hour (12-hour clock) as a decimal number
(01–12).
-
- <br><dt><code>%j</code><dd>The day of the year as a decimal number
(001–366).
-
- <br><dt><code>%m</code><dd>The month as a decimal number (01–12).
-
- <br><dt><code>%M</code><dd>The minute as a decimal number (00–59).
-
- <br><dt><code>%n</code><dd>A newline character (ASCII LF).
-
- <br><dt><code>%p</code><dd>The locale's equivalent of the AM/PM
designations associated
-with a 12-hour clock.
-
- <br><dt><code>%r</code><dd>The locale's 12-hour clock time.
-(This is `<samp><span class="samp">%I:%M:%S %p</span></samp>' in the
<code>"C"</code> locale.)
-
- <br><dt><code>%R</code><dd>Equivalent to specifying `<samp><span
class="samp">%H:%M</span></samp>'.
-
- <br><dt><code>%S</code><dd>The second as a decimal number (00–60).
-
- <br><dt><code>%t</code><dd>A TAB character.
-
- <br><dt><code>%T</code><dd>Equivalent to specifying `<samp><span
class="samp">%H:%M:%S</span></samp>'.
-
- <br><dt><code>%u</code><dd>The weekday as a decimal number (1–7).
Monday is day one.
-
- <br><dt><code>%U</code><dd>The week number of the year (the first Sunday
as the first day of week one)
-as a decimal number (00–53).
-
- <!-- @cindex ISO 8601 -->
-<br><dt><code>%V</code><dd>The week number of the year (the first Monday as
the first
-day of week one) as a decimal number (01–53).
-The method for determining the week number is as specified by ISO 8601.
-(To wit: if the week containing January 1 has four or more days in the
-new year, then it is week one; otherwise it is week 53 of the previous year
-and the next week is week one.)
-
- <br><dt><code>%w</code><dd>The weekday as a decimal number (0–6).
Sunday is day zero.
-
- <br><dt><code>%W</code><dd>The week number of the year (the first Monday
as the first day of week one)
-as a decimal number (00–53).
-
- <br><dt><code>%x</code><dd>The locale's “appropriate” date
representation.
-(This is `<samp><span class="samp">%A %B %d %Y</span></samp>' in the
<code>"C"</code> locale.)
-
- <br><dt><code>%X</code><dd>The locale's “appropriate” time
representation.
-(This is `<samp><span class="samp">%T</span></samp>' in the <code>"C"</code>
locale.)
-
- <br><dt><code>%y</code><dd>The year modulo 100 as a decimal number
(00–99).
-
- <br><dt><code>%Y</code><dd>The full year as a decimal number (e.g., 1995).
-
- <!-- @cindex RFC 822 -->
-<!-- @cindex RFC 1036 -->
-<br><dt><code>%z</code><dd>The timezone offset in a +HHMM format (e.g., the
format necessary to
-produce RFC 822/RFC 1036 date headers).
-
- <br><dt><code>%Z</code><dd>The time zone name or abbreviation; no
characters if
-no time zone is determinable.
-
- <br><dt><code>%Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH</code><dt><code>%OI %Om
%OM %OS %Ou %OU %OV %Ow %OW %Oy</code><dd>“Alternate
representations” for the specifications
-that use only the second letter (`<samp><span class="samp">%c</span></samp>',
`<samp><span class="samp">%C</span></samp>',
-and so on).<a rel="footnote" href="#fn-5" name="fnd-5"><sup>5</sup></a>
-(These facilitate compliance with the POSIX <samp><span
class="command">date</span></samp> utility.)
-
- <br><dt><code>%%</code><dd>A literal `<samp><span
class="samp">%</span></samp>'.
-</dl>
-
- <p>If a conversion specifier is not one of the above, the behavior is
-undefined.<a rel="footnote" href="#fn-6" name="fnd-6"><sup>6</sup></a>
-
-<!-- @cindex locale, definition of -->
-<p>Informally, a <dfn>locale</dfn> is the geographic place in which a program
-is meant to run. For example, a common way to abbreviate the date
-September 4, 1991 in the United States is “9/4/91.”
-In many countries in Europe, however, it is abbreviated “4.9.91.”
-Thus, the `<samp><span class="samp">%x</span></samp>' specification in a
<code>"US"</code> locale might produce
-`<samp><span class="samp">9/4/91</span></samp>', while in a
<code>"EUROPE"</code> locale, it might produce
-`<samp><span class="samp">4.9.91</span></samp>'. The ISO C standard defines a
default <code>"C"</code>
-locale, which is an environment that is typical of what most C programmers
-are used to.
-
- <p>A public-domain C version of <code>strftime</code> is supplied with
<samp><span class="command">gawk</span></samp>
-for systems that are not yet fully standards-compliant.
-It supports all of the just listed format specifications.
-If that version is
-used to compile <samp><span class="command">gawk</span></samp> (see <a
href="Installation.html#Installation">Installation</a>),
-then the following additional format specifications are available:
-
- <dl>
-<dt><code>%k</code><dd>The hour (24-hour clock) as a decimal number
(0–23).
-Single-digit numbers are padded with a space.
-
- <br><dt><code>%l</code><dd>The hour (12-hour clock) as a decimal number
(1–12).
-Single-digit numbers are padded with a space.
-
- <br><dt><code>%N</code><dd>The “Emperor/Era” name.
-Equivalent to <code>%C</code>.
-
- <br><dt><code>%o</code><dd>The “Emperor/Era” year.
-Equivalent to <code>%y</code>.
-
- <br><dt><code>%s</code><dd>The time as a decimal timestamp in seconds
since the epoch.
-
- <br><dt><code>%v</code><dd>The date in VMS format (e.g., `<samp><span
class="samp">20-JUN-1991</span></samp>').
-</dl>
- <!-- ENDOFRANGE strf -->
-
- <p>Additionally, the alternate representations are recognized but their
-normal representations are used.
-
- <p><a name="index-_0040code_007bdate_007d-utility_002c-POSIX-1243"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bdate_007d-utility-and-1244"></a>This
example is an <samp><span class="command">awk</span></samp> implementation of
the POSIX
-<samp><span class="command">date</span></samp> utility. Normally, the
<samp><span class="command">date</span></samp> utility prints the
-current date and time of day in a well-known format. However, if you
-provide an argument to it that begins with a `<samp><span
class="samp">+</span></samp>', <samp><span class="command">date</span></samp>
-copies nonformat specifier characters to the standard output and
-interprets the current time according to the format specifiers in
-the string. For example:
-
-<pre class="example"> $ date '+Today is %A, %B %d, %Y.'
- -| Today is Thursday, September 14, 2000.
-</pre>
- <p>Here is the <samp><span class="command">gawk</span></samp> version of
the <samp><span class="command">date</span></samp> utility.
-It has a shell “wrapper” to handle the <samp><span
class="option">-u</span></samp> option,
-which requires that <samp><span class="command">date</span></samp> run as if
the time zone
-is set to UTC:
-
-<pre class="example"> #! /bin/sh
- #
- # date --- approximate the P1003.2 'date' command
-
- case $1 in
- -u) TZ=UTC0 # use UTC
- export TZ
- shift ;;
- esac
-
- <!-- FIXME: One day, change %d to %e, when C 99 is common. -->
- gawk 'BEGIN {
- format = "%a %b %d %H:%M:%S %Z %Y"
- exitval = 0
-
- if (ARGC > 2)
- exitval = 1
- else if (ARGC == 2) {
- format = ARGV[1]
- if (format ~ /^\+/)
- format = substr(format, 2) # remove leading +
- }
- print strftime(format)
- exit exitval
- }' "$@"
-</pre>
- <!-- ENDOFRANGE tst -->
-<!-- ENDOFRANGE logftst -->
-<!-- ENDOFRANGE filogtst -->
-<!-- ENDOFRANGE gawtst -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> See <a href="Glossary.html#Glossary">Glossary</a>,
-especially the entries “Epoch” and “UTC.”</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> The
GNU <samp><span class="command">date</span></samp> utility can
-also do many of the things described here. Its use may be preferable
-for simple time-related operations in shell scripts.</p>
-
- <p class="footnote"><small>[<a name="fn-3" href="#fnd-3">3</a>]</small>
Occasionally there are
-minutes in a year with a leap second, which is why the
-seconds can go up to 60.</p>
-
- <p class="footnote"><small>[<a name="fn-4" href="#fnd-4">4</a>]</small> As
this
-is a recent standard, not every system's <code>strftime</code> necessarily
-supports all of the conversions listed here.</p>
-
- <p class="footnote"><small>[<a name="fn-5" href="#fnd-5">5</a>]</small> If
you don't understand any of this, don't worry about
-it; these facilities are meant to make it easier to
“internationalize”
-programs.
-Other internationalization features are described in
-<a
href="Internationalization.html#Internationalization">Internationalization</a>.</p>
-
- <p class="footnote"><small>[<a name="fn-6" href="#fnd-6">6</a>]</small>
This is because ISO C leaves the
-behavior of the C version of <code>strftime</code> undefined and <samp><span
class="command">gawk</span></samp>
-uses the system's version of <code>strftime</code> if it's there.
-Typically, the conversion specifier either does not appear in the
-returned string or appears literally.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Translate-Program.html
===================================================================
RCS file: manual/html_node/Translate-Program.html
diff -N manual/html_node/Translate-Program.html
--- manual/html_node/Translate-Program.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,193 +0,0 @@
-<html lang="en">
-<head>
-<title>Translate Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Alarm-Program.html#Alarm-Program" title="Alarm Program">
-<link rel="next" href="Labels-Program.html#Labels-Program" title="Labels
Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Translate-Program"></a>Next: <a rel="next" accesskey="n"
href="Labels-Program.html#Labels-Program">Labels Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Alarm-Program.html#Alarm-Program">Alarm Program</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.3 Transliterating Characters</h4>
-
-<!-- STARTOFRANGE chtra -->
-<p><a name="index-characters_002c-transliterating-1797"></a><a
name="index-_0040command_007btr_007d-utility-1798"></a>The system <samp><span
class="command">tr</span></samp> utility transliterates characters. For
example, it is
-often used to map uppercase letters into lowercase for further processing:
-
-<pre class="example"> <var>generate data</var> | tr 'A-Z' 'a-z' |
<var>process data</var> ...
-</pre>
- <p><samp><span class="command">tr</span></samp> requires two lists of
characters.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> When
processing the input, the first character in the
-first list is replaced with the first character in the second list,
-the second character in the first list is replaced with the second
-character in the second list, and so on. If there are more characters
-in the “from” list than in the “to” list, the last
character of the
-“to” list is used for the remaining characters in the
“from” list.
-
- <p>Some time ago,
-<!-- early or mid-1989! -->
-a user proposed that a transliteration function should
-be added to <samp><span class="command">gawk</span></samp>.
-<!-- Wishing to avoid gratuitous new features, -->
-<!-- at least theoretically -->
-The following program was written to
-prove that character transliteration could be done with a user-level
-function. This program is not as complete as the system <samp><span
class="command">tr</span></samp> utility
-but it does most of the job.
-
- <p>The <samp><span class="command">translate</span></samp> program
demonstrates one of the few weaknesses
-of standard <samp><span class="command">awk</span></samp>: dealing with
individual characters is very
-painful, requiring repeated use of the <code>substr</code>, <code>index</code>,
-and <code>gsub</code> built-in functions
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).<a
rel="footnote" href="#fn-2" name="fnd-2"><sup>2</sup></a>
-<!-- Exercise: How might you use this new feature to simplify the program? -->
-There are two functions. The first, <code>stranslate</code>, takes three
-arguments:
-
- <dl>
-<dt><code>from</code><dd>A list of characters from which to translate.
-
- <br><dt><code>to</code><dd>A list of characters to which to translate.
-
- <br><dt><code>target</code><dd>The string on which to do the translation.
-</dl>
-
- <p>Associative arrays make the translation part fairly easy.
<code>t_ar</code> holds
-the “to” characters, indexed by the “from” characters.
Then a simple
-loop goes through <code>from</code>, one character at a time. For each
character
-in <code>from</code>, if the character appears in <code>target</code>,
<code>gsub</code>
-is used to change it to the corresponding <code>to</code> character.
-
- <p>The <code>translate</code> function simply calls <code>stranslate</code>
using <code>$0</code>
-as the target. The main program sets two global variables, <code>FROM</code>
and
-<code>TO</code>, from the command line, and then changes <code>ARGV</code> so
that
-<samp><span class="command">awk</span></samp> reads from the standard input.
-
- <p>Finally, the processing rule simply calls <code>translate</code> for
each record:
-
- <p><a name="index-_0040code_007btranslate_002eawk_007d-program-1799"></a>
-<pre class="example"> <!-- file eg/prog/translate.awk -->
- # translate.awk --- do tr-like stuff
- <!-- endfile -->
- <!-- file eg/prog/translate.awk -->
- # Bugs: does not handle things like: tr A-Z a-z, it has
- # to be spelled out. However, if `to' is shorter than `from',
- # the last character in `to' is used for the rest of `from'.
-
- function stranslate(from, to, target, lf, lt, t_ar, i, c)
- {
- lf = length(from)
- lt = length(to)
- for (i = 1; i <= lt; i++)
- t_ar[substr(from, i, 1)] = substr(to, i, 1)
- if (lt < lf)
- for (; i <= lf; i++)
- t_ar[substr(from, i, 1)] = substr(to, lt, 1)
- for (i = 1; i <= lf; i++) {
- c = substr(from, i, 1)
- if (index(target, c) > 0)
- gsub(c, t_ar[c], target)
- }
- return target
- }
-
- function translate(from, to)
- {
- return $0 = stranslate(from, to, $0)
- }
-
- # main program
- BEGIN {
- if (ARGC < 3) {
- print "usage: translate from to" > "/dev/stderr"
- exit
- }
- FROM = ARGV[1]
- TO = ARGV[2]
- ARGC = 2
- ARGV[1] = "-"
- }
-
- {
- translate(FROM, TO)
- print
- }
- <!-- endfile -->
-</pre>
- <p>While it is possible to do character transliteration in a user-level
-function, it is not necessarily efficient, and we (the <samp><span
class="command">gawk</span></samp>
-authors) started to consider adding a built-in function. However,
-shortly after writing this program, we learned that the System V Release 4
-<samp><span class="command">awk</span></samp> had added the
<code>toupper</code> and <code>tolower</code> functions
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-These functions handle the vast majority of the
-cases where character transliteration is necessary, and so we chose to
-simply add those functions to <samp><span class="command">gawk</span></samp>
as well and then leave well
-enough alone.
-
- <p>An obvious improvement to this program would be to set up the
-<code>t_ar</code> array only once, in a <code>BEGIN</code> rule. However, this
-assumes that the “from” and “to” lists
-will never change throughout the lifetime of the program.
-<!-- ENDOFRANGE chtra -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> On some older
-System V systems,
-<samp><span class="command">tr</span></samp> may require that the lists be
written as
-range expressions enclosed in square brackets (`<samp><span
class="samp">[a-z]</span></samp>') and quoted,
-to prevent the shell from attempting a file name expansion. This is
-not a feature.</p>
-
- <p class="footnote"><small>[<a name="fn-2" href="#fnd-2">2</a>]</small> This
-program was written before <samp><span class="command">gawk</span></samp>
acquired the ability to
-split each character in a string into separate array elements.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Translator-i18n.html
===================================================================
RCS file: manual/html_node/Translator-i18n.html
diff -N manual/html_node/Translator-i18n.html
--- manual/html_node/Translator-i18n.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-<html lang="en">
-<head>
-<title>Translator i18n - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Internationalization.html#Internationalization"
title="Internationalization">
-<link rel="prev" href="Programmer-i18n.html#Programmer-i18n" title="Programmer
i18n">
-<link rel="next" href="I18N-Example.html#I18N-Example" title="I18N Example">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Translator-i18n"></a>Next: <a rel="next" accesskey="n"
href="I18N-Example.html#I18N-Example">I18N Example</a>,
-Previous: <a rel="previous" accesskey="p"
href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a>,
-Up: <a rel="up" accesskey="u"
href="Internationalization.html#Internationalization">Internationalization</a>
-<hr><br>
-</div>
-
-<h3 class="section">9.4 Translating <samp><span
class="command">awk</span></samp> Programs</h3>
-
-<p><a name="index-_0040code_007b_002epo_007d-files-1358"></a><a
name="index-files_002c-_0040code_007b_002epo_007d-1359"></a><a
name="index-portable-object-files-1360"></a><a
name="index-files_002c-portable-object-1361"></a>Once a program's translatable
strings have been marked, they must
-be extracted to create the initial <samp><span class="file">.po</span></samp>
file.
-As part of translation, it is often helpful to rearrange the order
-in which arguments to <code>printf</code> are output.
-
- <p><samp><span class="command">gawk</span></samp>'s <samp><span
class="option">--gen-po</span></samp> command-line option extracts
-the messages and is discussed next.
-After that, <code>printf</code>'s ability to
-rearrange the order for <code>printf</code> arguments at runtime
-is covered.
-
-<ul class="menu">
-<li><a accesskey="1" href="String-Extraction.html#String-Extraction">String
Extraction</a>: Extracting marked strings.
-<li><a accesskey="2" href="Printf-Ordering.html#Printf-Ordering">Printf
Ordering</a>: Rearranging <code>printf</code> arguments.
-<li><a accesskey="3" href="I18N-Portability.html#I18N-Portability">I18N
Portability</a>: <samp><span
class="command">awk</span></samp>-level portability issues.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Truth-Values.html
===================================================================
RCS file: manual/html_node/Truth-Values.html
diff -N manual/html_node/Truth-Values.html
--- manual/html_node/Truth-Values.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-<html lang="en">
-<head>
-<title>Truth Values - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Increment-Ops.html#Increment-Ops" title="Increment Ops">
-<link rel="next" href="Typing-and-Comparison.html#Typing-and-Comparison"
title="Typing and Comparison">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Truth-Values"></a>Next: <a rel="next" accesskey="n"
href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>,
-Previous: <a rel="previous" accesskey="p"
href="Increment-Ops.html#Increment-Ops">Increment Ops</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.9 True and False in <samp><span
class="command">awk</span></samp></h3>
-
-<p><a name="index-truth-values-731"></a><a
name="index-logical-false_002ftrue-732"></a><a
name="index-false_002c-logical-733"></a><a
name="index-true_002c-logical-734"></a>
-<a name="index-null-strings-735"></a>Many programming languages have a special
representation for the concepts
-of “true” and “false.” Such languages usually use the
special
-constants <code>true</code> and <code>false</code>, or perhaps their uppercase
-equivalents.
-However, <samp><span class="command">awk</span></samp> is different.
-It borrows a very simple concept of true and
-false from C. In <samp><span class="command">awk</span></samp>, any nonzero
numeric value <em>or</em> any
-nonempty string value is true. Any other value (zero or the null
-string <code>""</code>) is false. The following program prints `<samp><span
class="samp">A strange
-truth value</span></samp>' three times:
-
-<pre class="example"> BEGIN {
- if (3.1415927)
- print "A strange truth value"
- if ("Four Score And Seven Years Ago")
- print "A strange truth value"
- if (j = 57)
- print "A strange truth value"
- }
-</pre>
- <p><a name="index-dark-corner-736"></a>There is a surprising consequence of
the “nonzero or non-null” rule:
-the string constant <code>"0"</code> is actually true, because it is non-null.
-(d.c.)
-
- </body></html>
-
Index: manual/html_node/Two-Rules.html
===================================================================
RCS file: manual/html_node/Two-Rules.html
diff -N manual/html_node/Two-Rules.html
--- manual/html_node/Two-Rules.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,106 +0,0 @@
-<html lang="en">
-<head>
-<title>Two Rules - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="Very-Simple.html#Very-Simple" title="Very Simple">
-<link rel="next" href="More-Complex.html#More-Complex" title="More Complex">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Two-Rules"></a>Next: <a rel="next" accesskey="n"
href="More-Complex.html#More-Complex">More Complex</a>,
-Previous: <a rel="previous" accesskey="p"
href="Very-Simple.html#Very-Simple">Very Simple</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.4 An Example with Two Rules</h3>
-
-<p><a name="index-_0040command_007bawk_007d-programs-143"></a>
-The <samp><span class="command">awk</span></samp> utility reads the input
files one line at a
-time. For each line, <samp><span class="command">awk</span></samp> tries the
patterns of each of the rules.
-If several patterns match, then several actions are run in the order in
-which they appear in the <samp><span class="command">awk</span></samp>
program. If no patterns match, then
-no actions are run.
-
- <p>After processing all the rules that match the line (and perhaps there
are none),
-<samp><span class="command">awk</span></samp> reads the next line. (However,
-see <a href="Next-Statement.html#Next-Statement">Next Statement</a>,
-and also see <a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>).
-This continues until the program reaches the end of the file.
-For example, the following <samp><span class="command">awk</span></samp>
program contains two rules:
-
-<pre class="example"> /12/ { print $0 }
- /21/ { print $0 }
-</pre>
- <p class="noindent">The first rule has the string `<samp><span
class="samp">12</span></samp>' as the
-pattern and `<samp><span class="samp">print $0</span></samp>' as the action.
The second rule has the
-string `<samp><span class="samp">21</span></samp>' as the pattern and also has
`<samp><span class="samp">print $0</span></samp>' as the
-action. Each rule's action is enclosed in its own pair of braces.
-
- <p>This program prints every line that contains the string
-`<samp><span class="samp">12</span></samp>' <em>or</em> the string
`<samp><span class="samp">21</span></samp>'. If a line contains both
-strings, it is printed twice, once by each rule.
-
- <p>This is what happens if we run this program on our two sample data files,
-<samp><span class="file">BBS-list</span></samp> and <samp><span
class="file">inventory-shipped</span></samp>:
-
-<pre class="example"> $ awk '/12/ { print $0 }
- > /21/ { print $0 }' BBS-list inventory-shipped
- -| aardvark 555-5553 1200/300 B
- -| alpo-net 555-3412 2400/1200/300 A
- -| barfly 555-7685 1200/300 A
- -| bites 555-1675 2400/1200/300 A
- -| core 555-2912 1200/300 C
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sdace 555-3430 2400/1200/300 A
- -| sabafoo 555-2127 1200/300 C
- -| sabafoo 555-2127 1200/300 C
- -| Jan 21 36 64 620
- -| Apr 21 70 74 514
-</pre>
- <p class="noindent">Note how the line beginning with `<samp><span
class="samp">sabafoo</span></samp>'
-in <samp><span class="file">BBS-list</span></samp> was printed twice, once for
each rule.
-
- </body></html>
-
Index: manual/html_node/Two_002dway-I_002fO.html
===================================================================
RCS file: manual/html_node/Two_002dway-I_002fO.html
diff -N manual/html_node/Two_002dway-I_002fO.html
--- manual/html_node/Two_002dway-I_002fO.html 7 Feb 2007 02:36:56 -0000
1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,213 +0,0 @@
-<html lang="en">
-<head>
-<title>Two-way I/O - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Advanced-Features.html#Advanced-Features" title="Advanced
Features">
-<link rel="prev" href="Nondecimal-Data.html#Nondecimal-Data" title="Nondecimal
Data">
-<link rel="next" href="TCP_002fIP-Networking.html#TCP_002fIP-Networking"
title="TCP/IP Networking">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Two_002dway-I_002fO"></a>Next: <a rel="next" accesskey="n"
href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP Networking</a>,
-Previous: <a rel="previous" accesskey="p"
href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a>,
-Up: <a rel="up" accesskey="u"
href="Advanced-Features.html#Advanced-Features">Advanced Features</a>
-<hr><br>
-</div>
-
-<h3 class="section">10.2 Two-Way Communications with Another Process</h3>
-
-<p><a name="index-Brennan_002c-Michael-1405"></a><a
name="index-programmers_002c-attractiveness-of-1406"></a>
-<pre class="smallexample"> <!-- Path:
cssun.mathcs.emory.edu!gatech!newsxfer3.itd.umich.edu!news-peer.sprintlink.net!news-sea-19.sprintlink.net!news-in-west.sprintlink.net!news.sprintlink.net!Sprint!204.94.52.5!news.whidbey.com!brennan
-->
- From: address@hidden (Mike Brennan)
- Newsgroups: comp.lang.awk
- Subject: Re: Learn the SECRET to Attract Women Easily
- Date: 4 Aug 1997 17:34:46 GMT
- <!-- Organization: WhidbeyNet -->
- <!-- Lines: 12 -->
- Message-ID: <address@hidden>
- <!-- References: <address@hidden> -->
- <!-- Reply-To: address@hidden -->
- <!-- NNTP-Posting-Host: asn202.whidbey.com -->
- <!-- X-Newsreader: slrn (0.9.4.1 Unix) -->
- <!-- Xref: cssun.mathcs.emory.edu comp.lang.awk:5403 -->
-
- On 3 Aug 1997 13:17:43 GMT, Want More Dates???
- <address@hidden> wrote:
- >Learn the SECRET to Attract Women Easily
- >
- >The SCENT(tm) Pheromone Sex Attractant For Men to Attract Women
-
- The scent of awk programmers is a lot more attractive to women than
- the scent of perl programmers.
- --
- Mike Brennan
- <!-- brennan@@whidbey.com -->
-</pre>
- <p><a
name="index-advanced-features_002c-_0040command_007bgawk_007d_002c-processes_0040comma_007b_007d-communicating-with-1407"></a><a
name="index-processes_002c-two_002dway-communications-with-1408"></a>It is
often useful to be able to
-send data to a separate program for
-processing and then read the result. This can always be
-done with temporary files:
-
-<pre class="example"> # write the data for processing
- tempfile = ("mydata." PROCINFO["pid"])
- while (<var>not done with data</var>)
- print <var>data</var> | ("subprogram > " tempfile)
- close("subprogram > " tempfile)
-
- # read the results, remove tempfile when done
- while ((getline newdata < tempfile) > 0)
- <var>process</var> newdata <var>appropriately</var>
- close(tempfile)
- system("rm " tempfile)
-</pre>
- <p class="noindent">This works, but not elegantly. Among other things, it
requires that
-the program be run in a directory that cannot be shared among users;
-for example, <samp><span class="file">/tmp</span></samp> will not do, as
another user might happen
-to be using a temporary file with the same name.
-
- <p><a name="index-coprocesses-1409"></a><a
name="index-input_002foutput_002c-two_002dway-1410"></a><a
name="index-_0040code_007b_007c_007d-_0028vertical-bar_0029_002c-_0040code_007b_007c_0026_007d-operator-_0028I_002fO_0029-1411"></a><a
name="index-vertical-bar-_0028_0040code_007b_007c_007d_0029_002c-_0040code_007b_007c_0026_007d-I_002fO-operator-_0028I_002fO_0029-1412"></a><a
name="index-_0040command_007bcsh_007d-utility_002c-_0040code_007b_007c_0026_007d-operator_002c-comparison-with-1413"></a>Starting
with version 3.1 of <samp><span class="command">gawk</span></samp>, it is
possible to
-open a <em>two-way</em> pipe to another process. The second process is
-termed a <dfn>coprocess</dfn>, since it runs in parallel with <samp><span
class="command">gawk</span></samp>.
-The two-way connection is created using the new `<samp><span
class="samp">|&</span></samp>' operator
-(borrowed from the Korn shell, <samp><span
class="command">ksh</span></samp>):<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
-<pre class="example"> do {
- print <var>data</var> |& "subprogram"
- "subprogram" |& getline results
- } while (<var>data left to process</var>)
- close("subprogram")
-</pre>
- <p>The first time an I/O operation is executed using the `<samp><span
class="samp">|&</span></samp>'
-operator, <samp><span class="command">gawk</span></samp> creates a two-way
pipeline to a child process
-that runs the other program. Output created with <code>print</code>
-or <code>printf</code> is written to the program's standard input, and
-output from the program's standard output can be read by the <samp><span
class="command">gawk</span></samp>
-program using <code>getline</code>.
-As is the case with processes started by `<samp><span
class="samp">|</span></samp>', the subprogram
-can be any program, or pipeline of programs, that can be started by
-the shell.
-
- <p>There are some cautionary items to be aware of:
-
- <ul>
-<li>As the code inside <samp><span class="command">gawk</span></samp>
currently stands, the coprocess's
-standard error goes to the same place that the parent <samp><span
class="command">gawk</span></samp>'s
-standard error goes. It is not possible to read the child's
-standard error separately.
-
- <p><a name="index-deadlocks-1414"></a><a
name="index-buffering_002c-input_002foutput-1415"></a><a
name="index-_0040code_007bgetline_007d-command_002c-deadlock-and-1416"></a><li>I/O
buffering may be a problem. <samp><span class="command">gawk</span></samp>
automatically
-flushes all output down the pipe to the child process.
-However, if the coprocess does not flush its output,
-<samp><span class="command">gawk</span></samp> may hang when doing a
<code>getline</code> in order to read
-the coprocess's results. This could lead to a situation
-known as <dfn>deadlock</dfn>, where each process is waiting for the
-other one to do something.
-</ul>
-
- <p><a
name="index-_0040code_007bclose_007d-function_002c-two_002dway-pipes-and-1417"></a>It
is possible to close just one end of the two-way pipe to
-a coprocess, by supplying a second argument to the <code>close</code>
-function of either <code>"to"</code> or <code>"from"</code>
-(see <a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files
And Pipes</a>).
-These strings tell <samp><span class="command">gawk</span></samp> to close the
end of the pipe
-that sends data to the process or the end that reads from it,
-respectively.
-
- <p><a
name="index-_0040command_007bsort_007d-utility_002c-coprocesses-and-1418"></a>This
is particularly necessary in order to use
-the system <samp><span class="command">sort</span></samp> utility as part of a
coprocess;
-<samp><span class="command">sort</span></samp> must read <em>all</em> of its
input
-data before it can produce any output.
-The <samp><span class="command">sort</span></samp> program does not receive an
end-of-file indication
-until <samp><span class="command">gawk</span></samp> closes the write end of
the pipe.
-
- <p>When you have finished writing data to the <samp><span
class="command">sort</span></samp>
-utility, you can close the <code>"to"</code> end of the pipe, and
-then start reading sorted data via <code>getline</code>.
-For example:
-
-<pre class="example"> BEGIN {
- command = "LC_ALL=C sort"
- n = split("abcdefghijklmnopqrstuvwxyz", a, "")
-
- for (i = n; i > 0; i--)
- print a[i] |& command
- close(command, "to")
-
- while ((command |& getline line) > 0)
- print "got", line
- close(command)
- }
-</pre>
- <p>This program writes the letters of the alphabet in reverse order, one
-per line, down the two-way pipe to <samp><span
class="command">sort</span></samp>. It then closes the
-write end of the pipe, so that <samp><span class="command">sort</span></samp>
receives an end-of-file
-indication. This causes <samp><span class="command">sort</span></samp> to
sort the data and write the
-sorted data back to the <samp><span class="command">gawk</span></samp>
program. Once all of the data
-has been read, <samp><span class="command">gawk</span></samp> terminates the
coprocess and exits.
-
- <p>As a side note, the assignment `<samp><span
class="samp">LC_ALL=C</span></samp>' in the <samp><span
class="command">sort</span></samp>
-command ensures traditional Unix (ASCII) sorting from <samp><span
class="command">sort</span></samp>.
-
- <p>Beginning with <samp><span class="command">gawk</span></samp> 3.1.2, you
may use Pseudo-ttys (ptys) for
-two-way communication instead of pipes, if your system supports them.
-This is done on a per-command basis, by setting a special element
-in the <code>PROCINFO</code> array
-(see <a href="Auto_002dset.html#Auto_002dset">Auto-set</a>),
-like so:
-
-<pre class="example"> command = "sort -nr" # command, saved in
variable for convenience
- PROCINFO[command, "pty"] = 1 # update PROCINFO
- print ... |& command # start two-way pipe
- ...
-</pre>
- <p class="noindent">Using ptys avoids the buffer deadlock issues described
earlier, at some
-loss in performance. If your system does not have ptys, or if all the
-system's ptys are in use, <samp><span class="command">gawk</span></samp>
automatically falls back to
-using regular pipes.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> This is very
-different from the same operator in the C shell, <samp><span
class="command">csh</span></samp>.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Typing-and-Comparison.html
===================================================================
RCS file: manual/html_node/Typing-and-Comparison.html
diff -N manual/html_node/Typing-and-Comparison.html
--- manual/html_node/Typing-and-Comparison.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,257 +0,0 @@
-<html lang="en">
-<head>
-<title>Typing and Comparison - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Truth-Values.html#Truth-Values" title="Truth Values">
-<link rel="next" href="Boolean-Ops.html#Boolean-Ops" title="Boolean Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Typing-and-Comparison"></a>Next: <a rel="next" accesskey="n"
href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a>,
-Previous: <a rel="previous" accesskey="p"
href="Truth-Values.html#Truth-Values">Truth Values</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.10 Variable Typing and Comparison Expressions</h3>
-
-<blockquote>
-<i>The Guide is definitive. Reality is frequently inaccurate.</i><br>
-The Hitchhiker's Guide to the Galaxy
-</blockquote>
-
-<!-- STARTOFRANGE comex -->
-<p><a name="index-comparison-expressions-737"></a><!-- STARTOFRANGE excom -->
-<a name="index-expressions_002c-comparison-738"></a><a
name="index-expressions_002c-matching_002c-See-comparison-expressions-739"></a><a
name="index-matching_002c-expressions_002c-See-comparison-expressions-740"></a><a
name="index-relational-operators_002c-See-comparison-operators-741"></a><a
name="index-operators_002c-relational_002c-See-operators_0040comma_007b_007d-comparison-742"></a><!--
STARTOFRANGE varting -->
-<a name="index-variable-typing-743"></a><!-- STARTOFRANGE vartypc -->
-<a
name="index-variables_002c-types-of_002c-comparison-expressions-and-744"></a>Unlike
other programming languages, <samp><span class="command">awk</span></samp>
variables do not have a
-fixed type. Instead, they can be either a number or a string, depending
-upon the value that is assigned to them.
-
- <p><a name="index-numeric_002c-strings-745"></a><a
name="index-strings_002c-numeric-746"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-numeric-strings-and-747"></a>The
1992 POSIX standard introduced
-the concept of a <dfn>numeric string</dfn>, which is simply a string that looks
-like a number—for example, <code>" +2"<!-- /@w --></code>. This
concept is used
-for determining the type of a variable.
-The type of the variable is important because the types of two variables
-determine how they are compared.
-In <samp><span class="command">gawk</span></samp>, variable typing follows
these rules:
-
- <ul>
-<li>A numeric constant or the result of a numeric operation has the
<var>numeric</var>
-attribute.
-
- <li>A string constant or the result of a string operation has the
<var>string</var>
-attribute.
-
- <li>Fields, <code>getline</code> input, <code>FILENAME</code>,
<code>ARGV</code> elements,
-<code>ENVIRON</code> elements, and the
-elements of an array created by <code>split</code> that are numeric strings
-have the <var>strnum</var> attribute. Otherwise, they have the
<var>string</var>
-attribute.
-Uninitialized variables also have the <var>strnum</var> attribute.
-
- <li>Attributes propagate across assignments but are not changed by
-any use.
-<!-- (Although a use may cause the entity to acquire an additional -->
-<!-- value such that it has both a numeric and string value, this leaves the
-->
-<!-- attribute unchanged.) -->
-<!-- This is important but not relevant -->
-</ul>
-
- <p>The last rule is particularly important. In the following program,
-<code>a</code> has numeric type, even though it is later used in a string
-operation:
-
-<pre class="example"> BEGIN {
- a = 12.345
- b = a " is a cute number"
- print b
- }
-</pre>
- <p>When two operands are compared, either string comparison or numeric
comparison
-may be used. This depends upon the attributes of the operands, according to the
-following symmetric matrix:
-
-<!-- thanks to Karl Berry, address@hidden, for major help with TeX tables -->
-<pre class="display">
+——————————————————————–
- | STRING NUMERIC STRNUM
-
———–+——————————————————————–
- |
- STRING | string string string
- |
- NUMERIC | string numeric numeric
- |
- STRNUM | string numeric numeric
-
———–+——————————————————————–
-</pre>
- <p>The basic idea is that user input that looks numeric—and
<em>only</em>
-user input—should be treated as numeric, even though it is actually
-made of characters and is therefore also a string.
-Thus, for example, the string constant <code>" +3.14"</code><!-- /@w -->
-is a string, even though it looks numeric,
-and is <em>never</em> treated as number for comparison
-purposes.
-
- <p>In short, when one operand is a “pure” string, such as a
string
-constant, then a string comparison is performed. Otherwise, a
-numeric comparison is performed.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a>
-
- <p><dfn>Comparison expressions</dfn> compare strings or numbers for
-relationships such as equality. They are written using <dfn>relational
-operators</dfn>, which are a superset of those in C.
-<a
href="table_002drelational_002dops.html#table_002drelational_002dops">table-relational-ops</a>
describes them.
-
- <p><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_007d-operator-748"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_007d-operator-749"></a><a
name="index-_0040code_007b_003c_007d-_0028left-angle-bracket_0029_002c-_0040code_007b_003c_003d_007d-operator-750"></a><a
name="index-left-angle-bracket-_0028_0040code_007b_003c_007d_0029_002c-_0040code_007b_003c_003d_007d-operator-751"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_003d_007d-operator-752"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_003d_007d-operator-753"></a><a
name="index-_0040code_007b_003e_007d-_0028right-angle-bracket_0029_002c-_0040code_007b_003e_007d-operator-754"></a><a
name="index-right-angle-bracket-_0028_0040code_007b_003e_007d_0029_002c-_0040code_007b_003e_007d-operator-755"></a><a
name="index-_0040code_007b_003d_007d-_0028equals-sign_0029_002c-_0040code_007b_003d_003d_007d-operator-756"></a><a
name="index-equals-sign-_0028_0040code_007b_003d_007d_0029_002c-_0040code_007b_003d_003d_007d-operator-757"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_003d_007d-operator-758"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_003d_007d-operator-759"></a><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-760"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-761"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-762"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-763"></a><a
name="index-_0040code_007bin_007d-operator-764"></a><div class="float">
-<a name="table_002drelational_002dops"></a>
- <p><table summary=""><tr align="left"><th valign="top"
width="25%">Expression </th><th valign="top" width="75%">Result
-<br></th></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code><</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is less than <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code><=</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is less than or equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>></code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is greater than <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>>=</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is greater than or equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>==</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>!=</code> <var>y</var> </td><td valign="top" width="75%">True if
<var>x</var> is not equal to <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>~</code> <var>y</var> </td><td valign="top" width="75%">True if the
string <var>x</var> matches the regexp denoted by <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top" width="25%"><var>x</var>
<code>!~</code> <var>y</var> </td><td valign="top" width="75%">True if the
string <var>x</var> does not match the regexp denoted by <var>y</var>.
-<br></td></tr><tr align="left"><td valign="top"
width="25%"><var>subscript</var> <code>in</code> <var>array</var> </td><td
valign="top" width="75%">True if the array <var>array</var> has an element with
the subscript <var>subscript</var>.
- <br></td></tr></table>
-<p><strong class="float-caption">Table 5.2: Relational
Operators</strong></p></div>
-
- <p>Comparison expressions have the value one if true and zero if false.
-When comparing operands of mixed types, numeric operands are converted
-to strings using the value of <code>CONVFMT</code>
-(see <a href="Conversion.html#Conversion">Conversion</a>).
-
- <p>Strings are compared
-by comparing the first character of each, then the second character of each,
-and so on. Thus, <code>"10"</code> is less than <code>"9"</code>. If there
are two
-strings where one is a prefix of the other, the shorter string is less than
-the longer one. Thus, <code>"abc"</code> is less than <code>"abcd"</code>.
-
- <p><a
name="index-troubleshooting_002c-_0040code_007b_003d_003d_007d-operator-765"></a>It
is very easy to accidentally mistype the `<samp><span
class="samp">==</span></samp>' operator and
-leave off one of the `<samp><span class="samp">=</span></samp>' characters.
The result is still valid <samp><span class="command">awk</span></samp>
-code, but the program does not do what is intended:
-
-<pre class="example"> if (a = b) # oops! should be a == b
- ...
- else
- ...
-</pre>
- <p class="noindent">Unless <code>b</code> happens to be zero or the null
string, the <code>if</code>
-part of the test always succeeds. Because the operators are
-so similar, this kind of error is very difficult to spot when
-scanning the source code.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-comparison-operators-and-766"></a>The
following table of expressions illustrates the kind of comparison
-<samp><span class="command">gawk</span></samp> performs, as well as what the
result of the comparison is:
-
- <dl>
-<dt><code>1.5 <= 2.0</code><dd>numeric comparison (true)
-
- <br><dt><code>"abc" >= "xyz"</code><dd>string comparison (false)
-
- <br><dt><code>1.5 != " +2"</code><dd>string comparison (true)
-
- <br><dt><code>"1e2" < "3"</code><dd>string comparison (true)
-
- <br><dt><code>a = 2; b = "2"</code><dt><code>a == b</code><dd>string
comparison (true)
-
- <br><dt><code>a = 2; b = " +2"</code><br><dt><code>a ==
b</code><dd>string comparison (false)
-</dl>
-
- <p>In the next example:
-
-<pre class="example"> $ echo 1e2 3 | awk '{ print ($1 < $2) ? "true" :
"false" }'
- -| false
-</pre>
- <p><a
name="index-comparison-expressions_002c-string-vs_002e-regexp-767"></a><!--
@cindex string comparison vs. regexp comparison -->
-<!-- @cindex regexp comparison vs. string comparison -->
-the result is `<samp><span class="samp">false</span></samp>' because both
<code>$1</code> and <code>$2</code>
-are user input. They are numeric strings—therefore both have
-the <var>strnum</var> attribute, dictating a numeric comparison.
-The purpose of the comparison rules and the use of numeric strings is
-to attempt to produce the behavior that is “least surprising,”
while
-still “doing the right thing.”
-String comparisons and regular expression comparisons are very different.
-For example:
-
-<pre class="example"> x == "foo"
-</pre>
- <p class="noindent">has the value one, or is true if the variable
<code>x</code>
-is precisely `<samp><span class="samp">foo</span></samp>'. By contrast:
-
-<pre class="example"> x ~ /foo/
-</pre>
- <p class="noindent">has the value one if <code>x</code> contains
`<samp><span class="samp">foo</span></samp>', such as
-<code>"Oh, what a fool am I!"</code>.
-
- <p><a
name="index-_0040code_007b_007e_007d-_0028tilde_0029_002c-_0040code_007b_007e_007d-operator-768"></a><a
name="index-tilde-_0028_0040code_007b_007e_007d_0029_002c-_0040code_007b_007e_007d-operator-769"></a><a
name="index-_0040code_007b_0021_007d-_0028exclamation-point_0029_002c-_0040code_007b_0021_007e_007d-operator-770"></a><a
name="index-exclamation-point-_0028_0040code_007b_0021_007d_0029_002c-_0040code_007b_0021_007e_007d-operator-771"></a>The
righthand operand of the `<samp><span class="samp">~</span></samp>' and
`<samp><span class="samp">!~</span></samp>' operators may be
-either a regexp constant (<code>/.../</code>) or an ordinary
-expression. In the latter case, the value of the expression as a string is
used as a
-dynamic regexp (see <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>;
also
-see <a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>).
-
- <p><a
name="index-_0040command_007bawk_007d_002c-regexp-constants-and-772"></a><a
name="index-regexp-constants-773"></a>In modern implementations of <samp><span
class="command">awk</span></samp>, a constant regular
-expression in slashes by itself is also an expression. The regexp
-<code>/</code><var>regexp</var><code>/</code> is an abbreviation for the
following comparison expression:
-
-<pre class="example"> $0 ~ /<var>regexp</var>/
-</pre>
- <p>One special place where <code>/foo/</code> is <em>not</em> an
abbreviation for
-`<samp><span class="samp">$0 ~ /foo/</span></samp>' is when it is the
righthand operand of `<samp><span class="samp">~</span></samp>' or
-`<samp><span class="samp">!~</span></samp>'.
-See <a href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using
Constant Regexps</a>,
-where this is discussed in more detail.
-<!-- ENDOFRANGE comex -->
-<!-- ENDOFRANGE excom -->
-<!-- ENDOFRANGE vartypc -->
-<!-- ENDOFRANGE varting -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The POSIX standard is under
-revision. The revised standard's rules for typing and comparison are
-the same as just described for <samp><span
class="command">gawk</span></samp>.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Undocumented.html
===================================================================
RCS file: manual/html_node/Undocumented.html
diff -N manual/html_node/Undocumented.html
--- manual/html_node/Undocumented.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-<html lang="en">
-<head>
-<title>Undocumented - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Invoking-Gawk.html#Invoking-Gawk" title="Invoking Gawk">
-<link rel="prev" href="Obsolete.html#Obsolete" title="Obsolete">
-<link rel="next" href="Known-Bugs.html#Known-Bugs" title="Known Bugs">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Undocumented"></a>Next: <a rel="next" accesskey="n"
href="Known-Bugs.html#Known-Bugs">Known Bugs</a>,
-Previous: <a rel="previous" accesskey="p"
href="Obsolete.html#Obsolete">Obsolete</a>,
-Up: <a rel="up" accesskey="u"
href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>
-<hr><br>
-</div>
-
-<h3 class="section">11.6 Undocumented Options and Features</h3>
-
-<p><a name="index-undocumented-features-1578"></a><a
name="index-features_002c-undocumented-1579"></a><a
name="index-Skywalker_002c-Luke-1580"></a><a
name="index-Kenobi_002c-Obi_002dWan-1581"></a><a
name="index-Jedi-knights-1582"></a><a
name="index-Knights_002c-jedi-1583"></a><blockquote>
-<i>Use the Source, Luke!</i><br>
-Obi-Wan
-</blockquote>
-
- <p>This section intentionally left
-blank.
-
- </body></html>
-
Index: manual/html_node/Uninitialized-Subscripts.html
===================================================================
RCS file: manual/html_node/Uninitialized-Subscripts.html
diff -N manual/html_node/Uninitialized-Subscripts.html
--- manual/html_node/Uninitialized-Subscripts.html 31 Aug 2004 22:04:12
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,103 +0,0 @@
-<html lang="en">
-<head>
-<title>Uninitialized Subscripts - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Arrays.html#Arrays" title="Arrays">
-<link rel="prev" href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts"
title="Numeric Array Subscripts">
-<link rel="next" href="Multi_002ddimensional.html#Multi_002ddimensional"
title="Multi-dimensional">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Uninitialized-Subscripts"></a>Next: <a rel="next" accesskey="n"
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a>,
-Previous: <a rel="previous" accesskey="p"
href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric Array
Subscripts</a>,
-Up: <a rel="up" accesskey="u" href="Arrays.html#Arrays">Arrays</a>
-<hr><br>
-</div>
-
-<h3 class="section">7.8 Using Uninitialized Variables as Subscripts</h3>
-
-<p><a
name="index-variables_002c-uninitialized_0040comma_007b_007d-as-array-subscripts-1120"></a><a
name="index-uninitialized-variables_002c-as-array-subscripts-1121"></a><a
name="index-subscripts-in-arrays_002c-uninitialized-variables-as-1122"></a><a
name="index-arrays_002c-subscripts_002c-uninitialized-variables-as-1123"></a>Suppose
it's necessary to write a program
-to print the input data in reverse order.
-A reasonable attempt to do so (with some test
-data) might look like this:
-
-<pre class="example"> $ echo 'line 1
- > line 2
- > line 3' | awk '{ l[lines] = $0; ++lines }
- > END {
- > for (i = lines-1; i >= 0; --i)
- > print l[i]
- > }'
- -| line 3
- -| line 2
-</pre>
- <p>Unfortunately, the very first line of input data did not come out in the
-output!
-
- <p>At first glance, this program should have worked. The variable
<code>lines</code>
-is uninitialized, and uninitialized variables have the numeric value zero.
-So, <samp><span class="command">awk</span></samp> should have printed the
value of <code>l[0]</code>.
-
- <p>The issue here is that subscripts for <samp><span
class="command">awk</span></samp> arrays are <em>always</em>
-strings. Uninitialized variables, when used as strings, have the
-value <code>""</code>, not zero. Thus, `<samp><span class="samp">line
1</span></samp>' ends up stored in
-<code>l[""]</code>.
-The following version of the program works correctly:
-
-<pre class="example"> { l[lines++] = $0 }
- END {
- for (i = lines - 1; i >= 0; --i)
- print l[i]
- }
-</pre>
- <p>Here, the `<samp><span class="samp">++</span></samp>' forces
<code>lines</code> to be numeric, thus making
-the “old value” numeric zero. This is then converted to
<code>"0"</code>
-as the array subscript.
-
- <p><a name="index-null-strings_002c-as-array-subscripts-1124"></a><a
name="index-dark-corner_002c-array-subscripts-1125"></a><a
name="index-lint-checking_002c-array-subscripts-1126"></a>Even though it is
somewhat unusual, the null string
-(<code>""</code>) is a valid array subscript.
-(d.c.)
-<samp><span class="command">gawk</span></samp> warns about the use of the null
string as a subscript
-if <samp><span class="option">--lint</span></samp> is provided
-on the command line (see <a href="Options.html#Options">Options</a>).
-
- </body></html>
-
Index: manual/html_node/Uniq-Program.html
===================================================================
RCS file: manual/html_node/Uniq-Program.html
diff -N manual/html_node/Uniq-Program.html
--- manual/html_node/Uniq-Program.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,285 +0,0 @@
-<html lang="en">
-<head>
-<title>Uniq Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="prev" href="Tee-Program.html#Tee-Program" title="Tee Program">
-<link rel="next" href="Wc-Program.html#Wc-Program" title="Wc Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Uniq-Program"></a>Next: <a rel="next" accesskey="n"
href="Wc-Program.html#Wc-Program">Wc Program</a>,
-Previous: <a rel="previous" accesskey="p"
href="Tee-Program.html#Tee-Program">Tee Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.6 Printing Nonduplicated Lines of Text</h4>
-
-<!-- STARTOFRANGE prunt -->
-<p><a name="index-printing_002c-unduplicated-lines-of-text-1775"></a><!--
STARTOFRANGE tpul -->
-<a
name="index-text_0040comma_007b_007d-printing_002c-unduplicated-lines-of-1776"></a><a
name="index-_0040command_007buniq_007d-utility-1777"></a>The <samp><span
class="command">uniq</span></samp> utility reads sorted lines of data on its
standard
-input, and by default removes duplicate lines. In other words, it only
-prints unique lines—hence the name. <samp><span
class="command">uniq</span></samp> has a number of
-options. The usage is as follows:
-
-<pre class="example"> uniq <span class="roman">[</span>-udc <span
class="roman">[</span>-<var>n</var><span class="roman">]]</span> <span
class="roman">[</span>+<var>n</var><span class="roman">]</span> <span
class="roman">[</span> <var>input file</var> <span class="roman">[</span>
<var>output file</var> <span class="roman">]]</span>
-</pre>
- <p>The options for <samp><span class="command">uniq</span></samp> are:
-
- <dl>
-<dt><code>-d</code><dd>Pnly print only repeated lines.
-
- <br><dt><code>-u</code><dd>Print only nonrepeated lines.
-
- <br><dt><code>-c</code><dd>Count lines. This option overrides <samp><span
class="option">-d</span></samp> and <samp><span
class="option">-u</span></samp>. Both repeated
-and nonrepeated lines are counted.
-
- <br><dt><code>-</code><var>n</var><dd>Skip <var>n</var> fields before
comparing lines. The definition of fields
-is similar to <samp><span class="command">awk</span></samp>'s default:
nonwhitespace characters separated
-by runs of spaces and/or tabs.
-
- <br><dt><code>+</code><var>n</var><dd>Skip <var>n</var> characters before
comparing lines. Any fields specified with
-`<samp><span class="samp">-</span><var>n</var></samp>' are skipped first.
-
- <br><dt><var>input file</var><dd>Data is read from the input file named
on the command line, instead of from
-the standard input.
-
- <br><dt><var>output file</var><dd>The generated output is sent to the
named output file, instead of to the
-standard output.
-</dl>
-
- <p>Normally <samp><span class="command">uniq</span></samp> behaves as if
both the <samp><span class="option">-d</span></samp> and
-<samp><span class="option">-u</span></samp> options are provided.
-
- <p><samp><span class="command">uniq</span></samp> uses the
-<code>getopt</code> library function
-(see <a href="Getopt-Function.html#Getopt-Function">Getopt Function</a>)
-and the <code>join</code> library function
-(see <a href="Join-Function.html#Join-Function">Join Function</a>).
-
- <p>The program begins with a <code>usage</code> function and then a brief
outline of
-the options and their meanings in a comment.
-The <code>BEGIN</code> rule deals with the command-line arguments and options.
It
-uses a trick to get <code>getopt</code> to handle options of the form
`<samp><span class="samp">-25</span></samp>',
-treating such an option as the option letter `<samp><span
class="samp">2</span></samp>' with an argument of
-`<samp><span class="samp">5</span></samp>'. If indeed two or more digits are
supplied (<code>Optarg</code> looks
-like a number), <code>Optarg</code> is
-concatenated with the option digit and then the result is added to zero to make
-it into a number. If there is only one digit in the option, then
-<code>Optarg</code> is not needed. In this case, <code>Optind</code> must be
decremented so that
-<code>getopt</code> processes it next time. This code is admittedly a bit
-tricky.
-
- <p>If no options are supplied, then the default is taken, to print both
-repeated and nonrepeated lines. The output file, if provided, is assigned
-to <code>outputfile</code>. Early on, <code>outputfile</code> is initialized
to the
-standard output, <samp><span class="file">/dev/stdout</span></samp>:
-
- <p><a name="index-_0040code_007buniq_002eawk_007d-program-1778"></a>
-<pre class="example"> <!-- file eg/prog/uniq.awk -->
- # uniq.awk --- do uniq in awk
- #
- # Requires getopt and join library functions
- <!-- endfile -->
- <!-- file eg/prog/uniq.awk -->
- function usage( e)
- {
- e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]"
- print e > "/dev/stderr"
- exit 1
- }
-
- # -c count lines. overrides -d and -u
- # -d only repeated lines
- # -u only non-repeated lines
- # -n skip n fields
- # +n skip n characters, skip fields first
-
- BEGIN \
- {
- count = 1
- outputfile = "/dev/stdout"
- opts = "udc0:1:2:3:4:5:6:7:8:9:"
- while ((c = getopt(ARGC, ARGV, opts)) != -1) {
- if (c == "u")
- non_repeated_only++
- else if (c == "d")
- repeated_only++
- else if (c == "c")
- do_count++
- else if (index("0123456789", c) != 0) {
- # getopt requires args to options
- # this messes us up for things like -5
- if (Optarg ~ /^[0-9]+$/)
- fcount = (c Optarg) + 0
- else {
- fcount = c + 0
- Optind--
- }
- } else
- usage()
- }
-
- if (ARGV[Optind] ~ /^\+[0-9]+$/) {
- charcount = substr(ARGV[Optind], 2) + 0
- Optind++
- }
-
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- if (repeated_only == 0 && non_repeated_only == 0)
- repeated_only = non_repeated_only = 1
-
- if (ARGC - Optind == 2) {
- outputfile = ARGV[ARGC - 1]
- ARGV[ARGC - 1] = ""
- }
- }
- <!-- endfile -->
-</pre>
- <p>The following function, <code>are_equal</code>, compares the current
line,
-<code>$0</code>, to the
-previous line, <code>last</code>. It handles skipping fields and characters.
-If no field count and no character count are specified, <code>are_equal</code>
-simply returns one or zero depending upon the result of a simple string
-comparison of <code>last</code> and <code>$0</code>. Otherwise, things get
more
-complicated.
-If fields have to be skipped, each line is broken into an array using
-<code>split</code>
-(see <a href="String-Functions.html#String-Functions">String Functions</a>);
-the desired fields are then joined back into a line using <code>join</code>.
-The joined lines are stored in <code>clast</code> and <code>cline</code>.
-If no fields are skipped, <code>clast</code> and <code>cline</code> are set to
-<code>last</code> and <code>$0</code>, respectively.
-Finally, if characters are skipped, <code>substr</code> is used to strip off
the
-leading <code>charcount</code> characters in <code>clast</code> and
<code>cline</code>. The
-two strings are then compared and <code>are_equal</code> returns the result:
-
-<pre class="example"> <!-- file eg/prog/uniq.awk -->
- function are_equal( n, m, clast, cline, alast, aline)
- {
- if (fcount == 0 && charcount == 0)
- return (last == $0)
-
- if (fcount > 0) {
- n = split(last, alast)
- m = split($0, aline)
- clast = join(alast, fcount+1, n)
- cline = join(aline, fcount+1, m)
- } else {
- clast = last
- cline = $0
- }
- if (charcount) {
- clast = substr(clast, charcount + 1)
- cline = substr(cline, charcount + 1)
- }
-
- return (clast == cline)
- }
- <!-- endfile -->
-</pre>
- <p>The following two rules are the body of the program. The first one is
-executed only for the very first line of data. It sets <code>last</code>
equal to
-<code>$0</code>, so that subsequent lines of text have something to be
compared to.
-
- <p>The second rule does the work. The variable <code>equal</code> is one or
zero,
-depending upon the results of <code>are_equal</code>'s comparison. If
<samp><span class="command">uniq</span></samp>
-is counting repeated lines, and the lines are equal, then it increments the
<code>count</code> variable.
-Otherwise, it prints the line and resets <code>count</code>,
-since the two lines are not equal.
-
- <p>If <samp><span class="command">uniq</span></samp> is not counting, and
if the lines are equal, <code>count</code> is incremented.
-Nothing is printed, since the point is to remove duplicates.
-Otherwise, if <samp><span class="command">uniq</span></samp> is counting
repeated lines and more than
-one line is seen, or if <samp><span class="command">uniq</span></samp> is
counting nonrepeated lines
-and only one line is seen, then the line is printed, and <code>count</code>
-is reset.
-
- <p>Finally, similar logic is used in the <code>END</code> rule to print the
final
-line of input data:
-
-<pre class="example"> <!-- file eg/prog/uniq.awk -->
- NR == 1 {
- last = $0
- next
- }
-
- {
- equal = are_equal()
-
- if (do_count) { # overrides -d and -u
- if (equal)
- count++
- else {
- printf("%4d %s\n", count, last) > outputfile
- last = $0
- count = 1 # reset
- }
- next
- }
-
- if (equal)
- count++
- else {
- if ((repeated_only && count > 1) ||
- (non_repeated_only && count == 1))
- print last > outputfile
- last = $0
- count = 1
- }
- }
-
- END {
- if (do_count)
- printf("%4d %s\n", count, last) > outputfile
- else if ((repeated_only && count > 1) ||
- (non_repeated_only && count == 1))
- print last > outputfile
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE prunt -->
-<!-- ENDOFRANGE tpul -->
-</body></html>
-
Index: manual/html_node/Unix-Installation.html
===================================================================
RCS file: manual/html_node/Unix-Installation.html
diff -N manual/html_node/Unix-Installation.html
--- manual/html_node/Unix-Installation.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,68 +0,0 @@
-<html lang="en">
-<head>
-<title>Unix Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Installation.html#Installation" title="Installation">
-<link rel="prev" href="Gawk-Distribution.html#Gawk-Distribution" title="Gawk
Distribution">
-<link rel="next"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation" title="Non-Unix
Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Unix-Installation"></a>Next: <a rel="next" accesskey="n"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>,
-Previous: <a rel="previous" accesskey="p"
href="Gawk-Distribution.html#Gawk-Distribution">Gawk Distribution</a>,
-Up: <a rel="up" accesskey="u"
href="Installation.html#Installation">Installation</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">B.2 Compiling and Installing <samp><span
class="command">gawk</span></samp> on Unix</h3>
-
-<p>Usually, you can compile and install <samp><span
class="command">gawk</span></samp> by typing only two
-commands. However, if you use an unusual system, you may need
-to configure <samp><span class="command">gawk</span></samp> for your system
yourself.
-
-<ul class="menu">
-<li><a accesskey="1" href="Quick-Installation.html#Quick-Installation">Quick
Installation</a>: Compiling <samp><span
class="command">gawk</span></samp> under Unix.
-<li><a accesskey="2"
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>: Other compile-time options.
-<li><a accesskey="3"
href="Configuration-Philosophy.html#Configuration-Philosophy">Configuration
Philosophy</a>: How it's all supposed to work.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Unsupported.html
===================================================================
RCS file: manual/html_node/Unsupported.html
diff -N manual/html_node/Unsupported.html
--- manual/html_node/Unsupported.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,66 +0,0 @@
-<html lang="en">
-<head>
-<title>Unsupported - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Installation.html#Installation" title="Installation">
-<link rel="prev"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation" title="Non-Unix
Installation">
-<link rel="next" href="Bugs.html#Bugs" title="Bugs">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Unsupported"></a>Next: <a rel="next" accesskey="n"
href="Bugs.html#Bugs">Bugs</a>,
-Previous: <a rel="previous" accesskey="p"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Installation.html#Installation">Installation</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">B.4 Unsupported Operating System Ports</h3>
-
-<p>This sections describes systems for which
-the <samp><span class="command">gawk</span></samp> port is no longer supported.
-
-<ul class="menu">
-<li><a accesskey="1" href="Atari-Installation.html#Atari-Installation">Atari
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on the Atari ST.
-<li><a accesskey="2"
href="Tandem-Installation.html#Tandem-Installation">Tandem Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on a Tandem.
-</ul>
-
- </body></html>
-
Index: manual/html_node/User_002ddefined.html
===================================================================
RCS file: manual/html_node/User_002ddefined.html
diff -N manual/html_node/User_002ddefined.html
--- manual/html_node/User_002ddefined.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,72 +0,0 @@
-<html lang="en">
-<head>
-<title>User-defined - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Functions.html#Functions" title="Functions">
-<link rel="prev" href="Built_002din.html#Built_002din" title="Built-in">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="User_002ddefined"></a>Previous: <a rel="previous" accesskey="p"
href="Built_002din.html#Built_002din">Built-in</a>,
-Up: <a rel="up" accesskey="u"
href="Functions.html#Functions">Functions</a>
-<hr><br>
-</div>
-
-<h3 class="section">8.2 User-Defined Functions</h3>
-
-<!-- STARTOFRANGE udfunc -->
-<p><a name="index-user_002ddefined_002c-functions-1275"></a><!-- STARTOFRANGE
funcud -->
-<a name="index-functions_002c-user_002ddefined-1276"></a>Complicated
<samp><span class="command">awk</span></samp> programs can often be simplified
by defining
-your own functions. User-defined functions can be called just like
-built-in ones (see <a href="Function-Calls.html#Function-Calls">Function
Calls</a>), but it is up to you to define
-them, i.e., to tell <samp><span class="command">awk</span></samp> what they
should do.
-
-<ul class="menu">
-<li><a accesskey="1"
href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a>:
How to write definitions and what they mean.
-<li><a accesskey="2" href="Function-Example.html#Function-Example">Function
Example</a>: An example function definition and what it
- does.
-<li><a accesskey="3" href="Function-Caveats.html#Function-Caveats">Function
Caveats</a>: Things to watch out for.
-<li><a accesskey="4" href="Return-Statement.html#Return-Statement">Return
Statement</a>: Specifying the value a function returns.
-<li><a accesskey="5" href="Dynamic-Typing.html#Dynamic-Typing">Dynamic
Typing</a>: How variable types can change at runtime.
-</ul>
-
- </body></html>
-
Index: manual/html_node/User_002dmodified.html
===================================================================
RCS file: manual/html_node/User_002dmodified.html
diff -N manual/html_node/User_002dmodified.html
--- manual/html_node/User_002dmodified.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,230 +0,0 @@
-<html lang="en">
-<head>
-<title>User-modified - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Built_002din-Variables.html#Built_002din-Variables"
title="Built-in Variables">
-<link rel="next" href="Auto_002dset.html#Auto_002dset" title="Auto-set">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="User_002dmodified"></a>Next: <a rel="next" accesskey="n"
href="Auto_002dset.html#Auto_002dset">Auto-set</a>,
-Up: <a rel="up" accesskey="u"
href="Built_002din-Variables.html#Built_002din-Variables">Built-in Variables</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.5.1 Built-in Variables That Control <samp><span
class="command">awk</span></samp></h4>
-
-<!-- STARTOFRANGE bvaru -->
-<p><a
name="index-built_002din-variables_002c-user_002dmodifiable-993"></a><!--
STARTOFRANGE nmbv -->
-<a name="index-user_002dmodifiable-variables-994"></a>
-The following is an alphabetical list of variables that you can change to
-control how <samp><span class="command">awk</span></samp> does certain things.
The variables that are
-specific to <samp><span class="command">gawk</span></samp> are marked with a
pound sign (`<samp><span class="samp">#</span></samp>').<!-- /@w -->
-
-
-<a name="index-_0040code_007bBINMODE_007d-variable-995"></a>
-<a name="index-binary-input_002foutput-996"></a>
-<a name="index-input_002foutput_002c-binary-997"></a>
-<dl><dt><code>BINMODE #</code><dd>On non-POSIX systems, this variable
specifies use of binary mode for all I/O.
-Numeric values of one, two, or three specify that input files, output files, or
-all files, respectively, should use binary I/O.
-Alternatively,
-string values of <code>"r"</code> or <code>"w"</code> specify that input files
and
-output files, respectively, should use binary I/O.
-A string value of <code>"rw"</code> or <code>"wr"</code> indicates that all
-files should use binary I/O.
-Any other string value is equivalent to <code>"rw"</code>, but <samp><span
class="command">gawk</span></samp>
-generates a warning message.
-<code>BINMODE</code> is described in more detail in
-<a href="PC-Using.html#PC-Using">PC Using</a>.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bBINMODE_007d-variable-998"></a>This
variable is a <samp><span class="command">gawk</span></samp> extension.
-In other <samp><span class="command">awk</span></samp> implementations
-(except <samp><span class="command">mawk</span></samp>,
-see <a href="Other-Versions.html#Other-Versions">Other Versions</a>),
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-it is not special.
-
- <p><a name="index-_0040code_007bCONVFMT_007d-variable-999"></a><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bCONVFMT_007d-variable-and-1000"></a><a
name="index-numbers_002c-converting_002c-to-strings-1001"></a><a
name="index-strings_002c-converting_002c-numbers-to-1002"></a><br><dt><code>CONVFMT</code><dd>This
string controls conversion of numbers to
-strings (see <a href="Conversion.html#Conversion">Conversion</a>).
-It works by being passed, in effect, as the first argument to the
-<code>sprintf</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-Its default value is <code>"%.6g"</code>.
-<code>CONVFMT</code> was introduced by the POSIX standard.
-
- <p><a name="index-_0040code_007bFIELDWIDTHS_007d-variable-1003"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-1004"></a><a
name="index-field-separators_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1005"></a><a
name="index-separators_002c-field_002c-_0040code_007bFIELDWIDTHS_007d-variable-and-1006"></a><br><dt><code>FIELDWIDTHS
#</code><dd>This is a space-separated list of columns that tells <samp><span
class="command">gawk</span></samp>
-how to split input with fixed columnar boundaries.
-Assigning a value to <code>FIELDWIDTHS</code>
-overrides the use of <code>FS</code> for field splitting.
-See <a href="Constant-Size.html#Constant-Size">Constant Size</a>, for more
information.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bFIELDWIDTHS_007d-variable-in-1007"></a>If
<samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>), then <code>FIELDWIDTHS</code>
-has no special meaning, and field-splitting operations occur based
-exclusively on the value of <code>FS</code>.
-
- <p><a name="index-_0040code_007bFS_007d-variable-1008"></a><a
name="index-separators_002c-field-1009"></a><a
name="index-field-separators-1010"></a><br><dt><code>FS</code><dd>This is the
input field separator
-(see <a href="Field-Separators.html#Field-Separators">Field Separators</a>).
-The value is a single-character string or a multi-character regular
-expression that matches the separations between fields in an input
-record. If the value is the null string (<code>""</code>), then each
-character in the record becomes a separate field.
-(This behavior is a <samp><span class="command">gawk</span></samp> extension.
POSIX <samp><span class="command">awk</span></samp> does not
-specify the behavior when <code>FS</code> is the null string.)
-<!-- NEXT ED: Mark as common extension -->
-
- <p><a
name="index-POSIX-_0040command_007bawk_007d_002c-_0040code_007bFS_007d-variable-and-1011"></a>The
default value is <code>" "</code><!-- /@w -->, a string consisting of a
single
-space. As a special exception, this value means that any
-sequence of spaces, tabs, and/or newlines is a single separator.<a
rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> It also causes
-spaces, tabs, and newlines at the beginning and end of a record to be ignored.
-
- <p>You can set the value of <code>FS</code> on the command line using the
-<samp><span class="option">-F</span></samp> option:
-
- <pre class="example"> awk -F, '<var>program</var>'
<var>input-files</var>
- </pre>
- <p><a
name="index-_0040command_007bgawk_007d_002c-field-separators-and-1012"></a>If
<samp><span class="command">gawk</span></samp> is using
<code>FIELDWIDTHS</code> for field splitting,
-assigning a value to <code>FS</code> causes <samp><span
class="command">gawk</span></samp> to return to
-the normal, <code>FS</code>-based field splitting. An easy way to do this
-is to simply say `<samp><span class="samp">FS = FS</span></samp>', perhaps
with an explanatory comment.
-
- <p><a name="index-_0040code_007bIGNORECASE_007d-variable-1013"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-1014"></a><a
name="index-case-sensitivity_002c-string-comparisons-and-1015"></a><a
name="index-case-sensitivity_002c-regexps-and-1016"></a><a
name="index-regular-expressions_002c-case-sensitivity-1017"></a><br><dt><code>IGNORECASE
#</code><dd>If <code>IGNORECASE</code> is nonzero or non-null, then all string
comparisons
-and all regular expression matching are case independent. Thus, regexp
-matching with `<samp><span class="samp">~</span></samp>' and `<samp><span
class="samp">!~</span></samp>', as well as the <code>gensub</code>,
-<code>gsub</code>, <code>index</code>, <code>match</code>, <code>split</code>,
and <code>sub</code>
-functions, record termination with <code>RS</code>, and field splitting with
-<code>FS</code>, all ignore case when doing their particular regexp
operations.
-However, the value of <code>IGNORECASE</code> does <em>not</em> affect array
subscripting
-and it does not affect field splitting when using a single-character
-field separator.
-See <a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bIGNORECASE_007d-variable-in-1018"></a>If
<samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-then <code>IGNORECASE</code> has no special meaning. Thus, string
-and regexp operations are always case-sensitive.
-
- <p><a name="index-_0040code_007bLINT_007d-variable-1019"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-1020"></a><a
name="index-lint-checking-1021"></a><br><dt><code>LINT #</code><dd>When this
variable is true (nonzero or non-null), <samp><span
class="command">gawk</span></samp>
-behaves as if the <samp><span class="option">--lint</span></samp> command-line
option is in effect.
-(see <a href="Options.html#Options">Options</a>).
-With a value of <code>"fatal"</code>, lint warnings become fatal errors.
-With a value of <code>"invalid"</code>, only warnings about things that are
-actually invalid are issued. (This is not fully implemented yet.)
-Any other true value prints nonfatal warnings.
-Assigning a false value to <code>LINT</code> turns off the lint warnings.
-
- <p><a
name="index-_0040command_007bgawk_007d_002c-_0040code_007bLINT_007d-variable-in-1022"></a>This
variable is a <samp><span class="command">gawk</span></samp> extension. It is
not special
-in other <samp><span class="command">awk</span></samp> implementations.
Unlike the other special variables,
-changing <code>LINT</code> does affect the production of lint warnings,
-even if <samp><span class="command">gawk</span></samp> is in compatibility
mode. Much as
-the <samp><span class="option">--lint</span></samp> and <samp><span
class="option">--traditional</span></samp> options independently
-control different aspects of <samp><span class="command">gawk</span></samp>'s
behavior, the control
-of lint warnings during program execution is independent of the flavor
-of <samp><span class="command">awk</span></samp> being executed.
-
- <p><a name="index-_0040code_007bOFMT_007d-variable-1023"></a><a
name="index-numbers_002c-converting_002c-to-strings-1024"></a><a
name="index-strings_002c-converting_002c-numbers-to-1025"></a><br><dt><code>OFMT</code><dd>This
string controls conversion of numbers to
-strings (see <a href="Conversion.html#Conversion">Conversion</a>) for
-printing with the <code>print</code> statement. It works by being passed
-as the first argument to the <code>sprintf</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-Its default value is <code>"%.6g"</code>. Earlier versions of <samp><span
class="command">awk</span></samp>
-also used <code>OFMT</code> to specify the format for converting numbers to
-strings in general expressions; this is now done by <code>CONVFMT</code>.
-
- <p><a
name="index-_0040code_007bsprintf_007d-function_002c-_0040code_007bOFMT_007d-variable-and-1026"></a><a
name="index-_0040code_007bprint_007d-statement_002c-_0040code_007bOFMT_007d-variable-and-1027"></a><a
name="index-_0040code_007bOFS_007d-variable-1028"></a><a
name="index-separators_002c-field-1029"></a><a
name="index-field-separators-1030"></a><br><dt><code>OFS</code><dd>This is the
output field separator (see <a
href="Output-Separators.html#Output-Separators">Output Separators</a>). It is
-output between the fields printed by a <code>print</code> statement. Its
-default value is <code>" "</code><!-- /@w -->, a string consisting of a
single space.
-
- <p><a
name="index-_0040code_007bORS_007d-variable-1031"></a><br><dt><code>ORS</code><dd>This
is the output record separator. It is output at the end of every
-<code>print</code> statement. Its default value is <code>"\n"</code>, the
newline
-character. (See <a href="Output-Separators.html#Output-Separators">Output
Separators</a>.)
-
- <p><a name="index-_0040code_007bRS_007d-variable-1032"></a><a
name="index-separators_002c-record-1033"></a><a
name="index-record-separators-1034"></a><br><dt><code>RS</code><dd>This is
<samp><span class="command">awk</span></samp>'s input record separator. Its
default value is a string
-containing a single newline character, which means that an input record
-consists of a single line of text.
-It can also be the null string, in which case records are separated by
-runs of blank lines.
-If it is a regexp, records are separated by
-matches of the regexp in the input text.
-(See <a href="Records.html#Records">Records</a>.)
-
- <p>The ability for <code>RS</code> to be a regular expression
-is a <samp><span class="command">gawk</span></samp> extension.
-In most other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-just the first character of <code>RS</code>'s value is used.
-
- <p><a name="index-_0040code_007bSUBSEP_007d-variable-1035"></a><a
name="index-separators_002c-subscript-1036"></a><a
name="index-subscript-separators-1037"></a><br><dt><code>SUBSEP</code><dd>This
is the subscript separator. It has the default value of
-<code>"\034"</code> and is used to separate the parts of the indices of a
-multidimensional array. Thus, the expression <code>foo["A", "B"]<!-- /@w
--></code>
-really accesses <code>foo["A\034B"]</code>
-(see <a
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a>).
-
- <p><a name="index-_0040code_007bTEXTDOMAIN_007d-variable-1038"></a><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-_0040code_007bTEXTDOMAIN_007d-variable-1039"></a><a
name="index-internationalization_002c-localization-1040"></a><br><dt><code>TEXTDOMAIN
#</code><dd>This variable is used for internationalization of programs at the
-<samp><span class="command">awk</span></samp> level. It sets the default text
domain for specially
-marked string constants in the source text, as well as for the
-<code>dcgettext</code>, <code>dcngettext</code> and
<code>bindtextdomain</code> functions
-(see <a
href="Internationalization.html#Internationalization">Internationalization</a>).
-The default value of <code>TEXTDOMAIN</code> is <code>"messages"</code>.
-
- <p>This variable is a <samp><span class="command">gawk</span></samp>
extension.
-In other <samp><span class="command">awk</span></samp> implementations,
-or if <samp><span class="command">gawk</span></samp> is in compatibility mode
-(see <a href="Options.html#Options">Options</a>),
-it is not special.
-</dl>
- <!-- ENDOFRANGE bvar -->
-<!-- ENDOFRANGE varb -->
-<!-- ENDOFRANGE bvaru -->
-<!-- ENDOFRANGE nmbv -->
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> In
-POSIX <samp><span class="command">awk</span></samp>, newline does not count as
whitespace.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Using-BEGIN_002fEND.html
===================================================================
RCS file: manual/html_node/Using-BEGIN_002fEND.html
diff -N manual/html_node/Using-BEGIN_002fEND.html
--- manual/html_node/Using-BEGIN_002fEND.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,117 +0,0 @@
-<html lang="en">
-<head>
-<title>Using BEGIN/END - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="BEGIN_002fEND.html#BEGIN_002fEND" title="BEGIN/END">
-<link rel="next"
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND" title="I/O And
BEGIN/END">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Using-BEGIN_002fEND"></a>Next: <a rel="next" accesskey="n"
href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a>,
-Up: <a rel="up" accesskey="u"
href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>
-<hr><br>
-</div>
-
-<h5 class="subsubsection">6.1.4.1 Startup and Cleanup Actions</h5>
-
-<p>A <code>BEGIN</code> rule is executed once only, before the first input
record
-is read. Likewise, an <code>END</code> rule is executed once only, after all
the
-input is read. For example:
-
-<pre class="example"> $ awk '
- > BEGIN { print "Analysis of \"foo\"" }
- > /foo/ { ++n }
- > END { print "\"foo\" appears", n, "times." }' BBS-list
- -| Analysis of "foo"
- -| "foo" appears 4 times.
-</pre>
- <p><a
name="index-_0040code_007bBEGIN_007d-pattern_002c-operators-and-914"></a><a
name="index-_0040code_007bEND_007d-pattern_002c-operators-and-915"></a>This
program finds the number of records in the input file <samp><span
class="file">BBS-list</span></samp>
-that contain the string `<samp><span class="samp">foo</span></samp>'. The
<code>BEGIN</code> rule prints a title
-for the report. There is no need to use the <code>BEGIN</code> rule to
-initialize the counter <code>n</code> to zero, since <samp><span
class="command">awk</span></samp> does this
-automatically (see <a href="Variables.html#Variables">Variables</a>).
-The second rule increments the variable <code>n</code> every time a
-record containing the pattern `<samp><span class="samp">foo</span></samp>' is
read. The <code>END</code> rule
-prints the value of <code>n</code> at the end of the run.
-
- <p>The special patterns <code>BEGIN</code> and <code>END</code> cannot be
used in ranges
-or with Boolean operators (indeed, they cannot be used with any operators).
-An <samp><span class="command">awk</span></samp> program may have multiple
<code>BEGIN</code> and/or <code>END</code>
-rules. They are executed in the order in which they appear: all the
<code>BEGIN</code>
-rules at startup and all the <code>END</code> rules at termination.
-<code>BEGIN</code> and <code>END</code> rules may be intermixed with other
rules.
-This feature was added in the 1987 version of <samp><span
class="command">awk</span></samp> and is included
-in the POSIX standard.
-The original (1978) version of <samp><span class="command">awk</span></samp>
-required the <code>BEGIN</code> rule to be placed at the beginning of the
-program, the <code>END</code> rule to be placed at the end, and only allowed
one of
-each.
-This is no longer required, but it is a good idea to follow this template
-in terms of program organization and readability.
-
- <p>Multiple <code>BEGIN</code> and <code>END</code> rules are useful for
writing
-library functions, because each library file can have its own
<code>BEGIN</code> and/or
-<code>END</code> rule to do its own initialization and/or cleanup.
-The order in which library functions are named on the command line
-controls the order in which their <code>BEGIN</code> and <code>END</code>
rules are
-executed. Therefore, you have to be careful when writing such rules in
-library files so that the order in which they are executed doesn't matter.
-See <a href="Options.html#Options">Options</a>, for more information on
-using library functions.
-See <a href="Library-Functions.html#Library-Functions">Library Functions</a>,
-for a number of useful library functions.
-
- <p>If an <samp><span class="command">awk</span></samp> program has only a
<code>BEGIN</code> rule and no
-other rules, then the program exits after the <code>BEGIN</code> rule is
-run.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a> However, if
an
-<code>END</code> rule exists, then the input is read, even if there are
-no other rules in the program. This is necessary in case the <code>END</code>
-rule checks the <code>FNR</code> and <code>NR</code> variables.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> The original version of <samp><span
class="command">awk</span></samp> used to keep
-reading and ignoring input until the end of the file was seen.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/Using-Constant-Regexps.html
===================================================================
RCS file: manual/html_node/Using-Constant-Regexps.html
diff -N manual/html_node/Using-Constant-Regexps.html
--- manual/html_node/Using-Constant-Regexps.html 31 Aug 2004 22:04:12
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,146 +0,0 @@
-<html lang="en">
-<head>
-<title>Using Constant Regexps - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Constants.html#Constants" title="Constants">
-<link rel="next" href="Variables.html#Variables" title="Variables">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Using-Constant-Regexps"></a>Next: <a rel="next" accesskey="n"
href="Variables.html#Variables">Variables</a>,
-Previous: <a rel="previous" accesskey="p"
href="Constants.html#Constants">Constants</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.2 Using Regular Expression Constants</h3>
-
-<p><a name="index-dark-corner_002c-regexp-constants-624"></a>When used on the
righthand side of the `<samp><span class="samp">~</span></samp>' or
`<samp><span class="samp">!~</span></samp>'
-operators, a regexp constant merely stands for the regexp that is to be
-matched.
-However, regexp constants (such as <code>/foo/</code>) may be used like simple
expressions.
-When a
-regexp constant appears by itself, it has the same meaning as if it appeared
-in a pattern, i.e., `<samp><span class="samp">($0 ~ /foo/)</span></samp>'
-(d.c.)
-See <a href="Expression-Patterns.html#Expression-Patterns">Expression
Patterns</a>.
-This means that the following two code segments:
-
-<pre class="example"> if ($0 ~ /barfly/ || $0 ~ /camelot/)
- print "found"
-</pre>
- <p class="noindent">and:
-
-<pre class="example"> if (/barfly/ || /camelot/)
- print "found"
-</pre>
- <p class="noindent">are exactly equivalent.
-One rather bizarre consequence of this rule is that the following
-Boolean expression is valid, but does not do what the user probably
-intended:
-
-<pre class="example"> # note that /foo/ is on the left of the ~
- if (/foo/ ~ $1) print "found foo"
-</pre>
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p><a
name="index-_0040command_007bgawk_007d_002c-regexp-constants-and-625"></a><a
name="index-regexp-constants_002c-in-_0040command_007bgawk_007d-626"></a>This
code is “obviously” testing <code>$1</code> for a match against the
regexp
-<code>/foo/</code>. But in fact, the expression `<samp><span
class="samp">/foo/ ~ $1</span></samp>' actually means
-`<samp><span class="samp">($0 ~ /foo/) ~ $1</span></samp>'. In other words,
first match the input record
-against the regexp <code>/foo/</code>. The result is either zero or one,
-depending upon the success or failure of the match. That result
-is then matched against the first field in the record.
-Because it is unlikely that you would ever really want to make this kind of
-test, <samp><span class="command">gawk</span></samp> issues a warning when it
sees this construct in
-a program.
-Another consequence of this rule is that the assignment statement:
-
-<pre class="example"> matches = /foo/
-</pre>
- <p class="noindent">assigns either zero or one to the variable
<code>matches</code>, depending
-upon the contents of the current input record.
-This feature of the language has never been well documented until the
-POSIX specification.
-
- <p><a
name="index-differences-in-_0040command_007bawk_007d-and-_0040command_007bgawk_007d_002c-regexp-constants-627"></a><a
name="index-dark-corner_002c-regexp-constants_002c-as-arguments-to-user_002ddefined-functions-628"></a><a
name="index-_0040code_007bgensub_007d-function-_0028_0040command_007bgawk_007d_0029-629"></a><a
name="index-_0040code_007bsub_007d-function-630"></a><a
name="index-_0040code_007bgsub_007d-function-631"></a>Constant regular
expressions are also used as the first argument for
-the <code>gensub</code>, <code>sub</code>, and <code>gsub</code> functions,
and as the
-second argument of the <code>match</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-Modern implementations of <samp><span class="command">awk</span></samp>,
including <samp><span class="command">gawk</span></samp>, allow
-the third argument of <code>split</code> to be a regexp constant, but some
-older implementations do not.
-(d.c.)
-This can lead to confusion when attempting to use regexp constants
-as arguments to user-defined functions
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>).
-For example:
-
-<pre class="example"> function mysub(pat, repl, str, global)
- {
- if (global)
- gsub(pat, repl, str)
- else
- sub(pat, repl, str)
- return str
- }
-
- {
- ...
- text = "hi! hi yourself!"
- mysub(/hi/, "howdy", text, 1)
- ...
- }
-</pre>
- <!-- @cindex automatic warnings -->
-<!-- @cindex warnings, automatic -->
-<p>In this example, the programmer wants to pass a regexp constant to the
-user-defined function <code>mysub</code>, which in turn passes it on to
-either <code>sub</code> or <code>gsub</code>. However, what really happens is
that
-the <code>pat</code> parameter is either one or zero, depending upon whether
-or not <code>$0</code> matches <code>/hi/</code>.
-<samp><span class="command">gawk</span></samp> issues a warning when it sees a
regexp constant used as
-a parameter to a user-defined function, since passing a truth value in
-this way is probably not what was intended.
-<!-- ENDOFRANGE rec -->
-
- </body></html>
-
Index: manual/html_node/Using-Internal-File-Ops.html
===================================================================
RCS file: manual/html_node/Using-Internal-File-Ops.html
diff -N manual/html_node/Using-Internal-File-Ops.html
--- manual/html_node/Using-Internal-File-Ops.html 31 Aug 2004 22:04:12
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,120 +0,0 @@
-<html lang="en">
-<head>
-<title>Using Internal File Ops - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Sample-Library.html#Sample-Library" title="Sample
Library">
-<link rel="prev" href="Internal-File-Ops.html#Internal-File-Ops"
title="Internal File Ops">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Using-Internal-File-Ops"></a>Previous: <a rel="previous"
accesskey="p" href="Internal-File-Ops.html#Internal-File-Ops">Internal File
Ops</a>,
-Up: <a rel="up" accesskey="u"
href="Sample-Library.html#Sample-Library">Sample Library</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">C.3.2.3 Integrating the Extensions</h5>
-
-<p><a
name="index-_0040command_007bgawk_007d_002c-interpreter_0040comma_007b_007d-adding-code-to-2017"></a>Now
that the code is written, it must be possible to add it at
-runtime to the running <samp><span class="command">gawk</span></samp>
interpreter. First, the
-code must be compiled. Assuming that the functions are in
-a file named <samp><span class="file">filefuncs.c</span></samp>, and
<var>idir</var> is the location
-of the <samp><span class="command">gawk</span></samp> include files,
-the following steps create
-a GNU/Linux shared library:
-
-<pre class="example"> $ gcc -shared -DHAVE_CONFIG_H -c -O -g
-I<var>idir</var> filefuncs.c
- $ ld -o filefuncs.so -shared filefuncs.o
-</pre>
- <p><a
name="index-_0040code_007bextension_007d-function-_0028_0040command_007bgawk_007d_0029-2018"></a>Once
the library exists, it is loaded by calling the <code>extension</code>
-built-in function.
-This function takes two arguments: the name of the
-library to load and the name of a function to call when the library
-is first loaded. This function adds the new functions to <samp><span
class="command">gawk</span></samp>.
-It returns the value returned by the initialization function
-within the shared library:
-
-<pre class="example"> # file testff.awk
- BEGIN {
- extension("./filefuncs.so", "dlload")
-
- chdir(".") # no-op
-
- data[1] = 1 # force `data' to be an array
- print "Info for testff.awk"
- ret = stat("testff.awk", data)
- print "ret =", ret
- for (i in data)
- printf "data[\"%s\"] = %s\n", i, data[i]
- print "testff.awk modified:",
- strftime("%m %d %y %H:%M:%S", data["mtime"])
- }
-</pre>
- <p>Here are the results of running the program:
-
-<pre class="example"> $ gawk -f testff.awk
- -| Info for testff.awk
- -| ret = 0
- -| data["blksize"] = 4096
- -| data["mtime"] = 932361936
- -| data["mode"] = 33188
- -| data["type"] = file
- -| data["dev"] = 2065
- -| data["gid"] = 10
- -| data["ino"] = 878597
- -| data["ctime"] = 971431797
- -| data["blocks"] = 2
- -| data["nlink"] = 1
- -| data["name"] = testff.awk
- -| data["atime"] = 971608519
- -| data["pmode"] = -rw-r--r--
- -| data["size"] = 607
- -| data["uid"] = 2076
- -| testff.awk modified: 07 19 99 08:25:36
-</pre>
- <!-- ENDOFRANGE filre -->
-<!-- ENDOFRANGE dirch -->
-<!-- ENDOFRANGE statg -->
-<!-- ENDOFRANGE chdirg -->
-<!-- ENDOFRANGE gladfgaw -->
-<!-- ENDOFRANGE adfugaw -->
-<!-- ENDOFRANGE fubadgaw -->
-</body></html>
-
Index: manual/html_node/Using-Shell-Variables.html
===================================================================
RCS file: manual/html_node/Using-Shell-Variables.html
diff -N manual/html_node/Using-Shell-Variables.html
--- manual/html_node/Using-Shell-Variables.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,110 +0,0 @@
-<html lang="en">
-<head>
-<title>Using Shell Variables - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Patterns-and-Actions.html#Patterns-and-Actions"
title="Patterns and Actions">
-<link rel="prev" href="Pattern-Overview.html#Pattern-Overview" title="Pattern
Overview">
-<link rel="next" href="Action-Overview.html#Action-Overview" title="Action
Overview">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Using-Shell-Variables"></a>Next: <a rel="next" accesskey="n"
href="Action-Overview.html#Action-Overview">Action Overview</a>,
-Previous: <a rel="previous" accesskey="p"
href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>,
-Up: <a rel="up" accesskey="u"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>
-<hr><br>
-</div>
-
-<h3 class="section">6.2 Using Shell Variables in Programs</h3>
-
-<p><a name="index-shells_002c-variables-928"></a><a
name="index-_0040command_007bawk_007d-programs_002c-shell-variables-in-929"></a><!--
@cindex shell and @command{awk} interaction -->
-
- <p><samp><span class="command">awk</span></samp> programs are often used as
components in larger
-programs written in shell.
-For example, it is very common to use a shell variable to
-hold a pattern that the <samp><span class="command">awk</span></samp> program
searches for.
-There are two ways to get the value of the shell variable
-into the body of the <samp><span class="command">awk</span></samp> program.
-
- <p><a name="index-shells_002c-quoting-930"></a>The most common method is to
use shell quoting to substitute
-the variable's value into the program inside the script.
-For example, in the following program:
-
-<pre class="example"> echo -n "Enter search pattern: "
- read pattern
- awk "/$pattern/ "'{ nmatches++ }
- END { print nmatches, "found" }' /path/to/data
-</pre>
- <p class="noindent">the <samp><span class="command">awk</span></samp>
program consists of two pieces of quoted text
-that are concatenated together to form the program.
-The first part is double-quoted, which allows substitution of
-the <code>pattern</code> variable inside the quotes.
-The second part is single-quoted.
-
- <p>Variable substitution via quoting works, but can be potentially
-messy. It requires a good understanding of the shell's quoting rules
-(see <a href="Quoting.html#Quoting">Quoting</a>),
-and it's often difficult to correctly
-match up the quotes when reading the program.
-
- <p>A better method is to use <samp><span
class="command">awk</span></samp>'s variable assignment feature
-(see <a href="Assignment-Options.html#Assignment-Options">Assignment
Options</a>)
-to assign the shell variable's value to an <samp><span
class="command">awk</span></samp> variable's
-value. Then use dynamic regexps to match the pattern
-(see <a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>).
-The following shows how to redo the
-previous example using this technique:
-
-<pre class="example"> echo -n "Enter search pattern: "
- read pattern
- awk -v pat="$pattern" '$0 ~ pat { nmatches++ }
- END { print nmatches, "found" }' /path/to/data
-</pre>
- <p class="noindent">Now, the <samp><span class="command">awk</span></samp>
program is just one single-quoted string.
-The assignment `<samp><span class="samp">-v pat="$pattern"</span></samp>'
still requires double quotes,
-in case there is whitespace in the value of <code>$pattern</code>.
-The <samp><span class="command">awk</span></samp> variable <code>pat</code>
could be named <code>pattern</code>
-too, but that would be more confusing. Using a variable also
-provides more flexibility, since the variable can be used anywhere inside
-the program—for printing, as an array subscript, or for any other
-use—without requiring the quoting tricks at every point in the program.
-
- </body></html>
-
Index: manual/html_node/Using-Variables.html
===================================================================
RCS file: manual/html_node/Using-Variables.html
diff -N manual/html_node/Using-Variables.html
--- manual/html_node/Using-Variables.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,83 +0,0 @@
-<html lang="en">
-<head>
-<title>Using Variables - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Variables.html#Variables" title="Variables">
-<link rel="next" href="Assignment-Options.html#Assignment-Options"
title="Assignment Options">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Using-Variables"></a>Next: <a rel="next" accesskey="n"
href="Assignment-Options.html#Assignment-Options">Assignment Options</a>,
-Up: <a rel="up" accesskey="u"
href="Variables.html#Variables">Variables</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">5.3.1 Using Variables in a Program</h4>
-
-<p>Variables let you give names to values and refer to them later. Variables
-have already been used in many of the examples. The name of a variable
-must be a sequence of letters, digits, or underscores, and it may not begin
-with a digit. Case is significant in variable names; <code>a</code> and
<code>A</code>
-are distinct variables.
-
- <p>A variable name is a valid expression by itself; it represents the
-variable's current value. Variables are given new values with
-<dfn>assignment operators</dfn>, <dfn>increment operators</dfn>, and
-<dfn>decrement operators</dfn>.
-See <a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>.
-<!-- NEXT ED: Can also be changed by sub, gsub, split -->
-
- <p><a name="index-variables_002c-built_002din-634"></a><a
name="index-variables_002c-initializing-635"></a>A few variables have special
built-in meanings, such as <code>FS</code> (the
-field separator), and <code>NF</code> (the number of fields in the current
input
-record). See <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>, for a list of the built-in variables.
-These built-in variables can be used and assigned just like all other
-variables, but their values are also used or changed automatically by
-<samp><span class="command">awk</span></samp>. All built-in variables' names
are entirely uppercase.
-
- <p>Variables in <samp><span class="command">awk</span></samp> can be
assigned either numeric or string values.
-The kind of value a variable holds can change over the life of a program.
-By default, variables are initialized to the empty string, which
-is zero if converted to a number. There is no need to
-“initialize” each variable explicitly in <samp><span
class="command">awk</span></samp>,
-which is what you would do in C and in most other traditional languages.
-
- </body></html>
-
Index: manual/html_node/V7_002fSVR3_002e1.html
===================================================================
RCS file: manual/html_node/V7_002fSVR3_002e1.html
diff -N manual/html_node/V7_002fSVR3_002e1.html
--- manual/html_node/V7_002fSVR3_002e1.html 31 Aug 2004 22:04:12 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,123 +0,0 @@
-<html lang="en">
-<head>
-<title>V7/SVR3.1 - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Language-History.html#Language-History" title="Language
History">
-<link rel="next" href="SVR4.html#SVR4" title="SVR4">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="V7_002fSVR3_002e1"></a>Next: <a rel="next" accesskey="n"
href="SVR4.html#SVR4">SVR4</a>,
-Up: <a rel="up" accesskey="u"
href="Language-History.html#Language-History">Language History</a>
-<hr><br>
-</div>
-
-<h3 class="appendixsec">A.1 Major Changes Between V7 and SVR3.1</h3>
-
-<!-- STARTOFRANGE gawkv -->
-<p><a name="index-_0040command_007bawk_007d_002c-versions-of-1824"></a><!--
STARTOFRANGE gawkv1 -->
-<a
name="index-_0040command_007bawk_007d_002c-versions-of_002c-changes-between-V7-and-SVR3_002e1-1825"></a>
-The <samp><span class="command">awk</span></samp> language evolved
considerably between the release of
-Version 7 Unix (1978) and the new version that was first made generally
available in
-System V Release 3.1 (1987). This section summarizes the changes, with
-cross-references to further details:
-
- <ul>
-<li>The requirement for `<samp><span class="samp">;</span></samp>' to separate
rules on a line
-(see <a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>).
-
- <li>User-defined functions and the <code>return</code> statement
-(see <a href="User_002ddefined.html#User_002ddefined">User-defined</a>).
-
- <li>The <code>delete</code> statement (see <a
href="Delete.html#Delete">Delete</a>).
-
- <li>The <code>do</code>-<code>while</code> statement
-(see <a href="Do-Statement.html#Do-Statement">Do Statement</a>).
-
- <li>The built-in functions <code>atan2</code>, <code>cos</code>,
<code>sin</code>, <code>rand</code>, and
-<code>srand</code> (see <a
href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a>).
-
- <li>The built-in functions <code>gsub</code>, <code>sub</code>, and
<code>match</code>
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <li>The built-in functions <code>close</code> and <code>system</code>
-(see <a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>).
-
- <li>The <code>ARGC</code>, <code>ARGV</code>, <code>FNR</code>,
<code>RLENGTH</code>, <code>RSTART</code>,
-and <code>SUBSEP</code> built-in variables (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>).
-
- <li>The conditional expression using the ternary operator `<samp><span
class="samp">?:</span></samp>'
-(see <a href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>).
-
- <li>The exponentiation operator `<samp><span class="samp">^</span></samp>'
-(see <a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>) and its
assignment operator
-form `<samp><span class="samp">^=</span></samp>' (see <a
href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>).
-
- <li>C-compatible operator precedence, which breaks some old <samp><span
class="command">awk</span></samp>
-programs (see <a href="Precedence.html#Precedence">Precedence</a>).
-
- <li>Regexps as the value of <code>FS</code>
-(see <a href="Field-Separators.html#Field-Separators">Field Separators</a>)
and as the
-third argument to the <code>split</code> function
-(see <a href="String-Functions.html#String-Functions">String Functions</a>).
-
- <li>Dynamic regexps as operands of the `<samp><span
class="samp">~</span></samp>' and `<samp><span class="samp">!~</span></samp>'
operators
-(see <a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>).
-
- <li>The escape sequences `<samp><span class="samp">\b</span></samp>',
`<samp><span class="samp">\f</span></samp>', and `<samp><span
class="samp">\r</span></samp>'
-(see <a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>).
-(Some vendors have updated their old versions of <samp><span
class="command">awk</span></samp> to
-recognize `<samp><span class="samp">\b</span></samp>', `<samp><span
class="samp">\f</span></samp>', and `<samp><span
class="samp">\r</span></samp>', but this is not
-something you can rely on.)
-
- <li>Redirection of input for the <code>getline</code> function
-(see <a href="Getline.html#Getline">Getline</a>).
-
- <li>Multiple <code>BEGIN</code> and <code>END</code> rules
-(see <a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>).
-
- <li>Multidimensional arrays
-(see <a
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a>).
-</ul>
- <!-- ENDOFRANGE gawkv1 -->
-
- </body></html>
-
Index: manual/html_node/VMS-Compilation.html
===================================================================
RCS file: manual/html_node/VMS-Compilation.html
diff -N manual/html_node/VMS-Compilation.html
--- manual/html_node/VMS-Compilation.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,92 +0,0 @@
-<html lang="en">
-<head>
-<title>VMS Compilation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="VMS-Installation.html#VMS-Installation" title="VMS
Installation">
-<link rel="next" href="VMS-Installation-Details.html#VMS-Installation-Details"
title="VMS Installation Details">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="VMS-Compilation"></a>Next: <a rel="next" accesskey="n"
href="VMS-Installation-Details.html#VMS-Installation-Details">VMS Installation
Details</a>,
-Up: <a rel="up" accesskey="u"
href="VMS-Installation.html#VMS-Installation">VMS Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.1 Compiling <samp><span
class="command">gawk</span></samp> on VMS</h5>
-
-<p>To compile <samp><span class="command">gawk</span></samp> under VMS, there
is a <code>DCL</code> command procedure that
-issues all the necessary <code>CC</code> and <code>LINK</code> commands. There
is
-also a <samp><span class="file">Makefile</span></samp> for use with the
<code>MMS</code> utility. From the source
-directory, use either:
-
-<pre class="example"> $ @[.VMS]VMSBUILD.COM
-</pre>
- <p class="noindent">or:
-
-<pre class="example"> $ MMS/DESCRIPTION=[.VMS]DESCRIP.MMS GAWK
-</pre>
- <p>Depending upon which C compiler you are using, follow one of the sets
-of instructions in this table:
-
- <dl>
-<dt>VAX C V3.x<dd>Use either <samp><span
class="file">vmsbuild.com</span></samp> or <samp><span
class="file">descrip.mms</span></samp> as is. These use
-<code>CC/OPTIMIZE=NOLINE</code>, which is essential for Version 3.0.
-
- <br><dt>VAX C V2.x<dd>You must have Version 2.3 or 2.4; older ones won't
work. Edit either
-<samp><span class="file">vmsbuild.com</span></samp> or <samp><span
class="file">descrip.mms</span></samp> according to the comments in them.
-For <samp><span class="file">vmsbuild.com</span></samp>, this just entails
removing two `<samp><span class="samp">!</span></samp>' delimiters.
-Also edit <samp><span class="file">config.h</span></samp> (which is a copy of
file <samp><span class="file">[.config]vms-conf.h</span></samp>)
-and comment out or delete the two lines `<samp><span class="samp">#define
__STDC__ 0</span></samp>' and
-`<samp><span class="samp">#define VAXC_BUILTINS</span></samp>' near the end.
-
- <br><dt>GNU C<dd>Edit <samp><span class="file">vmsbuild.com</span></samp>
or <samp><span class="file">descrip.mms</span></samp>; the changes are different
-from those for VAX C V2.x but equally straightforward. No changes to
-<samp><span class="file">config.h</span></samp> are needed.
-
- <br><dt>DEC C<dd>Edit <samp><span class="file">vmsbuild.com</span></samp>
or <samp><span class="file">descrip.mms</span></samp> according to their
comments.
-No changes to <samp><span class="file">config.h</span></samp> are needed.
-</dl>
-
- <p><samp><span class="command">gawk</span></samp> has been tested under
VAX/VMS 5.5-1 using VAX C V3.2, and
-GNU C 1.40 and 2.3. It should work without modifications for VMS V4.6 and up.
-
- </body></html>
-
Index: manual/html_node/VMS-Installation-Details.html
===================================================================
RCS file: manual/html_node/VMS-Installation-Details.html
diff -N manual/html_node/VMS-Installation-Details.html
--- manual/html_node/VMS-Installation-Details.html 31 Aug 2004 22:04:12
-0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,94 +0,0 @@
-<html lang="en">
-<head>
-<title>VMS Installation Details - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="VMS-Installation.html#VMS-Installation" title="VMS
Installation">
-<link rel="prev" href="VMS-Compilation.html#VMS-Compilation" title="VMS
Compilation">
-<link rel="next" href="VMS-Running.html#VMS-Running" title="VMS Running">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="VMS-Installation-Details"></a>Next: <a rel="next" accesskey="n"
href="VMS-Running.html#VMS-Running">VMS Running</a>,
-Previous: <a rel="previous" accesskey="p"
href="VMS-Compilation.html#VMS-Compilation">VMS Compilation</a>,
-Up: <a rel="up" accesskey="u"
href="VMS-Installation.html#VMS-Installation">VMS Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.2 Installing <samp><span
class="command">gawk</span></samp> on VMS</h5>
-
-<p>To install <samp><span class="command">gawk</span></samp>, all you need is
a “foreign” command, which is
-a <code>DCL</code> symbol whose value begins with a dollar sign. For example:
-
-<pre class="example"> $ GAWK :== $disk1:[gnubin]GAWK
-</pre>
- <p class="noindent">Substitute the actual location of <samp><span
class="command">gawk.exe</span></samp> for
-`<samp><span class="samp">$disk1:[gnubin]</span></samp>'. The symbol should be
placed in the
-<samp><span class="file">login.com</span></samp> of any user who wants to run
<samp><span class="command">gawk</span></samp>,
-so that it is defined every time the user logs on.
-Alternatively, the symbol may be placed in the system-wide
-<samp><span class="file">sylogin.com</span></samp> procedure, which allows all
users
-to run <samp><span class="command">gawk</span></samp>.
-
- <p>Optionally, the help entry can be loaded into a VMS help library:
-
-<pre class="example"> $ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP
-</pre>
- <p class="noindent">(You may want to substitute a site-specific help
library rather than
-the standard VMS library `<samp><span class="samp">HELPLIB</span></samp>'.)
After loading the help text,
-the command:
-
-<pre class="example"> $ HELP GAWK
-</pre>
- <p class="noindent">provides information about both the <samp><span
class="command">gawk</span></samp> implementation and the
-<samp><span class="command">awk</span></samp> programming language.
-
- <p>The logical name `<samp><span class="samp">AWK_LIBRARY</span></samp>'
can designate a default location
-for <samp><span class="command">awk</span></samp> program files. For the
<samp><span class="option">-f</span></samp> option, if the specified
-file name has no device or directory path information in it, <samp><span
class="command">gawk</span></samp>
-looks in the current directory first, then in the directory specified
-by the translation of `<samp><span class="samp">AWK_LIBRARY</span></samp>' if
the file is not found.
-If, after searching in both directories, the file still is not found,
-<samp><span class="command">gawk</span></samp> appends the suffix `<samp><span
class="samp">.awk</span></samp>' to the filename and retries
-the file search. If `<samp><span class="samp">AWK_LIBRARY</span></samp>' is
not defined, that
-portion of the file search fails benignly.
-
- </body></html>
-
Index: manual/html_node/VMS-Installation.html
===================================================================
RCS file: manual/html_node/VMS-Installation.html
diff -N manual/html_node/VMS-Installation.html
--- manual/html_node/VMS-Installation.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,67 +0,0 @@
-<html lang="en">
-<head>
-<title>VMS Installation - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Non_002dUnix-Installation.html#Non_002dUnix-Installation"
title="Non-Unix Installation">
-<link rel="prev" href="PC-Installation.html#PC-Installation" title="PC
Installation">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="VMS-Installation"></a>Previous: <a rel="previous" accesskey="p"
href="PC-Installation.html#PC-Installation">PC Installation</a>,
-Up: <a rel="up" accesskey="u"
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>
-<hr><br>
-</div>
-
-<h4 class="appendixsubsec">B.3.4 How to Compile and Install <samp><span
class="command">gawk</span></samp> on VMS</h4>
-
-<!-- based on material from Pat Rankin <address@hidden> -->
-<!-- now address@hidden -->
-<p><a name="index-installation_002c-vms-1912"></a>This subsection describes
how to compile and install <samp><span class="command">gawk</span></samp> under
VMS.
-
-<ul class="menu">
-<li><a accesskey="1" href="VMS-Compilation.html#VMS-Compilation">VMS
Compilation</a>: How to compile <samp><span
class="command">gawk</span></samp> under VMS.
-<li><a accesskey="2"
href="VMS-Installation-Details.html#VMS-Installation-Details">VMS Installation
Details</a>: How to install <samp><span class="command">gawk</span></samp>
under VMS.
-<li><a accesskey="3" href="VMS-Running.html#VMS-Running">VMS Running</a>:
How to run <samp><span class="command">gawk</span></samp> under
VMS.
-<li><a accesskey="4" href="VMS-POSIX.html#VMS-POSIX">VMS POSIX</a>:
Alternate instructions for VMS POSIX.
-</ul>
-
- </body></html>
-
Index: manual/html_node/VMS-POSIX.html
===================================================================
RCS file: manual/html_node/VMS-POSIX.html
diff -N manual/html_node/VMS-POSIX.html
--- manual/html_node/VMS-POSIX.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,79 +0,0 @@
-<html lang="en">
-<head>
-<title>VMS POSIX - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="VMS-Installation.html#VMS-Installation" title="VMS
Installation">
-<link rel="prev" href="VMS-Running.html#VMS-Running" title="VMS Running">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="VMS-POSIX"></a>Previous: <a rel="previous" accesskey="p"
href="VMS-Running.html#VMS-Running">VMS Running</a>,
-Up: <a rel="up" accesskey="u"
href="VMS-Installation.html#VMS-Installation">VMS Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.4 Building and Using <samp><span
class="command">gawk</span></samp> on VMS POSIX</h5>
-
-<p>Ignore the instructions above, although <samp><span
class="file">vms/gawk.hlp</span></samp> should still
-be made available in a help library. The source tree should be unpacked
-into a container file subsystem rather than into the ordinary VMS filesystem.
-Make sure that the two scripts, <samp><span
class="file">configure</span></samp> and
-<samp><span class="file">vms/posix-cc.sh</span></samp>, are executable; use
`<samp><span class="samp">chmod +x</span></samp>' on them if
-necessary. Then execute the following two commands:
-
-<pre class="example"> psx> CC=vms/posix-cc.sh configure
- psx> make CC=c89 gawk
-</pre>
- <p class="noindent">The first command constructs files <samp><span
class="file">config.h</span></samp> and <samp><span
class="file">Makefile</span></samp> out
-of templates, using a script to make the C compiler fit <samp><span
class="command">configure</span></samp>'s
-expectations. The second command compiles and links <samp><span
class="command">gawk</span></samp> using
-the C compiler directly; ignore any warnings from <samp><span
class="command">make</span></samp> about being
-unable to redefine <code>CC</code>. <samp><span
class="command">configure</span></samp> takes a very long
-time to execute, but at least it provides incremental feedback as it runs.
-
- <p>This has been tested with VAX/VMS V6.2, VMS POSIX V2.0, and DEC C V5.2.
-
- <p>Once built, <samp><span class="command">gawk</span></samp> works like
any other shell utility. Unlike
-the normal VMS port of <samp><span class="command">gawk</span></samp>, no
special command-line manipulation is
-needed in the VMS POSIX environment.
-
- </body></html>
-
Index: manual/html_node/VMS-Running.html
===================================================================
RCS file: manual/html_node/VMS-Running.html
diff -N manual/html_node/VMS-Running.html
--- manual/html_node/VMS-Running.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,89 +0,0 @@
-<html lang="en">
-<head>
-<title>VMS Running - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="VMS-Installation.html#VMS-Installation" title="VMS
Installation">
-<link rel="prev" href="VMS-Installation-Details.html#VMS-Installation-Details"
title="VMS Installation Details">
-<link rel="next" href="VMS-POSIX.html#VMS-POSIX" title="VMS POSIX">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="VMS-Running"></a>Next: <a rel="next" accesskey="n"
href="VMS-POSIX.html#VMS-POSIX">VMS POSIX</a>,
-Previous: <a rel="previous" accesskey="p"
href="VMS-Installation-Details.html#VMS-Installation-Details">VMS Installation
Details</a>,
-Up: <a rel="up" accesskey="u"
href="VMS-Installation.html#VMS-Installation">VMS Installation</a>
-<hr><br>
-</div>
-
-<h5 class="appendixsubsubsec">B.3.4.3 Running <samp><span
class="command">gawk</span></samp> on VMS</h5>
-
-<p>Command-line parsing and quoting conventions are significantly different
-on VMS, so examples in this Web page or from other sources often need minor
-changes. They <em>are</em> minor though, and all <samp><span
class="command">awk</span></samp> programs
-should run correctly.
-
- <p>Here are a couple of trivial tests:
-
-<pre class="example"> $ gawk -- "BEGIN {print ""Hello, World!""}"
- $ gawk -"W" version
- ! could also be -"W version" or "-W version"
-</pre>
- <p class="noindent">Note that uppercase and mixed-case text must be quoted.
-
- <p>The VMS port of <samp><span class="command">gawk</span></samp> includes
a <code>DCL</code>-style interface in addition
-to the original shell-style interface (see the help entry for details).
-One side effect of dual command-line parsing is that if there is only a
-single parameter (as in the quoted string program above), the command
-becomes ambiguous. To work around this, the normally optional <samp><span
class="option">--</span></samp>
-flag is required to force Unix style rather than <code>DCL</code> parsing. If
any
-other dash-type options (or multiple parameters such as data files to
-process) are present, there is no ambiguity and <samp><span
class="option">--</span></samp> can be omitted.
-
-<!-- @cindex directory search -->
-<!-- @cindex path, search -->
-<p><a name="index-search-paths-1913"></a><a
name="index-search-paths_002c-for-source-files-1914"></a>The default search
path, when looking for <samp><span class="command">awk</span></samp> program
files specified
-by the <samp><span class="option">-f</span></samp> option, is
<code>"SYS$DISK:[],AWK_LIBRARY:"</code>. The logical
-name `<samp><span class="samp">AWKPATH</span></samp>' can be used to override
this default. The format
-of `<samp><span class="samp">AWKPATH</span></samp>' is a comma-separated list
of directory specifications.
-When defining it, the value should be quoted so that it retains a single
-translation and not a multitranslation <code>RMS</code> searchlist.
-
- </body></html>
-
Index: manual/html_node/Variables.html
===================================================================
RCS file: manual/html_node/Variables.html
diff -N manual/html_node/Variables.html
--- manual/html_node/Variables.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,70 +0,0 @@
-<html lang="en">
-<head>
-<title>Variables - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Expressions.html#Expressions" title="Expressions">
-<link rel="prev" href="Using-Constant-Regexps.html#Using-Constant-Regexps"
title="Using Constant Regexps">
-<link rel="next" href="Conversion.html#Conversion" title="Conversion">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Variables"></a>Next: <a rel="next" accesskey="n"
href="Conversion.html#Conversion">Conversion</a>,
-Previous: <a rel="previous" accesskey="p"
href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using Constant
Regexps</a>,
-Up: <a rel="up" accesskey="u"
href="Expressions.html#Expressions">Expressions</a>
-<hr><br>
-</div>
-
-<h3 class="section">5.3 Variables</h3>
-
-<p><a name="index-variables_002c-user_002ddefined-632"></a><a
name="index-user_002ddefined_002c-variables-633"></a>Variables are ways of
storing values at one point in your program for
-use later in another part of your program. They can be manipulated
-entirely within the program text, and they can also be assigned values
-on the <samp><span class="command">awk</span></samp> command line.
-
-<ul class="menu">
-<li><a accesskey="1" href="Using-Variables.html#Using-Variables">Using
Variables</a>: Using variables in your programs.
-<li><a accesskey="2"
href="Assignment-Options.html#Assignment-Options">Assignment Options</a>:
Setting variables on the command-line and a
- summary of command-line syntax. This is an
- advanced method of input.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Very-Simple.html
===================================================================
RCS file: manual/html_node/Very-Simple.html
diff -N manual/html_node/Very-Simple.html
--- manual/html_node/Very-Simple.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,174 +0,0 @@
-<html lang="en">
-<head>
-<title>Very Simple - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="Sample-Data-Files.html#Sample-Data-Files" title="Sample
Data Files">
-<link rel="next" href="Two-Rules.html#Two-Rules" title="Two Rules">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Very-Simple"></a>Next: <a rel="next" accesskey="n"
href="Two-Rules.html#Two-Rules">Two Rules</a>,
-Previous: <a rel="previous" accesskey="p"
href="Sample-Data-Files.html#Sample-Data-Files">Sample Data Files</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.3 Some Simple Examples</h3>
-
-<p>The following command runs a simple <samp><span
class="command">awk</span></samp> program that searches the
-input file <samp><span class="file">BBS-list</span></samp> for the character
string `<samp><span class="samp">foo</span></samp>' (a
-grouping of characters is usually called a <dfn>string</dfn>;
-the term <dfn>string</dfn> is based on similar usage in English, such
-as “a string of pearls,” or “a string of cars in a
train”):
-
-<pre class="example"> awk '/foo/ { print $0 }' BBS-list
-</pre>
- <p class="noindent">When lines containing `<samp><span
class="samp">foo</span></samp>' are found, they are printed because
-`<samp><span class="samp">print $0</span></samp>'<!-- /@w --> means print
the current line. (Just `<samp><span class="samp">print</span></samp>' by
-itself means the same thing, so we could have written that
-instead.)
-
- <p>You will notice that slashes (`<samp><span
class="samp">/</span></samp>') surround the string `<samp><span
class="samp">foo</span></samp>'
-in the <samp><span class="command">awk</span></samp> program. The slashes
indicate that `<samp><span class="samp">foo</span></samp>'
-is the pattern to search for. This type of pattern is called a
-<dfn>regular expression</dfn>, which is covered in more detail later
-(see <a href="Regexp.html#Regexp">Regexp</a>).
-The pattern is allowed to match parts of words.
-There are
-single quotes around the <samp><span class="command">awk</span></samp> program
so that the shell won't
-interpret any of it as special shell characters.
-
- <p>Here is what this program prints:
-
-<pre class="example"> $ awk '/foo/ { print $0 }' BBS-list
- -| fooey 555-1234 2400/1200/300 B
- -| foot 555-6699 1200/300 B
- -| macfoo 555-6480 1200/300 A
- -| sabafoo 555-2127 1200/300 C
-</pre>
- <p><a name="index-actions_002c-default-138"></a><a
name="index-patterns_002c-default-139"></a>In an <samp><span
class="command">awk</span></samp> rule, either the pattern or the action can be
omitted,
-but not both. If the pattern is omitted, then the action is performed
-for <em>every</em> input line. If the action is omitted, the default
-action is to print all lines that match the pattern.
-
- <p><a name="index-actions_002c-empty-140"></a>Thus, we could leave out the
action (the <code>print</code> statement and the curly
-braces) in the previous example and the result would be the same: all
-lines matching the pattern `<samp><span class="samp">foo</span></samp>' are
printed. By comparison,
-omitting the <code>print</code> statement but retaining the curly braces makes
an
-empty action that does nothing (i.e., no lines are printed).
-
- <p><a
name="index-_0040command_007bawk_007d-programs_002c-one_002dline-examples-141"></a>Many
practical <samp><span class="command">awk</span></samp> programs are just a
line or two. Following is a
-collection of useful, short programs to get you started. Some of these
-programs contain constructs that haven't been covered yet. (The description
-of the program will give you a good idea of what is going on, but please
-read the rest of the Web page to become an <samp><span
class="command">awk</span></samp> expert!)
-Most of the examples use a data file named <samp><span
class="file">data</span></samp>. This is just a
-placeholder; if you use these programs yourself, substitute
-your own file names for <samp><span class="file">data</span></samp>.
-For future reference, note that there is often more than
-one way to do things in <samp><span class="command">awk</span></samp>. At
some point, you may want
-to look back at these examples and see if
-you can come up with different ways to do the same things shown here:
-
- <ul>
-<li>Print the length of the longest input line:
-
- <pre class="example"> awk '{ if (length($0) > max) max =
length($0) }
- END { print max }' data
- </pre>
- <li>Print every line that is longer than 80 characters:
-
- <pre class="example"> awk 'length($0) > 80' data
- </pre>
- <p>The sole rule has a relational expression as its pattern and it has no
-action—so the default action, printing the record, is used.
-
- <p><a name="index-_0040command_007bexpand_007d-utility-142"></a><li>Print
the length of the longest line in <samp><span class="file">data</span></samp>:
-
- <pre class="example"> expand data | awk '{ if (x < length())
x = length() }
- END { print "maximum line length is " x }'
- </pre>
- <p>The input is processed by the <samp><span
class="command">expand</span></samp> utility to change tabs
-into spaces, so the widths compared are actually the right-margin columns.
-
- <li>Print every line that has at least one field:
-
- <pre class="example"> awk 'NF > 0' data
- </pre>
- <p>This is an easy way to delete blank lines from a file (or rather, to
-create a new file similar to the old file but from which the blank lines
-have been removed).
-
- <li>Print seven random numbers from 0 to 100, inclusive:
-
- <pre class="example"> awk 'BEGIN { for (i = 1; i <= 7; i++)
- print int(101 * rand()) }'
- </pre>
- <li>Print the total number of bytes used by <var>files</var>:
-
- <pre class="example"> ls -l <var>files</var> | awk '{ x += $5 }
- END { print "total bytes: " x }'
- </pre>
- <li>Print the total number of kilobytes used by <var>files</var>:
-
- <!-- Don't use \ continuation, not discussed yet -->
-<pre class="example"> ls -l <var>files</var> | awk '{ x += $5 }
- END { print "total K-bytes: " (x + 1023)/1024 }'
- </pre>
- <li>Print a sorted list of the login names of all users:
-
- <pre class="example"> awk -F: '{ print $1 }' /etc/passwd | sort
- </pre>
- <li>Count the lines in a file:
-
- <pre class="example"> awk 'END { print NR }' data
- </pre>
- <li>Print the even-numbered lines in the data file:
-
- <pre class="example"> awk 'NR % 2 == 0' data
- </pre>
- <p>If you use the expression `<samp><span class="samp">NR % 2 ==
1</span></samp>' instead,
-the program would print the odd-numbered lines.
-</ul>
-
- </body></html>
-
Index: manual/html_node/Wc-Program.html
===================================================================
RCS file: manual/html_node/Wc-Program.html
diff -N manual/html_node/Wc-Program.html
--- manual/html_node/Wc-Program.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,225 +0,0 @@
-<html lang="en">
-<head>
-<title>Wc Program - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Clones.html#Clones" title="Clones">
-<link rel="prev" href="Uniq-Program.html#Uniq-Program" title="Uniq Program">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Wc-Program"></a>Previous: <a rel="previous" accesskey="p"
href="Uniq-Program.html#Uniq-Program">Uniq Program</a>,
-Up: <a rel="up" accesskey="u" href="Clones.html#Clones">Clones</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.2.7 Counting Things</h4>
-
-<!-- STARTOFRANGE count -->
-<p><a name="index-counting-1779"></a><!-- STARTOFRANGE infco -->
-<a name="index-input-files_002c-counting-elements-in-1780"></a><!--
STARTOFRANGE woco -->
-<a name="index-words_002c-counting-1781"></a><!-- STARTOFRANGE chco -->
-<a name="index-characters_002c-counting-1782"></a><!-- STARTOFRANGE lico -->
-<a name="index-lines_002c-counting-1783"></a><a
name="index-_0040command_007bwc_007d-utility-1784"></a>The <samp><span
class="command">wc</span></samp> (word count) utility counts lines, words, and
characters in
-one or more input files. Its usage is as follows:
-
-<pre class="example"> wc <span class="roman">[</span>-lwc<span
class="roman">]</span> <span class="roman">[</span> <var>files</var> ... <span
class="roman">]</span>
-</pre>
- <p>If no files are specified on the command line, <samp><span
class="command">wc</span></samp> reads its standard
-input. If there are multiple files, it also prints total counts for all
-the files. The options and their meanings are shown in the following list:
-
- <dl>
-<dt><code>-l</code><dd>Count only lines.
-
- <br><dt><code>-w</code><dd>Count only words.
-A “word” is a contiguous sequence of nonwhitespace characters,
separated
-by spaces and/or tabs. Luckily, this is the normal way <samp><span
class="command">awk</span></samp> separates
-fields in its input data.
-
- <br><dt><code>-c</code><dd>Count only characters.
-</dl>
-
- <p>Implementing <samp><span class="command">wc</span></samp> in <samp><span
class="command">awk</span></samp> is particularly elegant,
-since <samp><span class="command">awk</span></samp> does a lot of the work for
us; it splits lines into
-words (i.e., fields) and counts them, it counts lines (i.e., records),
-and it can easily tell us how long a line is.
-
- <p>This uses the <code>getopt</code> library function
-(see <a href="Getopt-Function.html#Getopt-Function">Getopt Function</a>)
-and the file-transition functions
-(see <a href="Filetrans-Function.html#Filetrans-Function">Filetrans
Function</a>).
-
- <p>This version has one notable difference from traditional versions of
-<samp><span class="command">wc</span></samp>: it always prints the counts in
the order lines, words,
-and characters. Traditional versions note the order of the <samp><span
class="option">-l</span></samp>,
-<samp><span class="option">-w</span></samp>, and <samp><span
class="option">-c</span></samp> options on the command line, and print the
-counts in that order.
-
- <p>The <code>BEGIN</code> rule does the argument processing. The variable
-<code>print_total</code> is true if more than one file is named on the
-command line:
-
- <p><a name="index-_0040code_007bwc_002eawk_007d-program-1785"></a>
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- # wc.awk --- count lines, words, characters
- <!-- endfile -->
- <!-- file eg/prog/wc.awk -->
-
- # Options:
- # -l only count lines
- # -w only count words
- # -c only count characters
- #
- # Default is to count lines, words, characters
- #
- # Requires getopt and file transition library functions
-
- BEGIN {
- # let getopt print a message about
- # invalid options. we ignore them
- while ((c = getopt(ARGC, ARGV, "lwc")) != -1) {
- if (c == "l")
- do_lines = 1
- else if (c == "w")
- do_words = 1
- else if (c == "c")
- do_chars = 1
- }
- for (i = 1; i < Optind; i++)
- ARGV[i] = ""
-
- # if no options, do all
- if (! do_lines && ! do_words && ! do_chars)
- do_lines = do_words = do_chars = 1
-
- print_total = (ARGC - i > 2)
- }
- <!-- endfile -->
-</pre>
- <p>The <code>beginfile</code> function is simple; it just resets the counts
of lines,
-words, and characters to zero, and saves the current file name in
-<code>fname</code>:
-
-<!-- NEXT ED: make it lines = words = chars = 0 -->
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- function beginfile(file)
- {
- chars = lines = words = 0
- fname = FILENAME
- }
- <!-- endfile -->
-</pre>
- <p>The <code>endfile</code> function adds the current file's numbers to the
running
-totals of lines, words, and characters.<a rel="footnote" href="#fn-1"
name="fnd-1"><sup>1</sup></a> It then prints out those numbers
-for the file that was just read. It relies on <code>beginfile</code> to reset
the
-numbers for the following data file:
-<!-- ONE DAY: make the above footnote an exercise, instead of giving away the
answer. -->
-
-<!-- NEXT ED: make order for += be lines, words, chars -->
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- function endfile(file)
- {
- tchars += chars
- tlines += lines
- twords += words
- if (do_lines)
- printf "\t%d", lines
- if (do_words)
- printf "\t%d", words
- if (do_chars)
- printf "\t%d", chars
- printf "\t%s\n", fname
- }
- <!-- endfile -->
-</pre>
- <p>There is one rule that is executed for each line. It adds the length of
-the record, plus one, to <code>chars</code>. Adding one plus the record length
-is needed because the newline character separating records (the value
-of <code>RS</code>) is not part of the record itself, and thus not included
-in its length. Next, <code>lines</code> is incremented for each line read,
-and <code>words</code> is incremented by the value of <code>NF</code>, which
is the
-number of “words” on this line:
-
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- # do per line
- {
- chars += length($0) + 1 # get newline
- lines++
- words += NF
- }
- <!-- endfile -->
-</pre>
- <p>Finally, the <code>END</code> rule simply prints the totals for all the
files:
-
-<pre class="example"> <!-- file eg/prog/wc.awk -->
- END {
- if (print_total) {
- if (do_lines)
- printf "\t%d", tlines
- if (do_words)
- printf "\t%d", twords
- if (do_chars)
- printf "\t%d", tchars
- print "\ttotal"
- }
- }
- <!-- endfile -->
-</pre>
- <!-- ENDOFRANGE count -->
-<!-- ENDOFRANGE infco -->
-<!-- ENDOFRANGE lico -->
-<!-- ENDOFRANGE woco -->
-<!-- ENDOFRANGE chco -->
-<!-- ENDOFRANGE posimawk -->
-<div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <samp><span class="command">wc</span></samp> can't
just use the value of
-<code>FNR</code> in <code>endfile</code>. If you examine
-the code in
-<a href="Filetrans-Function.html#Filetrans-Function">Filetrans Function</a>,
-you will see that
-<code>FNR</code> has already been reset by the time
-<code>endfile</code> is called.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/When.html
===================================================================
RCS file: manual/html_node/When.html
diff -N manual/html_node/When.html
--- manual/html_node/When.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,99 +0,0 @@
-<html lang="en">
-<head>
-<title>When - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Getting-Started.html#Getting-Started" title="Getting
Started">
-<link rel="prev" href="Other-Features.html#Other-Features" title="Other
Features">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="When"></a>Previous: <a rel="previous" accesskey="p"
href="Other-Features.html#Other-Features">Other Features</a>,
-Up: <a rel="up" accesskey="u"
href="Getting-Started.html#Getting-Started">Getting Started</a>
-<hr><br>
-</div>
-
-<h3 class="section">1.8 When to Use <samp><span
class="command">awk</span></samp></h3>
-
-<p><a name="index-_0040command_007bawk_007d_002c-uses-for-166"></a>Now that
you've seen some of what <samp><span class="command">awk</span></samp> can do,
-you might wonder how <samp><span class="command">awk</span></samp> could be
useful for you. By using
-utility programs, advanced patterns, field separators, arithmetic
-statements, and other selection criteria, you can produce much more
-complex output. The <samp><span class="command">awk</span></samp> language is
very useful for producing
-reports from large amounts of raw data, such as summarizing information
-from the output of other utility programs like <samp><span
class="command">ls</span></samp>.
-(See <a href="More-Complex.html#More-Complex">More Complex</a>.)
-
- <p>Programs written with <samp><span class="command">awk</span></samp> are
usually much smaller than they would
-be in other languages. This makes <samp><span
class="command">awk</span></samp> programs easy to compose and
-use. Often, <samp><span class="command">awk</span></samp> programs can be
quickly composed at your terminal,
-used once, and thrown away. Because <samp><span
class="command">awk</span></samp> programs are interpreted, you
-can avoid the (usually lengthy) compilation part of the typical
-edit-compile-test-debug cycle of software development.
-
- <p>Complex programs have been written in <samp><span
class="command">awk</span></samp>, including a complete
-retargetable assembler for eight-bit microprocessors (see <a
href="Glossary.html#Glossary">Glossary</a>, for
-more information), and a microcode assembler for a special-purpose Prolog
-computer. More recently, <samp><span class="command">gawk</span></samp> was
used for writing a Wiki
-clone.<a rel="footnote" href="#fn-1" name="fnd-1"><sup>1</sup></a>
-While the original <samp><span class="command">awk</span></samp>'s
capabilities were strained by tasks
-of such complexity, modern versions are more capable. Even the Bell
-Labs version of <samp><span class="command">awk</span></samp> has fewer
predefined limits, and those
-that it has are much larger than they used to be.
-
- <p><a
name="index-_0040command_007bawk_007d-programs_002c-complex-167"></a>If you
find yourself writing <samp><span class="command">awk</span></samp> scripts of
more than, say, a few
-hundred lines, you might consider using a different programming
-language. Emacs Lisp is a good choice if you need sophisticated string
-or pattern matching capabilities. The shell is also good at string and
-pattern matching; in addition, it allows powerful use of the system
-utilities. More conventional languages, such as C, C++, and Java, offer
-better facilities for system programming and for managing the complexity
-of large programs. Programs in these languages may require more lines
-of source code than the equivalent <samp><span
class="command">awk</span></samp> programs, but they are
-easier to maintain and usually run more efficiently.
-
- <div class="footnote">
-<hr>
-<h4>Footnotes</h4><p class="footnote"><small>[<a name="fn-1"
href="#fnd-1">1</a>]</small> <a
href="http://www.awk-scripting.de/cgi/wiki.cgi/yawk/">Yet Another Wiki
Clone</a>.</p>
-
- <p><hr></div>
-
- </body></html>
-
Index: manual/html_node/While-Statement.html
===================================================================
RCS file: manual/html_node/While-Statement.html
diff -N manual/html_node/While-Statement.html
--- manual/html_node/While-Statement.html 31 Aug 2004 22:04:12 -0000
1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,102 +0,0 @@
-<html lang="en">
-<head>
-<title>While Statement - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Statements.html#Statements" title="Statements">
-<link rel="prev" href="If-Statement.html#If-Statement" title="If Statement">
-<link rel="next" href="Do-Statement.html#Do-Statement" title="Do Statement">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="While-Statement"></a>Next: <a rel="next" accesskey="n"
href="Do-Statement.html#Do-Statement">Do Statement</a>,
-Previous: <a rel="previous" accesskey="p"
href="If-Statement.html#If-Statement">If Statement</a>,
-Up: <a rel="up" accesskey="u"
href="Statements.html#Statements">Statements</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">6.4.2 The <code>while</code> Statement</h4>
-
-<p><a name="index-_0040code_007bwhile_007d-statement-951"></a><a
name="index-loops-952"></a><a
name="index-loops_002c-See-Also-_0040code_007bwhile_007d-statement-953"></a>
-In programming, a <dfn>loop</dfn> is a part of a program that can
-be executed two or more times in succession.
-The <code>while</code> statement is the simplest looping statement in
-<samp><span class="command">awk</span></samp>. It repeatedly executes a
statement as long as a condition is
-true. For example:
-
-<pre class="example"> while (<var>condition</var>)
- <var>body</var>
-</pre>
- <p><a name="index-body_002c-in-loops-954"></a><var>body</var> is a
statement called the <dfn>body</dfn> of the loop,
-and <var>condition</var> is an expression that controls how long the loop
-keeps running.
-The first thing the <code>while</code> statement does is test the
<var>condition</var>.
-If the <var>condition</var> is true, it executes the statement
<var>body</var>.
-After <var>body</var> has been executed,
-<var>condition</var> is tested again, and if it is still true, <var>body</var>
is
-executed again. This process repeats until the <var>condition</var> is no
longer
-true. If the <var>condition</var> is initially false, the body of the loop is
-never executed and <samp><span class="command">awk</span></samp> continues
with the statement following
-the loop.
-This example prints the first three fields of each record, one per line:
-
-<pre class="example"> awk '{ i = 1
- while (i <= 3) {
- print $i
- i++
- }
- }' inventory-shipped
-</pre>
- <p class="noindent">The body of this loop is a compound statement enclosed
in braces,
-containing two statements.
-The loop works in the following manner: first, the value of <code>i</code> is
set to one.
-Then, the <code>while</code> statement tests whether <code>i</code> is less
than or equal to
-three. This is true when <code>i</code> equals one, so the <code>i</code>-th
-field is printed. Then the `<samp><span class="samp">i++</span></samp>'
increments the value of <code>i</code>
-and the loop repeats. The loop terminates when <code>i</code> reaches four.
-
- <p>A newline is not required between the condition and the
-body; however using one makes the program clearer unless the body is a
-compound statement or else is very simple. The newline after the open-brace
-that begins the compound statement is not required either, but the
-program is harder to read without it.
-
- </body></html>
-
Index: manual/html_node/Word-Sorting.html
===================================================================
RCS file: manual/html_node/Word-Sorting.html
diff -N manual/html_node/Word-Sorting.html
--- manual/html_node/Word-Sorting.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,171 +0,0 @@
-<html lang="en">
-<head>
-<title>Word Sorting - The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="Miscellaneous-Programs.html#Miscellaneous-Programs"
title="Miscellaneous Programs">
-<link rel="prev" href="Labels-Program.html#Labels-Program" title="Labels
Program">
-<link rel="next" href="History-Sorting.html#History-Sorting" title="History
Sorting">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<div class="node">
-<p>
-<a name="Word-Sorting"></a>Next: <a rel="next" accesskey="n"
href="History-Sorting.html#History-Sorting">History Sorting</a>,
-Previous: <a rel="previous" accesskey="p"
href="Labels-Program.html#Labels-Program">Labels Program</a>,
-Up: <a rel="up" accesskey="u"
href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>
-<hr><br>
-</div>
-
-<h4 class="subsection">13.3.5 Generating Word-Usage Counts</h4>
-
-<!-- STARTOFRANGE worus -->
-<p><a
name="index-words_002c-usage-counts_0040comma_007b_007d-generating-1803"></a><!--
NEXT ED: Rewrite this whole section and example -->
-The following <samp><span class="command">awk</span></samp> program prints
-the number of occurrences of each word in its input. It illustrates the
-associative nature of <samp><span class="command">awk</span></samp> arrays by
using strings as subscripts. It
-also demonstrates the `<samp><span class="samp">for
</span><var>index</var><span class="samp"> in </span><var>array</var></samp>'
mechanism.
-Finally, it shows how <samp><span class="command">awk</span></samp> is used in
conjunction with other
-utility programs to do a useful task of some complexity with a minimum of
-effort. Some explanations follow the program listing:
-
-<pre class="example"> # Print list of word frequencies
- {
- for (i = 1; i <= NF; i++)
- freq[$i]++
- }
-
- END {
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
- }
-</pre>
- <!-- Exercise: Use asort() here -->
-<p>This program has two rules. The
-first rule, because it has an empty pattern, is executed for every input line.
-It uses <samp><span class="command">awk</span></samp>'s field-accessing
mechanism
-(see <a href="Fields.html#Fields">Fields</a>) to pick out the individual words
from
-the line, and the built-in variable <code>NF</code> (see <a
href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>)
-to know how many fields are available.
-For each input word, it increments an element of the array <code>freq</code> to
-reflect that the word has been seen an additional time.
-
- <p>The second rule, because it has the pattern <code>END</code>, is not
executed
-until the input has been exhausted. It prints out the contents of the
-<code>freq</code> table that has been built up inside the first action.
-This program has several problems that would prevent it from being
-useful by itself on real text files:
-
- <ul>
-<li>Words are detected using the <samp><span class="command">awk</span></samp>
convention that fields are
-separated just by whitespace. Other characters in the input (except
-newlines) don't have any special meaning to <samp><span
class="command">awk</span></samp>. This means that
-punctuation characters count as part of words.
-
- <li>The <samp><span class="command">awk</span></samp> language considers
upper- and lowercase characters to be
-distinct. Therefore, “bartender” and “Bartender” are
not treated
-as the same word. This is undesirable, since in normal text, words
-are capitalized if they begin sentences, and a frequency analyzer should not
-be sensitive to capitalization.
-
- <li>The output does not come out in any useful order. You're more likely
to be
-interested in which words occur most frequently or in having an alphabetized
-table of how frequently each word occurs.
-</ul>
-
- <p><a name="index-_0040command_007bsort_007d-utility-1804"></a>The way to
solve these problems is to use some of <samp><span
class="command">awk</span></samp>'s more advanced
-features. First, we use <code>tolower</code> to remove
-case distinctions. Next, we use <code>gsub</code> to remove punctuation
-characters. Finally, we use the system <samp><span
class="command">sort</span></samp> utility to process the
-output of the <samp><span class="command">awk</span></samp> script. Here is
the new version of
-the program:
-
- <p><a name="index-_0040code_007bwordfreq_002eawk_007d-program-1805"></a>
-<pre class="example"> <!-- file eg/prog/wordfreq.awk -->
- # wordfreq.awk --- print list of word frequencies
-
- {
- $0 = tolower($0) # remove case distinctions
- # remove punctuation
- gsub(/[^[:alnum:]_[:blank:]]/, "", $0)
- for (i = 1; i <= NF; i++)
- freq[$i]++
- }
-
- END {
- for (word in freq)
- printf "%s\t%d\n", word, freq[word]
- }
- <!-- endfile -->
-</pre>
- <p>Assuming we have saved this program in a file named <samp><span
class="file">wordfreq.awk</span></samp>,
-and that the data is in <samp><span class="file">file1</span></samp>, the
following pipeline:
-
-<pre class="example"> awk -f wordfreq.awk file1 | sort -k 2nr
-</pre>
- <p class="noindent">produces a table of the words appearing in <samp><span
class="file">file1</span></samp> in order of
-decreasing frequency. The <samp><span class="command">awk</span></samp>
program suitably massages the
-data and produces a word frequency table, which is not ordered.
-
- <p>The <samp><span class="command">awk</span></samp> script's output is
then sorted by the <samp><span class="command">sort</span></samp>
-utility and printed on the terminal. The options given to <samp><span
class="command">sort</span></samp>
-specify a sort that uses the second field of each input line (skipping
-one field), that the sort keys should be treated as numeric quantities
-(otherwise `<samp><span class="samp">15</span></samp>' would come before
`<samp><span class="samp">5</span></samp>'), and that the sorting
-should be done in descending (reverse) order.
-
- <p>The <samp><span class="command">sort</span></samp> could even be done
from within the program, by changing
-the <code>END</code> action to:
-
-<pre class="example"> <!-- file eg/prog/wordfreq.awk -->
- END {
- sort = "sort -k 2nr"
- for (word in freq)
- printf "%s\t%d\n", word, freq[word] | sort
- close(sort)
- }
- <!-- endfile -->
-</pre>
- <p>This way of sorting must be used on systems that do not
-have true pipes at the command-line (or batch-file) level.
-See the general operating system documentation for more information on how
-to use the <samp><span class="command">sort</span></samp> program.
-<!-- ENDOFRANGE worus -->
-
- </body></html>
-
Index: manual/html_node/index.html
===================================================================
RCS file: manual/html_node/index.html
diff -N manual/html_node/index.html
--- manual/html_node/index.html 31 Aug 2004 22:04:12 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,883 +0,0 @@
-<html lang="en">
-<head>
-<title>The GNU Awk User's Guide</title>
-<meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="The GNU Awk User's Guide">
-<meta name="generator" content="makeinfo 4.7">
-<link title="Top" rel="start" href="index.html#Top">
-<link rel="up" href="../index.html#dir" title="(dir)">
-<link rel="next" href="Foreword.html#Foreword" title="Foreword">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
-<!--
-Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003 Free Software Foundation, Inc.
-
-
-
- This is Edition 3 of `GAWK: Effective AWK Programming: A User's Guide for
GNU Awk',
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being ``GNU General Public License'', the Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-``GNU Free Documentation License''.
- a. ``A GNU Manual''
-
- b. ``You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development.''
- -->
-<meta http-equiv="Content-Style-Type" content="text/css">
-<style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
---></style>
-</head>
-<body>
-<h1 class="settitle">The GNU Awk User's Guide</h1>
-<div class="node">
-<p>
-<a name="Top"></a>Next: <a rel="next" accesskey="n"
href="Foreword.html#Foreword">Foreword</a>,
-Up: <a rel="up" accesskey="u" href="../index.html#dir">(dir)</a>
-<hr><br>
-</div>
-
-<h2 class="unnumbered">General Introduction</h2>
-
-<!-- Preface node should come right after the Top -->
-<!-- node, in `unnumbered' sections, then the chapter, `What is gawk'. -->
-<!-- Licensing nodes are appendices, they're not central to AWK. -->
-<p>This file documents <samp><span class="command">awk</span></samp>, a
program that you can use to select
-particular records in a file and perform operations upon them.
-
- <p>Copyright © 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003 Free Software Foundation, Inc.
- <pre class="sp">
-
-
-</pre>
-
-This is Edition 3 of <cite>GAWK: Effective AWK Programming: A User's Guide for
GNU Awk</cite>,
-for the 3.1.4 (or later) version of the GNU
-implementation of AWK.
-
- <p>Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.2 or
-any later version published by the Free Software Foundation; with the
-Invariant Sections being “GNU General Public License”, the
Front-Cover
-texts being (a) (see below), and with the Back-Cover Texts being (b)
-(see below). A copy of the license is included in the section entitled
-“GNU Free Documentation License”.
-
- <ol type=a start=1>
-<li>“A GNU Manual”
-
- <li>“You have freedom to copy and modify this GNU Manual, like GNU
-software. Copies published by the Free Software Foundation raise
-funds for GNU development.”
- </ol>
-
-<ul class="menu">
-<li><a accesskey="1" href="Foreword.html#Foreword">Foreword</a>:
Some nice words about this
- Web page.
-<li><a accesskey="2" href="Preface.html#Preface">Preface</a>:
What this Web page is about; brief
- history and acknowledgments.
-<li><a accesskey="3" href="Getting-Started.html#Getting-Started">Getting
Started</a>: A basic introduction to using
- <samp><span
class="command">awk</span></samp>. How to run an <samp><span
class="command">awk</span></samp>
- program. Command-line syntax.
-<li><a accesskey="4" href="Regexp.html#Regexp">Regexp</a>:
All about matching things using regular
- expressions.
-<li><a accesskey="5" href="Reading-Files.html#Reading-Files">Reading
Files</a>: How to read files and manipulate fields.
-<li><a accesskey="6" href="Printing.html#Printing">Printing</a>:
How to print using <samp><span class="command">awk</span></samp>.
Describes
- the <code>print</code> and
<code>printf</code>
- statements. Also describes redirection of
- output.
-<li><a accesskey="7" href="Expressions.html#Expressions">Expressions</a>:
Expressions are the basic building blocks
- of statements.
-<li><a accesskey="8"
href="Patterns-and-Actions.html#Patterns-and-Actions">Patterns and Actions</a>:
Overviews of patterns and actions.
-<li><a accesskey="9" href="Arrays.html#Arrays">Arrays</a>:
The description and use of arrays. Also
- includes array-oriented control statements.
-<li><a href="Functions.html#Functions">Functions</a>:
Built-in and user-defined functions.
-<li><a
href="Internationalization.html#Internationalization">Internationalization</a>:
Getting <samp><span class="command">gawk</span></samp> to speak your
- language.
-<li><a href="Advanced-Features.html#Advanced-Features">Advanced Features</a>:
Stuff for advanced users, specific to
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="Invoking-Gawk.html#Invoking-Gawk">Invoking Gawk</a>:
How to run <samp><span class="command">gawk</span></samp>.
-<li><a href="Library-Functions.html#Library-Functions">Library Functions</a>:
A Library of <samp><span class="command">awk</span></samp>
Functions.
-<li><a href="Sample-Programs.html#Sample-Programs">Sample Programs</a>:
Many <samp><span class="command">awk</span></samp> programs with
complete
- explanations.
-<li><a href="Language-History.html#Language-History">Language History</a>:
The evolution of the <samp><span class="command">awk</span></samp>
- language.
-<li><a href="Installation.html#Installation">Installation</a>:
Installing <samp><span class="command">gawk</span></samp> under various
- operating systems.
-<li><a href="Notes.html#Notes">Notes</a>: Notes
about <samp><span class="command">gawk</span></samp> extensions and
- possible future work.
-<li><a href="Basic-Concepts.html#Basic-Concepts">Basic Concepts</a>:
A very quick intoduction to programming
- concepts.
-<li><a href="Glossary.html#Glossary">Glossary</a>: An
explanation of some unfamiliar terms.
-<li><a href="Copying.html#Copying">Copying</a>: Your
right to copy and distribute
- <samp><span
class="command">gawk</span></samp>.
-<li><a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>: The license for this Web page.
-<li><a href="Index.html#Index">Index</a>: Concept
and Variable Index.
-
-<li><a href="History.html#History">History</a>: The
history of <samp><span class="command">gawk</span></samp> and
- <samp><span
class="command">awk</span></samp>.
-<li><a href="Names.html#Names">Names</a>: What name
to use to find <samp><span class="command">awk</span></samp>.
-<li><a href="This-Manual.html#This-Manual">This Manual</a>:
Using this Web page. Includes
- sample input files that you can use.
-<li><a href="Conventions.html#Conventions">Conventions</a>:
Typographical Conventions.
-<li><a href="Manual-History.html#Manual-History">Manual History</a>:
Brief history of the GNU project and this
- Web page.
-<li><a href="How-To-Contribute.html#How-To-Contribute">How To Contribute</a>:
Helping to save the world.
-<li><a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a>:
Acknowledgments.
-<li><a href="Running-gawk.html#Running-gawk">Running gawk</a>:
How to run <samp><span class="command">gawk</span></samp> programs;
- includes command-line syntax.
-<li><a href="One_002dshot.html#One_002dshot">One-shot</a>:
Running a short throwaway <samp><span class="command">awk</span></samp>
- program.
-<li><a href="Read-Terminal.html#Read-Terminal">Read Terminal</a>:
Using no input files (input from terminal
- instead).
-<li><a href="Long.html#Long">Long</a>: Putting
permanent <samp><span class="command">awk</span></samp> programs in
- files.
-<li><a href="Executable-Scripts.html#Executable-Scripts">Executable
Scripts</a>: Making self-contained <samp><span
class="command">awk</span></samp>
- programs.
-<li><a href="Comments.html#Comments">Comments</a>:
Adding documentation to <samp><span class="command">gawk</span></samp>
- programs.
-<li><a href="Quoting.html#Quoting">Quoting</a>: More
discussion of shell quoting issues.
-<li><a href="Sample-Data-Files.html#Sample-Data-Files">Sample Data Files</a>:
Sample data files for use in the
- <samp><span
class="command">awk</span></samp> programs illustrated in this
- Web page.
-<li><a href="Very-Simple.html#Very-Simple">Very Simple</a>:
A very simple example.
-<li><a href="Two-Rules.html#Two-Rules">Two Rules</a>: A
less simple one-line example using two
- rules.
-<li><a href="More-Complex.html#More-Complex">More Complex</a>:
A more complex example.
-<li><a
href="Statements_002fLines.html#Statements_002fLines">Statements/Lines</a>:
Subdividing or combining statements into
- lines.
-<li><a href="Other-Features.html#Other-Features">Other Features</a>:
Other Features of <samp><span class="command">awk</span></samp>.
-<li><a href="When.html#When">When</a>: When to use
<samp><span class="command">gawk</span></samp> and when to use
- other things.
-<li><a href="Regexp-Usage.html#Regexp-Usage">Regexp Usage</a>:
How to Use Regular Expressions.
-<li><a href="Escape-Sequences.html#Escape-Sequences">Escape Sequences</a>:
How to write nonprinting characters.
-<li><a href="Regexp-Operators.html#Regexp-Operators">Regexp Operators</a>:
Regular Expression Operators.
-<li><a href="Character-Lists.html#Character-Lists">Character Lists</a>:
What can go between `<samp><span class="samp">[...]</span></samp>'.
-<li><a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">GNU Regexp
Operators</a>: Operators specific to GNU software.
-<li><a
href="Case_002dsensitivity.html#Case_002dsensitivity">Case-sensitivity</a>:
How to do case-insensitive matching.
-<li><a href="Leftmost-Longest.html#Leftmost-Longest">Leftmost Longest</a>:
How much text matches.
-<li><a href="Computed-Regexps.html#Computed-Regexps">Computed Regexps</a>:
Using Dynamic Regexps.
-<li><a href="Locales.html#Locales">Locales</a>: How
the locale affects things.
-<li><a href="Records.html#Records">Records</a>:
Controlling how data is split into records.
-<li><a href="Fields.html#Fields">Fields</a>: An
introduction to fields.
-<li><a href="Nonconstant-Fields.html#Nonconstant-Fields">Nonconstant
Fields</a>: Nonconstant Field Numbers.
-<li><a href="Changing-Fields.html#Changing-Fields">Changing Fields</a>:
Changing the Contents of a Field.
-<li><a href="Field-Separators.html#Field-Separators">Field Separators</a>:
The field separator and how to change it.
-<li><a href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">Regexp Field
Splitting</a>: Using regexps as the field separator.
-<li><a href="Single-Character-Fields.html#Single-Character-Fields">Single
Character Fields</a>: Making each character a separate field.
-<li><a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">Command
Line Field Separator</a>: Setting <code>FS</code> from the command-line.
-<li><a href="Field-Splitting-Summary.html#Field-Splitting-Summary">Field
Splitting Summary</a>: Some final points and a summary table.
-<li><a href="Constant-Size.html#Constant-Size">Constant Size</a>:
Reading constant width data.
-<li><a href="Multiple-Line.html#Multiple-Line">Multiple Line</a>:
Reading multi-line records.
-<li><a href="Getline.html#Getline">Getline</a>:
Reading files under explicit program
- control using the <code>getline</code>
function.
-<li><a href="Plain-Getline.html#Plain-Getline">Plain Getline</a>:
Using <code>getline</code> with no arguments.
-<li><a
href="Getline_002fVariable.html#Getline_002fVariable">Getline/Variable</a>:
Using <code>getline</code> into a variable.
-<li><a href="Getline_002fFile.html#Getline_002fFile">Getline/File</a>:
Using <code>getline</code> from a file.
-<li><a
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">Getline/Variable/File</a>:
Using <code>getline</code> into a variable from a
- file.
-<li><a href="Getline_002fPipe.html#Getline_002fPipe">Getline/Pipe</a>:
Using <code>getline</code> from a pipe.
-<li><a
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">Getline/Variable/Pipe</a>:
Using <code>getline</code> into a variable from a
- pipe.
-<li><a
href="Getline_002fCoprocess.html#Getline_002fCoprocess">Getline/Coprocess</a>:
Using <code>getline</code> from a coprocess.
-<li><a
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess">Getline/Variable/Coprocess</a>:
Using <code>getline</code> into a variable from a
- coprocess.
-<li><a href="Getline-Notes.html#Getline-Notes">Getline Notes</a>:
Important things to know about
- <code>getline</code>.
-<li><a href="Getline-Summary.html#Getline-Summary">Getline Summary</a>:
Summary of <code>getline</code> Variants.
-<li><a href="Print.html#Print">Print</a>: The
<code>print</code> statement.
-<li><a href="Print-Examples.html#Print-Examples">Print Examples</a>:
Simple examples of <code>print</code> statements.
-<li><a href="Output-Separators.html#Output-Separators">Output Separators</a>:
The output separators and how to change
- them.
-<li><a href="OFMT.html#OFMT">OFMT</a>: Controlling
Numeric Output With
- <code>print</code>.
-<li><a href="Printf.html#Printf">Printf</a>: The
<code>printf</code> statement.
-<li><a href="Basic-Printf.html#Basic-Printf">Basic Printf</a>:
Syntax of the <code>printf</code> statement.
-<li><a href="Control-Letters.html#Control-Letters">Control Letters</a>:
Format-control letters.
-<li><a href="Format-Modifiers.html#Format-Modifiers">Format Modifiers</a>:
Format-specification modifiers.
-<li><a href="Printf-Examples.html#Printf-Examples">Printf Examples</a>:
Several examples.
-<li><a href="Redirection.html#Redirection">Redirection</a>:
How to redirect output to multiple files
- and pipes.
-<li><a href="Special-Files.html#Special-Files">Special Files</a>:
File name interpretation in <samp><span
class="command">gawk</span></samp>.
- <samp><span
class="command">gawk</span></samp> allows access to inherited
- file descriptors.
-<li><a href="Special-FD.html#Special-FD">Special FD</a>:
Special files for I/O.
-<li><a href="Special-Process.html#Special-Process">Special Process</a>:
Special files for process information.
-<li><a href="Special-Network.html#Special-Network">Special Network</a>:
Special files for network communications.
-<li><a href="Special-Caveats.html#Special-Caveats">Special Caveats</a>:
Things to watch out for.
-<li><a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">Close Files And
Pipes</a>: Closing Input and Output Files and Pipes.
-<li><a href="Constants.html#Constants">Constants</a>:
String, numeric and regexp constants.
-<li><a href="Scalar-Constants.html#Scalar-Constants">Scalar Constants</a>:
Numeric and string constants.
-<li><a
href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">Nondecimal-numbers</a>:
What are octal and hex numbers.
-<li><a href="Regexp-Constants.html#Regexp-Constants">Regexp Constants</a>:
Regular Expression constants.
-<li><a href="Using-Constant-Regexps.html#Using-Constant-Regexps">Using
Constant Regexps</a>: When and how to use a regexp constant.
-<li><a href="Variables.html#Variables">Variables</a>:
Variables give names to values for later
- use.
-<li><a href="Using-Variables.html#Using-Variables">Using Variables</a>:
Using variables in your programs.
-<li><a href="Assignment-Options.html#Assignment-Options">Assignment
Options</a>: Setting variables on the command-line and a
- summary of command-line syntax. This is an
- advanced method of input.
-<li><a href="Conversion.html#Conversion">Conversion</a>:
The conversion of strings to numbers and
- vice versa.
-<li><a href="Arithmetic-Ops.html#Arithmetic-Ops">Arithmetic Ops</a>:
Arithmetic operations (`<samp><span class="samp">+</span></samp>',
`<samp><span class="samp">-</span></samp>',
- etc.)
-<li><a href="Concatenation.html#Concatenation">Concatenation</a>:
Concatenating strings.
-<li><a href="Assignment-Ops.html#Assignment-Ops">Assignment Ops</a>:
Changing the value of a variable or a
- field.
-<li><a href="Increment-Ops.html#Increment-Ops">Increment Ops</a>:
Incrementing the numeric value of a
- variable.
-<li><a href="Truth-Values.html#Truth-Values">Truth Values</a>:
What is ``true'' and what is ``false''.
-<li><a href="Typing-and-Comparison.html#Typing-and-Comparison">Typing and
Comparison</a>: How variables acquire types and how this
- affects comparison of numbers and strings
- with `<samp><span
class="samp"><</span></samp>', etc.
-<li><a href="Boolean-Ops.html#Boolean-Ops">Boolean Ops</a>:
Combining comparison expressions using
- boolean operators `<samp><span
class="samp">||</span></samp>' (``or''),
- `<samp><span
class="samp">&&</span></samp>' (``and'') and `<samp><span
class="samp">!</span></samp>' (``not'').
-<li><a href="Conditional-Exp.html#Conditional-Exp">Conditional Exp</a>:
Conditional expressions select between two
- subexpressions under control of a third
- subexpression.
-<li><a href="Function-Calls.html#Function-Calls">Function Calls</a>:
A function call is an expression.
-<li><a href="Precedence.html#Precedence">Precedence</a>:
How various operators nest.
-<li><a href="Pattern-Overview.html#Pattern-Overview">Pattern Overview</a>:
What goes into a pattern.
-<li><a href="Regexp-Patterns.html#Regexp-Patterns">Regexp Patterns</a>:
Using regexps as patterns.
-<li><a href="Expression-Patterns.html#Expression-Patterns">Expression
Patterns</a>: Any expression can be used as a pattern.
-<li><a href="Ranges.html#Ranges">Ranges</a>: Pairs of
patterns specify record ranges.
-<li><a href="BEGIN_002fEND.html#BEGIN_002fEND">BEGIN/END</a>:
Specifying initialization and cleanup
- rules.
-<li><a href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">Using
BEGIN/END</a>: How and why to use BEGIN/END rules.
-<li><a href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">I/O And
BEGIN/END</a>: I/O issues in BEGIN/END rules.
-<li><a href="Empty.html#Empty">Empty</a>: The empty
pattern, which matches every
- record.
-<li><a href="Using-Shell-Variables.html#Using-Shell-Variables">Using Shell
Variables</a>: How to use shell variables with
- <samp><span
class="command">awk</span></samp>.
-<li><a href="Action-Overview.html#Action-Overview">Action Overview</a>:
What goes into an action.
-<li><a href="Statements.html#Statements">Statements</a>:
Describes the various control statements in
- detail.
-<li><a href="If-Statement.html#If-Statement">If Statement</a>:
Conditionally execute some <samp><span class="command">awk</span></samp>
- statements.
-<li><a href="While-Statement.html#While-Statement">While Statement</a>:
Loop until some condition is satisfied.
-<li><a href="Do-Statement.html#Do-Statement">Do Statement</a>:
Do specified action while looping until
- some condition is satisfied.
-<li><a href="For-Statement.html#For-Statement">For Statement</a>:
Another looping statement, that provides
- initialization and increment clauses.
-<li><a href="Switch-Statement.html#Switch-Statement">Switch Statement</a>:
Switch/case evaluation for conditional
- execution of statements based on a value.
-<li><a href="Break-Statement.html#Break-Statement">Break Statement</a>:
Immediately exit the innermost enclosing
- loop.
-<li><a href="Continue-Statement.html#Continue-Statement">Continue
Statement</a>: Skip to the end of the innermost enclosing
- loop.
-<li><a href="Next-Statement.html#Next-Statement">Next Statement</a>:
Stop processing the current input record.
-<li><a href="Nextfile-Statement.html#Nextfile-Statement">Nextfile
Statement</a>: Stop processing the current file.
-<li><a href="Exit-Statement.html#Exit-Statement">Exit Statement</a>:
Stop execution of <samp><span class="command">awk</span></samp>.
-<li><a href="Built_002din-Variables.html#Built_002din-Variables">Built-in
Variables</a>: Summarizes the built-in variables.
-<li><a href="User_002dmodified.html#User_002dmodified">User-modified</a>:
Built-in variables that you change to
- control <samp><span
class="command">awk</span></samp>.
-<li><a href="Auto_002dset.html#Auto_002dset">Auto-set</a>:
Built-in variables where <samp><span class="command">awk</span></samp>
- gives you information.
-<li><a href="ARGC-and-ARGV.html#ARGC-and-ARGV">ARGC and ARGV</a>:
Ways to use <code>ARGC</code> and <code>ARGV</code>.
-<li><a href="Array-Intro.html#Array-Intro">Array Intro</a>:
Introduction to Arrays
-<li><a href="Reference-to-Elements.html#Reference-to-Elements">Reference to
Elements</a>: How to examine one element of an array.
-<li><a href="Assigning-Elements.html#Assigning-Elements">Assigning
Elements</a>: How to change an element of an array.
-<li><a href="Array-Example.html#Array-Example">Array Example</a>:
Basic Example of an Array
-<li><a href="Scanning-an-Array.html#Scanning-an-Array">Scanning an Array</a>:
A variation of the <code>for</code> statement. It
- loops through the indices of an array's
- existing elements.
-<li><a href="Delete.html#Delete">Delete</a>: The
<code>delete</code> statement removes an
- element from an array.
-<li><a href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">Numeric
Array Subscripts</a>: How to use numbers as subscripts in
- <samp><span
class="command">awk</span></samp>.
-<li><a
href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">Uninitialized
Subscripts</a>: Using Uninitialized variables as
- subscripts.
-<li><a
href="Multi_002ddimensional.html#Multi_002ddimensional">Multi-dimensional</a>:
Emulating multidimensional arrays in
- <samp><span
class="command">awk</span></samp>.
-<li><a href="Multi_002dscanning.html#Multi_002dscanning">Multi-scanning</a>:
Scanning multidimensional arrays.
-<li><a href="Array-Sorting.html#Array-Sorting">Array Sorting</a>:
Sorting array values and indices.
-<li><a href="Built_002din.html#Built_002din">Built-in</a>:
Summarizes the built-in functions.
-<li><a href="Calling-Built_002din.html#Calling-Built_002din">Calling
Built-in</a>: How to call built-in functions.
-<li><a href="Numeric-Functions.html#Numeric-Functions">Numeric Functions</a>:
Functions that work with numbers, including
- <code>int</code>, <code>sin</code> and
<code>rand</code>.
-<li><a href="String-Functions.html#String-Functions">String Functions</a>:
Functions for string manipulation, such as
- <code>split</code>, <code>match</code> and
- <code>sprintf</code>.
-<li><a href="Gory-Details.html#Gory-Details">Gory Details</a>:
More than you want to know about `<samp><span class="samp">\</span></samp>'
- and `<samp><span
class="samp">&</span></samp>' with <code>sub</code>, <code>gsub</code>,
- and <code>gensub</code>.
-<li><a href="I_002fO-Functions.html#I_002fO-Functions">I/O Functions</a>:
Functions for files and shell commands.
-<li><a href="Time-Functions.html#Time-Functions">Time Functions</a>:
Functions for dealing with timestamps.
-<li><a href="Bitwise-Functions.html#Bitwise-Functions">Bitwise Functions</a>:
Functions for bitwise operations.
-<li><a href="I18N-Functions.html#I18N-Functions">I18N Functions</a>:
Functions for string translation.
-<li><a href="User_002ddefined.html#User_002ddefined">User-defined</a>:
Describes User-defined functions in detail.
-<li><a href="Definition-Syntax.html#Definition-Syntax">Definition Syntax</a>:
How to write definitions and what they
- mean.
-<li><a href="Function-Example.html#Function-Example">Function Example</a>:
An example function definition and what it
- does.
-<li><a href="Function-Caveats.html#Function-Caveats">Function Caveats</a>:
Things to watch out for.
-<li><a href="Return-Statement.html#Return-Statement">Return Statement</a>:
Specifying the value a function returns.
-<li><a href="Dynamic-Typing.html#Dynamic-Typing">Dynamic Typing</a>:
How variable types can change at runtime.
-<li><a href="I18N-and-L10N.html#I18N-and-L10N">I18N and L10N</a>:
Internationalization and Localization.
-<li><a href="Explaining-gettext.html#Explaining-gettext">Explaining
gettext</a>: How GNU <code>gettext</code> works.
-<li><a href="Programmer-i18n.html#Programmer-i18n">Programmer i18n</a>:
Features for the programmer.
-<li><a href="Translator-i18n.html#Translator-i18n">Translator i18n</a>:
Features for the translator.
-<li><a href="String-Extraction.html#String-Extraction">String Extraction</a>:
Extracting marked strings.
-<li><a href="Printf-Ordering.html#Printf-Ordering">Printf Ordering</a>:
Rearranging <code>printf</code> arguments.
-<li><a href="I18N-Portability.html#I18N-Portability">I18N Portability</a>:
<samp><span class="command">awk</span></samp>-level portability
issues.
-<li><a href="I18N-Example.html#I18N-Example">I18N Example</a>:
A simple i18n example.
-<li><a href="Gawk-I18N.html#Gawk-I18N">Gawk I18N</a>:
<samp><span class="command">gawk</span></samp> is also internationalized.
-<li><a href="Nondecimal-Data.html#Nondecimal-Data">Nondecimal Data</a>:
Allowing nondecimal input data.
-<li><a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">Two-way I/O</a>:
Two-way communications with another
- process.
-<li><a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">TCP/IP
Networking</a>: Using <samp><span
class="command">gawk</span></samp> for network
- programming.
-<li><a href="Portal-Files.html#Portal-Files">Portal Files</a>:
Using <samp><span class="command">gawk</span></samp> with BSD portals.
-<li><a href="Profiling.html#Profiling">Profiling</a>:
Profiling your <samp><span class="command">awk</span></samp> programs.
-<li><a href="Command-Line.html#Command-Line">Command Line</a>:
How to run <samp><span class="command">awk</span></samp>.
-<li><a href="Options.html#Options">Options</a>:
Command-line options and their meanings.
-<li><a href="Other-Arguments.html#Other-Arguments">Other Arguments</a>:
Input file names and variable assignments.
-<li><a href="AWKPATH-Variable.html#AWKPATH-Variable">AWKPATH Variable</a>:
Searching directories for <samp><span
class="command">awk</span></samp>
- programs.
-<li><a href="Obsolete.html#Obsolete">Obsolete</a>:
Obsolete Options and/or features.
-<li><a href="Undocumented.html#Undocumented">Undocumented</a>:
Undocumented Options and Features.
-<li><a href="Known-Bugs.html#Known-Bugs">Known Bugs</a>:
Known Bugs in <samp><span class="command">gawk</span></samp>.
-<li><a href="Library-Names.html#Library-Names">Library Names</a>:
How to best name private global variables
- in library functions.
-<li><a href="General-Functions.html#General-Functions">General Functions</a>:
Functions that are of general use.
-<li><a href="Nextfile-Function.html#Nextfile-Function">Nextfile Function</a>:
Two implementations of a <code>nextfile</code>
- function.
-<li><a href="Assert-Function.html#Assert-Function">Assert Function</a>:
A function for assertions in <samp><span
class="command">awk</span></samp>
- programs.
-<li><a href="Round-Function.html#Round-Function">Round Function</a>:
A function for rounding if <code>sprintf</code>
- does not do it correctly.
-<li><a href="Cliff-Random-Function.html#Cliff-Random-Function">Cliff Random
Function</a>: The Cliff Random Number Generator.
-<li><a href="Ordinal-Functions.html#Ordinal-Functions">Ordinal Functions</a>:
Functions for using characters as numbers
- and vice versa.
-<li><a href="Join-Function.html#Join-Function">Join Function</a>:
A function to join an array into a string.
-<li><a href="Gettimeofday-Function.html#Gettimeofday-Function">Gettimeofday
Function</a>: A function to get formatted times.
-<li><a href="Data-File-Management.html#Data-File-Management">Data File
Management</a>: Functions for managing command-line data
- files.
-<li><a href="Filetrans-Function.html#Filetrans-Function">Filetrans
Function</a>: A function for handling data file
- transitions.
-<li><a href="Rewind-Function.html#Rewind-Function">Rewind Function</a>:
A function for rereading the current file.
-<li><a href="File-Checking.html#File-Checking">File Checking</a>:
Checking that data files are readable.
-<li><a href="Empty-Files.html#Empty-Files">Empty Files</a>:
Checking for zero-length files.
-<li><a href="Ignoring-Assigns.html#Ignoring-Assigns">Ignoring Assigns</a>:
Treating assignments as file names.
-<li><a href="Getopt-Function.html#Getopt-Function">Getopt Function</a>:
A function for processing command-line
- arguments.
-<li><a href="Passwd-Functions.html#Passwd-Functions">Passwd Functions</a>:
Functions for getting user information.
-<li><a href="Group-Functions.html#Group-Functions">Group Functions</a>:
Functions for getting group information.
-<li><a href="Running-Examples.html#Running-Examples">Running Examples</a>:
How to run these examples.
-<li><a href="Clones.html#Clones">Clones</a>: Clones
of common utilities.
-<li><a href="Cut-Program.html#Cut-Program">Cut Program</a>:
The <samp><span class="command">cut</span></samp> utility.
-<li><a href="Egrep-Program.html#Egrep-Program">Egrep Program</a>:
The <samp><span class="command">egrep</span></samp> utility.
-<li><a href="Id-Program.html#Id-Program">Id Program</a>:
The <samp><span class="command">id</span></samp> utility.
-<li><a href="Split-Program.html#Split-Program">Split Program</a>:
The <samp><span class="command">split</span></samp> utility.
-<li><a href="Tee-Program.html#Tee-Program">Tee Program</a>:
The <samp><span class="command">tee</span></samp> utility.
-<li><a href="Uniq-Program.html#Uniq-Program">Uniq Program</a>:
The <samp><span class="command">uniq</span></samp> utility.
-<li><a href="Wc-Program.html#Wc-Program">Wc Program</a>:
The <samp><span class="command">wc</span></samp> utility.
-<li><a href="Miscellaneous-Programs.html#Miscellaneous-Programs">Miscellaneous
Programs</a>: Some interesting <samp><span
class="command">awk</span></samp> programs.
-<li><a href="Dupword-Program.html#Dupword-Program">Dupword Program</a>:
Finding duplicated words in a document.
-<li><a href="Alarm-Program.html#Alarm-Program">Alarm Program</a>:
An alarm clock.
-<li><a href="Translate-Program.html#Translate-Program">Translate Program</a>:
A program similar to the <samp><span
class="command">tr</span></samp>
- utility.
-<li><a href="Labels-Program.html#Labels-Program">Labels Program</a>:
Printing mailing labels.
-<li><a href="Word-Sorting.html#Word-Sorting">Word Sorting</a>:
A program to produce a word usage count.
-<li><a href="History-Sorting.html#History-Sorting">History Sorting</a>:
Eliminating duplicate entries from a
- history file.
-<li><a href="Extract-Program.html#Extract-Program">Extract Program</a>:
Pulling out programs from Texinfo source
- files.
-<li><a href="Simple-Sed.html#Simple-Sed">Simple Sed</a>:
A Simple Stream Editor.
-<li><a href="Igawk-Program.html#Igawk-Program">Igawk Program</a>:
A wrapper for <samp><span class="command">awk</span></samp> that includes
- files.
-<li><a href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">V7/SVR3.1</a>:
The major changes between V7 and System V
- Release 3.1.
-<li><a href="SVR4.html#SVR4">SVR4</a>: Minor
changes between System V Releases 3.1
- and 4.
-<li><a href="POSIX.html#POSIX">POSIX</a>: New
features from the POSIX standard.
-<li><a href="BTL.html#BTL">BTL</a>: New features
from the Bell Laboratories
- version of <samp><span
class="command">awk</span></samp>.
-<li><a href="POSIX_002fGNU.html#POSIX_002fGNU">POSIX/GNU</a>:
The extensions in <samp><span class="command">gawk</span></samp> not in
- POSIX <samp><span
class="command">awk</span></samp>.
-<li><a href="Contributors.html#Contributors">Contributors</a>:
The major contributors to <samp><span class="command">gawk</span></samp>.
-<li><a href="Gawk-Distribution.html#Gawk-Distribution">Gawk Distribution</a>:
What is in the <samp><span class="command">gawk</span></samp>
distribution.
-<li><a href="Getting.html#Getting">Getting</a>: How to
get the distribution.
-<li><a href="Extracting.html#Extracting">Extracting</a>:
How to extract the distribution.
-<li><a href="Distribution-contents.html#Distribution-contents">Distribution
contents</a>: What is in the distribution.
-<li><a href="Unix-Installation.html#Unix-Installation">Unix Installation</a>:
Installing <samp><span class="command">gawk</span></samp> under
various
- versions of Unix.
-<li><a href="Quick-Installation.html#Quick-Installation">Quick
Installation</a>: Compiling <samp><span
class="command">gawk</span></samp> under Unix.
-<li><a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">Additional
Configuration Options</a>: Other compile-time options.
-<li><a
href="Configuration-Philosophy.html#Configuration-Philosophy">Configuration
Philosophy</a>: How it's all supposed to work.
-<li><a
href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">Non-Unix
Installation</a>: Installation on Other Operating Systems.
-<li><a href="Amiga-Installation.html#Amiga-Installation">Amiga
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on an Amiga.
-<li><a href="BeOS-Installation.html#BeOS-Installation">BeOS Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on BeOS.
-<li><a href="PC-Installation.html#PC-Installation">PC Installation</a>:
Installing and Compiling <samp><span
class="command">gawk</span></samp> on
- MS-DOS and OS/2.
-<li><a href="PC-Binary-Installation.html#PC-Binary-Installation">PC Binary
Installation</a>: Installing a prepared distribution.
-<li><a href="PC-Compiling.html#PC-Compiling">PC Compiling</a>:
Compiling <samp><span class="command">gawk</span></samp> for MS-DOS,
Windows32,
- and OS/2.
-<li><a href="PC-Using.html#PC-Using">PC Using</a>:
Running <samp><span class="command">gawk</span></samp> on MS-DOS, Windows32 and
- OS/2.
-<li><a href="PC-Dynamic.html#PC-Dynamic">PC Dynamic</a>:
Compiling <samp><span class="command">gawk</span></samp> for dynamic
- libraries.
-<li><a href="Cygwin.html#Cygwin">Cygwin</a>: Building
and running <samp><span class="command">gawk</span></samp> for
- Cygwin.
-<li><a href="VMS-Installation.html#VMS-Installation">VMS Installation</a>:
Installing <samp><span class="command">gawk</span></samp> on VMS.
-<li><a href="VMS-Compilation.html#VMS-Compilation">VMS Compilation</a>:
How to compile <samp><span class="command">gawk</span></samp> under
VMS.
-<li><a href="VMS-Installation-Details.html#VMS-Installation-Details">VMS
Installation Details</a>: How to install <samp><span
class="command">gawk</span></samp> under VMS.
-<li><a href="VMS-Running.html#VMS-Running">VMS Running</a>:
How to run <samp><span class="command">gawk</span></samp> under VMS.
-<li><a href="VMS-POSIX.html#VMS-POSIX">VMS POSIX</a>:
Alternate instructions for VMS POSIX.
-<li><a href="Unsupported.html#Unsupported">Unsupported</a>:
Systems whose ports are no longer
- supported.
-<li><a href="Atari-Installation.html#Atari-Installation">Atari
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on the Atari ST.
-<li><a href="Atari-Compiling.html#Atari-Compiling">Atari Compiling</a>:
Compiling <samp><span class="command">gawk</span></samp> on Atari.
-<li><a href="Atari-Using.html#Atari-Using">Atari Using</a>:
Running <samp><span class="command">gawk</span></samp> on Atari.
-<li><a href="Tandem-Installation.html#Tandem-Installation">Tandem
Installation</a>: Installing <samp><span
class="command">gawk</span></samp> on a Tandem.
-<li><a href="Bugs.html#Bugs">Bugs</a>: Reporting
Problems and Bugs.
-<li><a href="Other-Versions.html#Other-Versions">Other Versions</a>:
Other freely available <samp><span class="command">awk</span></samp>
- implementations.
-<li><a href="Compatibility-Mode.html#Compatibility-Mode">Compatibility
Mode</a>: How to disable certain <samp><span
class="command">gawk</span></samp>
- extensions.
-<li><a href="Additions.html#Additions">Additions</a>:
Making Additions To <samp><span class="command">gawk</span></samp>.
-<li><a href="Adding-Code.html#Adding-Code">Adding Code</a>:
Adding code to the main body of
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="New-Ports.html#New-Ports">New Ports</a>:
Porting <samp><span class="command">gawk</span></samp> to a new operating
- system.
-<li><a href="Dynamic-Extensions.html#Dynamic-Extensions">Dynamic
Extensions</a>: Adding new built-in functions to
- <samp><span
class="command">gawk</span></samp>.
-<li><a href="Internals.html#Internals">Internals</a>: A
brief look at some <samp><span class="command">gawk</span></samp>
- internals.
-<li><a href="Sample-Library.html#Sample-Library">Sample Library</a>:
A example of new functions.
-<li><a
href="Internal-File-Description.html#Internal-File-Description">Internal File
Description</a>: What the new functions will do.
-<li><a href="Internal-File-Ops.html#Internal-File-Ops">Internal File Ops</a>:
The code for internal file operations.
-<li><a href="Using-Internal-File-Ops.html#Using-Internal-File-Ops">Using
Internal File Ops</a>: How to use an external extension.
-<li><a href="Future-Extensions.html#Future-Extensions">Future Extensions</a>:
New features that may be implemented one
- day.
-<li><a href="Basic-High-Level.html#Basic-High-Level">Basic High Level</a>:
The high level view.
-<li><a href="Basic-Data-Typing.html#Basic-Data-Typing">Basic Data Typing</a>:
A very quick intro to data types.
-<li><a href="Floating-Point-Issues.html#Floating-Point-Issues">Floating Point
Issues</a>: Stuff to know about floating-point numbers.
-</ul>
-
-<!-- dedication for Info file -->
-<div class="shortcontents">
-<h2>Short Contents</h2>
-<ul>
-<li><a href="index.html#toc_Top">General Introduction</a></li>
-<li><a href="index.html#toc_Foreword">Foreword</a></li>
-<li><a href="index.html#toc_Preface">Preface</a></li>
-<li><a href="index.html#toc_Getting-Started">1 Getting Started with
<samp><span class="command">awk</span></samp></a></li>
-<li><a href="index.html#toc_Regexp">2 Regular Expressions</a></li>
-<li><a href="index.html#toc_Reading-Files">3 Reading Input Files</a></li>
-<li><a href="index.html#toc_Printing">4 Printing Output</a></li>
-<li><a href="index.html#toc_Expressions">5 Expressions</a></li>
-<li><a href="index.html#toc_Patterns-and-Actions">6 Patterns, Actions, and
Variables</a></li>
-<li><a href="index.html#toc_Arrays">7 Arrays in <samp><span
class="command">awk</span></samp></a></li>
-<li><a href="index.html#toc_Functions">8 Functions</a></li>
-<li><a href="index.html#toc_Internationalization">9 Internationalization with
<samp><span class="command">gawk</span></samp></a></li>
-<li><a href="index.html#toc_Advanced-Features">10 Advanced Features of
<samp><span class="command">gawk</span></samp></a></li>
-<li><a href="index.html#toc_Invoking-Gawk">11 Running <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></a></li>
-<li><a href="index.html#toc_Library-Functions">12 A Library of <samp><span
class="command">awk</span></samp> Functions</a></li>
-<li><a href="index.html#toc_Sample-Programs">13 Practical <samp><span
class="command">awk</span></samp> Programs</a></li>
-<li><a href="index.html#toc_Language-History">Appendix A The Evolution of the
<samp><span class="command">awk</span></samp> Language</a></li>
-<li><a href="index.html#toc_Installation">Appendix B Installing <samp><span
class="command">gawk</span></samp></a></li>
-<li><a href="index.html#toc_Notes">Appendix C Implementation Notes</a></li>
-<li><a href="index.html#toc_Basic-Concepts">Appendix D Basic Programming
Concepts</a></li>
-<li><a href="index.html#toc_Glossary">Glossary</a></li>
-<li><a href="index.html#toc_Copying">GNU General Public License</a></li>
-<li><a href="index.html#toc_GNU-Free-Documentation-License">GNU Free
Documentation License</a></li>
-<li><a href="index.html#toc_Index">Index</a></li>
-</ul>
-</div>
-
- <div class="contents">
-<h2>Table of Contents</h2>
-<ul>
-<li><a name="toc_Top" href="index.html#Top">General Introduction</a>
-<li><a name="toc_Foreword" href="Foreword.html#Foreword">Foreword</a>
-<li><a name="toc_Preface" href="Preface.html#Preface">Preface</a>
-<ul>
-<li><a href="History.html#History">History of <samp><span
class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></a>
-<li><a href="Names.html#Names">A Rose by Any Other Name</a>
-<li><a href="This-Manual.html#This-Manual">Using This Book</a>
-<li><a href="Conventions.html#Conventions">Typographical Conventions</a>
-<li><a href="Manual-History.html#Manual-History">The GNU Project and This
Book</a>
-<li><a href="How-To-Contribute.html#How-To-Contribute">How to Contribute</a>
-<li><a href="Acknowledgments.html#Acknowledgments">Acknowledgments</a>
-</li></ul>
-<li><a name="toc_Getting-Started"
href="Getting-Started.html#Getting-Started">1 Getting Started with <samp><span
class="command">awk</span></samp></a>
-<ul>
-<li><a href="Running-gawk.html#Running-gawk">1.1 How to Run <samp><span
class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="One_002dshot.html#One_002dshot">1.1.1 One-Shot Throwaway
<samp><span class="command">awk</span></samp> Programs</a>
-<li><a href="Read-Terminal.html#Read-Terminal">1.1.2 Running <samp><span
class="command">awk</span></samp> Without Input Files</a>
-<li><a href="Long.html#Long">1.1.3 Running Long Programs</a>
-<li><a href="Executable-Scripts.html#Executable-Scripts">1.1.4 Executable
<samp><span class="command">awk</span></samp> Programs</a>
-<li><a href="Comments.html#Comments">1.1.5 Comments in <samp><span
class="command">awk</span></samp> Programs</a>
-<li><a href="Quoting.html#Quoting">1.1.6 Shell-Quoting Issues</a>
-</li></ul>
-<li><a href="Sample-Data-Files.html#Sample-Data-Files">1.2 Data Files for the
Examples</a>
-<li><a href="Very-Simple.html#Very-Simple">1.3 Some Simple Examples</a>
-<li><a href="Two-Rules.html#Two-Rules">1.4 An Example with Two Rules</a>
-<li><a href="More-Complex.html#More-Complex">1.5 A More Complex Example</a>
-<li><a href="Statements_002fLines.html#Statements_002fLines">1.6 <samp><span
class="command">awk</span></samp> Statements Versus Lines</a>
-<li><a href="Other-Features.html#Other-Features">1.7 Other Features of
<samp><span class="command">awk</span></samp></a>
-<li><a href="When.html#When">1.8 When to Use <samp><span
class="command">awk</span></samp></a>
-</li></ul>
-<li><a name="toc_Regexp" href="Regexp.html#Regexp">2 Regular Expressions</a>
-<ul>
-<li><a href="Regexp-Usage.html#Regexp-Usage">2.1 How to Use Regular
Expressions</a>
-<li><a href="Escape-Sequences.html#Escape-Sequences">2.2 Escape Sequences</a>
-<li><a href="Regexp-Operators.html#Regexp-Operators">2.3 Regular Expression
Operators</a>
-<li><a href="Character-Lists.html#Character-Lists">2.4 Using Character
Lists</a>
-<li><a href="GNU-Regexp-Operators.html#GNU-Regexp-Operators">2.5 <samp><span
class="command">gawk</span></samp>-Specific Regexp Operators</a>
-<li><a href="Case_002dsensitivity.html#Case_002dsensitivity">2.6 Case
Sensitivity in Matching</a>
-<li><a href="Leftmost-Longest.html#Leftmost-Longest">2.7 How Much Text
Matches?</a>
-<li><a href="Computed-Regexps.html#Computed-Regexps">2.8 Using Dynamic
Regexps</a>
-<li><a href="Locales.html#Locales">2.9 Where You Are Makes A Difference</a>
-</li></ul>
-<li><a name="toc_Reading-Files" href="Reading-Files.html#Reading-Files">3
Reading Input Files</a>
-<ul>
-<li><a href="Records.html#Records">3.1 How Input Is Split into Records</a>
-<li><a href="Fields.html#Fields">3.2 Examining Fields</a>
-<li><a href="Nonconstant-Fields.html#Nonconstant-Fields">3.3 Nonconstant Field
Numbers</a>
-<li><a href="Changing-Fields.html#Changing-Fields">3.4 Changing the Contents
of a Field</a>
-<li><a href="Field-Separators.html#Field-Separators">3.5 Specifying How Fields
Are Separated</a>
-<ul>
-<li><a href="Regexp-Field-Splitting.html#Regexp-Field-Splitting">3.5.1 Using
Regular Expressions to Separate Fields</a>
-<li><a href="Single-Character-Fields.html#Single-Character-Fields">3.5.2
Making Each Character a Separate Field</a>
-<li><a
href="Command-Line-Field-Separator.html#Command-Line-Field-Separator">3.5.3
Setting <code>FS</code> from the Command Line</a>
-<li><a href="Field-Splitting-Summary.html#Field-Splitting-Summary">3.5.4
Field-Splitting Summary</a>
-</li></ul>
-<li><a href="Constant-Size.html#Constant-Size">3.6 Reading Fixed-Width Data</a>
-<li><a href="Multiple-Line.html#Multiple-Line">3.7 Multiple-Line Records</a>
-<li><a href="Getline.html#Getline">3.8 Explicit Input with
<code>getline</code></a>
-<ul>
-<li><a href="Plain-Getline.html#Plain-Getline">3.8.1 Using
<code>getline</code> with No Arguments</a>
-<li><a href="Getline_002fVariable.html#Getline_002fVariable">3.8.2 Using
<code>getline</code> into a Variable</a>
-<li><a href="Getline_002fFile.html#Getline_002fFile">3.8.3 Using
<code>getline</code> from a File</a>
-<li><a
href="Getline_002fVariable_002fFile.html#Getline_002fVariable_002fFile">3.8.4
Using <code>getline</code> into a Variable from a File</a>
-<li><a href="Getline_002fPipe.html#Getline_002fPipe">3.8.5 Using
<code>getline</code> from a Pipe</a>
-<li><a
href="Getline_002fVariable_002fPipe.html#Getline_002fVariable_002fPipe">3.8.6
Using <code>getline</code> into a Variable from a Pipe</a>
-<li><a href="Getline_002fCoprocess.html#Getline_002fCoprocess">3.8.7 Using
<code>getline</code> from a Coprocess</a>
-<li><a
href="Getline_002fVariable_002fCoprocess.html#Getline_002fVariable_002fCoprocess">3.8.8
Using <code>getline</code> into a Variable from a Coprocess</a>
-<li><a href="Getline-Notes.html#Getline-Notes">3.8.9 Points to Remember About
<code>getline</code></a>
-<li><a href="Getline-Summary.html#Getline-Summary">3.8.10 Summary of
<code>getline</code> Variants</a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Printing" href="Printing.html#Printing">4 Printing Output</a>
-<ul>
-<li><a href="Print.html#Print">4.1 The <code>print</code> Statement</a>
-<li><a href="Print-Examples.html#Print-Examples">4.2 Examples of
<code>print</code> Statements</a>
-<li><a href="Output-Separators.html#Output-Separators">4.3 Output
Separators</a>
-<li><a href="OFMT.html#OFMT">4.4 Controlling Numeric Output with
<code>print</code></a>
-<li><a href="Printf.html#Printf">4.5 Using <code>printf</code> Statements for
Fancier Printing</a>
-<ul>
-<li><a href="Basic-Printf.html#Basic-Printf">4.5.1 Introduction to the
<code>printf</code> Statement</a>
-<li><a href="Control-Letters.html#Control-Letters">4.5.2 Format-Control
Letters</a>
-<li><a href="Format-Modifiers.html#Format-Modifiers">4.5.3 Modifiers for
<code>printf</code> Formats</a>
-<li><a href="Printf-Examples.html#Printf-Examples">4.5.4 Examples Using
<code>printf</code></a>
-</li></ul>
-<li><a href="Redirection.html#Redirection">4.6 Redirecting Output of
<code>print</code> and <code>printf</code></a>
-<li><a href="Special-Files.html#Special-Files">4.7 Special File Names in
<samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Special-FD.html#Special-FD">4.7.1 Special Files for Standard
Descriptors</a>
-<li><a href="Special-Process.html#Special-Process">4.7.2 Special Files for
Process-Related Information</a>
-<li><a href="Special-Network.html#Special-Network">4.7.3 Special Files for
Network Communications</a>
-<li><a href="Special-Caveats.html#Special-Caveats">4.7.4 Special File Name
Caveats</a>
-</li></ul>
-<li><a href="Close-Files-And-Pipes.html#Close-Files-And-Pipes">4.8 Closing
Input and Output Redirections</a>
-</li></ul>
-<li><a name="toc_Expressions" href="Expressions.html#Expressions">5
Expressions</a>
-<ul>
-<li><a href="Constants.html#Constants">5.1 Constant Expressions</a>
-<ul>
-<li><a href="Scalar-Constants.html#Scalar-Constants">5.1.1 Numeric and String
Constants</a>
-<li><a href="Nondecimal_002dnumbers.html#Nondecimal_002dnumbers">5.1.2 Octal
and Hexadecimal Numbers</a>
-<li><a href="Regexp-Constants.html#Regexp-Constants">5.1.3 Regular Expression
Constants</a>
-</li></ul>
-<li><a href="Using-Constant-Regexps.html#Using-Constant-Regexps">5.2 Using
Regular Expression Constants</a>
-<li><a href="Variables.html#Variables">5.3 Variables</a>
-<ul>
-<li><a href="Using-Variables.html#Using-Variables">5.3.1 Using Variables in a
Program</a>
-<li><a href="Assignment-Options.html#Assignment-Options">5.3.2 Assigning
Variables on the Command Line</a>
-</li></ul>
-<li><a href="Conversion.html#Conversion">5.4 Conversion of Strings and
Numbers</a>
-<li><a href="Arithmetic-Ops.html#Arithmetic-Ops">5.5 Arithmetic Operators</a>
-<li><a href="Concatenation.html#Concatenation">5.6 String Concatenation</a>
-<li><a href="Assignment-Ops.html#Assignment-Ops">5.7 Assignment Expressions</a>
-<li><a href="Increment-Ops.html#Increment-Ops">5.8 Increment and Decrement
Operators</a>
-<li><a href="Truth-Values.html#Truth-Values">5.9 True and False in <samp><span
class="command">awk</span></samp></a>
-<li><a href="Typing-and-Comparison.html#Typing-and-Comparison">5.10 Variable
Typing and Comparison Expressions</a>
-<li><a href="Boolean-Ops.html#Boolean-Ops">5.11 Boolean Expressions</a>
-<li><a href="Conditional-Exp.html#Conditional-Exp">5.12 Conditional
Expressions</a>
-<li><a href="Function-Calls.html#Function-Calls">5.13 Function Calls</a>
-<li><a href="Precedence.html#Precedence">5.14 Operator Precedence (How
Operators Nest)</a>
-</li></ul>
-<li><a name="toc_Patterns-and-Actions"
href="Patterns-and-Actions.html#Patterns-and-Actions">6 Patterns, Actions, and
Variables</a>
-<ul>
-<li><a href="Pattern-Overview.html#Pattern-Overview">6.1 Pattern Elements</a>
-<ul>
-<li><a href="Regexp-Patterns.html#Regexp-Patterns">6.1.1 Regular Expressions
as Patterns</a>
-<li><a href="Expression-Patterns.html#Expression-Patterns">6.1.2 Expressions
as Patterns</a>
-<li><a href="Ranges.html#Ranges">6.1.3 Specifying Record Ranges with
Patterns</a>
-<li><a href="BEGIN_002fEND.html#BEGIN_002fEND">6.1.4 The <code>BEGIN</code>
and <code>END</code> Special Patterns</a>
-<ul>
-<li><a href="Using-BEGIN_002fEND.html#Using-BEGIN_002fEND">6.1.4.1 Startup and
Cleanup Actions</a>
-<li><a href="I_002fO-And-BEGIN_002fEND.html#I_002fO-And-BEGIN_002fEND">6.1.4.2
Input/Output from <code>BEGIN</code> and <code>END</code> Rules</a>
-</li></ul>
-<li><a href="Empty.html#Empty">6.1.5 The Empty Pattern</a>
-</li></ul>
-<li><a href="Using-Shell-Variables.html#Using-Shell-Variables">6.2 Using Shell
Variables in Programs</a>
-<li><a href="Action-Overview.html#Action-Overview">6.3 Actions</a>
-<li><a href="Statements.html#Statements">6.4 Control Statements in Actions</a>
-<ul>
-<li><a href="If-Statement.html#If-Statement">6.4.1 The
<code>if</code>-<code>else</code> Statement</a>
-<li><a href="While-Statement.html#While-Statement">6.4.2 The
<code>while</code> Statement</a>
-<li><a href="Do-Statement.html#Do-Statement">6.4.3 The
<code>do</code>-<code>while</code> Statement</a>
-<li><a href="For-Statement.html#For-Statement">6.4.4 The <code>for</code>
Statement</a>
-<li><a href="Switch-Statement.html#Switch-Statement">6.4.5 The
<code>switch</code> Statement</a>
-<li><a href="Break-Statement.html#Break-Statement">6.4.6 The
<code>break</code> Statement</a>
-<li><a href="Continue-Statement.html#Continue-Statement">6.4.7 The
<code>continue</code> Statement</a>
-<li><a href="Next-Statement.html#Next-Statement">6.4.8 The <code>next</code>
Statement</a>
-<li><a href="Nextfile-Statement.html#Nextfile-Statement">6.4.9 Using
<samp><span class="command">gawk</span></samp>'s <code>nextfile</code>
Statement</a>
-<li><a href="Exit-Statement.html#Exit-Statement">6.4.10 The <code>exit</code>
Statement</a>
-</li></ul>
-<li><a href="Built_002din-Variables.html#Built_002din-Variables">6.5 Built-in
Variables</a>
-<ul>
-<li><a href="User_002dmodified.html#User_002dmodified">6.5.1 Built-in
Variables That Control <samp><span class="command">awk</span></samp></a>
-<li><a href="Auto_002dset.html#Auto_002dset">6.5.2 Built-in Variables That
Convey Information</a>
-<li><a href="ARGC-and-ARGV.html#ARGC-and-ARGV">6.5.3 Using <code>ARGC</code>
and <code>ARGV</code></a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Arrays" href="Arrays.html#Arrays">7 Arrays in <samp><span
class="command">awk</span></samp></a>
-<ul>
-<li><a href="Array-Intro.html#Array-Intro">7.1 Introduction to Arrays</a>
-<li><a href="Reference-to-Elements.html#Reference-to-Elements">7.2 Referring
to an Array Element</a>
-<li><a href="Assigning-Elements.html#Assigning-Elements">7.3 Assigning Array
Elements</a>
-<li><a href="Array-Example.html#Array-Example">7.4 Basic Array Example</a>
-<li><a href="Scanning-an-Array.html#Scanning-an-Array">7.5 Scanning All
Elements of an Array</a>
-<li><a href="Delete.html#Delete">7.6 The <code>delete</code> Statement</a>
-<li><a href="Numeric-Array-Subscripts.html#Numeric-Array-Subscripts">7.7 Using
Numbers to Subscript Arrays</a>
-<li><a href="Uninitialized-Subscripts.html#Uninitialized-Subscripts">7.8 Using
Uninitialized Variables as Subscripts</a>
-<li><a href="Multi_002ddimensional.html#Multi_002ddimensional">7.9
Multidimensional Arrays</a>
-<li><a href="Multi_002dscanning.html#Multi_002dscanning">7.10 Scanning
Multidimensional Arrays</a>
-<li><a href="Array-Sorting.html#Array-Sorting">7.11 Sorting Array Values and
Indices with <samp><span class="command">gawk</span></samp></a>
-</li></ul>
-<li><a name="toc_Functions" href="Functions.html#Functions">8 Functions</a>
-<ul>
-<li><a href="Built_002din.html#Built_002din">8.1 Built-in Functions</a>
-<ul>
-<li><a href="Calling-Built_002din.html#Calling-Built_002din">8.1.1 Calling
Built-in Functions</a>
-<li><a href="Numeric-Functions.html#Numeric-Functions">8.1.2 Numeric
Functions</a>
-<li><a href="String-Functions.html#String-Functions">8.1.3 String-Manipulation
Functions</a>
-<ul>
-<li><a href="Gory-Details.html#Gory-Details">8.1.3.1 More About `<samp><span
class="samp">\</span></samp>' and `<samp><span
class="samp">&</span></samp>' with <code>sub</code>, <code>gsub</code>, and
<code>gensub</code></a>
-</li></ul>
-<li><a href="I_002fO-Functions.html#I_002fO-Functions">8.1.4 Input/Output
Functions</a>
-<li><a href="Time-Functions.html#Time-Functions">8.1.5 Using <samp><span
class="command">gawk</span></samp>'s Timestamp Functions</a>
-<li><a href="Bitwise-Functions.html#Bitwise-Functions">8.1.6 Bit-Manipulation
Functions of <samp><span class="command">gawk</span></samp></a>
-<li><a href="I18N-Functions.html#I18N-Functions">8.1.7 Using <samp><span
class="command">gawk</span></samp>'s String-Translation Functions</a>
-</li></ul>
-<li><a href="User_002ddefined.html#User_002ddefined">8.2 User-Defined
Functions</a>
-<ul>
-<li><a href="Definition-Syntax.html#Definition-Syntax">8.2.1 Function
Definition Syntax</a>
-<li><a href="Function-Example.html#Function-Example">8.2.2 Function Definition
Examples</a>
-<li><a href="Function-Caveats.html#Function-Caveats">8.2.3 Calling
User-Defined Functions</a>
-<li><a href="Return-Statement.html#Return-Statement">8.2.4 The
<code>return</code> Statement</a>
-<li><a href="Dynamic-Typing.html#Dynamic-Typing">8.2.5 Functions and Their
Effects on Variable Typing</a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Internationalization"
href="Internationalization.html#Internationalization">9 Internationalization
with <samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="I18N-and-L10N.html#I18N-and-L10N">9.1 Internationalization and
Localization</a>
-<li><a href="Explaining-gettext.html#Explaining-gettext">9.2 GNU
<code>gettext</code></a>
-<li><a href="Programmer-i18n.html#Programmer-i18n">9.3 Internationalizing
<samp><span class="command">awk</span></samp> Programs</a>
-<li><a href="Translator-i18n.html#Translator-i18n">9.4 Translating <samp><span
class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="String-Extraction.html#String-Extraction">9.4.1 Extracting Marked
Strings</a>
-<li><a href="Printf-Ordering.html#Printf-Ordering">9.4.2 Rearranging
<code>printf</code> Arguments</a>
-<li><a href="I18N-Portability.html#I18N-Portability">9.4.3 <samp><span
class="command">awk</span></samp> Portability Issues</a>
-</li></ul>
-<li><a href="I18N-Example.html#I18N-Example">9.5 A Simple Internationalization
Example</a>
-<li><a href="Gawk-I18N.html#Gawk-I18N">9.6 <samp><span
class="command">gawk</span></samp> Can Speak Your Language</a>
-</li></ul>
-<li><a name="toc_Advanced-Features"
href="Advanced-Features.html#Advanced-Features">10 Advanced Features of
<samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Nondecimal-Data.html#Nondecimal-Data">10.1 Allowing Nondecimal
Input Data</a>
-<li><a href="Two_002dway-I_002fO.html#Two_002dway-I_002fO">10.2 Two-Way
Communications with Another Process</a>
-<li><a href="TCP_002fIP-Networking.html#TCP_002fIP-Networking">10.3 Using
<samp><span class="command">gawk</span></samp> for Network Programming</a>
-<li><a href="Portal-Files.html#Portal-Files">10.4 Using <samp><span
class="command">gawk</span></samp> with BSD Portals</a>
-<li><a href="Profiling.html#Profiling">10.5 Profiling Your <samp><span
class="command">awk</span></samp> Programs</a>
-</li></ul>
-<li><a name="toc_Invoking-Gawk" href="Invoking-Gawk.html#Invoking-Gawk">11
Running <samp><span class="command">awk</span></samp> and <samp><span
class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Command-Line.html#Command-Line">11.1 Invoking <samp><span
class="command">awk</span></samp></a>
-<li><a href="Options.html#Options">11.2 Command-Line Options</a>
-<li><a href="Other-Arguments.html#Other-Arguments">11.3 Other Command-Line
Arguments</a>
-<li><a href="AWKPATH-Variable.html#AWKPATH-Variable">11.4 The <samp><span
class="env">AWKPATH</span></samp> Environment Variable</a>
-<li><a href="Obsolete.html#Obsolete">11.5 Obsolete Options and/or Features</a>
-<li><a href="Undocumented.html#Undocumented">11.6 Undocumented Options and
Features</a>
-<li><a href="Known-Bugs.html#Known-Bugs">11.7 Known Bugs in <samp><span
class="command">gawk</span></samp></a>
-</li></ul>
-<li><a name="toc_Library-Functions"
href="Library-Functions.html#Library-Functions">12 A Library of <samp><span
class="command">awk</span></samp> Functions</a>
-<ul>
-<li><a href="Library-Names.html#Library-Names">12.1 Naming Library Function
Global Variables</a>
-<li><a href="General-Functions.html#General-Functions">12.2 General
Programming</a>
-<ul>
-<li><a href="Nextfile-Function.html#Nextfile-Function">12.2.1 Implementing
<code>nextfile</code> as a Function</a>
-<li><a href="Strtonum-Function.html#Strtonum-Function">12.2.2 Converting
Strings To Numbers</a>
-<li><a href="Assert-Function.html#Assert-Function">12.2.3 Assertions</a>
-<li><a href="Round-Function.html#Round-Function">12.2.4 Rounding Numbers</a>
-<li><a href="Cliff-Random-Function.html#Cliff-Random-Function">12.2.5 The
Cliff Random Number Generator</a>
-<li><a href="Ordinal-Functions.html#Ordinal-Functions">12.2.6 Translating
Between Characters and Numbers</a>
-<li><a href="Join-Function.html#Join-Function">12.2.7 Merging an Array into a
String</a>
-<li><a href="Gettimeofday-Function.html#Gettimeofday-Function">12.2.8 Managing
the Time of Day</a>
-</li></ul>
-<li><a href="Data-File-Management.html#Data-File-Management">12.3 Data File
Management</a>
-<ul>
-<li><a href="Filetrans-Function.html#Filetrans-Function">12.3.1 Noting Data
File Boundaries</a>
-<li><a href="Rewind-Function.html#Rewind-Function">12.3.2 Rereading the
Current File</a>
-<li><a href="File-Checking.html#File-Checking">12.3.3 Checking for Readable
Data Files</a>
-<li><a href="Empty-Files.html#Empty-Files">12.3.4 Checking For Zero-length
Files</a>
-<li><a href="Ignoring-Assigns.html#Ignoring-Assigns">12.3.5 Treating
Assignments as File Names</a>
-</li></ul>
-<li><a href="Getopt-Function.html#Getopt-Function">12.4 Processing
Command-Line Options</a>
-<li><a href="Passwd-Functions.html#Passwd-Functions">12.5 Reading the User
Database</a>
-<li><a href="Group-Functions.html#Group-Functions">12.6 Reading the Group
Database</a>
-</li></ul>
-<li><a name="toc_Sample-Programs"
href="Sample-Programs.html#Sample-Programs">13 Practical <samp><span
class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="Running-Examples.html#Running-Examples">13.1 Running the Example
Programs</a>
-<li><a href="Clones.html#Clones">13.2 Reinventing Wheels for Fun and Profit</a>
-<ul>
-<li><a href="Cut-Program.html#Cut-Program">13.2.1 Cutting out Fields and
Columns</a>
-<li><a href="Egrep-Program.html#Egrep-Program">13.2.2 Searching for Regular
Expressions in Files</a>
-<li><a href="Id-Program.html#Id-Program">13.2.3 Printing out User
Information</a>
-<li><a href="Split-Program.html#Split-Program">13.2.4 Splitting a Large File
into Pieces</a>
-<li><a href="Tee-Program.html#Tee-Program">13.2.5 Duplicating Output into
Multiple Files</a>
-<li><a href="Uniq-Program.html#Uniq-Program">13.2.6 Printing Nonduplicated
Lines of Text</a>
-<li><a href="Wc-Program.html#Wc-Program">13.2.7 Counting Things</a>
-</li></ul>
-<li><a href="Miscellaneous-Programs.html#Miscellaneous-Programs">13.3 A Grab
Bag of <samp><span class="command">awk</span></samp> Programs</a>
-<ul>
-<li><a href="Dupword-Program.html#Dupword-Program">13.3.1 Finding Duplicated
Words in a Document</a>
-<li><a href="Alarm-Program.html#Alarm-Program">13.3.2 An Alarm Clock
Program</a>
-<li><a href="Translate-Program.html#Translate-Program">13.3.3 Transliterating
Characters</a>
-<li><a href="Labels-Program.html#Labels-Program">13.3.4 Printing Mailing
Labels</a>
-<li><a href="Word-Sorting.html#Word-Sorting">13.3.5 Generating Word-Usage
Counts</a>
-<li><a href="History-Sorting.html#History-Sorting">13.3.6 Removing Duplicates
from Unsorted Text</a>
-<li><a href="Extract-Program.html#Extract-Program">13.3.7 Extracting Programs
from Texinfo Source Files</a>
-<li><a href="Simple-Sed.html#Simple-Sed">13.3.8 A Simple Stream Editor</a>
-<li><a href="Igawk-Program.html#Igawk-Program">13.3.9 An Easy Way to Use
Library Functions</a>
-</li></ul>
-</li></ul>
-<li><a name="toc_Language-History"
href="Language-History.html#Language-History">Appendix A The Evolution of the
<samp><span class="command">awk</span></samp> Language</a>
-<ul>
-<li><a href="V7_002fSVR3_002e1.html#V7_002fSVR3_002e1">A.1 Major Changes
Between V7 and SVR3.1</a>
-<li><a href="SVR4.html#SVR4">A.2 Changes Between SVR3.1 and SVR4</a>
-<li><a href="POSIX.html#POSIX">A.3 Changes Between SVR4 and POSIX <samp><span
class="command">awk</span></samp></a>
-<li><a href="BTL.html#BTL">A.4 Extensions in the Bell Laboratories <samp><span
class="command">awk</span></samp></a>
-<li><a href="POSIX_002fGNU.html#POSIX_002fGNU">A.5 Extensions in <samp><span
class="command">gawk</span></samp> Not in POSIX <samp><span
class="command">awk</span></samp></a>
-<li><a href="Contributors.html#Contributors">A.6 Major Contributors to
<samp><span class="command">gawk</span></samp></a>
-</li></ul>
-<li><a name="toc_Installation" href="Installation.html#Installation">Appendix
B Installing <samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Gawk-Distribution.html#Gawk-Distribution">B.1 The <samp><span
class="command">gawk</span></samp> Distribution</a>
-<ul>
-<li><a href="Getting.html#Getting">B.1.1 Getting the <samp><span
class="command">gawk</span></samp> Distribution</a>
-<li><a href="Extracting.html#Extracting">B.1.2 Extracting the Distribution</a>
-<li><a href="Distribution-contents.html#Distribution-contents">B.1.3 Contents
of the <samp><span class="command">gawk</span></samp> Distribution</a>
-</li></ul>
-<li><a href="Unix-Installation.html#Unix-Installation">B.2 Compiling and
Installing <samp><span class="command">gawk</span></samp> on Unix</a>
-<ul>
-<li><a href="Quick-Installation.html#Quick-Installation">B.2.1 Compiling
<samp><span class="command">gawk</span></samp> for Unix</a>
-<li><a
href="Additional-Configuration-Options.html#Additional-Configuration-Options">B.2.2
Additional Configuration Options</a>
-<li><a href="Configuration-Philosophy.html#Configuration-Philosophy">B.2.3 The
Configuration Process</a>
-</li></ul>
-<li><a href="Non_002dUnix-Installation.html#Non_002dUnix-Installation">B.3
Installation on Other Operating Systems</a>
-<ul>
-<li><a href="Amiga-Installation.html#Amiga-Installation">B.3.1 Installing
<samp><span class="command">gawk</span></samp> on an Amiga</a>
-<li><a href="BeOS-Installation.html#BeOS-Installation">B.3.2 Installing
<samp><span class="command">gawk</span></samp> on BeOS</a>
-<li><a href="PC-Installation.html#PC-Installation">B.3.3 Installation on PC
Operating Systems</a>
-<ul>
-<li><a href="PC-Binary-Installation.html#PC-Binary-Installation">B.3.3.1
Installing a Prepared Distribution for PC Systems</a>
-<li><a href="PC-Compiling.html#PC-Compiling">B.3.3.2 Compiling <samp><span
class="command">gawk</span></samp> for PC Operating Systems</a>
-<li><a href="PC-Dynamic.html#PC-Dynamic">B.3.3.3 Compiling <samp><span
class="command">gawk</span></samp> For Dynamic Libraries</a>
-<li><a href="PC-Using.html#PC-Using">B.3.3.4 Using <samp><span
class="command">gawk</span></samp> on PC Operating Systems</a>
-<li><a href="Cygwin.html#Cygwin">B.3.3.5 Using <samp><span
class="command">gawk</span></samp> In The Cygwin Environment</a>
-</li></ul>
-<li><a href="VMS-Installation.html#VMS-Installation">B.3.4 How to Compile and
Install <samp><span class="command">gawk</span></samp> on VMS</a>
-<ul>
-<li><a href="VMS-Compilation.html#VMS-Compilation">B.3.4.1 Compiling
<samp><span class="command">gawk</span></samp> on VMS</a>
-<li><a href="VMS-Installation-Details.html#VMS-Installation-Details">B.3.4.2
Installing <samp><span class="command">gawk</span></samp> on VMS</a>
-<li><a href="VMS-Running.html#VMS-Running">B.3.4.3 Running <samp><span
class="command">gawk</span></samp> on VMS</a>
-<li><a href="VMS-POSIX.html#VMS-POSIX">B.3.4.4 Building and Using <samp><span
class="command">gawk</span></samp> on VMS POSIX</a>
-</li></ul>
-</li></ul>
-<li><a href="Unsupported.html#Unsupported">B.4 Unsupported Operating System
Ports</a>
-<ul>
-<li><a href="Atari-Installation.html#Atari-Installation">B.4.1 Installing
<samp><span class="command">gawk</span></samp> on the Atari ST</a>
-<ul>
-<li><a href="Atari-Compiling.html#Atari-Compiling">B.4.1.1 Compiling
<samp><span class="command">gawk</span></samp> on the Atari ST</a>
-<li><a href="Atari-Using.html#Atari-Using">B.4.1.2 Running <samp><span
class="command">gawk</span></samp> on the Atari ST</a>
-</li></ul>
-<li><a href="Tandem-Installation.html#Tandem-Installation">B.4.2 Installing
<samp><span class="command">gawk</span></samp> on a Tandem</a>
-</li></ul>
-<li><a href="Bugs.html#Bugs">B.5 Reporting Problems and Bugs</a>
-<li><a href="Other-Versions.html#Other-Versions">B.6 Other Freely Available
<samp><span class="command">awk</span></samp> Implementations</a>
-</li></ul>
-<li><a name="toc_Notes" href="Notes.html#Notes">Appendix C Implementation
Notes</a>
-<ul>
-<li><a href="Compatibility-Mode.html#Compatibility-Mode">C.1 Downward
Compatibility and Debugging</a>
-<li><a href="Additions.html#Additions">C.2 Making Additions to <samp><span
class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Adding-Code.html#Adding-Code">C.2.1 Adding New Features</a>
-<li><a href="New-Ports.html#New-Ports">C.2.2 Porting <samp><span
class="command">gawk</span></samp> to a New Operating System</a>
-</li></ul>
-<li><a href="Dynamic-Extensions.html#Dynamic-Extensions">C.3 Adding New
Built-in Functions to <samp><span class="command">gawk</span></samp></a>
-<ul>
-<li><a href="Internals.html#Internals">C.3.1 A Minimal Introduction to
<samp><span class="command">gawk</span></samp> Internals</a>
-<li><a href="Sample-Library.html#Sample-Library">C.3.2 Directory and File
Operation Built-ins</a>
-<ul>
-<li><a href="Internal-File-Description.html#Internal-File-Description">C.3.2.1
Using <code>chdir</code> and <code>stat</code></a>
-<li><a href="Internal-File-Ops.html#Internal-File-Ops">C.3.2.2 C Code for
<code>chdir</code> and <code>stat</code></a>
-<li><a href="Using-Internal-File-Ops.html#Using-Internal-File-Ops">C.3.2.3
Integrating the Extensions</a>
-</li></ul>
-</li></ul>
-<li><a href="Future-Extensions.html#Future-Extensions">C.4 Probable Future
Extensions</a>
-</li></ul>
-<li><a name="toc_Basic-Concepts"
href="Basic-Concepts.html#Basic-Concepts">Appendix D Basic Programming
Concepts</a>
-<ul>
-<li><a href="Basic-High-Level.html#Basic-High-Level">D.1 What a Program
Does</a>
-<li><a href="Basic-Data-Typing.html#Basic-Data-Typing">D.2 Data Values in a
Computer</a>
-<li><a href="Floating-Point-Issues.html#Floating-Point-Issues">D.3
Floating-Point Number Caveats</a>
-</li></ul>
-<li><a name="toc_Glossary" href="Glossary.html#Glossary">Glossary</a>
-<li><a name="toc_Copying" href="Copying.html#Copying">GNU General Public
License</a>
-<ul>
-<li><a href="Copying.html#Copying">Preamble</a>
-<li><a href="Copying.html#Copying">Terms and Conditions for Copying,
Distribution and Modification</a>
-<li><a href="Copying.html#Copying">How to Apply These Terms to Your New
Programs</a>
-</li></ul>
-<li><a name="toc_GNU-Free-Documentation-License"
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">GNU
Free Documentation License</a>
-<ul>
-<li><a
href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License">ADDENDUM:
How to use this License for your documents</a>
-</li></ul>
-<li><a name="toc_Index" href="Index.html#Index">Index</a>
-</li></ul>
-</div>
-
-</body></html>
-
Index: manual/html_node/table_002dassign_002dops.html
===================================================================
RCS file: manual/html_node/table_002dassign_002dops.html
diff -N manual/html_node/table_002dassign_002dops.html
--- manual/html_node/table_002dassign_002dops.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Assignment-Ops.html#table%2dassign%2dops">
Index: manual/html_node/table_002dbitwise_002dops.html
===================================================================
RCS file: manual/html_node/table_002dbitwise_002dops.html
diff -N manual/html_node/table_002dbitwise_002dops.html
--- manual/html_node/table_002dbitwise_002dops.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Bitwise-Functions.html#table%2dbitwise%2dops">
Index: manual/html_node/table_002dchar_002dclasses.html
===================================================================
RCS file: manual/html_node/table_002dchar_002dclasses.html
diff -N manual/html_node/table_002dchar_002dclasses.html
--- manual/html_node/table_002dchar_002dclasses.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Character-Lists.html#table%2dchar%2dclasses">
Index: manual/html_node/table_002dgensub_002descapes.html
===================================================================
RCS file: manual/html_node/table_002dgensub_002descapes.html
diff -N manual/html_node/table_002dgensub_002descapes.html
--- manual/html_node/table_002dgensub_002descapes.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Gory-Details.html#table%2dgensub%2descapes">
Index: manual/html_node/table_002dgetline_002dvariants.html
===================================================================
RCS file: manual/html_node/table_002dgetline_002dvariants.html
diff -N manual/html_node/table_002dgetline_002dvariants.html
--- manual/html_node/table_002dgetline_002dvariants.html 31 Aug 2004
22:04:12 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Getline-Summary.html#table%2dgetline%2dvariants">
Index: manual/html_node/table_002dposix_002d2001_002dsub.html
===================================================================
RCS file: manual/html_node/table_002dposix_002d2001_002dsub.html
diff -N manual/html_node/table_002dposix_002d2001_002dsub.html
--- manual/html_node/table_002dposix_002d2001_002dsub.html 31 Aug 2004
22:04:12 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Gory-Details.html#table%2dposix%2d2001%2dsub">
Index: manual/html_node/table_002drelational_002dops.html
===================================================================
RCS file: manual/html_node/table_002drelational_002dops.html
diff -N manual/html_node/table_002drelational_002dops.html
--- manual/html_node/table_002drelational_002dops.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Typing-and-Comparison.html#table%2drelational%2dops">
Index: manual/html_node/table_002dsub_002descapes.html
===================================================================
RCS file: manual/html_node/table_002dsub_002descapes.html
diff -N manual/html_node/table_002dsub_002descapes.html
--- manual/html_node/table_002dsub_002descapes.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Gory-Details.html#table%2dsub%2descapes">
Index: manual/html_node/table_002dsub_002dposix_002d92.html
===================================================================
RCS file: manual/html_node/table_002dsub_002dposix_002d92.html
diff -N manual/html_node/table_002dsub_002dposix_002d92.html
--- manual/html_node/table_002dsub_002dposix_002d92.html 31 Aug 2004
22:04:12 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Gory-Details.html#table%2dsub%2dposix%2d92">
Index: manual/html_node/table_002dsub_002dproposed.html
===================================================================
RCS file: manual/html_node/table_002dsub_002dproposed.html
diff -N manual/html_node/table_002dsub_002dproposed.html
--- manual/html_node/table_002dsub_002dproposed.html 31 Aug 2004 22:04:12
-0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1 +0,0 @@
-<meta http-equiv="refresh" content="0;
url=Gory-Details.html#table%2dsub%2dproposed">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- www/software/gawk .symlinks gawk.html manual/ga...,
Karl Berry <=