need to delete notification * functions in all yang files , using linux script inside notification * function some functions has nested functions upto 3 levels. what is the best way to delete the notification * function using linux script
@ramananm , Welcome.
The site is a collaboration, please show you attempts, some example data you are working with and the expected results needed (you may need to manually produce those !). Once you have shown your attempt we can come back with suggestions/fixes/tweaks to your submissions.
thks
PS: It would also be helpful (to you) to read the forum rules/faqs.
used these
awk '/notification .* {/,/}/{ if (/notification .* {/) { n++ } if (n > 0) { if (/}/) { n-- } next } } 1' fscfa.yang > temp_file && mv temp_file fscfa.yang
but not able to delete the whole function.
notification ifDeleted {
description
"This trap is generated when interface Row Status
is Destroy or interface is deleted.";
leaf ifMainIndex {
type fs-if:InterfaceIndex;
}
}
notification ifUfdEnabled {
description
"This trap is generated when the interface's Uplink Failure
Detection(UFD) operational status is moved from UFD error
disabled to Up state";
leaf ifMainIndex {
type fs-if:InterfaceIndex;
}
leaf ifMainUfdOperStatus {
type leafref {
path "/fs-fs-cfa:fscfa/fs-fs-cfa:if/fs-fs-cfa:ifMainTable/fs-fs-cfa:ifMainEntry/fs-fs-cfa:ifMainUfdOperStatus";
}
}
}
notification ifUfdErrorDisabled {
description
"This trap is generated when the interface's Uplink Failure
Detection(UFD) operational status is moved from Up to UFD
error disabled state";
leaf ifMainIndex {
type fs-if:InterfaceIndex;
}
leaf ifMainUfdOperStatus {
type leafref {
path "/fs-fs-cfa:fscfa/fs-fs-cfa:if/fs-fs-cfa:ifMainTable/fs-fs-cfa:ifMainEntry/fs-fs-cfa:ifMainUfdOperStatus";
}
}
}
eg code of notification to be delete for reference
Your range spans up to the first }
but you want the corresponding }
BTW in ERE they should be escaped \{
and \}
I found this, after a little puzzling:
awk '/notification .* \{/ { del=1 } del { if(/\{/) n++; if (/\}/ && n--) next } n == 0 { print; del=0 }' fscfa.yang
The del
flag variable is 1=true if inside the notification function.