Skip to content

Instantly share code, notes, and snippets.

@spencerwi
Created September 10, 2019 15:52
Show Gist options
  • Save spencerwi/f93ae791d24e34bf183b8904395b3aed to your computer and use it in GitHub Desktop.
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
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