我的目标是检查是否没有为目录设置执行位。bash命令检查目录是否可执行
我更改了/ tmp的权限,以便执行位关闭。
root$: chmod 666 /tmp
root$: ls -l/
....
.....
drw-rw-rw- 12 root root 4096 Feb 29 15:17 tmp
在我的bash脚本,我曾尝试没有成功如下:
if [ ! -x /tmp ]; then
......
我已经尝试通过以下链接所有的建议,但唯一不同的语法方法并没有为我工作或者:
if [[ ! -x /tmp] ; then
帖e对于普通文件按预期工作,但不适用于任何目录,但我不知道为什么。有任何想法吗?
更新#2
我写了一个小bash脚本只在下方留言,建议的代码。
结果:
[[email protected]/]# cat tst.sh
#!/bin/bash
if [ ! -x /tmp ]; then echo 'not executable!'; fi
exit
[[email protected]/]# ./tst.sh
[[email protected]/]#
退房更新#2在我的岗位。我只用简单的代码片段写了一个迷你bash脚本,然后运行它。没有输出。 –
嗯......你可以再次在/ tmp上回显权限吗? 'ls -lAh/tmp' – Toberumono
drw-rw-rw- 12 root root 4096 Mar 1 13:15 tmp –