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.
> >
What redirection operator creates a new file containing error messages. If the specified file already exists, it is overwritten
2>
What redirection operator appends standard error to the existing file. If the specified file does not exist, it is created.
2»
What redirection operator creates a new file containing both standard output and standard error. If the specified file exists, it is overwritten.
&>
What redirection operator sends the contents of the specified file to be used as standard input
<
What redirection operator accepts the text on the following lines as standard input
«
What redirection operator causes the specified file to be used for both standard input and standard output
<>
In a blank, standard output from one program is redirected as standard input to a second program.
pipe
The blank command’s purpose in a pipeline is to build a command from its standard input
xargs
GIve the xargs basic syntax
xargs [OPTIONS] [COMMAND [INITIAL-ARGUMENTS]]
Text placed within two blank is treated as a separate command whose results are substituted on the command line
back ticks `
Using backticks in this way is called blank, because you are providing a substitution for one of the command’s arguments
command substitution
Name the other and more favorable way of denoting command substitution
$()
The tar’s program name stands for blank
tape archive
Regardless of its name, you can use blank to backup (or archive) data to your hard disk or other media, not just to tapes
tar
Because an archive file can be quite large, it is often compressed via the tar program into a blank
tarball
Whenever you run tar, you use blank option and usually at least one blank
one
qualifier
Name the tar option(s) that creates an archive
–create or -c
Name the tar option(s) that appends tar files to an archive
–concatenate or -A
Name the tar option(s) that appends non-tar files to an archive
–append or -r
Name the tar option(s) that appends files that are newer than those in an archive
–update or -u
Name the tar option(s) that compares an archive to files on the disk
–diff or –compare or -d
Name the tar option(s) that lists an archive’s contents
–list or -t
Name the tar option(s) that extracts files from an archive
–extract or –get or -x
Name the tar qualifier(s) that changes to directory dir before performing operations
–directory dir or -C
Name the tar qualifier(s) that uses the file called file on the computer called host as the archive file
–file[host:]file or -f
Name the tar qualifier(s) that performs an incremental backup or restore, using file as a list of previously archived files
–listed-incremental file or -g
Name the tar qualifier(s) that backs up only one filesystem(partition)
–one-file-system
Name the tar qualifier(s) that creates or extracts a multitape archive
–multi-volume or -M
Name the tar qualifier(s) that changes tapes after N kilobytes
–tape-length N or -L
Name the tar qualifier(s) that preserves all protection information
–same-permissions or -p
Name the tar qualifier(s) that retains the leading / on filenames
–absolute-names or -P
Name the tar qualifier(s) that lists all files read or extracted; when used with –list displays the file sizes, ownership, and time stamps
–verbose or -v
Name the tar qualifier(s) that verifies the archive after writing it
–verify or -W
Name the tar qualifier(s) that excludes file from the archive
–exclude file
Name the tar qualifier(s) that excludes files listed in file from the archive
–exclude-from file or -X
Name the tar qualifier(s) that processes an archive through gzip
–gzip or –ungzip or -z
Name the tar qualifier(s) that processes an archive through bzip2
–bzip2 or -j or( -I or -y older)
In Linux, the blank, blank, and blank all compress individual files.
gzip, bzip2, xz
Of the three compression commands, which provides the least compression?
gzip
Of the three compression commands, which provides the most compression?
xz
What is the decompression program for gzip?
gunzip
What is the decompression program for bzip2?
bunzip2
What is the decompression program for xz?
unxz
What is the filename extension for gzip?
.gz
What is the filename extension for bzip2?
.bz2
What is the filename extension for xz?
.xz
What is the tarball filename extension for gzip?
.tgz
What is the tarball filename extension for bzip2?
.tbz or .tbz2 or .tb2
What is the tarball filename extension for xz?
.txz
The gzip, bzip2 and xz compression programs all apply blank, meaning the data recovered by uncompressing the file is identical to what went into it
lossless compression
Some graphics, audio, and audiovisual file formats apply blank, in which some data is discarded
lossy compression
Outside of the Unix and Linux world, the blank file format is a common one that fills a role similar to a compressed tarball.
zip
What option used with the zip command sets the amounts of compression from low to high
-0 through -9
What option used with the zip command deletes the specified files from the archive file?
–delete or -d
What option used with the zip command encrypts the archive with a password
–encrypt or -e
What option used with the zip command updates the file in an archive if they’ve changed since the original archive’s creation
–freshen or -f
What option used with the zip command performs on repairs on a damaged archive file.
–fix or -F (minimal)
–fixfix or -FF
What option used with the zip command updates the file in an archive if they’ve changed since the original archive’s creation
–filesync or -FS
What option used with the zip command appends files to an existing archive
–grow or -g
What option used with the zip command displays basic help information
–help or -h or -?
What option used with the zip command moves the files into the zip archive - that is, the original files are deleted
–move or -m
What option used with the zip command includes files subdirectories inside the directories you specify
–recurse-paths or -r
What option used with the zip command creates a potentially multifile archive with each file no larger than size bytes
–split-size size or -s size
What option used with the zip command excludes the specified files
–exclude files or -x files
What option used with the zip command includes symbolc links
–symlinks or -y
What option used with the unzip command freshens files from the archive
-f
What option used with the unzip command lists files in the archive but does not extract them
-l
What option used with the unzip command extracts files to a pipeline
-p
What option used with the unzip command test the integrity of files in the archive
-t
What option used with the unzip command updates the files, but also extracts files that don’t exist on the filesystem
-u
What option used with the unzip command lists files in the archive in a more verbose format than -l does
-v
What option used with the unzip command converts filenames to lowercase if they originated on an uppercase-only OS, such as DOS
-L
What option used with the unzip command never overwrites existing files
-n
What option used with the unzip command overwrites existing files without prompting
-o
Which of the following commands will print lines from world.txt that contains matches to changes and changed
A. grep changes[ds] world.txt
B. tar change[d-s] world.txt
C. find “change’d|s” world.txt
D. cat world.txt changes changed
E. find change[^ds] world.txt
A
Which of the redirection operators appends a program’s standard output to an existing file without overwriting that file’s original contents.
> >
You’ve received a tar archive, but you want to check the name of the files it contains before you extract them. Which of the following commands would you use to do this?
A. tar uvf data79.tar
B. tar cvf data79.tar
C. tar xvf data79.tar
D. tar tvf data79.tar
E. tar Avf data79.tar
D
True or False: the regular expression Linu[^x].*lds matches the string Linus Torvalds
True
True or False: The find command allows you to locate files based on size
True
True or False: To compress files archived with zip, you must use an external compression program such as gzip, xz, or bzip2 in a pipeline with zip
False
The blank command can extract specified data fields from a file’s records
cut
Complete the following command to redirect both standard output and standard error from the bigprog program to the file out.txt.
$bigprog blank out.txt
&>
THe gzip, bzip2, and xz programs all perform blank compression.
Lossless