-
" "
/P 2.1
C-shell
1988
C-shell.
, C-
shell, .
1. C-shell
-
- -
. -
- , (
) , -
( ) -
.
.
.
, -
-
C-shell [].
C-shell - -
.
-
C-shell
, -
. C-shell:
C -
shell - (-
""). -
csh,
C-shell. csh :
.
, -
,
.
, -
.
.
( C-shell),
( C-shell).
1.1. C-shell
C-shell
,
(, /bin/cat), csh
(, cd), C-shell
(, while).
- 3 -
-
. , , -
. -
, , ..
. , -
,
( ),
csh. csh -
: , -
.
- ,
csh.
, :
; ( ) << >> & |
, , -
\. , ; \,
,
';' , .
- -
, .
C-shell.
! # $ % : * , ?
[ ] { } @ ~ . ^
\ -
.
""
, . csh
,
, -
:
"" '' ``
. -
\.
,
, \.
, ,
csh,
.
- 4 -
, (-
), . -
. -
? . * ! ~
.
, , -
. -
.
- C-
shell csh:
alias endsw logout suspend
alloc eval newgrp switch
bg exec nice time
break exit nohup umask
breaksw fg notify unalias
case foreach onintr unhash
cd glob popd unlimit
chdir goto pushd unset
continue hashstat rehash unsetenv
default history repeat wait
dirs if set while
echo jobs setenv
else kill shift
end limit source
endif login stop
csh:
argv history nonomatch status
cdpath home notify time
checktime ignoreeof path verbose
child mail prompt
cwd noclobber savehist
echo noglob shell
-
, csh. -
. , time -
, -
time
, -
.
- 5 -
1.2. , -
csh
.
(\n) -
.
, , , .
-
. csh
.
, .
,
pr -2 -w39 -l24 -t file
file
, 39 24 .
pr (
/bin)
. pr ,
.
, .
, file, -
pr. pr
, :
;
(
- /bin);
.
csh ( -
). , -
.
, , -
.
, ;, :
cat << file ; pr -2 -w39 -l24 -t file
:
- 6 -
file , ,
pr .
&& ||, :
cat << file && pr -2 -w39 -l24 -t file
, -
, .. file
.
cat << file1 || pr -2 -w79 -l24 -t file
,
, file1 .
- -
, .
-
.
.
, , -
-
, :
ls -l; ( cat << f1 && cat << f2 ) && date
, -
,
, date. -
csh -
, ;, &&, |,
||, -.
, .
,
. -
, .
|,
:
cat -n << file | pr -2 -w39 -l24 -t
cat file ( n),
pr .
.
sort file | cat -n | pr -2 -w39 -l24 >>>> file2
sort ; cat - ;
pr - file2.
- 7 -
&&
||, , ;, :
( cat << f1 && date ) && ( cat -n << f1 | sort ); date
f1, , -
, cat, ,
.
. f1 , -
.
-
, .
.
.
& , -
, :
cat -n << f1 | pr -2 -w39 -l24 -t >> f2 &
cat , pr -
, f2.
,
.
(DEL) -
, .
/W (CTRL/W)
.
/U (CTRL/U) .
cd, popd pushd. -
( -
cwd), ,
dirs.
pushd popd
.
cd .
1, .
popd cd
__2 , .. -
, -
. __1 ,
.
popd + __(1+) ,
.
.
- 8 -
pushd -
1. pushd -
cd __2 .
___2 , ___1 -
(
). pushd cd
, ,
.
pushd + cd
___(1+). ___(1+)
,
, -
. .
1.3.
,
-
.
, - ,
-
.
: -
- ; -
/ .
() -
,
() - .
()
.
. (-
) :
<<, <<<<, <<<<
,
( ).
() -
:
>> >>>> |
>>& >>>>& |&
>>! >>>>!
>>&! >>>>&!
,
( ).
& ,
,
. ! ,
- 9 -
.
- -
noclobber, noglob nonomatch. -
,
-.
set unset. :
set noclobber unset noclobber
:
<< _
, -
;
<<<<
-
. ,
. :
cat >> file <<<< mmm
0123
3456
6789
mmm
cat file
. mmm.
mmm, file.
mmm, file -
. mmm . -
.
:
>> _
.
>>! _
noclobber.
,
(,
/dev/tty*). , file1
file2
set noclobber
- 10 -
cat << file2 >> file1
,
cat << file2 >>! file1
. noclobber
, -
. >>!, >>>>!, >>&!
>>>>&!
.
>>& _ >>&! _
, - ,
noclobber.
>>>> _ >>>>! _
. ,
, - ,
noclobber.
>>>>& _ >>>>&! _
csh
, , -
noclobber.
.
noglob.
: _..
noglob,
.
, -
,
noclobber.
.
|&. ,
-
( ), -
. ,
cat << file1 |& pr -w79 -l24 >> file2
( ),
pr file2.
1.4.
, -
. -
- 11 -
,
,
csh.
, -
- . -
. -
: . -
ps -
.
-
.
, ,
,
fg, bg, stop, kill, notify. -
- -
.
:
() -
;
()
() ;
;
;
- ;
;
.
. ,
jobs jobs -l. -
.
jobs , :
- 12 -
[1] cc -c *.o
[2] - make install
[3] + red file
[4] sort file >> result &
[5] mx -q -N -u -s *.m >> out &
-
.
. -
-
:
% %+
;
%-
;
%
;
%
;
%??
.
, &.
,
/C (CTRL/C).
, /\ (CTRL/\).
core.
core , -
, /\.
. , , -
/S (CTRL/S),
, /Q (CTRL/Q).
,
, /Z
(CTRL/Z), - fg %. -
-
. -
, . ,
/Z
csh, /S
.
. -
, /Z,
- 13 -
bg.
.
-
,
&.
[]
- -
, - .
, -
stop %_
stop %
stop %
. , -
:
1 sort file >> /tmp/result &
2 cc *.c >>& errors &
3 lint *.c >>& mymsg &
: stop %1 stop %sort;
- stop %2 stop %c; - stop %3 stop %li,
stop %?mymsg?. -
, fg
bg .
-
:
%_ &
% &
bg %_
bg %
fg %_ &
fg % &
:
%_
%
fg %_
fg %
( -
) .
- 14 -
, .
:
kill -KILL %_
kill -KILL %
kill -KILL __
suspend, /Z .
-
. ,
stty tostop
tostop, -
-
.
. :
stty tostop
cat << file &
[1] 285
jobs
[1] + ( ) cat << file
,
fg %1
fg %cat
tostop,
stty -tostop
kill .
kill:
kill -l
;
kill % kill %
TERM () ;
kill __
TERM ;
- 15 -
kill -SIG
SIG .
,
( /usr/include/signal.h SIG).
-
(
). notify,
, .
notify
:
notify - ;
unset notify - ;
notify % - .
32-
, . -
:
cputime
,
;
filesize
, ;
datasize
( + )
sbrk(2) ;
stacksize
;
coredumpsize
, .
limit, - unlimit. -
, cputime, k -
m - . cputime ss - , m
- , h - .
. :
- 16 -
limit cputime 1m (1 )
limit cputime 05:30 (5 30 )
limit filesize 2m ( 2 )
1.5.
*, ?, [, ], {, }
~ (), -
. -
,
,
.
,
. -
.
*
. -
, echo *
, echo */*/f* -
,
f.
?
. :
% ls f.?
f.c
f.o
f.s
,
f, -
- .
[_]
-
. :
% ls f.[cso]
f.c
f.o
f.s
[-]
-
. :
- 17 -
% ls f.[a-z]
f.c
f.o
f.s
, -
.
~ ()
,
ls -l ~
, -
. -
.
~__
. :
% ls ~
.
{___}
. :
% ls f.{c,s,o}
f.c
f.o
f.s
1{___}2
1
2.
. .
1 / 2 . :
% ls aaa{ddd,ccc,bbb}eee
aaadddeee
aaaccceee
aaabbbeee
.
, ls .
-
, , -
:
- 18 -
% echo {,,,,,}
, :
%echo {,,}{' ',' '}
.
., .
-
\.
,
.
, -
, .
-
. ,
, - nonomatch. -
, csh ,
. , ,
f.1, f.2 f.3. echo f.[4-
9], :
echo: .
set nonomatch; echo f.[4-9]
: f.[4-9].
echo .
f.[4-9],
.
,
- .
1.6.
C-shell :
, , , .
, -
(, )
, C-shell
- 19 -
,
.
set
(, @ a = 5). -
,
$.
?, # -
. :
;
-
;
, -
.
. ,
comfile aaa bbb ccc ddd
-
comfile. , -
, $0 -
comfile, $3 - ccc.
.
% set a = 5
% echo a
a
% echo $a
5
$ ,
\. :
% set a = 5
% echo \$a
$a
% echo $a
5
, ,
$, :
- 20 -
% set a = 5
% echo \$a
$a
% echo "\$a"
\5
% set b = ", , $a."
% echo $b
, , 5.
%
% set b = ", , \$a."
% echo $b
, , \5.
, -
, $ , :
% set a = 5
%set b = ', , $a.'
% echo $b
, , $a.
%
% set b = ', , \$a.'
% echo $b
, , \$a.
,
() , $ -
. -
, . :
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 >> 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,
.
$<< -
.
$<<, -
$<<
- 25 -
% set = $<<
% echo $
% @ aaa = 1 + $<< + 3
2
% echo $aaa
6
% echo $<<
% set = ( $<< )
% echo : $
:
% echo $[4]
% set [4] = $<<
% echo $[4]
csh $<<
.
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 -
__:
( ):
||
&&
<<= ?
>>= ?
>> ?
<< ?
+
-
*
/
%
( ):
++ ,
()
-- ,
()
_:
&
|
^
~
()
!
()
>>>>
<<<<
:
- _, -
, :
r ( ?)
w ( ?)
x ( ?)
e ( ?)
o ( ?)
z ( = 0 ?)
f ( ?)
d ( - ?)
,
, .
:
@
;
@ _
;
- 31 -
@ [] _ e
.
:
= += -= *= /= %=
,
, .
:
||, &&, | , ^ , & , ==, !=,
<<=, >>=, << , >> , <<<<, >>>>, + ,
- , * , / , % , ! , ~ , ( )
-
:
[ =~, !~, ==, != ]
[ <<, >>, <<=, >>= ]
[ <<<<, >>>> ]
[ +, - ]
[ *, /, % ]
-
. ,
, .
.
, ,
.
,
:
- 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 >> 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 = $<<
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 = $<<
continue
case '[Bb]':
glob ' : '
set = $<<
continue
case '[Ww]':
glob ': '
set = $<<
continue
case '[Gg]':
glob ': '
set = $<<
continue
case '[1-9]':
case "1[012]":
glob $[$]': '
- 41 -
set [$] = $<<
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 = "$<<"
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. ,
, , ,
.
- 44 -
, -
-
.
.
history :
1 cat file1
2 pr -w39 -l24 -2 file1
3 cc program.c >>& errors &
4 cat errors
5 ed program.c
6 history
, ,
:
!2
;
!!
:
!-2
( );
!cat !c
. -
, -
(cat c),
;
!{cat}.a1
cat errors.a1 -
.a1;
!?gram?
. -
, -
gram. ? ,
;
cat !5* !1*
cat program.c file1 - -
,
.
.
, 0. 0 -
. ,
,
- 45 -
cat !3:1
1,
cat program.c
:
* n* n-m
, 1,
, n,
, n -
m;
n n-, -n
n, , -
n, ,
, 0
n;
??:%
, ;
^ $
1 .
:
^ $ * - %
. history
:
1 cat file1 file2 file3
2 pr -w39 -l24 -2 file1 file5
3 cc -o program1.c program2.c >>& errors &
4 cat errors
5 ed program2.c
6 history
csh , -
:
!5:0 !1:3
0 (
),
3. ed file3;
- 46 -
!5:0 !1$
0,
- . ed file3;
!2:-3 !3:2-3
2 0 3 -
, 3 2
3. :
pr -w39 -l24 -2 program1.c program2.c
!2-3 !?prog?%
:
pr -w39 -l24 -2 program2.c
, -
,
.
.
:
p
, ;
&
;
s/_1/_2/
_1 _2. / -
, . -
_2 , _1 .
-
. ,
. history
:
1 cat /usarc/gruppa/ivanov/file1.c
2 pr /usarc/gruppa/ivanov/file1.c
3 cc pa1.c pa2.c pa3.c pa4.c >>& errors &
4 cat errors
5 ed program.c
6 history
, -
, :
- 47 -
!1:0 !1^:t:r
1 0, ..
, cat.
1,
/usarc/gruppa/ivanov/file1.c. t
,
/usarc/gruppa/ivanov,
file1.c. r .
, cat file1.
!1:0 !1^:h/document
^
, h ,
, ,
cat /usarc/gruppa/ivanov/document
!1:0 !1^:h:s?ivanov?sidorov?/document
-
, , s
ivanov sidorov
cat /usarc/gruppa/sidorov/document
!1:0 !1^:h:s?ivanov?sidorov?/doc !1^:&:p
. 1
1,
( & ), , ..
?ivanov?sidorov?,
. ,
( p):
cat /usarc/gruppa/sidorov/doc \
/usarc/gruppa/sidorov/file1.c
!1:0 !3:1-4:gs?pa?ff?:p
, 3
1 4 -
( g)
?pa?ff? . , -
( p):
cat ff1.c ff2.c ff3.c ff4.c
-
. -
^^^. ,
cat aaa bbb ccc ddd, ^ccc^file.c^
- 48 -
: cat aaa file.c ccc ddd.
. -
. -
, , -
, . , -
alias sp "sort \!* | print"
sort file1 file2 | print
sp file1 file2
. !* -
sort, -
sp.
,
,
alias unalias.
, ,
, , -
, . ,
. -
! . -
. csh,
alias a alias
alias.
1.12. csh
csh :
.
,
, .
(
) . , argv
, ver-
bose
.
. .
-
- 49 -
.
.
-
- -
. ,
.
: argv, cdpath, cwd, home, path, prompt,
shell. child status
. set
csh. -
unset. -
.
argv
. -
.
cdpath
,
. ,
cdpath : set cdpath = (
/usr/include /usr/lib ), chdir sys -
chdir /usr/include/sys.
checktime
-
- ,
exit. , set
checktime = 3, , 3 -
- , exit, -
.
child
.
. child -
, .
cwd
-
. -
, symlink.
echo
.
. echo
,
. ,
csh -x comfile echo
comfile, set echo -
.
- 50 -
history
-
, .
. - 22 .
home
. -
csh HOME.
ignoreeof
-
.
/D CTRL/D .
stty(1).
mail
, .
noclobber
.
noglob
.
nonomatch
, (, echo *.[2-
5]) , -
. nonomatch,
, -
.
notify
. notify ,
.
path
,
, .
-
, path.
.
, .. -
, ,
-,
.
rehash. rehash
-,
.
~/.cshrc -.
,
- 51 -
, -
-f
csh -f comfile
- ,
set -
path.
prompt
,
. -
,
. prompt -
, % -
# .
shell
,
. -
SHELL
.
status
, :
% false ; echo $status
1
% true ; echo $status
0
false 1 -
, true 0 -
.
time
. -
,
. ,
~/.cshrc set time = 6, ,
-
, -
6 . , , sort
file,
:
1.6u 17.9s 0:26 74%
: 1.6u - ;
17.9s - ; 0:26 - -
; 74% -
-
.
- 52 -
verbose
. ,
-v -
.
-
.
:
csh -_ _ ...
_ , -
.
:
-c ,
-c;
-e ,
( 0);
-f ~/.cshrc
;
-i .
,
;
-n ,
. ;
-s ;
-t .
\;
-v
;
-V ~/.cshrc ~/.login
-v.
,
-
;
-x -
;
-X -x ~/.cshrc
~./login.
- 53 -
- ,
.
,
. -
set unset.
, -
.
.
setenv, - unsetenv. -
,
setenv.
.
,
. -
. -
. , -
.
:
PATH
, ;
HOME
,
/etc/passwd;
TERM
;
TERMCAP
/etc/termcap;
SHELL
, -
;
MSG
,
(MSG = r - -
, MSG = l - );
USER
.
unsetenv
. setenv
- 54 -
% setenv NAME 15
% echo $NAME
15
% @ a = ( $NAME + 15 )
% echo $a
30
% setenv NAME "Jan Feb Mar Apr"
% echo $NAME
Jan Feb Mar Apr
-
, .
1.13.
: ~/.hushlogin, ~/.login,
~/.cshrc, ~/.logout ~/.history.
~/.hushlogin .
,
/etc/motd - -
. /etc/motd
, "" ..
~/.login ~/.cshrc, -
~/.logout.
~/.cshrc, ~/.login. -
~/.history, .
, ~/.history,
, -
.
~/.login , -
.
:
set ignoreeof
set prompt = ' .._\!> '
if( $?MAIL ) set mail = $MAIL
msgs
setenv MSG r
ignoreeof,
/D (CTRL/D).
- 55 -
,
. \!
history, :
.._15>
.
, :
" ".
mail, .
msgs,
( , -
).
MSG,
( - ,
l).
~/.logout
.
.
~/.logout ,
. , , -
, , -
, .
csh ~/.cshrc.
~/.cshrc:
set path = ( . /bin /usr/bin /usr/ucb )
set history = 22
set savehist = 22
set checktime = 3
set prompt = ' .._\!> '
alias h history
alias c /bin/cat
alias l /bin/ls -l
set path = (. /bin /usr/bin /usr/ucb)
, csh
.
set history = 22
,
.
set savehist = 22
,
- 56 -
~/.history.
.
set checktime = 3
(3 ), csh
"". -
- ,
exit csh .
,
.
set prompt = ' .._\!>'
, csh
. -
,
.
-
. , ~/.login -
- ;
~/.cshrc .
1.14.
,
.
alias
alias
alias _
alias
. -
, alias,
.
, -
, , -
. -
.
alloc
,
,
.
.
bg
bg %__
bg %__
- 57 -
-
.
break
end
foreach while. -
-
break , ;.
breaksw
switch
endsw;
case :
- switch.
-
( *, ?, [...] ). .
cd
cd
chdir
chdir
.
,
.
continue
while
foreach. end , -
.
default:
switch.
, case, -
, default.
default case. -
.
dirs
.
pushd,
popd.
1,
.
echo _
echo -n _
. -n
.
- 58 -
else
end
endif
endsw
. foreach, if, switch
while.
eval ...
, eval
,
, .
exec
.
.
exit
exit()
( )
( ). -
status .
fg
fg %__
fg %__
( )
.
foreach (_)
...
end
-
end (foreach end
).
glob _
echo.
.
, -
.
- 59 -
goto
.
, .
:.
goto , ,
.
.
hashstat
, , -
-
. .
history
history -r
history n
history -r n
history -h
. -r -
. n,
n . -h -
~/.history.
if()
( ),
. . -
/ .
, .
if(_1) then
...
else if(_2) then
...
else
...
endif
_1 ,
else. , _2
, else ..
else-if; endif
. else .
else endif ,
. if
else.
jobs
jobs -l
- 60 -
. jobs -l
.
.
ps jobs -l, - jobs.
,
. -
. + -
; - -
.
kill %__ ...
kill -SIG %__ ...
kill %__ ...
kill -SIG %__ ...
kill __ ...
kill -SIG __ ...
kill -l
SIG , TERM
(). SIG ,
SIG (
/usr/include/signal.h). kill -l
.
limit _ _
limit _
limit
32- -
, .
,
, ,
. ,
;
_ ,
.
cputime (
, ),
filesize (
, ),
datasize ( _+_
sbrk(2) ),
stacksize ( -
), coredumpsize
( , ).
( ),
- 61 -
.
.
login
login
login .
login
.
.
logout
. ~/.logout, ,
.
.
nice
nice +
nice -
nice
nice +
nice -
.
: [-100; +100], +100
.
, 4, - ,
, - , -
4.
.
,
.
, .
nohup
nohup
SIGINT (CTRL/C), SIGQUIT
(CTRL/\) SIGHUP (BREAK - -
).
, . ,
-
. nohup -
.
- 62 -
notify %__
notify %__
notify
-
. -
. notify ,
.
onintr
onintr -
onintr
. -
,
.
.
-
- . ,
csh , onintr -
.
popd
popd +
cd __2 .
__1 , -
.
popd + __(1+)
,
. -
.
pushd
pushd _
pushd +
pushd
. pushd cd
__2 . __2
, __1 - ; -
.
pushd _ cd _,
_ ,
.
pushd + cd
- 63 -
__(1+). __(1+) -
, -
, -
,
.
rehash
-.
repeat
repeat
.
, -
, .
set
set
set =
set [] =
set = (_)
set _
set -
. ,
, -
.
, -
, - ,
- .
-
.
.
-
. -
. -
-
.
setenv
setenv
,
.
unsetenv.
shift
shift
.
. shift
- 64 -
.
source
. source
. source
. source
.
stop %__
stop %__
.
suspend
.
switch( _ )
case _1:
...
breaksw
...
default:
...
endsw
case -
. case
*, ? [...].
case switch
.
,
default. case default
. breaksw
, endsw. case
breaksw,
breaksw default.
default
, endsw.
time
time
,
.
.
umask
umask
- 65 -
,
. ,
( 0) ,
( 1) . 123.
-
, -
, - -
.
. 002,
,
,
022, (
) .
,
umask .
unalias ...
, ,
. , unalias * -
.
.
unhash
- .
unlimit
unlimit
. ,
.
unset
,
. , unset *
, set.
unsetenv
.
wait
.
wait, . wait
,
.
wait (CTRL/C /C)
, .
while( )
...
end
- 66 -
, ( )
. while end -
. -
break continue -
-
.
- 67 -
......................................... 2
1. C-shell ............................ 3
1.1. C-shell ............. 3
1.2. ,
......................................... 6
1.3. ..................... 9
1.4. ........................... 11
1.5. ................. 17
1.6. ................. 19
1.7. ......................... 26
1.8. ....................................... 30
1.9. C-shell ......................... 35
1.10. ................................. 39
1.11. , .. 44
1.12. csh ................... 49
1.13. ............................... 55
1.14. .................. 57
- 68 -
Last-modified: Mon, 29 Jun 1998 13:54:54 GMT