Shell reads files and updates them to the database (awk assigns values to external variables)
Source: Internet
Author: User
Shell reads the file and updates it to the database (awk assigns an external variable) www.2cto.com #! /Bin/bashfile&%39%20121224_finaldatapm.csv & amp; #39; MYSQL & amp; #39;/usr/local/mysql/bin/mysql & amp; #39; USER & amp; #3 shell reads files and updates them to the database (awk assigns an external variable) www.2cto.com #! /Bin/bashfile='221224_finaldatapm.csv 'MySQL = '/usr/local/MYSQL/bin/mysql 'user = 'root' PASSWD = 'root' DB = 'itims' while read ido eval $ (echo $ I | awk-f ', ''{printf (" a = % s \ nb = % d \ nc = % d \ nd = % d \ ne = % d \ nf = % s ", $1, $2, $3, $4, $5, $6);} ') SQL = "update it_reportb set activeuser = $ B, ctnpush = $ c, wangmengnu = $ d, wangmenguser = $ e where name = '$ A' and date =' $ f' "$ MYSQL-u $ USER-p $ PASSWD $ DB-e" $ SQL "done <$ FILE
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service