I need to implement something like:
if [ $i -ne $hosts_count - 1] ; then
cmd="$cmd;"
fi
But I get
./installer.sh: line 124: [: missing `]'
What I am doing wrong?
The command [
can't handle arithmetics inside its test. Change it to:
if [ $i -ne $((hosts_count-1)) ]; then
Edit: what @cebewee wrote is also true; you must put a space in front of the closing ]
. But, just doing that will result in yet another error: extra argument '-'
]
must be a separate argument to [
.You're assuming you can do math in [
.
if [ $i -ne $(($hosts_count - 1)) ] ; then
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With