[Li|U]nix: grep and grep -E, part1
Self-tutoring about Unix: the tutor continues about grep.
After reading my post from yesterday, I was in disbelief. I even tried the command there several more times – it works every time.
grep isn’t necessarily expected to support alternation – that is, the “or” operator, | (but grep -E does). Surprisingly, the system I experimented with yesterday indeed does support | with grep.
So, what are some differences between grep and grep -E (on this system, anyway)? Well, one is that grep needs escape sequences to specify specific multiples. For instance, the regex ^[a-zA-Z]{0,5} might mean 0 to 5 letters at the front of a string. I can do that with grep, this way:
grep “[a-zA-Z]\{0,5\}”
but with grep -E, this way:
grep -E “[a-zA-Z]{0,5}”
Relating to grep, the option -E means “enhanced” or “extended” functionality.
Source:
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.