I want to use user input of special characters in conditional statement. I tried:
read -p "press arrow up" foo
if [ $foo == "^[[A" ]; then echo yes; fi
It did not do what I wanted it to do.
I want to use user input of special characters in conditional statement. I tried:
read -p "press arrow up" foo
if [ $foo == "^[[A" ]; then echo yes; fi
It did not do what I wanted it to do.
In bash, you could use ANSI-C quoting
For a more nuanced version, see BASH question: using read, can I capture a single char OR arrow key (on keyup)
Not especially beautiful, but you could compare hex values.
To find out hex value of up arrow, assign
foo
manually and runCopy paste the output to your script and use
xxd -r
to revert the hex value: