Kyle Sexton
2012-Feb-02 22:56 UTC
[asterisk-users] Quick bash tip for finding free SIP extensions from your sip.conf
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>
Steve Edwards
2012-Feb-02 23:34 UTC
[asterisk-users] Quick bash tip for finding free SIP extensions from your sip.conf
On Thu, 2 Feb 2012, Kyle Sexton wrote:> 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:]] > }Shave 4 processes: freesip() { comm -2 -3\ <(seq $2 $3)\ <(grep ^\\[[[:digit:]] $1 | sort -u | tr -d \[]) } -- Thanks in advance, ------------------------------------------------------------------------- Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST Newline Fax: +1-760-731-3000