首页 > 解决方案 > 如何在bash中逐行执行if语句

问题描述

如何在bash中逐行执行if语句?

for i in $(cat $install_script)
do
    if [ "$i" = "$check" ]; then
        count=$((count+1))
        echo whiptail --title "Install SmartBoard" --yesno "${scripts_name[$count]}" 7 $((${#scripts_name[$count]} + 5))
        if (( $? == 0 )); then
            skip=false
        else
            skip=true
        fi
    fi
    if [ "$i" == "$check wifi" ]; then
        break
    fi
    if [ $skip == true ]; then
        continue
    else
        sh -c $i ## process line by line
    fi
done

错误 !!

sh: 1: Syntax error: end of file unexpected (expecting "then")

sh: 1: Syntax error: "then" unexpected

sh: 1: Syntax error: "else" unexpected

sh: 1: Syntax error: "fi" unexpected

我英语不好,所以如果我的帖子很粗鲁,对不起。:(

标签: bash

解决方案


推荐阅读