Last active
December 8, 2021 22:58
-
-
Save brennanMKE/fdef8aea21f9cd27630ff97dda9a9dd9 to your computer and use it in GitHub Desktop.
Find Up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Locates directory that contains $1. | |
findup() | |
{ | |
DIR=$1 | |
START="${DIR}" | |
while [ ! "${DIR}" -ef .. ]; do | |
[ -e "$1" ] && echo "$DIR" && return | |
cd .. || return | |
DIR=$(pwd) | |
done | |
} | |
findup $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment