Syntax errors
Nothing can be so frustrating than to be on a roll when coding your script or program and then have a syntax error pop up. In some cases the solution is so easy you find and solve it right away. In other cases it can take minutes or even hours. Here are a few pointers:
When coding a loop put the whole while...do...done
structure in first. It is sometimes really easy to forget the ending done
statement, especially if the code spans more than a page.
Take a look at Script 1:
Chapter 9 - Script 1
#!/bin/sh # # 6/7/2017 # echo "Chapter 9 - Script 1" x=0 while [ $x -lt 5 ] do echo "x: $x" let x++ y=0 while [ $y -lt 5 ] do echo "y: $y" let y++ done # more code here # more code here echo "End of script1" exit 0
And here is the output:

Look at this real closely, it says the error is at line 26. Wow, how can that be, when the file has only has 25 lines in it? The simple answer is that's just the way the Bash interpreter handles this type of situation. If you have not already found...