0

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?

afenster
  • 3,468
  • 19
  • 26
Rob McNeil
  • 51
  • 8

1 Answers1

2

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.

Community
  • 1
  • 1
afenster
  • 3,468
  • 19
  • 26