I have a issue.

I build a script can connect to database and select a value from table

But i can't get only the result

this is my script

while IFS='' read -r line || [[ -n "$line" ]]; do
    mysql -p<pass-db> -e "select id from test where concat(upper(trim(firstname)), ' ', upper(trim(lastname)))=upper('$line')" mydatanase 
    echo ${IDS[j]}
    let "j++"
done < employees.txt

the output of echo is


i would only get the "78" , not the name of colomun

  • Hello @YOU CHT LEE is the output of echo only two lines? or a series of lines: Id then number then id after then number and so on ?
    – user88036
    Oct 15, 2018 at 18:55

1 Answer 1


Invoke mysql with -N to turn off column headers, i.e. mysql -N

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .