An error was encountered
Execute the command $./example03. Sh
error:
./example03. Sh: 3: syntax error: “(” unexpected
check the document
#!/bin/sh
#function hello
function hello(){
echo "hello SXU."
}
#main
hello
exit 0
Confirm again and again that there is no error.
Find the reason
Related to the actual shell version used
use the command LS - L/bin/* sh
to print and view. For example:
you can see that SH is redirected to dash. Therefore, if./example.sh is executed, dash is used.
Solution:
bash example. Sh
the first line of the script #/ Change bin/sh to: #/ Bin/bash, and then execute./example. Sh. The code is correct for standard bash, because Ubuntu/Debian uses dash instead of traditional bash in order to speed up startup. The solution is to cancel Dash: sudo dpkg reconfigure dash
, and select no in the selection, choose one of the three methods to succeed.
Read More:
- .sh error: ***.sh: 2: set: Illegal option – Solution
- How to Solve hadoop3.x.x sh start-dfs.sh Startup Error
- line 1: syntax error: unexpected “(“ [How to Solve]
- [Solved] The Shell Script error: syntax error: “(” unexpected “)
- [Solved] SHELL Run Error: “-BASH: ./TEST.SH: /BIN/BASH^M: BAD INTERPRETER: NO SUCH FILE OR DIRECTORY”
- How to Solve Error: “syntax error near unexpected token `newline’”
- Refresh 404 after packaging Vue project, uncaught syntax error: unexpected token <
- [Solved] Error: Waveform5.vwf.vt(30): near “1“: syntax error, unexpected INTEGER NUMBER, expecting ‘)‘ Erro
- [Solved] Error c2226: syntax error: unexpected ‘lpstr’ type
- [Solved] .\main.go:3:6: missing function body .\main.go:4:1: syntax error: unexpected semicolon or newline be
- Template cannot be rendered due to the joint query of populate in mongoose: syntax error: unexpected token r in JSON at position 0
- [Solved] Quartus II waveform simulat error: error: waveform2 vwf. VT (30): near “,” syntax error, unexpected “, ‘# * * error
- PHP Parse error: syntax error, unexpected ‘class‘ (T_CLASS), expecting identifier (T_STRING)
- [Solved] kettle Error: Unexpected problem reading shared objects from XML file: null
- How to Solve bootstrap.sh error during the construction of fabric environment
- [Solved] Unexpected error while saving file: xxx.ipynb database or disk is full
- [Solved] Faceswap Error: CRITICAL An unexpected crash has occurred.You MUST provide this file if seeking assistan
- [Solved] winnt.h a large number of file errors (287): error c2059: syntax error: “;”
- [Solved] Virtualenvwrapper.sh error: There was a problem running the initialization hooks.
- start-all.sh Execute error: Stopping journal nodes [slave2 slave1 master]…