shell判断当前目录下目录文件的个数

#!/bin/bash
File=`ls`
i=0
for Var in $File
do
	if [ -d $Var ]
	then 
		echo "$Var is a directory"
		i=`expr $i + 1`
	fi
done

echo "total directory is $i"

测试结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/zxy131072/article/details/108528857
今日推荐