Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
26 views1 page

U 9

The script prompts the user to enter a filename and checks if the file exists, is a regular file, and is readable. If the file is readable, it displays its contents; otherwise, it informs the user of the lack of permissions or that the file does not exist. Additionally, there is a section of the script that attempts to delete a specified file and provides feedback on the success or failure of the deletion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

U 9

The script prompts the user to enter a filename and checks if the file exists, is a regular file, and is readable. If the file is readable, it displays its contents; otherwise, it informs the user of the lack of permissions or that the file does not exist. Additionally, there is a section of the script that attempts to delete a specified file and provides feedback on the success or failure of the deletion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

--write script to accept a file and open

echo -n "enter a filename: "


read fn
if [ -e $fn ]
then
if [ -f $fn ]
then
if [ -r $fn ]
then
cat $fn
else
echo "no read permission"
#chmod 644 $fn
#cat $fn
#echo "no read permission"
fi
else
echo "it is not a file"
fi
else
echo "$fn file doesnot exist"
fi
--o/p
[chandra@localhost ~]$ sh readpermission
enter a filename: delete
echo " enter a filename "
read n
if rm $n
then
echo " the file is deleted"
else
echo " no such files"
fi
--o/p
[chandra@localhost ~]$ sh readpermission
enter a filename: tyuo
tyuo file doesnot exist

You might also like