Hello everyone,
I have a customized bash script to build some stuffs which it looks something like this:
Code:
#!/bin/bash
#Do some stuffs
#...
STATUS=$?
if [ $STATUS -eq 0 ]; then
#Do stuffs 1
#...
STATUS=$?
if [ $STATUS -eq 0 ]; then
#Do stuffs 2
#...
STATUS=$?
if [ $STATUS -eq 0 ]; then
#...
else echo "Random message for building stuffs 3"
fi
else echo "Random message for building stuffs 2"
fi
else echo "Random message for building stuffs 1"
fi
Is there a way to simplify my script. I'm thinking about using some kind of FOR so I won't have to repeat writing that IF-ELSE-FI clause lots of time. I'm pretty new in bash but if you can give me some hints or links I'm a pretty fast learner. The biggest problem is the fact that there are different line codes for each IF-ELSE branch (even though the logic is basically the same for each branch).
Thanks in advance!
Bookmarks