http://www.technicalpage.net/search/label/SQL

>> cat command


cat 
cat is used to see the contents of a file and to create new file.

To see the contents of an existing file:

cat  filename  press ENTER

Create new file or write to an existing file.

cat>fileName

cat>fileName.txt  press ENTER , the cursor moves to the one line below,
enter the text
then press CTRL+d

Above command will create a new fileName.txt , if the file does not exist already , and adds the entered text into it. If the file fileName.txt exists already, then it adds the entered text into the existing file replacing the previous contents of the file.



Note: extension of the file is optional, you can put it or not as per your need.

To copy contents of a file to another file :

cat  file1>>file2 press ENTER
Above command will copy the contents of file1 to file2 appending the second file. It will not replace the contents of file2.  If the file2 does not exist already ,then it creates file2 and copies the contents of file1 to file2.


To copy contents of a file to another file, replacing the contents of second file:

cat file1>file2  press ENTER
Above command will copy the contents of file1 to file2 replacing the contents of file2. If the file2 does not exist already ,then it creates file2 and copies the contents of file1 to file2.


Concatenate two or more files:

cat  file1 file2 file3 ....
The output will show contents of all the files involved.


GoTo_Main UNIX Page


NEXT



.

No comments:

Post a Comment