Syntax errors are misspellings or missing pieces of code in a script. These are usually the easiest errors to spot because they
generate an error message when you try to run the code. The shell will try to identify which line of your script is causing the error.
The following code has a syntax error. There should be no space before the equal sign.
Logic errors often are the most difficult to locate. When your code tests for the wrong value, you have a logic error.
For example, if your program is supposed to print out the last five lines in a file and it instead prints out the last four, you have a logic error.
With this type of error, your code will run with no syntax errors identified, making the error hard to spot.
You may have to examine your code line by line to find the error.
The following code checks for the value “mo” instead of the value “no”.
if["$answer" = "mo" ]
then echo "I will exit the program now"
The next lesson explores options to the shell that help identify the errors in a script.