100 Useful Command-Line Utilities
by Oliver; 201432. readlink
readlink provides a way to get the absolute path of a directory.Get the absolute path of the directory mydir:
$ readlink -m mydirGet the absolute path of the cwd:
$ readlink -m .Note this is different than:
$ pwdbecause I'm using the term absolute path to express not only that the path is not a relative path, but also to denote that it's free of symbolic links. So if we have the link discussed above:
~/MYLINK --> /some/long/and/complicated/path/to/an/often/used/directorythen:
$ cd ~/MYLINK $ readlink -m . /some/long/and/complicated/path/to/an/often/used/directoryOne profound annoyance: readlink doesn't work the same way on Mac unix (Darwin). To get the proper one, you need to download the GNU coreutils.