按行读取sql结果:
while read -a row
do
echo "..${row[0]}..${row[1]}..${row[2]}.."
done < <(echo "SELECT A, B, C FROM table_a"
mysql database -u $user -p $password)
将sql执行结果读取到shell变量中:
while read a b c
do
echo "..${a}..${b}..${c}.."
done < <(echo "SELECT A, B, C FROM table_a"
mysql database -u $user -p $password)