How to get the absolute path for a given relative path programmatically in Linux?

后端 未结 7 1817
轻奢々
轻奢々 2020-12-05 07:33

How to get the absolute path for a given relative path programmatically in Linux?

Incase of Windows we have the _fullpath() API. In other words, I mean

7条回答
  •  抹茶落季
    2020-12-05 08:02

    Running on RedHat 5.3, realpath doesn't exist but readlink is installed. You can use it on relative paths and symlinks, plus it will resolve symlinks recursively for you. It's thus a better option that realpath in my opinion

    readlink -f .
    

提交回复
热议问题