3 ms·
I found a much better way of handling this via SO one time, and I've kept it ever since: # Up command, from stackoverflow. Takes optional number of level
by bussierem 8y ago
I found a much better way of handling this via SO one time, and I've kept it ever since:
# Up command, from stackoverflow. Takes optional number of
levels to cd ../
up(){
local d=""
limit=$1
for ((i=1 ; i <= limit ; i++))
do
d=$d/..
done
d=$(echo $d | sed 's/^\///')
if [ -z "$d" ]; then
d=..
fi
cd $d
}