Quantcast
Channel: Read mysql column result in awk variable - Unix & Linux Stack Exchange
Browsing index pages (3 articles)

Read mysql column result in awk variable

I am unable to read single VALUE from mysql Query in awk.I am able to read it in bash but not in awk. I want to read the result variable in awk as I want to fire the query only based on some dynamic...

View Article


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

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...

View Article


Answer by Kusalananda for Read mysql column result in awk variable

mysql ... | awk '{ print "diff is", $0 }' Or just mysql ... 'SELECT CONCAT("diff is ", VALUE) FROM ...' From within awk: awk 'BEGIN { cmd = "mysql ..." } { cmd | getline value; printf("diff is %s\n",...

View Article
Browsing index pages (3 articles)


Latest Images