Check if the Enter key is pressed in a linux bash script

bash, linux

Solution

The `\n` at the end of the user's input is stripped off before assigning the value to the shell variable. If the user just presses `ENTER`, the value read will be the empty string.

read VAR
if [[ -z $VAR ]]; then echo "User pressed ENTER with no input text"; fi

Problem

I want to check if the value entered by the user using the `read` command is the Enter key using `if/elif` statements in order to `echo` something. How should I do?

Original source