Comando test
:
# doesn't echo OK, because no read-write permissions
$ [ -r /proc/28127/task/28189/fd ] && [ -w /proc/28127/task/28189/fd ] && echo "OK"
# echoes OK, because my user has read-write permissions to the directory
$ [ -r $HOME ] && [ -w $HOME ] && echo "OK"
OK
Isso pode ser colocado em uma função e armazenar em ~/.bashrc
ou usado em um script:
check_dir() {
[ -r "" ] && [ -w "" ] && echo "OK"
}
E usado assim:
$ check_dir $HOME
OK
Comando find
:
# Doesn't return directory name because I don't have read/write permissions
$ find /proc/28127/task/28189/fd -maxdepth 0 -readable -writable
# Returns directory name, because I can write/read there
$ find $HOME -maxdepth 0 -readable -writable
/home/xieerq