i have following columns in mysql table:
id start_time 51 2015-01-01 01:00:00
i have following mysql query in bash:
values=($(mysql -dhistorization -hlocalhost -uroot -padmin -se "select id, start_time table_new id=51"));
when try assign , print values this:
id=values[0]; start_time=values[1]; echo $id; echo $ start_time;
it prints this:
51 2015-01-01
ideally should print like, desired output:
51 2015-01-01 01:00:00
when print
echo ${values[*]};
it prints:
51 2015-01-01 01:00:00
values contains 3 elements should contain two. think problem due space character in "2015-01-01 01:00:00", how rid of this? appreciate answer without changing ifs.
thanks..
mysql output tab separated.
thus, should work:
ifs=$'\t' read -a values < <(mysql -dhistorization -hlocalhost -uroot -padmin -se "select id, start_time table_new id=51");