Fairly easy in Tcl. I'm not sure how you'd go about doing it in a "standard" shell script like Ksh, Bash, etc.
Tcl is pretty good for this because all variables are both strings and "lists" (sorta like arrays).
#! /usr/bin/tclsh
# open the data file for reading.
set fid [open /path/to/matrix.data r]
# loop through all lines in the file.
while { ![eof $fid] } {
gets $fid row
# Row are: ID, X1, X2, Y1, Y2
# We don't care if the ID row is higer than
# .5, so don't check it.
set data [lrange $row 1 end]
#data = X!, X2, Y1, Y2.
# so foreach d $data will check the individual elements of the list.
foreach d $data {
if { $d >= 0.5 } {
set newdata $row
}
}
# if we have a match from above, then
# spit out the entire row.
if { $newdata != "" } {
puts stdout $newdata
set newdata ""
}
}
# close the file.
close $fid
Thank you folks so much! But it didn't work for me with both awk or Tcl. By the way, I wanted to filter absolute value. Second, I use Mac OS 10. Third The file is much bigger than the sample part.