A statement like this is used when matching strings
if[ $ timeofday = ” yes”]; then
echo ” Good morning”
exit 0
The reason for the error is: if the value of the variable timeofday is empty, the if statement becomes if [ =” yes” ], This is not a legal condition. To avoid this, we must quote the variable if [ “$ timeofdat”=”yes” ], In this way, even null variables provide legal test conditions, if [ ” “=” yes” ]
Similar Posts:
- Shell script error: ‘[: =: unary operator expected’
- Shell script execution error [: 0: unary operator expected
- String null space error: binary operator expected
- Perl : Quantifier follows nothing in regex; marked by
- Solutions to the problem of too many arguments in Linux Bash
- nginx using uninitialized “XXXX” variable while logging request
- Linux: Environment Variables C_INCLUDE_PATH, CPLUS_INCLUDE_PATH, CPATH Common Error [How to Solve]
- The solution of typeerror: expected string or buffer
- Script error: unary operator expected [How to Solve]
- HTTP Status 500 – An exception occurred processing JSP page /common/../left.jsp at line 20