0

I need to print expressions ${STR1} and $STR2 into a file -- not the content of the variables. How can I accomplish this using echo or printf?

3

You just need to escape the $ character, as in

echo "\${STR1}" >> myfile

or

echo "\$STR2" >> myfile

Alternatively, you can use single quotes

echo '${STR1}' '$STR2'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.