Skip to content

Instantly share code, notes, and snippets.

@magnli10 magnli10/changedir
Created Jul 14, 2016

Embed
What would you like to do?
Script snippet to quickly navigate many levels up in the folder structure
##
# 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
You can’t perform that action at this time.