Problem phenomenon:
Run shell script: Syntax error near unexpected token ‘$’ do\r
Problem analysis:
Nodepad++ does not show a $sign, it should be hidden
Causes:
Open notepad++ and click view -> Display symbol -& GT; Displays all symbols and finds that the return newline characters on Linux and Windows are incompatible
Unix is: & lt; LF> : /n
Run shell script: Syntax error near unexpected token ‘$’ do\r
Problem analysis:
Nodepad++ does not show a $sign, it should be hidden
Causes:
Open notepad++ and click view -> Display symbol -& GT; Displays all symbols and finds that the return newline characters on Linux and Windows are incompatible
Unix is: & lt; LF> : /n
DOS is: < CR> < LF> : /r/n
MAC is: < CR>/r:
Problem Solving:
Use the DOS2UNIX tool for processing.
Install DOS2UNIX on Linux: Sudo Apt-get install dos2UNIX (install with different commands depending on the system)
After a successful installation, you can define a shell script or execute a command manually
Dos2unix *. Sh
So, as you can see: dos2UNIX: converting File eval1.sh to Unix format…
This will convert this file to an executable file under Linux.
Read More:
- Solve the problem of shell script “syntax error near unexpected token `fi’”.
- Shell script execution error: “syntax error near unexpected token”
- Syntax error near unexpected token `newline’script cannot be executed
- Solve the problem of syntax error: unexpected end of file or syntax error near unexpected token ` fi ‘error
- Shell script: syntax error: bad for loop variable error resolution
- Solution to shell script error “expr: syntax error”
- syntax error near unexpected token `then’ problem solution
- Unexpected syntax error: unexpected token<
- Syntax error: unexpected token in uni app project compilation
- [shell] sh executes the script and reports an error syntax error: “(” unexpected “)
- Syntax error near unexpected token ‘$’Do is reported when running bash file
- Docker machine install syntax error near unexpected token ‘newline’! DOCTYPE HTML problem resolution
- Uncaught syntax error: unexpected token ‘< 0‘
- syntax error near unexpected token `else’
- Error: unexpected syntax error: unexpected token<
- Error: syntax error – unexpected token P in JSON at position 0
- Baidu editor echo JS error uncaught syntax error: invalid or unexpected token
- About writing [if] and [else] statements in JSP, Syntax error on token “else”, delete this token
- Syntax error on token “}“, delete this token
- [development experience] solution to unexpected syntax error: unexpected identifier in JSON parsing