Linux Commands

View Linux File Contents with cat.

View Linux File Contents with cat.

There are so many ways to view Linux file contents. One of the simplest is way to view the file contents is using the cat command:

 

Example:

root@fedora ~]# cat filename.txt

Create file

Using cat command

Fedora Core

Operating

Systems

[root@fedora ~]#


Note: From the example above, the cat command is use with no greater-than (>) sign. The file name that you want to view is issue after the cat command. The text in the file is displayed immediately after you hit the enter key, all the contents of the file display after you hit enter key, the first line after the cat command. The "end of file" content is mark on the appearance of shell prompt.


Create Files with cat.

 

Create Files with cat.


There are so many ways of creating a file in Linux base operating system. One of the simples way to create a file is using the cat command:


[root@fedora ~]# cat > filename.txt
Create file
Using cat command
Fedora Core
Operating
Systems

[root@fedora ~]#


Note: The greater-than sign (>) after cat command is necessary to create the file.
The text typed is written to a file with the specified file name, on the example above the text that you type is written to the text file named filename.txt.
Press Ctrl+D key after a line-break (just hit the enter key after last line of text) to denote the end of the file. The next shell prompt is displayed then use the ls -l command to verify the existence of the new file called filename.txt

 


Custom Search

Syndicate content