Use I/O redirection to perform the following tasks in the specified order:
Write line containing the word COMPUTER to the text file output.txt. If the current directory already contains a file output.txt, the file must be overwritten.
In Unix, it is standard that each line of a text file ends with a newline. This is also the definition for a line in the POSIX standard1:
3.206 Line
A sequence of zero or more non- <newline> characters plus a terminating <newline> character.
According to this convention, all text files (except empty ones) end with a newline, because there must also be a newline after the last line. Many Unix commands will not work properly for text files that do not follow this convention.
Download the text file reservoir.txt2 using the command wget or the command curl. Make sure that all output generated by the command is immediately discarded. In other words: the output the command generates may never be displayed in the terminal or written to a file.
Try to find out what you can do with the file /dev/null. What kind of file is this?
Append the contents of the text file reservoir.txt3 to the text file output.txt, without the existing content of the file output.txt being overwritten. Any possible error messages must be written to the text file error.txt.
Write the output of the command whoami — along with any possible error messages — to the text file userinfo. What information is generated by this command? What possible applications could this command support?
First try to predict the result of the next three commands and then execute the commands to see if your predictions are correct. We assume that the current directory does not contain a file named xxx. Explain the differences in the output of these commands.
Execute the following command:
$ sort xxx 2> userinfo
Execute the following command:
$ sort < xxx 2> userinfo
Execute the following command:
$ < xxx 2> userinfo sort