The test command

The test command is widely used in shell scripts for conditional statements. See the man page for test for all possible usages. For example we can use it to test two strings:

if test "$name" = "alice"
then
    echo "yes"
else
    echo "no"
fi

Note that there must be a space around the = in the test command. We can also use it to check if a file is a regular file or a directory. For example.

for f in *
do
    if test -f "$f"
    then
        echo "$f is a regular file"
    else
        
        echo "$f is a directory"
    fi
done

We can also use it to compare numbers. For example.

if test "$total" -ge 1000
    then
        echo "the total is >= 1000"
    fi
done

Note that bash also allows the syntax [...], which is almost equivalent to the test command. It also has a newer variant [[ ... ]], which is recommended but it isn't part of the POSIX shell standard. See man page for bash for more details.