readlink - displays the target of a symbolic link
readlink [
-fn]
file(s) ...
The readlink utility, when called with one or more pathes of a symbolic
link as its argument, displays the real path/target of it at the standard
output.
It accepts the following options:
- -f
- Follows the symbolic link until it reaches the original target,
recursively.
- -n
- Does not print a newline character at the end of the output string. This
option is ignored if readlink is used with more than one path as its
argument.
If
readlink is invoked without the
-f option and with a
non-symbolic link path as its argument, the path will not be printed to the
screen.
The readlink utility may be used at shell scripts for displaying/modifying the
real file behind a symbolic link.
For instance, here is an example of how to read both the current directory and
the path of a program behind a process on the
/proc directory.
- readlink -f /proc/`ps -a | nawk '/vim/{ print $1;
exit}'`/{cwd,exe}
ln(1), ls(1), file(1), readlink(2), realpath(3)
The
readlink utility first appeared in OpenBSD 2.1, NetBSD 1.6 and
FreeBSD 4.10.
The GNU variant, which supports multiple files as input, was written by Dmitry
V. Levin and first appeared in GNU coreutils 4.5.5 in February 2, 2003.