Reading a file

I have all the subdirectories names in a text file. I have to read that text file and move that subdirectory and come back to orginal directory and again read anoteh sub directory like that.
main > sub1 > testsub1.txt
> sub2 > testsub2.txt
> sub3 > testsub3.txt
> sub4 > testsub4.txt
I have done all the subdirectories names in free.txt which contains:

sub1
sub2
sub3

like entries.

Here i need a shell script to read free.txt file, and go to sub1 directory and read testsub1.txt file and come back to sub2 and read testsub2.txt like that .i am using the below script but i am not getting properly. Can anyone suggest me.

cat test.txt | while read LINE
do
CD1=`ls ${LINE}/inbox`
done

Hi Kiran,
Would u pl elaborate on your problem?
May I know your goal of reading testsub1.txt file.
u can try the following also:
#!/usr/bin/tcsh

set mylist = `cat test.txt`
foreach mydir ($mylist)
cd $mydir
cat *.txt
cd -
end
and save this script out of the directory that contains all these sub1, sub2, sub3 etc.,
and source it in the directory with sub1, sub2, sub3 there as
source ../myscript

Thanks,
Sowmya

Thanx for Reply Soumya.
The thing i need shel script in unix. The problem is..

I have "main" directory.under that "sub1,sub2,sub3" like n directories are there. each subdirectory is having "inbox" subdirectory. I have to iterate all the directories and get the file in "inbox" directory of each sub directory. Please do the needful

Hi Kiran,
Thanks for the elaboration.
Still I could not get the output of reading the file in the inbox.
Anyway, pl try this shell script:
#!/usr/bin/tcsh
set mylist = `cat free.txt`
foreach mydir ($mylist)
cat $mydir/inbox/*.txt
end

Thanks,
Sowmya

foreach in not working Soumya

Hello kiran ,
what you have written is correct.

I have also tried the same it works fine

cat test.txt | while read LINE
do
CD1=`ls ${LINE}/inbox`
echo $CD1 ### this is a extar which i have included for checking.
done

and text.txt file contains

sub1
sub2
sub3

in which I have created files under each folder.

check this out if any problem you can get back.

Praveen,
Only sub1 is iterating and remaining is sub directories are not iterating. Can u suggest

is it giving any error

one more thing i want to clarify , is there only one particular sub-directory under sub1, sub2, ...subn and its "inbox" .

If this is the case then above script will work fine.

If not then script has to changed . For that you have to explain your problem.