. : f.csh: # !/bin/csh set a = 1 b = '`echo $v`' c = 3 echo a = $a b = $b c = $c set v = 100 @ b++ echo b = $b @ d = ( $a + $b + $c ) echo d = $d # - C-shell- -. !/bin/csh , - csh. : % f.csh a = 1 b = `echo $v` c = 3 b = 101 d = 105 a, b, c v - , , - 21 - @. . set b = '`echo $v`' - b . set - b : b = `echo $v`. @ b++ `echo $v` ( b ), b 1. b 101 . - . , - . , , : % set a = '' % echo ${a} % echo ${a} % echo ${a} : $ ${} ; {} - , ; $[] ${[]}  ; $? ${?} 1, , 0; $$ csh; $# ${#} , ; $?0 ${?0} 1, , 0; $0 , - ; $ ${} $argv[]; $* $argv[*], .. , csh. - 22 - - f.csh. 23 - , - . # - . , , - , - : - 23 - # !/bin/csh set m = ( w1 w2 w3 w4 w5 ) # 1 - 2 if( $?m ) then echo 1 $m else echo 2 0 endif # 3 - 4 if( ${?m} ) then echo 3 $m else echo 4 0 endif # 5 - 6 if( $?0 ) then echo 5 1 else echo 6 0 endif # 7 - 8 if( ${?0} ) then echo 7 1 else echo 8 0 endif # 9 echo 9 $$ @ p = ( $$ + 10 ) # 10 echo 10 $p date >&gt; ofile$$ # 11 echo "11 `ls ofile$$`" cat ofile$$ set p = 2 @ p++ # 12 - 17 echo 12 p = $p echo 13 ${p}aaa echo 14 $m[1] echo 15 $m[5] echo 16 $m[2-4] echo 17 ${m[3]}aaa # 18 - 23 set p = $#m echo 18 $p echo 19 ${#m}aaa echo 20 $0 echo 21 $3 echo 22 ${3}ddd echo 23 $* - 24 - : 11 22 33 44 55 66. : % f.csh 11 22 33 44 55 66 1 w1 w2 w3 w4 w5 3 w1 w2 w3 w4 w5 5 1 7 1 9 525 10 535 11 ofile525 10 22:57:20 MSK 1988 12 p = 3 13 3aaa 14 w1 15 w5 16 w2 w3 w4 17 w3aaa 18 5 19 5aaa 20 f.csh 21 33 22 33ddd 23 11 22 33 44 55 66 , 11, . . , - . 20 - 23 - argv. f.csh 11 22 33 44 55 66, . $<&lt; - . $<&lt;, - $<&lt; - 25 - % set  = $<&lt; % echo $ % @ aaa = 1 + $<&lt; + 3 2 % echo $aaa 6 % echo $<&lt; % set  = ( $<&lt; ) % echo : $ : % echo $[4] % set [4] = $<&lt; % echo $[4] csh $<&lt; . rline, : % set a = `rline` % echo $a 1.7. . - - , . , - _: : h , ( /); gh h , ; r , , ; - 26 - gr r , ; e , ; ge e , ; t , ( / ); gt t , ; q . - ; x . . - : $? ${?} $?0 $$ . - . {}, - . f.csh : - 27 - #!/bin/csh set a = /usr/bin/pr1 set b = /dir1/dir11/dir111/file.c set c = (/d/d1/d2/f.c /d/d1/c.c /d5/f.s ) # 1 echo ' 1' echo $a:h echo $b:h echo $c[1]:h echo ${c[2]:h} echo $c[3]:h # 2 echo ' 2' echo $a:t echo $b:t echo $c[1]:t echo ${c[2]:t} echo $c[3]:t # 3 echo ' 3' echo $a:r echo $a:e echo $b:r echo $b:e echo $c[1]:r echo $c[1]:e echo ${c[2]:r} echo ${c[2]:e} echo $c[3]:r echo $c[3]:e # 4 echo ' 4' echo $c:gh echo $c:gt echo $c:gr # 5 echo ' 5' set m = "$c:x" echo $m echo $m[1]:t echo $m[1]:r # 6 echo ' 6' set m = "$c:q" echo $m echo $m[1]:h echo $m[1]:r - 28 - : % f.csh 1 /usr/bin /dir1/dir11/dir111 /d/d1/d2 /d/d1 /d5 2 pr1 file.c f.c c.c f.s 3 /usr/bin/pr1 pr1 /dir1/dir11/dir111/file c /d/d1/d2/f c /d/d1/c c /d5/f s 4 /d/d1/d2 /d/d1 /d5 f.c c.c f.s /d/d1/d2/f /d/d1/c /d5/f 5 /d/d1/d2/f.c /d/d1/c.c /d5/f.s f.s /d/d1/d2/f.c /d/d1/c.c /d5/f 6 /d/d1/d2/f.c /d/d1/c.c /d5/f.s /d/d1/d2/f.c /d/d1/c.c /d5 /d/d1/d2/f.c /d/d1/c.c /d5/f , . 5 6 - x q . c . m - x q. , - , h, t r - . - 29 - 1.8. @ , , : % set a = 5 b = 7 % @ c = ( $a + $b ) % echo $c 12 C-shell , - . , , . (0 - 1 - ). , . C-shell . if_then_else, while, exit. , . - , - . : == =~ ? != !~ ? . ~ *, ? [...]. - switch . - 30 - __: ( ): || && <&lt;= ? >&gt;= ? >&gt; ? <&lt; ? + - * / % ( ): ++ , () -- , () _: & | ^ ~ () ! () >&gt;>&gt; <&lt;<&lt; : - _,  - , : r ( ?) w ( ?) x ( ?) e ( ?) o ( ?) z ( = 0 ?) f ( ?) d ( - ?) , , . :  @ ; @  _  ; - 31 - @ [] _ e . : = += -= *= /= %= , , . : ||, &&, | , ^ , & , ==, !=, <&lt;=, >&gt;=, <&lt; , >&gt; , <&lt;<&lt;, >&gt;>&gt;, + , - , * , / , % , ! , ~ , ( ) - : [ =~, !~, ==, != ] [ <&lt;, >&gt;, <&lt;=, >&gt;= ] [ <&lt;<&lt;, >&gt;>&gt; ] [ +, - ] [ *, /, % ] - . , , . . , , . , : - 32 - # !/bin/csh # 1 set a = 5 @ a++ echo $a # : 6 # 2 @ a = 7 echo $a # : 7 # 3 set a = 10 b = 15 @ c = ( $a + $b ) echo $c # : 25 # 4 @ c += 5 echo $c # : 30 # 5 @ c = ( $c * 5 ) echo $c # : 150 # 6 @ c *= 5 echo $c # : 750 # 7 @ c *= $c echo $c # : -27324 # 8 set a = 5 b = 7 c = 9 @ a = ( $a << 2 ) @ b = ( $b >> 2 ) @ c = ( $c + $a + $b ) echo $a $b $c # : 20 1 30 # 9 set a = 5 b = 3 @ c = ( $a | $b ) echo $c # : 7 # 10 - 33 - set a = 5 b = 3 c = 2 @ d = ( ( $a + $b ) + ( $a + $b + $c ) ) echo $d # : 18 # 11 set a = 5 if( "$a" == "5" ) echo ' ' if( "$a" != "5" ) echo ' ' # : # 12 date >&gt; file chmod 755 file if( -x file ) echo '' # : 1 - 6 . 7 - , C-shell integer ( 16- ). : % set c = 0 % @ c = -x a.out + 100 % echo $c 101 % @ c = 100 - -x a.out % echo $c 99 . % @ c = 100 - { date } 3 14:48:37 1988 % echo $c 99 % @ c = { date rrrjjj } - 100 : % echo $c -100 : - 34 - == != =~ !~ - ? . * [...] - . - , % set c = "*" % if( "$c" == "*" ) _____ % if( "$c" =~ "*" ) _____ - - , ( *). - . 1.9. C-shell C-shell : foreach, switch, while, if_then_else, goto, continue, break, shift, exit. csh . - . - . ? , , . , . foreach, switch, while, if_then_else goto . foreach foreach  ( ) ... end    - foreach. foreach end - 35 - % foreach i ( a b c d e f g h ) ? if( "$i" == "c" ) continue ? glob "$i " ? if( "$i" == "f" ) break ? end a b d e f % i , foreach. . i c, , i f, . continue , - break , . glob echo, , - . switch : switch(_) case : ... breaksw ... default: ... ... endsw case switch ( *, ? [...]). case , breaksw, default endsw. , default. default , endsw. case default . breaksw , endsw - 36 - % set j = 0 % foreach i ( aaa bbb ccc ddd eee ) ? @ j++ ? switch( $i ) ? case "aaa": ? glob "$i " ? breaksw ? case "bbb": ? glob "$i " ? breaksw ? case "ccc": ? glob "$i " ? breaksw ? case "ddd": ? glob "$i " ? breaksw ? default: ? breaksw ? ? endsw ? glob "$j " ?end aaa 1 bbb 2 ccc 3 ddd 4 5 % i foreach. switch. case i, default. - switch, foreach . switch. if if(1) then ... else if(2) then ... else ... endif 1 ( ), - else. , 2 , else .. else if, endif . else . else endif , . if else - 37 - % foreach i ( a b c d e f ) ? if( "$i" == "a" ) then ? glob "a " ? else if( "$i" == "b" ) then ? glob "b " ? else if( "$i" == "c" ) then ? glob "c " ? endif ? end a b c % foreach - i 'a', 'b' , - , - . while while() ... end , . - while end . break continue ( , continue, ) % set argv = ( 1 2 3 1 2 3 0 1 ) % while( $#argv > 0 ) ? if( "$argv[1]" == "3" ) then ? shift ? continue ? endif ? if( "$argv[1]" == "0" ) then ? break ? endif ? glob " $argv[1]" ? shift ? end 1 2 1 2 % , argv. argv[1] "3", , "0", . - shift () . - argv. argv[1] . - 38 - while , argv , .. $#argv . 1.10. , C-shell, . - csh, , - , , . , , csh sh. , . C-shell - # , - . . , #, - . , argv, - , , . . - 39 - #!/bin/csh # # . # Result. # # . # . # out # . # out = /dev/tty # , out = Result # ./Result. set   set out = /dev/tty set  = ( 0 0 0 0 0 0 0 0 0 0 0 0 ) set  = ( 0 0 0 0 0 ) # # set  = ( \ \ \ ) # # while(1) while ( 1 ) glob ' > ' set  = $<&lt; switch( "$" ) case '[Kk]': exit( 0 ) case '[Zz]': set out = Result case '[Dd]': # # @ [1] = $[1] + $[2] + $[3] @ [2] = $[4] + $[5] + $[6] @ [3] = $[7] + $[8] + $[9] @ [4] = $[10] + $[11] + $[12] @ [5] = $[1] + $[2] + $[3] + $[4] # , - 40 - if( "$out" != "Result" ) clear # echo out # echo " \ .\ $ \ $ \ $ \ $ \ $[1] \ $[2] \ $[3] \ $[1] \ $[4] \ $[5] \ $[6] \ $[2] \ $[7] \ $[8] \ $[9] \ $[3] \ $[10] \ $[11] \ $[12] \ $[4] \ $[5] " >> $out continue case '[Aa]': glob ' : ' set  = $<&lt; continue case '[Bb]': glob ' : ' set  = $<&lt; continue case '[Ww]': glob ': ' set  = $<&lt; continue case '[Gg]': glob ': ' set  = $<&lt; continue case '[1-9]': case "1[012]": glob $[$]': ' - 41 - set [$] = $<&lt; continue default: # , . echo ' .' clear echo ' \ \ \ \ \ \ : \ \ . \ . \ . \ . \ . \ . \ . \ : \ 1 2 3 \ 4 5 6 \ 7 8 9 \ 10 11 12 \ \ ' endsw end Result, . , - 42 - . 1420 1673 124 300 350 350 1000 520 330 700 1550 200 150 250 600 300 310 280 890 4040 , - . - . - . , - , . - 43 - # !/bin/csh # # ? *, # # # while( 1 ) glob '=> ' set  = "$<&lt;" switch( "$" ) case [?] : echo ' ' breaksw case [*] : echo '' breaksw case '{' : case '}' : echo ' ' breaksw default : echo ' ' endsw end 1.11. , . history, ~/.cshrc ( ). - savehist, history ~/.history. - . , set savehist = 22 22 ~/.history . , history.