3 Replies Latest reply: May 15, 2019 3:50 PM by Luke RSS

    Question about show and Pipe command to search a config

    David

      Often I search a configuration using "Show config | begin <word>, but I'm also interested in seeing what immediately preceded this line, is there any command to see the previous line or page after a search returns output.

       

      I know in Juniper you can search and find an item, but then using the ctrl or arrow keys you can then move backwards or forwards in the configuration. I just wanted to see if there is something similar within Cisco. Seems there should be.

         
        • 1. Re: Question about show and Pipe command to search a config
          Juergen Ilse CCNA R&S

          David schrieb:

           

          Often I search a configuration using "Show config | begin <word>, but I'm also interested in seeing what immediately preceded this line, is there any command to see the previous line or page after a search returns output.

           

          I know in Juniper you can search and find an item, but then using the ctrl or arrow keys you can then move backwards or forwards in the configuration. I just wanted to see if there is something similar within Cisco. Seems there should be.

          As far as i know, there is no such possibility in Cisco IOS or Cisco PIXOS. But in some cases, it may be useful to use something  like

               "sh run | sec <keyword>

          (for example "sh run | sec ospf" to see all ospf related configuration) or on our backbone routers (C7600 series) i sometimes use

               "sh run part router bgp 15743"

          to see only the configuration of the BGP process ... There is more possibilitiues than just "| include" or " | exclude" which are sometimes useful ...

          • 2. Re: Question about show and Pipe command to search a config
            Ing_Percy

            Hi!

            David escribió:

             

            Often I search a configuration using "Show config | begin <word>, but I'm also interested in seeing what immediately preceded this line, is there any command to see the previous line or page after a search returns output.

            I don't see a option in a cisco device

             

            But, the pipe commands in both devices are useful and if you use it with more detail can get the exactly information.

             

            user@router> show route | ?

            Possible completions:

            count      Count occurrences

            display      Show additional kinds of information

            except      Show only text that does not match a pattern

            find           Search for first occurrence of pattern

            hold           Hold text without exiting the --More-- prompt

            last           Display end of output only

            match      Show only text that matches a pattern

            no-more  Don’t paginate output

            request   Make system-level requests

            resolve   Resolve IP addresses

            save       Save output text to file

            trim         Trim specified number of columns from start of line

             

            SW#show ip route | ?

              append    Append redirected output to URL (URLs supporting append operation only)

              begin     Begin with the line that matches

              count     Count number of lines which match regexp

              exclude   Exclude lines that match

              format    Format the output using the specified spec file

            include   Include lines that match

              redirect  Redirect output to URL

              section   Filter a section of output

              tee       Copy output to URL

             

            Regards!

            • 3. Re: Question about show and Pipe command to search a config
              Luke

              I don't think you can do it in IOS, but if you have NXOS, you can use egrep with prev to see a number of previous lines