bash比较变量和变量+字符串

这个问题在这里已经有了答案:

  • 如何连接Bash中的字符串变量27个答案

  • 我没有AWS CLI的东西,所以这里是存根的例子:

    task_name () {
      echo "$task"
    }
    state () {
      echo "$task RUNNING"
    }
    
    task_status () {
      tasksInCluster=(mis-dev-core mis-dev-other "mis-dev with space")
      for task in "${tasksInCluster[@]}"; do
          if [ "$(state)" != "$(task_name) RUNNING" ] 
          then
            echo "$(task_name)" "NOT RUNNING!"
            exit 1
          else
            state
          fi
      done
    }
    
    task_status
    

    更新:正如@ charles-duffy所述,使用数组而不是字符串。

    链接地址: http://www.djcxy.com/p/29137.html

    上一篇: bash compare variable and variable + string

    下一篇: Append string to file names with bash