If you run into problems building, testing or running complex bash scripts, don’t lose heart. There are many ways you can help ensure that your scripts will work flawlessly. In this post, we’ll examine some ways you can lessen the likelihood of errors and how to go about doing some simple but very effective troubleshooting.
Through a combination of robust logic that tests for possible problems and some troubleshooting to help detect errors, your scripts are likely to be ready for showtime very quickly.
Summarizing your command-line usage on Linux
Building the outer edges first
One way to avoid syntactical errors in scripts is to start your for and while loops, case statements and if/then commands using the outer logic first. If you start your script logic using a syntactical “skeleton”, you won’t forget to end it properly.
Source:: Network World – Linux