bash — if

#!/bin/bash

if [ -n “$1” ]; then
        filename = $1;
else
        filename = `date –date=’1 hour ago’ “+%Y-%m-%d.%H”`;
fi

Compare numbers with -gt -lt -ne -eq

if [ “${size}” -gt 100 ];then
  echo $size
fi

Compare strings with = !=

if [ “${domain}” = “lalife.net” ];then
echo “correct”
fi
(#if [ “${domain}”=”lalife.net” ];then (##this won’t work without space around “=” or “!=”)

When using [[ ]]
if [[ ${domain} = “lalife.net” ]];then
echo “correct”
fi

([ ] needs the variable to be inside of “”)

Match
if [[ ${domain} =~ “lalife.net” ]];then
echo “correct”
fi
([ ] doesn’t work with =~)