linux - shell 脚本 -o 操作不起作用

标签 linux bash scripting shell

DISPLAY_HEADER=1
 if [ "$1" != "test" -o "$1" != "test2" ]
    then
        if [ $DISPLAY_HEADER == 1 ]; then
                DISPLAY_HEADER=0
                echo "sdasa "
                echo $1
        fi
   fi

它的显示 sdasa 和 -o 不工作?

怎么了?

最佳答案

你可以使用 case/esac

case "$1" in
  test|test2) 
    # do something
  *) 
    # set display data 
    ;;
esac

关于linux - shell 脚本 -o 操作不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3438671/

相关文章:

c++ - 我的 CMakeList.txt 出了什么问题?

linux - 使用 Shell 脚本内容保存文件

linux - 使用for循环在每个单词前后添加3个星号

linux - 在 Linux 交互使用中是否有任何 bash 符号来表示重定向操作数?

bash - 获取 shell 脚本错误的行号

python - 使用 Python 在 linux 终端中显示图像

database - 只读,相当小的数据库 - 优化方法?

unix - 可移植社帮线

linux - 在 Crontab 中删除现有的作业/任务

bash - 如何使用 shell 脚本从第二列中选择一个值?