La forma correcta es pasar la variable bash/shell
al script awk
como argumento a través de la opción-v
(variable
):
i=1;
while [ $i -lt 5 ]; do
A=$(awk -v i="$i" -F_ '{ print $i }' <<< 'one_two_test_three')
echo $A
((i++))
done
La salida:
one
two
test
three
Почему бы вам не попробовать закодировать строку rand в base64? Вот так :openssl rand -base64 16
С этим намного легче справиться.