← Back to team overview

sslug-teknik team mailing list archive

Re: Storke langsomt bash script

 

On 31/05/2010, at 11.28, Martin Dupont Ahrentsen wrote:

> Hej i kloge folk bag keyboardet,

[kliip]

> ----------------start cut af script----------------
> 
> startno1=92080000001
> endno1=92081327500
> 
> startno2=92085000001
> endno2=92085135000
> 
> startno3=92085135000
> endno3=92085973000
> 
> cd ${masterdatadir}
> 
> for i in `cat t_pcl_ser`

systemkald af cat programmet

> do
>       testcustomerid=`echo $i | cut -d\| -f1`
>       teststartno=`echo $i | cut -d\| -f2`
>       testendno=`echo $i | cut -d\| -f3`
>       testactiveflag=`echo $i | cut -d\| -f4`
>       testprocflag001=`echo $i | cut -d\| -f5`
>       testprocflag002=`echo $i | cut -d\| -f6`
>       testprocflag003=`echo $i | cut -d\| -f7`
>       testprocflag004=`echo $i | cut -d\| -f8`
>       testcountrya2=`echo $i | cut -d\| -f9`
>       testzip=`echo $i | cut -d\| -f10`
>       testprocflag005=`echo $i | cut -d\| -f11`

2 systemkald pr. linie, både echo og cut.


>       if [ \( ${teststartno} -ge ${startno1} -a ${testendno} -le ${endno1} \) -o \( ${teststartno} -ge ${startno2} -a ${testendno} -le ${endno2} \) -o \( ${teststartno} -ge ${startno3} -a ${testendno} -le ${endno3} \) ]

stor sammenligning

>       then
>               echo

systemkald af echo programmet

> "${testcustomerid}|${teststartno}|${testendno}|${testactiveflag}|${testprocflag001}|Y|Y|${testprocflag004}|${testcountrya2}|${testzip}|${testprocflag005}|"  >> ${masterdatadir}/tmp/t_pcl_ser
>       else
>               echo  ${i} >> ${masterdatadir}/tmp/t_pcl_ser

også her.


>       fi
> done
> 
> ----------------end cut af script----------------
> 
> Er der en anden måde at skrive det på så hastigheden bliver sat i vejret eller skal det skrives i et andet sprog?

Måske kan det forbedres ved at sammenligne anderledes. Hvis man kan.

Men jeg tror at du kun vil få en forbedring af hastigheden hvis du skriver det i et hurtigere sprog. Bemærk dog at du jo skal igennem samtlige linier, så du er bundet af en O(n) begrænsning.



JonB



References