-->

Thursday, 12 December 2019

10 Basic Cat Command Examples in Linux


Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. cat command allows us to create single or multiple files, view contain of file, concatenate files and redirect output in terminal or files. In this article, we are going to find out handy use of cat commands with their examples in Linux. 10 Basic Cat Command Examples in Linux
So let us see some frequently used cat commands.


Syntax :

cat [ OPTION ] [ FILE ] ....



Command :

1. To display a single file , Look Like 

cat /etc/protocols


10 Basic Cat Command Examples in Linux

It will show content of given filename.






2. To view multiple files command :

supposed that i have a file likes atul and atul


cat atul atul1





3. To View content of a file :

With -n option you could see the line numbers of a file "atul" in the output terminal.

cat -n filename
cat -n atul






4. Create a file with cat command :

We will create a file called hackingtruth file with below command.

cat > hackingtruth





5. Copy the contents of one file to another file  &&  standard output :





We can redirect standard output of a file into a new file else existing file with ‘>‘ (greater than) symbol. Careful, existing contents of atul1 will be overwritten by contents of atul2 file.


cat [filename-whose-contents-is-to-be-copied] > [destination-filename]

cat atul1 > atul2








SEE ALSO :


 1.  Brute Force Attack on Instagram 

 2.  The Linux Choice Saycheese [ Hack Android Camera ] 

 3.  Sender Policy Framework [ SPF ]

 4.  Bypass Facebook Profile Security Guard

 5.  Kali Undercover Mode setup in kali linux 2019.4

 6.  Trape peoples Device

 7.  Hollywood Style Hacking Terminal  

 8. 10 Basic cat command in Linux






 6. Appending Standard Output with Redirection Operator :

Appends in existing file with ‘>>‘ (double greater than) symbol. Here, contents of test file will be appended at the end of test1 file.

 cat kumar1 >> kumar2





7. Redirecting Standard Input with Redirection Operator :

When you use the redirect with standard input ‘<‘ (less than symbol), it use file name atul2 as a input for a command and output will be shown in a terminal.


 cat < atul2







8. Redirecting Multiple Files Contain in a Single File :

This will create a file called atul1 and all output will be redirected in a newly created file.

cat atul atul1 atul2 > atul3






9. Sorting Contents of Multiple Files in a Single File :

This will create a file test4 and output of cat command is piped to sort and result will be redirected in a newly created file.

 cat atul atul1 atul2 atul3 | sort > atul4





9. Display $ at the End of FileIn the below, you can see with -e option that ‘$‘ is shows at the end of line and also in space showing ‘$‘ if there is any gap between paragraphs. This options is useful to squeeze multiple lines in a single line.


cat -e atul





10. Use Cat Command with More & Less Options :

If file having large number of content that won’t fit in output terminal and screen scrolls up very fast, we can use parameters more and less with cat command as show above.

 cat song.txt | more



















This article shows the basic commands that may help you to explore cat command. You may refer man page of cat command if you want to know more options. In out next article we will cover more advanced cat commands. Please share it if you find this article useful through our comment box below.

All tutorials and videos have been made using our own routers, servers, websites and other resources, they do not contain any illegal activity. We do not promote, encourage, support or excite any illegal activity or hacking without written permission in general. We want to raise security awareness and inform our readers on how to prevent themselves from being a victim of hackers. If you plan to use the information for illegal purposes, please leave this website now. We cannot be held responsible for any misuse of the given information.


- Hacking Truth by Kumar Atul Jaiswal





My Self Kumar Atul Jaiswal Urf HackerboY and Kumar Atul Jaiswal is a name among millions who struggled failed and surged ahead in search of how to become a Hacker ( passionate about Hacking just like profession an entrepreneur ), just like any middle class guy, he too had a bunch of unclear dreams and a blurred version of his goals in life 😊.

0 comments:

Post a Comment

Contact

Send Us A Email

Search This Blog

Address

Contact Info

The page name itself is a call-to-action; Treat it with some respect.!

Address:

15, Ranchi, India, 834002

Phone:

404

Email:

kumaratuljaiswal222@gmail.com

atulthehacker222@gmail.com