[Linux] I just learned shell and encountered a problem. The total error occurred during execution: Unexpected Operator

Source: Internet
Author: User
I just learned shell and encountered a problem. The total error occurred during execution: Unexpected
Operator. I used Ubuntu 9. 04. I learned from laruence to go to the shell script section,

The script is as follows:

#! /Bin/bash

# Program:

#       This program shows the user's choice

# History:

#2005/08/25       Vbird       First release

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" & Exit 0

["$ YN" = "N"-o "$ YN" = "N"] & Echo "Oh, interrupt! "& Exit 0

Echo "I don't know what your choice is" & Exit 0


Error prompted during execution

Root @ dustsnow-LAPTOP :~ /Scripts # sh sh06.sh

Please input (y/N): Y

[: 10: Y: Unexpected Operator

[: 11: Y: Unexpected Operator

I don't know what your choice is


But it is correctly executed in the fedora 11 System of the VM.


The solution cannot be found online.

Have you encountered the same problem,

Thank you first


Solution: solve the problem on the Ubuntu Chinese forum.

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.

Reference: http://hi.baidu.com/nako521/blog/item/248fee953b52454fd1135eb7 . Html

I do not know whether the summary is accurate. If any error occurs, please correct me.Reprinted: http://blog.sina.com.cn/s/blog_63484d2d0100mdfn.html

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.