[nzlug] Checking for directories that are symbolic links
Johann Schoonees
j.schoonees at irl.cri.nz
Fri Feb 23 17:11:03 NZDT 2007
In bash scripts, how would I check if a directory name is a symlink or
not? The conditional in
if [ -d $dirname ]
evaluates to true whether dirname is a symlink or not. I can think of
roundabout ways like
if $(ls -F $dirname | grep -q "@")
but that would fail on filenames containing @, and
if [ "$(ls -F $dirname)" = "$dirname@" ]
is just as silly. There must be a better way.
Googling "bash directory symlink conditional" gives 140,000 hits. Sigh.
Johann
This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
More information about the NZLUG
mailing list