Sample Header Ad - 728x90

Transforming if statement in case

1 vote
2 answers
949 views
I'm currently testing changes in my scripts for performance purposes. Specifically, I want to change if to case statements. However, being new to shell programming I'm getting stuck on this type of statement: if [ "$A" == "x" -a "$B" == "y" ] then let a=a+1 fi I tried this but it didn't work: case "$A$B" in "x""y") let a=a+1 ;; esac What did I get wrong? And is it possible to manage a "!=" in case statements? Such as: if [ "$A" == "x" -a "$B" != "y" ] then let a=a+1 fi
Asked by Matieu (23 rep)
Mar 22, 2017, 01:57 PM
Last activity: Mar 22, 2017, 04:17 PM