Saturday, October 31, 2020

Linux cat command Help and Examples

Must read

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...
SATISH KUMAR
I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.
- Advertisement -

Linux command cat stands for “catenate”.

The cat is one of the simple and most commonly used commands in Linux. It is used to:

  • Pint text from files
  • Copy text from files to a new file
  • Append contents of a text file to the end of another text files, and combine them
- Advertisement -

You can check here for cat command syntax and options.

Cat command examples

Example 1 – Displaying text files

The most popular and most straightforward way to use cat command is to apply for displaying or printing file content on the screen.

$  cat example.txt

If you have entered two file names in command, will show the content of those two files as if they were a single file.

- Advertisement -
$  cat  example1.txt  example2.txt

Example 2 – Copy a text file

We usually use cp command to copy a file, but we can use cat command also to make copies of text files.

To copy text files using cat command we can use output redirect operator so that we can redirect the output of a file to another new file and it will copy the entire content to a new text file.

To output redirection use symbol “>” like below command

- Advertisement -
$  cat  example.txt  >  newexample.txt

Similarly, we can catenate more than one file into a single file.

$  cat  example1.txt  example2.txt  >  newexample.txt

Example 3 – Append a text file’s contents to another text file

If you use the cat command to copy content into the old destination file, it will overwrite your old data from the destination file. So, instead of overwriting destination file, you can also append the content of source file to destination file using the redirection operator symbol “>>” like below command.

$  cat  example1.txt  >>  example2.txt
- Advertisement -
- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Latest article

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...

How to Reset the MySQL Root Password

Do you want to reset the MySQL root password? Sometimes we forget the root password and not able to log in on...