I want to create a poll in a shell script:
echo "1 - What is your name?"
read name
echo "your name is $name"
echo "2 - What is your country?"
read country
echo "your country is $country"
...
...etc...
...
I want if the user press ESC in a question, cancel the question an jump to the next question.
Thanks! I keep in wait for possibles answers!
$_ (dollar underscore) is another special bash parameter and used to reference the absolute file name of the shell or bash script which is being executed as specified in the argument list. This bash parameter is also used to hold the name of mail file while checking emails. $@
The $$ variable is the PID (Process IDentifier) of the currently running shell. This can be useful for creating temporary files, such as /tmp/my-script. $$ which is useful if many instances of the script could be run at the same time, and they all need their own temporary files.
ps -p $$ – Display your current shell name reliably. echo "$SHELL" – Print the shell for the current user but not necessarily the shell that is running at the movement. echo $0 – Another reliable and simple method to get the current shell interpreter name on Linux or Unix-like systems.
In the Linux command-line shell, pressing Ctrl + D logs out of the interface. If you used the sudo command to execute commands as another user, pressing Ctrl + D exits out of that other user and puts you back as the user you originally logged into.
this is how to know if user selected escape :
read -s -n1 key
case $key in
$'\e') echo "Escape";;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With