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...
cat
can also be used following a|
to write to a file, i.e. pipe feeds cat a stream of dataThe Solution to your problem is :
But you can use cat command if you want to redirect the output of a file to some other file or if you want to append the output of a file to another file :
cat filename > newfile -- To redirect output of filename to newfile
cat filename >> newfile -- To append the output of filename to newfile
enter the text until EOF for save the text use : ctrl+d
if you want to read that .txt file use
and one thing .txt is not mandatory, its for your reference.
Another way to write text to file using cat would be something like this
Write multi-line text with environment variables using
echo
:simply pipeline echo with cat
For example