Harrison.DING
Harrison.DING

Reputation: 3

Linux Shell: Verify whether a file exists and is a soft link?

How to verify whether a file or directory exist and is a symbolic link (soft link) on Linux?

I want to write a shell to do it.

Could you please give me some tips?

Upvotes: 0

Views: 3487

Answers (1)

dogbane
dogbane

Reputation: 274532

You can use the -L test option:

if [[ -L $file ]]; then
    echo "$file exists and is a symbolic link"
fi

Upvotes: 2

Related Questions