I use the below code to assign a given by the user character to variable G:
read G
However in order to move forward with executing of my script I need to press enter button. Is it possible to set the read command somehow that it show process forward to the next line immediately after it receive the one letter from stdin?
For shell scripts without execute permissions, you will need to pass the script as an argument to your choice of interpreter. Here the execute permissions are checked for your shell interpreter and not the script itself. So you should have execute for /bin/sh and your script can have only read permissions.
The read command reads one line from standard input and assigns the values of each field in the input line to a shell variable using the characters in the IFS (Internal Field Separator) variable as separators.
If you're using Bash:
read -n1 G
Your system is configured to use dash by default and dash doesn't support this feature, so you also need to change the first line of your script to specify that you wish you use bash:
#!/bin/bash
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