Closed. This question is off-topic. It is not currently accepting answers. Learn more
想改进这个问题吗?Update the question所以堆栈溢出的值小于aa>。
我试图确定符号链接是否存在。我以为-L-f可以做到,但它似乎不起作用。

VHOST="/etc/apache2/sites-available/vhost.local";
if [ ! -L VHOST ]; then
        ln -s /home/user/Ubuntu\ One/htdocs/vhosts/vhost.local VHOST;
        a2ensite vhost.local;
        echo "  -vhost.local":
fi

它应该创建sym链接,如果还没有一个…

最佳答案

根据TEST(1)手册页:

   -h FILE
          FILE exists and is a symbolic link (same as -L)
   -L FILE
          FILE exists and is a symbolic link (same as -h)

-h-L应该起作用。但是,您不是针对变量$VHOST进行测试,而是针对文本VHOST。这就是错误。
所以,我想你是想说:
if [ ! -L "$VHOST" ]; then
  ...

另外,您在ln -s中忘记了$
ln -s /home/user/Ubuntu\ One/htdocs/vhosts/vhost.local "$VHOST";

10-05 19:20