sslug-teknik team mailing list archive
-
sslug-teknik team
-
Mailing list archive
-
Message #100414
Re: Storke langsomt bash script
2010/5/31 Martin Dupont Ahrentsen <martin@xxxxxxxxxxxx>:
> Er der en anden måde at skrive det på så hastigheden bliver sat i vejret
> eller skal det skrives i et andet sprog?
>
jag hade skrivit i tcl :
set startno1 92080000001
set endno1 92081327500
set startno2 92085000001
set endno2 92085135000
set startno3 92085135000
set endno3 92085973000
# antar att det är en miljövariabel ? cd ${masterdatadir}
# skall exporteras typ export masterdatadir=where/ever/it/is
set input_file_pointer [open [file join $::env(masterdatadir)
t_pcl_ser] {RDONLY}]
set output_file_pointer [open [file join $::env(masterdatadir) tmp
t_pcl_ser] {WRONLY CREAT}]
while {[gets $input_file_pointer Line] >= 0} {
set split_line [split $Line "|"]
set testcustomerid [lindex $split_line 0] ;# =`echo $i | cut -d\| -f1`
set teststartno [lindex $split_line 1] ;#=`echo $i | cut -d\| -f2`
set testendno [lindex $split_line 2] ;#=`echo $i | cut -d\| -f3`
set testactiveflag [lindex $split_line 3] ;#=`echo $i | cut -d\| -f4`
set testprocflag001 [lindex $split_line 4] ;#=`echo $i | cut -d\| -f5`
set testprocflag002 [lindex $split_line 5] ;#=`echo $i | cut -d\| -f6`
set testprocflag003 [lindex $split_line 6] ;#=`echo $i | cut -d\| -f7`
set testprocflag004 [lindex $split_line 7] ;#=`echo $i | cut -d\| -f8`
set testcountrya2 [lindex $split_line 8] ;#=`echo $i | cut -d\| -f9`
set testzip [lindex $split_line 9] ;#=`echo $i | cut -d\| -f10`
set testprocflag005 [lindex $split_line 10] ;#=`echo $i | cut -d\| -f11`
set combined "$testcustomerid|$teststartno|$testendno|$testactiveflag|$testprocflag001|Y|Y|$testprocflag004|$testcountrya2|$testzip|$testprocflag005|"
if { $teststartno >= $startno1 & $testendno <= $endno1 } {
puts $output_file_pointer $combined
} elseif {$teststartno >= $startno2 & $testendno <= $endno2 } {
puts $output_file_pointer $combined
} elseif {$teststartno >= $startno3 & $testendno <= $endno3 } {
puts $output_file_pointer $combined
} else {
puts $output_file_pointer $Line
}
}
close $input_file_pointer
close $output_file_pointer
#-----------------
spara ned till fil, tex myfilter.tcl och kör med
tclsh myfilter.tcl
--
/Björn
References