parsing output from ls command

I have to test the directory name which is obtained from

for dir in `ls -l|grep $9 '
i need to check whether it is directory ( [ -d dir ]

if yes, I have to check the first 3 character fo the directory

how can I do that? Please help me

thanks

your statement is not clear !!!
to list dirs ls -l | grep ^d

what abt this ?

Can you please be some more specific?
If possible with an example.

firt I have to find the directory in a directory

ls -ld */ will do it

once I find it is directory, I have to check the first 3 character of the directory

drwxr-xr-x 2 mqm mqm 512 Jan 20 09:36 DQAT001/
drwxr-xr-x 3 mqm mqm 512 Jan 25 12:38 DQAT004/
drwxr-xr-x 2 mqm mqm 512 Apr 20 07:55 DQAT0040/
drwxr-xr-x 2 mqm mqm 512 Apr 20 10:31 DQAT0041/
drwxr-xr-x 2 mqm mqm 512 Jul 13 2005 DQAT005/
drwxr-xr-x 2 mqm mqm 512 May 2 09:33 DQBT007/

in the above I have to find certain directory which has first three character say ' DQA'

how i can check the first three character in the "DQAT001/"

i hope you understand
thanks

more clearly I am trying to like this

for i in ` ls -ld */ |awk '{print $9}'| awk -F \/ '{print $1}'` ;
do

awk $i~/^DQA/ ' {
log for processing goes here

\}'

done

when i find directoy, then i need to see first three character of $i and if matches, process

thanks