String Return for Array

0

I'm doing a shellscript and got the command that returns:

$ sqlite3 banco.db 'select code from channels'

00 01 02 03

When I assign the return to a variable, everything changes to a single string.

$ export LISTA=$(sqlite3 banco.db 'select code from channels')
$ echo $LISTA

00 01 02 03

I would like each number to be the element of an array, how can I transform it so that it can be called something like:

$ echo $LISTA[0]

00

$ echo $LISTA[1]

01

    
asked by anonymous 06.11.2018 / 12:35

1 answer

0

After putting the contents of the command inside the variable, you must declare an array:

  

LIST = $ (sqlite3 bank.db 'select code from channels')

     

echo $ LIST

     

00 01 02 03

Now you must declare an array with the contents of the variable, with a delimiter:

  

IFS = '' read -r -a array

09.11.2018 / 18:46