cat Command in Linux




In this blog we will learn about cat command . cat is one of the mostfrequently used command on linux .It has three related functions with regard to text files one is displaying the text while second is combining copies of tex tfiles and third is creating new text file.First of all lets open our terminal , We can press ctrl+alt+ t to do this .

1.The syntax for using cat command is you just need to write cat ,then you write options and then you give the file name . Command look like : cat options filename . Let’s see how we can use cat command so first of all you can just give cat and press enter and you can see it’s giving us the cursor to type so we can just type for example ‘hello world’ andthen press ENTER and it will echo whatever input we have given.

 To exit this cat command you can just press ctrl+d which means the end of the file so just press ctrl+d and you are out of this cat command.

2.If you want to print the text of any file on terminal you can use cat and then the name of the file so the name press ENTER and it will display the content of the file . Command : cat filename .


If you want to display the content of multiple files you can just add one more file name .Command : cat file1 file2 .It will combine the content of both the file and display on terminal .

3. There are some options related to cat command so for example you want to show the line number on the every line of the content of the file so you can use a cat and then minus b , then filename ,which will add line number to non blank lines . Command : cat -b filename .

4.Next command is cat -n and what it will do is it will add line number to all the lines i.e. the non blank lines also . Command : cat -n filename .

5. If I just want to show only one line break instead of many lines , then write the command cat -s filename . It will not affect the content of the file remember it will only display the content of th efile in this format .

6.The next command is cat – E . It adds this dollar symbol at the end of each line .

if you want to know more options related to cat you can just enter man cat .This is all about cat command .


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*