sip.conf文件配置文件为每条记录添加新行

2024-10-01 15:32:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个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吗?我想知道你将如何处理这个问题。你知道吗

谢谢


Tags: 文件方法nofriendhosttype配置文件记录

热门问题