[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check existence but not dereference symlink
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: Check existence but not dereference symlink |
Date: |
Fri, 26 Mar 2021 22:39:17 +0100 |
there is shopt or var option about do defaultly reference or dereference
might have influence here
also its -h and -L
help test
On Fri, Mar 26, 2021 at 10:20 PM Peng Yu <pengyu.ut@gmail.com> wrote:
>
> Hi,
>
> ln -s 1.txt a.txt
> [[ -a a.txt ]]; echo $?
> 1
> [[ -e a.txt ]]; echo $?
> 1
>
> [[ -e path ]] and [[ -e path ]] will deference symlink. If the target
> does not exist, it will return an error.
>
> I want to check the existence of a path without dereferencing symlink.
> I come up with this, but it is a little verbose. Is this the best way
> to do so?
>
> [[ -f path || -h path || -d path ]]
>
> --
> Regards,
> Peng
>