Class
Character class matches any one of serveral characters.
#!/bin/sh
: "Character class []
matches any one of several characters
For characters inside a class, the implication is OR
For chars outside a class, the implication is AND
Within a class, dash (-) means a range of chars
Multiple ranges are fine [0-9a-z]
"
A='gray grey greay greey gr-y'
B='<H1></H1> <H22></H22> <H3></H3>'
echo $A | grep 'gr[-ae]y' -o | tee result.txt
echo $B | grep '<H[1-3]>' -o | tee result.txt -a

gray
grey
gr-y
<H1>
<H3>
Questions and answers
Character class [ae] means [a,2]
- a) a or e
- b) a and then e
Match a range of characters
- a) [a-e]
- b) [ae]
Which one matches the dash character?
- a) [a-z]
- b) [-a-z]
Multiple ranges like [0-9A-Z] are permited?
- a) true
- b) false