SHELL SCRIPT TO CHECK IF THE FILE HAS ALL PERMISSION | URDINESH

Software Programming, Tutorials, Interview Preparations,Stock Market,BSE/NSE, General informations

Sunday, July 19, 2015

SHELL SCRIPT TO CHECK IF THE FILE HAS ALL PERMISSION

CHECK IF THE FILE HAS ALL PERMISSION:
  
echo "checking file permission"
read fn
if [ -r $fn -a -w $fn -a -x $fn ]
then
echo "The file has all permission"
else
echo "The file has not all permission"
fi





















OUTPUT:
 
  [localhost ~]$ sh fileper.sh
checking file permission
pol.sh
The file has not all permission
[localhost ~]$ chmod 777 pol.sh
[localhost ~]$ sh fileper.sh
checking file permission
pol.sh
The file has all permission

[localhost ~]$

No comments:

Post a Comment

Thanks for your valuable comments

Followers