shell -- 获取绝对路径

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

posted @ 2017-02-05 22:26  raindream  阅读(2234)  评论(0编辑  收藏  举报