Here’s a decent writeup on how to tweak your bash scripts to be more reliable. It goes step by step and is easy to understand even for a novice. Cheers!
Many people hack together shell scripts quickly to do simple tasks, but these soon take on a life of their own. Unfortunately shell scripts are full of subtle effects which result in scripts failing in unusual ways. It’s possible to write scripts which minimize these problems. In this article, I explain several techniques for writing robust bash scripts.
Be prepared for spaces in filenames
Someone will always use spaces in filenames or command line arguments and you should keep this in mind when writing shell scripts. In particular you should use quotes around variables.if [ $filename = "foo" ];
will fail if $filename contains a space… This can be fixed by using:if [ "$filename" = "foo" ];
Related Posts: On this day...
- Day after big debit fee hike, BofA homepage fails - 2011
- Disaster girl - 2010
- Hacking Work, a new book by Bill Jensen and Josh Klein - 2010
- Pocket Radar - 2010
- Massachusetts: Cops Need Warrant To Stick GPS Device On Your Car - 2009
- Network security alarm sounded by second-hand ebay sale - 2008
- Richard Stallman: Keep your data at home, not in the clouds - 2008
- Quit Bitching! LOL - 2008