初学liunx 在网上拷贝了段代码 运行报错

火山1 2012-01-18 04:51:01
#!/bin/ksh
# This is my test shell (ksh)
# name file : sort directory and executable file and link file
clear
print " "
print " "
print " **************************************************"
print " sort directory and executable file and link file"
print " **************************************************"
print " "
print " "
print " "
print " Hi $(who i am | cut -c 1-6), nice to see you ! "
print " Your present information . "
print " OS : $(uname -s) IP : $(who i am | cut -c 35-48)"
print " Machine : $(uname -p)"
print " Currently work directory : $(pwd) "
print " "
while (true)
do
print " "
print -n " Please enter sort path (enter x logout!) :";
read path1 ;
print " Your enter path :" $path1;
print " "
case $path1 in
x)
print " Thank you test this ksh Script ! "
print " Good luck ! "
exit 1 ;;
~)
if ( $LOGNAME == root)
then
print " Directory :" $(ls -l /root | grep -c 'd[r-][w-][x-]')
print " Exexutable file :" $(ls -l /root |grep -c '[d-][r-][w-]x')
print " Link file : " $(ls -l /root | grep -c 'l[r-][w-][x-]')
else
print " Directory :" $(ls -l /home/$LOGNAME | grep -c 'd[r-][w-][x-]')
print " Exexutable file :" $(ls -l /home/$LOGNAME |grep -c '[d-][r-][w-]x')
print " Link file : " $(ls -l /home/$LOGNAME | grep -c 'l[r-][w-][x-]')

fi
next ;;
*)
if [ ! -d $path1 ]
then
print " Youre enter path no availability !"
elif
then
print " Directory :" $(ls -l $path1 | grep -c 'd[r-][w-][x-]')
print " Exexutable file :" $(ls -l $path1 |grep -c '[d-][r-][w-]x')
print " Link file : " $(ls -l $path1 | grep -c 'l[r-][w-][x-]')
fi;;
esac
done


报错:syntax error at line 46: 'elif' unexpected
...全文
95 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
火山1 2012-01-18
  • 打赏
  • 举报
回复
但是我将elif then 改成else 也报错
Setarcos 2012-01-18
  • 打赏
  • 举报
回复
elif 后面没有条件就直接 then 了么?
其实不懂 ksh,但看这里比较奇怪。

23,116

社区成员

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

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