![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tuning AIX IO | theerthan | UNIX for Advanced & Expert Users | 1 | 04-06-2008 10:12 AM |
| Merging lines using AWK | senthil_is | Shell Programming and Scripting | 6 | 03-05-2008 12:40 PM |
| Merging files with AWK filtering and counting lines | Meert | Shell Programming and Scripting | 2 | 01-28-2008 11:58 AM |
| merging two lines in a file | thaduka | UNIX for Dummies Questions & Answers | 6 | 07-11-2007 10:27 AM |
| Merging lines into one | Foxgard | UNIX for Dummies Questions & Answers | 8 | 06-19-2005 07:36 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Merging lines - Tuning the script
Hi, Anybody can tune the below script? Its taking 1hour to process 7000 lines.
addendaRecInd=7 entryDetailRecord=6 hdrDetailRecord=1 companyHdrRecord=5 companyCtrlRecord=8 trlRecord=9 recLength=94 FormatDone=false trlCompleted=false prevEntryCalc=false batchCnt=0 hdrFound=false while read line do # Find the Line # grep -n "$line" $srcFile |cut -d : -f1 |read lineno #find the Rec Type if [ `echo $line|grep "^$companyHdrRecord"| wc -l` -ne 0 ] then hdrFound="true" val="" typeset -L94 line hdr="$line" typeset -R0 line typeset -R0 batchCnt fi if [ `echo $line|grep "^$hdrDetailRecord"| wc -l` -ne 0 ] then typeset -L94 line value="" echo "$line" >> $destFile line="" typeset -R0 line fi if [ `echo $line|grep "^$trlRecord"| wc -l` -ne 0 -a $trlCompleted = false ] then echo $trlCompleted value="" typeset -L94 line echo "$line" >> $destFile line="" typeset -R0 line trlCompleted=true echo $trlCompleted fi if [ `echo $line|grep "^$companyCtrlRecord"| wc -l` -ne 0 ] then if [ "$hdrFound" != "true" ] then echo "hdrFound" $hdrFound echo "The last line is " $value if [ "$value" != " " ] then typeset -L599 value typeset -L6 batchCnt echo "$value$batchCnt" >> $destFile typeset -R0 value typeset -R0 batchcnt fi typeset -L94 line typeset -L6 batchcnt echo "$line$batchCnt" >> $destFile typeset -R0 line typeset -R0 batchcnt value="" line="" prevEntryCalc=false fi fi if [ `echo $line|grep "^$entryDetailRecord"| wc -l` -ne 0 ] then # Print Header after the entry detail record has been read if [ "$hdrFound" != "false" ] then batchCnt=`expr $batchCnt + 1 ` typeset -L94 hdr typeset -L6 batchCnt echo "$hdr$batchCnt" >> $destFile typeset -R0 hdr hdrFound="false" hdr="" fi if [ "$prevEntryCalc" != "false" ] then typeset -L599 value typeset -L6 batchCnt echo "$value$batchCnt" >> $destFile typeset -R0 value typeset -R0 batchcnt value="" fi line=`echo "$line"` value=`echo "$line"` prevEntryCalc="true" fi if [ `echo $line|grep "^$addendaRecInd" | wc -l` -ne 0 ] then typeset -L101 line len=`echo $line|wc -c` #echo "The Length of addenda record is "$len value="$value$line" typeset -R0 line fi done < $srcFile Last edited by senthil_is; 03-04-2008 at 09:40 PM.. Reason: adding some more tips |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|