Created
September 10, 2019 15:52
-
-
Save spencerwi/f93ae791d24e34bf183b8904395b3aed to your computer and use it in GitHub Desktop.
Bash function to go up 1 or more directories without manually cd-ing
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
function up { | |
if [ -z "$1" -o ! "$1" -gt 0 ]; then | |
cd .. | |
else | |
CDSTR="" | |
for i in $(seq 1 $1) ; do | |
CDSTR="../$CDSTR" | |
done | |
cd $CDSTR | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment