#!/bin/bash # http://www.codelibary.com/Bash/Arrow-key-detect.html arrowup='\[A' SUCCESS=0 OTHER=65 echo -n "Press a key... " # May need to also press ENTER if a key not listed above pressed. read -n3 key # Read 3 characters. echo -n "$key" | grep "$arrowup" #Check if character code detected. if [ "$?" -eq $SUCCESS ] then echo "Up-arrow key pressed." exit $SUCCESS fi exit $OTHER
In reply to Translating Bash to Perl by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |