Posted on 4th March 2024|28 views


Create A File In Linux

What are the various ways to create a new file in Linux?

sumana reddy

Posted on 4th March 2024

Let me explain to you the four different ways to create a new file in Linux.

  • Creating a file using touch command:

Using touch command is the simplest way to create a file; we can easily run the touch command to create a new file.

Syntax: $ touch file.txt

  • Creating a file using Redirection operator:

Redirection permits you to catch the output of command plus transfer it as input into different command either a file.

Syntax: $>file.txt

  • Creating a file using cat command:

To create a distinct file run the cat command accompanied by the operator of the redirection > also that name of that file you need to create. Press Enter Copy the text and once you are completed doing this process, then press the CRTL+D to store the files.

Syntax: $ cat > file.txt

  • Creating a file using the echo command:

To build a new file, manage the echo command accompanied by the text you desire to print and utilize the operator of the redirection > to write the output over the file you need to build.

Syntax: $ echo > file.txt 

If you want to learn more you can visit here: Linux Advanced Functions and Commands

Write your answer


Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos