0
#!/bin/bash

_0=("Mami"  "Bebe"  "Princesa"  "Mami")
_1=("Yo quiero " "Yo puedo "  "Yo vengo a " "Voy a ")
_2=("Encenderte"  "Amarte"  "Ligar"  "Jugar")
_3=("Suave"  "Lento"  "Rapido"  "Fuerte")
_4=("Hasta que salga el sol " "Toda la noche "  "Hasta el amanecer "  "Todo el dia ")
_5=("Sin anestecia " "Sin compromiso " "Feis to feis " "Sin Miedo ")

b=$(( $RANDOM % 6 ))

echo _$b[@]

I want to select randomly one array and print its value.

1
  • Why not use a case statement? Commented Oct 29, 2017 at 1:25

1 Answer 1

1

Please see this answer. Adapting it to your script, the last two lines become:

b=_$(( $RANDOM % 6 ))[@]
echo ${!b}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Vasan, It was what I really wanted
Mr vasan i use too: c=$(( $RANDOM % 4 )) b=_$(( $RANDOM % 6 ))[c] echo ${!b}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.