How to print #!/bin/bash using echo command [duplicate]

穿精又带淫゛_ 提交于 2020-01-30 05:52:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!