08-13-2007 08:57 AM
Does anyone know what character codes IOS uses for EOL in show
output? The standard "\n" and "\r" chars are used for some lines, but
not all. The regex character "$" is catching something more than "\n"
and "\r" and I need to find out for some scripting purposes:
Rack1R1#show run | exclude \n
!
service timestamps debug datetime msec
service timestamps log datetime msec
!
!
boot-start-marker
!
!
memory-size iomem 10
ip cef
!
!
Rack1R1#show run | exclude \r
!
!
hostname Rack1R1
!
!
!
no aaa new-model
ip cef
!
!
!
!
no ip domain lookup
!
!
Rack1R1#show run | exclude \r|\n
!
!
!
!
!
ip cef
!
!
Rack1R1#show run | exclude $
Rack1R1#
Thanks,
Brian McGahan, CCIE #8593 (R&S/SP/Security)
bmcgahan@internetworkexpert.com
Internetwork Expert, Inc.
http://www.InternetworkExpert.com
Toll Free: 877-224-8987 x 705
Outside US: 775-826-4344 x 705
24/7 Support: http://forum.internetworkexpert.com
Live Chat: http://www.internetworkexpert.com/chat/
08-13-2007 09:01 AM
I have no problem with "show run | exc $" but try out:
show run | exc [\r\n]?$
That sequence also works for me.
08-13-2007 09:38 AM
Hi Joe,
Thanks for the reply. The issue isn't that $ isn't matching the EOL, it's that $ is matching additional EOL chars besides "\n" and "\r". I need to find out what those additional characters are.
Thanks,
Brian
08-13-2007 10:06 AM
The only two characters used are ASCII \015 (carriage return) and ASCII \012 (newline) (at least on my test 7206). There appears to be a problem with the exclude command, though in that it is not matching what it should when character classes are included.
If you're device is running 12.3(2)T or higher, you can use TCL to scrub your config looking for other EOL characters. Here is a quick and dirty script:
set output [exec "show run"]
set fmt [string repeat "%c" [string length $output]]
set char_lst [scan $output $fmt]
foreach char $char_lst {
if { $char < 32 || $char > 126 } {
puts $char
}
}
This will print the decimal values of any non-printable character. In my test, I only see 10 and 13.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide