【发布时间】:2012-08-23 21:06:09
【问题描述】:
我有一个如下所示的 sip 配置文件:
[1664]
username=1664
mailbox=1664@8360
host=192.168.254.3
type=friend
subscribemwi=no
[1679]
username=1679
mailbox=1679@8360
host=192.168.254.3
type=friend
subscribemwi=no
[1700]
username=1700
mailbox=1700@8360
host=192.168.254.3
type=friend
subscribemwi=no
[1701]
username=1701
mailbox=1701@8360
host=192.168.254.3
type=friend
subscribemwi=no
对于每条记录,我需要为每条记录添加另一行(vmxten),例如上面变成:
[1664]
username=1664
mailbox=1664@8360
host=192.168.254.3
type=friend
subscribemwi=no
vmexten=1664
[1679]
username=1679
mailbox=1679@8360
host=192.168.254.3
type=friend
subscribemwi=no
vmexten=1679
[1700]
username=1700
mailbox=1700@8360
host=192.168.254.3
type=friend
subscribemwi=no
vmexten=1700
[1701]
username=1701
mailbox=1701@8360
host=192.168.254.3
type=friend
subscribemwi=no
vmexten=1701
您认为最快的方法是什么?文件中有数百条记录,因此手动修改所有记录需要很长时间。
你会使用正则表达式吗?你会用sed吗?我很想知道您将如何解决这个问题。
谢谢
【问题讨论】:
标签: php python ruby regex linux