commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Also resolves symlinks, showing the full path of the link target
There are 3 alternatives - vote for the best!
Sometimes you need the full path to your script, regardless of how it was executed (which starting directory) in order to maintain other relative paths in the script.
If you attempt to just use something simple like:
you will only get the relative path depending on where you first executed the script from.
You can get the relative path to the script (from your starting point) by using dirname, but you actually have to change directories and print the working directory to get the absolute full path.
Since none of the systems I work on have readlink, this works cross-platform (everywhere has perl, right?).
Note: This will resolve links.
work for execute file
If you can do better, submit your command here.
You must be signed in to comment.