Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有将文件路径作为输入并返回绝对文件路径的 bash 命令?更具体地说,我想要一个将路径作为输入的命令,例如:
/tmp/yaneeve/kit/linux/../../output/kit/SOURCES//usr//apps/myapp/lib
并返回路径:
/tmp/yaneeve/output/kit/SOURCES/usr/apps/myapp/lib
谢谢!
如果路径存在,则有一种可移植的方式(即使在 linux 上)更可靠:
canonicalPath=$(cd "$path"; pwd)
尝试(Linux)
readlink -f