[root@mysql1 tmp]# cat test.sh
#!/bin/bash
for fileName in `ls /tmp/fastweb/`
do
echo `/bin/date` ${fileName}--start------------
ttl=`head -1 /tmp/fastweb/${fileName}|awk '{print $2}'`
`sed '1,13d' /tmp/fastweb/${fileName}|awk '{if($2=="IN"){ print $1,"|",801,"|",$3,"|",$4 }else{ print $1,"|",$2,"|",$4,"|",$5 }}' > ${fileName}_`
`mysql -s -e "load data infile '/tmp/${fileName}_' into table test.logs_1 fields terminated by '|' "`
echo `/bin/date` ${fileName}--end--------------
#!/bin/bash
for fileName in `ls /tmp/fastweb/`
do
echo `/bin/date` ${fileName}--start------------
ttl=`head -1 /tmp/fastweb/${fileName}|awk '{print $2}'`
`sed '1,13d' /tmp/fastweb/${fileName}|awk '{if($2=="IN"){ print $1,"|",801,"|",$3,"|",$4 }else{ print $1,"|",$2,"|",$4,"|",$5 }}' > ${fileName}_`
`mysql -s -e "load data infile '/tmp/${fileName}_' into table test.logs_1 fields terminated by '|' "`
echo `/bin/date` ${fileName}--end--------------
done
本文转自cloves 51CTO博客,原文链接:http://blog.51cto.com/yeqing/1611596