linux shell script问题

极光默尘 2011-01-06 02:32:54
谁能帮我看下为什么下面的代码没法运行,而是显示“declare:not found" 还有一些错误的信息
declare -i number
for option in $@
do
number=number+1
case $option in
-f)
date=`date +%Y%m%d`
host=`hostname`
if [ $number -eq 1 ];then
echo "檔案無資料儲存"
break
else
number=number+1
file=`echo $@ | cut -d " " -f $number`
if [ "$file" != "" ];then
print_time>>"$file.$date"
print_user>>"$file.$date"
print_disk>>"$file.$date"
else
print_time>>"$host.$date"
print_user>>"$host.$date"
print_disk>>"$host.$date"
fi
break
fi
;;
*)
echo "$option command not found"
exit 1
esac
done
...全文
100 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
freetstar 2011-01-06
  • 打赏
  • 举报
回复
lz用的什么shell?

我感觉lz应该是没有指定shell
加这个#!/bin/bash
yifanernei 2011-01-06
  • 打赏
  • 举报
回复
第一行加上
#!/bin/bash
你默认的shell是bash吗?

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧