Linux: grep command Flashcards
Learn the basics of regular expressions. From Jason Wertz's youtube tutorial
1
Q
dot (‘ . ‘)
A
Matches 1 of any character
grep “c.t” dictionary
wildcat
yacht
woodcutter
grep ^c.t$ dictionary
cat
cut
2
Q
Literal string
A
grep ^the word$ dictionary
3
Q
Classes
A
a defined class of characters, whether individual or a range
[a-c]at = acrobat [0-9][0-9] = 99 ,13
4
Q
Find all lowercase letters and numbers USING classes
A
[a-z0-9]
5
Q
Character classes
A
[[:alpha:]] = [a-zA-Z] [[:upper:]] = [A-Z] [[:lower:]] = [a-z] [[:digit:]] = [0-9] [[:alnum:]] = [0-9a-zA-Z] [[:space:]] matches any whitespace, including tabs
6
Q
Character class abbreviations
A
\d = [[:digit:]] \w = [[:alnum:]] \s = [[:space:]]
\D = [^0-9] \W = [^a-z....] \S = [^\t\n\r\f]