I want a shell script that accepts user input simultaneously when performing other tasks. Example: A shell script should echo some messages on the console and when the user presses some keys it should respond to that action.
say, when user presses the key
A - more information should be printed on the console
M - minimum information should be printed on the console
P - pause the script
How to achieve it ?
#!/usr/bin/bash
while true
do
echo "im in infinite loop.."
done
#simultaneously below logic should be handled
if [ key "A" is pressed ]
then
echo "hello you pressed A while infinite loop is running"
fi
if [ key "P" is pressed ]
then
echo "pausing the script"
fi