#+( ) - шаблон extglob: один или несколько символов
shopt -s extglob
#в bash нет типов, любое значение - строка: case сравнивает её с шаблонами имён
#файлов сверху вниз
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"