Filtering Output Command on CISCO Router/Switch

Other Cisco Other Cisco Material Original source

Filtering Output

Use

In the Cisco IOS, there are several different ways to control the output so that you get only the information that you want.

Syntax

| < | >

Options

Only show lines that contain a given text string
Shows all output after a given text string is found
Show all output except lines containing the given text string
Show just a section of output.
< >
< / > Like the begin string, but used when you see the ‘–more–‘ indicating multiple pages of output.

Example

In this example we will use the show ip interface briefcommand but exclude any unassiged interfaces . First, here is the regular output

Copy

R4(config-if)#do show ip interface brief

Interface IP-Address OK? Method Status Protocol

Serial0/0 10.4.4.4 YES NVRAM up up

Serial0/1 unassigned YES NVRAM administratively down down

Serial0/2 unassigned YES NVRAM administratively down down

Serial0/3 unassigned YES NVRAM administratively down down

Loopback55 4.5.5.5 YES manual up up

Here is the filtered output

Copy

R4(config-if)#do show ip interface brief | exclude unassigned

Interface IP-Address OK? Method Status Protocol

Serial0/0 10.4.4.4 YES NVRAM up up

Loopback55 4.5.5.5 YES manual up up

In this example we will just view the OSPF configuration from the show runoutput

Copy

R4(config-if)#do show run | section ospf

ip ospf network broadcast

ip ospf priority 255

router ospf 1

log-adjacency-changes

network 0.0.0.0 255.255.255.255 area 0

alias exec son show ip ospf ne

R4(config-if)#

In this example we will just view the interface name and its cost from the show ip ospf  interface command.

Copy

R1(config)#do show ip ospf interface | include is up|Cost

Loopback22 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type LOOPBACK, Cost: 1

Loopback12 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type LOOPBACK, Cost: 1

Loopback11 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type LOOPBACK, Cost: 1

Loopback1 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type LOOPBACK, Cost: 1

Loopback0 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type LOOPBACK, Cost: 1

Serial1/1 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type POINT_TO_POINT, Cost: 150

Serial1/0 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type BROADCAST, Cost: 64

FastEthernet0/0 is up, line protocol is up

Process ID 1, Router ID 111.111.111.111, Network Type BROADCAST, Cost: 200

In this example we will just view the show run information starting with the router ospf configuration

Copy

R1(config)#do show run | begin router ospf

router ospf 1

log-adjacency-changes

network 0.0.0.0 255.255.255.255 area 0

!

ip http server

no ip http secure-server

!

!

!

!

!

!

control-plane

!

!

!

!

!

!

!

!

!

alias exec sr show ip route

alias exec s show ip int br

alias exec ss show ip int br | ex unass

alias exec sc show cdp ne

alias exec son show ip ospf ne

alias exec sbs show ip bgp sum

alias exec sib show ip bgp

!

line con 0

exec-timeout 0 0

privilege level 15

logging synchronous

line aux 0

exec-timeout 0 0

privilege level 15

line vty 0 4

password cisco

login local

transport input ssh

!

!

end



R1(config)

In this example we will use the / command with show run to start with ip address.

Copy

2611XM#show run

Building configuration…



Current configuration : 1437 bytes

!

version 12.4

service timestamps debug datetime msec

service timestamps log datetime msec

no service password-encryption

!

hostname 2611XM

!

boot-start-marker

boot-end-marker

!

!

no aaa new-model

no network-clock-participate slot 1

no network-clock-participate wic 0

ip cef

!

!

!

!

!

/ip address

filtering…

ip address 1.1.1.1 255.255.255.255

!

interface FastEthernet0/0

ip address 10.10.2.5 255.255.255.0

duplex auto

speed auto

!

interface FastEthernet0/1

no ip address

duplex auto

speed auto

!

interface FastEthernet0/1.70

encapsulation dot1Q 70

ip address 10.10.70.1 255.255.255.0

!

interface FastEthernet0/1.99

encapsulation dot1Q 99

ip address 10.10.99.1 255.255.255.0

!

router ospf 1

log-adjacency-changes
← All Other Cisco articles Home