.TH REALPATH 1 "October 16th, 2011" "Debian" "Debian" .SH NAME realpath \- return the canonicalised absolute pathname .SH SYNOPSIS .if !'po4a'hide' .B realpath .if !'po4a'hide' .if !'po4a'hide' .RB [ \-s | \-\-strip ] .if !'po4a'hide' .RB [ \-z | \-\-zero ] .I " filename " ... .br .if !'po4a'hide' .B realpath .if !'po4a'hide' .BR \-\-h | \-\-help .br .if !'po4a'hide' .B realpath .if !'po4a'hide' .BR \-\-v | \-\-version .SH "DESCRIPTION" .B realpath converts each .I filename argument to an absolute pathname, which has no components that are symbolic links or the special .B . or .B .. directory entries. (See .BR realpath (3) for more information.) .br Each path component in the .I filename must exist, otherwise .B realpath will fail and non-zero exit status will be returned. .br Please note that mostly the same functionality is provided by the `\-e' option of the .BR readlink (1) command. .PP When the .B \-s option is used .B realpath only removes the .B . and .B .. directories, but not symbolic links from .IR filename . If the given .I filename argument is relative (i.e. does not start with .RI ` / '), .B realpath \-s prepends to it the current directory name as obtained from the .BR getcwd (2) system call before further processing. .PP Each converted pathname is output to the standard output, on its own line. .SH OPTIONS .TP 5 .if !'po4a'hide' .BR \-s ", " \-\-strip Only strip .B . and .BR .. , components, but do not resolve symbolic links. .\" .TP 5 .if !'po4a'hide' .BR \-z ", " \-\-zero Separate output filenames with the null character instead of newline, so it can be used with the .RI ` \-0 ' option of .BR xargs (1). .\" .TP 5 .if !'po4a'hide' .BR \-h ", " \-\-help Print short usage information. .\" .TP 5 .if !'po4a'hide' .BR \-v ", " \-\-version Show .BR realpath 's version number. .SH EXAMPLES .PP For the examples below let's suppose that .I /usr/bin/X11 is a symbolic link, pointing to directory .IR /usr/bin . .SS Example 1 Regardless of what the current directory is .br .RS 4 .nf .if !'po4a'hide' .BI "realpath " /../usr/bin/X11/./xterm .fi .RE prints .RS 4 .nf .if !'po4a'hide' .I /usr/bin/xterm .fi .RE but .RS 4 .nf .if !'po4a'hide' .BI "realpath \-s " /../usr/bin/X11/./xterm .fi .RE outputs .RS 4 .nf .if !'po4a'hide' .I /usr/bin/X11/xterm .fi .RE .SS Example 2 When the current directory is .I /usr/bin/X11 (which is still a symbolic link to .IR /usr/bin ), the output of both .br .RS 4 .nf .if !'po4a'hide' .BI "realpath " ./xterm .fi .RE and .RS 4 .nf .if !'po4a'hide' .BI "realpath \-s " ./xterm .fi .RE will be .RS 4 .nf .if !'po4a'hide' .I /usr/bin/xterm .ne .RE .SS Example 3 Providing that the current directory is .IR /home/user (and the directory exists before and during the realpath run), the command .br .RS 4 .nf .if !'po4a'hide' .BI "realpath " ../path/to/some/./non-existent/./directory/../or/../file .fi .RE will fail with the following error .RS 4 .nf .if !'po4a'hide' .I \&../path/to/some/./non-existent/./directory/../or/../file: No such file or directory .fi .RE but .RS 4 .nf .if !'po4a'hide' .BI "realpath \-s " ../path/to/some/./non-existent/./directory/../or/../file .fi .RE will return .RS 4 .nf .if !'po4a'hide' .I /home/path/to/some/non-existent/file .fi .RE .SH EXIT STATUS .B realpath returns a zero exit code when .I all pathnames were successfully converted. .br In case of any errors (e.g. missing or unavailable directories in the path), .B realpath prints error message to stderr and returns a non-zero exit code. .RE .SH "SEE ALSO" .if !'po4a'hide' .BR basename (1), .if !'po4a'hide' .BR dirname (1), .if !'po4a'hide' .BR readlink (1), .if !'po4a'hide' .BR chase (1), .if !'po4a'hide' .BR realpath (3) .SH BUGS Hopefully none :) .br If you find some, please report them via the normal Debian bug reporting system, see the file .I /usr/share/doc/debian/bug\-reporting.txt in the package doc\-debian or the .BR reportbug (1) man page. .SH AUTHOR Originally written by Lars Wirzenius , as a part of the dwww package. Robert Luberda currently maintains and extends it. .PP realpath is licensed via the GNU General Public License. While it has been written for Debian, porting it to other systems is strongly encouraged.