Quantcast
Channel: How to catch carriage return / line feed in case statement - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

How to catch carriage return / line feed in case statement

0
0

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" ;;
esac

The following works though.

$ x="                                         
> "
$ if [ "$x" = $'\n' ]; then echo "newline"; fi
newline

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images