Значения разных типов

Поток управления / Условные операторы / Операторы switch/case

#+( ) is a pattern of extglob: one or more of the characters
shopt -s extglob

#bash has no types, every value is a string:
#case compares it with file name patterns, from the top down
describe() {
    case $1 in
        2)
            echo "two"
            ;;
        "Error")
            echo "Error string"
            ;;
        ?(-)+([0-9]))
            echo "integer"
            ;;
        *.txt)
            echo "text file name"
            ;;
        "")
            echo "empty string"
            ;;
        *)
            echo "string value '$1'"
            ;;
    esac
}

result1=$(describe 2)
#result1 is "two"
result2=$(describe -15)
#result2 is "integer"
result3=$(describe "notes.txt")
#result3 is "text file name"
result4=$(describe "test")
#result4 is "string value 'test'"

echo "result1 is $result1"
echo "result2 is $result2"
echo "result3 is $result3"
echo "result4 is $result4"