Created
September 1, 2013 15:52
-
-
Save alvinlai/6405317 to your computer and use it in GitHub Desktop.
quickly go back up to a specific folder in a directory tree
This file contains hidden or 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
function bd () { | |
OLDPWD=`pwd` | |
NEWPWD=`echo $OLDPWD | sed 's|\(.*/'$1'[^/]*/\).*|\1|'` | |
index=`echo $NEWPWD | awk '{ print index($1,"/'$1'"); }'` | |
if [ $index -eq 0 ] ; then | |
echo "No such occurrence." | |
else | |
echo $NEWPWD | |
cd "$NEWPWD" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment