Tuesday 3 November 2015

Linux Shell program to check access mode of a file

if [ -r /$PWD/new2 ]
then
   echo “new2 exists and is executable. Exiting.”
elif [ -x /bin/bash ]
then
   echo “/bin/bash exists and is executable. Exiting.”
elif [ -x /bin/sh ]
 then
   echo “/bin/sh exists and is executable. Exiting.”
else
   echo “Found no executable program.”
fi

No comments:

Post a Comment