! has a special meaning in bash:
When the command history expansion facilities are being used (see HISTORY EXPANSION below), the history expansion character, usually !,
must be quoted to prevent history expansion.
There are two ways to prevent history exspansion, either by escaping the !
with a backslash, or by using single quotes:
a@ubuntu:~$ echo "#\!/bin/sh" > ~/bin/run_linux_program
a@ubuntu:~$ echo '#!/bin/sh' > ~/bin/run_linux_program
In complex constructs, try to avoid the "
(double quote) char and use the single one instead ('
):
echo "$1" '"$(wine winepath -u "'$2'")"' >> ~/bin/run_linux_program
I've replaced the backticks by $(
and )
to make the line more clear.