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

Jay picture Jay · Feb 26, 2010 · Viewed 59k times · Source

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 what is analogous API to _fullpath of Windows in Linux?

Answer

unwind picture unwind · Feb 26, 2010

As Paul mentioned, use realpath(). Please note though, that since many file systems in Linux support hard links, any given directory can have a number of different absolute paths.