We have now discussed both regular expressions and globbing. As we saw, they were very similar, but still had differences to be aware of. In our examples for regular expressions, and a little for globbing, we have already seen how grep
can be used.
In this part, we'll introduce another command, which is very handy when combined with regular expressions: sed
(not to be confused with set
). We'll start with some advanced uses for grep
.
We have already discussed a few popular options for grep
to alter its default behavior: --ignore-case
(-i
), --invert-match
(-v
), and --word-regexp
(-w
). As a reminder here's what they do:
-i
allows us to search case-insensitively-v
only prints lines that are not matched, instead of matched lines-w
only matches on full words that are surrounded by spaces and/or line anchors and/or punctuation marks
There are three other options we'd like to share with you. The first new option, --only-matching
(-o
) prints...