소스기록장/shell script

해당 디렉토리내의 내용이 파일인지 디렉토리인지 확인하는 스크립트

푸른너구리 2010. 12. 12. 18:06
#!/bin/sh
#파일인지 디렉토리인지 확인및파일은 rwx 가능한지 체크합니다.
for name in $(ls $1)
do
        echo -n "$name : "
        whf=$1/$name
        if [ -d $whf ]
        then
                echo "diretory"
        else
                if [ -r $whf ]
                then
                echo -n " r "
                fi
                if [ -w $whf ]
                then
                echo -n " w "
                fi
                if [ -x $whf ]
                then
                echo -n " x "
                fi
                echo "file"
        fi
done