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
What option(s) with the find command to find files that have certain permissions. The mode may be expressed either symbolically or through octal.
-perm mode
What option(s) with the find command to search for files based on size.
-size n
What option(s) with the find command to search for files that belong to the specified group.
-group name
What option(s) with the find command to search for files whose GroupID is set to GID
-gid GID
What option(s) with the find command to search for files that are owned by a specified user
-user name
What option(s) with the find command to search for files by user UID number
-uid UID
What option(s) with the find command to limit the search of a directory and, perhaps, some limited number of subdirectories
-maxdepth levels
The blank command provides how many words or lines are in a text file.
wc
What option(s) with the wc command displays the file’s byte count
–bytes or -c
What option(s) with the wc command displays the files character count
–chars or -m
What option(s) with the wc command displays the file’s newline count
–lines or -l
What option(s) with the wc command displays the file’s word count
–words or -w
What option(s) with the wc command displays the length of the longest line in the file
–max-line-length or -L
What command do you use when you only want part of a file record?
cut
What option(s) with the cut command selects only designated character position(s)?
–characters -c
What option(s) with the cut command uses the designated delimiter as the field delimiter instead of the default delimiter(tab)
–delimiter -d
What option(s) with the cut command selects only designated fields
–fields -f
What option(s) with the cut command prevents lines without a delimiter from being printed
–only-delimited -s
What command allows you to sort large amounts of data
sort
What option(s) with the sort command considers only blanks and alphanumeric characters, but ignores special characters
–dictionary-order or -d
What option(s) with the sort command ignores case
–ignore-case -f
What option(s) with the sort command sorts string by numeric value
–numeric-sort or -n
What option(s) with the sort command writes result to the specified file
–output-file or -o
What option(s) with the sort command sorts in descending order
–reverse or -r
Though blank is often used for displaying short text files on screen, it can also concatenate files together
cat
The cat command needs how many files as an argument to concatenate into a new file
two
If you want to use a program’s output for future reference, you can blank it to a file
redirect
Redirection is achieved with the help of blank, which are short strings that appear after the command and its argument
Redirection operator
The output of redirection comes in what two types?
Standard output
Standard error
What redirection operator creates a new file containing standard output. It rewrites if the specified file already exists.
>
What redirection operator appends standard output to the existing file. If the specified file does not exist, it creates it.
> >