[asterisk-users] Quick bash tip for finding free SIP extensions from your sip.conf

Kyle Sexton ks at mocker.org
Thu Feb 2 16:56:51 CST 2012


Created this function on one of my machines today, thought others might
find it useful:

freesip() {
comm -2 <(seq $2 $3) <(cat $1 | grep ^\\[ | sort | uniq | tr -d \[ | tr -d
\]) | grep ^[[:digit:]]
}

On RedHat/CentOS based systems you can create the following file to have
the function available on login:

/etc/profile.d/freesip.sh
# Free SIP extensions
freesip() {
  comm -2 <(seq $2 $3) <(cat $1 | grep ^\\[ | sort | uniq | tr -d \[ | tr
-d \]) | grep ^[[:digit:]]
}

Then if you have a large sip.conf and want to find a free extension between
200 and 299 you can login and do the following:

<begin fake results>
[host]$ freesip /etc/asterisk/sip.conf 200 299
200
201
233
245
[host]$
<end fake results>


-- 
Kyle Sexton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20120202/772a54ef/attachment.htm>


More information about the asterisk-users mailing list