if on one line

If you want to execute a conditional command in bash you can use only [] condition with && like the following example

[ $1 -eq 0 ] && command

Command will be executed only if $1 is equal with 0. This is a little simpler that the usual

if [ condition ] ; then
command
fi

Leave a Reply

Your email address will not be published. Required fields are marked *