Shell脚本,目录是可写的奇怪行为

时间:2013-08-13 04:03:25

标签: shell ubuntu scripting dash-shell

以下是-w的手册页中的test选项说明:

   -w FILE
          FILE exists and write permission is granted

作为一个例子胜于千言万语:

$ ls -ld /home/maxime/.gvfs
dr-x------ 2 maxime maxime 0 Aug  5 22:53 /home/maxime/.gvfs
$ [ -w /home/maxime/.gvfs ] && echo "is writable" 
is writable
$ touch /home/maxime/.gvfs/file
touch: cannot touch `/home/maxime/.gvfs/file': No such file or directory

如您所见,目录不可写:仅设置rx标志。 但是,test说我可以写进去......第一个奇怪的事情。另一个是当我尝试在其中创建文件时发生的事情:No such file or directory

顺便说一句,我正在以“maxime”用户身份运行上述命令,而我正在使用Ubuntu 12.04中的破折号。

嗯,我在这里有点迷失,有人得到解释吗?

1 个答案:

答案 0 :(得分:1)

.gvfs是一个特殊文件,实际上是由gvfs-fuse-daemon创建的虚拟文件系统。你不应该直接使用它。