- Copy 2 text files from ~ghoffman/course_files/it244_files to your
cp ~ghoffman/course_files/it244_files/foo.txt .
ls to make sure the copy operation worked
cat on foo1.txt and foo2.txt
When you give
cat two files as arguments, it prints the first, followed by the second.
cat on a file that does not exist
cat sends an error message to standard error, which is the terminal by default.
cat on two files, one nonexistent, sending standard output to a file
cat foo1.txt xxx.txt > foo_xxx.txt
The error message went to the terminal, not the file.
- Print the contents of foo_xxx.txt
Notice that the error message was not inserted into the file.
cat on two files, one nonexistent, sending standard error to a file
cat foo1.txt xxx.txt 2> errors.txt
Notice that the contents of the first file is displayed on the terminal, but not the error message.
- Print errors.txt
errors.txt contains the error message that would have gone to the
screen if you had not redirected standard error.
cat on two files, one nonexistent, sending all output to a file
cat foo1.txt xxx.txt &> everything.txt
Noting appears on the screen.
- Print everything.txt
Both the output and error message were redirected to the same file