sip.conf configuration file - add new line to each record

Posted by Flukey on Stack Overflow See other posts from Stack Overflow or by Flukey
Published on 2012-08-29T09:31:44Z Indexed on 2012/08/29 9:38 UTC
Read the original article Hit count: 117

Filed under:
|
|
|
|

I have a sip configuration file which looks like this:

[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

For each record I need to add another line (vmxten for each record) for example the above becomes:

[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

What would you say would be the quickest way to do this? there are hundreds of records in the file, therefore modifying all of the records by hand would take a long time.

Would you use Regex? Would you use sed? I'm interested to know how you would approach the problem.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about python