i have a table that i want to query to that and get some values from my bash script and use it in while loop,when i use one column it works as a champ but i cant use more than one i get error like:
read: `IP, PL_Seq': not a valid identifier
here is my SELECT result
and here is may bash script
sql="SELECT IP,PL_Seq FROM mytabel WHERE FLAG=0 AND CIDR =24";
i=0
while IFS=$'\t' read IP, PL_Seq ;do
IP[$i]=$IP
PL_Seq[$i]=$PL_Seq
((i ))
echo $IP
echo $PL_Seq
done < <(mysql TestDB -u $DB_USER --password=$DB_PASSWD -N -e "$sql")
CodePudding user response:
You are nearly there, you just need to remove the comma from the line:
while IFS=$'\t' read IP, PL_Seq ;do
and so:
sql="SELECT IP FROM mytabel WHERE FLAG=0 AND CIDR =24";
i=0
while IFS=$'\t' read IP PL_Seq ;do
IP[$i]=$IP
PL_Seq[$i]=$PL_Seq
((i ))
echo $IP
done < <(mysql TestDB -u $DB_USER --password=$DB_PASSWD -N -e "$sql")