home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: SHell self-extracting ARchive
(archive/shar).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| Newsgroup Content (archive/news)
| magic
| Supported |
100%
| dexvert
| SHell self-extracting ARchive (archive/shar)
| magic
| Supported |
100%
| dexvert
| Internet Message Format (text/imf)
| magic
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| news or mail, ASCII text
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/329 Shell Archive Format
| default
| |
100%
| detectItEasy
| Format: plain text[LF]
| default (weak)
| |
100%
| xdgMime
| message/rfc822
| default
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 53 75 62 6a 65 63 74 3a | 20 20 76 32 32 69 30 39 |Subject:| v22i09|
|00000010| 32 3a 20 20 47 4e 55 20 | 41 57 4b 2c 20 76 65 72 |2: GNU |AWK, ver|
|00000020| 73 69 6f 6e 20 32 2e 31 | 31 2c 20 50 61 72 74 30 |sion 2.1|1, Part0|
|00000030| 36 2f 31 36 0a 4e 65 77 | 73 67 72 6f 75 70 73 3a |6/16.New|sgroups:|
|00000040| 20 63 6f 6d 70 2e 73 6f | 75 72 63 65 73 2e 75 6e | comp.so|urces.un|
|00000050| 69 78 0a 41 70 70 72 6f | 76 65 64 3a 20 72 73 61 |ix.Appro|ved: rsa|
|00000060| 6c 7a 40 75 75 6e 65 74 | 2e 55 55 2e 4e 45 54 0a |lz@uunet|.UU.NET.|
|00000070| 58 2d 43 68 65 63 6b 73 | 75 6d 2d 53 6e 65 66 72 |X-Checks|um-Snefr|
|00000080| 75 3a 20 36 64 66 34 38 | 34 34 36 20 63 66 39 62 |u: 6df48|446 cf9b|
|00000090| 66 66 34 37 20 32 33 63 | 38 62 61 65 39 20 33 62 |ff47 23c|8bae9 3b|
|000000a0| 66 39 35 39 63 33 0a 0a | 53 75 62 6d 69 74 74 65 |f959c3..|Submitte|
|000000b0| 64 2d 62 79 3a 20 22 41 | 72 6e 6f 6c 64 20 44 2e |d-by: "A|rnold D.|
|000000c0| 20 52 6f 62 62 69 6e 73 | 22 20 3c 61 72 6e 6f 6c | Robbins|" <arnol|
|000000d0| 64 40 75 6e 69 78 2e 63 | 63 2e 65 6d 6f 72 79 2e |d@unix.c|c.emory.|
|000000e0| 65 64 75 3e 0a 50 6f 73 | 74 69 6e 67 2d 6e 75 6d |edu>.Pos|ting-num|
|000000f0| 62 65 72 3a 20 56 6f 6c | 75 6d 65 20 32 32 2c 20 |ber: Vol|ume 22, |
|00000100| 49 73 73 75 65 20 39 32 | 0a 41 72 63 68 69 76 65 |Issue 92|.Archive|
|00000110| 2d 6e 61 6d 65 3a 20 67 | 61 77 6b 32 2e 31 31 2f |-name: g|awk2.11/|
|00000120| 70 61 72 74 30 36 0a 0a | 23 21 20 2f 62 69 6e 2f |part06..|#! /bin/|
|00000130| 73 68 0a 23 20 54 68 69 | 73 20 69 73 20 61 20 73 |sh.# Thi|s is a s|
|00000140| 68 65 6c 6c 20 61 72 63 | 68 69 76 65 2e 20 20 52 |hell arc|hive. R|
|00000150| 65 6d 6f 76 65 20 61 6e | 79 74 68 69 6e 67 20 62 |emove an|ything b|
|00000160| 65 66 6f 72 65 20 74 68 | 69 73 20 6c 69 6e 65 2c |efore th|is line,|
|00000170| 20 74 68 65 6e 20 66 65 | 65 64 20 69 74 0a 23 20 | then fe|ed it.# |
|00000180| 69 6e 74 6f 20 61 20 73 | 68 65 6c 6c 20 76 69 61 |into a s|hell via|
|00000190| 20 22 73 68 20 66 69 6c | 65 22 20 6f 72 20 73 69 | "sh fil|e" or si|
|000001a0| 6d 69 6c 61 72 2e 20 20 | 54 6f 20 6f 76 65 72 77 |milar. |To overw|
|000001b0| 72 69 74 65 20 65 78 69 | 73 74 69 6e 67 20 66 69 |rite exi|sting fi|
|000001c0| 6c 65 73 2c 0a 23 20 74 | 79 70 65 20 22 73 68 20 |les,.# t|ype "sh |
|000001d0| 66 69 6c 65 20 2d 63 22 | 2e 0a 23 20 54 68 65 20 |file -c"|..# The |
|000001e0| 74 6f 6f 6c 20 74 68 61 | 74 20 67 65 6e 65 72 61 |tool tha|t genera|
|000001f0| 74 65 64 20 74 68 69 73 | 20 61 70 70 65 61 72 65 |ted this| appeare|
|00000200| 64 20 69 6e 20 74 68 65 | 20 63 6f 6d 70 2e 73 6f |d in the| comp.so|
|00000210| 75 72 63 65 73 2e 75 6e | 69 78 20 6e 65 77 73 67 |urces.un|ix newsg|
|00000220| 72 6f 75 70 3b 0a 23 20 | 73 65 6e 64 20 6d 61 69 |roup;.# |send mai|
|00000230| 6c 20 74 6f 20 63 6f 6d | 70 2d 73 6f 75 72 63 65 |l to com|p-source|
|00000240| 73 2d 75 6e 69 78 40 75 | 75 6e 65 74 2e 75 75 2e |s-unix@u|unet.uu.|
|00000250| 6e 65 74 20 69 66 20 79 | 6f 75 20 77 61 6e 74 20 |net if y|ou want |
|00000260| 74 68 61 74 20 74 6f 6f | 6c 2e 0a 23 20 43 6f 6e |that too|l..# Con|
|00000270| 74 65 6e 74 73 3a 20 20 | 2e 2f 67 61 77 6b 2e 74 |tents: |./gawk.t|
|00000280| 65 78 69 6e 66 6f 2e 30 | 33 20 2e 2f 6d 69 73 73 |exinfo.0|3 ./miss|
|00000290| 69 6e 67 2e 64 2f 73 74 | 72 63 68 72 2e 63 20 2e |ing.d/st|rchr.c .|
|000002a0| 2f 76 65 72 73 69 6f 6e | 2e 73 68 0a 23 20 57 72 |/version|.sh.# Wr|
|000002b0| 61 70 70 65 64 20 62 79 | 20 72 73 61 6c 7a 40 6c |apped by| rsalz@l|
|000002c0| 69 74 63 68 69 2e 62 62 | 6e 2e 63 6f 6d 20 6f 6e |itchi.bb|n.com on|
|000002d0| 20 57 65 64 20 4a 75 6e | 20 20 36 20 31 32 3a 32 | Wed Jun| 6 12:2|
|000002e0| 34 3a 35 30 20 31 39 39 | 30 0a 50 41 54 48 3d 2f |4:50 199|0.PATH=/|
|000002f0| 62 69 6e 3a 2f 75 73 72 | 2f 62 69 6e 3a 2f 75 73 |bin:/usr|/bin:/us|
|00000300| 72 2f 75 63 62 20 3b 20 | 65 78 70 6f 72 74 20 50 |r/ucb ; |export P|
|00000310| 41 54 48 0a 65 63 68 6f | 20 49 66 20 74 68 69 73 |ATH.echo| If this|
|00000320| 20 61 72 63 68 69 76 65 | 20 69 73 20 63 6f 6d 70 | archive| is comp|
|00000330| 6c 65 74 65 2c 20 79 6f | 75 20 77 69 6c 6c 20 73 |lete, yo|u will s|
|00000340| 65 65 20 74 68 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |ee the f|ollowing|
|00000350| 20 6d 65 73 73 61 67 65 | 3a 0a 65 63 68 6f 20 27 | message|:.echo '|
|00000360| 20 20 20 20 20 20 20 20 | 20 20 22 73 68 61 72 3a | | "shar:|
|00000370| 20 45 6e 64 20 6f 66 20 | 61 72 63 68 69 76 65 20 | End of |archive |
|00000380| 36 20 28 6f 66 20 31 36 | 29 2e 22 27 0a 69 66 20 |6 (of 16|)."'.if |
|00000390| 74 65 73 74 20 2d 66 20 | 27 2e 2f 67 61 77 6b 2e |test -f |'./gawk.|
|000003a0| 74 65 78 69 6e 66 6f 2e | 30 33 27 20 2d 61 20 22 |texinfo.|03' -a "|
|000003b0| 24 7b 31 7d 22 20 21 3d | 20 22 2d 63 22 20 3b 20 |${1}" !=| "-c" ; |
|000003c0| 74 68 65 6e 20 0a 20 20 | 65 63 68 6f 20 73 68 61 |then . |echo sha|
|000003d0| 72 3a 20 57 69 6c 6c 20 | 6e 6f 74 20 63 6c 6f 62 |r: Will |not clob|
|000003e0| 62 65 72 20 65 78 69 73 | 74 69 6e 67 20 66 69 6c |ber exis|ting fil|
|000003f0| 65 20 5c 22 27 2e 2f 67 | 61 77 6b 2e 74 65 78 69 |e \"'./g|awk.texi|
|00000400| 6e 66 6f 2e 30 33 27 5c | 22 0a 65 6c 73 65 0a 20 |nfo.03'\|".else. |
|00000410| 20 65 63 68 6f 20 73 68 | 61 72 3a 20 45 78 74 72 | echo sh|ar: Extr|
|00000420| 61 63 74 69 6e 67 20 5c | 22 27 2e 2f 67 61 77 6b |acting \|"'./gawk|
|00000430| 2e 74 65 78 69 6e 66 6f | 2e 30 33 27 5c 22 20 5c |.texinfo|.03'\" \|
|00000440| 28 34 39 36 32 35 20 63 | 68 61 72 61 63 74 65 72 |(49625 c|haracter|
|00000450| 73 5c 29 0a 20 20 73 65 | 64 20 22 73 2f 5e 58 2f |s\). se|d "s/^X/|
|00000460| 2f 22 20 3e 27 2e 2f 67 | 61 77 6b 2e 74 65 78 69 |/" >'./g|awk.texi|
|00000470| 6e 66 6f 2e 30 33 27 20 | 3c 3c 27 45 4e 44 5f 4f |nfo.03' |<<'END_O|
|00000480| 46 5f 46 49 4c 45 27 0a | 58 20 20 20 20 20 20 20 |F_FILE'.|X |
|00000490| 20 20 20 20 20 20 70 72 | 69 6e 74 66 20 66 6f 72 | pr|intf for|
|000004a0| 6d 61 74 2c 20 22 2d 2d | 2d 2d 22 2c 20 22 2d 2d |mat, "--|--", "--|
|000004b0| 2d 2d 2d 2d 22 20 40 7d | 0a 58 20 20 20 20 20 40 |----" @}|.X @|
|000004c0| 7b 20 70 72 69 6e 74 66 | 20 66 6f 72 6d 61 74 2c |{ printf| format,|
|000004d0| 20 24 31 2c 20 24 32 20 | 40 7d 27 20 42 42 53 2d | $1, $2 |@}' BBS-|
|000004e0| 6c 69 73 74 0a 58 40 65 | 6e 64 20 65 78 61 6d 70 |list.X@e|nd examp|
|000004f0| 6c 65 0a 58 0a 58 53 65 | 65 20 69 66 20 79 6f 75 |le.X.XSe|e if you|
|00000500| 20 63 61 6e 20 75 73 65 | 20 74 68 65 20 40 63 6f | can use| the @co|
|00000510| 64 65 7b 70 72 69 6e 74 | 66 7d 20 73 74 61 74 65 |de{print|f} state|
|00000520| 6d 65 6e 74 20 74 6f 20 | 6c 69 6e 65 20 75 70 20 |ment to |line up |
|00000530| 74 68 65 20 68 65 61 64 | 69 6e 67 73 20 61 6e 64 |the head|ings and|
|00000540| 0a 58 74 61 62 6c 65 20 | 64 61 74 61 20 66 6f 72 |.Xtable |data for|
|00000550| 20 6f 75 72 20 40 66 69 | 6c 65 7b 69 6e 76 65 6e | our @fi|le{inven|
|00000560| 74 6f 72 79 2d 73 68 69 | 70 70 65 64 7d 20 65 78 |tory-shi|pped} ex|
|00000570| 61 6d 70 6c 65 20 63 6f | 76 65 72 65 64 20 65 61 |ample co|vered ea|
|00000580| 72 6c 69 65 72 20 69 6e | 20 74 68 65 0a 58 73 65 |rlier in| the.Xse|
|00000590| 63 74 69 6f 6e 20 6f 6e | 20 74 68 65 20 40 63 6f |ction on| the @co|
|000005a0| 64 65 7b 70 72 69 6e 74 | 7d 20 73 74 61 74 65 6d |de{print|} statem|
|000005b0| 65 6e 74 20 28 40 70 78 | 72 65 66 7b 50 72 69 6e |ent (@px|ref{Prin|
|000005c0| 74 7d 29 2e 0a 58 0a 58 | 40 6e 6f 64 65 20 52 65 |t})..X.X|@node Re|
|000005d0| 64 69 72 65 63 74 69 6f | 6e 2c 20 53 70 65 63 69 |directio|n, Speci|
|000005e0| 61 6c 20 46 69 6c 65 73 | 2c 20 50 72 69 6e 74 66 |al Files|, Printf|
|000005f0| 2c 20 50 72 69 6e 74 69 | 6e 67 0a 58 40 73 65 63 |, Printi|ng.X@sec|
|00000600| 74 69 6f 6e 20 52 65 64 | 69 72 65 63 74 69 6e 67 |tion Red|irecting|
|00000610| 20 4f 75 74 70 75 74 20 | 6f 66 20 40 63 6f 64 65 | Output |of @code|
|00000620| 7b 70 72 69 6e 74 7d 20 | 61 6e 64 20 40 63 6f 64 |{print} |and @cod|
|00000630| 65 7b 70 72 69 6e 74 66 | 7d 0a 58 0a 58 40 63 69 |e{printf|}.X.X@ci|
|00000640| 6e 64 65 78 20 6f 75 74 | 70 75 74 20 72 65 64 69 |ndex out|put redi|
|00000650| 72 65 63 74 69 6f 6e 0a | 58 40 63 69 6e 64 65 78 |rection.|X@cindex|
|00000660| 20 72 65 64 69 72 65 63 | 74 69 6f 6e 20 6f 66 20 | redirec|tion of |
|00000670| 6f 75 74 70 75 74 0a 58 | 53 6f 20 66 61 72 20 77 |output.X|So far w|
|00000680| 65 20 68 61 76 65 20 62 | 65 65 6e 20 64 65 61 6c |e have b|een deal|
|00000690| 69 6e 67 20 6f 6e 6c 79 | 20 77 69 74 68 20 6f 75 |ing only| with ou|
|000006a0| 74 70 75 74 20 74 68 61 | 74 20 70 72 69 6e 74 73 |tput tha|t prints|
|000006b0| 20 74 6f 20 74 68 65 20 | 73 74 61 6e 64 61 72 64 | to the |standard|
|000006c0| 0a 58 6f 75 74 70 75 74 | 2c 20 75 73 75 61 6c 6c |.Xoutput|, usuall|
|000006d0| 79 20 79 6f 75 72 20 74 | 65 72 6d 69 6e 61 6c 2e |y your t|erminal.|
|000006e0| 20 20 42 6f 74 68 20 40 | 63 6f 64 65 7b 70 72 69 | Both @|code{pri|
|000006f0| 6e 74 7d 20 61 6e 64 20 | 40 63 6f 64 65 7b 70 72 |nt} and |@code{pr|
|00000700| 69 6e 74 66 7d 20 63 61 | 6e 20 62 65 0a 58 74 6f |intf} ca|n be.Xto|
|00000710| 6c 64 20 74 6f 20 73 65 | 6e 64 20 74 68 65 69 72 |ld to se|nd their|
|00000720| 20 6f 75 74 70 75 74 20 | 74 6f 20 6f 74 68 65 72 | output |to other|
|00000730| 20 70 6c 61 63 65 73 2e | 20 20 54 68 69 73 20 69 | places.| This i|
|00000740| 73 20 63 61 6c 6c 65 64 | 0a 58 40 64 66 6e 7b 72 |s called|.X@dfn{r|
|00000750| 65 64 69 72 65 63 74 69 | 6f 6e 7d 2e 40 72 65 66 |edirecti|on}.@ref|
|00000760| 69 6c 6c 0a 58 0a 58 41 | 20 72 65 64 69 72 65 63 |ill.X.XA| redirec|
|00000770| 74 69 6f 6e 20 61 70 70 | 65 61 72 73 20 61 66 74 |tion app|ears aft|
|00000780| 65 72 20 74 68 65 20 40 | 63 6f 64 65 7b 70 72 69 |er the @|code{pri|
|00000790| 6e 74 7d 20 6f 72 20 40 | 63 6f 64 65 7b 70 72 69 |nt} or @|code{pri|
|000007a0| 6e 74 66 7d 20 73 74 61 | 74 65 6d 65 6e 74 2e 0a |ntf} sta|tement..|
|000007b0| 58 52 65 64 69 72 65 63 | 74 69 6f 6e 73 20 69 6e |XRedirec|tions in|
|000007c0| 20 40 63 6f 64 65 7b 61 | 77 6b 7d 20 61 72 65 20 | @code{a|wk} are |
|000007d0| 77 72 69 74 74 65 6e 20 | 6a 75 73 74 20 6c 69 6b |written |just lik|
|000007e0| 65 20 72 65 64 69 72 65 | 63 74 69 6f 6e 73 20 69 |e redire|ctions i|
|000007f0| 6e 20 73 68 65 6c 6c 0a | 58 63 6f 6d 6d 61 6e 64 |n shell.|Xcommand|
|00000800| 73 2c 20 65 78 63 65 70 | 74 20 74 68 61 74 20 74 |s, excep|t that t|
|00000810| 68 65 79 20 61 72 65 20 | 77 72 69 74 74 65 6e 20 |hey are |written |
|00000820| 69 6e 73 69 64 65 20 74 | 68 65 20 40 63 6f 64 65 |inside t|he @code|
|00000830| 7b 61 77 6b 7d 20 70 72 | 6f 67 72 61 6d 2e 0a 58 |{awk} pr|ogram..X|
|00000840| 0a 58 40 6d 65 6e 75 0a | 58 2a 20 46 69 6c 65 2f |.X@menu.|X* File/|
|00000850| 50 69 70 65 20 52 65 64 | 69 72 65 63 74 69 6f 6e |Pipe Red|irection|
|00000860| 3a 3a 20 20 20 20 20 20 | 20 52 65 64 69 72 65 63 |:: | Redirec|
|00000870| 74 69 6e 67 20 4f 75 74 | 70 75 74 20 74 6f 20 46 |ting Out|put to F|
|00000880| 69 6c 65 73 20 61 6e 64 | 20 50 69 70 65 73 2e 0a |iles and| Pipes..|
|00000890| 58 2a 20 43 6c 6f 73 65 | 20 4f 75 74 70 75 74 3a |X* Close| Output:|
|000008a0| 3a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |: | |
|000008b0| 20 48 6f 77 20 74 6f 20 | 63 6c 6f 73 65 20 6f 75 | How to |close ou|
|000008c0| 74 70 75 74 20 66 69 6c | 65 73 20 61 6e 64 20 70 |tput fil|es and p|
|000008d0| 69 70 65 73 2e 0a 58 40 | 65 6e 64 20 6d 65 6e 75 |ipes..X@|end menu|
|000008e0| 0a 58 0a 58 40 6e 6f 64 | 65 20 46 69 6c 65 2f 50 |.X.X@nod|e File/P|
|000008f0| 69 70 65 20 52 65 64 69 | 72 65 63 74 69 6f 6e 2c |ipe Redi|rection,|
|00000900| 20 43 6c 6f 73 65 20 4f | 75 74 70 75 74 2c 20 52 | Close O|utput, R|
|00000910| 65 64 69 72 65 63 74 69 | 6f 6e 2c 20 52 65 64 69 |edirecti|on, Redi|
|00000920| 72 65 63 74 69 6f 6e 0a | 58 40 73 75 62 73 65 63 |rection.|X@subsec|
|00000930| 74 69 6f 6e 20 52 65 64 | 69 72 65 63 74 69 6e 67 |tion Red|irecting|
|00000940| 20 4f 75 74 70 75 74 20 | 74 6f 20 46 69 6c 65 73 | Output |to Files|
|00000950| 20 61 6e 64 20 50 69 70 | 65 73 0a 58 0a 58 48 65 | and Pip|es.X.XHe|
|00000960| 72 65 20 61 72 65 20 74 | 68 65 20 74 68 72 65 65 |re are t|he three|
|00000970| 20 66 6f 72 6d 73 20 6f | 66 20 6f 75 74 70 75 74 | forms o|f output|
|00000980| 20 72 65 64 69 72 65 63 | 74 69 6f 6e 2e 20 20 54 | redirec|tion. T|
|00000990| 68 65 79 20 61 72 65 20 | 61 6c 6c 20 73 68 6f 77 |hey are |all show|
|000009a0| 6e 20 66 6f 72 0a 58 74 | 68 65 20 40 63 6f 64 65 |n for.Xt|he @code|
|000009b0| 7b 70 72 69 6e 74 7d 20 | 73 74 61 74 65 6d 65 6e |{print} |statemen|
|000009c0| 74 2c 20 62 75 74 20 74 | 68 65 79 20 77 6f 72 6b |t, but t|hey work|
|000009d0| 20 69 64 65 6e 74 69 63 | 61 6c 6c 79 20 66 6f 72 | identic|ally for|
|000009e0| 20 40 63 6f 64 65 7b 70 | 72 69 6e 74 66 7d 0a 58 | @code{p|rintf}.X|
|000009f0| 61 6c 73 6f 2e 0a 58 0a | 58 40 74 61 62 6c 65 20 |also..X.|X@table |
|00000a00| 40 63 6f 64 65 0a 58 40 | 69 74 65 6d 20 70 72 69 |@code.X@|item pri|
|00000a10| 6e 74 20 40 76 61 72 7b | 69 74 65 6d 73 7d 20 3e |nt @var{|items} >|
|00000a20| 20 40 76 61 72 7b 6f 75 | 74 70 75 74 2d 66 69 6c | @var{ou|tput-fil|
|00000a30| 65 7d 0a 58 54 68 69 73 | 20 74 79 70 65 20 6f 66 |e}.XThis| type of|
|00000a40| 20 72 65 64 69 72 65 63 | 74 69 6f 6e 20 70 72 69 | redirec|tion pri|
|00000a50| 6e 74 73 20 74 68 65 20 | 69 74 65 6d 73 20 6f 6e |nts the |items on|
|00000a60| 74 6f 20 74 68 65 20 6f | 75 74 70 75 74 20 66 69 |to the o|utput fi|
|00000a70| 6c 65 0a 58 40 76 61 72 | 7b 6f 75 74 70 75 74 2d |le.X@var|{output-|
|00000a80| 66 69 6c 65 7d 2e 20 20 | 54 68 65 20 66 69 6c 65 |file}. |The file|
|00000a90| 20 6e 61 6d 65 20 40 76 | 61 72 7b 6f 75 74 70 75 | name @v|ar{outpu|
|00000aa0| 74 2d 66 69 6c 65 7d 20 | 63 61 6e 20 62 65 20 61 |t-file} |can be a|
|00000ab0| 6e 79 0a 58 65 78 70 72 | 65 73 73 69 6f 6e 2e 20 |ny.Xexpr|ession. |
|00000ac0| 20 49 74 73 20 76 61 6c | 75 65 20 69 73 20 63 68 | Its val|ue is ch|
|00000ad0| 61 6e 67 65 64 20 74 6f | 20 61 20 73 74 72 69 6e |anged to| a strin|
|00000ae0| 67 20 61 6e 64 20 74 68 | 65 6e 20 75 73 65 64 20 |g and th|en used |
|00000af0| 61 73 20 61 0a 58 66 69 | 6c 65 20 6e 61 6d 65 20 |as a.Xfi|le name |
|00000b00| 28 40 70 78 72 65 66 7b | 45 78 70 72 65 73 73 69 |(@pxref{|Expressi|
|00000b10| 6f 6e 73 7d 29 2e 40 72 | 65 66 69 6c 6c 0a 58 0a |ons}).@r|efill.X.|
|00000b20| 58 57 68 65 6e 20 74 68 | 69 73 20 74 79 70 65 20 |XWhen th|is type |
|00000b30| 6f 66 20 72 65 64 69 72 | 65 63 74 69 6f 6e 20 69 |of redir|ection i|
|00000b40| 73 20 75 73 65 64 2c 20 | 74 68 65 20 40 76 61 72 |s used, |the @var|
|00000b50| 7b 6f 75 74 70 75 74 2d | 66 69 6c 65 7d 20 69 73 |{output-|file} is|
|00000b60| 20 65 72 61 73 65 64 0a | 58 62 65 66 6f 72 65 20 | erased.|Xbefore |
|00000b70| 74 68 65 20 66 69 72 73 | 74 20 6f 75 74 70 75 74 |the firs|t output|
|00000b80| 20 69 73 20 77 72 69 74 | 74 65 6e 20 74 6f 20 69 | is writ|ten to i|
|00000b90| 74 2e 20 20 53 75 62 73 | 65 71 75 65 6e 74 20 77 |t. Subs|equent w|
|00000ba0| 72 69 74 65 73 20 64 6f | 20 6e 6f 74 0a 58 65 72 |rites do| not.Xer|
|00000bb0| 61 73 65 20 40 76 61 72 | 7b 6f 75 74 70 75 74 2d |ase @var|{output-|
|00000bc0| 66 69 6c 65 7d 2c 20 62 | 75 74 20 61 70 70 65 6e |file}, b|ut appen|
|00000bd0| 64 20 74 6f 20 69 74 2e | 20 20 49 66 20 40 76 61 |d to it.| If @va|
|00000be0| 72 7b 6f 75 74 70 75 74 | 2d 66 69 6c 65 7d 20 64 |r{output|-file} d|
|00000bf0| 6f 65 73 0a 58 6e 6f 74 | 20 65 78 69 73 74 2c 20 |oes.Xnot| exist, |
|00000c00| 74 68 65 6e 20 69 74 20 | 69 73 20 63 72 65 61 74 |then it |is creat|
|00000c10| 65 64 2e 40 72 65 66 69 | 6c 6c 0a 58 0a 58 46 6f |ed.@refi|ll.X.XFo|
|00000c20| 72 20 65 78 61 6d 70 6c | 65 2c 20 68 65 72 65 20 |r exampl|e, here |
|00000c30| 69 73 20 68 6f 77 20 6f | 6e 65 20 40 63 6f 64 65 |is how o|ne @code|
|00000c40| 7b 61 77 6b 7d 20 70 72 | 6f 67 72 61 6d 20 63 61 |{awk} pr|ogram ca|
|00000c50| 6e 20 77 72 69 74 65 20 | 61 20 6c 69 73 74 20 6f |n write |a list o|
|00000c60| 66 0a 58 42 42 53 20 6e | 61 6d 65 73 20 74 6f 20 |f.XBBS n|ames to |
|00000c70| 61 20 66 69 6c 65 20 40 | 66 69 6c 65 7b 6e 61 6d |a file @|file{nam|
|00000c80| 65 2d 6c 69 73 74 7d 20 | 61 6e 64 20 61 20 6c 69 |e-list} |and a li|
|00000c90| 73 74 20 6f 66 20 70 68 | 6f 6e 65 20 6e 75 6d 62 |st of ph|one numb|
|00000ca0| 65 72 73 20 74 6f 20 61 | 0a 58 66 69 6c 65 20 40 |ers to a|.Xfile @|
|00000cb0| 66 69 6c 65 7b 70 68 6f | 6e 65 2d 6c 69 73 74 7d |file{pho|ne-list}|
|00000cc0| 2e 20 20 45 61 63 68 20 | 6f 75 74 70 75 74 20 66 |. Each |output f|
|00000cd0| 69 6c 65 20 63 6f 6e 74 | 61 69 6e 73 20 6f 6e 65 |ile cont|ains one|
|00000ce0| 20 6e 61 6d 65 20 6f 72 | 20 6e 75 6d 62 65 72 0a | name or| number.|
|00000cf0| 58 70 65 72 20 6c 69 6e | 65 2e 0a 58 0a 58 40 65 |Xper lin|e..X.X@e|
|00000d00| 78 61 6d 70 6c 65 0a 58 | 61 77 6b 20 27 40 7b 20 |xample.X|awk '@{ |
|00000d10| 70 72 69 6e 74 20 24 32 | 20 3e 20 22 70 68 6f 6e |print $2| > "phon|
|00000d20| 65 2d 6c 69 73 74 22 0a | 58 20 20 20 20 20 20 20 |e-list".|X |
|00000d30| 70 72 69 6e 74 20 24 31 | 20 3e 20 22 6e 61 6d 65 |print $1| > "name|
|00000d40| 2d 6c 69 73 74 22 20 40 | 7d 27 20 42 42 53 2d 6c |-list" @|}' BBS-l|
|00000d50| 69 73 74 0a 58 40 65 6e | 64 20 65 78 61 6d 70 6c |ist.X@en|d exampl|
|00000d60| 65 0a 58 0a 58 40 69 74 | 65 6d 20 70 72 69 6e 74 |e.X.X@it|em print|
|00000d70| 20 40 76 61 72 7b 69 74 | 65 6d 73 7d 20 3e 3e 20 | @var{it|ems} >> |
|00000d80| 40 76 61 72 7b 6f 75 74 | 70 75 74 2d 66 69 6c 65 |@var{out|put-file|
|00000d90| 7d 0a 58 54 68 69 73 20 | 74 79 70 65 20 6f 66 20 |}.XThis |type of |
|00000da0| 72 65 64 69 72 65 63 74 | 69 6f 6e 20 70 72 69 6e |redirect|ion prin|
|00000db0| 74 73 20 74 68 65 20 69 | 74 65 6d 73 20 6f 6e 74 |ts the i|tems ont|
|00000dc0| 6f 20 74 68 65 20 6f 75 | 74 70 75 74 20 66 69 6c |o the ou|tput fil|
|00000dd0| 65 0a 58 40 76 61 72 7b | 6f 75 74 70 75 74 2d 66 |e.X@var{|output-f|
|00000de0| 69 6c 65 7d 2e 20 20 54 | 68 65 20 64 69 66 66 65 |ile}. T|he diffe|
|00000df0| 72 65 6e 63 65 20 62 65 | 74 77 65 65 6e 20 74 68 |rence be|tween th|
|00000e00| 69 73 20 61 6e 64 20 74 | 68 65 0a 58 73 69 6e 67 |is and t|he.Xsing|
|00000e10| 6c 65 2d 40 73 61 6d 70 | 7b 3e 7d 20 72 65 64 69 |le-@samp|{>} redi|
|00000e20| 72 65 63 74 69 6f 6e 20 | 69 73 20 74 68 61 74 20 |rection |is that |
|00000e30| 74 68 65 20 6f 6c 64 20 | 63 6f 6e 74 65 6e 74 73 |the old |contents|
|00000e40| 20 28 69 66 20 61 6e 79 | 29 20 6f 66 0a 58 40 76 | (if any|) of.X@v|
|00000e50| 61 72 7b 6f 75 74 70 75 | 74 2d 66 69 6c 65 7d 20 |ar{outpu|t-file} |
|00000e60| 61 72 65 20 6e 6f 74 20 | 65 72 61 73 65 64 2e 20 |are not |erased. |
|00000e70| 20 49 6e 73 74 65 61 64 | 2c 20 74 68 65 20 40 63 | Instead|, the @c|
|00000e80| 6f 64 65 7b 61 77 6b 7d | 20 6f 75 74 70 75 74 20 |ode{awk}| output |
|00000e90| 69 73 0a 58 61 70 70 65 | 6e 64 65 64 20 74 6f 20 |is.Xappe|nded to |
|00000ea0| 74 68 65 20 66 69 6c 65 | 2e 0a 58 0a 58 40 63 69 |the file|..X.X@ci|
|00000eb0| 6e 64 65 78 20 70 69 70 | 65 73 20 66 6f 72 20 6f |ndex pip|es for o|
|00000ec0| 75 74 70 75 74 0a 58 40 | 63 69 6e 64 65 78 20 6f |utput.X@|cindex o|
|00000ed0| 75 74 70 75 74 2c 20 70 | 69 70 69 6e 67 0a 58 40 |utput, p|iping.X@|
|00000ee0| 69 74 65 6d 20 70 72 69 | 6e 74 20 40 76 61 72 7b |item pri|nt @var{|
|00000ef0| 69 74 65 6d 73 7d 20 7c | 20 40 76 61 72 7b 63 6f |items} || @var{co|
|00000f00| 6d 6d 61 6e 64 7d 0a 58 | 49 74 20 69 73 20 61 6c |mmand}.X|It is al|
|00000f10| 73 6f 20 70 6f 73 73 69 | 62 6c 65 20 74 6f 20 73 |so possi|ble to s|
|00000f20| 65 6e 64 20 6f 75 74 70 | 75 74 20 74 68 72 6f 75 |end outp|ut throu|
|00000f30| 67 68 20 61 20 40 64 66 | 6e 7b 70 69 70 65 7d 20 |gh a @df|n{pipe} |
|00000f40| 69 6e 73 74 65 61 64 20 | 6f 66 20 69 6e 74 6f 20 |instead |of into |
|00000f50| 61 0a 58 66 69 6c 65 2e | 20 20 20 54 68 69 73 20 |a.Xfile.| This |
|00000f60| 74 79 70 65 20 6f 66 20 | 72 65 64 69 72 65 63 74 |type of |redirect|
|00000f70| 69 6f 6e 20 6f 70 65 6e | 73 20 61 20 70 69 70 65 |ion open|s a pipe|
|00000f80| 20 74 6f 20 40 76 61 72 | 7b 63 6f 6d 6d 61 6e 64 | to @var|{command|
|00000f90| 7d 20 61 6e 64 20 77 72 | 69 74 65 73 0a 58 74 68 |} and wr|ites.Xth|
|00000fa0| 65 20 76 61 6c 75 65 73 | 20 6f 66 20 40 76 61 72 |e values| of @var|
|00000fb0| 7b 69 74 65 6d 73 7d 20 | 74 68 72 6f 75 67 68 20 |{items} |through |
|00000fc0| 74 68 69 73 20 70 69 70 | 65 2c 20 74 6f 20 61 6e |this pip|e, to an|
|00000fd0| 6f 74 68 65 72 20 70 72 | 6f 63 65 73 73 20 63 72 |other pr|ocess cr|
|00000fe0| 65 61 74 65 64 0a 58 74 | 6f 20 65 78 65 63 75 74 |eated.Xt|o execut|
|00000ff0| 65 20 40 76 61 72 7b 63 | 6f 6d 6d 61 6e 64 7d 2e |e @var{c|ommand}.|
|00001000| 40 72 65 66 69 6c 6c 0a | 58 0a 58 54 68 65 20 72 |@refill.|X.XThe r|
|00001010| 65 64 69 72 65 63 74 69 | 6f 6e 20 61 72 67 75 6d |edirecti|on argum|
|00001020| 65 6e 74 20 40 76 61 72 | 7b 63 6f 6d 6d 61 6e 64 |ent @var|{command|
|00001030| 7d 20 69 73 20 61 63 74 | 75 61 6c 6c 79 20 61 6e |} is act|ually an|
|00001040| 20 40 63 6f 64 65 7b 61 | 77 6b 7d 0a 58 65 78 70 | @code{a|wk}.Xexp|
|00001050| 72 65 73 73 69 6f 6e 2e | 20 20 49 74 73 20 76 61 |ression.| Its va|
|00001060| 6c 75 65 20 69 73 20 63 | 6f 6e 76 65 72 74 65 64 |lue is c|onverted|
|00001070| 20 74 6f 20 61 20 73 74 | 72 69 6e 67 2c 20 77 68 | to a st|ring, wh|
|00001080| 6f 73 65 20 63 6f 6e 74 | 65 6e 74 73 20 67 69 76 |ose cont|ents giv|
|00001090| 65 20 74 68 65 0a 58 73 | 68 65 6c 6c 20 63 6f 6d |e the.Xs|hell com|
|000010a0| 6d 61 6e 64 20 74 6f 20 | 62 65 20 72 75 6e 2e 0a |mand to |be run..|
|000010b0| 58 0a 58 46 6f 72 20 65 | 78 61 6d 70 6c 65 2c 20 |X.XFor e|xample, |
|000010c0| 74 68 69 73 20 70 72 6f | 64 75 63 65 73 20 74 77 |this pro|duces tw|
|000010d0| 6f 20 66 69 6c 65 73 2c | 20 6f 6e 65 20 75 6e 73 |o files,| one uns|
|000010e0| 6f 72 74 65 64 20 6c 69 | 73 74 20 6f 66 20 42 42 |orted li|st of BB|
|000010f0| 53 20 6e 61 6d 65 73 0a | 58 61 6e 64 20 6f 6e 65 |S names.|Xand one|
|00001100| 20 6c 69 73 74 20 73 6f | 72 74 65 64 20 69 6e 20 | list so|rted in |
|00001110| 72 65 76 65 72 73 65 20 | 61 6c 70 68 61 62 65 74 |reverse |alphabet|
|00001120| 69 63 61 6c 20 6f 72 64 | 65 72 3a 0a 58 0a 58 40 |ical ord|er:.X.X@|
|00001130| 65 78 61 6d 70 6c 65 0a | 58 61 77 6b 20 27 40 7b |example.|Xawk '@{|
|00001140| 20 70 72 69 6e 74 20 24 | 31 20 3e 20 22 6e 61 6d | print $|1 > "nam|
|00001150| 65 73 2e 75 6e 73 6f 72 | 74 65 64 22 0a 58 20 20 |es.unsor|ted".X |
|00001160| 20 20 20 20 20 70 72 69 | 6e 74 20 24 31 20 7c 20 | pri|nt $1 | |
|00001170| 22 73 6f 72 74 20 2d 72 | 20 3e 20 6e 61 6d 65 73 |"sort -r| > names|
|00001180| 2e 73 6f 72 74 65 64 22 | 20 40 7d 27 20 42 42 53 |.sorted"| @}' BBS|
|00001190| 2d 6c 69 73 74 0a 58 40 | 65 6e 64 20 65 78 61 6d |-list.X@|end exam|
|000011a0| 70 6c 65 0a 58 0a 58 48 | 65 72 65 20 74 68 65 20 |ple.X.XH|ere the |
|000011b0| 75 6e 73 6f 72 74 65 64 | 20 6c 69 73 74 20 69 73 |unsorted| list is|
|000011c0| 20 77 72 69 74 74 65 6e | 20 77 69 74 68 20 61 6e | written| with an|
|000011d0| 20 6f 72 64 69 6e 61 72 | 79 20 72 65 64 69 72 65 | ordinar|y redire|
|000011e0| 63 74 69 6f 6e 20 77 68 | 69 6c 65 0a 58 74 68 65 |ction wh|ile.Xthe|
|000011f0| 20 73 6f 72 74 65 64 20 | 6c 69 73 74 20 69 73 20 | sorted |list is |
|00001200| 77 72 69 74 74 65 6e 20 | 62 79 20 70 69 70 69 6e |written |by pipin|
|00001210| 67 20 74 68 72 6f 75 67 | 68 20 74 68 65 20 40 63 |g throug|h the @c|
|00001220| 6f 64 65 7b 73 6f 72 74 | 7d 20 75 74 69 6c 69 74 |ode{sort|} utilit|
|00001230| 79 2e 0a 58 0a 58 48 65 | 72 65 20 69 73 20 61 6e |y..X.XHe|re is an|
|00001240| 20 65 78 61 6d 70 6c 65 | 20 74 68 61 74 20 75 73 | example| that us|
|00001250| 65 73 20 72 65 64 69 72 | 65 63 74 69 6f 6e 20 74 |es redir|ection t|
|00001260| 6f 20 6d 61 69 6c 20 61 | 20 6d 65 73 73 61 67 65 |o mail a| message|
|00001270| 20 74 6f 20 61 20 6d 61 | 69 6c 69 6e 67 0a 58 6c | to a ma|iling.Xl|
|00001280| 69 73 74 20 40 73 61 6d | 70 7b 62 75 67 2d 73 79 |ist @sam|p{bug-sy|
|00001290| 73 74 65 6d 7d 2e 20 20 | 54 68 69 73 20 6d 69 67 |stem}. |This mig|
|000012a0| 68 74 20 62 65 20 75 73 | 65 66 75 6c 20 77 68 65 |ht be us|eful whe|
|000012b0| 6e 20 74 72 6f 75 62 6c | 65 20 69 73 20 65 6e 63 |n troubl|e is enc|
|000012c0| 6f 75 6e 74 65 72 65 64 | 0a 58 69 6e 20 61 6e 20 |ountered|.Xin an |
|000012d0| 40 63 6f 64 65 7b 61 77 | 6b 7d 20 73 63 72 69 70 |@code{aw|k} scrip|
|000012e0| 74 20 72 75 6e 20 70 65 | 72 69 6f 64 69 63 61 6c |t run pe|riodical|
|000012f0| 6c 79 20 66 6f 72 20 73 | 79 73 74 65 6d 20 6d 61 |ly for s|ystem ma|
|00001300| 69 6e 74 65 6e 61 6e 63 | 65 2e 0a 58 0a 58 40 65 |intenanc|e..X.X@e|
|00001310| 78 61 6d 70 6c 65 0a 58 | 70 72 69 6e 74 20 22 41 |xample.X|print "A|
|00001320| 77 6b 20 73 63 72 69 70 | 74 20 66 61 69 6c 65 64 |wk scrip|t failed|
|00001330| 3a 22 2c 20 24 30 20 7c | 20 22 6d 61 69 6c 20 62 |:", $0 || "mail b|
|00001340| 75 67 2d 73 79 73 74 65 | 6d 22 0a 58 70 72 69 6e |ug-syste|m".Xprin|
|00001350| 74 20 22 61 74 20 72 65 | 63 6f 72 64 20 6e 75 6d |t "at re|cord num|
|00001360| 62 65 72 22 2c 20 46 4e | 52 2c 20 22 6f 66 22 2c |ber", FN|R, "of",|
|00001370| 20 46 49 4c 45 4e 41 4d | 45 20 20 7c 20 22 6d 61 | FILENAM|E | "ma|
|00001380| 69 6c 20 62 75 67 2d 73 | 79 73 74 65 6d 22 0a 58 |il bug-s|ystem".X|
|00001390| 63 6c 6f 73 65 28 22 6d | 61 69 6c 20 62 75 67 2d |close("m|ail bug-|
|000013a0| 73 79 73 74 65 6d 22 29 | 0a 58 40 65 6e 64 20 65 |system")|.X@end e|
|000013b0| 78 61 6d 70 6c 65 0a 58 | 0a 58 57 65 20 63 61 6c |xample.X|.XWe cal|
|000013c0| 6c 20 74 68 65 20 40 63 | 6f 64 65 7b 63 6c 6f 73 |l the @c|ode{clos|
|000013d0| 65 7d 20 66 75 6e 63 74 | 69 6f 6e 20 68 65 72 65 |e} funct|ion here|
|000013e0| 20 62 65 63 61 75 73 65 | 20 69 74 27 73 20 61 20 | because| it's a |
|000013f0| 67 6f 6f 64 20 69 64 65 | 61 20 74 6f 20 63 6c 6f |good ide|a to clo|
|00001400| 73 65 0a 58 74 68 65 20 | 70 69 70 65 20 61 73 20 |se.Xthe |pipe as |
|00001410| 73 6f 6f 6e 20 61 73 20 | 61 6c 6c 20 74 68 65 20 |soon as |all the |
|00001420| 69 6e 74 65 6e 64 65 64 | 20 6f 75 74 70 75 74 20 |intended| output |
|00001430| 68 61 73 20 62 65 65 6e | 20 73 65 6e 74 20 74 6f |has been| sent to|
|00001440| 20 69 74 2e 0a 58 40 78 | 72 65 66 7b 43 6c 6f 73 | it..X@x|ref{Clos|
|00001450| 65 20 4f 75 74 70 75 74 | 7d 2c 20 66 6f 72 20 6d |e Output|}, for m|
|00001460| 6f 72 65 20 69 6e 66 6f | 72 6d 61 74 69 6f 6e 20 |ore info|rmation |
|00001470| 6f 6e 20 74 68 69 73 2e | 0a 58 40 65 6e 64 20 74 |on this.|.X@end t|
|00001480| 61 62 6c 65 0a 58 0a 58 | 52 65 64 69 72 65 63 74 |able.X.X|Redirect|
|00001490| 69 6e 67 20 6f 75 74 70 | 75 74 20 75 73 69 6e 67 |ing outp|ut using|
|000014a0| 20 40 73 61 6d 70 7b 3e | 7d 2c 20 40 73 61 6d 70 | @samp{>|}, @samp|
|000014b0| 7b 3e 3e 7d 2c 20 6f 72 | 20 40 73 61 6d 70 7b 7c |{>>}, or| @samp{||
|000014c0| 7d 20 61 73 6b 73 20 74 | 68 65 20 73 79 73 74 65 |} asks t|he syste|
|000014d0| 6d 0a 58 74 6f 20 6f 70 | 65 6e 20 61 20 66 69 6c |m.Xto op|en a fil|
|000014e0| 65 20 6f 72 20 70 69 70 | 65 20 6f 6e 6c 79 20 69 |e or pip|e only i|
|000014f0| 66 20 74 68 65 20 70 61 | 72 74 69 63 75 6c 61 72 |f the pa|rticular|
|00001500| 20 40 76 61 72 7b 66 69 | 6c 65 7d 20 6f 72 20 40 | @var{fi|le} or @|
|00001510| 76 61 72 7b 63 6f 6d 6d | 61 6e 64 7d 0a 58 79 6f |var{comm|and}.Xyo|
|00001520| 75 27 76 65 20 73 70 65 | 63 69 66 69 65 64 20 68 |u've spe|cified h|
|00001530| 61 73 20 6e 6f 74 20 61 | 6c 72 65 61 64 79 20 62 |as not a|lready b|
|00001540| 65 65 6e 20 77 72 69 74 | 74 65 6e 20 74 6f 20 62 |een writ|ten to b|
|00001550| 79 20 79 6f 75 72 20 70 | 72 6f 67 72 61 6d 2e 40 |y your p|rogram.@|
|00001560| 72 65 66 69 6c 6c 0a 58 | 0a 58 40 6e 6f 64 65 20 |refill.X|.X@node |
|00001570| 43 6c 6f 73 65 20 4f 75 | 74 70 75 74 2c 20 2c 20 |Close Ou|tput, , |
|00001580| 46 69 6c 65 2f 50 69 70 | 65 20 52 65 64 69 72 65 |File/Pip|e Redire|
|00001590| 63 74 69 6f 6e 2c 20 52 | 65 64 69 72 65 63 74 69 |ction, R|edirecti|
|000015a0| 6f 6e 0a 58 40 73 75 62 | 73 65 63 74 69 6f 6e 20 |on.X@sub|section |
|000015b0| 43 6c 6f 73 69 6e 67 20 | 4f 75 74 70 75 74 20 46 |Closing |Output F|
|000015c0| 69 6c 65 73 20 61 6e 64 | 20 50 69 70 65 73 0a 58 |iles and| Pipes.X|
|000015d0| 40 63 69 6e 64 65 78 20 | 63 6c 6f 73 69 6e 67 20 |@cindex |closing |
|000015e0| 6f 75 74 70 75 74 20 66 | 69 6c 65 73 20 61 6e 64 |output f|iles and|
|000015f0| 20 70 69 70 65 73 0a 58 | 40 66 69 6e 64 65 78 20 | pipes.X|@findex |
|00001600| 63 6c 6f 73 65 0a 58 0a | 58 57 68 65 6e 20 61 20 |close.X.|XWhen a |
|00001610| 66 69 6c 65 20 6f 72 20 | 70 69 70 65 20 69 73 20 |file or |pipe is |
|00001620| 6f 70 65 6e 65 64 2c 20 | 74 68 65 20 66 69 6c 65 |opened, |the file|
|00001630| 20 6e 61 6d 65 20 6f 72 | 20 63 6f 6d 6d 61 6e 64 | name or| command|
|00001640| 20 61 73 73 6f 63 69 61 | 74 65 64 20 77 69 74 68 | associa|ted with|
|00001650| 0a 58 69 74 20 69 73 20 | 72 65 6d 65 6d 62 65 72 |.Xit is |remember|
|00001660| 65 64 20 62 79 20 40 63 | 6f 64 65 7b 61 77 6b 7d |ed by @c|ode{awk}|
|00001670| 20 61 6e 64 20 73 75 62 | 73 65 71 75 65 6e 74 20 | and sub|sequent |
|00001680| 77 72 69 74 65 73 20 74 | 6f 20 74 68 65 20 73 61 |writes t|o the sa|
|00001690| 6d 65 20 66 69 6c 65 20 | 6f 72 0a 58 63 6f 6d 6d |me file |or.Xcomm|
|000016a0| 61 6e 64 20 61 72 65 20 | 61 70 70 65 6e 64 65 64 |and are |appended|
|000016b0| 20 74 6f 20 74 68 65 20 | 70 72 65 76 69 6f 75 73 | to the |previous|
|000016c0| 20 77 72 69 74 65 73 2e | 20 20 54 68 65 20 66 69 | writes.| The fi|
|000016d0| 6c 65 20 6f 72 20 70 69 | 70 65 20 73 74 61 79 73 |le or pi|pe stays|
|000016e0| 0a 58 6f 70 65 6e 20 75 | 6e 74 69 6c 20 40 63 6f |.Xopen u|ntil @co|
|000016f0| 64 65 7b 61 77 6b 7d 20 | 65 78 69 74 73 2e 20 20 |de{awk} |exits. |
|00001700| 54 68 69 73 20 69 73 20 | 75 73 75 61 6c 6c 79 20 |This is |usually |
|00001710| 63 6f 6e 76 65 6e 69 65 | 6e 74 2e 0a 58 0a 58 53 |convenie|nt..X.XS|
|00001720| 6f 6d 65 74 69 6d 65 73 | 20 74 68 65 72 65 20 69 |ometimes| there i|
|00001730| 73 20 61 20 72 65 61 73 | 6f 6e 20 74 6f 20 63 6c |s a reas|on to cl|
|00001740| 6f 73 65 20 61 6e 20 6f | 75 74 70 75 74 20 66 69 |ose an o|utput fi|
|00001750| 6c 65 20 6f 72 20 70 69 | 70 65 20 65 61 72 6c 69 |le or pi|pe earli|
|00001760| 65 72 0a 58 74 68 61 6e | 20 74 68 61 74 2e 20 20 |er.Xthan| that. |
|00001770| 54 6f 20 64 6f 20 74 68 | 69 73 2c 20 75 73 65 20 |To do th|is, use |
|00001780| 74 68 65 20 40 63 6f 64 | 65 7b 63 6c 6f 73 65 7d |the @cod|e{close}|
|00001790| 20 66 75 6e 63 74 69 6f | 6e 2c 20 61 73 20 66 6f | functio|n, as fo|
|000017a0| 6c 6c 6f 77 73 3a 0a 58 | 0a 58 40 65 78 61 6d 70 |llows:.X|.X@examp|
|000017b0| 6c 65 0a 58 63 6c 6f 73 | 65 28 40 76 61 72 7b 66 |le.Xclos|e(@var{f|
|000017c0| 69 6c 65 6e 61 6d 65 7d | 29 0a 58 40 65 6e 64 20 |ilename}|).X@end |
|000017d0| 65 78 61 6d 70 6c 65 0a | 58 0a 58 40 6e 6f 69 6e |example.|X.X@noin|
|000017e0| 64 65 6e 74 0a 58 6f 72 | 0a 58 0a 58 40 65 78 61 |dent.Xor|.X.X@exa|
|000017f0| 6d 70 6c 65 0a 58 63 6c | 6f 73 65 28 40 76 61 72 |mple.Xcl|ose(@var|
|00001800| 7b 63 6f 6d 6d 61 6e 64 | 7d 29 0a 58 40 65 6e 64 |{command|}).X@end|
|00001810| 20 65 78 61 6d 70 6c 65 | 0a 58 0a 58 54 68 65 20 | example|.X.XThe |
|00001820| 61 72 67 75 6d 65 6e 74 | 20 40 76 61 72 7b 66 69 |argument| @var{fi|
|00001830| 6c 65 6e 61 6d 65 7d 20 | 6f 72 20 40 76 61 72 7b |lename} |or @var{|
|00001840| 63 6f 6d 6d 61 6e 64 7d | 20 63 61 6e 20 62 65 20 |command}| can be |
|00001850| 61 6e 79 20 65 78 70 72 | 65 73 73 69 6f 6e 2e 0a |any expr|ession..|
|00001860| 58 49 74 73 20 76 61 6c | 75 65 20 6d 75 73 74 20 |XIts val|ue must |
|00001870| 65 78 61 63 74 6c 79 20 | 65 71 75 61 6c 20 74 68 |exactly |equal th|
|00001880| 65 20 73 74 72 69 6e 67 | 20 75 73 65 64 20 74 6f |e string| used to|
|00001890| 20 6f 70 65 6e 20 74 68 | 65 20 66 69 6c 65 20 6f | open th|e file o|
|000018a0| 72 20 70 69 70 65 0a 58 | 74 6f 20 62 65 67 69 6e |r pipe.X|to begin|
|000018b0| 20 77 69 74 68 2d 2d 2d | 66 6f 72 20 65 78 61 6d | with---|for exam|
|000018c0| 70 6c 65 2c 20 69 66 20 | 79 6f 75 20 6f 70 65 6e |ple, if |you open|
|000018d0| 20 61 20 70 69 70 65 20 | 77 69 74 68 20 74 68 69 | a pipe |with thi|
|000018e0| 73 3a 0a 58 0a 58 40 65 | 78 61 6d 70 6c 65 0a 58 |s:.X.X@e|xample.X|
|000018f0| 70 72 69 6e 74 20 24 31 | 20 7c 20 22 73 6f 72 74 |print $1| | "sort|
|00001900| 20 2d 72 20 3e 20 6e 61 | 6d 65 73 2e 73 6f 72 74 | -r > na|mes.sort|
|00001910| 65 64 22 0a 58 40 65 6e | 64 20 65 78 61 6d 70 6c |ed".X@en|d exampl|
|00001920| 65 0a 58 0a 58 40 6e 6f | 69 6e 64 65 6e 74 0a 58 |e.X.X@no|indent.X|
|00001930| 74 68 65 6e 20 79 6f 75 | 20 6d 75 73 74 20 63 6c |then you| must cl|
|00001940| 6f 73 65 20 69 74 20 77 | 69 74 68 20 74 68 69 73 |ose it w|ith this|
|00001950| 3a 0a 58 0a 58 40 65 78 | 61 6d 70 6c 65 0a 58 63 |:.X.X@ex|ample.Xc|
|00001960| 6c 6f 73 65 28 22 73 6f | 72 74 20 2d 72 20 3e 20 |lose("so|rt -r > |
|00001970| 6e 61 6d 65 73 2e 73 6f | 72 74 65 64 22 29 0a 58 |names.so|rted").X|
|00001980| 40 65 6e 64 20 65 78 61 | 6d 70 6c 65 0a 58 0a 58 |@end exa|mple.X.X|
|00001990| 48 65 72 65 20 61 72 65 | 20 73 6f 6d 65 20 72 65 |Here are| some re|
|000019a0| 61 73 6f 6e 73 20 77 68 | 79 20 79 6f 75 20 6d 69 |asons wh|y you mi|
|000019b0| 67 68 74 20 6e 65 65 64 | 20 74 6f 20 63 6c 6f 73 |ght need| to clos|
|000019c0| 65 20 61 6e 20 6f 75 74 | 70 75 74 20 66 69 6c 65 |e an out|put file|
|000019d0| 3a 0a 58 0a 58 40 69 74 | 65 6d 69 7a 65 20 40 62 |:.X.X@it|emize @b|
|000019e0| 75 6c 6c 65 74 0a 58 40 | 69 74 65 6d 0a 58 54 6f |ullet.X@|item.XTo|
|000019f0| 20 77 72 69 74 65 20 61 | 20 66 69 6c 65 20 61 6e | write a| file an|
|00001a00| 64 20 72 65 61 64 20 69 | 74 20 62 61 63 6b 20 6c |d read i|t back l|
|00001a10| 61 74 65 72 20 6f 6e 20 | 69 6e 20 74 68 65 20 73 |ater on |in the s|
|00001a20| 61 6d 65 20 40 63 6f 64 | 65 7b 61 77 6b 7d 0a 58 |ame @cod|e{awk}.X|
|00001a30| 70 72 6f 67 72 61 6d 2e | 20 20 43 6c 6f 73 65 20 |program.| Close |
|00001a40| 74 68 65 20 66 69 6c 65 | 20 77 68 65 6e 20 79 6f |the file| when yo|
|00001a50| 75 20 61 72 65 20 66 69 | 6e 69 73 68 65 64 20 77 |u are fi|nished w|
|00001a60| 72 69 74 69 6e 67 20 69 | 74 3b 20 74 68 65 6e 0a |riting i|t; then.|
|00001a70| 58 79 6f 75 20 63 61 6e | 20 73 74 61 72 74 20 72 |Xyou can| start r|
|00001a80| 65 61 64 69 6e 67 20 69 | 74 20 77 69 74 68 20 40 |eading i|t with @|
|00001a90| 63 6f 64 65 7b 67 65 74 | 6c 69 6e 65 7d 20 28 40 |code{get|line} (@|
|00001aa0| 70 78 72 65 66 7b 47 65 | 74 6c 69 6e 65 7d 29 2e |pxref{Ge|tline}).|
|00001ab0| 0a 58 0a 58 40 69 74 65 | 6d 0a 58 54 6f 20 77 72 |.X.X@ite|m.XTo wr|
|00001ac0| 69 74 65 20 6e 75 6d 65 | 72 6f 75 73 20 66 69 6c |ite nume|rous fil|
|00001ad0| 65 73 2c 20 73 75 63 63 | 65 73 73 69 76 65 6c 79 |es, succ|essively|
|00001ae0| 2c 20 69 6e 20 74 68 65 | 20 73 61 6d 65 20 40 63 |, in the| same @c|
|00001af0| 6f 64 65 7b 61 77 6b 7d | 0a 58 70 72 6f 67 72 61 |ode{awk}|.Xprogra|
|00001b00| 6d 2e 20 20 49 66 20 79 | 6f 75 20 64 6f 6e 27 74 |m. If y|ou don't|
|00001b10| 20 63 6c 6f 73 65 20 74 | 68 65 20 66 69 6c 65 73 | close t|he files|
|00001b20| 2c 20 65 76 65 6e 74 75 | 61 6c 6c 79 20 79 6f 75 |, eventu|ally you|
|00001b30| 20 77 69 6c 6c 20 65 78 | 63 65 65 64 20 74 68 65 | will ex|ceed the|
|00001b40| 0a 58 73 79 73 74 65 6d | 20 6c 69 6d 69 74 20 6f |.Xsystem| limit o|
|00001b50| 6e 20 74 68 65 20 6e 75 | 6d 62 65 72 20 6f 66 20 |n the nu|mber of |
|00001b60| 6f 70 65 6e 20 66 69 6c | 65 73 20 69 6e 20 6f 6e |open fil|es in on|
|00001b70| 65 20 70 72 6f 63 65 73 | 73 2e 20 20 53 6f 20 63 |e proces|s. So c|
|00001b80| 6c 6f 73 65 0a 58 65 61 | 63 68 20 6f 6e 65 20 77 |lose.Xea|ch one w|
|00001b90| 68 65 6e 20 79 6f 75 20 | 61 72 65 20 66 69 6e 69 |hen you |are fini|
|00001ba0| 73 68 65 64 20 77 72 69 | 74 69 6e 67 20 69 74 2e |shed wri|ting it.|
|00001bb0| 0a 58 0a 58 40 69 74 65 | 6d 0a 58 54 6f 20 6d 61 |.X.X@ite|m.XTo ma|
|00001bc0| 6b 65 20 61 20 63 6f 6d | 6d 61 6e 64 20 66 69 6e |ke a com|mand fin|
|00001bd0| 69 73 68 2e 20 20 57 68 | 65 6e 20 79 6f 75 20 72 |ish. Wh|en you r|
|00001be0| 65 64 69 72 65 63 74 20 | 6f 75 74 70 75 74 20 74 |edirect |output t|
|00001bf0| 68 72 6f 75 67 68 20 61 | 20 70 69 70 65 2c 0a 58 |hrough a| pipe,.X|
|00001c00| 74 68 65 20 63 6f 6d 6d | 61 6e 64 20 72 65 61 64 |the comm|and read|
|00001c10| 69 6e 67 20 74 68 65 20 | 70 69 70 65 20 6e 6f 72 |ing the |pipe nor|
|00001c20| 6d 61 6c 6c 79 20 63 6f | 6e 74 69 6e 75 65 73 20 |mally co|ntinues |
|00001c30| 74 6f 20 74 72 79 20 74 | 6f 20 72 65 61 64 20 69 |to try t|o read i|
|00001c40| 6e 70 75 74 0a 58 61 73 | 20 6c 6f 6e 67 20 61 73 |nput.Xas| long as|
|00001c50| 20 74 68 65 20 70 69 70 | 65 20 69 73 20 6f 70 65 | the pip|e is ope|
|00001c60| 6e 2e 20 20 4f 66 74 65 | 6e 20 74 68 69 73 20 6d |n. Ofte|n this m|
|00001c70| 65 61 6e 73 20 74 68 65 | 20 63 6f 6d 6d 61 6e 64 |eans the| command|
|00001c80| 20 63 61 6e 6e 6f 74 0a | 58 72 65 61 6c 6c 79 20 | cannot.|Xreally |
|00001c90| 64 6f 20 69 74 73 20 77 | 6f 72 6b 20 75 6e 74 69 |do its w|ork unti|
|00001ca0| 6c 20 74 68 65 20 70 69 | 70 65 20 69 73 20 63 6c |l the pi|pe is cl|
|00001cb0| 6f 73 65 64 2e 20 20 46 | 6f 72 20 65 78 61 6d 70 |osed. F|or examp|
|00001cc0| 6c 65 2c 20 69 66 20 79 | 6f 75 0a 58 72 65 64 69 |le, if y|ou.Xredi|
|00001cd0| 72 65 63 74 20 6f 75 74 | 70 75 74 20 74 6f 20 74 |rect out|put to t|
|00001ce0| 68 65 20 40 63 6f 64 65 | 7b 6d 61 69 6c 7d 20 70 |he @code|{mail} p|
|00001cf0| 72 6f 67 72 61 6d 2c 20 | 74 68 65 20 6d 65 73 73 |rogram, |the mess|
|00001d00| 61 67 65 20 69 73 20 6e | 6f 74 0a 58 61 63 74 75 |age is n|ot.Xactu|
|00001d10| 61 6c 6c 79 20 73 65 6e | 74 20 75 6e 74 69 6c 20 |ally sen|t until |
|00001d20| 74 68 65 20 70 69 70 65 | 20 69 73 20 63 6c 6f 73 |the pipe| is clos|
|00001d30| 65 64 2e 0a 58 0a 58 40 | 69 74 65 6d 0a 58 54 6f |ed..X.X@|item.XTo|
|00001d40| 20 72 75 6e 20 74 68 65 | 20 73 61 6d 65 20 70 72 | run the| same pr|
|00001d50| 6f 67 72 61 6d 20 61 20 | 73 65 63 6f 6e 64 20 74 |ogram a |second t|
|00001d60| 69 6d 65 2c 20 77 69 74 | 68 20 74 68 65 20 73 61 |ime, wit|h the sa|
|00001d70| 6d 65 20 61 72 67 75 6d | 65 6e 74 73 2e 0a 58 54 |me argum|ents..XT|
|00001d80| 68 69 73 20 69 73 20 6e | 6f 74 20 74 68 65 20 73 |his is n|ot the s|
|00001d90| 61 6d 65 20 74 68 69 6e | 67 20 61 73 20 67 69 76 |ame thin|g as giv|
|00001da0| 69 6e 67 20 6d 6f 72 65 | 20 69 6e 70 75 74 20 74 |ing more| input t|
|00001db0| 6f 20 74 68 65 20 66 69 | 72 73 74 20 72 75 6e 21 |o the fi|rst run!|
|00001dc0| 0a 58 0a 58 46 6f 72 20 | 65 78 61 6d 70 6c 65 2c |.X.XFor |example,|
|00001dd0| 20 73 75 70 70 6f 73 65 | 20 79 6f 75 20 70 69 70 | suppose| you pip|
|00001de0| 65 20 6f 75 74 70 75 74 | 20 74 6f 20 74 68 65 20 |e output| to the |
|00001df0| 40 63 6f 64 65 7b 6d 61 | 69 6c 7d 20 70 72 6f 67 |@code{ma|il} prog|
|00001e00| 72 61 6d 2e 20 20 49 66 | 20 79 6f 75 0a 58 6f 75 |ram. If| you.Xou|
|00001e10| 74 70 75 74 20 73 65 76 | 65 72 61 6c 20 6c 69 6e |tput sev|eral lin|
|00001e20| 65 73 20 72 65 64 69 72 | 65 63 74 65 64 20 74 6f |es redir|ected to|
|00001e30| 20 74 68 69 73 20 70 69 | 70 65 20 77 69 74 68 6f | this pi|pe witho|
|00001e40| 75 74 20 63 6c 6f 73 69 | 6e 67 20 69 74 2c 20 74 |ut closi|ng it, t|
|00001e50| 68 65 79 20 6d 61 6b 65 | 0a 58 61 20 73 69 6e 67 |hey make|.Xa sing|
|00001e60| 6c 65 20 6d 65 73 73 61 | 67 65 20 6f 66 20 73 65 |le messa|ge of se|
|00001e70| 76 65 72 61 6c 20 6c 69 | 6e 65 73 2e 20 20 42 79 |veral li|nes. By|
|00001e80| 20 63 6f 6e 74 72 61 73 | 74 2c 20 69 66 20 79 6f | contras|t, if yo|
|00001e90| 75 20 63 6c 6f 73 65 20 | 74 68 65 20 70 69 70 65 |u close |the pipe|
|00001ea0| 0a 58 61 66 74 65 72 20 | 65 61 63 68 20 6c 69 6e |.Xafter |each lin|
|00001eb0| 65 20 6f 66 20 6f 75 74 | 70 75 74 2c 20 74 68 65 |e of out|put, the|
|00001ec0| 6e 20 65 61 63 68 20 6c | 69 6e 65 20 6d 61 6b 65 |n each l|ine make|
|00001ed0| 73 20 61 20 73 65 70 61 | 72 61 74 65 20 6d 65 73 |s a sepa|rate mes|
|00001ee0| 73 61 67 65 2e 0a 58 40 | 65 6e 64 20 69 74 65 6d |sage..X@|end item|
|00001ef0| 69 7a 65 0a 58 0a 58 40 | 6e 6f 64 65 20 53 70 65 |ize.X.X@|node Spe|
|00001f00| 63 69 61 6c 20 46 69 6c | 65 73 2c 20 2c 20 52 65 |cial Fil|es, , Re|
|00001f10| 64 69 72 65 63 74 69 6f | 6e 2c 20 50 72 69 6e 74 |directio|n, Print|
|00001f20| 69 6e 67 0a 58 40 73 65 | 63 74 69 6f 6e 20 53 74 |ing.X@se|ction St|
|00001f30| 61 6e 64 61 72 64 20 49 | 2f 4f 20 53 74 72 65 61 |andard I|/O Strea|
|00001f40| 6d 73 0a 58 40 63 69 6e | 64 65 78 20 73 74 61 6e |ms.X@cin|dex stan|
|00001f50| 64 61 72 64 20 69 6e 70 | 75 74 0a 58 40 63 69 6e |dard inp|ut.X@cin|
|00001f60| 64 65 78 20 73 74 61 6e | 64 61 72 64 20 6f 75 74 |dex stan|dard out|
|00001f70| 70 75 74 0a 58 40 63 69 | 6e 64 65 78 20 73 74 61 |put.X@ci|ndex sta|
|00001f80| 6e 64 61 72 64 20 65 72 | 72 6f 72 20 6f 75 74 70 |ndard er|ror outp|
|00001f90| 75 74 0a 58 40 63 69 6e | 64 65 78 20 66 69 6c 65 |ut.X@cin|dex file|
|00001fa0| 20 64 65 73 63 72 69 70 | 74 6f 72 73 0a 58 0a 58 | descrip|tors.X.X|
|00001fb0| 52 75 6e 6e 69 6e 67 20 | 70 72 6f 67 72 61 6d 73 |Running |programs|
|00001fc0| 20 63 6f 6e 76 65 6e 74 | 69 6f 6e 61 6c 6c 79 20 | convent|ionally |
|00001fd0| 68 61 76 65 20 74 68 72 | 65 65 20 69 6e 70 75 74 |have thr|ee input|
|00001fe0| 20 61 6e 64 20 6f 75 74 | 70 75 74 20 73 74 72 65 | and out|put stre|
|00001ff0| 61 6d 73 0a 58 61 6c 72 | 65 61 64 79 20 61 76 61 |ams.Xalr|eady ava|
|00002000| 69 6c 61 62 6c 65 20 74 | 6f 20 74 68 65 6d 20 66 |ilable t|o them f|
|00002010| 6f 72 20 72 65 61 64 69 | 6e 67 20 61 6e 64 20 77 |or readi|ng and w|
|00002020| 72 69 74 69 6e 67 2e 20 | 20 54 68 65 73 65 20 61 |riting. | These a|
|00002030| 72 65 20 6b 6e 6f 77 6e | 20 61 73 0a 58 74 68 65 |re known| as.Xthe|
|00002040| 20 40 64 66 6e 7b 73 74 | 61 6e 64 61 72 64 20 69 | @dfn{st|andard i|
|00002050| 6e 70 75 74 7d 2c 20 40 | 64 66 6e 7b 73 74 61 6e |nput}, @|dfn{stan|
|00002060| 64 61 72 64 20 6f 75 74 | 70 75 74 7d 2c 20 61 6e |dard out|put}, an|
|00002070| 64 20 40 64 66 6e 7b 73 | 74 61 6e 64 61 72 64 20 |d @dfn{s|tandard |
|00002080| 65 72 72 6f 72 0a 58 6f | 75 74 70 75 74 7d 2e 20 |error.Xo|utput}. |
|00002090| 20 54 68 65 73 65 20 73 | 74 72 65 61 6d 73 20 61 | These s|treams a|
|000020a0| 72 65 2c 20 62 79 20 64 | 65 66 61 75 6c 74 2c 20 |re, by d|efault, |
|000020b0| 74 65 72 6d 69 6e 61 6c | 20 69 6e 70 75 74 20 61 |terminal| input a|
|000020c0| 6e 64 20 6f 75 74 70 75 | 74 2c 20 62 75 74 0a 58 |nd outpu|t, but.X|
|000020d0| 74 68 65 79 20 61 72 65 | 20 6f 66 74 65 6e 20 72 |they are| often r|
|000020e0| 65 64 69 72 65 63 74 65 | 64 20 77 69 74 68 20 74 |edirecte|d with t|
|000020f0| 68 65 20 73 68 65 6c 6c | 2c 20 76 69 61 20 74 68 |he shell|, via th|
|00002100| 65 20 40 73 61 6d 70 7b | 3c 7d 2c 20 40 73 61 6d |e @samp{|<}, @sam|
|00002110| 70 7b 3c 3c 7d 2c 0a 58 | 40 73 61 6d 70 7b 3e 7d |p{<<},.X|@samp{>}|
|00002120| 2c 20 40 73 61 6d 70 7b | 3e 3e 7d 2c 20 40 73 61 |, @samp{|>>}, @sa|
|00002130| 6d 70 7b 3e 26 7d 20 61 | 6e 64 20 40 73 61 6d 70 |mp{>&} a|nd @samp|
|00002140| 7b 7c 7d 20 6f 70 65 72 | 61 74 6f 72 73 2e 20 20 |{|} oper|ators. |
|00002150| 53 74 61 6e 64 61 72 64 | 20 65 72 72 6f 72 0a 58 |Standard| error.X|
|00002160| 69 73 20 75 73 65 64 20 | 6f 6e 6c 79 20 66 6f 72 |is used |only for|
|00002170| 20 77 72 69 74 69 6e 67 | 20 65 72 72 6f 72 20 6d | writing| error m|
|00002180| 65 73 73 61 67 65 73 3b | 20 74 68 65 20 72 65 61 |essages;| the rea|
|00002190| 73 6f 6e 20 77 65 20 68 | 61 76 65 20 74 77 6f 20 |son we h|ave two |
|000021a0| 73 65 70 61 72 61 74 65 | 0a 58 73 74 72 65 61 6d |separate|.Xstream|
|000021b0| 73 2c 20 73 74 61 6e 64 | 61 72 64 20 6f 75 74 70 |s, stand|ard outp|
|000021c0| 75 74 20 61 6e 64 20 73 | 74 61 6e 64 61 72 64 20 |ut and s|tandard |
|000021d0| 65 72 72 6f 72 2c 20 69 | 73 20 73 6f 20 74 68 61 |error, i|s so tha|
|000021e0| 74 20 74 68 65 79 20 63 | 61 6e 20 62 65 0a 58 72 |t they c|an be.Xr|
|000021f0| 65 64 69 72 65 63 74 65 | 64 20 73 65 70 61 72 61 |edirecte|d separa|
|00002200| 74 65 6c 79 2e 0a 58 0a | 58 40 63 20 40 63 69 6e |tely..X.|X@c @cin|
|00002210| 64 65 78 20 64 69 66 66 | 65 72 65 6e 63 65 73 20 |dex diff|erences |
|00002220| 62 65 74 77 65 65 6e 20 | 40 63 6f 64 65 7b 67 61 |between |@code{ga|
|00002230| 77 6b 7d 20 61 6e 64 20 | 40 63 6f 64 65 7b 61 77 |wk} and |@code{aw|
|00002240| 6b 7d 0a 58 49 6e 20 6f | 74 68 65 72 20 69 6d 70 |k}.XIn o|ther imp|
|00002250| 6c 65 6d 65 6e 74 61 74 | 69 6f 6e 73 20 6f 66 20 |lementat|ions of |
|00002260| 40 63 6f 64 65 7b 61 77 | 6b 7d 2c 20 74 68 65 20 |@code{aw|k}, the |
|00002270| 6f 6e 6c 79 20 77 61 79 | 20 74 6f 20 77 72 69 74 |only way| to writ|
|00002280| 65 20 61 6e 20 65 72 72 | 6f 72 0a 58 6d 65 73 73 |e an err|or.Xmess|
|00002290| 61 67 65 20 74 6f 20 73 | 74 61 6e 64 61 72 64 20 |age to s|tandard |
|000022a0| 65 72 72 6f 72 20 69 6e | 20 61 6e 20 40 63 6f 64 |error in| an @cod|
|000022b0| 65 7b 61 77 6b 7d 20 70 | 72 6f 67 72 61 6d 20 69 |e{awk} p|rogram i|
|000022c0| 73 20 61 73 20 66 6f 6c | 6c 6f 77 73 3a 0a 58 0a |s as fol|lows:.X.|
|000022d0| 58 40 65 78 61 6d 70 6c | 65 0a 58 70 72 69 6e 74 |X@exampl|e.Xprint|
|000022e0| 20 22 53 65 72 69 6f 75 | 73 20 65 72 72 6f 72 20 | "Seriou|s error |
|000022f0| 64 65 74 65 63 74 65 64 | 21 5c 6e 22 20 7c 20 22 |detected|!\n" | "|
|00002300| 63 61 74 20 31 3e 26 32 | 22 0a 58 40 65 6e 64 20 |cat 1>&2|".X@end |
|00002310| 65 78 61 6d 70 6c 65 0a | 58 0a 58 40 6e 6f 69 6e |example.|X.X@noin|
|00002320| 64 65 6e 74 0a 58 54 68 | 69 73 20 77 6f 72 6b 73 |dent.XTh|is works|
|00002330| 20 62 79 20 6f 70 65 6e | 69 6e 67 20 61 20 70 69 | by open|ing a pi|
|00002340| 70 65 6c 69 6e 65 20 74 | 6f 20 61 20 73 68 65 6c |peline t|o a shel|
|00002350| 6c 20 63 6f 6d 6d 61 6e | 64 20 77 68 69 63 68 20 |l comman|d which |
|00002360| 63 61 6e 20 61 63 63 65 | 73 73 20 74 68 65 0a 58 |can acce|ss the.X|
|00002370| 73 74 61 6e 64 61 72 64 | 20 65 72 72 6f 72 20 73 |standard| error s|
|00002380| 74 72 65 61 6d 20 77 68 | 69 63 68 20 69 74 20 69 |tream wh|ich it i|
|00002390| 6e 68 65 72 69 74 73 20 | 66 72 6f 6d 20 74 68 65 |nherits |from the|
|000023a0| 20 40 63 6f 64 65 7b 61 | 77 6b 7d 20 70 72 6f 63 | @code{a|wk} proc|
|000023b0| 65 73 73 2e 0a 58 54 68 | 69 73 20 69 73 20 66 61 |ess..XTh|is is fa|
|000023c0| 72 20 66 72 6f 6d 20 65 | 6c 65 67 61 6e 74 2c 20 |r from e|legant, |
|000023d0| 61 6e 64 20 69 73 20 61 | 6c 73 6f 20 69 6e 65 66 |and is a|lso inef|
|000023e0| 66 69 63 69 65 6e 74 2c | 20 73 69 6e 63 65 20 69 |ficient,| since i|
|000023f0| 74 20 72 65 71 75 69 72 | 65 73 20 61 0a 58 73 65 |t requir|es a.Xse|
|00002400| 70 61 72 61 74 65 20 70 | 72 6f 63 65 73 73 2e 20 |parate p|rocess. |
|00002410| 20 53 6f 20 70 65 6f 70 | 6c 65 20 77 72 69 74 69 | So peop|le writi|
|00002420| 6e 67 20 40 63 6f 64 65 | 7b 61 77 6b 7d 20 70 72 |ng @code|{awk} pr|
|00002430| 6f 67 72 61 6d 73 20 68 | 61 76 65 20 6f 66 74 65 |ograms h|ave ofte|
|00002440| 6e 0a 58 6e 65 67 6c 65 | 63 74 65 64 20 74 6f 20 |n.Xnegle|cted to |
|00002450| 64 6f 20 74 68 69 73 2e | 20 20 49 6e 73 74 65 61 |do this.| Instea|
|00002460| 64 2c 20 74 68 65 79 20 | 68 61 76 65 20 73 65 6e |d, they |have sen|
|00002470| 74 20 74 68 65 20 65 72 | 72 6f 72 20 6d 65 73 73 |t the er|ror mess|
|00002480| 61 67 65 73 20 74 6f 20 | 74 68 65 0a 58 74 65 72 |ages to |the.Xter|
|00002490| 6d 69 6e 61 6c 2c 20 6c | 69 6b 65 20 74 68 69 73 |minal, l|ike this|
|000024a0| 3a 0a 58 0a 58 40 65 78 | 61 6d 70 6c 65 0a 58 4e |:.X.X@ex|ample.XN|
|000024b0| 46 20 21 3d 20 34 20 40 | 7b 0a 58 20 20 20 70 72 |F != 4 @|{.X pr|
|000024c0| 69 6e 74 66 28 22 6c 69 | 6e 65 20 25 64 20 73 6b |intf("li|ne %d sk|
|000024d0| 69 70 70 65 64 3a 20 64 | 6f 65 73 6e 27 74 20 68 |ipped: d|oesn't h|
|000024e0| 61 76 65 20 34 20 66 69 | 65 6c 64 73 5c 6e 22 2c |ave 4 fi|elds\n",|
|000024f0| 20 46 4e 52 29 20 3e 20 | 22 2f 64 65 76 2f 74 74 | FNR) > |"/dev/tt|
|00002500| 79 22 0a 58 40 7d 0a 58 | 40 65 6e 64 20 65 78 61 |y".X@}.X|@end exa|
|00002510| 6d 70 6c 65 0a 58 0a 58 | 40 6e 6f 69 6e 64 65 6e |mple.X.X|@noinden|
|00002520| 74 0a 58 54 68 69 73 20 | 68 61 73 20 74 68 65 20 |t.XThis |has the |
|00002530| 73 61 6d 65 20 65 66 66 | 65 63 74 20 6d 6f 73 74 |same eff|ect most|
|00002540| 20 6f 66 20 74 68 65 20 | 74 69 6d 65 2c 20 62 75 | of the |time, bu|
|00002550| 74 20 6e 6f 74 20 61 6c | 77 61 79 73 3a 20 61 6c |t not al|ways: al|
|00002560| 74 68 6f 75 67 68 20 74 | 68 65 0a 58 73 74 61 6e |though t|he.Xstan|
|00002570| 64 61 72 64 20 65 72 72 | 6f 72 20 73 74 72 65 61 |dard err|or strea|
|00002580| 6d 20 69 73 20 75 73 75 | 61 6c 6c 79 20 74 68 65 |m is usu|ally the|
|00002590| 20 74 65 72 6d 69 6e 61 | 6c 2c 20 69 74 20 63 61 | termina|l, it ca|
|000025a0| 6e 20 62 65 20 72 65 64 | 69 72 65 63 74 65 64 2c |n be red|irected,|
|000025b0| 20 61 6e 64 0a 58 77 68 | 65 6e 20 74 68 61 74 20 | and.Xwh|en that |
|000025c0| 68 61 70 70 65 6e 73 2c | 20 77 72 69 74 69 6e 67 |happens,| writing|
|000025d0| 20 74 6f 20 74 68 65 20 | 74 65 72 6d 69 6e 61 6c | to the |terminal|
|000025e0| 20 69 73 20 6e 6f 74 20 | 63 6f 72 72 65 63 74 2e | is not |correct.|
|000025f0| 20 20 49 6e 20 66 61 63 | 74 2c 20 69 66 0a 58 40 | In fac|t, if.X@|
|00002600| 63 6f 64 65 7b 61 77 6b | 7d 20 69 73 20 72 75 6e |code{awk|} is run|
|00002610| 20 66 72 6f 6d 20 61 20 | 62 61 63 6b 67 72 6f 75 | from a |backgrou|
|00002620| 6e 64 20 6a 6f 62 2c 20 | 69 74 20 6d 61 79 20 6e |nd job, |it may n|
|00002630| 6f 74 20 68 61 76 65 20 | 61 20 74 65 72 6d 69 6e |ot have |a termin|
|00002640| 61 6c 20 61 74 20 61 6c | 6c 2e 0a 58 54 68 65 6e |al at al|l..XThen|
|00002650| 20 6f 70 65 6e 69 6e 67 | 20 40 66 69 6c 65 7b 2f | opening| @file{/|
|00002660| 64 65 76 2f 74 74 79 7d | 20 77 69 6c 6c 20 66 61 |dev/tty}| will fa|
|00002670| 69 6c 2e 0a 58 0a 58 40 | 63 6f 64 65 7b 67 61 77 |il..X.X@|code{gaw|
|00002680| 6b 7d 20 70 72 6f 76 69 | 64 65 73 20 73 70 65 63 |k} provi|des spec|
|00002690| 69 61 6c 20 66 69 6c 65 | 20 6e 61 6d 65 73 20 66 |ial file| names f|
|000026a0| 6f 72 20 61 63 63 65 73 | 73 69 6e 67 20 74 68 65 |or acces|sing the|
|000026b0| 20 74 68 72 65 65 20 73 | 74 61 6e 64 61 72 64 0a | three s|tandard.|
|000026c0| 58 73 74 72 65 61 6d 73 | 2e 20 20 57 68 65 6e 20 |Xstreams|. When |
|000026d0| 79 6f 75 20 72 65 64 69 | 72 65 63 74 20 69 6e 70 |you redi|rect inp|
|000026e0| 75 74 20 6f 72 20 6f 75 | 74 70 75 74 20 69 6e 20 |ut or ou|tput in |
|000026f0| 40 63 6f 64 65 7b 67 61 | 77 6b 7d 2c 20 69 66 20 |@code{ga|wk}, if |
|00002700| 74 68 65 20 66 69 6c 65 | 20 6e 61 6d 65 0a 58 6d |the file| name.Xm|
|00002710| 61 74 63 68 65 73 20 6f | 6e 65 20 6f 66 20 74 68 |atches o|ne of th|
|00002720| 65 73 65 20 73 70 65 63 | 69 61 6c 20 6e 61 6d 65 |ese spec|ial name|
|00002730| 73 2c 20 74 68 65 6e 20 | 40 63 6f 64 65 7b 67 61 |s, then |@code{ga|
|00002740| 77 6b 7d 20 64 69 72 65 | 63 74 6c 79 20 75 73 65 |wk} dire|ctly use|
|00002750| 73 20 74 68 65 0a 58 73 | 74 72 65 61 6d 20 69 74 |s the.Xs|tream it|
|00002760| 20 73 74 61 6e 64 73 20 | 66 6f 72 2e 0a 58 0a 58 | stands |for..X.X|
|00002770| 40 63 69 6e 64 65 78 20 | 40 66 69 6c 65 7b 2f 64 |@cindex |@file{/d|
|00002780| 65 76 2f 73 74 64 69 6e | 7d 0a 58 40 63 69 6e 64 |ev/stdin|}.X@cind|
|00002790| 65 78 20 40 66 69 6c 65 | 7b 2f 64 65 76 2f 73 74 |ex @file|{/dev/st|
|000027a0| 64 6f 75 74 7d 0a 58 40 | 63 69 6e 64 65 78 20 40 |dout}.X@|cindex @|
|000027b0| 66 69 6c 65 7b 2f 64 65 | 76 2f 73 74 64 65 72 72 |file{/de|v/stderr|
|000027c0| 7d 0a 58 40 63 69 6e 64 | 65 78 20 40 66 69 6c 65 |}.X@cind|ex @file|
|000027d0| 7b 2f 64 65 76 2f 66 64 | 2f 7d 0a 58 40 74 61 62 |{/dev/fd|/}.X@tab|
|000027e0| 6c 65 20 40 66 69 6c 65 | 0a 58 40 69 74 65 6d 20 |le @file|.X@item |
|000027f0| 2f 64 65 76 2f 73 74 64 | 69 6e 0a 58 54 68 65 20 |/dev/std|in.XThe |
|00002800| 73 74 61 6e 64 61 72 64 | 20 69 6e 70 75 74 20 28 |standard| input (|
|00002810| 66 69 6c 65 20 64 65 73 | 63 72 69 70 74 6f 72 20 |file des|criptor |
|00002820| 30 29 2e 0a 58 0a 58 40 | 69 74 65 6d 20 2f 64 65 |0)..X.X@|item /de|
|00002830| 76 2f 73 74 64 6f 75 74 | 0a 58 54 68 65 20 73 74 |v/stdout|.XThe st|
|00002840| 61 6e 64 61 72 64 20 6f | 75 74 70 75 74 20 28 66 |andard o|utput (f|
|00002850| 69 6c 65 20 64 65 73 63 | 72 69 70 74 6f 72 20 31 |ile desc|riptor 1|
|00002860| 29 2e 0a 58 0a 58 40 69 | 74 65 6d 20 2f 64 65 76 |)..X.X@i|tem /dev|
|00002870| 2f 73 74 64 65 72 72 0a | 58 54 68 65 20 73 74 61 |/stderr.|XThe sta|
|00002880| 6e 64 61 72 64 20 65 72 | 72 6f 72 20 6f 75 74 70 |ndard er|ror outp|
|00002890| 75 74 20 28 66 69 6c 65 | 20 64 65 73 63 72 69 70 |ut (file| descrip|
|000028a0| 74 6f 72 20 32 29 2e 0a | 58 0a 58 40 69 74 65 6d |tor 2)..|X.X@item|
|000028b0| 20 2f 64 65 76 2f 66 64 | 2f 40 76 61 72 7b 6e 7d | /dev/fd|/@var{n}|
|000028c0| 0a 58 54 68 65 20 66 69 | 6c 65 20 61 73 73 6f 63 |.XThe fi|le assoc|
|000028d0| 69 61 74 65 64 20 77 69 | 74 68 20 66 69 6c 65 20 |iated wi|th file |
|000028e0| 64 65 73 63 72 69 70 74 | 6f 72 20 40 76 61 72 7b |descript|or @var{|
|000028f0| 6e 7d 2e 20 20 53 75 63 | 68 20 61 20 66 69 6c 65 |n}. Suc|h a file|
|00002900| 20 6d 75 73 74 20 68 61 | 76 65 0a 58 62 65 65 6e | must ha|ve.Xbeen|
|00002910| 20 6f 70 65 6e 65 64 20 | 62 79 20 74 68 65 20 70 | opened |by the p|
|00002920| 72 6f 67 72 61 6d 20 69 | 6e 69 74 69 61 74 69 6e |rogram i|nitiatin|
|00002930| 67 20 74 68 65 20 40 63 | 6f 64 65 7b 61 77 6b 7d |g the @c|ode{awk}|
|00002940| 20 65 78 65 63 75 74 69 | 6f 6e 20 28 74 79 70 69 | executi|on (typi|
|00002950| 63 61 6c 6c 79 0a 58 74 | 68 65 20 73 68 65 6c 6c |cally.Xt|he shell|
|00002960| 29 2e 20 20 55 6e 6c 65 | 73 73 20 79 6f 75 20 74 |). Unle|ss you t|
|00002970| 61 6b 65 20 73 70 65 63 | 69 61 6c 20 70 61 69 6e |ake spec|ial pain|
|00002980| 73 2c 20 6f 6e 6c 79 20 | 64 65 73 63 72 69 70 74 |s, only |descript|
|00002990| 6f 72 73 20 30 2c 20 31 | 20 61 6e 64 20 32 0a 58 |ors 0, 1| and 2.X|
|000029a0| 61 72 65 20 61 76 61 69 | 6c 61 62 6c 65 2e 0a 58 |are avai|lable..X|
|000029b0| 40 65 6e 64 20 74 61 62 | 6c 65 0a 58 0a 58 54 68 |@end tab|le.X.XTh|
|000029c0| 65 20 66 69 6c 65 20 6e | 61 6d 65 73 20 40 66 69 |e file n|ames @fi|
|000029d0| 6c 65 7b 2f 64 65 76 2f | 73 74 64 69 6e 7d 2c 20 |le{/dev/|stdin}, |
|000029e0| 40 66 69 6c 65 7b 2f 64 | 65 76 2f 73 74 64 6f 75 |@file{/d|ev/stdou|
|000029f0| 74 7d 2c 20 61 6e 64 20 | 40 66 69 6c 65 7b 2f 64 |t}, and |@file{/d|
|00002a00| 65 76 2f 73 74 64 65 72 | 72 7d 0a 58 61 72 65 20 |ev/stder|r}.Xare |
|00002a10| 61 6c 69 61 73 65 73 20 | 66 6f 72 20 40 66 69 6c |aliases |for @fil|
|00002a20| 65 7b 2f 64 65 76 2f 66 | 64 2f 30 7d 2c 20 40 66 |e{/dev/f|d/0}, @f|
|00002a30| 69 6c 65 7b 2f 64 65 76 | 2f 66 64 2f 31 7d 2c 20 |ile{/dev|/fd/1}, |
|00002a40| 61 6e 64 20 40 66 69 6c | 65 7b 2f 64 65 76 2f 66 |and @fil|e{/dev/f|
|00002a50| 64 2f 32 7d 2c 0a 58 72 | 65 73 70 65 63 74 69 76 |d/2},.Xr|espectiv|
|00002a60| 65 6c 79 2c 20 62 75 74 | 20 74 68 65 79 20 61 72 |ely, but| they ar|
|00002a70| 65 20 6d 6f 72 65 20 73 | 65 6c 66 2d 65 78 70 6c |e more s|elf-expl|
|00002a80| 61 6e 61 74 6f 72 79 2e | 0a 58 0a 58 54 68 65 20 |anatory.|.X.XThe |
|00002a90| 70 72 6f 70 65 72 20 77 | 61 79 20 74 6f 20 77 72 |proper w|ay to wr|
|00002aa0| 69 74 65 20 61 6e 20 65 | 72 72 6f 72 20 6d 65 73 |ite an e|rror mes|
|00002ab0| 73 61 67 65 20 69 6e 20 | 61 20 40 63 6f 64 65 7b |sage in |a @code{|
|00002ac0| 67 61 77 6b 7d 20 70 72 | 6f 67 72 61 6d 0a 58 69 |gawk} pr|ogram.Xi|
|00002ad0| 73 20 74 6f 20 75 73 65 | 20 40 66 69 6c 65 7b 2f |s to use| @file{/|
|00002ae0| 64 65 76 2f 73 74 64 65 | 72 72 7d 2c 20 6c 69 6b |dev/stde|rr}, lik|
|00002af0| 65 20 74 68 69 73 3a 0a | 58 0a 58 40 65 78 61 6d |e this:.|X.X@exam|
|00002b00| 70 6c 65 0a 58 4e 46 20 | 21 3d 20 34 20 40 7b 0a |ple.XNF |!= 4 @{.|
|00002b10| 58 20 20 70 72 69 6e 74 | 66 28 22 6c 69 6e 65 20 |X print|f("line |
|00002b20| 25 64 20 73 6b 69 70 70 | 65 64 3a 20 64 6f 65 73 |%d skipp|ed: does|
|00002b30| 6e 27 74 20 68 61 76 65 | 20 34 20 66 69 65 6c 64 |n't have| 4 field|
|00002b40| 73 5c 6e 22 2c 20 46 4e | 52 29 20 3e 20 22 2f 64 |s\n", FN|R) > "/d|
|00002b50| 65 76 2f 73 74 64 65 72 | 72 22 0a 58 40 7d 0a 58 |ev/stder|r".X@}.X|
|00002b60| 40 65 6e 64 20 65 78 61 | 6d 70 6c 65 0a 58 0a 58 |@end exa|mple.X.X|
|00002b70| 52 65 63 6f 67 6e 69 74 | 69 6f 6e 20 6f 66 20 74 |Recognit|ion of t|
|00002b80| 68 65 73 65 20 73 70 65 | 63 69 61 6c 20 66 69 6c |hese spe|cial fil|
|00002b90| 65 20 6e 61 6d 65 73 20 | 69 73 20 64 69 73 61 62 |e names |is disab|
|00002ba0| 6c 65 64 20 69 66 20 40 | 63 6f 64 65 7b 67 61 77 |led if @|code{gaw|
|00002bb0| 6b 7d 20 69 73 20 69 6e | 0a 58 63 6f 6d 70 61 74 |k} is in|.Xcompat|
|00002bc0| 69 62 69 6c 69 74 79 20 | 6d 6f 64 65 20 28 40 70 |ibility |mode (@p|
|00002bd0| 78 72 65 66 7b 43 6f 6d | 6d 61 6e 64 20 4c 69 6e |xref{Com|mand Lin|
|00002be0| 65 7d 29 2e 0a 58 0a 58 | 40 6e 6f 64 65 20 4f 6e |e})..X.X|@node On|
|00002bf0| 65 2d 6c 69 6e 65 72 73 | 2c 20 50 61 74 74 65 72 |e-liners|, Patter|
|00002c00| 6e 73 2c 20 50 72 69 6e | 74 69 6e 67 2c 20 54 6f |ns, Prin|ting, To|
|00002c10| 70 0a 58 40 63 68 61 70 | 74 65 72 20 55 73 65 66 |p.X@chap|ter Usef|
|00002c20| 75 6c 20 60 60 4f 6e 65 | 2d 6c 69 6e 65 72 73 27 |ul ``One|-liners'|
|00002c30| 27 0a 58 0a 58 40 63 69 | 6e 64 65 78 20 6f 6e 65 |'.X.X@ci|ndex one|
|00002c40| 2d 6c 69 6e 65 72 73 0a | 58 55 73 65 66 75 6c 20 |-liners.|XUseful |
|00002c50| 40 63 6f 64 65 7b 61 77 | 6b 7d 20 70 72 6f 67 72 |@code{aw|k} progr|
|00002c60| 61 6d 73 20 61 72 65 20 | 6f 66 74 65 6e 20 73 68 |ams are |often sh|
|00002c70| 6f 72 74 2c 20 6a 75 73 | 74 20 61 20 6c 69 6e 65 |ort, jus|t a line|
|00002c80| 20 6f 72 20 74 77 6f 2e | 20 20 48 65 72 65 20 69 | or two.| Here i|
|00002c90| 73 20 61 0a 58 63 6f 6c | 6c 65 63 74 69 6f 6e 20 |s a.Xcol|lection |
|00002ca0| 6f 66 20 75 73 65 66 75 | 6c 2c 20 73 68 6f 72 74 |of usefu|l, short|
|00002cb0| 20 70 72 6f 67 72 61 6d | 73 20 74 6f 20 67 65 74 | program|s to get|
|00002cc0| 20 79 6f 75 20 73 74 61 | 72 74 65 64 2e 20 20 53 | you sta|rted. S|
|00002cd0| 6f 6d 65 20 6f 66 20 74 | 68 65 73 65 0a 58 70 72 |ome of t|hese.Xpr|
|00002ce0| 6f 67 72 61 6d 73 20 63 | 6f 6e 74 61 69 6e 20 63 |ograms c|ontain c|
|00002cf0| 6f 6e 73 74 72 75 63 74 | 73 20 74 68 61 74 20 68 |onstruct|s that h|
|00002d00| 61 76 65 6e 27 74 20 62 | 65 65 6e 20 63 6f 76 65 |aven't b|een cove|
|00002d10| 72 65 64 20 79 65 74 2e | 20 20 54 68 65 20 64 65 |red yet.| The de|
|00002d20| 73 63 72 69 70 74 69 6f | 6e 0a 58 6f 66 20 74 68 |scriptio|n.Xof th|
|00002d30| 65 20 70 72 6f 67 72 61 | 6d 20 77 69 6c 6c 20 67 |e progra|m will g|
|00002d40| 69 76 65 20 79 6f 75 20 | 61 20 67 6f 6f 64 20 69 |ive you |a good i|
|00002d50| 64 65 61 20 6f 66 20 77 | 68 61 74 20 69 73 20 67 |dea of w|hat is g|
|00002d60| 6f 69 6e 67 20 6f 6e 2c | 20 62 75 74 20 70 6c 65 |oing on,| but ple|
|00002d70| 61 73 65 0a 58 72 65 61 | 64 20 74 68 65 20 72 65 |ase.Xrea|d the re|
|00002d80| 73 74 20 6f 66 20 74 68 | 65 20 6d 61 6e 75 61 6c |st of th|e manual|
|00002d90| 20 74 6f 20 62 65 63 6f | 6d 65 20 61 6e 20 40 63 | to beco|me an @c|
|00002da0| 6f 64 65 7b 61 77 6b 7d | 20 65 78 70 65 72 74 21 |ode{awk}| expert!|
|00002db0| 0a 58 0a 58 40 74 61 62 | 6c 65 20 40 63 6f 64 65 |.X.X@tab|le @code|
|00002dc0| 0a 58 40 69 74 65 6d 20 | 61 77 6b 20 27 40 7b 20 |.X@item |awk '@{ |
|00002dd0| 6e 75 6d 5f 66 69 65 6c | 64 73 20 3d 20 6e 75 6d |num_fiel|ds = num|
|00002de0| 5f 66 69 65 6c 64 73 20 | 2b 20 4e 46 20 40 7d 0a |_fields |+ NF @}.|
|00002df0| 58 40 69 74 65 6d 78 20 | 40 20 40 20 40 20 40 20 |X@itemx |@ @ @ @ |
|00002e00| 40 20 45 4e 44 20 40 7b | 20 70 72 69 6e 74 20 6e |@ END @{| print n|
|00002e10| 75 6d 5f 66 69 65 6c 64 | 73 20 40 7d 27 0a 58 54 |um_field|s @}'.XT|
|00002e20| 68 69 73 20 70 72 6f 67 | 72 61 6d 20 70 72 69 6e |his prog|ram prin|
|00002e30| 74 73 20 74 68 65 20 74 | 6f 74 61 6c 20 6e 75 6d |ts the t|otal num|
|00002e40| 62 65 72 20 6f 66 20 66 | 69 65 6c 64 73 20 69 6e |ber of f|ields in|
|00002e50| 20 61 6c 6c 20 69 6e 70 | 75 74 20 6c 69 6e 65 73 | all inp|ut lines|
|00002e60| 2e 0a 58 0a 58 40 69 74 | 65 6d 20 61 77 6b 20 27 |..X.X@it|em awk '|
|00002e70| 6c 65 6e 67 74 68 28 24 | 30 29 20 3e 20 38 30 27 |length($|0) > 80'|
|00002e80| 0a 58 54 68 69 73 20 70 | 72 6f 67 72 61 6d 20 70 |.XThis p|rogram p|
|00002e90| 72 69 6e 74 73 20 65 76 | 65 72 79 20 6c 69 6e 65 |rints ev|ery line|
|00002ea0| 20 6c 6f 6e 67 65 72 20 | 74 68 61 6e 20 38 30 20 | longer |than 80 |
|00002eb0| 63 68 61 72 61 63 74 65 | 72 73 2e 20 20 54 68 65 |characte|rs. The|
|00002ec0| 20 73 6f 6c 65 0a 58 72 | 75 6c 65 20 68 61 73 20 | sole.Xr|ule has |
|00002ed0| 61 20 72 65 6c 61 74 69 | 6f 6e 61 6c 20 65 78 70 |a relati|onal exp|
|00002ee0| 72 65 73 73 69 6f 6e 20 | 61 73 20 69 74 73 20 70 |ression |as its p|
|00002ef0| 61 74 74 65 72 6e 2c 20 | 61 6e 64 20 68 61 73 20 |attern, |and has |
|00002f00| 6e 6f 20 61 63 74 69 6f | 6e 20 28 73 6f 20 74 68 |no actio|n (so th|
|00002f10| 65 0a 58 64 65 66 61 75 | 6c 74 20 61 63 74 69 6f |e.Xdefau|lt actio|
|00002f20| 6e 2c 20 70 72 69 6e 74 | 69 6e 67 20 74 68 65 20 |n, print|ing the |
|00002f30| 72 65 63 6f 72 64 2c 20 | 69 73 20 75 73 65 64 29 |record, |is used)|
|00002f40| 2e 0a 58 0a 58 40 69 74 | 65 6d 20 61 77 6b 20 27 |..X.X@it|em awk '|
|00002f50| 4e 46 20 3e 20 30 27 0a | 58 54 68 69 73 20 70 72 |NF > 0'.|XThis pr|
|00002f60| 6f 67 72 61 6d 20 70 72 | 69 6e 74 73 20 65 76 65 |ogram pr|ints eve|
|00002f70| 72 79 20 6c 69 6e 65 20 | 74 68 61 74 20 68 61 73 |ry line |that has|
|00002f80| 20 61 74 20 6c 65 61 73 | 74 20 6f 6e 65 20 66 69 | at leas|t one fi|
|00002f90| 65 6c 64 2e 20 20 54 68 | 69 73 20 69 73 20 61 6e |eld. Th|is is an|
|00002fa0| 0a 58 65 61 73 79 20 77 | 61 79 20 74 6f 20 64 65 |.Xeasy w|ay to de|
|00002fb0| 6c 65 74 65 20 62 6c 61 | 6e 6b 20 6c 69 6e 65 73 |lete bla|nk lines|
|00002fc0| 20 66 72 6f 6d 20 61 20 | 66 69 6c 65 20 28 6f 72 | from a |file (or|
|00002fd0| 20 72 61 74 68 65 72 2c | 20 74 6f 20 63 72 65 61 | rather,| to crea|
|00002fe0| 74 65 20 61 20 6e 65 77 | 0a 58 66 69 6c 65 20 73 |te a new|.Xfile s|
|00002ff0| 69 6d 69 6c 61 72 20 74 | 6f 20 74 68 65 20 6f 6c |imilar t|o the ol|
|00003000| 64 20 66 69 6c 65 20 62 | 75 74 20 66 72 6f 6d 20 |d file b|ut from |
|00003010| 77 68 69 63 68 20 74 68 | 65 20 62 6c 61 6e 6b 20 |which th|e blank |
|00003020| 6c 69 6e 65 73 20 68 61 | 76 65 20 62 65 65 6e 0a |lines ha|ve been.|
|00003030| 58 64 65 6c 65 74 65 64 | 29 2e 0a 58 0a 58 40 69 |Xdeleted|)..X.X@i|
|00003040| 74 65 6d 20 61 77 6b 20 | 27 40 7b 20 69 66 20 28 |tem awk |'@{ if (|
|00003050| 4e 46 20 3e 20 30 29 20 | 70 72 69 6e 74 20 40 7d |NF > 0) |print @}|
|00003060| 27 0a 58 54 68 69 73 20 | 70 72 6f 67 72 61 6d 20 |'.XThis |program |
|00003070| 61 6c 73 6f 20 70 72 69 | 6e 74 73 20 65 76 65 72 |also pri|nts ever|
|00003080| 79 20 6c 69 6e 65 20 74 | 68 61 74 20 68 61 73 20 |y line t|hat has |
|00003090| 61 74 20 6c 65 61 73 74 | 20 6f 6e 65 20 66 69 65 |at least| one fie|
|000030a0| 6c 64 2e 20 20 48 65 72 | 65 20 77 65 0a 58 61 6c |ld. Her|e we.Xal|
|000030b0| 6c 6f 77 20 74 68 65 20 | 72 75 6c 65 20 74 6f 20 |low the |rule to |
|000030c0| 6d 61 74 63 68 20 65 76 | 65 72 79 20 6c 69 6e 65 |match ev|ery line|
|000030d0| 2c 20 74 68 65 6e 20 64 | 65 63 69 64 65 20 69 6e |, then d|ecide in|
|000030e0| 20 74 68 65 20 61 63 74 | 69 6f 6e 20 77 68 65 74 | the act|ion whet|
|000030f0| 68 65 72 0a 58 74 6f 20 | 70 72 69 6e 74 2e 0a 58 |her.Xto |print..X|
|00003100| 0a 58 40 69 74 65 6d 20 | 61 77 6b 40 20 27 42 45 |.X@item |awk@ 'BE|
|00003110| 47 49 4e 40 20 40 7b 40 | 20 66 6f 72 20 28 69 20 |GIN@ @{@| for (i |
|00003120| 3d 20 31 3b 20 69 20 3c | 3d 20 37 3b 20 69 2b 2b |= 1; i <|= 7; i++|
|00003130| 29 0a 58 40 69 74 65 6d | 78 20 40 20 40 20 40 20 |).X@item|x @ @ @ |
|00003140| 40 20 40 20 40 20 40 20 | 40 20 40 20 40 20 40 20 |@ @ @ @ |@ @ @ @ |
|00003150| 40 20 40 20 40 20 40 20 | 70 72 69 6e 74 20 69 6e |@ @ @ @ |print in|
|00003160| 74 28 31 30 31 20 2a 20 | 72 61 6e 64 28 29 29 20 |t(101 * |rand()) |
|00003170| 40 7d 27 0a 58 54 68 69 | 73 20 70 72 6f 67 72 61 |@}'.XThi|s progra|
|00003180| 6d 20 70 72 69 6e 74 73 | 20 37 20 72 61 6e 64 6f |m prints| 7 rando|
|00003190| 6d 20 6e 75 6d 62 65 72 | 73 20 66 72 6f 6d 20 30 |m number|s from 0|
|000031a0| 20 74 6f 20 31 30 30 2c | 20 69 6e 63 6c 75 73 69 | to 100,| inclusi|
|000031b0| 76 65 2e 0a 58 0a 58 40 | 69 74 65 6d 20 6c 73 20 |ve..X.X@|item ls |
|000031c0| 2d 6c 20 40 76 61 72 7b | 66 69 6c 65 73 7d 20 7c |-l @var{|files} ||
|000031d0| 20 61 77 6b 20 27 40 7b | 20 78 20 2b 3d 20 24 34 | awk '@{| x += $4|
|000031e0| 20 40 7d 20 3b 20 45 4e | 44 20 40 7b 20 70 72 69 | @} ; EN|D @{ pri|
|000031f0| 6e 74 20 22 74 6f 74 61 | 6c 20 62 79 74 65 73 3a |nt "tota|l bytes:|
|00003200| 20 22 20 78 20 40 7d 27 | 0a 58 54 68 69 73 20 70 | " x @}'|.XThis p|
|00003210| 72 6f 67 72 61 6d 20 70 | 72 69 6e 74 73 20 74 68 |rogram p|rints th|
|00003220| 65 20 74 6f 74 61 6c 20 | 6e 75 6d 62 65 72 20 6f |e total |number o|
|00003230| 66 20 62 79 74 65 73 20 | 75 73 65 64 20 62 79 20 |f bytes |used by |
|00003240| 40 76 61 72 7b 66 69 6c | 65 73 7d 2e 0a 58 0a 58 |@var{fil|es}..X.X|
|00003250| 40 69 74 65 6d 20 65 78 | 70 61 6e 64 40 20 40 76 |@item ex|pand@ @v|
|00003260| 61 72 7b 66 69 6c 65 7d | 40 20 7c 40 20 61 77 6b |ar{file}|@ |@ awk|
|00003270| 40 20 27 40 7b 20 69 66 | 20 28 78 20 3c 20 6c 65 |@ '@{ if| (x < le|
|00003280| 6e 67 74 68 28 29 29 20 | 78 20 3d 20 6c 65 6e 67 |ngth()) |x = leng|
|00003290| 74 68 28 29 20 40 7d 0a | 58 40 69 74 65 6d 78 20 |th() @}.|X@itemx |
|000032a0| 40 20 40 20 40 20 40 20 | 40 20 40 20 40 20 40 20 |@ @ @ @ |@ @ @ @ |
|000032b0| 40 20 40 20 40 20 40 20 | 40 20 40 20 40 20 40 20 |@ @ @ @ |@ @ @ @ |
|000032c0| 40 20 40 20 45 4e 44 20 | 40 7b 20 70 72 69 6e 74 |@ @ END |@{ print|
|000032d0| 20 22 6d 61 78 69 6d 75 | 6d 20 6c 69 6e 65 20 6c | "maximu|m line l|
|000032e0| 65 6e 67 74 68 20 69 73 | 20 22 20 78 20 40 7d 27 |ength is| " x @}'|
|000032f0| 0a 58 54 68 69 73 20 70 | 72 6f 67 72 61 6d 20 70 |.XThis p|rogram p|
|00003300| 72 69 6e 74 73 20 74 68 | 65 20 6d 61 78 69 6d 75 |rints th|e maximu|
|00003310| 6d 20 6c 69 6e 65 20 6c | 65 6e 67 74 68 20 6f 66 |m line l|ength of|
|00003320| 20 40 76 61 72 7b 66 69 | 6c 65 7d 2e 20 20 54 68 | @var{fi|le}. Th|
|00003330| 65 20 69 6e 70 75 74 0a | 58 69 73 20 70 69 70 65 |e input.|Xis pipe|
|00003340| 64 20 74 68 72 6f 75 67 | 68 20 74 68 65 20 40 63 |d throug|h the @c|
|00003350| 6f 64 65 7b 65 78 70 61 | 6e 64 7d 20 70 72 6f 67 |ode{expa|nd} prog|
|00003360| 72 61 6d 20 74 6f 20 63 | 68 61 6e 67 65 20 74 61 |ram to c|hange ta|
|00003370| 62 73 20 69 6e 74 6f 20 | 73 70 61 63 65 73 2c 0a |bs into |spaces,.|
|00003380| 58 73 6f 20 74 68 65 20 | 77 69 64 74 68 73 20 63 |Xso the |widths c|
|00003390| 6f 6d 70 61 72 65 64 20 | 61 72 65 20 61 63 74 75 |ompared |are actu|
|000033a0| 61 6c 6c 79 20 74 68 65 | 20 72 69 67 68 74 2d 6d |ally the| right-m|
|000033b0| 61 72 67 69 6e 20 63 6f | 6c 75 6d 6e 73 2e 0a 58 |argin co|lumns..X|
|000033c0| 40 65 6e 64 20 74 61 62 | 6c 65 0a 58 0a 58 40 6e |@end tab|le.X.X@n|
|000033d0| 6f 64 65 20 50 61 74 74 | 65 72 6e 73 2c 20 41 63 |ode Patt|erns, Ac|
|000033e0| 74 69 6f 6e 73 2c 20 4f | 6e 65 2d 6c 69 6e 65 72 |tions, O|ne-liner|
|000033f0| 73 2c 20 54 6f 70 0a 58 | 40 63 68 61 70 74 65 72 |s, Top.X|@chapter|
|00003400| 20 50 61 74 74 65 72 6e | 73 0a 58 40 63 69 6e 64 | Pattern|s.X@cind|
|00003410| 65 78 20 70 61 74 74 65 | 72 6e 2c 20 64 65 66 69 |ex patte|rn, defi|
|00003420| 6e 69 74 69 6f 6e 20 6f | 66 0a 58 0a 58 50 61 74 |nition o|f.X.XPat|
|00003430| 74 65 72 6e 73 20 69 6e | 20 40 63 6f 64 65 7b 61 |terns in| @code{a|
|00003440| 77 6b 7d 20 63 6f 6e 74 | 72 6f 6c 20 74 68 65 20 |wk} cont|rol the |
|00003450| 65 78 65 63 75 74 69 6f | 6e 20 6f 66 20 72 75 6c |executio|n of rul|
|00003460| 65 73 3a 20 61 20 72 75 | 6c 65 20 69 73 0a 58 65 |es: a ru|le is.Xe|
|00003470| 78 65 63 75 74 65 64 20 | 77 68 65 6e 20 69 74 73 |xecuted |when its|
|00003480| 20 70 61 74 74 65 72 6e | 20 6d 61 74 63 68 65 73 | pattern| matches|
|00003490| 20 74 68 65 20 63 75 72 | 72 65 6e 74 20 69 6e 70 | the cur|rent inp|
|000034a0| 75 74 20 72 65 63 6f 72 | 64 2e 20 20 54 68 69 73 |ut recor|d. This|
|000034b0| 0a 58 63 68 61 70 74 65 | 72 20 74 65 6c 6c 73 20 |.Xchapte|r tells |
|000034c0| 61 6c 6c 20 61 62 6f 75 | 74 20 68 6f 77 20 74 6f |all abou|t how to|
|000034d0| 20 77 72 69 74 65 20 70 | 61 74 74 65 72 6e 73 2e | write p|atterns.|
|000034e0| 0a 58 0a 58 40 6d 65 6e | 75 0a 58 2a 20 4b 69 6e |.X.X@men|u.X* Kin|
|000034f0| 64 73 20 6f 66 20 50 61 | 74 74 65 72 6e 73 3a 3a |ds of Pa|tterns::|
|00003500| 20 20 20 20 41 20 6c 69 | 73 74 20 6f 66 20 61 6c | A li|st of al|
|00003510| 6c 20 6b 69 6e 64 73 20 | 6f 66 20 70 61 74 74 65 |l kinds |of patte|
|00003520| 72 6e 73 2e 0a 58 20 20 | 20 20 20 20 20 20 20 20 |rns..X | |
|00003530| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 54 | | T|
|00003540| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 73 75 62 |he follo|wing sub|
|00003550| 73 65 63 74 69 6f 6e 73 | 20 64 65 73 63 72 69 62 |sections| describ|
|00003560| 65 20 74 68 65 6d 20 69 | 6e 20 64 65 74 61 69 6c |e them i|n detail|
|00003570| 2e 0a 58 0a 58 2a 20 45 | 6d 70 74 79 3a 3a 20 20 |..X.X* E|mpty:: |
|00003580| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 54 68 | | Th|
|00003590| 65 20 65 6d 70 74 79 20 | 70 61 74 74 65 72 6e 2c |e empty |pattern,|
|000035a0| 20 77 68 69 63 68 20 6d | 61 74 63 68 65 73 20 65 | which m|atches e|
|000035b0| 76 65 72 79 20 72 65 63 | 6f 72 64 2e 0a 58 0a 58 |very rec|ord..X.X|
|000035c0| 2a 20 52 65 67 65 78 70 | 3a 3a 20 20 20 20 20 20 |* Regexp|:: |
|000035d0| 20 20 20 20 20 20 20 20 | 20 52 65 67 75 6c 61 72 | | Regular|
|000035e0| 20 65 78 70 72 65 73 73 | 69 6f 6e 73 20 73 75 63 | express|ions suc|
|000035f0| 68 20 61 73 20 40 73 61 | 6d 70 7b 2f 66 6f 6f 2f |h as @sa|mp{/foo/|
|00003600| 7d 2e 0a 58 0a 58 2a 20 | 43 6f 6d 70 61 72 69 73 |}..X.X* |Comparis|
|00003610| 6f 6e 20 50 61 74 74 65 | 72 6e 73 3a 3a 20 20 43 |on Patte|rns:: C|
|00003620| 6f 6d 70 61 72 69 73 6f | 6e 20 65 78 70 72 65 73 |ompariso|n expres|
|00003630| 73 69 6f 6e 73 20 73 75 | 63 68 20 61 73 20 40 63 |sions su|ch as @c|
|00003640| 6f 64 65 7b 24 31 20 3e | 20 31 30 7d 2e 0a 58 0a |ode{$1 >| 10}..X.|
|00003650| 58 2a 20 42 6f 6f 6c 65 | 61 6e 20 50 61 74 74 65 |X* Boole|an Patte|
|00003660| 72 6e 73 3a 3a 20 20 20 | 20 20 43 6f 6d 62 69 6e |rns:: | Combin|
|00003670| 69 6e 67 20 63 6f 6d 70 | 61 72 69 73 6f 6e 20 65 |ing comp|arison e|
|00003680| 78 70 72 65 73 73 69 6f | 6e 73 2e 0a 58 0a 58 2a |xpressio|ns..X.X*|
|00003690| 20 45 78 70 72 65 73 73 | 69 6f 6e 20 50 61 74 74 | Express|ion Patt|
|000036a0| 65 72 6e 73 3a 3a 20 20 | 41 6e 79 20 65 78 70 72 |erns:: |Any expr|
|000036b0| 65 73 73 69 6f 6e 20 63 | 61 6e 20 62 65 20 75 73 |ession c|an be us|
|000036c0| 65 64 20 61 73 20 61 20 | 70 61 74 74 65 72 6e 2e |ed as a |pattern.|
|000036d0| 0a 58 0a 58 2a 20 52 61 | 6e 67 65 73 3a 3a 20 20 |.X.X* Ra|nges:: |
|000036e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 55 73 69 | | Usi|
|000036f0| 6e 67 20 70 61 69 72 73 | 20 6f 66 20 70 61 74 74 |ng pairs| of patt|
|00003700| 65 72 6e 73 20 74 6f 20 | 73 70 65 63 69 66 79 20 |erns to |specify |
|00003710| 72 65 63 6f 72 64 20 72 | 61 6e 67 65 73 2e 0a 58 |record r|anges..X|
|00003720| 0a 58 2a 20 42 45 47 49 | 4e 2f 45 4e 44 3a 3a 20 |.X* BEGI|N/END:: |
|00003730| 20 20 20 20 20 20 20 20 | 20 20 20 53 70 65 63 69 | | Speci|
|00003740| 66 79 69 6e 67 20 69 6e | 69 74 69 61 6c 69 7a 61 |fying in|itializa|
|00003750| 74 69 6f 6e 20 61 6e 64 | 20 63 6c 65 61 6e 75 70 |tion and| cleanup|
|00003760| 20 72 75 6c 65 73 2e 0a | 58 40 65 6e 64 20 6d 65 | rules..|X@end me|
|00003770| 6e 75 0a 58 0a 58 40 6e | 6f 64 65 20 4b 69 6e 64 |nu.X.X@n|ode Kind|
|00003780| 73 20 6f 66 20 50 61 74 | 74 65 72 6e 73 2c 20 45 |s of Pat|terns, E|
|00003790| 6d 70 74 79 2c 20 50 61 | 74 74 65 72 6e 73 2c 20 |mpty, Pa|tterns, |
|000037a0| 50 61 74 74 65 72 6e 73 | 0a 58 40 73 65 63 74 69 |Patterns|.X@secti|
|000037b0| 6f 6e 20 4b 69 6e 64 73 | 20 6f 66 20 50 61 74 74 |on Kinds| of Patt|
|000037c0| 65 72 6e 73 0a 58 40 63 | 69 6e 64 65 78 20 70 61 |erns.X@c|index pa|
|000037d0| 74 74 65 72 6e 73 2c 20 | 74 79 70 65 73 20 6f 66 |tterns, |types of|
|000037e0| 0a 58 0a 58 48 65 72 65 | 20 69 73 20 61 20 73 75 |.X.XHere| is a su|
|000037f0| 6d 6d 61 72 79 20 6f 66 | 20 74 68 65 20 74 79 70 |mmary of| the typ|
|00003800| 65 73 20 6f 66 20 70 61 | 74 74 65 72 6e 73 20 73 |es of pa|tterns s|
|00003810| 75 70 70 6f 72 74 65 64 | 20 69 6e 20 40 63 6f 64 |upported| in @cod|
|00003820| 65 7b 61 77 6b 7d 2e 0a | 58 0a 58 40 74 61 62 6c |e{awk}..|X.X@tabl|
|00003830| 65 20 40 63 6f 64 65 0a | 58 40 69 74 65 6d 20 2f |e @code.|X@item /|
|00003840| 40 76 61 72 7b 72 65 67 | 75 6c 61 72 20 65 78 70 |@var{reg|ular exp|
|00003850| 72 65 73 73 69 6f 6e 7d | 2f 0a 58 41 20 72 65 67 |ression}|/.XA reg|
|00003860| 75 6c 61 72 20 65 78 70 | 72 65 73 73 69 6f 6e 20 |ular exp|ression |
|00003870| 61 73 20 61 20 70 61 74 | 74 65 72 6e 2e 20 20 49 |as a pat|tern. I|
|00003880| 74 20 6d 61 74 63 68 65 | 73 20 77 68 65 6e 20 74 |t matche|s when t|
|00003890| 68 65 20 74 65 78 74 20 | 6f 66 20 74 68 65 0a 58 |he text |of the.X|
|000038a0| 69 6e 70 75 74 20 72 65 | 63 6f 72 64 20 66 69 74 |input re|cord fit|
|000038b0| 73 20 74 68 65 20 72 65 | 67 75 6c 61 72 20 65 78 |s the re|gular ex|
|000038c0| 70 72 65 73 73 69 6f 6e | 2e 20 20 28 40 78 72 65 |pression|. (@xre|
|000038d0| 66 7b 52 65 67 65 78 70 | 2c 20 2c 20 52 65 67 75 |f{Regexp|, , Regu|
|000038e0| 6c 61 72 0a 58 45 78 70 | 72 65 73 73 69 6f 6e 73 |lar.XExp|ressions|
|000038f0| 20 61 73 20 50 61 74 74 | 65 72 6e 73 7d 2e 29 0a | as Patt|erns}.).|
|00003900| 58 0a 58 40 69 74 65 6d | 20 40 76 61 72 7b 65 78 |X.X@item| @var{ex|
|00003910| 70 72 65 73 73 69 6f 6e | 7d 0a 58 41 20 73 69 6e |pression|}.XA sin|
|00003920| 67 6c 65 20 65 78 70 72 | 65 73 73 69 6f 6e 2e 20 |gle expr|ession. |
|00003930| 20 49 74 20 6d 61 74 63 | 68 65 73 20 77 68 65 6e | It matc|hes when|
|00003940| 20 69 74 73 20 76 61 6c | 75 65 2c 20 63 6f 6e 76 | its val|ue, conv|
|00003950| 65 72 74 65 64 20 74 6f | 20 61 20 6e 75 6d 62 65 |erted to| a numbe|
|00003960| 72 2c 0a 58 69 73 20 6e | 6f 6e 7a 65 72 6f 20 28 |r,.Xis n|onzero (|
|00003970| 69 66 20 61 20 6e 75 6d | 62 65 72 29 20 6f 72 20 |if a num|ber) or |
|00003980| 6e 6f 6e 6e 75 6c 6c 20 | 28 69 66 20 61 20 73 74 |nonnull |(if a st|
|00003990| 72 69 6e 67 29 2e 20 20 | 28 40 78 72 65 66 7b 45 |ring). |(@xref{E|
|000039a0| 78 70 72 65 73 73 69 6f | 6e 0a 58 50 61 74 74 65 |xpressio|n.XPatte|
|000039b0| 72 6e 73 7d 2e 29 0a 58 | 0a 58 40 69 74 65 6d 20 |rns}.).X|.X@item |
|000039c0| 40 76 61 72 7b 70 61 74 | 31 7d 2c 20 40 76 61 72 |@var{pat|1}, @var|
|000039d0| 7b 70 61 74 32 7d 0a 58 | 41 20 70 61 69 72 20 6f |{pat2}.X|A pair o|
|000039e0| 66 20 70 61 74 74 65 72 | 6e 73 20 73 65 70 61 72 |f patter|ns separ|
|000039f0| 61 74 65 64 20 62 79 20 | 61 20 63 6f 6d 6d 61 2c |ated by |a comma,|
|00003a00| 20 73 70 65 63 69 66 79 | 69 6e 67 20 61 20 72 61 | specify|ing a ra|
|00003a10| 6e 67 65 20 6f 66 20 72 | 65 63 6f 72 64 73 2e 0a |nge of r|ecords..|
|00003a20| 58 28 40 78 72 65 66 7b | 52 61 6e 67 65 73 2c 20 |X(@xref{|Ranges, |
|00003a30| 2c 20 53 70 65 63 69 66 | 79 69 6e 67 20 52 65 63 |, Specif|ying Rec|
|00003a40| 6f 72 64 20 52 61 6e 67 | 65 73 20 57 69 74 68 20 |ord Rang|es With |
|00003a50| 50 61 74 74 65 72 6e 73 | 7d 2e 29 0a 58 0a 58 40 |Patterns|}.).X.X@|
|00003a60| 69 74 65 6d 20 42 45 47 | 49 4e 0a 58 40 69 74 65 |item BEG|IN.X@ite|
|00003a70| 6d 78 20 45 4e 44 0a 58 | 53 70 65 63 69 61 6c 20 |mx END.X|Special |
|00003a80| 70 61 74 74 65 72 6e 73 | 20 74 6f 20 73 75 70 70 |patterns| to supp|
|00003a90| 6c 79 20 73 74 61 72 74 | 2d 75 70 20 6f 72 20 63 |ly start|-up or c|
|00003aa0| 6c 65 61 6e 2d 75 70 20 | 69 6e 66 6f 72 6d 61 74 |lean-up |informat|
|00003ab0| 69 6f 6e 20 74 6f 0a 58 | 40 63 6f 64 65 7b 61 77 |ion to.X|@code{aw|
|00003ac0| 6b 7d 2e 20 20 28 40 78 | 72 65 66 7b 42 45 47 49 |k}. (@x|ref{BEGI|
|00003ad0| 4e 2f 45 4e 44 7d 2e 29 | 0a 58 0a 58 40 69 74 65 |N/END}.)|.X.X@ite|
|00003ae0| 6d 20 40 76 61 72 7b 6e | 75 6c 6c 7d 0a 58 54 68 |m @var{n|ull}.XTh|
|00003af0| 65 20 65 6d 70 74 79 20 | 70 61 74 74 65 72 6e 20 |e empty |pattern |
|00003b00| 6d 61 74 63 68 65 73 20 | 65 76 65 72 79 20 69 6e |matches |every in|
|00003b10| 70 75 74 20 72 65 63 6f | 72 64 2e 20 20 28 40 78 |put reco|rd. (@x|
|00003b20| 72 65 66 7b 45 6d 70 74 | 79 2c 20 2c 20 54 68 65 |ref{Empt|y, , The|
|00003b30| 20 45 6d 70 74 79 0a 58 | 50 61 74 74 65 72 6e 7d | Empty.X|Pattern}|
|00003b40| 2e 29 0a 58 40 65 6e 64 | 20 74 61 62 6c 65 0a 58 |.).X@end| table.X|
|00003b50| 0a 58 40 6e 6f 64 65 20 | 45 6d 70 74 79 2c 20 52 |.X@node |Empty, R|
|00003b60| 65 67 65 78 70 2c 20 4b | 69 6e 64 73 20 6f 66 20 |egexp, K|inds of |
|00003b70| 50 61 74 74 65 72 6e 73 | 2c 20 50 61 74 74 65 72 |Patterns|, Patter|
|00003b80| 6e 73 0a 58 40 73 65 63 | 74 69 6f 6e 20 54 68 65 |ns.X@sec|tion The|
|00003b90| 20 45 6d 70 74 79 20 50 | 61 74 74 65 72 6e 0a 58 | Empty P|attern.X|
|00003ba0| 0a 58 40 63 69 6e 64 65 | 78 20 65 6d 70 74 79 20 |.X@cinde|x empty |
|00003bb0| 70 61 74 74 65 72 6e 0a | 58 40 63 69 6e 64 65 78 |pattern.|X@cindex|
|00003bc0| 20 70 61 74 74 65 72 6e | 2c 20 65 6d 70 74 79 0a | pattern|, empty.|
|00003bd0| 58 41 6e 20 65 6d 70 74 | 79 20 70 61 74 74 65 72 |XAn empt|y patter|
|00003be0| 6e 20 69 73 20 63 6f 6e | 73 69 64 65 72 65 64 20 |n is con|sidered |
|00003bf0| 74 6f 20 6d 61 74 63 68 | 20 40 65 6d 70 68 7b 65 |to match| @emph{e|
|00003c00| 76 65 72 79 7d 20 69 6e | 70 75 74 20 72 65 63 6f |very} in|put reco|
|00003c10| 72 64 2e 20 20 46 6f 72 | 0a 58 65 78 61 6d 70 6c |rd. For|.Xexampl|
|00003c20| 65 2c 20 74 68 65 20 70 | 72 6f 67 72 61 6d 3a 40 |e, the p|rogram:@|
|00003c30| 72 65 66 69 6c 6c 0a 58 | 0a 58 40 65 78 61 6d 70 |refill.X|.X@examp|
|00003c40| 6c 65 0a 58 61 77 6b 20 | 27 40 7b 20 70 72 69 6e |le.Xawk |'@{ prin|
|00003c50| 74 20 24 31 20 40 7d 27 | 20 42 42 53 2d 6c 69 73 |t $1 @}'| BBS-lis|
|00003c60| 74 0a 58 40 65 6e 64 20 | 65 78 61 6d 70 6c 65 0a |t.X@end |example.|
|00003c70| 58 0a 58 40 6e 6f 69 6e | 64 65 6e 74 0a 58 70 72 |X.X@noin|dent.Xpr|
|00003c80| 69 6e 74 73 20 6a 75 73 | 74 20 74 68 65 20 66 69 |ints jus|t the fi|
|00003c90| 72 73 74 20 66 69 65 6c | 64 20 6f 66 20 65 76 65 |rst fiel|d of eve|
|00003ca0| 72 79 20 72 65 63 6f 72 | 64 2e 0a 58 0a 58 40 6e |ry recor|d..X.X@n|
|00003cb0| 6f 64 65 20 52 65 67 65 | 78 70 2c 20 43 6f 6d 70 |ode Rege|xp, Comp|
|00003cc0| 61 72 69 73 6f 6e 20 50 | 61 74 74 65 72 6e 73 2c |arison P|atterns,|
|00003cd0| 20 45 6d 70 74 79 2c 20 | 50 61 74 74 65 72 6e 73 | Empty, |Patterns|
|00003ce0| 0a 58 40 73 65 63 74 69 | 6f 6e 20 52 65 67 75 6c |.X@secti|on Regul|
|00003cf0| 61 72 20 45 78 70 72 65 | 73 73 69 6f 6e 73 20 61 |ar Expre|ssions a|
|00003d00| 73 20 50 61 74 74 65 72 | 6e 73 0a 58 40 63 69 6e |s Patter|ns.X@cin|
|00003d10| 64 65 78 20 70 61 74 74 | 65 72 6e 2c 20 72 65 67 |dex patt|ern, reg|
|00003d20| 75 6c 61 72 20 65 78 70 | 72 65 73 73 69 6f 6e 73 |ular exp|ressions|
|00003d30| 0a 58 40 63 69 6e 64 65 | 78 20 72 65 67 65 78 70 |.X@cinde|x regexp|
|00003d40| 0a 58 40 63 69 6e 64 65 | 78 20 72 65 67 75 6c 61 |.X@cinde|x regula|
|00003d50| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 73 20 61 73 |r expres|sions as|
|00003d60| 20 70 61 74 74 65 72 6e | 73 0a 58 0a 58 41 20 40 | pattern|s.X.XA @|
|00003d70| 64 66 6e 7b 72 65 67 75 | 6c 61 72 20 65 78 70 72 |dfn{regu|lar expr|
|00003d80| 65 73 73 69 6f 6e 7d 2c | 20 6f 72 20 40 64 66 6e |ession},| or @dfn|
|00003d90| 7b 72 65 67 65 78 70 7d | 2c 20 69 73 20 61 20 77 |{regexp}|, is a w|
|00003da0| 61 79 20 6f 66 20 64 65 | 73 63 72 69 62 69 6e 67 |ay of de|scribing|
|00003db0| 20 61 0a 58 63 6c 61 73 | 73 20 6f 66 20 73 74 72 | a.Xclas|s of str|
|00003dc0| 69 6e 67 73 2e 20 20 41 | 20 72 65 67 75 6c 61 72 |ings. A| regular|
|00003dd0| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 65 6e 63 6c | express|ion encl|
|00003de0| 6f 73 65 64 20 69 6e 20 | 73 6c 61 73 68 65 73 20 |osed in |slashes |
|00003df0| 28 40 73 61 6d 70 7b 2f | 7d 29 0a 58 69 73 20 61 |(@samp{/|}).Xis a|
|00003e00| 6e 20 40 63 6f 64 65 7b | 61 77 6b 7d 20 70 61 74 |n @code{|awk} pat|
|00003e10| 74 65 72 6e 20 74 68 61 | 74 20 6d 61 74 63 68 65 |tern tha|t matche|
|00003e20| 73 20 65 76 65 72 79 20 | 69 6e 70 75 74 20 72 65 |s every |input re|
|00003e30| 63 6f 72 64 20 77 68 6f | 73 65 20 74 65 78 74 0a |cord who|se text.|
|00003e40| 58 62 65 6c 6f 6e 67 73 | 20 74 6f 20 74 68 61 74 |Xbelongs| to that|
|00003e50| 20 63 6c 61 73 73 2e 0a | 58 0a 58 54 68 65 20 73 | class..|X.XThe s|
|00003e60| 69 6d 70 6c 65 73 74 20 | 72 65 67 75 6c 61 72 20 |implest |regular |
|00003e70| 65 78 70 72 65 73 73 69 | 6f 6e 20 69 73 20 61 20 |expressi|on is a |
|00003e80| 73 65 71 75 65 6e 63 65 | 20 6f 66 20 6c 65 74 74 |sequence| of lett|
|00003e90| 65 72 73 2c 20 6e 75 6d | 62 65 72 73 2c 20 6f 72 |ers, num|bers, or|
|00003ea0| 0a 58 62 6f 74 68 2e 20 | 20 53 75 63 68 20 61 20 |.Xboth. | Such a |
|00003eb0| 72 65 67 65 78 70 20 6d | 61 74 63 68 65 73 20 61 |regexp m|atches a|
|00003ec0| 6e 79 20 73 74 72 69 6e | 67 20 74 68 61 74 20 63 |ny strin|g that c|
|00003ed0| 6f 6e 74 61 69 6e 73 20 | 74 68 61 74 20 73 65 71 |ontains |that seq|
|00003ee0| 75 65 6e 63 65 2e 0a 58 | 54 68 75 73 2c 20 74 68 |uence..X|Thus, th|
|00003ef0| 65 20 72 65 67 65 78 70 | 20 40 73 61 6d 70 7b 66 |e regexp| @samp{f|
|00003f00| 6f 6f 7d 20 6d 61 74 63 | 68 65 73 20 61 6e 79 20 |oo} matc|hes any |
|00003f10| 73 74 72 69 6e 67 20 63 | 6f 6e 74 61 69 6e 69 6e |string c|ontainin|
|00003f20| 67 20 40 73 61 6d 70 7b | 66 6f 6f 7d 2e 0a 58 54 |g @samp{|foo}..XT|
|00003f30| 68 65 72 65 66 6f 72 65 | 2c 20 74 68 65 20 70 61 |herefore|, the pa|
|00003f40| 74 74 65 72 6e 20 40 63 | 6f 64 65 7b 2f 66 6f 6f |ttern @c|ode{/foo|
|00003f50| 2f 7d 20 6d 61 74 63 68 | 65 73 20 61 6e 79 20 69 |/} match|es any i|
|00003f60| 6e 70 75 74 20 72 65 63 | 6f 72 64 20 63 6f 6e 74 |nput rec|ord cont|
|00003f70| 61 69 6e 69 6e 67 0a 58 | 40 73 61 6d 70 7b 66 6f |aining.X|@samp{fo|
|00003f80| 6f 7d 2e 20 20 4f 74 68 | 65 72 20 6b 69 6e 64 73 |o}. Oth|er kinds|
|00003f90| 20 6f 66 20 72 65 67 65 | 78 70 73 20 6c 65 74 20 | of rege|xps let |
|00003fa0| 79 6f 75 20 73 70 65 63 | 69 66 79 20 6d 6f 72 65 |you spec|ify more|
|00003fb0| 20 63 6f 6d 70 6c 69 63 | 61 74 65 64 0a 58 63 6c | complic|ated.Xcl|
|00003fc0| 61 73 73 65 73 20 6f 66 | 20 73 74 72 69 6e 67 73 |asses of| strings|
|00003fd0| 2e 0a 58 0a 58 40 6d 65 | 6e 75 0a 58 2a 20 55 73 |..X.X@me|nu.X* Us|
|00003fe0| 61 67 65 3a 20 52 65 67 | 65 78 70 20 55 73 61 67 |age: Reg|exp Usag|
|00003ff0| 65 2e 20 20 20 20 20 20 | 20 20 20 20 48 6f 77 20 |e. | How |
|00004000| 72 65 67 65 78 70 73 20 | 61 72 65 20 75 73 65 64 |regexps |are used|
|00004010| 20 69 6e 20 70 61 74 74 | 65 72 6e 73 2e 0a 58 2a | in patt|erns..X*|
|00004020| 20 4f 70 65 72 61 74 6f | 72 73 3a 20 52 65 67 65 | Operato|rs: Rege|
|00004030| 78 70 20 4f 70 65 72 61 | 74 6f 72 73 2e 20 20 48 |xp Opera|tors. H|
|00004040| 6f 77 20 74 6f 20 77 72 | 69 74 65 20 61 20 72 65 |ow to wr|ite a re|
|00004050| 67 65 78 70 2e 0a 58 2a | 20 43 61 73 65 2d 73 65 |gexp..X*| Case-se|
|00004060| 6e 73 69 74 69 76 69 74 | 79 3a 3a 20 20 20 20 20 |nsitivit|y:: |
|00004070| 20 20 20 20 20 20 20 48 | 6f 77 20 74 6f 20 64 6f | H|ow to do|
|00004080| 20 63 61 73 65 2d 69 6e | 73 65 6e 73 69 74 69 76 | case-in|sensitiv|
|00004090| 65 20 6d 61 74 63 68 69 | 6e 67 2e 0a 58 40 65 6e |e matchi|ng..X@en|
|000040a0| 64 20 6d 65 6e 75 0a 58 | 0a 58 40 6e 6f 64 65 20 |d menu.X|.X@node |
|000040b0| 52 65 67 65 78 70 20 55 | 73 61 67 65 2c 20 52 65 |Regexp U|sage, Re|
|000040c0| 67 65 78 70 20 4f 70 65 | 72 61 74 6f 72 73 2c 20 |gexp Ope|rators, |
|000040d0| 52 65 67 65 78 70 2c 20 | 52 65 67 65 78 70 0a 58 |Regexp, |Regexp.X|
|000040e0| 40 73 75 62 73 65 63 74 | 69 6f 6e 20 48 6f 77 20 |@subsect|ion How |
|000040f0| 74 6f 20 55 73 65 20 52 | 65 67 75 6c 61 72 20 45 |to Use R|egular E|
|00004100| 78 70 72 65 73 73 69 6f | 6e 73 0a 58 0a 58 41 20 |xpressio|ns.X.XA |
|00004110| 72 65 67 75 6c 61 72 20 | 65 78 70 72 65 73 73 69 |regular |expressi|
|00004120| 6f 6e 20 63 61 6e 20 62 | 65 20 75 73 65 64 20 61 |on can b|e used a|
|00004130| 73 20 61 20 70 61 74 74 | 65 72 6e 20 62 79 20 65 |s a patt|ern by e|
|00004140| 6e 63 6c 6f 73 69 6e 67 | 20 69 74 20 69 6e 0a 58 |nclosing| it in.X|
|00004150| 73 6c 61 73 68 65 73 2e | 20 20 54 68 65 6e 20 74 |slashes.| Then t|
|00004160| 68 65 20 72 65 67 75 6c | 61 72 20 65 78 70 72 65 |he regul|ar expre|
|00004170| 73 73 69 6f 6e 20 69 73 | 20 6d 61 74 63 68 65 64 |ssion is| matched|
|00004180| 20 61 67 61 69 6e 73 74 | 20 74 68 65 20 65 6e 74 | against| the ent|
|00004190| 69 72 65 20 74 65 78 74 | 0a 58 6f 66 20 65 61 63 |ire text|.Xof eac|
|000041a0| 68 20 72 65 63 6f 72 64 | 2e 20 20 28 4e 6f 72 6d |h record|. (Norm|
|000041b0| 61 6c 6c 79 2c 20 69 74 | 20 6f 6e 6c 79 20 6e 65 |ally, it| only ne|
|000041c0| 65 64 73 20 74 6f 20 6d | 61 74 63 68 20 73 6f 6d |eds to m|atch som|
|000041d0| 65 20 70 61 72 74 20 6f | 66 20 74 68 65 20 74 65 |e part o|f the te|
|000041e0| 78 74 0a 58 69 6e 20 6f | 72 64 65 72 20 74 6f 20 |xt.Xin o|rder to |
|000041f0| 73 75 63 63 65 65 64 2e | 29 20 20 46 6f 72 20 65 |succeed.|) For e|
|00004200| 78 61 6d 70 6c 65 2c 20 | 74 68 69 73 20 70 72 69 |xample, |this pri|
|00004210| 6e 74 73 20 74 68 65 20 | 73 65 63 6f 6e 64 20 66 |nts the |second f|
|00004220| 69 65 6c 64 20 6f 66 20 | 65 61 63 68 0a 58 72 65 |ield of |each.Xre|
|00004230| 63 6f 72 64 20 74 68 61 | 74 20 63 6f 6e 74 61 69 |cord tha|t contai|
|00004240| 6e 73 20 40 73 61 6d 70 | 7b 66 6f 6f 7d 20 61 6e |ns @samp|{foo} an|
|00004250| 79 77 68 65 72 65 3a 0a | 58 0a 58 40 65 78 61 6d |ywhere:.|X.X@exam|
|00004260| 70 6c 65 0a 58 61 77 6b | 20 27 2f 66 6f 6f 2f 20 |ple.Xawk| '/foo/ |
|00004270| 40 7b 20 70 72 69 6e 74 | 20 24 32 20 40 7d 27 20 |@{ print| $2 @}' |
|00004280| 42 42 53 2d 6c 69 73 74 | 0a 58 40 65 6e 64 20 65 |BBS-list|.X@end e|
|00004290| 78 61 6d 70 6c 65 0a 58 | 0a 58 40 63 69 6e 64 65 |xample.X|.X@cinde|
|000042a0| 78 20 72 65 67 75 6c 61 | 72 20 65 78 70 72 65 73 |x regula|r expres|
|000042b0| 73 69 6f 6e 20 6d 61 74 | 63 68 69 6e 67 20 6f 70 |sion mat|ching op|
|000042c0| 65 72 61 74 6f 72 73 0a | 58 40 63 69 6e 64 65 78 |erators.|X@cindex|
|000042d0| 20 73 74 72 69 6e 67 2d | 6d 61 74 63 68 69 6e 67 | string-|matching|
|000042e0| 20 6f 70 65 72 61 74 6f | 72 73 0a 58 40 63 69 6e | operato|rs.X@cin|
|000042f0| 64 65 78 20 6f 70 65 72 | 61 74 6f 72 73 2c 20 73 |dex oper|ators, s|
|00004300| 74 72 69 6e 67 2d 6d 61 | 74 63 68 69 6e 67 0a 58 |tring-ma|tching.X|
|00004310| 40 63 69 6e 64 65 78 20 | 6f 70 65 72 61 74 6f 72 |@cindex |operator|
|00004320| 73 2c 20 72 65 67 75 6c | 61 72 20 65 78 70 72 65 |s, regul|ar expre|
|00004330| 73 73 69 6f 6e 20 6d 61 | 74 63 68 69 6e 67 0a 58 |ssion ma|tching.X|
|00004340| 40 63 69 6e 64 65 78 20 | 72 65 67 65 78 70 20 73 |@cindex |regexp s|
|00004350| 65 61 72 63 68 20 6f 70 | 65 72 61 74 6f 72 73 0a |earch op|erators.|
|00004360| 58 52 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 |XRegular| express|
|00004370| 69 6f 6e 73 20 63 61 6e | 20 61 6c 73 6f 20 62 65 |ions can| also be|
|00004380| 20 75 73 65 64 20 69 6e | 20 63 6f 6d 70 61 72 69 | used in| compari|
|00004390| 73 6f 6e 20 65 78 70 72 | 65 73 73 69 6f 6e 73 2e |son expr|essions.|
|000043a0| 20 20 54 68 65 6e 0a 58 | 79 6f 75 20 63 61 6e 20 | Then.X|you can |
|000043b0| 73 70 65 63 69 66 79 20 | 74 68 65 20 73 74 72 69 |specify |the stri|
|000043c0| 6e 67 20 74 6f 20 6d 61 | 74 63 68 20 61 67 61 69 |ng to ma|tch agai|
|000043d0| 6e 73 74 3b 20 69 74 20 | 6e 65 65 64 20 6e 6f 74 |nst; it |need not|
|000043e0| 20 62 65 20 74 68 65 20 | 65 6e 74 69 72 65 0a 58 | be the |entire.X|
|000043f0| 63 75 72 72 65 6e 74 20 | 69 6e 70 75 74 20 72 65 |current |input re|
|00004400| 63 6f 72 64 2e 20 20 54 | 68 65 73 65 20 63 6f 6d |cord. T|hese com|
|00004410| 70 61 72 69 73 6f 6e 20 | 65 78 70 72 65 73 73 69 |parison |expressi|
|00004420| 6f 6e 73 20 63 61 6e 20 | 62 65 20 75 73 65 64 20 |ons can |be used |
|00004430| 61 73 0a 58 70 61 74 74 | 65 72 6e 73 20 6f 72 20 |as.Xpatt|erns or |
|00004440| 69 6e 20 40 63 6f 64 65 | 7b 69 66 7d 20 61 6e 64 |in @code|{if} and|
|00004450| 20 40 63 6f 64 65 7b 77 | 68 69 6c 65 7d 20 73 74 | @code{w|hile} st|
|00004460| 61 74 65 6d 65 6e 74 73 | 2e 0a 58 0a 58 40 74 61 |atements|..X.X@ta|
|00004470| 62 6c 65 20 40 63 6f 64 | 65 0a 58 40 69 74 65 6d |ble @cod|e.X@item|
|00004480| 20 40 76 61 72 7b 65 78 | 70 7d 20 7e 20 2f 40 76 | @var{ex|p} ~ /@v|
|00004490| 61 72 7b 72 65 67 65 78 | 70 7d 2f 0a 58 54 68 69 |ar{regex|p}/.XThi|
|000044a0| 73 20 69 73 20 74 72 75 | 65 20 69 66 20 74 68 65 |s is tru|e if the|
|000044b0| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 40 76 61 72 | express|ion @var|
|000044c0| 7b 65 78 70 7d 20 28 74 | 61 6b 65 6e 20 61 73 20 |{exp} (t|aken as |
|000044d0| 61 20 63 68 61 72 61 63 | 74 65 72 20 73 74 72 69 |a charac|ter stri|
|000044e0| 6e 67 29 0a 58 69 73 20 | 6d 61 74 63 68 65 64 20 |ng).Xis |matched |
|000044f0| 62 79 20 40 76 61 72 7b | 72 65 67 65 78 70 7d 2e |by @var{|regexp}.|
|00004500| 20 20 54 68 65 20 66 6f | 6c 6c 6f 77 69 6e 67 20 | The fo|llowing |
|00004510| 65 78 61 6d 70 6c 65 20 | 6d 61 74 63 68 65 73 2c |example |matches,|
|00004520| 20 6f 72 20 73 65 6c 65 | 63 74 73 2c 0a 58 61 6c | or sele|cts,.Xal|
|00004530| 6c 20 69 6e 70 75 74 20 | 72 65 63 6f 72 64 73 20 |l input |records |
|00004540| 77 69 74 68 20 74 68 65 | 20 75 70 70 65 72 2d 63 |with the| upper-c|
|00004550| 61 73 65 20 6c 65 74 74 | 65 72 20 40 73 61 6d 70 |ase lett|er @samp|
|00004560| 7b 4a 7d 20 73 6f 6d 65 | 77 68 65 72 65 20 69 6e |{J} some|where in|
|00004570| 20 74 68 65 0a 58 66 69 | 72 73 74 20 66 69 65 6c | the.Xfi|rst fiel|
|00004580| 64 3a 40 72 65 66 69 6c | 6c 0a 58 0a 58 40 65 78 |d:@refil|l.X.X@ex|
|00004590| 61 6d 70 6c 65 0a 58 61 | 77 6b 20 27 24 31 20 7e |ample.Xa|wk '$1 ~|
|000045a0| 20 2f 4a 2f 27 20 69 6e | 76 65 6e 74 6f 72 79 2d | /J/' in|ventory-|
|000045b0| 73 68 69 70 70 65 64 0a | 58 40 65 6e 64 20 65 78 |shipped.|X@end ex|
|000045c0| 61 6d 70 6c 65 0a 58 0a | 58 53 6f 20 64 6f 65 73 |ample.X.|XSo does|
|000045d0| 20 74 68 69 73 3a 0a 58 | 0a 58 40 65 78 61 6d 70 | this:.X|.X@examp|
|000045e0| 6c 65 0a 58 61 77 6b 20 | 27 40 7b 20 69 66 20 28 |le.Xawk |'@{ if (|
|000045f0| 24 31 20 7e 20 2f 4a 2f | 29 20 70 72 69 6e 74 20 |$1 ~ /J/|) print |
|00004600| 40 7d 27 20 69 6e 76 65 | 6e 74 6f 72 79 2d 73 68 |@}' inve|ntory-sh|
|00004610| 69 70 70 65 64 0a 58 40 | 65 6e 64 20 65 78 61 6d |ipped.X@|end exam|
|00004620| 70 6c 65 0a 58 0a 58 40 | 69 74 65 6d 20 40 76 61 |ple.X.X@|item @va|
|00004630| 72 7b 65 78 70 7d 20 21 | 7e 20 2f 40 76 61 72 7b |r{exp} !|~ /@var{|
|00004640| 72 65 67 65 78 70 7d 2f | 0a 58 54 68 69 73 20 69 |regexp}/|.XThis i|
|00004650| 73 20 74 72 75 65 20 69 | 66 20 74 68 65 20 65 78 |s true i|f the ex|
|00004660| 70 72 65 73 73 69 6f 6e | 20 40 76 61 72 7b 65 78 |pression| @var{ex|
|00004670| 70 7d 20 28 74 61 6b 65 | 6e 20 61 73 20 61 20 63 |p} (take|n as a c|
|00004680| 68 61 72 61 63 74 65 72 | 20 73 74 72 69 6e 67 29 |haracter| string)|
|00004690| 0a 58 69 73 20 40 65 6d | 70 68 7b 6e 6f 74 7d 20 |.Xis @em|ph{not} |
|000046a0| 6d 61 74 63 68 65 64 20 | 62 79 20 40 76 61 72 7b |matched |by @var{|
|000046b0| 72 65 67 65 78 70 7d 2e | 20 20 54 68 65 20 66 6f |regexp}.| The fo|
|000046c0| 6c 6c 6f 77 69 6e 67 20 | 65 78 61 6d 70 6c 65 20 |llowing |example |
|000046d0| 6d 61 74 63 68 65 73 2c | 0a 58 6f 72 20 73 65 6c |matches,|.Xor sel|
|000046e0| 65 63 74 73 2c 20 61 6c | 6c 20 69 6e 70 75 74 20 |ects, al|l input |
|000046f0| 72 65 63 6f 72 64 73 20 | 77 68 6f 73 65 20 66 69 |records |whose fi|
|00004700| 72 73 74 20 66 69 65 6c | 64 20 40 65 6d 70 68 7b |rst fiel|d @emph{|
|00004710| 64 6f 65 73 20 6e 6f 74 | 7d 20 63 6f 6e 74 61 69 |does not|} contai|
|00004720| 6e 0a 58 74 68 65 20 75 | 70 70 65 72 2d 63 61 73 |n.Xthe u|pper-cas|
|00004730| 65 20 6c 65 74 74 65 72 | 20 40 73 61 6d 70 7b 4a |e letter| @samp{J|
|00004740| 7d 3a 40 72 65 66 69 6c | 6c 0a 58 0a 58 40 65 78 |}:@refil|l.X.X@ex|
|00004750| 61 6d 70 6c 65 0a 58 61 | 77 6b 20 27 24 31 20 21 |ample.Xa|wk '$1 !|
|00004760| 7e 20 2f 4a 2f 27 20 69 | 6e 76 65 6e 74 6f 72 79 |~ /J/' i|nventory|
|00004770| 2d 73 68 69 70 70 65 64 | 0a 58 40 65 6e 64 20 65 |-shipped|.X@end e|
|00004780| 78 61 6d 70 6c 65 0a 58 | 40 65 6e 64 20 74 61 62 |xample.X|@end tab|
|00004790| 6c 65 0a 58 0a 58 40 63 | 69 6e 64 65 78 20 63 6f |le.X.X@c|index co|
|000047a0| 6d 70 75 74 65 64 20 72 | 65 67 75 6c 61 72 20 65 |mputed r|egular e|
|000047b0| 78 70 72 65 73 73 69 6f | 6e 73 0a 58 40 63 69 6e |xpressio|ns.X@cin|
|000047c0| 64 65 78 20 72 65 67 75 | 6c 61 72 20 65 78 70 72 |dex regu|lar expr|
|000047d0| 65 73 73 69 6f 6e 73 2c | 20 63 6f 6d 70 75 74 65 |essions,| compute|
|000047e0| 64 0a 58 40 63 69 6e 64 | 65 78 20 64 79 6e 61 6d |d.X@cind|ex dynam|
|000047f0| 69 63 20 72 65 67 75 6c | 61 72 20 65 78 70 72 65 |ic regul|ar expre|
|00004800| 73 73 69 6f 6e 73 0a 58 | 54 68 65 20 72 69 67 68 |ssions.X|The righ|
|00004810| 74 20 68 61 6e 64 20 73 | 69 64 65 20 6f 66 20 61 |t hand s|ide of a|
|00004820| 20 40 73 61 6d 70 7b 7e | 7d 20 6f 72 20 40 73 61 | @samp{~|} or @sa|
|00004830| 6d 70 7b 21 7e 7d 20 6f | 70 65 72 61 74 6f 72 20 |mp{!~} o|perator |
|00004840| 6e 65 65 64 20 6e 6f 74 | 20 62 65 20 61 0a 58 63 |need not| be a.Xc|
|00004850| 6f 6e 73 74 61 6e 74 20 | 72 65 67 65 78 70 20 28 |onstant |regexp (|
|00004860| 69 2e 65 2e 2c 20 61 20 | 73 74 72 69 6e 67 20 6f |i.e., a |string o|
|00004870| 66 20 63 68 61 72 61 63 | 74 65 72 73 20 62 65 74 |f charac|ters bet|
|00004880| 77 65 65 6e 20 73 6c 61 | 73 68 65 73 29 2e 20 20 |ween sla|shes). |
|00004890| 49 74 20 6d 61 79 0a 58 | 62 65 20 61 6e 79 20 65 |It may.X|be any e|
|000048a0| 78 70 72 65 73 73 69 6f | 6e 2e 20 20 54 68 65 20 |xpressio|n. The |
|000048b0| 65 78 70 72 65 73 73 69 | 6f 6e 20 69 73 20 65 76 |expressi|on is ev|
|000048c0| 61 6c 75 61 74 65 64 2c | 20 61 6e 64 20 63 6f 6e |aluated,| and con|
|000048d0| 76 65 72 74 65 64 20 69 | 66 0a 58 6e 65 63 65 73 |verted i|f.Xneces|
|000048e0| 73 61 72 79 20 74 6f 20 | 61 20 73 74 72 69 6e 67 |sary to |a string|
|000048f0| 3b 20 74 68 65 20 63 6f | 6e 74 65 6e 74 73 20 6f |; the co|ntents o|
|00004900| 66 20 74 68 65 20 73 74 | 72 69 6e 67 20 61 72 65 |f the st|ring are|
|00004910| 20 75 73 65 64 20 61 73 | 20 74 68 65 0a 58 72 65 | used as| the.Xre|
|00004920| 67 65 78 70 2e 20 20 41 | 20 72 65 67 65 78 70 20 |gexp. A| regexp |
|00004930| 74 68 61 74 20 69 73 20 | 63 6f 6d 70 75 74 65 64 |that is |computed|
|00004940| 20 69 6e 20 74 68 69 73 | 20 77 61 79 20 69 73 20 | in this| way is |
|00004950| 63 61 6c 6c 65 64 20 61 | 20 40 64 66 6e 7b 64 79 |called a| @dfn{dy|
|00004960| 6e 61 6d 69 63 0a 58 72 | 65 67 65 78 70 7d 2e 20 |namic.Xr|egexp}. |
|00004970| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 3a 0a 58 0a | For exa|mple:.X.|
|00004980| 58 40 65 78 61 6d 70 6c | 65 0a 58 69 64 65 6e 74 |X@exampl|e.Xident|
|00004990| 69 66 69 65 72 5f 72 65 | 67 65 78 70 20 3d 20 22 |ifier_re|gexp = "|
|000049a0| 5b 41 2d 5a 61 2d 7a 5f | 5d 5b 41 2d 5a 61 2d 7a |[A-Za-z_|][A-Za-z|
|000049b0| 5f 30 2d 39 5d 2b 22 0a | 58 24 30 20 7e 20 69 64 |_0-9]+".|X$0 ~ id|
|000049c0| 65 6e 74 69 66 69 65 72 | 5f 72 65 67 65 78 70 0a |entifier|_regexp.|
|000049d0| 58 40 65 6e 64 20 65 78 | 61 6d 70 6c 65 0a 58 0a |X@end ex|ample.X.|
|000049e0| 58 40 6e 6f 69 6e 64 65 | 6e 74 0a 58 73 65 74 73 |X@noinde|nt.Xsets|
|000049f0| 20 40 63 6f 64 65 7b 69 | 64 65 6e 74 69 66 69 65 | @code{i|dentifie|
|00004a00| 72 5f 72 65 67 65 78 70 | 7d 20 74 6f 20 61 20 72 |r_regexp|} to a r|
|00004a10| 65 67 65 78 70 20 74 68 | 61 74 20 64 65 73 63 72 |egexp th|at descr|
|00004a20| 69 62 65 73 20 40 63 6f | 64 65 7b 61 77 6b 7d 0a |ibes @co|de{awk}.|
|00004a30| 58 76 61 72 69 61 62 6c | 65 20 6e 61 6d 65 73 2c |Xvariabl|e names,|
|00004a40| 20 61 6e 64 20 74 65 73 | 74 73 20 69 66 20 74 68 | and tes|ts if th|
|00004a50| 65 20 69 6e 70 75 74 20 | 72 65 63 6f 72 64 20 6d |e input |record m|
|00004a60| 61 74 63 68 65 73 20 74 | 68 69 73 20 72 65 67 65 |atches t|his rege|
|00004a70| 78 70 2e 0a 58 0a 58 40 | 6e 6f 64 65 20 52 65 67 |xp..X.X@|node Reg|
|00004a80| 65 78 70 20 4f 70 65 72 | 61 74 6f 72 73 2c 20 43 |exp Oper|ators, C|
|00004a90| 61 73 65 2d 73 65 6e 73 | 69 74 69 76 69 74 79 2c |ase-sens|itivity,|
|00004aa0| 20 52 65 67 65 78 70 20 | 55 73 61 67 65 2c 20 52 | Regexp |Usage, R|
|00004ab0| 65 67 65 78 70 0a 58 40 | 73 75 62 73 65 63 74 69 |egexp.X@|subsecti|
|00004ac0| 6f 6e 20 52 65 67 75 6c | 61 72 20 45 78 70 72 65 |on Regul|ar Expre|
|00004ad0| 73 73 69 6f 6e 20 4f 70 | 65 72 61 74 6f 72 73 0a |ssion Op|erators.|
|00004ae0| 58 40 63 69 6e 64 65 78 | 20 6d 65 74 61 63 68 61 |X@cindex| metacha|
|00004af0| 72 61 63 74 65 72 73 0a | 58 40 63 69 6e 64 65 78 |racters.|X@cindex|
|00004b00| 20 72 65 67 75 6c 61 72 | 20 65 78 70 72 65 73 73 | regular| express|
|00004b10| 69 6f 6e 20 6d 65 74 61 | 63 68 61 72 61 63 74 65 |ion meta|characte|
|00004b20| 72 73 0a 58 0a 58 59 6f | 75 20 63 61 6e 20 63 6f |rs.X.XYo|u can co|
|00004b30| 6d 62 69 6e 65 20 72 65 | 67 75 6c 61 72 20 65 78 |mbine re|gular ex|
|00004b40| 70 72 65 73 73 69 6f 6e | 73 20 77 69 74 68 20 74 |pression|s with t|
|00004b50| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 63 68 61 |he follo|wing cha|
|00004b60| 72 61 63 74 65 72 73 2c | 0a 58 63 61 6c 6c 65 64 |racters,|.Xcalled|
|00004b70| 20 40 64 66 6e 7b 72 65 | 67 75 6c 61 72 20 65 78 | @dfn{re|gular ex|
|00004b80| 70 72 65 73 73 69 6f 6e | 20 6f 70 65 72 61 74 6f |pression| operato|
|00004b90| 72 73 7d 2c 20 6f 72 20 | 40 64 66 6e 7b 6d 65 74 |rs}, or |@dfn{met|
|00004ba0| 61 63 68 61 72 61 63 74 | 65 72 73 7d 2c 20 74 6f |acharact|ers}, to|
|00004bb0| 0a 58 69 6e 63 72 65 61 | 73 65 20 74 68 65 20 70 |.Xincrea|se the p|
|00004bc0| 6f 77 65 72 20 61 6e 64 | 20 76 65 72 73 61 74 69 |ower and| versati|
|00004bd0| 6c 69 74 79 20 6f 66 20 | 72 65 67 75 6c 61 72 20 |lity of |regular |
|00004be0| 65 78 70 72 65 73 73 69 | 6f 6e 73 2e 0a 58 0a 58 |expressi|ons..X.X|
|00004bf0| 48 65 72 65 20 69 73 20 | 61 20 74 61 62 6c 65 20 |Here is |a table |
|00004c00| 6f 66 20 6d 65 74 61 63 | 68 61 72 61 63 74 65 72 |of metac|haracter|
|00004c10| 73 2e 20 20 41 6c 6c 20 | 63 68 61 72 61 63 74 65 |s. All |characte|
|00004c20| 72 73 20 6e 6f 74 20 6c | 69 73 74 65 64 20 69 6e |rs not l|isted in|
|00004c30| 20 74 68 65 0a 58 74 61 | 62 6c 65 20 73 74 61 6e | the.Xta|ble stan|
|00004c40| 64 20 66 6f 72 20 74 68 | 65 6d 73 65 6c 76 65 73 |d for th|emselves|
|00004c50| 2e 0a 58 0a 58 40 74 61 | 62 6c 65 20 40 63 6f 64 |..X.X@ta|ble @cod|
|00004c60| 65 0a 58 40 69 74 65 6d | 20 5e 0a 58 54 68 69 73 |e.X@item| ^.XThis|
|00004c70| 20 6d 61 74 63 68 65 73 | 20 74 68 65 20 62 65 67 | matches| the beg|
|00004c80| 69 6e 6e 69 6e 67 20 6f | 66 20 74 68 65 20 73 74 |inning o|f the st|
|00004c90| 72 69 6e 67 20 6f 72 20 | 74 68 65 20 62 65 67 69 |ring or |the begi|
|00004ca0| 6e 6e 69 6e 67 20 6f 66 | 20 61 20 6c 69 6e 65 0a |nning of| a line.|
|00004cb0| 58 77 69 74 68 69 6e 20 | 74 68 65 20 73 74 72 69 |Xwithin |the stri|
|00004cc0| 6e 67 2e 20 20 46 6f 72 | 20 65 78 61 6d 70 6c 65 |ng. For| example|
|00004cd0| 3a 0a 58 0a 58 40 65 78 | 61 6d 70 6c 65 0a 58 5e |:.X.X@ex|ample.X^|
|00004ce0| 40 40 63 68 61 70 74 65 | 72 0a 58 40 65 6e 64 20 |@@chapte|r.X@end |
|00004cf0| 65 78 61 6d 70 6c 65 0a | 58 0a 58 40 6e 6f 69 6e |example.|X.X@noin|
|00004d00| 64 65 6e 74 0a 58 6d 61 | 74 63 68 65 73 20 74 68 |dent.Xma|tches th|
|00004d10| 65 20 40 73 61 6d 70 7b | 40 40 63 68 61 70 74 65 |e @samp{|@@chapte|
|00004d20| 72 7d 20 61 74 20 74 68 | 65 20 62 65 67 69 6e 6e |r} at th|e beginn|
|00004d30| 69 6e 67 20 6f 66 20 61 | 20 73 74 72 69 6e 67 2c |ing of a| string,|
|00004d40| 20 61 6e 64 20 63 61 6e | 20 62 65 20 75 73 65 64 | and can| be used|
|00004d50| 0a 58 74 6f 20 69 64 65 | 6e 74 69 66 79 20 63 68 |.Xto ide|ntify ch|
|00004d60| 61 70 74 65 72 20 62 65 | 67 69 6e 6e 69 6e 67 73 |apter be|ginnings|
|00004d70| 20 69 6e 20 54 65 78 69 | 6e 66 6f 20 73 6f 75 72 | in Texi|nfo sour|
|00004d80| 63 65 20 66 69 6c 65 73 | 2e 0a 58 0a 58 40 69 74 |ce files|..X.X@it|
|00004d90| 65 6d 20 24 0a 58 54 68 | 69 73 20 69 73 20 73 69 |em $.XTh|is is si|
|00004da0| 6d 69 6c 61 72 20 74 6f | 20 40 73 61 6d 70 7b 5e |milar to| @samp{^|
|00004db0| 7d 2c 20 62 75 74 20 69 | 74 20 6d 61 74 63 68 65 |}, but i|t matche|
|00004dc0| 73 20 6f 6e 6c 79 20 61 | 74 20 74 68 65 20 65 6e |s only a|t the en|
|00004dd0| 64 20 6f 66 20 61 20 73 | 74 72 69 6e 67 0a 58 6f |d of a s|tring.Xo|
|00004de0| 72 20 74 68 65 20 65 6e | 64 20 6f 66 20 61 20 6c |r the en|d of a l|
|00004df0| 69 6e 65 20 77 69 74 68 | 69 6e 20 74 68 65 20 73 |ine with|in the s|
|00004e00| 74 72 69 6e 67 2e 20 20 | 46 6f 72 20 65 78 61 6d |tring. |For exam|
|00004e10| 70 6c 65 3a 0a 58 0a 58 | 40 65 78 61 6d 70 6c 65 |ple:.X.X|@example|
|00004e20| 0a 58 70 24 0a 58 40 65 | 6e 64 20 65 78 61 6d 70 |.Xp$.X@e|nd examp|
|00004e30| 6c 65 0a 58 0a 58 40 6e | 6f 69 6e 64 65 6e 74 0a |le.X.X@n|oindent.|
|00004e40| 58 6d 61 74 63 68 65 73 | 20 61 20 72 65 63 6f 72 |Xmatches| a recor|
|00004e50| 64 20 74 68 61 74 20 65 | 6e 64 73 20 77 69 74 68 |d that e|nds with|
|00004e60| 20 61 20 40 73 61 6d 70 | 7b 70 7d 2e 0a 58 0a 58 | a @samp|{p}..X.X|
|00004e70| 40 69 74 65 6d 20 2e 0a | 58 54 68 69 73 20 6d 61 |@item ..|XThis ma|
|00004e80| 74 63 68 65 73 20 61 6e | 79 20 73 69 6e 67 6c 65 |tches an|y single|
|00004e90| 20 63 68 61 72 61 63 74 | 65 72 20 65 78 63 65 70 | charact|er excep|
|00004ea0| 74 20 61 20 6e 65 77 6c | 69 6e 65 2e 20 20 46 6f |t a newl|ine. Fo|
|00004eb0| 72 20 65 78 61 6d 70 6c | 65 3a 0a 58 0a 58 40 65 |r exampl|e:.X.X@e|
|00004ec0| 78 61 6d 70 6c 65 0a 58 | 2e 50 0a 58 40 65 6e 64 |xample.X|.P.X@end|
|00004ed0| 20 65 78 61 6d 70 6c 65 | 0a 58 0a 58 40 6e 6f 69 | example|.X.X@noi|
|00004ee0| 6e 64 65 6e 74 0a 58 6d | 61 74 63 68 65 73 20 61 |ndent.Xm|atches a|
|00004ef0| 6e 79 20 73 69 6e 67 6c | 65 20 63 68 61 72 61 63 |ny singl|e charac|
|00004f00| 74 65 72 20 66 6f 6c 6c | 6f 77 65 64 20 62 79 20 |ter foll|owed by |
|00004f10| 61 20 40 73 61 6d 70 7b | 50 7d 20 69 6e 20 61 20 |a @samp{|P} in a |
|00004f20| 73 74 72 69 6e 67 2e 20 | 20 55 73 69 6e 67 0a 58 |string. | Using.X|
|00004f30| 63 6f 6e 63 61 74 65 6e | 61 74 69 6f 6e 20 77 65 |concaten|ation we|
|00004f40| 20 63 61 6e 20 6d 61 6b | 65 20 72 65 67 75 6c 61 | can mak|e regula|
|00004f50| 72 20 65 78 70 72 65 73 | 73 69 6f 6e 73 20 6c 69 |r expres|sions li|
|00004f60| 6b 65 20 40 73 61 6d 70 | 7b 55 2e 41 7d 2c 20 77 |ke @samp|{U.A}, w|
|00004f70| 68 69 63 68 0a 58 6d 61 | 74 63 68 65 73 20 61 6e |hich.Xma|tches an|
|00004f80| 79 20 74 68 72 65 65 2d | 63 68 61 72 61 63 74 65 |y three-|characte|
|00004f90| 72 20 73 65 71 75 65 6e | 63 65 20 74 68 61 74 20 |r sequen|ce that |
|00004fa0| 62 65 67 69 6e 73 20 77 | 69 74 68 20 40 73 61 6d |begins w|ith @sam|
|00004fb0| 70 7b 55 7d 20 61 6e 64 | 20 65 6e 64 73 0a 58 77 |p{U} and| ends.Xw|
|00004fc0| 69 74 68 20 40 73 61 6d | 70 7b 41 7d 2e 0a 58 0a |ith @sam|p{A}..X.|
|00004fd0| 58 40 69 74 65 6d 20 5b | 40 64 6f 74 73 7b 7d 5d |X@item [|@dots{}]|
|00004fe0| 0a 58 54 68 69 73 20 69 | 73 20 63 61 6c 6c 65 64 |.XThis i|s called|
|00004ff0| 20 61 20 40 64 66 6e 7b | 63 68 61 72 61 63 74 65 | a @dfn{|characte|
|00005000| 72 20 73 65 74 7d 2e 20 | 20 49 74 20 6d 61 74 63 |r set}. | It matc|
|00005010| 68 65 73 20 61 6e 79 20 | 6f 6e 65 20 6f 66 20 74 |hes any |one of t|
|00005020| 68 65 0a 58 63 68 61 72 | 61 63 74 65 72 73 20 74 |he.Xchar|acters t|
|00005030| 68 61 74 20 61 72 65 20 | 65 6e 63 6c 6f 73 65 64 |hat are |enclosed|
|00005040| 20 69 6e 20 74 68 65 20 | 73 71 75 61 72 65 20 62 | in the |square b|
|00005050| 72 61 63 6b 65 74 73 2e | 20 20 46 6f 72 20 65 78 |rackets.| For ex|
|00005060| 61 6d 70 6c 65 3a 0a 58 | 0a 58 40 65 78 61 6d 70 |ample:.X|.X@examp|
|00005070| 6c 65 0a 58 5b 4d 56 58 | 5d 0a 58 40 65 6e 64 20 |le.X[MVX|].X@end |
|00005080| 65 78 61 6d 70 6c 65 0a | 58 0a 58 40 6e 6f 69 6e |example.|X.X@noin|
|00005090| 64 65 6e 74 0a 58 6d 61 | 74 63 68 65 73 20 61 6e |dent.Xma|tches an|
|000050a0| 79 20 6f 66 20 74 68 65 | 20 63 68 61 72 61 63 74 |y of the| charact|
|000050b0| 65 72 73 20 40 73 61 6d | 70 7b 4d 7d 2c 20 40 73 |ers @sam|p{M}, @s|
|000050c0| 61 6d 70 7b 56 7d 2c 20 | 6f 72 20 40 73 61 6d 70 |amp{V}, |or @samp|
|000050d0| 7b 58 7d 20 69 6e 20 61 | 0a 58 73 74 72 69 6e 67 |{X} in a|.Xstring|
|000050e0| 2e 40 72 65 66 69 6c 6c | 0a 58 0a 58 52 61 6e 67 |.@refill|.X.XRang|
|000050f0| 65 73 20 6f 66 20 63 68 | 61 72 61 63 74 65 72 73 |es of ch|aracters|
|00005100| 20 61 72 65 20 69 6e 64 | 69 63 61 74 65 64 20 62 | are ind|icated b|
|00005110| 79 20 75 73 69 6e 67 20 | 61 20 68 79 70 68 65 6e |y using |a hyphen|
|00005120| 20 62 65 74 77 65 65 6e | 20 74 68 65 20 62 65 67 | between| the beg|
|00005130| 69 6e 6e 69 6e 67 0a 58 | 61 6e 64 20 65 6e 64 69 |inning.X|and endi|
|00005140| 6e 67 20 63 68 61 72 61 | 63 74 65 72 73 2c 20 61 |ng chara|cters, a|
|00005150| 6e 64 20 65 6e 63 6c 6f | 73 69 6e 67 20 74 68 65 |nd enclo|sing the|
|00005160| 20 77 68 6f 6c 65 20 74 | 68 69 6e 67 20 69 6e 20 | whole t|hing in |
|00005170| 62 72 61 63 6b 65 74 73 | 2e 20 20 46 6f 72 0a 58 |brackets|. For.X|
|00005180| 65 78 61 6d 70 6c 65 3a | 40 72 65 66 69 6c 6c 0a |example:|@refill.|
|00005190| 58 0a 58 40 65 78 61 6d | 70 6c 65 0a 58 5b 30 2d |X.X@exam|ple.X[0-|
|000051a0| 39 5d 0a 58 40 65 6e 64 | 20 65 78 61 6d 70 6c 65 |9].X@end| example|
|000051b0| 0a 58 0a 58 40 6e 6f 69 | 6e 64 65 6e 74 0a 58 6d |.X.X@noi|ndent.Xm|
|000051c0| 61 74 63 68 65 73 20 61 | 6e 79 20 64 69 67 69 74 |atches a|ny digit|
|000051d0| 2e 0a 58 0a 58 54 6f 20 | 69 6e 63 6c 75 64 65 20 |..X.XTo |include |
|000051e0| 74 68 65 20 63 68 61 72 | 61 63 74 65 72 20 40 73 |the char|acter @s|
|000051f0| 61 6d 70 7b 5c 7d 2c 20 | 40 73 61 6d 70 7b 5d 7d |amp{\}, |@samp{]}|
|00005200| 2c 20 40 73 61 6d 70 7b | 2d 7d 20 6f 72 20 40 73 |, @samp{|-} or @s|
|00005210| 61 6d 70 7b 5e 7d 20 69 | 6e 20 61 0a 58 63 68 61 |amp{^} i|n a.Xcha|
|00005220| 72 61 63 74 65 72 20 73 | 65 74 2c 20 70 75 74 20 |racter s|et, put |
|00005230| 61 20 40 73 61 6d 70 7b | 5c 7d 20 69 6e 20 66 72 |a @samp{|\} in fr|
|00005240| 6f 6e 74 20 6f 66 20 69 | 74 2e 20 20 46 6f 72 20 |ont of i|t. For |
|00005250| 65 78 61 6d 70 6c 65 3a | 0a 58 0a 58 40 65 78 61 |example:|.X.X@exa|
|00005260| 6d 70 6c 65 0a 58 5b 64 | 5c 5d 5d 0a 58 40 65 6e |mple.X[d|\]].X@en|
|00005270| 64 20 65 78 61 6d 70 6c | 65 0a 58 0a 58 40 6e 6f |d exampl|e.X.X@no|
|00005280| 69 6e 64 65 6e 74 0a 58 | 6d 61 74 63 68 65 73 20 |indent.X|matches |
|00005290| 65 69 74 68 65 72 20 40 | 73 61 6d 70 7b 5d 7d 2c |either @|samp{]},|
|000052a0| 20 6f 72 20 40 73 61 6d | 70 7b 64 7d 2e 40 72 65 | or @sam|p{d}.@re|
|000052b0| 66 69 6c 6c 0a 58 0a 58 | 54 68 69 73 20 74 72 65 |fill.X.X|This tre|
|000052c0| 61 74 6d 65 6e 74 20 6f | 66 20 40 73 61 6d 70 7b |atment o|f @samp{|
|000052d0| 5c 7d 20 69 73 20 63 6f | 6d 70 61 74 69 62 6c 65 |\} is co|mpatible|
|000052e0| 20 77 69 74 68 20 6f 74 | 68 65 72 20 40 63 6f 64 | with ot|her @cod|
|000052f0| 65 7b 61 77 6b 7d 0a 58 | 69 6d 70 6c 65 6d 65 6e |e{awk}.X|implemen|
|00005300| 74 61 74 69 6f 6e 73 20 | 62 75 74 20 69 6e 63 6f |tations |but inco|
|00005310| 6d 70 61 74 69 62 6c 65 | 20 77 69 74 68 20 74 68 |mpatible| with th|
|00005320| 65 20 70 72 6f 70 6f 73 | 65 64 20 50 4f 53 49 58 |e propos|ed POSIX|
|00005330| 20 73 70 65 63 69 66 69 | 63 61 74 69 6f 6e 0a 58 | specifi|cation.X|
|00005340| 66 6f 72 20 40 63 6f 64 | 65 7b 61 77 6b 7d 2e 20 |for @cod|e{awk}. |
|00005350| 20 54 68 65 20 63 75 72 | 72 65 6e 74 20 64 72 61 | The cur|rent dra|
|00005360| 66 74 20 73 70 65 63 69 | 66 69 65 73 20 74 68 65 |ft speci|fies the|
|00005370| 20 75 73 65 20 6f 66 20 | 74 68 65 20 73 61 6d 65 | use of |the same|
|00005380| 20 73 79 6e 74 61 78 0a | 58 75 73 65 64 20 69 6e | syntax.|Xused in|
|00005390| 20 40 63 6f 64 65 7b 65 | 67 72 65 70 7d 2e 0a 58 | @code{e|grep}..X|
|000053a0| 0a 58 57 65 20 6d 61 79 | 20 63 68 61 6e 67 65 20 |.XWe may| change |
|000053b0| 40 63 6f 64 65 7b 67 61 | 77 6b 7d 20 74 6f 20 66 |@code{ga|wk} to f|
|000053c0| 69 74 20 74 68 65 20 73 | 74 61 6e 64 61 72 64 2c |it the s|tandard,|
|000053d0| 20 6f 6e 63 65 20 77 65 | 20 61 72 65 20 73 75 72 | once we| are sur|
|000053e0| 65 20 69 74 20 77 69 6c | 6c 0a 58 6e 6f 20 6c 6f |e it wil|l.Xno lo|
|000053f0| 6e 67 65 72 20 63 68 61 | 6e 67 65 2e 20 20 46 6f |nger cha|nge. Fo|
|00005400| 72 20 74 68 65 20 6d 65 | 61 6e 77 68 69 6c 65 2c |r the me|anwhile,|
|00005410| 20 74 68 65 20 40 73 61 | 6d 70 7b 2d 61 7d 20 6f | the @sa|mp{-a} o|
|00005420| 70 74 69 6f 6e 20 73 70 | 65 63 69 66 69 65 73 20 |ption sp|ecifies |
|00005430| 74 68 65 0a 58 74 72 61 | 64 69 74 69 6f 6e 61 6c |the.Xtra|ditional|
|00005440| 20 40 63 6f 64 65 7b 61 | 77 6b 7d 20 73 79 6e 74 | @code{a|wk} synt|
|00005450| 61 78 20 64 65 73 63 72 | 69 62 65 64 20 61 62 6f |ax descr|ibed abo|
|00005460| 76 65 20 28 77 68 69 63 | 68 20 69 73 20 61 6c 73 |ve (whic|h is als|
|00005470| 6f 20 74 68 65 0a 58 64 | 65 66 61 75 6c 74 29 2c |o the.Xd|efault),|
|00005480| 20 77 68 69 6c 65 20 74 | 68 65 20 40 73 61 6d 70 | while t|he @samp|
|00005490| 7b 2d 65 7d 20 6f 70 74 | 69 6f 6e 20 73 70 65 63 |{-e} opt|ion spec|
|000054a0| 69 66 69 65 73 20 40 63 | 6f 64 65 7b 65 67 72 65 |ifies @c|ode{egre|
|000054b0| 70 7d 20 73 79 6e 74 61 | 78 2e 0a 58 40 78 72 65 |p} synta|x..X@xre|
|000054c0| 66 7b 4f 70 74 69 6f 6e | 73 7d 2e 0a 58 0a 58 49 |f{Option|s}..X.XI|
|000054d0| 6e 20 40 63 6f 64 65 7b | 65 67 72 65 70 7d 20 73 |n @code{|egrep} s|
|000054e0| 79 6e 74 61 78 2c 20 62 | 61 63 6b 73 6c 61 73 68 |yntax, b|ackslash|
|000054f0| 20 69 73 20 6e 6f 74 20 | 73 79 6e 74 61 63 74 69 | is not |syntacti|
|00005500| 63 61 6c 6c 79 20 73 70 | 65 63 69 61 6c 20 77 69 |cally sp|ecial wi|
|00005510| 74 68 69 6e 0a 58 73 71 | 75 61 72 65 20 62 72 61 |thin.Xsq|uare bra|
|00005520| 63 6b 65 74 73 2e 20 20 | 54 68 69 73 20 6d 65 61 |ckets. |This mea|
|00005530| 6e 73 20 74 68 61 74 20 | 73 70 65 63 69 61 6c 20 |ns that |special |
|00005540| 74 72 69 63 6b 73 20 68 | 61 76 65 20 74 6f 20 62 |tricks h|ave to b|
|00005550| 65 20 75 73 65 64 20 74 | 6f 0a 58 72 65 70 72 65 |e used t|o.Xrepre|
|00005560| 73 65 6e 74 20 74 68 65 | 20 63 68 61 72 61 63 74 |sent the| charact|
|00005570| 65 72 73 20 40 73 61 6d | 70 7b 5d 7d 2c 20 40 73 |ers @sam|p{]}, @s|
|00005580| 61 6d 70 7b 2d 7d 20 61 | 6e 64 20 40 73 61 6d 70 |amp{-} a|nd @samp|
|00005590| 7b 5e 7d 20 61 73 20 6d | 65 6d 62 65 72 73 20 6f |{^} as m|embers o|
|000055a0| 66 20 61 0a 58 63 68 61 | 72 61 63 74 65 72 20 73 |f a.Xcha|racter s|
|000055b0| 65 74 2e 0a 58 0a 58 54 | 6f 20 6d 61 74 63 68 20 |et..X.XT|o match |
|000055c0| 40 73 61 6d 70 7b 2d 7d | 2c 20 77 72 69 74 65 20 |@samp{-}|, write |
|000055d0| 69 74 20 61 73 20 40 73 | 61 6d 70 7b 2d 2d 2d 7d |it as @s|amp{---}|
|000055e0| 2c 20 77 68 69 63 68 20 | 69 73 20 61 20 72 61 6e |, which |is a ran|
|000055f0| 67 65 20 63 6f 6e 74 61 | 69 6e 69 6e 67 0a 58 6f |ge conta|ining.Xo|
|00005600| 6e 6c 79 20 40 73 61 6d | 70 7b 2d 7d 2e 20 20 59 |nly @sam|p{-}. Y|
|00005610| 6f 75 20 6d 61 79 20 61 | 6c 73 6f 20 67 69 76 65 |ou may a|lso give|
|00005620| 20 40 73 61 6d 70 7b 2d | 7d 20 61 73 20 74 68 65 | @samp{-|} as the|
|00005630| 20 66 69 72 73 74 20 6f | 72 20 6c 61 73 74 0a 58 | first o|r last.X|
|00005640| 63 68 61 72 61 63 74 65 | 72 20 69 6e 20 74 68 65 |characte|r in the|
|00005650| 20 73 65 74 2e 20 20 54 | 6f 20 6d 61 74 63 68 20 | set. T|o match |
|00005660| 40 73 61 6d 70 7b 5e 7d | 2c 20 70 75 74 20 69 74 |@samp{^}|, put it|
|00005670| 20 61 6e 79 77 68 65 72 | 65 20 65 78 63 65 70 74 | anywher|e except|
|00005680| 20 61 73 20 74 68 65 0a | 58 66 69 72 73 74 20 63 | as the.|Xfirst c|
|00005690| 68 61 72 61 63 74 65 72 | 20 6f 66 20 61 20 73 65 |haracter| of a se|
|000056a0| 74 2e 20 20 54 6f 20 6d | 61 74 63 68 20 61 20 40 |t. To m|atch a @|
|000056b0| 73 61 6d 70 7b 5d 7d 2c | 20 6d 61 6b 65 20 69 74 |samp{]},| make it|
|000056c0| 20 74 68 65 20 66 69 72 | 73 74 0a 58 63 68 61 72 | the fir|st.Xchar|
|000056d0| 61 63 74 65 72 20 69 6e | 20 74 68 65 20 73 65 74 |acter in| the set|
|000056e0| 2e 20 20 46 6f 72 20 65 | 78 61 6d 70 6c 65 3a 0a |. For e|xample:.|
|000056f0| 58 0a 58 40 65 78 61 6d | 70 6c 65 0a 58 5b 5d 64 |X.X@exam|ple.X[]d|
|00005700| 5e 5d 0a 58 40 65 6e 64 | 20 65 78 61 6d 70 6c 65 |^].X@end| example|
|00005710| 0a 58 0a 58 40 6e 6f 69 | 6e 64 65 6e 74 0a 58 6d |.X.X@noi|ndent.Xm|
|00005720| 61 74 63 68 65 73 20 65 | 69 74 68 65 72 20 40 73 |atches e|ither @s|
|00005730| 61 6d 70 7b 5d 7d 2c 20 | 40 73 61 6d 70 7b 64 7d |amp{]}, |@samp{d}|
|00005740| 20 6f 72 20 40 73 61 6d | 70 7b 5e 7d 2e 40 72 65 | or @sam|p{^}.@re|
|00005750| 66 69 6c 6c 0a 58 0a 58 | 40 69 74 65 6d 20 5b 5e |fill.X.X|@item [^|
|00005760| 20 40 64 6f 74 73 7b 7d | 5d 0a 58 54 68 69 73 20 | @dots{}|].XThis |
|00005770| 69 73 20 61 20 40 64 66 | 6e 7b 63 6f 6d 70 6c 65 |is a @df|n{comple|
|00005780| 6d 65 6e 74 65 64 20 63 | 68 61 72 61 63 74 65 72 |mented c|haracter|
|00005790| 20 73 65 74 7d 2e 20 20 | 54 68 65 20 66 69 72 73 | set}. |The firs|
|000057a0| 74 20 63 68 61 72 61 63 | 74 65 72 20 61 66 74 65 |t charac|ter afte|
|000057b0| 72 0a 58 74 68 65 20 40 | 73 61 6d 70 7b 5b 7d 20 |r.Xthe @|samp{[} |
|000057c0| 40 65 6d 70 68 7b 6d 75 | 73 74 7d 20 62 65 20 61 |@emph{mu|st} be a|
|000057d0| 20 40 73 61 6d 70 7b 5e | 7d 2e 20 20 49 74 20 6d | @samp{^|}. It m|
|000057e0| 61 74 63 68 65 73 20 61 | 6e 79 20 63 68 61 72 61 |atches a|ny chara|
|000057f0| 63 74 65 72 73 0a 58 40 | 65 6d 70 68 7b 65 78 63 |cters.X@|emph{exc|
|00005800| 65 70 74 7d 20 74 68 6f | 73 65 20 69 6e 20 74 68 |ept} tho|se in th|
|00005810| 65 20 73 71 75 61 72 65 | 20 62 72 61 63 6b 65 74 |e square| bracket|
|00005820| 73 2e 20 20 46 6f 72 20 | 65 78 61 6d 70 6c 65 3a |s. For |example:|
|00005830| 0a 58 0a 58 40 65 78 61 | 6d 70 6c 65 0a 58 5b 5e |.X.X@exa|mple.X[^|
|00005840| 30 2d 39 5d 0a 58 40 65 | 6e 64 20 65 78 61 6d 70 |0-9].X@e|nd examp|
|00005850| 6c 65 0a 58 0a 58 40 6e | 6f 69 6e 64 65 6e 74 0a |le.X.X@n|oindent.|
|00005860| 58 6d 61 74 63 68 65 73 | 20 61 6e 79 20 63 68 61 |Xmatches| any cha|
|00005870| 72 61 63 74 65 72 20 74 | 68 61 74 20 69 73 20 6e |racter t|hat is n|
|00005880| 6f 74 20 61 20 64 69 67 | 69 74 2e 0a 58 0a 58 40 |ot a dig|it..X.X@|
|00005890| 69 74 65 6d 20 7c 0a 58 | 54 68 69 73 20 69 73 20 |item |.X|This is |
|000058a0| 74 68 65 20 40 64 66 6e | 7b 61 6c 74 65 72 6e 61 |the @dfn|{alterna|
|000058b0| 74 69 6f 6e 20 6f 70 65 | 72 61 74 6f 72 7d 20 61 |tion ope|rator} a|
|000058c0| 6e 64 20 69 74 20 69 73 | 20 75 73 65 64 20 74 6f |nd it is| used to|
|000058d0| 20 73 70 65 63 69 66 79 | 0a 58 61 6c 74 65 72 6e | specify|.Xaltern|
|000058e0| 61 74 69 76 65 73 2e 20 | 20 46 6f 72 20 65 78 61 |atives. | For exa|
|000058f0| 6d 70 6c 65 3a 0a 58 0a | 58 40 65 78 61 6d 70 6c |mple:.X.|X@exampl|
|00005900| 65 0a 58 5e 50 7c 5b 30 | 2d 39 5d 0a 58 40 65 6e |e.X^P|[0|-9].X@en|
|00005910| 64 20 65 78 61 6d 70 6c | 65 0a 58 0a 58 40 6e 6f |d exampl|e.X.X@no|
|00005920| 69 6e 64 65 6e 74 0a 58 | 6d 61 74 63 68 65 73 20 |indent.X|matches |
|00005930| 61 6e 79 20 73 74 72 69 | 6e 67 20 74 68 61 74 20 |any stri|ng that |
|00005940| 6d 61 74 63 68 65 73 20 | 65 69 74 68 65 72 20 40 |matches |either @|
|00005950| 73 61 6d 70 7b 5e 50 7d | 20 6f 72 20 40 73 61 6d |samp{^P}| or @sam|
|00005960| 70 7b 5b 30 2d 39 5d 7d | 2e 20 20 54 68 69 73 0a |p{[0-9]}|. This.|
|00005970| 58 6d 65 61 6e 73 20 69 | 74 20 6d 61 74 63 68 65 |Xmeans i|t matche|
|00005980| 73 20 61 6e 79 20 73 74 | 72 69 6e 67 20 74 68 61 |s any st|ring tha|
|00005990| 74 20 63 6f 6e 74 61 69 | 6e 73 20 61 20 64 69 67 |t contai|ns a dig|
|000059a0| 69 74 20 6f 72 20 73 74 | 61 72 74 73 20 77 69 74 |it or st|arts wit|
|000059b0| 68 20 40 73 61 6d 70 7b | 50 7d 2e 0a 58 0a 58 54 |h @samp{|P}..X.XT|
|000059c0| 68 65 20 61 6c 74 65 72 | 6e 61 74 69 6f 6e 20 61 |he alter|nation a|
|000059d0| 70 70 6c 69 65 73 20 74 | 6f 20 74 68 65 20 6c 61 |pplies t|o the la|
|000059e0| 72 67 65 73 74 20 70 6f | 73 73 69 62 6c 65 20 72 |rgest po|ssible r|
|000059f0| 65 67 65 78 70 73 20 6f | 6e 20 65 69 74 68 65 72 |egexps o|n either|
|00005a00| 20 73 69 64 65 2e 0a 58 | 40 69 74 65 6d 20 28 40 | side..X|@item (@|
|00005a10| 64 6f 74 73 7b 7d 29 0a | 58 50 61 72 65 6e 74 68 |dots{}).|XParenth|
|00005a20| 65 73 65 73 20 61 72 65 | 20 75 73 65 64 20 66 6f |eses are| used fo|
|00005a30| 72 20 67 72 6f 75 70 69 | 6e 67 20 69 6e 20 72 65 |r groupi|ng in re|
|00005a40| 67 75 6c 61 72 20 65 78 | 70 72 65 73 73 69 6f 6e |gular ex|pression|
|00005a50| 73 20 61 73 20 69 6e 0a | 58 61 72 69 74 68 6d 65 |s as in.|Xarithme|
|00005a60| 74 69 63 2e 20 20 54 68 | 65 79 20 63 61 6e 20 62 |tic. Th|ey can b|
|00005a70| 65 20 75 73 65 64 20 74 | 6f 20 63 6f 6e 63 61 74 |e used t|o concat|
|00005a80| 65 6e 61 74 65 20 72 65 | 67 75 6c 61 72 20 65 78 |enate re|gular ex|
|00005a90| 70 72 65 73 73 69 6f 6e | 73 0a 58 63 6f 6e 74 61 |pression|s.Xconta|
|00005aa0| 69 6e 69 6e 67 20 74 68 | 65 20 61 6c 74 65 72 6e |ining th|e altern|
|00005ab0| 61 74 69 6f 6e 20 6f 70 | 65 72 61 74 6f 72 2c 20 |ation op|erator, |
|00005ac0| 40 73 61 6d 70 7b 7c 7d | 2e 0a 58 0a 58 40 69 74 |@samp{|}|..X.X@it|
|00005ad0| 65 6d 20 2a 0a 58 54 68 | 69 73 20 73 79 6d 62 6f |em *.XTh|is symbo|
|00005ae0| 6c 20 6d 65 61 6e 73 20 | 74 68 61 74 20 74 68 65 |l means |that the|
|00005af0| 20 70 72 65 63 65 64 69 | 6e 67 20 72 65 67 75 6c | precedi|ng regul|
|00005b00| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 20 69 73 |ar expre|ssion is|
|00005b10| 20 74 6f 20 62 65 0a 58 | 72 65 70 65 61 74 65 64 | to be.X|repeated|
|00005b20| 20 61 73 20 6d 61 6e 79 | 20 74 69 6d 65 73 20 61 | as many| times a|
|00005b30| 73 20 70 6f 73 73 69 62 | 6c 65 20 74 6f 20 66 69 |s possib|le to fi|
|00005b40| 6e 64 20 61 20 6d 61 74 | 63 68 2e 20 20 46 6f 72 |nd a mat|ch. For|
|00005b50| 20 65 78 61 6d 70 6c 65 | 3a 0a 58 0a 58 40 65 78 | example|:.X.X@ex|
|00005b60| 61 6d 70 6c 65 0a 58 70 | 68 2a 0a 58 40 65 6e 64 |ample.Xp|h*.X@end|
|00005b70| 20 65 78 61 6d 70 6c 65 | 0a 58 0a 58 40 6e 6f 69 | example|.X.X@noi|
|00005b80| 6e 64 65 6e 74 0a 58 61 | 70 70 6c 69 65 73 20 74 |ndent.Xa|pplies t|
|00005b90| 68 65 20 40 73 61 6d 70 | 7b 2a 7d 20 73 79 6d 62 |he @samp|{*} symb|
|00005ba0| 6f 6c 20 74 6f 20 74 68 | 65 20 70 72 65 63 65 64 |ol to th|e preced|
|00005bb0| 69 6e 67 20 40 73 61 6d | 70 7b 68 7d 20 61 6e 64 |ing @sam|p{h} and|
|00005bc0| 20 6c 6f 6f 6b 73 20 66 | 6f 72 20 6d 61 74 63 68 | looks f|or match|
|00005bd0| 65 73 0a 58 74 6f 20 6f | 6e 65 20 40 73 61 6d 70 |es.Xto o|ne @samp|
|00005be0| 7b 70 7d 20 66 6f 6c 6c | 6f 77 65 64 20 62 79 20 |{p} foll|owed by |
|00005bf0| 61 6e 79 20 6e 75 6d 62 | 65 72 20 6f 66 20 40 73 |any numb|er of @s|
|00005c00| 61 6d 70 7b 68 7d 73 2e | 20 20 54 68 69 73 20 77 |amp{h}s.| This w|
|00005c10| 69 6c 6c 20 61 6c 73 6f | 20 6d 61 74 63 68 0a 58 |ill also| match.X|
|00005c20| 6a 75 73 74 20 40 73 61 | 6d 70 7b 70 7d 20 69 66 |just @sa|mp{p} if|
|00005c30| 20 6e 6f 20 40 73 61 6d | 70 7b 68 7d 73 20 61 72 | no @sam|p{h}s ar|
|00005c40| 65 20 70 72 65 73 65 6e | 74 2e 0a 58 0a 58 54 68 |e presen|t..X.XTh|
|00005c50| 65 20 40 73 61 6d 70 7b | 2a 7d 20 72 65 70 65 61 |e @samp{|*} repea|
|00005c60| 74 73 20 74 68 65 20 40 | 65 6d 70 68 7b 73 6d 61 |ts the @|emph{sma|
|00005c70| 6c 6c 65 73 74 7d 20 70 | 6f 73 73 69 62 6c 65 20 |llest} p|ossible |
|00005c80| 70 72 65 63 65 64 69 6e | 67 20 65 78 70 72 65 73 |precedin|g expres|
|00005c90| 73 69 6f 6e 2e 0a 58 28 | 55 73 65 20 70 61 72 65 |sion..X(|Use pare|
|00005ca0| 6e 74 68 65 73 65 73 20 | 69 66 20 79 6f 75 20 77 |ntheses |if you w|
|00005cb0| 69 73 68 20 74 6f 20 72 | 65 70 65 61 74 20 61 20 |ish to r|epeat a |
|00005cc0| 6c 61 72 67 65 72 20 65 | 78 70 72 65 73 73 69 6f |larger e|xpressio|
|00005cd0| 6e 2e 29 20 20 49 74 20 | 66 69 6e 64 73 0a 58 61 |n.) It |finds.Xa|
|00005ce0| 73 20 6d 61 6e 79 20 72 | 65 70 65 74 69 74 69 6f |s many r|epetitio|
|00005cf0| 6e 73 20 61 73 20 70 6f | 73 73 69 62 6c 65 2e 20 |ns as po|ssible. |
|00005d00| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 3a 0a 58 0a | For exa|mple:.X.|
|00005d10| 58 40 65 78 61 6d 70 6c | 65 0a 58 61 77 6b 20 27 |X@exampl|e.Xawk '|
|00005d20| 2f 5c 28 63 5b 61 64 5d | 5b 61 64 5d 2a 72 20 78 |/\(c[ad]|[ad]*r x|
|00005d30| 5c 29 2f 20 40 7b 20 70 | 72 69 6e 74 20 40 7d 27 |\)/ @{ p|rint @}'|
|00005d40| 20 73 61 6d 70 6c 65 0a | 58 40 65 6e 64 20 65 78 | sample.|X@end ex|
|00005d50| 61 6d 70 6c 65 0a 58 0a | 58 40 6e 6f 69 6e 64 65 |ample.X.|X@noinde|
|00005d60| 6e 74 0a 58 70 72 69 6e | 74 73 20 65 76 65 72 79 |nt.Xprin|ts every|
|00005d70| 20 72 65 63 6f 72 64 20 | 69 6e 20 74 68 65 20 69 | record |in the i|
|00005d80| 6e 70 75 74 20 63 6f 6e | 74 61 69 6e 69 6e 67 20 |nput con|taining |
|00005d90| 61 20 73 74 72 69 6e 67 | 20 6f 66 20 74 68 65 20 |a string| of the |
|00005da0| 66 6f 72 6d 0a 58 40 73 | 61 6d 70 7b 28 63 61 72 |form.X@s|amp{(car|
|00005db0| 20 78 29 7d 2c 20 40 73 | 61 6d 70 7b 28 63 64 72 | x)}, @s|amp{(cdr|
|00005dc0| 20 78 29 7d 2c 20 40 73 | 61 6d 70 7b 28 63 61 64 | x)}, @s|amp{(cad|
|00005dd0| 72 20 78 29 7d 2c 20 61 | 6e 64 20 73 6f 20 6f 6e |r x)}, a|nd so on|
|00005de0| 2e 40 72 65 66 69 6c 6c | 0a 58 0a 58 40 69 74 65 |.@refill|.X.X@ite|
|00005df0| 6d 20 2b 0a 58 54 68 69 | 73 20 73 79 6d 62 6f 6c |m +.XThi|s symbol|
|00005e00| 20 69 73 20 73 69 6d 69 | 6c 61 72 20 74 6f 20 40 | is simi|lar to @|
|00005e10| 73 61 6d 70 7b 2a 7d 2c | 20 62 75 74 20 74 68 65 |samp{*},| but the|
|00005e20| 20 70 72 65 63 65 64 69 | 6e 67 20 65 78 70 72 65 | precedi|ng expre|
|00005e30| 73 73 69 6f 6e 20 6d 75 | 73 74 20 62 65 0a 58 6d |ssion mu|st be.Xm|
|00005e40| 61 74 63 68 65 64 20 61 | 74 20 6c 65 61 73 74 20 |atched a|t least |
|00005e50| 6f 6e 63 65 2e 20 20 54 | 68 69 73 20 6d 65 61 6e |once. T|his mean|
|00005e60| 73 20 74 68 61 74 3a 0a | 58 0a 58 40 65 78 61 6d |s that:.|X.X@exam|
|00005e70| 70 6c 65 0a 58 77 68 2b | 79 0a 58 40 65 6e 64 20 |ple.Xwh+|y.X@end |
|00005e80| 65 78 61 6d 70 6c 65 0a | 58 0a 58 40 6e 6f 69 6e |example.|X.X@noin|
|00005e90| 64 65 6e 74 0a 58 77 6f | 75 6c 64 20 6d 61 74 63 |dent.Xwo|uld matc|
|00005ea0| 68 20 40 73 61 6d 70 7b | 77 68 79 7d 20 61 6e 64 |h @samp{|why} and|
|00005eb0| 20 40 73 61 6d 70 7b 77 | 68 68 79 7d 20 62 75 74 | @samp{w|hhy} but|
|00005ec0| 20 6e 6f 74 20 40 73 61 | 6d 70 7b 77 79 7d 2c 20 | not @sa|mp{wy}, |
|00005ed0| 77 68 65 72 65 61 73 0a | 58 40 73 61 6d 70 7b 77 |whereas.|X@samp{w|
|00005ee0| 68 2a 79 7d 20 77 6f 75 | 6c 64 20 6d 61 74 63 68 |h*y} wou|ld match|
|00005ef0| 20 61 6c 6c 20 74 68 72 | 65 65 20 6f 66 20 74 68 | all thr|ee of th|
|00005f00| 65 73 65 20 73 74 72 69 | 6e 67 73 2e 20 20 54 68 |ese stri|ngs. Th|
|00005f10| 69 73 20 69 73 20 61 20 | 73 69 6d 70 6c 65 72 0a |is is a |simpler.|
|00005f20| 58 77 61 79 20 6f 66 20 | 77 72 69 74 69 6e 67 20 |Xway of |writing |
|00005f30| 74 68 65 20 6c 61 73 74 | 20 40 73 61 6d 70 7b 2a |the last| @samp{*|
|00005f40| 7d 20 65 78 61 6d 70 6c | 65 3a 0a 58 0a 58 40 65 |} exampl|e:.X.X@e|
|00005f50| 78 61 6d 70 6c 65 0a 58 | 61 77 6b 20 27 2f 5c 28 |xample.X|awk '/\(|
|00005f60| 63 5b 61 64 5d 2b 72 20 | 78 5c 29 2f 20 40 7b 20 |c[ad]+r |x\)/ @{ |
|00005f70| 70 72 69 6e 74 20 40 7d | 27 20 73 61 6d 70 6c 65 |print @}|' sample|
|00005f80| 0a 58 40 65 6e 64 20 65 | 78 61 6d 70 6c 65 0a 58 |.X@end e|xample.X|
|00005f90| 0a 58 40 69 74 65 6d 20 | 3f 0a 58 54 68 69 73 20 |.X@item |?.XThis |
|00005fa0| 73 79 6d 62 6f 6c 20 69 | 73 20 73 69 6d 69 6c 61 |symbol i|s simila|
|00005fb0| 72 20 74 6f 20 40 73 61 | 6d 70 7b 2a 7d 2c 20 62 |r to @sa|mp{*}, b|
|00005fc0| 75 74 20 74 68 65 20 70 | 72 65 63 65 64 69 6e 67 |ut the p|receding|
|00005fd0| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 63 61 6e 20 | express|ion can |
|00005fe0| 62 65 0a 58 6d 61 74 63 | 68 65 64 20 6f 6e 63 65 |be.Xmatc|hed once|
|00005ff0| 20 6f 72 20 6e 6f 74 20 | 61 74 20 61 6c 6c 2e 20 | or not |at all. |
|00006000| 20 46 6f 72 20 65 78 61 | 6d 70 6c 65 3a 0a 58 0a | For exa|mple:.X.|
|00006010| 58 40 65 78 61 6d 70 6c | 65 0a 58 66 65 3f 64 0a |X@exampl|e.Xfe?d.|
|00006020| 58 40 65 6e 64 20 65 78 | 61 6d 70 6c 65 0a 58 0a |X@end ex|ample.X.|
|00006030| 58 40 6e 6f 69 6e 64 65 | 6e 74 0a 58 77 69 6c 6c |X@noinde|nt.Xwill|
|00006040| 20 6d 61 74 63 68 20 40 | 73 61 6d 70 7b 66 65 64 | match @|samp{fed|
|00006050| 7d 20 6f 72 20 40 73 61 | 6d 70 7b 66 64 7d 2c 20 |} or @sa|mp{fd}, |
|00006060| 62 75 74 20 6e 6f 74 68 | 69 6e 67 20 65 6c 73 65 |but noth|ing else|
|00006070| 2e 40 72 65 66 69 6c 6c | 0a 58 0a 58 40 69 74 65 |.@refill|.X.X@ite|
|00006080| 6d 20 5c 0a 58 54 68 69 | 73 20 69 73 20 75 73 65 |m \.XThi|s is use|
|00006090| 64 20 74 6f 20 73 75 70 | 70 72 65 73 73 20 74 68 |d to sup|press th|
|000060a0| 65 20 73 70 65 63 69 61 | 6c 20 6d 65 61 6e 69 6e |e specia|l meanin|
|000060b0| 67 20 6f 66 20 61 20 63 | 68 61 72 61 63 74 65 72 |g of a c|haracter|
|000060c0| 20 77 68 65 6e 0a 58 6d | 61 74 63 68 69 6e 67 2e | when.Xm|atching.|
|000060d0| 20 20 46 6f 72 20 65 78 | 61 6d 70 6c 65 3a 0a 58 | For ex|ample:.X|
|000060e0| 0a 58 40 65 78 61 6d 70 | 6c 65 0a 58 5c 24 0a 58 |.X@examp|le.X\$.X|
|000060f0| 40 65 6e 64 20 65 78 61 | 6d 70 6c 65 0a 58 0a 58 |@end exa|mple.X.X|
|00006100| 40 6e 6f 69 6e 64 65 6e | 74 0a 58 6d 61 74 63 68 |@noinden|t.Xmatch|
|00006110| 65 73 20 74 68 65 20 63 | 68 61 72 61 63 74 65 72 |es the c|haracter|
|00006120| 20 40 73 61 6d 70 7b 24 | 7d 2e 0a 58 0a 58 54 68 | @samp{$|}..X.XTh|
|00006130| 65 20 65 73 63 61 70 65 | 20 73 65 71 75 65 6e 63 |e escape| sequenc|
|00006140| 65 73 20 75 73 65 64 20 | 66 6f 72 20 73 74 72 69 |es used |for stri|
|00006150| 6e 67 20 63 6f 6e 73 74 | 61 6e 74 73 20 28 40 70 |ng const|ants (@p|
|00006160| 78 72 65 66 7b 43 6f 6e | 73 74 61 6e 74 73 7d 29 |xref{Con|stants})|
|00006170| 20 61 72 65 0a 58 76 61 | 6c 69 64 20 69 6e 20 72 | are.Xva|lid in r|
|00006180| 65 67 75 6c 61 72 20 65 | 78 70 72 65 73 73 69 6f |egular e|xpressio|
|00006190| 6e 73 20 61 73 20 77 65 | 6c 6c 3b 20 74 68 65 79 |ns as we|ll; they|
|000061a0| 20 61 72 65 20 61 6c 73 | 6f 20 69 6e 74 72 6f 64 | are als|o introd|
|000061b0| 75 63 65 64 20 62 79 20 | 61 0a 58 40 73 61 6d 70 |uced by |a.X@samp|
|000061c0| 7b 5c 7d 2e 0a 58 40 65 | 6e 64 20 74 61 62 6c 65 |{\}..X@e|nd table|
|000061d0| 0a 58 0a 58 49 6e 20 72 | 65 67 75 6c 61 72 20 65 |.X.XIn r|egular e|
|000061e0| 78 70 72 65 73 73 69 6f | 6e 73 2c 20 74 68 65 20 |xpressio|ns, the |
|000061f0| 40 73 61 6d 70 7b 2a 7d | 2c 20 40 73 61 6d 70 7b |@samp{*}|, @samp{|
|00006200| 2b 7d 2c 20 61 6e 64 20 | 40 73 61 6d 70 7b 3f 7d |+}, and |@samp{?}|
|00006210| 20 6f 70 65 72 61 74 6f | 72 73 20 68 61 76 65 0a | operato|rs have.|
|00006220| 58 74 68 65 20 68 69 67 | 68 65 73 74 20 70 72 65 |Xthe hig|hest pre|
|00006230| 63 65 64 65 6e 63 65 2c | 20 66 6f 6c 6c 6f 77 65 |cedence,| followe|
|00006240| 64 20 62 79 20 63 6f 6e | 63 61 74 65 6e 61 74 69 |d by con|catenati|
|00006250| 6f 6e 2c 20 61 6e 64 20 | 66 69 6e 61 6c 6c 79 20 |on, and |finally |
|00006260| 62 79 20 40 73 61 6d 70 | 7b 7c 7d 2e 0a 58 41 73 |by @samp|{|}..XAs|
|00006270| 20 69 6e 20 61 72 69 74 | 68 6d 65 74 69 63 2c 20 | in arit|hmetic, |
|00006280| 70 61 72 65 6e 74 68 65 | 73 65 73 20 63 61 6e 20 |parenthe|ses can |
|00006290| 63 68 61 6e 67 65 20 68 | 6f 77 20 6f 70 65 72 61 |change h|ow opera|
|000062a0| 74 6f 72 73 20 61 72 65 | 20 67 72 6f 75 70 65 64 |tors are| grouped|
|000062b0| 2e 40 72 65 66 69 6c 6c | 0a 58 0a 58 40 6e 6f 64 |.@refill|.X.X@nod|
|000062c0| 65 20 43 61 73 65 2d 73 | 65 6e 73 69 74 69 76 69 |e Case-s|ensitivi|
|000062d0| 74 79 2c 2c 20 52 65 67 | 65 78 70 20 4f 70 65 72 |ty,, Reg|exp Oper|
|000062e0| 61 74 6f 72 73 2c 20 52 | 65 67 65 78 70 0a 58 40 |ators, R|egexp.X@|
|000062f0| 73 75 62 73 65 63 74 69 | 6f 6e 20 43 61 73 65 2d |subsecti|on Case-|
|00006300| 73 65 6e 73 69 74 69 76 | 69 74 79 20 69 6e 20 4d |sensitiv|ity in M|
|00006310| 61 74 63 68 69 6e 67 0a | 58 0a 58 43 61 73 65 20 |atching.|X.XCase |
|00006320| 69 73 20 6e 6f 72 6d 61 | 6c 6c 79 20 73 69 67 6e |is norma|lly sign|
|00006330| 69 66 69 63 61 6e 74 20 | 69 6e 20 72 65 67 75 6c |ificant |in regul|
|00006340| 61 72 20 65 78 70 72 65 | 73 73 69 6f 6e 73 2c 20 |ar expre|ssions, |
|00006350| 62 6f 74 68 20 77 68 65 | 6e 20 6d 61 74 63 68 69 |both whe|n matchi|
|00006360| 6e 67 0a 58 6f 72 64 69 | 6e 61 72 79 20 63 68 61 |ng.Xordi|nary cha|
|00006370| 72 61 63 74 65 72 73 20 | 28 69 2e 65 2e 2c 20 6e |racters |(i.e., n|
|00006380| 6f 74 20 6d 65 74 61 63 | 68 61 72 61 63 74 65 72 |ot metac|haracter|
|00006390| 73 29 2c 20 61 6e 64 20 | 69 6e 73 69 64 65 20 63 |s), and |inside c|
|000063a0| 68 61 72 61 63 74 65 72 | 0a 58 73 65 74 73 2e 20 |haracter|.Xsets. |
|000063b0| 20 54 68 75 73 20 61 20 | 40 73 61 6d 70 7b 77 7d | Thus a |@samp{w}|
|000063c0| 20 69 6e 20 61 20 72 65 | 67 75 6c 61 72 20 65 78 | in a re|gular ex|
|000063d0| 70 72 65 73 73 69 6f 6e | 20 6d 61 74 63 68 65 73 |pression| matches|
|000063e0| 20 6f 6e 6c 79 20 61 20 | 6c 6f 77 65 72 20 63 61 | only a |lower ca|
|000063f0| 73 65 0a 58 40 73 61 6d | 70 7b 77 7d 20 61 6e 64 |se.X@sam|p{w} and|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.