Skip to content

Instantly share code, notes, and snippets.

@nataliefl
Created July 14, 2016 14:26
Show Gist options
  • Save nataliefl/12cb9c36159c34ff0dcb07106c31500e to your computer and use it in GitHub Desktop.
Save nataliefl/12cb9c36159c34ff0dcb07106c31500e to your computer and use it in GitHub Desktop.
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