Qual é a sua dúvida?
Bash Sintaxes If and Case
IF =, contains, not contains
Bash If Sintaxe
#!/bin/bash
CONTENT=".log"
# string é igual
if [ "$1" == ".log" ];
then
echo "conteudo = .log"
# string contains
elif [[ "$1" == *".log" ]];
then
echo "contem .log"
# stirng not contains
elif [[ "$1" != *"$CONTENT"* ]];
then
echo "nao contem .log"
# else
else
echo "bash if example"
fi
IF $1 is null
Try using the -z test:
if [ -z "$1" ] && [ -z "$2" ]
From man bash
:
-z string
True if the length of string is zero.
Case
Bash Case Sintaxe
#!/bin/bash
case $1 in
"www")
cd /var/www
;;
"opt")
cd /opt
;;
*)
echo "bash if example"
;;
esac