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
Issue with Splitting of file
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 38
- Joined: Mon Feb 27, 2006 10:34 pm
- Location: Chennai
- Contact:
Issue with Splitting of file
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
Cognizant technologies,Perungudi
Chennai
-
- Participant
- Posts: 69
- Joined: Tue Jan 18, 2005 12:15 am
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
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
-
- Participant
- Posts: 38
- Joined: Mon Feb 27, 2006 10:34 pm
- Location: Chennai
- Contact:
-
- Participant
- Posts: 69
- Joined: Tue Jan 18, 2005 12:15 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 38
- Joined: Mon Feb 27, 2006 10:34 pm
- Location: Chennai
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: