I need to parse .conf file in Unix system to get output from the snippets like below :
[sub_suffix-324]
; generated by mod_identity
exten => int,1,GoSub(mdc_template-3,s,1)
exten => int,n(next_380),Return()
; default action for busy
exten => ext,1,GoSub(mdc_template-3,s,1)
exten => ext,n,Set(PRI_CAUSE=17)
exten => ext,n,HangUp(17)
exten => ext,n(back),Return()
I interested specifically about below lines:
[sub_suffix-324]
exten => int,1,GoSub(mdc_template-3,s,1)
exten => ext,1,GoSub(mdc_template-3,s,1)
to get output to another file as below:
Extension int_voicemail ext_voicemail
324 yes(if int exist) yes(if ext exist)
My initial awk script :
#!/usr/bin/awk -f
/^\[sub_suffix-/ {
print $0
next
}
/mdc_template/ {
print substr($3,1,3)
next
}
And the output like:
[sub_suffix-324]
int
ext
[sub_suffix-424]
int
ext
[sub_suffix-321]
[sub_suffix-3245]
ext
[sub_suffix-7435]
[sub_suffix-123]
[sub_suffix-325]
int
ext
but i need something like:
324
int
ext
424
int
ext
321
null
null
3245
null
ext
7435
null
null
123
null
null
325
int
ext
then format this as:
extension int_mail ext_mail
324 yes yes
424 yes yes
321 null null
.
.
.
.
Any help is appreciated
Thanks
cheecky