问题
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