Search This Blog

Thursday, January 29, 2009

Find symbolic link in a dir

With single command
find path_to_dir -lname "*"

OR
ls -l | grep ^l

OR COUNT
ls -l | grep ^l | wc -l

SCRIPT



#echo -n "Enter file name : "
#read file

echo -n "Enter dir name/path : "
read dir1
echo "***********************"
echo "Files are symbolic link"
find $dir1 -lname '*'
echo "***********************"

for file1 in `ls $dir1`
do



# find out if file has write permission or not
#[ -w $file1 ] && W="Write = yes" || W="Write = No"

# find out if file has excute permission or not
#[ -x $file1 ] && X="Execute = yes" || X="Execute = No"

# find out if file has read permission or not
#[ -r $file1 ] && R="Read = yes" || R="Read = No"

#echo "$file permissions"
#echo "$W"
#echo "$R"
#echo

dr="$dir1/$file1"
#echo $dr
if [ -L $dr ] ; then
sym="Its a Symbolik link"
else
sym="Its a not Symbolic link."
fi
echo -e $file1
echo $sym

done

1 comment: