how do I echo an asterisks to an output

放肆的年华 提交于 2019-12-13 04:49:51

问题


The line in my shell script is

OUTPUTMESSAGE="****Warning error $MYERRORNUM ****"
echo $OUTPUTMESSAGE

The asterisks are expanded to file names so it looks like

file1  file2 file 3 file4 Warning error 404  file1  file2 file 3 file4 

How do I prevent the * expansion in echo?


回答1:


Quote the variable name not only in assignment, but also in your echo command:

OUTPUTMESSAGE="****Warning error $MYERRORNUM ****"
echo "$OUTPUTMESSAGE"

More information can be found in the answers to this question.



来源:https://stackoverflow.com/questions/26833786/how-do-i-echo-an-asterisks-to-an-output

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