Symlink check - Linux Bash Script
问题 I'm trying to create a script that searches through a directory to find symlinks that point to non-existing objects. I have a file in a directory with a deleted symlink, but for some reason when i run the below script It says file exists. #!/bin/bash ls -l $1 | if [ -d $1 ] then while read file do if test -e $1 then echo "file exists" else echo "file does not exist" fi done else echo "No directory given" fi Thanks 回答1: Check this page. It has a test for broken links. It uses the -h operator