Issue with Splitting of file

HI! All
Iam running this script ro split the file ,attact a timesatmp to it and then conver it to .tmp extension

cd /home/staff/thussain
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
find . -name "$Prefix*" -print | {
while read FILE;
do
mv $FILE $FILE.tmp
done
}
out put
Z_PRICE_NEW_20070517014630aaaac.tmp
Z_PRICE_NEW_20070517014630aaaaa.tmp.tmp

but sone file are coming with tmp extension twice ,and any on tell me how to resolve this issue..

Thanks in Advance

Regards

Tausif

Put the output files into a second directory, the find statement is also finding the new files that you are creating and then processing them again.

It seems like you are having left over files from previous splits.
The "split" command does not remove files prior to execution.
What I recommend you to do is to clean up the output split
files first before you issue the command:

...
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
rm -f $Prefix*
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
...

I think script is finding the files which are already been given .tmp extension. So it might be giving the problem

So how to handle this issue becasue these files needs to be pickedup from the same location by SAP XI

I think if you eliminate the files having .tmp extension from the list of files into which you are looping, this problem will be solved. Code would be something like this,

cd /home/staff/thussain
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
find . -name "$Prefix*" -print | grep -v '.tmp$' | {
while read FILE;
do
mv $FILE $FILE.tmp
done
}

you can give a !, an example

find . ! -name "*tmp" -a -name "$Prefix*"  .......

something like that...