bash script compare string to asterisk character - how to?
Posted on 2003-10-28
I want to test whether a string is the asterisk character:
if [ $thestring == '*' ]
.. do stuff ..
the asterisk is read into the script by redirect ie:
while read thestring anotherstring etc
and i run the script like:
myscript < datafile
i have tried various things like:
if [ $thestring == '\*' ]
if [ $thestring == * ]
if [ $thestring == \* ]
etc, but nothing seems to work. the comparison never seems to recognise when the string really *is* an asterisk.
hope someone can help.