Linux 如何检查目录是否为;d";存在,但无权为当前用户读取

Linux 如何检查目录是否为;d";存在,但无权为当前用户读取,linux,bash,shell,Linux,Bash,Shell,我需要一个bash程序的助手。 如何检查“d”目录是否存在,但当前用户没有读取权限 if [ -d $d ]; #Check if directory exist then #check the permission fi 如果需要可移植的shell语法:[-d]&&![-rd] 参考:可能的副本等。 $ mkdir d $ sudo sh -c 'chown root:root d && chmod 700 d' $ [[ -d d && ! -r

我需要一个bash程序的助手。 如何检查“d”目录是否存在,但当前用户没有读取权限

if [ -d $d ]; #Check if directory exist
then
    #check the permission
fi
如果需要可移植的shell语法:
[-d]&&![-rd]

参考:

可能的副本等。
$ mkdir d
$ sudo sh -c 'chown root:root d && chmod 700 d'

$ [[ -d d && ! -r d ]] && echo "d exists but is not readable"
d exists but is not readable