I tried printing \"Dogs are the best.\" with this bash script.
#!/bin/bash
ANIMAL=\"Dog\"
echo \"$ANIMALs are the best.\"
exit
However, I
With braces: echo "${ANIMAL}s are the best."
With quotes: echo "$ANIMAL"'s are the best.'
With printf: printf '%ss are the best.\n' "$ANIMAL"
I wouldn't use the quotes one most of the time. I don't find it readable, but it's good to be aware of.
Move your variable outside the quotes in echo :
#!/bin/bash
ANIMAL="Dog"
echo $ANIMAL"s are the best."
exit
OR :
#!/bin/bash
ANIMAL="Dog"
echo "${ANIMAL}s are the best."
exit
Both worked for me
Just surround the variable's name with curly braces.
#!/bin/bash
ANIMAL="Dog"
echo "${ANIMAL}s are the best."
exit
Useless quotation, useless exit. A finished script needs no help to exit but the exit will bite you when sourcing that script.
ANIMAL=Dog
echo ${ANIMAL}s are the best.
#!/bin/bash
ANIMAL="Dog"
echo "{$ANIMAL}s are the best."
exit
The answer is no longer unique, but correct...