如何使用sed或awk命令从正则表达式重建?

时间:2015-11-15 18:16:12

标签: regex bash awk sed

您好我想用正则表达式的sed创建insert命令。像这样:

正则表达式:

   0  M 63823170268                         1C:1A:C0:20:07:BD 4d6h40m1s           
  10  M C2W0T979L                           2C:8A:72:D8:2F:81 4d6h40m1s           
 100  M PP2275468                           50:EA:D6:AB:61:EE 4d6h40m1s           

我想这样:

insert into users(user, mac) select  '63823170268','1C:1A:C0:20:07:BD' from dual where not exists ( select  user  from users where user = '63823170268' and mac = '1C:1A:C0:20:07:BD' );
insert into users(user, mac) select  'C2W0T979L','2C:8A:72:D8:2F:81' from dual where not exists ( select  user  from users where user = 'C2W0T979L' and mac = '3C:C2:43:6D:EB:18' );
insert into users(user, mac) select  'PP2275468','50:EA:D6:AB:61:EE' from dual where not exists ( select  user  from users where user = 'PP2275468' and mac = '50:EA:D6:AB:61:EE' );

1 个答案:

答案 0 :(得分:3)

展开此示例:

// Fixes popover anchor centering issue in iOS 9
if let popoverPresentationController = segue.destinationViewController.popoverPresentationController, sourceView = sender as? UIView {
  popoverPresentationController.sourceRect = sourceView.bounds
}