Linux distributions have three basic forms of Input/Output (standard input, stan
ID: 3863168 • Letter: L
Question
Linux distributions have three basic forms of Input/Output (standard input, standard output, and standard error) redirections which will need to understand how to use each one.
State the purpose of each of three I/O forms including which file descriptor is used for each one
Provide your own redirection command syntax example as well as description what your command syntax will do
(optional-challenging) How would command syntax appear if you want redirect the cat command standard ouput and standard error to the same file? This would be useful if you want to view results of the cat command in a file containing both regular output and any error(s) which might appear (ex. syntax error).
Explanation / Answer
Here are the explanations of all three basic forms of Input/Output in Linux
Standard input(STDIN) -
File Descriptor - 0
Syntax: 0<
Description: Baiscailly this input comes from the keyboard. Whenever we type any thing on terminal it gets send to stdin. Linux also allows to get the input from file as well.
Standard output(STDOUT)
File Descriptor - 1
Syntax: 1>, output > or output >> (append to existing file)
Description: As the name suggests it send the output either to terminal or any file. in case redirection to file if the file does not exists it creates the file. we can also append the output to existing file.
For eg:
ls >> list (will append the result to the existing file)
Standard Error (STDERR)
Descriptor - 2
Syntx : 2>
Description: Whenever a result is written either to the terminal or file it can be in two forms.
1) Valid output as described above.
2) Any error in command or in execution of the command .
So for #2 Standard error comes into picture.
For eg:
Syntax for sending cat command standard output and error to the same file:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.