MTn
MTn

Reputation: 103

How to check if a given parameter is a symlink/soft link? in bash

I want something similar to this:

if [ -d "$1" ] 
then 
echo "Directory"

but with soft link:

if [ ??? "$1" ]
then 
echo "Softlink"

Upvotes: 1

Views: 2554

Answers (1)

xstefi
xstefi

Reputation: 591

According to docs Bash-Beginners-Guide:

[ -h FILE ] True if FILE exists and is a symbolic link.

Upvotes: 3

Related Questions