
正文
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






![【电子书】[职业技术] 《Linux命令行与shell脚本编程大全(第3版)》[Richard Blum][epub+mobi+azw3] 【电子书】[职业技术] 《Linux命令行与shell脚本编程大全(第3版)》[Richard Blum][epub+mobi+azw3]](https://www.04ip.com/template/qe/style/noimg/2.jpg)

