Write Linux Shell script to check whether a sample file is readable, writable, and executable
echo -n "Enter file name : "
read file
# find out if file has write permission or not
[ -w $file ] && W="Write = yes" || W="Write = No"
# find out if file has excute permission or not
[ -x $file ] && X="Execute = yes" || X="Execute = No"
# find out if file has read permission or not
[ -r $file ] && R="Read = yes" || R="Read = No"
echo "$file permissions"
echo "$W"
echo "$R"
echo "$X"
Comments
Leave a comment