cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1411
Views
0
Helpful
3
Replies

IOS EOL Characters

bmcgahan
Level 1
Level 1

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/

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

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

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

That sequence also works for me.

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

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.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: