My goal is to check if the the execution bit is not set for a directory.
I changed the permission of /tmp so that the execution bit is off.
root$: chmod 666 /tmp
root$: ls -l /
....
.....
drw-rw-rw- 12 root root 4096 Feb 29 15:17 tmp
In my bash script, I have tried the following without success:
if [ ! -x /tmp ]; then
......
I have experimented with all the suggestions at the following link, but the only different syntax approach does not work for me either:
if [[ ! -x /tmp] ; then
These work as expected for regular files, but not for any directory, but I don't know why. Any ideas?
Update #2
I wrote a mini bash script with only the code suggested in a comment below.
Results:
[root@mc/]# cat tst.sh
#!/bin/bash
if [ ! -x /tmp ]; then echo 'not executable!'; fi
exit
[root@mc/]# ./tst.sh
[root@mc/]#