Found this example on the arch wiki
#!/bin/sh case $1/$2 in pre/*) echo "Going to $2..." ;; post/*) echo "Waking up from $2..." ;; esac
and can't make out if it's a logical operator or something else.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
There is nothing special here. The syntax for
case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
In the example in the question,
word is built by combining
/ doesn't have a special meaning at all, it's just a character.
PS: Practically the usage is a bit strange, as the
$2 part afterwards gets matched against
* so the value of
$2 doesn't really matter. One could, in the context described in the Wiki, also write
#!/bin/sh case $1 in pre) echo "Going to $2..." ;; post) echo "Waking up from $2..." ;; esac
But there might be cases where
hybrid (the possible values for
$2) are relevant, so it's just a general pattern here.