Unix CLI that prints a symlink's complete chain of targets using absolute paths.
npm install rreadlink 
Contents
- rreadlink — introduction
- Examples
- Installation
- Installation from the npm registry
- Manual installation
- Usage
- License
- Acknowledgements
- npm dependencies
- Changelog
rreadlink is a multi-platform Unix CLI that prints a symlink's _complete chain_ of targets using _absolute_ paths; it can
also determine the canonical path of non-symlinks.
The primary purpose of rreadlink (recursive readlink) is to follow a given symlink to its ultimate target, printing _all intermediate symlinks_ along the way.
All paths are printed as _absolute_ paths, with the ultimate target printed in _canonical_ form.
This is hepful on Linux platforms, for instance, where some utilities are installed as symlinks that point to _other_ symlinks before resolving
to the ultimate target, making it difficult to understand what is ultimately invoked;
e.g., on some Linux distros /usr/bin/nawk links to /etc/alternatives/nawk, which in turn links to the actual target, /usr/bin/gawk.
Note that the native GNU readlink utility can either only give you the _next_ target (not the ultimate one), or, with -f or -e or -m,
_only_ the _ultimate_ target (not intermediate ones).
Loosely speaking, rreadlink provides the functionality of GNU readlink -e while also including _intermediate_ targets.rreadlink has the added advantage of being multi-platform (see Installation below).
Alternatively, given a _non_-symlink, rreadlink prints the argument's canonical path (i.e., any _directory_ components that are symlinks
are resolved to their ultimate targets).
Find examples below, concise usage information further below, or
read the manual.
See also: The typex utility
provides information about _executables in the path_ (among other things) and
has rreadlink's behavior built in to show what file is ultimately invoked.
``shellPrint the symlink chain for executable /usr/bin/nawk (e.g., on Ubuntu):
$ rreadlink /usr/bin/nawk
/usr/bin/nawk@ -> /etc/alternatives/nawk@ -> /usr/bin/gawk
Installation
Supported platforms
Unix-like platforms with POSIX-compatible utilities and
Bash, such as Linux and OS X.
Installation from the npm registry
Note: Even if you don't use Node.js, its package manager,
npm, works across platforms and is easy to install; try curl -L http://git.io/n-install | bashWith Node.js or io.js installed, install the package as follows:
[sudo] npm install rreadlink -g
Note:
* Whether you need
sudo depends on how you installed Node.js / io.js and whether you've changed permissions later; if you get an EACCES error, try again with sudo.
* The -g ensures _global_ installation and is needed to put rreadlink in your system's $PATH.Manual installation
* Download the CLI as
rreadlink.
* Make it executable with chmod +x rreadlink.
* Move it or symlink it to a folder in your $PATH, such as /usr/local/bin (OSX) or /usr/bin (Linux).
Usage
Find concise usage information below; for complete documentation, read the manual online or,
once installed, run
rreadlink nws (rreadlink --man if installed manually).`nohighlight
$ rreadlink --help
Recursively resolves symlinks by printing the chain of targets using absolute
paths or prints the canonical path of a symlink's ultimate target or of a
non-symlink.
rreadlink [-s|-1] symLink
rreadlink -e symLink
-s single-line output format using ' -> ' between paths and
@ to mark symlinks (default when printing to terminal)
-1 one-line-per-path output format, without the @ marker (default
when NOT printing to a terminal)
-e print only the symlink's ultimate target, in canonical form
Standard options: --help, --man, --version, --home
`License
Copyright (c) 2015 Michael Klement (http://same2u.net),
released under the MIT license.
Acknowledgements
This project gratefully depends on the following open-source components, according to the terms of their respective licenses.
npm dependencies below have optional suffixes denoting the type of dependency; the absence of a suffix denotes a required run-time dependency:
(D) denotes a development-time-only dependency, (O) an optional dependency, and (P) a peer dependency.npm dependencies
* doctoc (D)
* json (D)
* marked-man (D)
* replace (D)
* semver (D)
* shall (D)
* urchin (D)
Changelog
Versioning complies with semantic versioning (semver).
* v0.2.1 (2015-10-21):
* [dev] Improved robustness of interal
rreadlinkchain() function.* v0.2.0 (2015-09-18):
* [potentially breaking change]
rreadlink now also accepts options placed
_after_ operands on the command line (except after --).
* [doc] rreadlink now has a man page (if manually installed,
use rreadlink --man); rreadlink -h now just prints concise usage
information.
* [doc] README.md cleaned up and extended.
* [dev] Removed post-install command that verifies presence of Bash, because
npm` _prints_ the command during installation, which can be confusing.* v0.1.6 (2015-09-15):
* [dev] Makefile improvements; various other behind-the-scenes tweaks.
* v0.1.5 (2015-06-26):
* [doc] Read-me: npm badge changed to shields.io; license badge added; typo fixed.
* [dev] To-do added; Makefile updated.
* v0.1.4 (2015-05-30):
* [doc] npm registry badge added.
* v0.1.3 (2015-02-11):
* Doc: Read-me improvements.
* v0.1.2 (2015-02-11):
* Doc: Read-me and CLI help improvements.
* v0.1.1 (2015-02-11):
* Dev: Tests improved.
* v0.1.0 (2015-02-11):
* Initial release.