/usr/bin/realpath not found in Centos 6.5
Solution 1:
realpath
is a very useful tool, however most of its functionalities were already present with readlink
. The realpath
man page states:
Please note that mostly the same functionality is provided by the '-e' option of the readlink(1) command.
And the readlink
man page states:
-e, --canonicalize-existing: canonicalize by following every symlink in every component of the given name recursively, all components must exist.
The readlink
command was added to coreutils, AFAIK, in 2008: it is surely available in Ubuntu Hardy 8.04. So if you do not have realpath, it is possible that you have readlink
immediately available.
Solution 2:
The realpath
tool was added to GNU coreutils in version 8.15 (commit 77ea441f79aa), released in 2012. Your CentOS release likely has coreutils v8.4. The tool wasn't removed; it was not yet added in the first place.
Solution 3:
Normally realpath
is provided by coreutils
package, so you should install it via:
yum install coreutils
Alternatively try: readlink
or define your own function, such as:
realpath () { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" }
or see some more examples here.
I've tested the command in CentOS 7 VM via Vagrant:
vagrant init bento/centos-7.1 && vagrant up --provider virtualbox && vagrant ssh
it seems realpath
is installed by default.