cat command

 cat command

cat = concatenate 

In this section, what is cat command and why we use it and what are its options, we will give detailed information about all these questions by giving examples.so let's learn 

A.what is cat command ?

it concatenates files and displays them on the screen.  This means that this command continuously displays the contents of the files one after the other, so that we think that this content is present inside the same file which is displayed on the screen.

B. why use cat command ?

We can have many files present, by opening these files, we use its contents for useful work.Sometimes these files prefer to view the contents of all the files together instead of opening one file at a time, this command is very useful at that time. Apart from this, there are some other important features of this command, which will be known further.

C. operation with its options 

In this we will discuss the cat command with its option. Within this, we will tell the main purpose of cat command with practical.

Syntax :

cat  [options]  file1 file2 file3 ... ... ..

1. cat  file :

 With no options in this command, it displays the contents of the file on the screen when only one file argument is given.










We have a file named file.txt. On running it with cat command, the content of the file is being displayed.

2. cat file1 file2 file3 ... ... :

When we run two or more files with this command, then the contents of all the files are displayed one after the other. 

To understand this, we will take three files, you can take two files or more than three files.

First file is file.txt and two more files are shown on the screen below









Now we will run all three files with cat command. 













On the above screen you can see the contents of all the three files displayed one after the other.

3. cat -n file :
When we use -n with this command, it will number the contents of the file on the screen.















In the above picture now we can see how the numbering is done inside the red line rectangle.

4. cat -b file :
It shows the contents of the file by numbering but does not number the empty lines.
















You can see in the above picture that the numbering is done only in the nonempty line. 

5. cat -s file / cat --squeeze-blank file :
If two or more blank lines are present in the contents of the file, then converts them to a single line on the screen.
















You can see in the above screen that two consecutive blank lines of file.txt file were displayed in a single blank line with the help of -s option. 

6. cat -E file : 
This option displays on the screen by adding a $ symbol at the end of each line.
















The contend of file.txt file is displayed with the $ symbol appearing at the end of each line.

7. cat :
When we run it without any option and argument, then this command takes input from keyboard. 
you can see in the video below 



I have tried to make it easy to understand by taking the Linux manual page as a reference.



If you liked this article, please help others by sharing.If there is anything incorrect in this or it needs more improvement then you can comment me in the comment box below or contact at  query.me

Comments

Popular posts from this blog

ls command

wc Command

ifconfig command