Created
July 14, 2016 14:26
-
-
Save nataliefl/12cb9c36159c34ff0dcb07106c31500e to your computer and use it in GitHub Desktop.
Script snippet to quickly navigate many levels up in the folder structure
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
## | |
# Go back multiple directories at once. | |
# | |
# Example : | |
# | |
# shell> .. 5 | |
# | |
# This will take you 5 directories back in the file structure. This is the same as typing | |
# | |
# shell> cd ../../../../.. | |
## | |
.. () | |
{ | |
if [[ "$1" == [1-9] ]] ; then | |
limit=$1; | |
else | |
##echo "Illegal number of directories [1-9]. Defaulting to 1" | |
limit=1; | |
fi | |
c=0 | |
until [ $c -eq $limit ] | |
do | |
cd .. | |
c=$(( $c + 1 )) | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment