linux判断路径下所有内容是否为文件夹

PATH="完整路径即可"

function IsFile(){
        FULLPATH="$1"
        #遍历目录
        for fName in $(/bin/ls $FULLPATH)
        do
                fileType=`/usr/bin/file $PATH$fName | /bin/awk '{FS=":"} {printf $2}'`
                # 文件夹的类型为:directory
                if [ "directory" == $fileType ]; then
                        printf '%s is %s!! \n' $fName $fileType
                else
                        printf '%s is not file,is %s            ######## \n' $fName $fileType
                fi
        done
}

IsFile $PATH



注:command not found如果脚本出现这种错误提示,写命令完整路径即可,用whereis查找该命令的完整路径,

你可能感兴趣的:(sh)