Ls grep examples

broken image

Performing case-insensitive grep searches Our matching line is prefixed with ' 18:' which tells us this corresponds to line 18 in our file. If we specify the -n option, grep will prefix each matching line with the line number: It will be even more useful if we know where the matching line appears in our file. Viewing line numbers of successful matches If we use the -color option, our successful matches will be highlighted for us: For more information, see: Regular expression quick reference.

broken image

Other characters have special meanings, however - some punctuation marks, for example. In the above example, all the characters we used (letters and a space) are interpreted literally in regular expressions, so only the exact phrase will be matched. The PATTERN is interpreted by grep as a regular expression.

broken image