Created
October 22, 2011 18:05
-
-
Save peteboere/1306294 to your computer and use it in GitHub Desktop.
Bash function for 'cd'ing up the directory tree
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
# | |
# 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