Contact us

Print

Using cat

cat is short for concatenate, which means that it strings files together. The command cat will also display the contents of an entire file on the screen. You will use cat along with the redirection symbol “>” to create a file.

To use cat to create a file


1. Change directory to the /root/folder1 directory

2. Create a new text file called “first.txt”


[root@localhost folder1]# cat > first.txt


3. Type in the phrase below at the blank prompt and press <ENTER>.

This is a line from first.txt !!

4. Press the control key simultaneously with the “c” key on the keyboard.



5. Type “cat first.txt” to read the text you just typed in,

[root@localhost folder1]# cat first.txt

This is a line from first.txt !!


6. Create another file called “second.txt” using cat. Type the following text
into the file – “This is a line from second.txt !!”

What is the command to do this?

To use cat to concatenate files together


1. You will concatenate the files “first.txt” and “second.txt”. Type:


[root@localhost folder1]# cat first.txt second.txt


What is your output?


Created by: system. Last Modification: Wednesday 26 of November, 2008 19:23:52 EST by wale.

...