Gotchas with Bash programming

Working with Linux servers and automating tasks requires the use of bash programming. This is quite an old language if you compare it to 'modern' languages such as ruby.

As such it has some very unfriendly ways. One of which bit me today.
One of the scripts purges old snapshot on AWS.

Bash tries to be helpful by file globbing and word splitting. This caused some undesired effects.

Fortunately, thanks to Greg's Wiki the fix is quite easy. use quotes.

snap_data=$(/home/ec2/bin/ec2-describe-snapshots $snapshot_id_evaluated --region $AWS_REGION)
snap_description=$(echo "$snap_data" | grep complete | awk '{print $9}')
snap_creation_date=$(echo "$snap_data" | grep complete | awk '{print $5}')
purge_after_fe=$(echo "$snap_data" | grep ^TAG.*PurgeAfterFE | cut -f 5)

Thanks