alias m more 为more创建别名m。
alias 列出所有的alias。
unalias m 用来删除more的alias定义。
11)初始化文件
.login 在登录时执行的文件。
.cshrc 在每次调用shell时都执行的文件。
12) label 和 goto
csh中没有函数的概念,使用类似windows批处理中的label和goto。
goto label
......
label:
....
13) if/else/switch/case
if(expression)then
commands
endif
if {(command)} then
commands
endif
if(expression) then
commands
else if(expression) then
commands
else
commands
endif
switch("$value")
case pattern1:
commands
breaksw
case pattern2:
commands
breaksw
default:
commands
breaksw
endsw
14 while/foreach
while(expression)
commands
continue
break
end
foreach var (wordlist)
commands
end
15、repeat
repeat表示重复执行后面的命令。
repeat 3 "echo helloworld"
16、csh中设置环境变量PATH的方法
csh中使用path代替PATH,设置类似于数组的使用。
set path = ($path /home)
echo $path
echo $PATH
17、source等价于其他shell中的.
source使得程序在当前的shell中被执行,而不是派生子进程来执行。
18、转义字符与单双引号
引号必须成对出现,而且必须在同一行上配对。可以用反斜杠来转义换行符,这样就能在下一行配对了。
单引号可用于保护双引号,双引号也可以用来保护单引号。
单引号保护除历史字符(!)之外的所有元字符不被解释。
双引号保护除历史字符(!),变量替换字符($)和反引号(用于命令替换)之外的所有元字符,使其不被解释。
19、历史command
history用来查看command执行的历史。
!!用来执行上一条命令。
20、pushd和popd用来维护目录栈
21、csh -vx用来显示输入的原样和变量替换后的脚本,用来帮助调试。
22、在脚本中处理中断
onintr finish
<script continues here>
finish:
onintr - # Disable further interrupts
echo Cleaning temp files
exit 1
onintr 命令后跟一个标号名,finish是用户自定义的标号。如果发生中断,控制将被转移到finish标号。通常该行位于脚本的开头。除非当程序正在执行时按ctrl+C(中断键),此时控制将被转移到该标号。onintr - 表示屏蔽所有的中断,此时按下ctrl+C将会被忽略。










