Posted to tcl by mjanssen at Thu Oct 25 01:15:55 GMT 2007view pretty

set re {^$}
fconfigure stdout -encoding binary -translation binary -buffering full

proc filter {re argv} {
foreach file $argv {
        set line 0
        set f [open $file r]
        fconfigure $f -encoding binary -translation binary
        while {![eof $f]} {
                set buf [gets $f]
                if {[regexp -- $re $buf]} {puts $buf}
        }
        close $f
}
}
filter $re $argv