readlink
readlink prints value of a symbolic link or canonical file name.[1]
- GNU Coreutils [EN] @ Fedora Package
- GNU Coreutils [EN] @ Homebrew Formula
Documentation
- readlink [EN] @ GNU Coreutils Manual
- man 1 'readlink' [EN]
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
- ↑ man 1 'readlink'