[monitor@test ~]$ more 1.txt
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (4,'脮脠', ,'132','12','S0A');
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (5,'脌脣', ,'132','12','S0A');
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (6,'脥脦', ,'132','12','S0A');
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (7,'小鲁脗, ','132','12' 'S,'SOA');
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (9,'小脌', ,'132','12','S0A');
[monitor@test ~]$ sed "s#\(.*Values (\)\(.\)\(.*\)#\1\2\3\ndelete from t where ID='\2;'#" 1.txt
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (4,'脮脠', ,'132','12','S0A');
delete from t where ID='4;'
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (5,'脌脣', ,'132','12','S0A');
delete from t where ID='5;'
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (6,'脥脦', ,'132','12','S0A');
delete from t where ID='6;'
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (7,'小鲁脗, ','132','12' 'S,'SOA');
delete from t where ID='7;'
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (9,'小脌', ,'132','12','S0A');
delete from t where ID='9;'
[monitor@test ~]$
我也想用append,但是那个参数如何带下来
[monitor@test ~]$ sed "/Values (\(.\),/a delete from t where ID='\1';" 1.txt
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (4,'脮脠', ,'132','12','S0A');
delete from t where ID='1';
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (5,'脌脣', ,'132','12','S0A');
delete from t where ID='1';
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (6,'脥脦', ,'132','12','S0A');
delete from t where ID='1';
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (7,'小鲁脗, ','132','12' 'S,'SOA');
delete from t where ID='1';
Insert into T(ID,NAME, DESC, MEMO, STAT) Values (9,'小脌', ,'132','12','S0A');
delete from t where ID='1';
[monitor@test ~]$ |