Hello. First off I am not a programmer or script kiddie of any sorts and I am having a really hard time understanding sed. One of our other engineers left behind a script we heavily used to search our Cisco config files with. We backed these files up in a directory on a FreeBSD machine. The script was called
How it worked was, I could type
I understand what grep(1) is doing, I do not understand what the two sed(1) statements are doing and the man pages for sed(1) are really confusing.
I don't know if it will help but I think we use to use Rancid to back up config files, now we use Solar Winds CAT tools and it sames the Cisco config file in a simple .txt file.
Any help in telling me what exactly is happening in the sed(1) statements would be great as I am trying to get this to work on another system.
confsearch
. Below is the script and all it consisted of.
Code:
confsearch () { grep -ir -B 1 -A 4 "$*" /usr/local/configs | sed -E 's#/usr/local/configs/##g' | sed -E 's#,v:?-?#: #g'; }
How it worked was, I could type
confsearch Company ABC
and it would output Cisco interfaces that had descriptions on them with that company's name.I understand what grep(1) is doing, I do not understand what the two sed(1) statements are doing and the man pages for sed(1) are really confusing.
I don't know if it will help but I think we use to use Rancid to back up config files, now we use Solar Winds CAT tools and it sames the Cisco config file in a simple .txt file.
Any help in telling me what exactly is happening in the sed(1) statements would be great as I am trying to get this to work on another system.