Answer by chepner for How to catch carriage return / line feed in case statement
Since read only reads a single line of input, sans newline, you just want to check for the empty string: read Option case $Option in 1 ) echo "1" ;; 2 ) echo "2" ;; "" ) echo "LF" ;; 0 ) exit ;; * )...
View ArticleAnswer by PSkocik for How to catch carriage return / line feed in case statement
read will strip it. The case statement itself works. #read Option Option=' ' case "$Option" in [1] ) echo "1" ;; [2] ) echo "2" ;; [$'\n'] ) echo "LF" ;; [0] ) exit ;; * ) echo "Invalid input" ;; esac...
View ArticleHow to catch carriage return / line feed in case statement
I tried the following to no avail and couldn't find any documentation. read Option case $Option in [1] ) echo "1" ;; [2] ) echo "2" ;; [$'\n'] ) echo "LF" ;; [0] ) exit ;; * ) echo "Invalid input" ;;...
View ArticleAnswer by Mikhail T. for How to catch carriage return / line feed in case...
Though I remain unable to find, how to catch the actual newline with case directly, the following invoking an external program (like sed).In my example below, all blanks and non-printable characters...
View Article