#!/bin/bash
read zifu
case $zifu in
[[:lower:]])
echo "小写字母"
;;
[0-9])
echo "是数字字符"
;;
[[:upper:]])
echo "是大写字母"
;;
esac
#!/bin/bash
arr=(`ls ~`)
len=${#arr[*]}
sum1=0
sum2=0
for((i=0;i<len;i++))
do
if test -d ~/${arr[i]}
then
((sum1++))
elif test -f ~/${arr[i]}
then
((sum2++))
fi
done
echo "目录文件是"
echo $sum1
echo "普通文件是"
echo $sum2
#!/bin/bash
read -p "请输入一个年份" nian
echo
read -p "请输入一个月份" yue
if [ $((nian%4)) -eq 0 ] &&[ $((nian%100)) -ne 0 ] ||[ $((nian%400)) -eq 0 ]
then
case $yue in
1|3|5|7|8|10|12)
echo 31
;;
2)
echo 29
;;
4|6|9|11)
echo 30
;;
esac
else
case $yue in
1|3|5|7|8|10|12)
echo 31
;;
2)
echo 28
;;
4|6|9|11)
echo 30
;;
esac
fi
#!/bin/bash
for((i=100;i<1000;i++))
do
ge=$((i%100%10))
shi=$((i%100/10))
bai=$((i/100))
if [ $((ge**3+shi**3+bai**3)) -eq $i ]
then
echo $i
fi
done
#!/bin/bash
read -a arr
len=${#arr[*]}
echo ${arr[*]}
for((i=0;i<=len-1;i++))
do
for((j=0;j<len-i-1;j++))
do
if [ ${arr[$j]} -gt ${arr[$((j+1))]} ]
then
temp=${arr[j]}
arr[j]=${arr[j+1]}
arr[j+1]=$temp
fi
done
done
echo ${arr[*]}
#!/bin/bash
arr=([3]=20 [0]=30 [4]=50)
len=${#arr[*]}
brr=(${arr[*]})
for((i=0;i<len;i++))
do
((sum+=(brr[$i])))
done
echo $sum
#!/bin/bash
read -p "请输入成绩" cj
case $cj in
9?|1??)
echo A
;;
8?|9?)
echo B
;;
7?|8?)
echo C
;;
6?|7?)
echo D
;;
[1-5]?|[0-9])
echo "不合格"
;;
*)
echo "输入错误"
;;
esac