gpt4 book ai didi

mysql - 如何从 linux 文件中删除特定符号?

转载 作者:行者123 更新时间:2023-12-04 19:33:40 25 4
gpt4 key购买 nike

我的 Linux 文件包含 4000 多行代码,类似于:

[INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:57','Electrolux', 'abandoned', '1609507904.86839', 'ROUTING_SCRIPT', 'Electrolux', '01008367900', '886123', 'CALL')]
[INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:59','Electrolux-Inst', 'queued', '1609507878.86832', 'VIRTUAL', 'Electrolux', '01552050703', '886123', 'CALL')]
[INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:59','Electrolux', 'distributed', '1609507878.86832', 'ROUTING_SCRIPT', 'Electrolux', '01552050703', '886123', 'CALL')]
[INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:59','Electrolux-Inst', 'distributed', '1609507878.86832', 'VIRTUAL', 'Electrolux', '01552050703', '886123', 'CALL')]
我需要 linux 命令从文件中删除方括号 [ ],使其看起来像这样:
INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:57','Electrolux', 'abandoned', '1609507904.86839', 'ROUTING_SCRIPT', 'Electrolux', '01008367900', '886123', 'CALL')
INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:59','Electrolux-Inst', 'queued', '1609507878.86832', 'VIRTUAL', 'Electrolux', '01552050703', '886123', 'CALL')
INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:59','Electrolux', 'distributed', '1609507878.86832', 'ROUTING_SCRIPT', 'Electrolux', '01552050703', '886123', 'CALL')
INSERT INTO DATAMART_QUEUE_DETAILS(EVENT_TIME,QUEUE,EVENT,TRACKNUM,QUEUE_TYPE,ASSOCIATED_ROUTING_SCRIPT,ANI,DNIS,CHANNEL_TYPE) VALUES ('2021.01.01 15:31:59','Electrolux-Inst', 'distributed', '1609507878.86832', 'VIRTUAL', 'Electrolux', '01552050703', '886123', 'CALL')
最后,我想将这些行直接插入到 MySQL 查询中。

最佳答案

一种廉价而愉快的方式是

tr -d '[]' < infile > outfile
编辑:我应该补充一点,如果 [ 或 ] 出现在数据中,这将不会产生预期的结果。

关于mysql - 如何从 linux 文件中删除特定符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65656042/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com