Catch Keypress To Stop A Timer In Bash On Linux
Page 1 of 1
Catch Keypress To Stop A Timer In Bash On Linux
- Code:
#!/bin/bash
# Usage ./test.sh
if [ -t 0 ]; then 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 ]; then stty sane; fi
echo "You pressed '$keypress' after $count loop iterations"
echo "Thanks for using this script."
exit 0
# since=$(date +%s);watch -tn 1 eval "echo \$((\$(date +%s) - $since))"
To make executable
- Code:
sudo chmod +x test.sh
Similar topics
» Countdown Timer Using A File On Linux Bash Script Example
» Bash Countdown Timer With Voice Output
» Bash Psychic Game For Linux Bash
» Surpress Crontab Email Alarts to stop error emails on linux
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Bash Countdown Timer With Voice Output
» Bash Psychic Game For Linux Bash
» Surpress Crontab Email Alarts to stop error emails on linux
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|