Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Prints out the relative path between to absolute paths. Trivial.
- #
- # Parameters:
- # $1 = first path
- # $2 = second path
- #
- # Output: the relative path between 1st and 2nd paths
- relpath() {
- local pos="${1%%/}" ref="${2%%/}" down=''
- while :; do
- test "$pos" = '/' && break
- case "$ref" in $pos/*) break;; esac
- down="../$down"
- pos=${pos%/*}
- done
- echo "$down${ref##$pos/}"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement