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
or
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
tech'!)
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