Bash: How to end infinite loop with any key pressed?
You need to put the standard input in non-blocking mode. Here is an example that works: #!/bin/bash if [ -t 0 ]; then SAVED_STTY=”`stty –save`” stty -echo -icanon -icrnl time 0 min 0 fi count=0 keypress=”” while [ “x$keypress” = “x” ]; do let count+=1 echo -ne $count’\r’ keypress=”`cat -v`” done if [ -t 0 … Read more