Reading shell scripts is the best way to understand how a Unix-like system works. Here, I give some pointers and reminders for shell programming. See Shell Mistakes to learn from mistakes.
Shell Mistakes