Skip to content

Instantly share code, notes, and snippets.

@brennanMKE
Last active December 8, 2021 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brennanMKE/fdef8aea21f9cd27630ff97dda9a9dd9 to your computer and use it in GitHub Desktop.
Save brennanMKE/fdef8aea21f9cd27630ff97dda9a9dd9 to your computer and use it in GitHub Desktop.
Find Up
#!/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