Linux Streams, Redirection and Pipes Flashcards

1
Q

stdin

A

Standard input - what command you type into terminal

Numerical value = 0
Numerical value aka File Descriptor, is the number the system applies to it

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

stdout

A

Standard output on the screen from a command that was run

Numerical value = 1

Default standard output is to your screen, but it’s possible to redirect the output to many other locations/display types

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

stderr

A

providing the incorrect standard input will result in an error. This is called the Standard Error. There are other ways to receive a standard error, like incorrect syntax, etc.

Numerical value = 2

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

redirecting output

A

It’s possible to redirect the stdout to a file, for instance.

Command to redirect the output of a command to a file:
ls -la > directoryoutput.txt

”>” will pipe the output into a file called “directoryoutput.txt” and overwrite it’s original content

”»” use this to append the document instead of overwriting it

Hint: Think of the > like a funnel point to where the file will go.

Redirectory ex - It’s also possible to redirect to a command, but it’s less common.

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

How would you redirect errors from a script to a log file?

A

Example:
./show.sh 1» good.txt 2» errors.txt

Using “1»” will look at standard output and put them in a good.txt file (appending, not replacing).

Using “2»” will take the standard error and put them in a errors.txt file (appending, not replacing).

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