creating folder when the string matches

hi
:confused:sorry last time , b4 im drafting the thread i was unexpectedly posted the thread see here is the program wat it will do is .. i have to create folder at the run time when the string matches ... what to do is im havin text file which carry the file name like ( EngCVer1pg1j01.TOP, EngCVer1pg1m08.TOP, EngCVer1pg1h04,..and EngCVer1pg2j01.TOP, EngCVer1pg2e05.TOP ... an some pg3 like tat .) .. but wat i hav to do is , i have to create seprate folder for each EngCVer1pg1 files seprately for each pg1 files .. and in tat created folder i hav to copy the pg2 files each one files accordingly ...

thank you HAS

I'm not clear on your requirments it seems like this may be what you want:

  1. you know where the pg1 files come from
  2. the text file has names of the .TOP files in it, and it does not matter about copying those files.
#!/bin/ksh
cd /path/to/directory
while read filename
do
     base=${filename%%.*}
     mkdir ./"$base"
     cp /path/to/pg1files/"$base".pg1  ./"$base"
done < textfile

thank you for the reply n help ... the pg1 ,pg2 reffers the string EngCVer1pg1h04,..and EngCVer1pg2j01.TOP, EngCVer1pg2e05.TOP