Saturday, 15 March 2014

What am i doing wrong here? in bash random -



What am i doing wrong here? in bash random -

i trying create random colour output string file name abc , command entering abc random love_bash

color=(0;30 0;31 0;32 0;33 0;34 0;35 0;36 0;37) color2=${#color[*]} input='^random$' shopt -s nocasematch if [[ $1 =~ $input ]]; echo -ne '\e['${color[$((random%color2))]}m exit 2 fi

when come in command random output get

./echoc: line 22: syntax error near unexpected token `;' ./echoc: line 22: `color=(0;30 0;31 0;32 0;33 0;34 0;35 0;36 0;37)' ./echoc: line 42: random%color2: partition 0 (error token "color2")

; command terminator in bash; need quote part of array element.

color=("0;30" "0;31" ... )

bash

No comments:

Post a Comment