查看该目录下有几个文件夹几个文件的shell代码 #!/bin/sh directory() { let "filenum = 0 " let "dirnum = 0 " ls $1 echo "" for dir in $( ls ) do if [ -d $dir ] then let "dirnum+=1" else let "filenum+=1" fi done echo "The number of directories is $dirnum " echo "The number of files is $filenum " } directory