【问题标题】:Unix shell scripting return code error with for loop带有for循环的Unix shell脚本返回代码错误
【发布时间】:2016-04-20 20:14:04
【问题描述】:

我被困在一个有一个 if 循环和一个 for 循环的脚本中,PFB 是我在行中得到 语法错误的代码:`((' 意外

 if [ $? = 0 ]; then
 for (( count=0; count<=number; count++ ))
    echo " statement"
done

else 
 echo " Else statement executed "
fi

谁能帮我解决这个问题...?

【问题讨论】:

  • 我是 unix shell 脚本的新手...如果不是循环是什么意思...?
  • 你写了你有一个if。没有一种编程语言的 if 是一个循环。

标签: shell unix scripting


【解决方案1】:

您缺少 donefi

#!/bin/bash
number=4
if [ $? = 0 ]; then  
  for (( count=0; count<=number; count++ ))
  do
      echo "df"
  done
fi

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 2012-04-06
    • 2013-12-21
    • 2022-05-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多