正文

C shell学习笔记(一)综合2006-07-19 14:15:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/fred/16682.html

分享到:

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:     #!/bin/csh     echo “The command name is : $0”     echo “The number of command line arguments are $#argv”     echo –n “The value of the command line arguments are:”     echo “$argv[1] $argv[2] …”     echo “Another way to display value of all of the arguments : $argv[*]”     exit 0 9-1   if (…) then          …       else if (…) then           …       else if (…) then           …       else           …       endif 9-2   foreach variable (argument list)           command list       end 9-3  while (expression)          …(真时)      end(假时) 9-4  switch (“$string”)          case “yangfeng”:             …          breaksw          case “panye”:             …          breaksw          default:             …          breaksw      endsw 10 数值变量       eg. @ a=10          @ b=15          @ difference = ( $a - $b ) sum = ( $a + $b )          @ a++          @ a+=1          @ area = $a*$b 11 数组 set xxx = (…………………………)        $#xxx元素个数  $?xxx是否初始化(返回1表示已初始化)        $xxx   $xxx[i]     用set命令对任何shell变量赋以多个值,将会使其成为一个数组 12 连接多个字符串eg.set thisfile=”$directory”/”$file[$index]”  

阅读(3877) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册