How to create new files with cat?

You can create new files using the cat command by redirecting the output to a file. Here’s how to do it:

  1. Open your terminal.

  2. Use the following command to create a new file and start entering text:

    cat > filename.txt

    Replace filename.txt with your desired file name.

  3. After running the command, you can type the content you want to include in the file. Once you are done, press Ctrl + D to 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."

0 Comments

no data
Be the first to share your comment!