#!/bin/sh function getdir() { for file in $1/* do if [ -d $file ] then var=$file #path=`dirname $var` path=`cd "$path$var"; pwd` cd $path ls $path unset path cd .. fi done } getdir .