zoukankan      html  css  js  c++  java
  • [: 11: y: unexpected operator问题

    《私房菜》上的shell脚本问题:

    转载:[: 11: y: unexpected operator问题

    脚本如下:%

    #!/bin/bash
    # Program:
    #    This program shows the user's choice
    # History:
    #2018/01/03
    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin& 
    export PATH
    
    read -p "Please input (Y/N): " yn
    [ "$yn" == "Y" -o "$yn" == "y" ] &&echo "OK, continue" && exit0
    [ "$yn" == "N" -o "$yn" == "n" ] &&echo "Oh, interrupt!" && exit0
    echo "I don't know what your choice is"&& exit 0

    执行时总提示错误9

    Please input (Y/N): y
    [: 10: y: unexpected operator
    [: 11: y: unexpected operator
    I don't know what your choice is

    因为ubuntu默认的sh是连接到dash的,又因为dash跟bash的不兼容所以出错了.执行时可以把sh换成bash文件名.sh来执行.成功.dash是什么东西,查了一下,应该也是一种shell,貌似用户对它的诟病颇多.
    by the way修改sh默认连接到bash的一种方法:
    sudo dpkg-reconfigure dash0 Q$ c+ `. U+ c2 K
    选择no即可.

  • 相关阅读:
    DNS部署与安全
    DHCP部署与安全
    jenkins漏洞复现
    Apache Axis2 漏洞复现
    制作war包
    JBOOS 漏洞复现
    Tomcat漏洞复现
    编写登陆接口(2)
    学习使用新工具Pycharm
    while练习99乘法表
  • 原文地址:https://www.cnblogs.com/winterfells/p/8185406.html
Copyright © 2011-2022 走看看