You can create new files using the cat command by redirecting the output to a file. Here’s how to do it:
-
Open your terminal.
-
Use the following command to create a new file and start entering text:
cat > filename.txtReplace
filename.txtwith your desired file name. -
After running the command, you can type the content you want to include in the file. Once you are done, press
Ctrl + Dto save and exit.
For example:
cat > myfile.txt
This is my new file.
Press Ctrl + D to save.
This will create a file named myfile.txt containing the text "This is my new file."
