DEV Community

Djilou
Djilou

Posted on

1

3 Basic Cat Command Examples in Linux

The cat (short for “concatenate“) command is one of the most frequently used commands in Linux/Unix-like operating systems. cat command allows us to create single or multiple files, view content of a file, concatenate files and redirect output in terminal or files.

In this article, we are going to find out the handy use of cat commands with their examples in Linux.

General Syntax of Cat Command

$ cat [OPTION] [FILE]...

1. Display Contents of File

cat /etc/passwd

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
narad:x:500:500::/home/narad:/bin/bash

2. View Contents of Multiple Files in terminal

In below example, it will display the contents of the test and test1 file in the terminal.

cat test test1

Hello everybody
Hi world,

3. Create a File with Cat Command

We will create a file called test2 file with the below command.

cat >test2

Thanks for reading ! Happy coding !

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay