Skip to main content
added 96 characters in body
Source Link
Jahid
  • 22.6k
  • 10
  • 97
  • 114
[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quoting variables is a good practice.

Explanation:

  • -d: check if it's a directory
  • -L: check if it's a symbolic link
[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quoting variables is a good practice.

[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quoting variables is a good practice.

Explanation:

  • -d: check if it's a directory
  • -L: check if it's a symbolic link
edited body
Source Link
Jahid
  • 22.6k
  • 10
  • 97
  • 114
[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quote variable to tackle with spacesQuoting variables is a good practice.

[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quote variable to tackle with spaces.

[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quoting variables is a good practice.

Source Link
Jahid
  • 22.6k
  • 10
  • 97
  • 114

[[ -d "$DIR" && ! -L "$DIR" ]] && echo "It's a directory and not a symbolic link"

N.B: Quote variable to tackle with spaces.