#!/bin/bash arr=() j=0 IFS=' ' PWD=`pwd` DIR=$1 if [ "x$DIR" != "x" ] ; then cd $DIR fi for i in `ls -1` ; do if [ -d "$i" ] ; then arr[$j]=$i j=`expr $j + 1` fi done ls --color=auto -d ${arr[@]} if [ "x$DIR" != "x" ] ; then cd $PWD fi