这是来自手册页的-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
如您所见,该目录不应该是可写的:仅设置r
了x
标志。但是,test
说我可以在里面写... 第一个奇怪的事情。另一个是当我尝试在其中创建文件时会发生什么:No such file or directory
。
顺便说一句,我正在以用户“maxime”的身份运行上述命令,并且我使用的是 Ubuntu 12.04 中的破折号。
好吧,我有点迷路了,有人解释一下吗?