realpath
return the canonicalised absolute pathname
- Provided by: realpath (Version: 1.19)
- Report a bug
return the canonicalised absolute pathname
realpath [-s|--strip]
[-z|--zero] filename ...
realpath --h|--help
realpath --v|--version
realpath converts each filename argument to an
absolute pathname, which has no components that are symbolic links or the
special . or .. directory entries. (See realpath(3) for
more information.)
Each path component in the filename must exist, otherwise
realpath will fail and non-zero exit status will be returned.
Please note that mostly the same functionality is provided by the `-e' option
of the readlink(1) command.
When the -s option is used realpath only removes the . and .. directories, but not symbolic links from filename. If the given filename argument is relative (i.e. does not start with `/'), realpath -s prepends to it the current directory name as obtained from the getcwd(2) system call before further processing.
Each converted pathname is output to the standard output, on its own line.
For the examples below let's suppose that /usr/bin/X11 is a symbolic link, pointing to directory /usr/bin.
Regardless of what the current directory is
realpath /../usr/bin/X11/./xterm
/usr/bin/xterm
realpath -s /../usr/bin/X11/./xterm
/usr/bin/X11/xterm
When the current directory is /usr/bin/X11 (which is still
a symbolic link to /usr/bin), the output of both
realpath ./xterm
realpath -s ./xterm
/usr/bin/xterm
Providing that the current directory is /home/user (and the
directory exists before and during the realpath run), the command
realpath ../path/to/some/./non-existent/./directory/../or/../file
../path/to/some/./non-existent/./directory/../or/../file: No such file or directory
realpath -s ../path/to/some/./non-existent/./directory/../or/../file
/home/path/to/some/non-existent/file
realpath returns a zero exit code when all pathnames
were successfully converted.
In case of any errors (e.g. missing or unavailable directories in the path),
realpath prints error message to stderr and returns a non-zero exit
code.
Hopefully none :)
If you find some, please report them via the normal Debian bug reporting
system, see the file /usr/share/doc/debian/bug-reporting.txt in the
package doc-debian or the reportbug(1) man page.
Originally written by Lars Wirzenius <liw@iki.fi>, as a part of the dwww package. Robert Luberda <robert@debian.org> currently maintains and extends it.
realpath is licensed via the GNU General Public License. While it has been written for Debian, porting it to other systems is strongly encouraged.