How to check if a symlink exists

前端 未结 8 2069
無奈伤痛
無奈伤痛 2020-12-04 05:04

I\'m trying to check if a symlink exists in bash. Here\'s what I\'ve tried.

mda=/usr/mda
if [ ! -L $mda ]; then
  echo \"=> File doesn\'t exist\"
fi


mda         


        
8条回答
  •  萌比男神i
    2020-12-04 06:02

    Is the file really a symbolic link? If not, the usual test for existence is -r or -e.

    See man test.

提交回复
热议问题