我需要从中删除我的后缀日志行:
Jun 12 06:19:20 cm postfix: 123123: to=<xxxxx@xxx.xxx>, relay=x.x.x.x, conn_use=3, delay=2, delays=1.6/0/0.01/0.32, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as XXXXXXX)
到此:
Jun 12 06:19:20 cm postfix: 123123: to=<xxxxx@xxx.xxx>, relay=x.x.x.x, delay=2, delays=1.6/0/0.01/0.32, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as XXXXXXX)
我只需要删除“conn_use = 3”。该值可以是变量(例如conn_use = 12.5) 我尝试过: sed's / conn_use =。* \ //' 但它删除任何东西直到最后(基本上,在“as”之后):XXXXXXX)
答案 0 :(得分:1)
sed 方法:
sed 's/conn_use=[^,]*, //' file
输出:
Jun 12 06:19:20 cm postfix: 123123: to=<xxxxx@xxx.xxx>, relay=x.x.x.x, delay=2, delays=1.6/0/0.01/0.32, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as XXXXXXX)
[^,]*
- 匹配除,
答案 1 :(得分:1)
sed 's/conn_use=[^,]*, //'<<< 'Jun 12 06:19:20 cm postfix: 123123: to=<xxxxx@xxx.xxx>, relay=x.x.x.x, conn_use=3, delay=2, delays=1.6/0/0.01/0.32, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as XXXXXXX)'
输出:
Jun 12 06:19:20 cm postfix: 123123: to=<xxxxx@xxx.xxx>, relay=x.x.x.x, delay=2, delays=1.6/0/0.01/0.32, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as XXXXXXX)