Chapter 8 Flashcards
Many Linux programs employ blank, which are tools for expressing patterns in text.
regular expressions
Name the two most common forms of regular expression
basic and extended
Characters enclosed in square brackets constitute blank, which match any one character within the brackets
Bracket Expressions
Including a blank after the opening square bracket matches against any character except the ones specified.
caret ^
A blank is a variant on a bracket expression. Instead of listing every character that matches the start and end point are separated by a dash.
Range expressions
The dot (.) represents any blank except a newline.
single character
A blank consists of all the characters before the line is terminated with a new line.
text line (sometimes called a record)
When not in brackets the blank represents the start of a line.
caret ^
Blank represents the end of a line.
dollar sign $
An blank represents zero or more matches and is commonly used with a dot (.) to specify a substring.
asterisk *
If you want to match a special character such as (.), you must escape it by using what?
backslash /
With repetition operators, a blank matches one or more occurrences while a blank specifies zero or one.
plus +
question mark ?
The blank separates two possible matches.
vertical bar |
Blank surround subexpressions and are often used to specify how to apply operators.
Parenthesis ()
The blank command searches for files that contain a specified string and returns the name of the file and (if it’s a text file) the line containing the string
grep
You can also use blank to search a specified file for a specified string
grep
What option(s) with the grep command displays the number of lines that match, rather than the lines that contain matches to the regular expression
–count or -c
What option(s) with the grep command takes pattern input from the specified file rather than from the command line. The fgrep command is a shortcut for this option.
–file=file or -f file
What option(s) with the grep command performs a case-insensitive search, rather than the default case-sensitive search
–ignore-case -i
What option(s) with the grep command searches in the specified directory and all subdirectories rather than simply the specified directory. The rgrep is a shortcut for this command.
– recursive -R or -r
What option(s) with the grep command to use a regular expression. Alternatively, you can call egrep
–extended- regexp or -E
Blank is when you must enclose regular expressions in quotes. Otherwise, the shell will incorrectly treat the regular expressions as shell commands.
shell quoting
The blank utility uses a brute-force approach to finding files.
find
What option(s) with the find command searches for files using their name. Doing so finds files that match the specified pattern. This pattern is a shelled wildcard pattern and not a regular expression
-name pattern