According to the shell programming example of "laruence's house cooking", there is an inexplicable problem. For example, the file name is sh06.sh :#! /Bin/bash # Program: # Thisprogramwillshowtheuser 'schice # History: #2010/08/01 cnhjqFirstreleasePATH =/B
According to the shell programming example of "laruence's house cooking", there is an inexplicable problem.
For example, the file name is sh06.sh:
#! /Bin/bash
# Program:
# This program will show the user's choice
# History:
#2010/08/01 cnhjq 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 is you choice" & exit 0
During execution, the [: 10: y: unexpected operator
In the terminal, the command in shell is directly input by line, and the operation is successful. I can't help but sigh again about the strange problem.
Finally, I found the answer on the Internet:
First:
The default sh in Ubuntu is connected to dash, and an error occurs because of the incompatibility between dash and bash. During execution, you can replace sh with the bash file name. sh for execution (such as bash sh06.sh ). Successful.
What is dash! Ask baidu or google!
Modify sh to connect to bash by default:
Sudo dpkg-reconfigure dash
Or this should also be possible:
Alias sh = 'bash'
Second:
See the results of others' discussions in a forum.
Change = To =. dash uses = to judge that the string is equal.