readlink -f <file> readlink -m <file>
会把file的相对路径转化为绝对路径
几个选项的区别:
-f, --canonicalize canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist -e, --canonicalize-existing canonicalize by following every symlink in every component of the given name recursively, all components must exist -m, --canonicalize-missing canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence
参考:http://stackoverflow.com/questions/3915040/bash-fish-command-to-print-absolute-path-to-a-file