![]() When we list the contents of the words file, we see the following output: $ cat /usr/share/dict/words This file contains 479,826 words and is provided by the words package. 1 root root 11 /usr/share/dict/words -> linux.words grep basicsĭuring this part of the article, we use the words file, which you can find at the following location: $ ls -l /usr/share/dict/words With man pages at our disposal, we now can use grep and explore its options. On Red Hat Enterprise Linux-based systems, we can run the following to list grep's documentation files: $ rpm -qd grep Many (if not all) Unix tools provide man pages during install. The best way to understand the working of a program or utility is to consult its man page. In an upcoming article, we will also see how to use sed (Stream Editor) to manipulate a stream. ![]() In this article, we will cover the grep command to search for patterns, whether found in files or coming from a stream (a file or input comping from a pipe, or |). There are many tools we can use in *nix-based systems to find and manipulate text. ![]() How well do you know Linux? Take a quiz and get a badge.Linux system administration skills assessment.A guide to installing applications on Linux.Download RHEL 9 at no charge through the Red Hat Developer program.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.Īlso, don't overlook the prev and next modifiers for 'include' matches. 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).Įaster egg? Chapter numbers are in binary for this doc. Note that the docs may be version and platform dependent.Ĭisco Nexus 7000 Series Switches Configuration GuidesĬisco Nexus 5000 Series Switches Configuration Guides.Word-exp Print only lines where the match is a complete word Prev Print lines of context before every matching line Next Print lines of context after every matching line Line-number Print each match preceded by its line number Invert-match Print only lines that contain no matches for Line-exp Print only lines where the match is a whole lineĬount Print a total count of matching lines only Ignore-case Ignore case difference when comparing strings Vsh The shell that understands cli command ![]() Uniq Discard all but one of successive identical lines Tr Translate, squeeze, and/or delete characters Section Show lines that include the pattern as well as the subsequent lines that are more No-more Turn-off pagination for command output Grep Grep - print lines matching a pattern With 'diff-clean' command and dont use it on commands with big outputs, like 'showĮgrep Egrep - print lines matching a pattern The basic Cisco documentation is here*, but your command-line ? feature gives you quick reminders: 5k# show run | ?ĭiff Show difference between current and previous invocation (creates temp files: remove them Nevertheless, there is considerably more power and flexibility here than in current IOS. This would be equivalent to a bash-shell egrep -i vpc | egrep -vi peer Show run | egrep ignore-case vpc | egrep invert-match ignore-case peer On the command line this would look something likeĪn example of the verbosity (and strength) of the new regex features: The commands are odd comprises between English wording and standard regex idioms.įor example, what would be egrep -v in bash would look like egrep ignore-case NX-OS is Linux-based, and uses a *nix-like regular expression engine. The key in this example is that for NX-OS, the parens are replaced by quote marks. ![]() Show run | inc (interface Vlan|ip address) Note that this makes more sense when you leave out the extra parens in the original: NX-OS: show run | inc 'interface Vlan|ip address' IOS: show run | inc (interface Vlan)|(ip address) The easy answer is that, for a one-to-one mapping from IOS to NX-OS, it looks like this: ![]()
0 Comments
Leave a Reply. |