readlink — display the contents of a symbolic link
readlink [-n] file
If the file operand names a symbolic link, the readlink utility shall not follow the symbolic link when resolving file and shall write the contents of the symbolic link to standard output. If the -n option is not specified, the output to standard output shall be followed by a <newline> character.
If file does not name a symbolic link, readlink shall write a diagnostic message to standard error and exit with non-zero status.
The readlink utility shall conform to XBD 12.2 Utility Syntax Guidelines .
The following option shall be supported:
- -n
- Do not output a trailing <newline> character.
The following operand shall be supported:
- file
- A pathname of a symbolic link to be read.
Not used.
None.
The following environment variables shall affect the execution of readlink:
- LANG
- Provide a default value for the internationalization variables that are unset or null. (See XBD 8.2 Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalization variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files).
- LC_MESSAGES
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.- NLSPATH
- [XSI] Determine the location of messages objects and message catalogs.
Default.
See DESCRIPTION.
The standard error shall be used only for diagnostic messages.
None.
None.
The following exit values shall be returned:
- 0
- Successful completion.
- >0
- An error occurred.
Default.
None.
None.
The readlink utility was added because using ls -l to obtain the contents of a symbolic link is difficult if the output includes more than one occurrence of the string " -> ".
The -f option found in many implementations was not included, as the realpath utility provides equivalent functionality with a choice of behaviors.
None.
XBD 8. Environment Variables , 12.2 Utility Syntax Guidelines
XSH readlink
First released in Issue 8.
return to top of page