Quantcast
Channel: Read mysql column result in awk variable - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Raman Sailopal for Read mysql column result in awk variable

$
0
0

You will need to create the variable in bash before passing it to awk with the -v flag and so:

cmd=$(mysql --host='abc' --user='def' --password='..' --database='ghf' -sNe \"select VALUE from table where KEY='171-125';\")
awk -v cmd=$cmd '{ some awk script }'

Alternatively, if you want to parse the output of mysql, do:

awk '{ some awk script }' <<< $cmd

Viewing all articles
Browse latest Browse all 3


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>