Options

Question on: sh int status | include (port|fa0/13)

ciscofunciscofun Member Posts: 12 ■□□□□□□□□□
Dear all,
i just started working on my IE workbook Vol.1 , and found a question that would like to ask, below is what i need help on.

on Page.4 under the "Bridging and Switching"
1. there is a command call : sh int status | include (port|fa0/13),
what does the "|" and the "include (port|fa0/13)" means, how does it works ??

2. i followed the workbook to type this command, but nothing comes out from the switch, which does not match the outcome of the workbook's after running this command... but i checked all the commands in my switch are correct.

below is the outcome captured from my 3550

R12_Switch#
R12_Switch#
R12_Switch#sh int status | include (port|fa0/13)
R12_Switch#sh int status | include (port|fa0/13)
R12_Switch#sh int status | include (port|fa0/13)
R12_Switch#
R12_Switch#



can any one advice ? Thank you.

Comments

  • Options
    scheistermeisterscheistermeister Member Posts: 748 ■□□□□□□□□□
    ciscofun wrote:
    Dear all,
    i just started working on my IE workbook Vol.1 , and found a question that would like to ask, below is what i need help on.

    on Page.4 under the "Bridging and Switching"
    1. there is a command call : sh int status | include (port|fa0/13),
    what does the "|" and the "include (port|fa0/13)" means, how does it works ??

    2. i followed the workbook to type this command, but nothing comes out from the switch, which does not match the outcome of the workbook's after running this command... but i checked all the commands in my switch are correct.

    below is the outcome captured from my 3550

    R12_Switch#
    R12_Switch#
    R12_Switch#sh int status | include (port|fa0/13)
    R12_Switch#sh int status | include (port|fa0/13)
    R12_Switch#sh int status | include (port|fa0/13)
    R12_Switch#
    R12_Switch#



    can any one advice ? Thank you.

    The pipe ( | ) means to take the results of the first command and redirect the output to the second command (in this case i which is short for include). Sorta like grep from linux. That and the "do" command are some of the best ever.

    You would use it like

    router(config-router)#do sh int stat | i fastethernet 0/0

    Here is another example
    Cisco-gw(config-router)#do sh ip int bri | i Fast
    FastEthernet0/0 192.168.1.3 YES NVRAM up up

    Cisco-gw(config-router)#
    Give a man fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life.
  • Options
    mikej412mikej412 Member Posts: 10,086 ■■■■■■■■■■
    In the 2nd part, the | means OR

    You want to include only the output lines from the show interface status command that includes the words Port (so that you get the "header line" for the output) OR the interface that you are interested in -- Fa0/13


    The reason you're not getting any output is because the "match option" is case sensitive.
    S3550-1#
    S3550-1#sh int status | include (port|fa0/13)
    S3550-1#sh int status | include (Port|Fa0/13)
    Port      Name          Status       Vlan       Duplex  Speed Type
    Fa0/13                  connected    trunk      a-full  a-100 10/100BaseTX
    S3550-1#
    

    Use Port instead of port and Fa0/13 instead of fa0/13
    :mike: Cisco Certifications -- Collect the Entire Set!
  • Options
    mwgoodmwgood Member Posts: 293
    Also - the command will work with or without the parentheses.
  • Options
    SlowhandSlowhand Mod Posts: 5,161 Mod
    mikej412 wrote:
    In the 2nd part, the | means OR

    You want to include only the output lines from the show interface status command that includes the words Port (so that you get the "header line" for the output) OR the interface that you are interested in -- Fa0/13


    The reason you're not getting any output is because the "match option" is case sensitive.
    S3550-1#
    S3550-1#sh int status | include (port|fa0/13)
    S3550-1#sh int status | include (Port|Fa0/13)
    Port      Name          Status       Vlan       Duplex  Speed Type
    Fa0/13                  connected    trunk      a-full  a-100 10/100BaseTX
    S3550-1#
    

    Use Port instead of port and Fa0/13 instead of fa0/13
    Dammit, Mike! I've been trying to make that command work for the past year, or so, with no results. I keep thinking, "one of these days, I'll experiment with it and figure it out", sort of lazily and without too much effort put into it. . . and there you go, ruining what could have been several hours of hair-pulling and swearing, possibly even the kicking of more than one router. icon_lol.gif

    Free Microsoft Training: Microsoft Learn
    Free PowerShell Resources: Top PowerShell Blogs
    Free DevOps/Azure Resources: Visual Studio Dev Essentials

    Let it never be said that I didn't do the very least I could do.
  • Options
    ciscofunciscofun Member Posts: 12 ■□□□□□□□□□
    Thank you guys !!!! i got it !!
  • Options
    ciscofunciscofun Member Posts: 12 ■□□□□□□□□□
    case sensitive !! never thought of that !! thanks Mike !!! :D
  • Options
    redwarriorredwarrior Member Posts: 285
    I LOVE that one whenever I just want to find one thing in a running config when the device has a configuration a mile long...it really saves some time and tabbing! :D

    CCNP Progress

    ONT, ISCW, BCMSN - DONE

    BSCI - In Progress

    http://www.redwarriornet.com/ <--My Cisco Blog
  • Options
    IncInc Member Posts: 184
    For running config I use "sh run int <int><mod>/<port>"

    dc-sw00#sh run int vl1
    Building configuration...

    Current configuration : <some number> bytes
    !
    interface Vlan1
    <configuration>
    end

    also "sh run | section <string>" helps.

    Result will be configuration blocks where case sensitive search string has matched.

    Router#sh run | s FastEthernet0
    interface FastEthernet0
    description something
    no ip address
    duplex auto
    speed auto
    interface FastEthernet0.24979
    description Voice
    encapsulation dot1Q 24979
    ip vrf forwarding asdf
    ip address 192.168.0.2 255.255.255.0
    interface FastEthernet0.24980
    description Data
    encapsulation dot1Q 24980
    ip address 192.168.1.2 255.255.255.0
  • Options
    gojericho0gojericho0 Member Posts: 1,059 ■■■□□□□□□□
    I like using the carrot ^ as well especially for syslog events. It allows you to specify what the line begins with
  • Options
    tierstentiersten Member Posts: 4,505
    gojericho0 wrote:
    I like using the carrot ^ as well especially for syslog events. It allows you to specify what the line begins with
    Caret! :P
  • Options
    gojericho0gojericho0 Member Posts: 1,059 ■■■□□□□□□□
    haha i always thought it was called carrot because it was pointy like one
  • Options
    scheistermeisterscheistermeister Member Posts: 748 ■□□□□□□□□□
    Anyone else use the "/" to search through sh run?
    Give a man fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life.
Sign In or Register to comment.