小编use*_*648的帖子

bash脚本:如何在for循环中使用嵌套if

#! /bin/bash

count=1
step=(a b)

for x in 0 1
do
    if [[ $count != '0' ]]; then
        if [[ ${step[x]} = "a"]]; then
            echo "Python test ($count)"
        else
            echo "stress test"
        fi
    fi
done
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

syntax error in conditional expression: unexpected token `;'
line 20: syntax error near `;
line 20: `        if [[ ${step[x]} = "a"]]; then'
Run Code Online (Sandbox Code Playgroud)

为什么?

bash scripting

4
推荐指数
1
解决办法
4115
查看次数

标签 统计

bash ×1

scripting ×1