06 Redirection Flashcards

1
Q

What is the function of the “cat” command

A

Concatenate files

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

What is the function of the “sort” command

A

Sort lines of text

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

What is the function of the “uniq” command

A

Report (or omit) repeated lines

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

What is the function of the “grep” command

A

print lines of text matching a given pattern

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

What is the function of the “wc” command

A

Performs a word count; yields newlines, word count, and byte count of a file

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

What is the function of the “head” command

A

print ‘n’ lines from the beginning of a file

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

What is the function of the “tail” command

A

print the last ‘n’ lines from a file

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

What is the function of the ‘tee’ command

A

read from stdin, write to stdout AND to a file

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

Program output consists of what two types of data?

A
  1. Program execution results

2. Status/error messages

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

Programs send their output to a special file (typically the screen), known as … ?

A

Standard Output

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

What is the REDIRECTION operator?

A

>

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

What is the APPEND operator?

A

> >

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

If standard error has a file descriptor of ‘0’, where does the output go?

A

A file descriptor of ‘0’ sends error output to standard input

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

If standard error has a file descriptor of ‘1’, where does the output go?

A

A file descriptor of ‘0’ sends error output to standard output

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

If standard error has a file descriptor of ‘2’, where does the output go?

A

A file descriptor of ‘0’ sends error output to standard error

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

Assuming you give the command:

“ls -l /bin/usr 2> ls-error.txt”

Describe the output

A

list the contents of /bin/usr, which does not exist,

take the output that would’ve gone to standard error, and write it out as a new file ls-error.txt

17
Q

You issue the ‘cat’ command with no arguments. Describe what the system is doing…

A

Cat is reading from stdin (waiting for keyboard input)

18
Q

What is a ‘pipeline’

A

connects stdout to stdin of the next command

19
Q

What is the difference between ‘>’ and ‘|’ ?

A

Redirection connects a command to a file

A Pipeline connects the output of one command with the input of the next command.

20
Q

Describe the output of this command:

ls /bin /usr/bin | sort | less

A
  1. Create two directory listings (/bin, /usr/bin), passed to sort
  2. Sort command yields a single, sorted list; passed to ‘less’ command
  3. less outputs that single sorted list to screen
21
Q

Describe the output of the following command:

ls /usr/bin | tee ls.txt | grep zip

A
  1. list directory /usr/bin; passed to ‘tee’
  2. ‘tee’ writes directory listing to ls.txt, passes output to grep
  3. Grep searches the directory listing for “zip”, writes matched lines to screen