标题: 关于csh的疑惑 [打印本页] 作者: jiannma 时间: 2009-09-18 18:46 标题: 关于csh的疑惑 关于csh 的位置参数和命令行参数的理解:
比如我想写个脚本:
1)取得一个命令行参数,一个用户的注册名
2)测试下。看是否提供一个命令行参数
3)如果用户存在于/etc/passwd文件
则打印: Found <user> in the /etc/passwd file
否则则打印:
No such user on our system
我是这样写的:
#!/bin/csh
if { (cat /etc/passwd |grep $1 ) } then
echo "Found [color=Red]$1[/color] in the /etc/passwd file "