📄 plan9.ps
字号:
($*\(1\))720 7002 w10 R f(,)1020 7002 w10 CW f($*\(2\))1070 7002 w10 R f( addition,)1 378( In)1 133(, etc.)1 191 3 1370 7002 t10 CW f($0)2097 7002 w10 R f(is the name of the file from which)7 1356 1 2242 7002 t10 I f(rc)3623 7002 w10 R f('s input is being read.)4 863 1 3706 7002 tcleartomarkshowpagesaveobj restore%%EndPage: 2 2%%Page: 3 3/saveobj save defmark3 pagesetup10 R f(- 3 -)2 166 1 2797 480 t10 B f(6. Concatenation)1 747 1 720 840 t10 I f(Rc)720 996 w10 R f(has a string concatenation operator, the caret)6 1781 1 850 996 t10 CW f(\303)2656 996 w10 R f(, to build arguments out of pieces.)6 1360 1 2716 996 t9 CW f(echo hully\303gully)1 864 1 1008 1166 t10 R f(is exactly equivalent to)3 924 1 720 1346 t9 CW f(echo hullygully)1 810 1 1008 1516 t10 R f(Suppose variable)1 685 1 720 1696 t10 CW f(i)1430 1696 w10 R f( Then)1 255(contains the name of a command.)5 1342 2 1515 1696 t9 CW f(cc -o $i $i\303.c)3 756 1 1008 1866 t10 R f(might compile the command's source code, leaving the result in the appropriate file.)12 3367 1 720 2046 t(Concatenation distributes over lists. The following)5 2027 1 720 2202 t9 CW f(echo \(a b c\)\303\(1 2 3\))5 1080 1 1008 2372 t(src=\(main subr io\))2 972 1 1008 2482 t(cc $src\303.c)1 540 1 1008 2592 t10 R f(are equivalent to)2 665 1 720 2772 t9 CW f(echo a1 b2 c3)3 702 1 1008 2942 t(cc main.c subr.c io.c)3 1134 1 1008 3052 t10 R f(In detail, the rule is: if both operands of)8 1640 1 720 3232 t10 CW f(\303)2392 3232 w10 R f( non-zero number of strings, they are con-)7 1735(are lists of the same)4 821 2 2484 3232 t( if one of the operands is a single string, it is concatenated with each mem-)15 3059( Otherwise,)1 491(catenated pairwise.)1 770 3 720 3352 t( other combination of operands is an error.)7 1702( Any)1 222(ber of the other operand in turn.)6 1272 3 720 3472 t10 B f( carets)1 279(7. Free)1 318 2 720 3712 t10 R f(User demand has dictated that)4 1263 1 720 3868 t10 I f(rc)2023 3868 w10 R f( syntax look more like the)5 1121(insert carets in certain places, to make the)7 1773 2 2146 3868 t( example, this:)2 586( For)1 189(Bourne shell.)1 533 3 720 3988 t9 CW f(cc -$flags $stems.c)2 1026 1 1008 4158 t10 R f(is equivalent to)2 611 1 720 4338 t9 CW f(cc -\303$flags $stems\303.c)2 1134 1 1008 4508 t10 R f(In general,)1 440 1 720 4688 t10 I f(rc)1199 4688 w10 R f(will insert)1 417 1 1321 4688 t10 CW f(\303)1777 4688 w10 R f( Specifically,)1 567( not separated by white space.)5 1272(between two arguments that are)4 1325 3 1876 4688 t(whenever one of)2 668 1 720 4808 t10 CW f($'`)1415 4808 w10 R f(follows a quoted or unquoted word, or an unquoted word follows a quoted word with)14 3418 1 1622 4808 t(no intervening blanks or tabs, a)5 1264 1 720 4928 t10 CW f(\303)2011 4928 w10 R f( an unquoted word immediately following)5 1700( If)1 119( between the two.)3 713(is inserted)1 410 4 2098 4928 t(a)720 5048 w10 CW f($)797 5048 w10 R f(contains a character other than an alphanumeric, underscore or)8 2564 1 890 5048 t10 CW f(*)3487 5048 w10 R f(, a)1 102 1 3547 5048 t10 CW f(\303)3682 5048 w10 R f( the first such)3 562(is inserted before)2 703 2 3775 5048 t(character.)720 5168 w10 B f( substitution)1 532(8. Command)1 575 2 720 5408 t10 R f( list from the output of a command.)7 1444(It is often useful to build an argument)7 1528 2 720 5564 t10 I f(Rc)3746 5564 w10 R f(allows a command, enclosed)3 1160 1 3880 5564 t(in braces and preceded by a left quote,)7 1569 1 720 5684 t10 CW f(`{...})2319 5684 w10 R f( command is)2 519( The)1 209( an argument is required.)4 1011(, anywhere that)2 622 4 2679 5684 t( characters stored in the variable)5 1333( The)1 213( its standard output captured.)4 1189(executed and)1 530 4 720 5804 t10 CW f(ifs)4018 5804 w10 R f(are used to split the)4 809 1 4231 5804 t( example,)1 388( For)1 189(output into arguments.)2 903 3 720 5924 t9 CW f(cat `{ls -tr|sed 10q})3 1134 1 1008 6094 t10 R f(will catenate the ten oldest files in the current directory in temporal order.)12 2947 1 720 6274 t10 B f( branching)1 465(9. Pipeline)1 470 2 720 6514 t10 R f( occasionally it is useful to have)6 1312( Very)1 254( for almost all cases.)4 838(The normal pipeline notation is general enough)6 1916 4 720 6670 t( can require arbitrarily large pipe)5 1350( topologies more general than trees)5 1440( Pipeline)1 386(pipelines that are not linear.)4 1144 4 720 6790 t(buffers, or worse, can cause deadlock.)5 1567 1 720 6910 t10 I f(Rc)2346 6910 w10 R f( of non-linear but treelike pipelines.)5 1481(has syntax for some kinds)4 1074 2 2485 6910 t(For example,)1 527 1 720 7030 t9 CW f(cmp <{old} <{new})2 918 1 1440 7200 tcleartomarkshowpagesaveobj restore%%EndPage: 3 3%%Page: 4 4/saveobj save defmark4 pagesetup10 R f(- 4 -)2 166 1 2797 480 t(will regression test a new version of a command.)8 1963 1 720 840 t10 CW f(<)2734 840 w10 R f(or)2820 840 w10 CW f(>)2929 840 w10 R f( in braces causes the com-)5 1054(followed by a command)3 971 2 3015 840 t( parent command \()3 751( The)1 205( be run with its standard output or input attached to a pipe.)12 2334(mand to)1 326 4 720 960 t10 CW f(cmp)4336 960 w10 R f(in the exam-)2 499 1 4541 960 t( descriptor or other, and with an argument)7 1701(ple\) is started with the other end of the pipe attached to some file)13 2619 2 720 1080 t( connect to the pipe when opened \(e.g.)7 1601(that will)1 341 2 720 1200 t10 CW f(/dev/fd/6)2721 1200 w10 R f( systems without)2 691(.\) On)1 239 2 3261 1200 t10 CW f(/dev/fd)4225 1200 w10 R f(or some-)1 361 1 4679 1200 t(thing similar \(SunOS for example\) this feature does not work.)9 2475 1 720 1320 t10 B f( status)1 275(10. Exit)1 353 2 720 1560 t10 R f( Plan 9 status is a character)6 1153( On)1 184( executed it.)2 509(When a command exits it returns status to the program that)10 2474 4 720 1716 t( normal termination it is empty.)5 1267( On)1 172(string describing an error condition.)4 1434 3 720 1836 t10 I f(Rc)720 1992 w10 R f( the variable)2 537(captures commands' exit statuses in)4 1521 2 871 1992 t10 CW f($status)2976 1992 w10 R f( a simple command the value of)6 1408(. For)1 236 2 3396 1992 t10 CW f($status)720 2112 w10 R f( a pipeline)2 420( For)1 191(is just as described above.)4 1048 3 1167 2112 t10 CW f($status)2853 2112 w10 R f( to the concatenation of the statuses of)7 1535(is set)1 205 2 3300 2112 t(the pipeline components with)3 1180 1 720 2232 t10 CW f(|)1925 2232 w10 R f(characters for separators.)2 998 1 2010 2232 t10 I f(Rc)720 2388 w10 R f( control flow, many of them conditioned by the status returned from previously)12 3286(has a several kinds of)4 895 2 859 2388 t( Any)1 224(executed commands.)1 839 2 720 2508 t10 CW f($status)1810 2508 w10 R f(containing only)1 627 1 2257 2508 t10 CW f(0)2911 2508 w10 R f('s and)1 243 1 2971 2508 t10 CW f(|)3241 2508 w10 R f('s has boolean value)3 818 1 3301 2508 t10 I f(true)4146 2508 w10 R f( other status)2 485(. Any)1 248 2 4307 2508 t(is)720 2628 w10 I f(false)812 2628 w10 R f(.)1001 2628 w10 B f( grouping)1 415(11. Command)1 625 2 720 2868 t10 R f(A sequence of commands enclosed in)5 1505 1 720 3024 t10 CW f({})2250 3024 w10 R f( example:)1 391( For)1 189(may be used anywhere a command is required.)7 1873 3 2395 3024 t9 CW f({sleep 3600;echo 'Time''s up!'}&)3 1728 1 1008 3194 t10 R f( the braces:)2 454( Without)1 378(will wait an hour in the background, then print a message.)10 2319 3 720 3374 t9 CW f(sleep 3600;echo 'Time''s up!'&)3 1620 1 1008 3544 t10 R f(this would lock up the terminal for an hour, then print the message in the background!)15 3440 1 720 3724 t10 B f( flow \320)2 333(12. Control)1 508 2 720 3964 t10 CW f(for)1586 3964 w10 R f(A command may be executed once for each member of a list by typing, for example:)15 3387 1 720 4120 t9 CW f(for\(i in printf scanf putchar\) look $i /usr/td/lib/dw.dat)7 3078 1 1008 4290 t10 R f(This looks for each of the words)6 1292 1 720 4470 t10 CW f(printf)2037 4470 w10 R f(,)2397 4470 w10 CW f(scanf)2447 4470 w10 R f(and)2772 4470 w10 CW f(putchar)2941 4470 w10 R f( general form is)3 629( The)1 205(in the given file.)3 655 3 3386 4470 t9 CW f(for\()1008 4640 w9 I f(name)1224 4640 w9 CW f(in)1473 4640 w9 I f(list)1635 4640 w9 CW f(\))1745 4640 w9 I f(command)1853 4640 w10 R f(or)720 4820 w9 CW f(for\()1008 4990 w9 I f(name)1224 4990 w9 CW f(\))1419 4990 w9 I f(command)1527 4990 w10 R f( first case)2 394(In the)1 235 2 720 5170 t10 I f(command)1380 5170 w10 R f(is executed once for each member of)6 1503 1 1799 5170 t10 I f(list)3333 5170 w10 R f(with that member assigned to variable)5 1553 1 3487 5170 t10 I f(name)720 5290 w10 R f(. If)1 141 1 936 5290 t10 CW f(in)1102 5290 w10 I f(list)1247 5290 w10 R f(is not given,)2 492 1 1395 5290 t10 I f($*)1912 5290 w10 R f(is used.)1 300 1 2037 5290 t10 B f( execution \320)2 555(13. Conditional)1 682 2 720 5530 t10 CW f(if)1982 5530 w10 I f(Rc)720 5686 w10 R f( example:)1 391( For)1 189(also provides a general if-statement.)4 1444 3 850 5686 t9 CW f(if\(cyntax *.c\) cc -g -o cmd *.c)6 1674 1 1008 5856 t10 R f(runs the C compiler whenever)4 1259 1 720 6036 t10 CW f(cyntax)2018 6036 w10 R f(finds no problems with)3 967 1 2417 6036 t10 CW f(*.c)3423 6036 w10 R f( `if not' statement provides a)5 1226(. An)1 211 2 3603 6036 t( example:)1 391( For)1 189(two-tailed conditional.)1 905 3 720 6156 t9 CW f(for\(i\){)1008 6326 w(if\(test -f /tmp/$i\) echo $i already in /tmp)7 2322 1 1224 6436 t(if not cp $i /tmp)4 918 1 1224 6546 t(})1008 6656 w10 R f(This loops over each file in)5 1090 1 720 6836 t10 CW f($*)1835 6836 w10 R f(, copying to)2 475 1 1955 6836 t10 CW f(/tmp)2455 6836 w10 R f(those that do not already appear there, and printing a mes-)10 2320 1 2720 6836 t(sage for those that do.)4 879 1 720 6956 tcleartomarkshowpagesaveobj restore%%EndPage: 4 4%%Page: 5 5/saveobj save defmark5 pagesetup10 R f(- 5 -)2 166 1 2797 480 t10 B f( flow \320)2 333(14. Control)1 508 2 720 840 t10 CW f(while)1586 840 w10 I f(Rc)720 996 w10 R f('s while statement looks like this:)5 1342 1 825 996 t9 CW f(while\(newer subr.c subr.o\) sleep 5)4 1836 1 1008 1166 t10 R f(This waits until)2 623 1 720 1346 t10 CW f(subr.o)1368 1346 w10 R f(is newer than)2 532 1 1753 1346 t10 CW f(subr.c)2310 1346 w10 R f(\(presumably because the C compiler finished with it.\))7 2147 1 2695 1346 t10 B f( flow \320)2 333(15. Control)1 508 2 720 1586 t10 CW f(switch)1586 1586 w10 I f(Rc)720 1742 w10 R f( general form is)3 629( Its)1 150(provides a switch statement to do pattern-matching on arbitrary strings.)9 2852 3 850 1742 t9 CW f(switch\()1008 1912 w9 I f(word)1386 1912 w9 CW f(\){)1571 1912 w(case)1008 2022 w9 I f(pattern ...)1 352 1 1278 2022 t(commands)1224 2132 w9 CW f(case)1008 2242 w9 I f(pattern ...)1 352 1 1278 2242 t(commands)1224 2352 w9 CW f(...)1008 2462 w(})1008 2572 w10 I f(Rc)720 2752 w10 R f( are the same as)4 647( Patterns)1 376(attempts to match the word against the patterns in each case statement in turn.)13 3164 3 853 2752 t(for filename matching, except that)4 1372 1 720 2872 t10 CW f(/)2117 2872 w10 R f(and the first characters of)4 1013 1 2202 2872 t10 CW f(.)3240 2872 w10 R f(and)3350 2872 w10 CW f(..)3519 2872 w10 R f(need not be matched explicitly.)4 1251 1 3689 2872 t( to the next case \(or the end of the switch\) are)11 1864(If any pattern matches, the commands following that case up)9 2456 2 720 3028 t( example,)1 388( For)1 189(executed, and execution of the switch is complete.)7 2010 3 720 3148 t9 CW f(switch\($#*\){)1008 3318 w(case 1)1 324 1 1008 3428 t(cat >>$1)1 432 1 1224 3538 t(case 2)1 324 1 1008 3648 t(cat >>$2 <$1)2 648 1 1224 3758 t(case *)1 324 1 1008 3868 t(echo 'Usage: append [from] to')4 1620 1 1224 3978 t(})1008 4088 w10 R f( two, the first)3 536( With)1 251( with one file argument, it tacks standard input to its end.)11 2279( Called)1 311(is an append command.)3 943 5 720 4268 t( other number elicits a usage message.)6 1533( Any)1 222(is appended to the second.)4 1051 3 720 4388 t(The built-in)1 475 1 720 4544 t10 CW f(\304)1220 4544 w10 R f( arguments are a)3 659( Its)1 151( more concise than a switch.)5 1136(command also matches patterns, and is often)6 1789 4 1305 4544 t( sets)1 181( It)1 118(string and a list of patterns.)5 1123 3 720 4664 t10 CW f($status)2173 4664 w10 R f(to true if and only if any of the patterns matches the string.)12 2416 1 2624 4664 t(The following example processes option arguments for the)7 2349 1 720 4784 t10 I f(man)3094 4784 w10 R f(\(1\) command:)1 563 1 3266 4784 t9 CW f(opt=\(\))1008 4954 w(while\(\304 $1 -* [1-9] 10\){)4 1296 1 1008 5064 t(switch\($1\){)1224 5174 w
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -