Redirection Flashcards
(14 cards)
1️⃣ Q: What can you use the shell to do with stdout and stderr?
A: Redirect them from the terminal screen to a file on the filesystem.
2️⃣ Q: What is used to redirect output to a file in the shell?
A: The > shell metacharacter followed by the absolute or relative pathname of the file.
3️⃣ Q: How do you redirect only stdout to a file called goodoutput?
A: Append the number of the file descriptor (1) followed by the redirection symbol > and the file name goodoutput.
What can be assume form the results from the following command
[root@server1 ~]# ls /etc/hosts /etc/h 1>goodoutput
ls: cannot access ‘/etc/h’: No such file or directory
[root@server1 ~]#_
the stderr displayed on the terminal screen because it was not redirected to a file while the /etc/hosts was due to it being redicited to a file called goodoutput
what number is do you appended for stout?
1
what number is do you appended for sterr
2
true or false the shell assumes stdout by default if no numerb is given for rediection?
True
1️⃣ Q: Does the order of redirection on the command line matter in Linux?
no
what happens if you used differing filenames to hold the contents of stdout and stderr?
what happens is a loss of data due to writing to both at once
how do redirect both stdout and sdterr to the same file without anyloss assuming there are two files you are lsing?
> goodoutput 2>&1
how do you remove errors from common output in order to discard them>?
edirect the stderr to /dev/null
how do you prevent a file from being cleared by the shell when redicecting?
do the double redicited infount IE»_space;
1️⃣ Q: What is a limitation of some commands regarding file input?
A: Some commands only accept files that the shell passes through stdin.
3️⃣ Q: What can the tr command be used for?
A: To replace characters in a file sent via stdin.