I have a varsValues.txt file
cat varsValues.txt aa=13.7 something=20.6 countries=205 world=1 languages=2014 people=7.2 oceans=3.4 And I would like to create 2 arrays, vars and values. It should contain
echo ${vars[@]} aa something countries world languages people oceans echo ${values[@]} 13.7 20.6 205 1 2014 7.2 3.4 I use
Npars=7 readarray -t vars < <(cut -d '=' -f1 varsValues.txt) readarray -t values < <(cut -d '=' -f2 varsValues.txt) for (( yy=0; yy<$Npars; yy++ )); do eval ${vars[$yy]}=${values[$yy]} done echo $people 7.2 But I would like it without readarray which does not work on Mac (os x) and IFS (interfield separater).
Any other solution? awk? perl? which I can use in my bash script.
Thanks.