[169542] in North American Network Operators' Group
Re: Managing IOS Configuration Snippets
daemon@ATHENA.MIT.EDU (Robert Drake)
Sun Mar 2 13:14:47 2014
Date: Sun, 2 Mar 2014 13:13:41 -0500
From: Robert Drake <rdrake@direcpath.com>
To: <nanog@nanog.org>
In-Reply-To: <20140301021939.GN815@havarti.local>
Errors-To: nanog-bounces+nanog.discuss=bloom-picayune.mit.edu@nanog.org
On 2/28/2014 9:19 PM, Dale W. Carder wrote:
> If I'm understanding what you're trying to do, you could script around
> our rather unsophisticated 'sgrep' (stanza grep) tool combined with
> scripting around rancid & rcs to do what I think you are looking for.
>
> http://net.doit.wisc.edu/~dwcarder/scripts/sgrep
>
> sgrep can dump out a "stanza" of ios-like config, then you can rcsdiff
> that to your master, per 'chunk' of config.
> Dale
>
>
I'm digging the idea of your command. Along the same lines I've got
this awk snippet that I made and then forgot about. It functions like
the cisco pipe begin/end commands:
#!/bin/sh
if [ "x${2}" = "x" ]; then
awk "/${1}/{temp=1}; temp==1{print}"
else
awk "/${1}/{temp=1};/${2}/{temp=0}; temp==1{print}"
fi
Usage:
cat router-confg | begin_regex 'line vty' '!'
If you omit the second argument it just shows you from your match until
the end of file.