TABLE OF CONTENTS


::pwtk::egrep

SYNOPSIS

proc ::pwtk::egrep {pattern file {index ""}} {

PURPOSE

A simple egrep command (but without options). Lines that matches the pattern are returned as the Tcl list. If index argument is specified only the index-th match (list element) is returned.

ARGUMENTS

RETURN VALUE

SOURCE

    set result ""

    pwtk::lineread line $file {
        if { [regexp $pattern $line] } {
            lappend result $line 
        }
    }
    
    if { $index != "" } {
        set result [lindex $result $index]
    }
    
    return $result
}