table of contents
| XDG-REALPATH(1) | xdg-realpath Manual | XDG-REALPATH(1) |
NAME¶
xdg-realpath - Canonicalizes filepaths in a consistent way.
SYNOPSIS¶
xdg-realpath [--] file...
xdg-realpath --get-backend
xdg-realpath {--help | --manual | --version}
DESCRIPTION¶
xdg-realpath canonicalizes filepaths using the installed realpath or readlink -f implementation, automatically choosing the right calling conventions so you don't have to worry about it.
Canonicalization happens by resolving relative paths and symbolic links resulting in an absolute path to a file. It fails if the path does not lead to any kind file or directory.
It is strongly recommended to call xdg-realpath using the -- option.
When using xdg-realpath with multiple files and one of the given paths leads directly or indirectly to a missing file a message will be printed to stdout and xdg-realpath will continue resolving until it has finished with all given paths. If at least one path does not resolve, it will return an exit code 2.
Unlike realpath or readlink -f xdg-realpath will error if one attempts to resolve a non-existing file in an existing directory. If such behavior is added in the future it will be behind a command line flag.
OPTIONS¶
--help
--manual
--version
EXIT CODES¶
An exit code of 0 indicates success while a non-zero exit code indicates failure. The following failure codes can be returned:
1
2
3
4
ENVIRONMENT VARIABLES¶
xdg-realpath honours the following environment variables:
XDG_UTILS_REALPATH_BACKEND
Setting this variable has the possibility to break a lot of things. It is primarily intended for testing and quick-fixing. If you are not the local system administrator or a distribution maintainer leave it alone!
The --get-backend option will print the used backend.
SEE ALSO¶
EXAMPLES¶
xdg-realpath -- /./bin
Canonicalizes the path to /./bin, on most systems the output will be /bin or /usr/bin.
xdg-realpath -- foo.txt
Will print the absolute path of the file foo.txt or inform you that foo.txt doesn't exist.
xdg-realpath -- .
Will print the present working directory path with symbolic links resolved.
AUTHORS¶
Slatian <baschdel+xdg-utils@disroot.org>
Kevin Krammer
Jeremy White
COPYRIGHT¶
Copyright © 2023
| 03/11/2026 | xdg-utils 1.2 |