问题
I have tried the escape character but it doesn't seems works with !. I need this to auto-configure packages using scripts.
回答1:
!
is magic in a default interactive bash session, but not in scripts (set +H
to disable in an interactive prompt). In any case:
echo '#!/bin/bash'
回答2:
Or with no quotes and escaping the #
and the !
:
echo \#\!/bin/bash
回答3:
printf should work too:
printf '#!/bin/bash\n'
来源:https://stackoverflow.com/questions/22797530/how-to-print-bin-bash-using-echo-command