How to run a loop for assigning strings which are present in a file to an array

Hi Forum,

I am struggling with the for loop in shell script.
Let me explain what is needed in the script.
I have a file which will conatin some strings like

file1
place1
place2
place3
checkpoint
some other text
some more text

Now what my requirement is
the words
place1,place2 and place3 are directory names
from this file i have to store these directory names in some array
so first i have to split the file in such a way that i have only directory names that is done with the below line of code:

sed -n -e '/checkpoint/q' -e '1,/checkpoint/p' /tmp/file2
now my file contains only
place1
place2
place3

now my question is how to run a loop so that all these strings are stored in some variables and then inside the loop i can enter into each of these directiries and do a long listing.The long listing part i know,but my only problem is how to enter into each of the directory specified in file2 using a loop.

Hope i have cleary mentioned the problem,appreciate a positive response if my problem is not clear please do let me know.Thanks

If I understand, try this:

#! /usr/bin/ksh
sed -n -e '/checkpoint/q' -e '1,/checkpoint/p' /tmp/file2 | while read dir ; do
      cd $dir
      ls -l
      cd ..
done
exit 0

This assumes you are positioned in the parent of these directories when you start.

Hey thanks perderabo,
just one doubt..actually i am running a script to generate the above file.

it is generic or dynamic amd i am running it from some other location.
And i am not positioned at the parent location.

Now my question is how to run the above command from some other location
what changes are needed in the above line if i am executing this from other location?

For Eg:
i am running this script from /tmp

and the out put is like this

place1
place2
place3
checkpoint
some other text
some more text

now
place1,place2,place3

are directories under the parent directory /logs
Can you modify the above script so the inside the loop it will go into
/logs/$dir
and then do ls -l??

Thanks in advance.