readlink

From RaySoft

readlink prints value of a symbolic link or canonical file name.[1]

Documentation

Syntax

readlink [PARAMETER ...] FILE

Parameters

-e, --canonicalize-existing
Canonicalize by following every symlink in every component of the given name recursively, all components must exist.
-f, --canonicalize
Canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist.
-m, --canonicalize-missing
Canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence.
-n, --no-newline
Do not output the trailing newline.
-q, --quiet, -s, --silent
Suppress most error messages.

Examples

Get the absolute path of a file
readlink --canonicalize-missing '.profile'

Output:

/home/alex/.profile
Get the absolute path to a file
readlink --canonicalize-missing '.profile' | xargs dirname

Output:

/home/alex

References

  1. man 1 'readlink'