📄 awk.9
字号:
2658(declared.)S3135(Only)S3413(char's)S3746(and)S3956(int's)S4208(and)S4418(pointers)S4844(and)S3624 V936(arrays)S1266(of)S1400(char)S1642(and)S1849(int)S2010(are)S2192(allowed.)S12 I2669(Awk)S12 R2910(allows)S3260(only)S3507(decimal)S3924(integer)S4294(constants)S4777(to)S4904(be)S3762 V936(used\320no)S1434(hex)S(\(0xnn\))322 1645 A2004(or)S2142(octal)S(\(0nn\).)292 2415 A2744(String)S3077(and)S3288(character)S3771(constants)S4258(may)S4503(contain)S4896(all)S3900 V936(of)S1067(the)S1245(special)S1612(C)S1722(escapes)S2122(\(\\n,)S2317(\\r,)S2452(etc.\).)S4074 V12 I1116(Awk)S12 R(supports)409 1355 A1795(the)S1974(`)S2005(`if')S2152(',)S2254(`)S2285(`else')S2546(',)S2648(`)S2679(`while')S3021(')S3093(and)S3298(`)S3329(`break')S3670(')S3742(\257ow)S3989(of)S4122(control)S4497(constructs,)S4212 V936(which)S1262(behave)S1634(exactly)S2014(as)S2145(in)S2269(C.)S4386 V1116(Also)S(supported)476 1397 A1925(are)S2126(the)S2326(following)S2849(unary)S3176(and)S3403(binary)S3765(operators,)S4299(listed)S4615(in)S4762(order)S4524 V936(from)S1202(highest)S1581(to)S1705(lowest)S(precedence:)579 2052 A4731 V12 B1116(Operator)S2196(Type)S3096(Associativity)S4869 V12 R1116(\(\))S1228([])S2196(unary)S3096(left)S3289(to)S3413(right)S5007 V1116(!)S1187(\304)S1258(++)S1424(\261\261)S1574(\261)S1664(*)S1754(&)S2196(unary)S3096(right)S3355(to)S3479(left)S5145 V1116(*)S1206(/)S1270(%)S2196(binary)S3096(left)S3289(to)S3413(right)S5283 V1116(+)S1214(\261)S2196(binary)S3096(left)S3289(to)S3413(right)S5421 V1116(<<)S1282(>>)S2196(binary)S3096(left)S3289(to)S3413(right)S5559 V1116(<)S1214(<=)S1380(>)S1478(>=)S2196(binary)S3096(left)S3289(to)S3413(right)S5697 V1116(==)S1282(!=)S2196(binary)S3096(left)S3289(to)S3413(right)S5835 V1116(&)S2196(binary)S3096(left)S3289(to)S3413(right)S5973 V1116(\303)S2196(binary)S3096(left)S3289(to)S3413(right)S6111 V1116(|)S2196(binary)S3096(left)S3289(to)S3413(right)S6249 V1116(&&)S2196(binary)S3096(left)S3289(to)S3413(right)S6387 V1116(||)S2196(binary)S3096(left)S3289(to)S3413(right)S6525 V1116(=)S2196(binary)S3096(right)S3355(to)S3479(left)S6732 V936(Comments)S1500(are)S(introduced)517 1690 A2248(by)S2409(a)S2504('#')S2687(symbol)S3083(and)S3299(are)S3490(terminated)S4051(by)S4213(the)S4403(\256rst)S4634(newline)S6870 V936(character.)S1482(The)S1710(standard)S2160(`)S2191(`/*')S2357(')S2438(and)S2652(`)S2683(`*/')S2849(')S2930(comment)S3420(delimiters)S3946(are)S4135(not)S(supported)476 4329 A4844(and)S7008 V(will)190 936 A1156(result)S1456(in)S1580(a)S1664(syntax)S2009(error.)S8427 VEP%%Page: 3 3BP/slant 0 def/height 0 def1130 V12 B4958(3)S1380 V936(Fields)S1761 V12 R1116(When)S12 I1447(awk)S12 R1684(reads)S1983(a)S2080(line)S2306(from)S2586(the)S2778(current)S(input)248 3166 A3458(\256le,)S3687(the)S3879(record)S4233(is)S4358(automatically)S1899 V936(separated)S1432(into)S1657(`)S1688(`\256elds.')S2052(')S2160(A)S2285(\256eld)S2537(is)S2655(simply)S3021(a)S3112(string)S3425(of)S3563(consecutive)S4171(characters)S4701(delim-)S2037 V936(ited)S1164(by)S1330(either)S1653(the)S1847(beginning)S2375(or)S2522(end)S2742(of)S2889(line,)S3147(or)S3294(a)S3394(`)S3425(`\256eld)S3727(separator')S4203(')S4290(character.)S4842(Ini-)S2175 V936(tially,)S1251(the)S1433(\256eld)S1682(separators)S2208(are)S2391(the)S(space)269 2573 A2876(and)S3084(tab)S3266(character.)S3806(The)S4028(special)S4399(unary)S4708(opera-)S2313 V936(tor)S1109('$')S1289(is)S1408(used)S1667(to)S1799(reference)S2290(one)S2502(of)S2641(the)S2827(\256elds)S3128(in)S3261(the)S3448(current)S(input)248 3831 A4118(record)S4467(\(line\).)S4830(The)S2451 V936(\256elds)S1236(are)S1423(numbered)S1944(sequentially)S2567(starting)S2969(at)S3095(1.)S3253(The)S3478(expression)S4032(`)S4063(`$0')S4255(')S4333(references)S4870(the)S2589 V936(entire)S(input)248 1243 A1521(line.)S2763 V1116(Similarly,)S1656(the)S1863(`)S1894(`record)S2304(separator')S2780(')S2880(is)S3020(used)S3300(to)S3453(determine)S3997(the)S4204(end)S4437(of)S4597(an)S(input)248 4770 A2901 V936(`)S967(`line,')S1251(')S(initially)378 1348 A1782(the)S1986(newline)S2426(character.)S2987(The)S3230(\256eld)S3500(and)S3729(record)S4094(separators)S4641(may)S4904(be)S3039 V936(changed)S1398(programatically)S2227(by)S2408(one)S2643(of)S2805(the)S3014(actions)S3418(and)S(will)190 3653 A3904(remain)S4302(in)S4457(effect)S(until)222 4796 A3177 V936(changed)S1368(again.)S3351 V(Multiple)417 1116 A1575(\(up)S1778(to)S1914(10\))S2117(\256eld)S2374(separators)S2908(are)S3099(allowed)S3525(at)S3655(a)S3751(time,)S4039(but)S4235(only)S4491(one)S4708(record)S3489 V936(separator.)S3663 V1116(Fields)S1461(behave)S1852(exactly)S2251(like)S2482(strings;)S2889(and)S3113(can)S3331(be)S3495(used)S3766(in)S3910(the)S4108(same)S4407(context)S4813(as)S4964(a)S3801 V936(character)S1412(array.)S1752(These)S2071(`)S2102(`arrays')S2471(')S2542(can)S2740(be)S2884(considered)S3438(to)S3562(have)S3820(been)S4078(declared)S4519(as:)S4028 V1086(char)S1325(\($n\)[)S(128)180 1598 A1808(];)S4255 V936(In)S1075(other)S1362(words,)S1726(they)S1972(are)S(128)180 2159 A2377(bytes)S(long.)244 2671 A2984(Notice)S3347(that)S3568(the)S3755(parentheses)S4359(are)S(necessary)471 4547 A4393 V(because)383 936 A1358(the)S1545(operators)S2035([])S2156(and)S2368($)S2466(associate)S2942(from)S3216(right)S3483(to)S3615(left;)S(without)370 3850 A4258(them,)S4568(the)S4754(state-)S4531 V936(ment)S1208(would)S1540(have)S1798(parsed)S2144(as:)S4758 V1086(char)S1325($\(1[)S(128)180 1557 A1767(]\);)S4985 V936(which)S1262(is)S(obviously)475 1373 A1878(ridiculous.)S5159 V1116(If)S1235(the)S1421(contents)S1862(of)S2001(one)S2213(of)S2352(these)S2639(\256eld)S2892(arrays)S3227(is)S3346(altered,)S3745(the)S3931(`)S3962(`$0')S4154(')S4233(\256eld)S(will)190 4486 A4714(re\257ect)S5297 V936(this)S1141(change.)S1573(For)S1771(example,)S2241(this)S2446(expression:)S5524 V(*$4)180 1086 A1296(=)S1394('A';)S5751 V(will)190 936 A1160(change)S1536(the)S1718(\256rst)S1941(character)S2421(of)S2556(the)S2738(fourth)S3068(\256eld)S3317(to)S3445(an)S(upper-)316 3594 A3945(case)S4189(letter)S4475('A'.)S4740(Then,)S5889 V936(when)S1228(the)S1406(following)S(input)248 1907 A2185(line:)S6116 V(120)180 1086 A1296(PRINT)S1676("Name)S2285(address)S2888(Zip")S6343 V936(is)S1047(processed,)S1584(it)S1682(would)S2014(be)S2158(printed)S2531(as:)S6570 V(120)180 1086 A1296(PRINT)S1676("Name)S2285(Address)S2922(Zip")S6797 V936(Fields)S1273(may)S1522(also)S1758(be)S1913(modi\256ed)S2383(with)S2640(the)S2829(strcpy\(\))S3248(function)S3692(\(see)S3929(below\).)S4368(For)S4578(example,)S6935 V936(the)S1114(expression:)S7142 V1086(strcpy\()S1453($4,)S1633("Addr.")S2040(\);)S8427 VEP%%Page: 4 4BP/slant 0 def/height 0 def1130 V12 B936(4)S1380 V12 R936(applied)S1322(to)S1446(the)S1624(same)S1903(line)S(above)288 2115 A2433(would)S2765(yield:)S1587 V(120)180 1086 A1296(PRINT)S1676("Name)S2285(Addr.)S2804(Zip")S1932 V12 B936(Prede\256ned)S1524(Variables)S2244 V12 R1116(The)S1334(following)S1835(variables)S2303(are)S2482(pre-de\256ned:)S2451 V1116(FS)S2016(Field)S2295(separator)S2770(\(see)S2996(below\).)S2589 V1116(RS)S2016(Record)S2395(separator)S2870(\(see)S3096(below)S3422(also\).)S2727 V1116(NF)S2016(Number)S2443(of)S2574(\256elds)S2866(in)S2990(current)S(input)248 3364 A3642(record)S3982(\(line\).)S2865 V1116(NR)S2016(Number)S2443(of)S2574(records)S2961(processed)S3468(thus)S3699(far.)S3003 V1116(FILENAME)S2016(Name)S2336(of)S2467(current)S(input)248 2841 A3119(\256le.)S3141 V1116(BEGIN)S2016(A)S2134(special)S2501(<pattern>)S3004(that)S3216(matches)S3643(the)S3821(beginning)S4333(of)S(input)248 4464 A4742(text.)S3279 V1116(END)S2016(A)S2134(special)S2501(<pattern>)S3004(that)S3216(matches)S3643(the)S3821(end)S4025(of)S(input)248 4156 A4434(text.)S3486 V12 I936(Awk)S12 R1180(also)S1411(provides)S1864(some)S2156(useful)S(built-in)357 2489 A2883(functions)S3370(for)S3549(string)S3862(manipulation)S4537(and)S4748(print-)S3624 V936(ing:)S3831 V1116(print\(arg\))S2016(Simple)S2389(printing)S2802(of)S2933(strings)S3286(only,)S3560(terminated)S4109(by)S4259('\\n'.)S3969 V(printf\(arg...\))597 1116 A2016(Exactly)S2416(the)S(printf\(\))352 2594 A2976(function)S3409(from)S3675(C.)S4107 V(getline\(\))412 1116 A2016(Reads)S2341(the)S2519(next)S2757(record)S3097(and)S3301(returns)S3668(0)S3758(on)S3908(end)S4112(of)S4243(\256le.)S4245 V1116(next\256le\(\))S2016(Closes)S2385(the)S2580(current)S(input)248 2971 A3266(\256le)S3468(and)S3689(begins)S4051(processing)S4615(the)S4810(next)S4383 V2016(\256le)S4521 V1116(strlen\(s\))S2016(Returns)S2422(the)S2600(length)S2932(of)S3063(its)S3208(string)S3514(argument.)S4659 V1116(strcpy\(s,t\))S2016(Copies)S2381(the)S2559(string)S2865(`)S2896(`t')S3002(')S3073(to)S3197(the)S3375(string)S3681(`)S3712(`s')S3831('.)S4797 V1116(strcmp\(s,t\))S2016(Compares)S2536(the)S2714(`)S2745(`s')S2864(')S2935(to)S3059(`)S3090(`t')S3196(')S3267(and)S3471(returns)S3838(0)S3928(if)S4033(they)S4271(match.)S4935 V(toupper\(c\))505 1116 A2016(Returns)S2422(its)S2567(character)S3043(argument)S(converted)477 3530 A4037(to)S(upper-case.)555 4161 A5073 V1116(tolower\(c\))S2016(Returns)S2422(its)S2567(character)S3043(argument)S(converted)477 3530 A4037(to)S4161(lower-case.)S5211 V1116(match\(s,@re@\))S2016(Compares)S2548(the)S2738(string)S3056(`)S3087(`s')S3206(')S3289(to)S3425(the)S3615(regular)S4002(expression)S4562(`)S4593(`re')S4760(')S4844(and)S5349 V2016(returns)S2383(the)S2561(number)S2960(of)S3091(matches)S(found)281 3518 A3829(\(zero)S4109(if)S(none\).)305 4214 A5625 V12 B936(Authors)S5937 V12 I1116(Awk)S12 R1354(was)S(written)345 1573 A1948(by)S2098(Saeko)S2423(Hirabauashi)S3039(and)S3243(Kouichi)S3663(Hirabayashi.)S8427 VEP%%Trailer%%DocumentFonts: Times-Roman Times-Bold Times-Italic Helvetica%%Pages: 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -