2011-08-05 20:38:58|76556429203814|99999xxx|ending call
2011-08-05 20:39:34|76556429203909|7777xxxx|ending call
2011-08-05 22:26:15|77578322222419|775xxxxx|download fail
i would like to import into mysql, so i gonna use AWK to do it.
cat 20110805.log | awk -F"[ |]*" '{print "INSERT INTO tb_status VALUES(" "\47" $1 " " $2 "\47" "," "\47" $3 "\47" "," "\47" $4 "\47" "," "\47" $5 " " $6 "\47" " ) ; "}' >test.sql
result will be like
INSERT INTO tb_status VALUES('2011-08-05 22:26:15','77578322222419','775xxxxx','download fail' ) ;
INSERT INTO tb_status VALUES('2011-08-05 22:26:22','77578322222419','775xxxxx','ending call' ) ;
INSERT INTO tb_status VALUES('2011-08-05 23:14:59','78884147231433','788xxxxx','ending call' ) ;
No comments:
Post a Comment