Linux Command To Create A File

Chapter: Linux Commands Last Updated: 23-05-2019 02:36:23 UTC

Program:

            /* ............... START ............... */
                
$ cat > myfile.txt  /* Type the command in terminal and then type the content required to write in file. */

$ touch NewFile.txt /* This will create a file in linux with file name as NewFile */

$ touch file1.txt file2.txt file3.txt /* create three empty files at the same time */
                /* ............... END ............... */
        

Notes:

  • cat command linux is used to create and view files.
  • Syntax : $ cat > myfile.txt
  • After typing the command you can type any content, this will come as the content in the file. To save the file you have to press CTRL-D (Save and exit)
  • To view the content of the file you can use the same cat command to view the file by giving like this in terminal $ cat myfile.txt (This will display contents in the file )
  • touch command in linux can also be used to create a file.
  • Syntax : touch NewFile.txt
  • touch command is mainly used in linux to create an empty file.
  • By using touch command you can create multiple files at the same time (touch file1.txt file2.txt file3.txt).

Tags

command to create a file in unix/linux, create empty file linux, how to create a file in linux, cat and touch command in linux

Similar Programs Chapter Last Updated
How To Enable Permission On File Linux Ubuntu Linux Commands 26-08-2023
Linux Command To Give All Permissions To A File Linux Commands 24-08-2023
Important Network Commands In Linux Linux Commands 24-08-2023
Important Commands In Linux Linux Commands 24-08-2023
Grep Command In Linux Example Linux Commands 10-05-2023
Traceroute Command In Ubuntu Linux Commands 10-05-2023
Linux Command To Count Number Of Files In A Directory Linux Commands 18-03-2023
Linux Version Command Linux Commands 01-12-2020
Unzip Command In Linux Linux Commands 20-11-2019
Process Command In Linux Linux Commands 16-11-2019
Linux Command To Create Link Linux Commands 15-11-2019
Linux Command To View File Content Linux Commands 25-10-2019
Linux Command To Check OS Version Linux Commands 25-10-2019
Netstat Command In Linux Linux Commands 13-08-2019
Telnet Command In Linux Linux Commands 13-08-2019
Linux echo Command Linux Commands 05-05-2018
Linux Ping Command Linux Commands 05-05-2018
Linux ls (List Directory) Command Linux Commands 17-03-2018

1