Help Me Pls Its Urgent!!!!!!!!!!!!!!!!

Hi,
These are the text file I have

//input1.txt//
cd dir1/dir2/pg1.txt
cd dir3/dir4/pg2.txt
cd dir88/dir5/pg4.txt
cd dir7/dir6/pg5.txt
cd dir8/dir9/pg7.txt

And each text file has some text.

Now I have to write a shell script which reads input1.txt and changes the directory as shown in each line and reads pg1.txt and then copy it to another file namely out.txt. This has to be done recxursively. The code which i Have written is

#!/bin/ksh
 if [ $# -ne 2 ]  # enter the input data file and output file
 then
 echo "Please enter 2 filenames" 
 fi
 infile=$1
 outfile=$2
 while read line
 do
  #read the path of a file and change the path
  cd $line 
  while read line # now reads the file pg1.txt 
  do
   echo "$line" >> $outfile
  done< $line
 done < "$infile"

Here I am able to put data of pg1.txt in out.txt but other files I am not able to do it...Pls help me.....

Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.

Thank you.

The UNIX and Linux Forums