0

the input is a '*' and I want to print it and detect it

Content of script.sh:

MARK=$1 
echo "STRING: " $MARK
if [$MARK = "\*"]; then
    echo 'IT IS A *'
fi

Happens that echo $MARK shows the name of the file and there is an error in the if

Federico
  • 1
  • 1
  • You need to escape the `*` (or put in in `'*'`) when you call your script. Also do `echo "STRING: $MARK"` and `if [[ $MARK == '*' ]]; then` – Ted Lyngmo Sep 29 '20 at 16:47
  • Does this answer your question? [How do I pass in the asterisk character '\*' in bash .....?](https://stackoverflow.com/questions/2755795/how-do-i-pass-in-the-asterisk-character-in-bash-as-arguments-to-my-c-program) – markp-fuso Sep 29 '20 at 16:49
  • 3
    And quote the var also, ie. `if [ "$MARK" = "*" ]; then echo 'IT IS A *'; fi` – James Brown Sep 29 '20 at 16:54

0 Answers0