

Use the ls command to see if the recently created file now exists on your system.Ĭreate multiple files at once through the touch commandĪs mentioned above, the touch command takes the lead on the cat command on the basis that you can create multiple files simultaneously through the former. Let us first see how to create a single file first through the Linux touch command: You might prefer the touch command over the cat command in one scenario when you want to create multiple files at once through one command. After creating the file, you can enter the text through your favorite text editor. The touch command, however, does not let you enter text in the file at the time of creation. You can see that the cat command shows the text I wrote while creating my sample file:Īnother way of quickly creating a text file through the Terminal is by using the touch command. Through the cat command, you can then view the contents of the file as follows: $ cat filename.txt You can then use the ls command to see that your newly created text file will be there in the system. The usual command prompt will then appear for you to move on with further operations. Once you have entered all the text, hit enter to move to the next line and then use the Ctrl+D control to tell the system that you are done with entering the text.

In this example, I have created a text file through the following command and then entered some sample text: $ cat > SampleTextFile.txt Here, we will explore the first use of the cat command creating a text file through the command line.Įnter the following command in your Terminal:Īfter entering this command, the next prompt will not appear rather the cursor will display for you to enter the text for the file you just created. Printing contents of a text file to another text file.Printing contents of a text file in your Terminal.

It helps you in achieving three basic purposes:

The cat command is very helpful when dealing with text files in Linux. Since we will be creating the text files using Ubuntu command line-the Terminal you can open it either through the system Dash or the Ctrl+Alt+T shortcut. The commands and procedures mentioned in this article have been run on an Ubuntu 20.04 LTS system. Let us explore these commands in this article to create some sample text files. Three commands from the Linux command line are at your service for creating text files. Creating a text file is one task for which you can depend only on your keyboard on an Ubuntu system. Being a Terminal-savvy person, you may always be looking for ways to ditch the mouse.
