How to resolve symbolic links in a shell script

后端 未结 19 2185
死守一世寂寞
死守一世寂寞 2020-11-28 00:48

Given an absolute or relative path (in a Unix-like system), I would like to determine the full path of the target after resolving any intermediate symlinks. Bonus points for

19条回答
  •  时光取名叫无心
    2020-11-28 01:27

    readlink -e [filepath]
    

    seems to be exactly what you're asking for - it accepts an arbirary path, resolves all symlinks, and returns the "real" path - and it's "standard *nix" that likely all systems already have

提交回复
热议问题