/ Published in: Bash

Determine absolute minimal absolute path of parent directory containing this script. (remove any ".." path segments). Works with rudimentary Bourne shell as well as bash.
Expand |
Embed | Plain Text
#! /bin/sh # Get absolute minimal absolute path of parent directory containing # this script with ".." path segments removed d=`dirname $0`/.. d=`(cd "$d"; pwd)` echo parent: $d d=`dirname $0` d=`(cd "$d"; pwd)` echo self: $d # bash version # echo parent: $(cd "$(dirname $0)/.."; pwd) # echo self: $(cd "$(dirname $0)"; pwd)
You need to login to post a comment.