CentOS Linux Server Guide

Showing or Displaying file content in CentOS Linux

cat is the Linux command is to concatenate files and print on the standard output on screen.
 

Name

cat

 

Syntax

 

cat [option] filename(s)

 

Note: sometimes the number of lines/rows of a file are too many and cannot fit the screen, you can use the following syntax.

 

cat [option] filename(s) | more

- this will enable to scroll the page by page, press <space bar>

 

cat [option] filename(s) | less

- this will enable to scroll the page by page, press <UP arrow key> and <DOWN arrow key>

 

 
Command and options Description

cat

cat is the short name of 'conCATenate'. We use this command to show the content of particular file or more than one files.

Below example shows the content of file name called network.


#
cat network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=srv1.example.local

 

 

cat -n

 -n options will display the line numbers including empty lines

You will notice line numbering are added, this included the empty lines in the file.

[root@srv1 demo]# cat -n network
# cat -n network
1 NETWORKING=yes
2 NETWORKING_IPV6=no
3 HOSTNAME=srv1.example.local
4
5
6

 

 

cat -b, --number-nonblank

this will output output lines with number but ignore blank lines
# cat -b network
1 NETWORKING=yes
2 NETWORKING_IPV6=no
3 HOSTNAME=srv1.example.local

 

Back to Managing Files and Folders in CentOS Linux



Copyright 2011 http://www.1a-centosserver.com All Rights Reserved

All trademarks are the property of their respective owners.

Contact Us | Terms of Use | Privacy Policy