A
A
alekssamos2019-08-13 13:32:46
bash
alekssamos, 2019-08-13 13:32:46

Write to file via echo with hash?

If I write: echo addmodule>>/usr/file.conf(conditionally), then it is recorded.
And what if I need to write not addmodule, but #addmodule, that is, with a hash #? Then it's gone. Doesn't record. How to be? I tried to put it in quotes, it didn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-08-13
@deepblack

You need to escape the character with a backslash
echo \#addmodule>>./file.txt

M
Michael, 2019-08-13
@ARMADIK

You can use cat as an alternative.
cat <<EOF>/tmp/test.txt
TestTestTest
EOF

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question