IT 1100 : Introduction to Operating Systems

Chapter 6


Concatenate Files

As you read the section on the cat command, please note that our primary usage of this command in this class is to display the content of a file. It does a whole lot more, but we won’t worry about that right now.

The cat command has similar results to the less command. It allows us to view the contents of a file. Try the following commands to see the difference.

less /etc/passwd

cat /etc/passwd


Redirection


Redirection

Sometimes you want to redirect the standard output from the screen to a file or some other location (a printer?). You can do this by using either > or >> after the command.

Practice the above commands a few times and then use the cat command to see if you can figure out the difference between the > and >>


Redirect StdErr

Issue a command that generates an error like:

Now , redirect that error to a file:


Redirect both

To redirect both stdout and stderr to same file do:


Redirect output to the black hole

What if I don’t want to see output on the screen AND I don’t want to send it to a file? There is a location in linux to do that.


Piping

You can take the output of one command and send it to another command by using the pipe | operator. Here are some examples:

The above command took the output of the ls command and piped it to the wc command. You could use man wc to figure out what either command does if you don’t remember.

What does this command do?


Textbook Time

Read and Complete the Exercises in the Book


Last Updated 01/22/2018