Ubuntu9.04 shell programming [: 10: Y: Unexpected Operator

Source: Internet
Author: User

According to the shell programming of laruence's private dish, there is an inexplicable problem.
For example:

# Test if else

 

Read-P "input y/n? : "YN

If [$ YN = "Y"]; then

Echo "continue ;"
Elif [$ YN = "N"]; then
Echo "break ;"
Else
Echo "PLS input something ."
Fi

 

 

During execution, the [: 12: Y: Unexpected Operator
Instead, I ran to the terminal and entered it according to the shell command. It was a success and I couldn't help but sigh again about the strange problem.

Finally, I found the answer on the Internet:
First:

Original address: http://www.ylmf.net/read.php? Tid = 1377788 & page = E & fpage = 5

Because the default SH of Ubuntu is connected to dash, and the dash and bash are incompatible, an error occurs. during execution, you can replace sh with the bash file name. sh to execute. successful. dash is something. After checking it, it should also be a shell, which seems to be a lot of criticism from users.
By the way, modify sh to connect to bash by default:
Sudo dpkg-reconfigure dash
Select No.

Second:
See the results of others' discussions in a forum.

Change = To =. Dash uses = to judge that the string is equal.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.