Redirects Flashcards

1
Q

How can you add text to a file or overwrite an existing file?

A

echo “text” > /path/to/file

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

How can you append text to an existing file?

A

echo “text”&raquo_space; /path/to/file

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

What are the 3 standard redirects in Linux?

A

stdin (0) stdout (1) stderr (2)

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

What is the input redirect symbol?

A

<

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

Give an example of the input redirect action

A

wc < testfile (sending the testfile into the word count program - same as cat testfile | wc)

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

How can you suppress error output from a command?

A

<command></command>

2> /dev/null

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

Give an example of the tee command

A

echo “TESTING” | tee testfile (saves to file and displays “TESTING” on stdout - overwrites existing)

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

How can you append to file using tee?

A

echo “TESTING” | tee -a testfile

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

What is the | (pipe) used for?

A

To send the output of one command to the input of another command

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

How do you redirect output and error to the same place?

A

2>&1

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

What location can you redirect to to discard output?

A

/dev/null

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