So aggravating - i can't find good documentation on how to use the Nexus regex command.

So, if my interfaces look like this:

interface Vlan224
  description MANAGEMENT
  no shutdown
  ip flow monitor netflow-monitor input  
  no ip redirects
  ip address
  ip ospf passive-interface
  ip router ospf 1 area
  ip pim sparse-mode
  hsrp version 2
  hsrp 224 
  priority 120

I want to run something similar to:

show run | inc (interface Vlan)|(ip address)

And the output to look similar to (if this were on IOS):

interface Vlan10
ip address
interface Vlan 11
ip address

5 Answers 5


You can do a show run | egrep interface.Vlan|ip.address. It does grab a bit more info, but should provide similar output to what you see in IOS. I think grep might work as well, but I used egrep and got the correct output.


If you are just looking for the IP addresses of the Vlan interfaces, a better way may be: show ip int br | grep -i vlan

Note: show ip int br in NXOS only shows layer 3 interfaces. To see status of all interfaces use show int br


for NXOS 4.0(2) and earlier: show run | grep -i face\ vlan|ip\ address

4.0(3) and up: show run | grep ignore-case face\ vlan|ip\ address

also the \ is how to escape the space with regex. Link for the NXOS regex: http://www.cisco.com/en/US/docs/switches/datacenter/sw/4_0/nx-os/fundamentals/configuration/guide2/fun_3about_cli.html#wp1237003

  • I also want to have info on the subnet information, so that's why I was trying to pull it out of the "show run". May 30, 2013 at 15:17
  • I see. Then try this one on for size: show run | grep -i face\ vlan|ip\ address this will also show all lines in the output that contain either "face vlan" or "ip address"
    – emynd
    May 30, 2013 at 15:19
  • Richard, thanks, but get a carrot under the f after grep -i May 30, 2013 at 17:06
  • should have looked deeper, my apologies. That syntax should work on NXOS 4.0(2) and earlier. For 4.0(3) and up replace -i with ignore_case here's the link cisco.com/en/US/docs/switches/datacenter/sw/4_0/nx-os/…
    – emynd
    May 30, 2013 at 17:27
  • Richard S, so it sounds like what I used to be able to do in ios with a | inc, I now need to do in NXOS with a | grep ignore-case blah blah blah. And spaces need to be escaped, like this "\ " without quotes? and I can still use multiple |'s to use as logical or's? May 30, 2013 at 17:49

An alternate syntax involving single quotes.

# show run | inc 'interface Vlan|ip address'

In NX-OS, argument parsing works a lot like bash.


The documentation I have seen says this should work:

show run | inc interface_Vlan|ip_address

Although it does not seem to for me on a 4k blade switch. I had success with

sh run | inc interface.Vlan|ip.address
  • That doesn't work on a 7K. 7K# sh run | inc interface_Vlan|ip_address 7K# sh run | inc interface_Vlan | ip_address - puts a carrot under the p. No output at all. May 30, 2013 at 15:08
  • I don't have Nexus to try it on but you might try (interface.Vlan|ip.address). The ^ under the p sounds like it's interpreting the "|i" as a second pipe. May 30, 2013 at 15:22
  • @Pseudocyber: *caret :-)
    – Paul Gear
    May 30, 2013 at 23:05
  • Per docs, and unlike IOS, "the underscore is only treated as a regular expression for BPG related commands"
    – belacqua
    Mar 6, 2014 at 20:50

The easy answer is that, for a one-to-one mapping from IOS to NX-OS, it looks like this:

IOS: show run | inc (interface Vlan)|(ip address)
NX-OS: show run | inc 'interface Vlan|ip address'

Note that this makes more sense when you leave out the extra parens in the original:

show run | inc (interface Vlan|ip address)

The key in this example is that for NX-OS, the parens are replaced by quote marks.

You could also use double quotes, i.e. "" .

NX-OS is Linux-based[1], and uses a *nix-like regular expression engine. The commands are odd comprises between English wording and standard regex idioms.

For example, what would be egrep -v in bash would look like egrep ignore-case
On the command line this would look something like

show run | egrep ignore-case vpc
show run | inc ignore-case vpc

An example of the verbosity (and strength) of the new regex features:
show run | egrep ignore-case vpc | egrep invert-match ignore-case peer

This would be equivalent to a bash-shell egrep -i vpc <input> | egrep -vi peer

Nevertheless, there is considerably more power and flexibility here than in current IOS.

The basic Cisco documentation is here*, but your command-line ? feature gives you quick reminders:

5k# show run | ?
  cut      Print selected parts of lines.
  diff     Show difference between current and previous invocation (creates temp files: remove them
           with 'diff-clean' command and dont use it on commands with big outputs, like 'show 
  egrep    Egrep - print lines matching a pattern
  grep     Grep - print lines matching a pattern
  head     Display first lines
  human    Output in human format
  last     Display last lines
  less     Filter for paging
  no-more  Turn-off pagination for command output
  section  Show lines that include the pattern as well as the subsequent lines that are more
           indented than matching line 
  sort     Stream Sorter
  tr       Translate, squeeze, and/or delete characters
  uniq     Discard all but one of successive identical lines
  vsh      The shell that understands cli command
  wc       Count words, lines, characters
  xml      Output in xml format (according to .xsd definitions)
  begin    Begin with the line that matches
  count    Count number of lines
  end      End with the line that matches
  exclude  Exclude lines that match
  include  Include lines that match

5k# show run | inc ?
  WORD         Search for the expression
  ignore-case  Ignore case difference when comparing strings
  line-exp     Print only lines where the match is a whole line

5k# show run | egrep ?
  WORD          Search for the expression
  count         Print a total count of matching lines only
  ignore-case   Ignore case difference when comparing strings
  invert-match  Print only lines that contain no matches for <expr>
  line-exp      Print only lines where the match is a whole line
  line-number   Print each match preceded by its line number
  next          Print <num> lines of context after every matching line
  prev          Print <num> lines of context before every matching line
  word-exp      Print only lines where the match is a complete word

You'll then want to search "fun" (what else?) to find the Fundamentals Configuration Guide (which contains the Regular Expression section in the Understanding the Command-Line Interface chapter).

Easter egg? Chapter numbers are in binary for this doc.

If you walk through the docs, you'll find a lot more *nix-like command-line tools, including cut, tr, and on the 7K, sed and some other goodies.

Also, don't overlook the prev and next modifiers for 'include' matches.

This will grab lines containing foo, as well as three lines before and two lines after for context:
show run | inc foo prev 3 next 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.