博文
C shell学习笔记(一)综合(2006-07-19 14:15:00)
摘要:
C shell学习笔记(一)综合
1 #!/bin/csh
2 可用set与env命令查看环境变量与当前值
3 @、set xxx=xxx 设置局部数值变量/变量;setenv 设置全局变量
eg. set name 赋空值
set name = (John Doe)
setenv name “John Doe”
4 命令替换
eg. set command = `pwd`
echo “The … is : $command”
显示:The … is : /…/…
5 所有UNIX命令在执行成功时传回一个退出状态0,在失败时传回非0。一个命令传回的状态值被保存在只读环境变量$?中,可以由调用进程检查。
6 从标准输入读
set xxx=$<
或者set xxx=`head –l`
eg. #!/bin/csh
echo –n “Enter input:”
set line=`head –l`
echo “You entered: $line”
exit 0
7 unset xxx
unsetenv xxx
8 向脚本传递参数 eg:
......