section 7 - IO redirection, piping, regex, archiving, searching, extraction Flashcards

1
Q

xargs

A

enables a user to generate command line options from files, or another program’s output. Useful if you want to use same command on a list of files.

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

What does the following re-director operation do?
>

A

Creates a new file containing standard output.

If the specified file already exists, it is overwritten with whatever the program exports.

Can be useful when there are too many errors shown on screen, allows you to only see the standard output.

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

What does the following re-director operation do?
»

A

Appends the existing output to an existing file.

Does not overwrite an existing file, only adds to the bottom of the file.

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

What does the following re-director operation do?
2>

A

Creates a new file containing any standard errors.

If the specified file already exists, it is overwritten with whatever errors the program exports.

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

What does the following re-director operation do?

A

Appends standard error to an existing file.

Does not overwrite existing files, only appends.

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

What does the following re-director operation do?
<

A

Sends the content of a specified file as INPUT back into the
standard input.

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

What does the following re-director operation do?
«

A

Accepts text on the following lines as standard input.

Basically allows typed commands to be used for input rather than just reading from a file.

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

What does the following re-director operation do?
<>

A

Specified file can be used for standard input and standard output; allows the program to actively read and write to the same file as needed.

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

grep

A

searches for a pattern that defines a set of strings

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

&>

A

Creates a new file that contains both the standard output and standard error.

Will overwrite specified file if it already exists.

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

How would you do a search for the keyword “apple” in the /etc directory, while also discarding any standard errors that would appear on screen?

A

grep apple /etc/* 2> /dev/null

the /dev/null file acts as a trash bin and discards any output

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

tar

A

Archives multiple files into a single archive file, the original files remain on the disk.

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

tarball

A

compressed tar archive to save space. Can be archived with tar then compressed with a zip program:
gzp + tar = .tgz
bzip2 + tar = .tbz/.tb2/.tbz2
xz + tar = .txz

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

zip

A

gzip (.gz) gunzip
bzip2 (.bz2) bunzip2
xz (.xz) unxz

used to compress individual files, must be uncompressed first before a program can read it.

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

regular expression grep

A

grep -E

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

displays the lines a string appeared on

A

grep -n