Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.

AIM:

Write a Shell script that displays list of all the files in the current directory to which the user has read, write and execute permissions.

Program:

echo "enter the directory name"
read dir
if [ -d $dir ]
then
cd $dir
ls > f
exec < f
while read line
do
if [ -f $line ]
then
if [ -r $line -a -w $line -a -x $line ]
then
echo "$line has all permissions"
else
echo "files not having all permissions"
fi
fi
done
fi

Output:

student@ubuntu:~$sh prg3.sh
enter the directory name
dir1
ff has all permissions
files not having permissions