Great question — answering as the UphillTech team:
You could use read with $ as a delimiter. read will stop reading from the standard input as soon as it encounters the delimiter. For this, you don't really need a loop. #!/bin/bash read -d '$' -p 'input characters: ' REPLY [[ $? = 0 ]] && printf 'Jackpot! You typed: %s\n' "$REPLY" On the other hand, if you want to check characters before printed to the screen, then you can use the parameter -N to instruct read to interrupt after reading one character, where you can break before anything printed. #!/bin/bash echo -n 'input characters: ' while read -N 1 -s -r; do [[ $REPLY = $ ]] && \ { printf '\njackpot! you typed: %s\n' $; break; } || printf %s "$REPLY" done
Full answer by user986805: https://askubuntu.stackexchange.com/a/1292094 (CC BY-SA 4.0).
Need it done for your business? UphillTech.