The "not a valid identifier" problem showed up when I tried to read user input with bash scripting on my Ubuntu box. This part of my script is simply something like:
echo -e "Please input a word: \c "
read word
echo "The word you entered is: $word"
This was streight forward and should not have any problem. However, it responsed:
Please input a word: river
': not a valid identifier`word
The word you entered is:
The explanation for such an embarrassing situation is also simple. Since I wrote the script with notepad++ under windows, the script was set to DOS formatting instead of UNIX formatting. i.e. the line breaker was \n instead of \r.
There is one solution to covert all \n to \r\n to solve this problem:
The lesson I learn again is: Unix and Windows... they really do not like each other.
4 comments:
same problem encountered before...
useful info. encountered the same issue. Thinking if sublime is better at it..?
Exactly the same problem. Thank you for taking the time to make problem and solution available on the web
I hate when these issues are so simple - Thanks!
Post a Comment