Page 1 of 1

Issue with Splitting of file

Posted: Thu May 17, 2007 4:51 am
by mdtauseefhussain
HI! All
Iam running this script for splitting the file in command stage ,attacth 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
}
example out put
Z_PRICE_NEW_20070517014630aaaac.tmp
Z_PRICE_NEW_20070517014630aaaaa.tmp.tmp

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

Thanks in Advance

Regards

Tausif

Posted: Thu May 17, 2007 5:37 am
by maheshsada
Please use the following code, which split the files and changes the output file with the required format

TEMP_FILENAME="U_D-1_$DATE_YYYYMMDD"_

TEMP_DATA="NED1_DATA"

##Split the File
split -a 4 $WORKDIR/NED1.csv $WORKDIR/$TEMP_DATA

##Move all the Filename that has been created while splitting into NED1_files.txt
ls $WORKDIR/$TEMP_DATA* > $WORKDIR/EDWLoadExtractNED1_files.txt

i=1

##Attach Sequence to each generated File and rename the File to the required format

for FILE_NAME in `cat $WORKDIR/EDWLoadExtractNED1_files.txt`
do
j=`echo $i |awk '{printf "%04ld",$1}'`

FILE="$TEMP_FILENAME$j"

mv $FILE_NAME $FILE

i=`expr $i + 1`

done

regards
Magesh S

Posted: Thu May 17, 2007 5:52 am
by mdtauseefhussain
But what is the issue with the existing script ,it work fine when the file is is smaall,its is throwing this issue only whenthe file is big..

Posted: Thu May 17, 2007 8:13 am
by maheshsada
I have tested your script with 20000 rows its working fine, can you tell how much big is ur file

Magesh S

Posted: Thu May 17, 2007 4:53 pm
by ray.wurlod
:?
Why is this on a DataStage forum?
Ought it not to be on a UNIX or shell scripting forum?

Posted: Thu May 17, 2007 11:48 pm
by mdtauseefhussain
The file which is causing the issue contains 700000 records..

Posted: Fri May 18, 2007 12:49 am
by ray.wurlod
That's not many, unless each is Megabytes in size.