This question already has an answer here:
- Converting relative path into absolute path? 6 answers
Let's say I have a variable like this:
directory="/home/lrh/package1/util/../.."
How could I convert it to the following?:
"/home/lrh"
In other words, how could I have Bash "evaluate" the directory
variable and get the full path?
Changing to the directory seems to be a straightforward approach:
echo "$(cd "${directory}"; pwd)"