![]() |
![]() |
![]() cat command
|
![]() |
The symbol <
stands for redirect standard input. It is used to
allow you to take input from a file instead of input from the keyboard. One
use of this symbol would be a datafile for input to a Fortran program.
The similar symbol >
stands for redirect standard output. It is
used to allow you to take input from a file instead of input from the keyboard. One
One use of this command would be to combine it with the cat command to create a
file. To create a file use cat >
followed by the filename and
press return. Unix will give you a new line and wait for you to type the text
for the file. When you are done typing text hold down the "control" key
(sometimes labeled "Ctrl") and the "d" key at the same time to end the file (^d).
Try creating a file named "hello" with the text:
Hello World! I am here!
> cat > hello
Hello World!
I am here!
Now type a ^d
(control d) to end your file.
Another way to use cat
and <
to create a file is to
take the input from a series of other files. Just put the names of the input
files before the <
. For instance:
> cat hello .forward > old.text
Use the cat
command to view the new file. (Quiz)
Review the cat
command
If you use this method, be sure to not use
the same name for input and output files. Cat
creates the file
first and will therefore erase your input file before writing the output file.
In the next section we will use the
append symbol to input from and output to the same file.
![]() |
![]() |
![]() cat command
|
![]() |