First Post. Bash novice. Couldn't find an effective solution.
Looking for an efficient parsing method / alternative method
My initial attempt: (+ edit thanks to @larks)
services=($($PSQL "SELECT array(select name from services);"))
echo ${services[@]}
>array -------------------------------- {Shampoo,Dying,Long-cut} (1 row)
echo ${#services[@]}
>5
echo ${services[2]}
>{Shampoo,Dying,Long-cut}
I'm looking to end up with an array identical to the ones below but without creating a csv in the process.
echo $($PSQL "\copy (select name from services) to 'services.csv';")
readarray arr -t a < services.csv
echo ${arr[@]}
>Shampoo Dying Long-cut
echo ${#services[@]}
>3