linux - How to determine if sym link exists -


i'm trying determine if symbolic link exists. thought -l or -f it, doesn't seem working.

vhost="/etc/apache2/sites-available/vhost.local"; if [ ! -l vhost ];         ln -s /home/user/ubuntu\ one/htdocs/vhosts/vhost.local vhost;         a2ensite vhost.local;         echo "  -vhost.local": fi 

it should create sym link if there isn't one....

according test(1) manpage:

   -h file           file exists , symbolic link (same -l)    -l file           file exists , symbolic link (same -h) 

-h or -l should trick. however, not testing against variable $vhost literal vhost. that's error.

so, suppose meant say:

if [ ! -l "$vhost" ];   ... 

additionally you're forgetting $ in ln -s:

ln -s /home/user/ubuntu\ one/htdocs/vhosts/vhost.local "$vhost"; 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -