×

Warning message

  • Cisco Support Forums is in Read Only mode while the site is being migrated.
  • Cisco Support Forums is in Read Only mode while the site is being migrated.

IOS EOL Characters

Unanswered Question
Aug 13th, 2007
User Badges:

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/



  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
Joe Clarke Mon, 08/13/2007 - 09:01
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

I have no problem with "show run | exc $" but try out:


show run | exc [\r\n]?$


That sequence also works for me.

bmcgahan Mon, 08/13/2007 - 09:38
User Badges:

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

Joe Clarke Mon, 08/13/2007 - 10:06
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

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.

Actions

This Discussion