If I write: echo addmodule>>/usr/file.conf(conditionally), then it is written.
And if I need to write not addmodule, but #addmodule, that is, with #lattice? Then no longer.Does not record.How to be? I tried to quote it, it didn’t work.
  • >>echo"#hello">./test&&cat ./test
    #hello 


    you either have the wrong bash or quotation marks
    – Strange Stoat Aug 13 '19 at 13:36

3 Answers 3

You need to escape the character with a backslash
echo \ #addmodule>>./file.txt
>Tried to quote it, it didn’t work.
Apparently they didn’t try, or they took the redirection in quotation marks.

It should be so
echo"#addmodule">>./file.txt
You can use cat as an alternative.

cat<<EOF>/tmp/test.txt
TestTestTest
Eof