#!/bin/bash #goes up many dirs as the number passed as argument, if none goes up by 1 by default up(){ local d="" limit=$1 for ((i=1 ; i <= limit ; i++)) do d=$d/.. done if [ -z "$d" ]; then d=.. fi cd $d }