linux - How can I efficiently handle the result set of mysql from a bash script? -
i excited see how easy write bash script interact mysql
.
trying this:
#!/bin/bash res=`mysql -u $user -p$pass students <<eof | tail -n +2 select name table age = 20 limit 1; eof` d in $res; echo result : $d done
if result "john smith" get:
result: john
result: smith
how can around issue space?
seems treats 2 values while single column.
one way ask adding before loop:
ifs=$'\n'
this change default bash internal field separator (ifs), default works spaces, tabs , new lines.
my example work new lines, you're looking for.
Comments
Post a Comment