if {($ctr < 2) || ([string index [lindex [split $line "|"] 3] 0])} {puts $outfile $line}
set frl_data [read $frl 1000]
while { [gets $newFile msg] >= 0 } { # do your work on msg here # gets returns -1 when it hits end of file # if you only want to read a certain number of lines, set a counter and break when you've read your quota}
set lineNum 0set newFile [open vrl_adt.txt a]foreach msg $msgList { if { $lineNum >= 200 } { # your description was a little ambiguous, but I understood that you only want to read the first two lines of the file. # >> if that's not the case, you can remove this "if" # we've read lines one and two - break out of the foreach loop break } else { set splitMsg [split $msg |] if { [llength $splitMsg] == 4 } { # there are four elements in splitMsg list switch -exact [string index [lindex $splitMsg 0] 0] { P - 8 { # the first character of the first element is either 8 or P if { [string index [lindex $splitMsg 3] 0] eq "3" } { # the first character of the value in the fourth column is 3 # >> This is your match # write the four elements of splitMsg to your output file - separated by "|" # if you need to do any manipulation of the values, do it here prior to writing them to the file puts $newFile [join $splitMsg |] } } default { # not 8 or P } } } } incr lineNum}close $newFile
Originally posted by Mark Thompson