#!/bin/bash
#Determines whether the parameter is an integer
read -p " Enter your parameters: " NUM
if[[ $NUM =~[[:digit:]]]]
then
echo "The parameters you enter are integers"else
echo "The parameters you enter are not integers"
fi
~
编写脚本age.sh,判断年龄
#!/bin/bash
read -p "Input your age: " AGE
if[[!"$AGE"=~[[:digit:]]+]];then
echo "please input a digit age"
exit
elif [[ $AGE -lt 18]];then
echo "好好学习,天天向上"
elif [[ $AGE -le 60]];then
echo "好好工作,努力赚钱"
elif [[ $AGE -le 120]];then
echo "好好享受你的生活"else
echo “您是个长寿的人,或者您来自外星球?”
fi
#!/bin/bash
#Determine file type
read -p " Enter your file path: " FILE
if[[-z "$FILE"]];then
echo "Please Enter your file path!!"
elif [[-d "$FILE"]];then
echo "This file is directory file"
elif [[-f "$FILE"]];then
echo "This file is common file"
elif [[-L "$FILE"]];then
echo "This file is chained file"
elif [[!-a "$FILE"]];then
echo "This is not a file"else
echo "This file is Other file types"
fi