- Copy 2 text files from ~ghoffman/course_files/it244_files to your
ex17 directory
cp ~ghoffman/course_files/it244_files/foo[12].txt .
- Run
ls
to make sure the copy operation worked
ls
- Run
cat
on foo1.txt and foo2.txt
cat foo?.txt
When you give cat
two files as arguments, it prints the first, followed by the second.
- Run
cat
on a file that does not exist
cat xxx.txt
cat
sends an error message to standard error, which is the terminal by default.
- Run
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
cat foo_xxx.txt
Notice that the error message was not inserted into the file.
- Run
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
cat errors.txt
errors.txt contains the error message that would have gone to the
screen if you had not redirected standard error.
- Run
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
cat everything.txt
Both the output and error message were redirected to the same file