#!/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
shell脚本练习(查询某目录下的所有文本文件的个数,和行数)
猜你喜欢
转载自blog.csdn.net/hxpjava1/article/details/80719348
今日推荐
周排行