Search code examples
linuxbashparameterssymlink

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"

Solution

  • According to docs Bash-Beginners-Guide:

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