————————————————
#!/bin/bash
if [ $# -lt 1 ];then
echo "at least one path."
exit 1
fi
if ! [ -e "$1" ];then
echo "file does not exist"
exit 2
elif ! [ -d "$1" ];then
echo "file is not directory"
exit 3
else
fileCount=0;
lineCount=0;
for i in $1/*;do
if echo "$(file $i)"|grep "ASCII text" &>/dev/null;then
fileCount=$[$fileCount+1]
lineCount=$[$lineCount + $(cat $i|wc -l)]
fi
done
echo "text file count :$fileCount"
echo "text lien count:$lineCount"
fi