There are many ways to see this. First of all, it is indicated in the output of ls -l
. Note that the directory has a d
at the beginning of the permissions field while the link has an l
:
$ ls -l
drwxr-xr-x 2 terdon terdon 4096 Feb 13 14:12 bar
lrwxrwxrwx 1 terdon terdon 3 Feb 13 14:12 foo -> bar
You can also use file
:
$ file bar foo
bar: directory
foo: symbolic link to `bar'
Another choice is readlink
which follows symbolic links to their targets:
$ readlink foo
bar
Running readlink bar
will return no output (it fails, returning a non-0 exit code), so you can do something like:
readlink bar || echo "Not a link!"
or
readlink foo && "Echo this is a link"
Finally, you could also use find
or the shell itself to list all links:
find . -type l
or
for f in *; do [ -L "$f" ] && echo "$f is a link"; done
->
is that what you mean?