Bash scripting : The importance of a sanity check
echo "Execute $somecode ?" read bogusvar $somecode
-----
The above might be the most important part of any bash script. It does two things :
1. Shows you the actual command being executed
2. Gives you the chance to cancel the program
I recently learned the importance of this when “rm -rf $variable” became “rm -rf /” when executed. Before I realized what was going on /etc/ and a dozen /home/username/ directories were gone.
Avoid making the same mistake by incorporating some form of a sanity check into all of your bash scripts.







