There are two main issues in you script:
- The
case statement is not closed by esac.
- The third pattern contains
|| which is a syntax error in most Bourne-like shells (use '' or "" or an expansion that resolves to an empty value to match on the empty string portably)
It's unclear what your script is actually doing, so I'm speculating a bit and wrote this:
#!/bin/sh
input="$1"
case "$input" in
D|P|Q|L1|L2)
val='Hello' ;;
DD|DE|DF|CA)
val='Hi' ;;
MM|KL|""|TK|SZ)
val='Bye' ;;
*)
echo 'error' >&2
exit 1
esac
printf 'input was "%s", val is "%s"\n' "$input" "$val"
Testing it:
$ ./script.sh D
input was "D", val is "Hello"
$ ./script.sh MM
input was "MM", val is "Bye"
$ ./script.sh BOO
error
$input? Also, thecasestatement is partial (not closed byesac), and you're not using$valanywhere. – Kusalananda Mar 29 '18 at 07:39case "$input". It seems to me that the esac is missing. Or shall$inputbe printed only in the last case? And why$inputand not$val? Strange code... – Hauke Laging Mar 29 '18 at 07:42$inputin thecasestatement is good practice, but actually not necessary. https://unix.stackexchange.com/questions/68694/when-is-double-quoting-necessary (note, I always quote the expansion incasestatements) – Kusalananda Mar 29 '18 at 07:51