Warm tip: This article is reproduced from serverfault.com, please click

database-在MSQ数据中查找MILL

(database - Find MILL in MSQ data)

发布于 2020-12-07 06:36:21

我有看起来像的数据

121,736,52,0,5.295,0.000,70.000,3,1.0000,3,1  
122,736,52,0,5.295,0.000,70.000,3,1.0000,3,1  
123,736,52,0,5.295,0.000,70.000,3,1.0000,3,1  
124,736,52,1,5.295,1.000,70.200,3,1.0000,3,1  
124,736,52,OIND,70.200,27.641,-np-  
125,736,52,1,5.295,1.000,72.175,3,1.0000,3,1  
125,736,52,OIND,72.175,308.340,MILL    
129,736,52,1,5.295,1.000,70.525,3,1.0000,3,1  
129,736,52,OIND,70.525,76.211,MILL  

我需要存储所有以“ MILL”或“ -np-”结尾的数据,然后将其放入新的MSQ文件中

任何建议语言为TCL

Questioner
Alex Smith
Viewed
0
Shawn 2020-12-07 17:54:02

就像是

set in [open yourfile r]
set out [open newfile w]
while {[gets $in line] >= 0} {
    if {[regexp {(?:MILL|-np-)$} $line]} {
         puts $out $line
    }
}
close $in
close $out