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

Find MILL in MSQ data

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

I have data that looks like

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  

I need to store all the data that ends with "MILL" or "-np-" and then need to put it into a new MSQ file

Any suggestions The language is TCL

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

Something like

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