To execute MySQL query in shell script, try this:


 

for localFile in `ls /usr/local/testTemp/test`; do

echo $localFile
echo “load data local infile ‘/usr/local/testTemp/test/$localFile’ into table testSqoop.test24 FIELDS TERMINATED BY 0x01 LINES TERMINATED BY ‘\n’ ( e_vi, e_vg, e_ti, e_tp, e_v, e_s, e_bsid, e_it, e_bd, e_ec, e_st, e_up);” > /usr/local/hive-0.8.1-bin/localFile.sql
mysql –user=root –password=password < /usr/local/hive-0.8.1-bin/localFile.sql

done


 

SHARE

NO COMMENTS

LEAVE A REPLY