练习1:输入一个数,实现倒叙 123---》321 练习2:输入一个数,判断是否是素数 练习3:输入一个文件名, 判断是否在家目录下存在, 如果是一个目录,则直接输出是目录下的.sh文件的个数 如果存在则判断是否是一个普通文件,如果是普通文件则判断是否具备 可读可写可执行权限,如果具备权限,写入hello,不具备权限,则添加读写执行权限,写入hello 如果是一个链接文件则输出文件的详细信息 #!/bin/bashread -p "please enter file:" file file2=~/$file if [ -e $file2 ] #文件是否存在 then if [ -d $file2 ] #是否为目录文件 then arr=(`ls $file2/*.sh`) echo ${#arr[*]} elif [ -L $file2 ] #是否为链接文件 then a=`ls $file2 -lh` echo $a elif [ -f $file2 ] #是否为普通文件 then if [ -r $file2 -a -w $file2 -a -x $file2 ] then echo hello>>$file2 else chmod 777 $file2 echo hello>>$file2 fi fi fi 习题4 同1