Skip to content

Instantly share code, notes, and snippets.

@davemac
Created March 14, 2018 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davemac/fea5fc5b8a4aa7c7ef9ca29e700bb5c0 to your computer and use it in GitHub Desktop.
Save davemac/fea5fc5b8a4aa7c7ef9ca29e700bb5c0 to your computer and use it in GitHub Desktop.
bash move up x directories
# move up X directories, if no argument move up 1
up(){
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
if [ -z "$d" ]; then
d=..
fi
cd $d
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment