[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to test if a link exists
From: |
Dave Gibson |
Subject: |
Re: How to test if a link exists |
Date: |
Sun, 23 Jun 2013 15:18:16 +0100 |
User-agent: |
tin/2.1.2-20121224 ("Langholm") (UNIX) (Linux/3.0.0-1 (i686)) |
Mark Young <marky1124@gmail.com> wrote:
> Hi,
>
> I stumbled into discovering that the -e test for a file does not
> report the file as existing if the file is a dead symbolic link.
It's documented in the bash manpage under "CONDITIONAL EXPRESSIONS".
Unless otherwise specified, primaries that operate on files follow sym-
bolic links and operate on the target of the link, rather than the link
itself.
> What test should I use to decide if a file exists (including dead
> symbolic links)?
-h and -L apply to the symlink rather than the target, so
test -e broken_link -o -h broken_link