#! /bin/bash
#if program test
echo ‘a:’
read a
If [“$a” = “English”]; then
echo “right”
else
echo “wrong”
fi
I wrote the shell script according to the procedure on the video, but “syntax error near token ‘then'” appeared during the execution. After looking at the syntax error near token’ then’ for half a day, I did not find out the reason. After searching the Internet for a long time, I finally understood the reason: There is no space between if and ‘[‘. In addition, when executing, I also found that there must be space on both sides of’ = ‘, otherwise there will be an error, not a syntax error, but no matter what value is assigned to a, the program will get the statement after if is false, thus resulting in wrong.
Read More:
- Solve the problem of syntax error: unexpected end of file or syntax error near unexpected token ` fi ‘error
- Solve the problem of shell script “syntax error near unexpected token `fi’”.
- Docker machine install syntax error near unexpected token ‘newline’! DOCTYPE HTML problem resolution
- syntax error near unexpected token `else’
- Unexpected syntax error: unexpected token<
- Syntax error near unexpected token `newline’script cannot be executed
- Syntax error near unexpected token ‘$’Do is reported when running bash file
- Uncaught syntax error: unexpected token ‘< 0‘
- Syntax error: unexpected token in uni app project compilation
- Shell script syntax error near unexpected token ‘$’Do
- [development experience] solution to unexpected syntax error: unexpected identifier in JSON parsing
- Solve the Java “syntax error on token enum” problem
- Shell script execution error: “syntax error near unexpected token”
- Error: syntax error – unexpected token P in JSON at position 0
- Error: unexpected syntax error: unexpected token<
- About writing [if] and [else] statements in JSP, Syntax error on token “else”, delete this token
- Baidu editor echo JS error uncaught syntax error: invalid or unexpected token
- Syntax error: unexpected end of file problem [two solutions]
- Syntax error on token “}“, delete this token
- Front end project runtime prompts syntax error: typeerror: token.type.endswith is not a function solution