Created
March 14, 2018 00:24
-
-
Save davemac/fea5fc5b8a4aa7c7ef9ca29e700bb5c0 to your computer and use it in GitHub Desktop.
bash move up x directories
This file contains hidden or 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
# 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