Awk escapes single quotes in English

Source: Internet
Author: User

I have a small need to import the contents of a text into a MySQL table. I'm not using load, I'm using insert to do the following:


Text content:

  1   China         156   http:// data.10086.cn/fs/nmpfs/media/p/2/2/6/pubattachment/20160718/1261.jpg   2   American          840   http://data.10086.cn/fs/nmpfs/media/p/2/2/6/ pubattachment/20160718/1277.jpg   3   Japan          392   http://data.10086.cn/fs/nmpfs/media/p/2/2/6/pubAttachment/20160718/1278.jpg    4   Germany         280   http:// data.10086.cn/fs/nmpfs/media/p/2/2/6/pubattachment/20160718/1267.jpg   5   Russia        810   http://data.10086.cn/fs/nmpfs/media/p/2/2/6/pubattachment/ 20160718/1268.jpg   6   UK         826    http://data.10086.cn/fs/nmpfs/Media/p/2/2/6/pubattachment/20160718/1286.jpg 

The

uses awk to turn into an INSERT statement:

cat b.txt |awk  ' {print  ' insert into all_countries values  ("$", \047 "$ "\047,\047" $ "\047,\047" $4 "\047); insert into all_countries values  (1, ' China ', ' 156 ', ' http://data.10086.cn/fs/nmpfs/media/p/2/2/ 6/pubattachment/20160718/1261.jpg ');insert into all_countries values  (2, ' Us ', ' 840 ', ' http:/ /data.10086.cn/fs/nmpfs/media/p/2/2/6/pubattachment/20160718/1277.jpg '); insert into all_countries  values  (3, ' Japan ', ' 392 ', ' http://data.10086.cn/fs/nmpfs/media/p/2/2/6/pubAttachment/20160718/1278.jpg ') ;insert into all_countries values  (4, ' Germany ', ' 280 ', ' HTTP://DATA.10086.CN/FS/NMPFS/MEDIA/P/2/2 /6/pubattachment/20160718/1267.jpg ');insert into all_countries values  (5, ' Russia ', ' 810 ', ' http ://data.10086.cn/fs/nmpfs/media/p/2/2/6/pubattachment/20160718/1268.jpg '); insert into all_countries  values  (6, ' UK ', ' 826 ', ' Http://data.10086.cn/fs/nmpfs/media/p/2/2/6/pubAttachmeNt/20160718/1286.jpg '); 


This article is from the "just out of the shell of the Birds" blog, please be sure to keep this source http://qhd2004.blog.51cto.com/629417/1831664

Awk escapes single quotes in English

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.