How to resolve symbolic links in a shell script

后端 未结 19 2248
死守一世寂寞
死守一世寂寞 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:46

    To work around the Mac incompatibility, I came up with

    echo `php -r "echo realpath('foo');"`
    

    Not great but cross OS

提交回复
热议问题