How to create a file using cat?

0224

You can create a file using the cat command with a here-document. Here’s how to do it:

  1. Open your terminal.

  2. Use the following command to create a new file and add content to it:

    cat << EOF > filename.txt
    This is the first line.
    This is the second line.
    This is the third line.
    EOF

In this example, replace filename.txt with your desired file name. The text between EOF markers will be written to the file. After entering the command, press Enter, and the content will be saved in filename.txt.

0 Comments

no data
Be the first to share your comment!