问题
I have a directory as shown
d-wx--x--x 2 bcheudev bcheudev 4096 Jun 18 06:16 test
which shows the directory does not have read permission.
But when i check the same through shell script it's giving result as dir test has read permission.
export IN_DIR=$MMHOME/test
if [ -d ${IN_DIR} ]
then
if [ ! -r ${IN_DIR} ]
then
echo "${IN_DIR} Directory is not readable.">>$log_name
exit 255
fi
else
echo "${IN_DIR} Directory does not Exists.">>$log_name
exit 255
fi
inside second if it's not going.
Please help
回答1:
Remember that root will always have read permissions.
回答2:
I think that your condition is incorrect. Try with :
if ! [[ -r ${IN_DIR} ]]
then
echo "${IN_DIR} Directory is not readable.">>$log_name
exit 255
fi
来源:https://stackoverflow.com/questions/30930434/how-to-check-a-directory-has-a-read-write-permission