The shell determines the number of directory files in the current directory

#!/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"

Test Results

Insert picture description here

Guess you like

Origin blog.csdn.net/zxy131072/article/details/108528857