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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Literal string

A

grep ^the word$ dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Classes

A

a defined class of characters, whether individual or a range

[a-c]at = acrobat
[0-9][0-9]  = 99 ,13
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Find all lowercase letters and numbers USING classes

A

[a-z0-9]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Character class abbreviations

A
\d  = [[:digit:]] 
\w = [[:alnum:]] 
\s  = [[:space:]] 
\D = [^0-9]
\W = [^a-z....]
\S = [^\t\n\r\f]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly