Egrep / Character classes  

1) Character class [ae] means

2) Match a range of characters

Match any one of serveral characters

gr[ea]y means to find g, r, followed either an e or an a, followed by y. Notice how outside a class, literal characters (g, r) have an implied and-then between them. It's completely opposite inside a character class. The implication is or


Within a character class metacharacter "-" (dash) indicates a range of characters <H[1-6]> is identical to <H[123456]>. Multiple ranges are fine: [0-9A-F] You can freely combine ranges with literal characters: [0-9a-z_!.?] Note that a dash is a metacharacter only within a character class, otherwise it matches the normal dash character.