LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 691|回复: 2

求助: set i=$<

[复制链接]
发表于 2007-4-26 10:17:19 | 显示全部楼层 |阅读模式
有这样的一段shell小程序:
#!/bin/bash   #原文是#!/usr/bin/csh
echo "lease enter a number.."
set i=$<
if ( $ i< 20 )then
echo "$ i is less than 20"
else if ( $ i==20 ) then
echo "$ i is equal to 20"
else
echo "$ i is greater than 20"
endif
这段小程序不能执行,显示执行结果如下:
bash: ./a: cannot execute binary file
还有 set i=$ < 单独也不能执行 其执行结果如下:bash: syntax error near unexpected token `newline`
恭请高手指点迷津,先行谢过!!
发表于 2007-4-26 10:32:25 | 显示全部楼层
改成/bin/bash的话要用下面的写法:


  1. #!/bin/bash
  2. echo "Please enter a number.."
  3. read i
  4. if [ $i -lt 20 ]; then
  5.     echo "$i is less than 20"
  6. elif [ $i -eq 20 ]; then
  7.     echo "$i is equal to 20"
  8. else
  9.     echo "$i is greater than 20"
  10. fi
复制代码
回复 支持 反对

使用道具 举报

发表于 2007-4-26 10:46:51 | 显示全部楼层
我还在纳闷呢,写得什么语句阿,原来是csh
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表