Skip to content

Instantly share code, notes, and snippets.

@programmerShinobi
Last active October 24, 2024 15:01
Show Gist options
  • Save programmerShinobi/339d8fdc59aa6d5d0b11e024063619ef to your computer and use it in GitHub Desktop.
Save programmerShinobi/339d8fdc59aa6d5d0b11e024063619ef to your computer and use it in GitHub Desktop.
How To Create Or Update a File

Create or Update test.txt

To create or update the test.txt file using the following command:

$ cat << EOF > test.txt
  This is the first line.
  This is the second line.
  EOF

Explanation:

  • The cat << EOF > test.txt command creates (or updates if the file already exists) a file named test.txt and writes the specified content into it.
  • Everything between EOF and the second EOF is written into the file.
  • This command adds two lines to test.txt:
    • "This is the first line."
    • "This is the second line."

After running this command, your test.txt file will contain the following:

This is the first line.
This is the second line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment