Skip to content

Instantly share code, notes, and snippets.

@egulhan
Created January 27, 2013 21:08
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 egulhan/4650500 to your computer and use it in GitHub Desktop.
Save egulhan/4650500 to your computer and use it in GitHub Desktop.
go up by number means that do cd.. by number
# up 4 -> go up 4 directories
up()
{
dir=""
if [[ $1 =~ ^[0-9]+$ ]]; then
x=0
while [ $x -lt ${1:-1} ]; do
dir=${dir}../
x=$(($x+1))
done
else
dir=..
fi
cd "$dir";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment