kskp kskp - 1 year ago 66
Linux Question

Why doesn't my simple echo command not work?

I just gave a simple

command on centos 7 command line:

echo "what is the worst thing someone has said to you about cloth diaper ? ( hopefully nothing ) here's mine !! :..."

It threw an error:

-bash: syntax error near unexpected token `('

Can someone please elaborate?

Answer Source

double quotes allows shell to expand variables, for example !! has a special meaning. If you want to treat everything as text, use single quotes instead.

For example;

$ date
Thu Oct  6 11:14:59 EDT 2016

$ echo "!!"
echo "date"

$ echo '!!'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download