Skip to content

Instantly share code, notes, and snippets.

@peteboere
Created October 22, 2011 18:05
Show Gist options
  • Save peteboere/1306294 to your computer and use it in GitHub Desktop.
Save peteboere/1306294 to your computer and use it in GitHub Desktop.
Bash function for 'cd'ing up the directory tree
#
# Bash function for 'cd'ing up the directory tree
#
# Example use:
# Move working directory up 5 levels
# $> up 5
# Equivalent to
# $> cd ../../../../../
#
function up {
local counter=${1:-1}
local dirup="../"
local out=""
while (( counter > 0 )); do
let counter--
out="${out}$dirup"
done
cd $out
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment