Bash equivalent for PHP realpath()
For all you PHP hackers trying to write a BASH script and looking for an equivalent for PHP’s realpath function, try readlink. It can expand symbolic links and resolve relative paths like “./” and “../”. In a shell script, try this:
MY_PATH=$(readlink -f $0)
Thanks to Barry.
Tags: bash, PHP
This entry was posted on May 9, 2008 at 12:36 pm and is filed under Coding. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
May 9, 2008 at 1:24 pm
[...] bogged a piece of advice that I have him which I got from Barry… and if you want to know how to get the true absolute path to the real location of the current script is from inside of it (like phps realpath and __FILE__) I suggest you check it out Subscribe to the comments for this [...]