regex, sed, gawk, quiz 2 Flashcards
what is a regular expression
a description of a pattern of text
regex quantifier *
zero or more of the preceding characters
regex quantifier +
one or more of the preceding characters
regex quantifier ?
zero or one of the preceding characters
regex quantifier {min, max}
between min and max of preceding characters
regex character set [ ]
any single character in grouped set
regex character set [char - char]
any single enclosed range of characters, such as a-z, A-Z, 0-9
regex character set [^]
complement, excluding the enclosed character, a single character not in a grouped set. For example [^abcd] will match any character that isn’t a, b, c, or d.
[[:alpha:]]
alphabetic characters, [a-zA-Z]
used in regex
[[:lower:]]
lower case alphabetic characters, [a-z]
used in regex
[[:upper:]]
upper case alphabetic characters, [A-Z]
used in regex
[[:digit:]]
digits, [0-9]
used by regex
[[:alnum:]]
alphanumeric, [a-zA-Z0-9]
used in regex
[[:punct:]]
punctuation and symbols
used by regex
[[:space:]]
whitespace (e.g., newline, space, tab)
used in regex
regex anchor ^
beginning of the line
regex anchor $
end of the line
regex anchor <
beginning of word
regex anchor >
end of word
regex special character .
any single character, except newline
regex special character \
escape sequence, escapes the character following it
regex special character |
logical OR grouping
regex special character ()
group character set
grep
standard version of grep that supports basic regular expressions
egrep (grep –E)
Extended grep that understands extended regexes
fgrep (grep –F)
Supports fixed strings for faster performance
rgrep (grep –R)
Traverses subdirectories recursively
grep option -c
print only a count of matched lines
grep option -i
ignore uppercase and lowercase distinctions
grep option -l
list all files that contain the specified pattern