Is something like this:
cat "Some text here." > myfile.txt
Possible? Such that the contents of myfile.txt
would now be overwritten to:
Some text here.
This doesn't work for me, but also doesn't throw any errors.
Specifically interested in a cat
-based solution (not vim/vi/emacs, etc.). All examples online show cat
used in conjunction with file inputs, not raw text...
You can do it like this too:
I believe there is a lot of ways to use it.
Sounds like you're looking for a Here document
That's what
echo
does:Here's another way -
I use the following code to write raw text to files, to update my CPU-settings. Hope this helps out! Script:
This writes the text "performance" to the two files mentioned in the script above. This example overwrite old data in files.
This code is saved as a file (cpu_update.sh) and to make it executable run:
After that, you can run the script with:
IF you do not want to overwrite the old data in the file, switch out
with
This will append your text to the end of the file without removing what other data already is in the file.