最新消息:热烈庆祝IT小记上线!

Linux sed根据关键字所在行,然后删除其它关键字

源码:
smoketest:/tmp # cat 321.log
create table "omuuser"."t_omu_spec_nic"
(
    "ID" NUMBER(19,0) not null,
    "NETWORKNAME" VARCHAR2(50 CHAR),
    "SPECNAME" VARCHAR2(255 CHAR) not null,
    primary key ("ID")
);

alter table "omuuser"."cie_support_idgenerator" drop primary key;

====================================================

测试命令:
smoketest:/tmp #  sed -i '/table/s/"//g'    321.log

======================================

查看效果:
smoketest:/tmp # cat 321.log
create table omuuser.t_omu_spec_nic
(
    "ID" NUMBER(19,0) not null,
    "NETWORKNAME" VARCHAR2(50 CHAR),
    "SPECNAME" VARCHAR2(255 CHAR) not null,
    primary key ("ID")
);

alter table omuuser.cie_support_idgenerator drop primary key;

=======================================================

找到以 table 为关键字这行,并将前面的指定字符 "  删除

猜您喜欢

备案号:苏ICP备12016861号-4