linux - select one of outcomes randomally in sh -
i trying randomly choose 1 of 2 outcomes in sh
#!/bin/sh if [$[ $random % 2] -eq 1 ] echo yes else echo no fi
gives
sh-3.2$ sh test.sh test.bash: line 4: [1: command not found no
obviously, it's trying execute (0,1) command. doing wrong?
just put space after first [, like
#!/bin/sh if [ $[ $random % 2] -eq 1 ] echo yes else echo no fi
Comments
Post a Comment