TABLE OF CONTENTS


::pwtk::egrep_field

SYNOPSIS

proc ::pwtk::egrep_field {pattern file which_field {index ""}} {

PURPOSE

A "field-segmented" version of ::pwtk::egrep command. It returns only a specified field from the lines that matches the pattern.

ARGUMENTS

SOURCE

    set result ""

    pwtk::lineread line $file {
        if { [regexp $pattern $line] } {
            lappend result [lindex $line $which_field]
        }
    }

    if { $index != "" } {
        set result [lindex $result $index]
    }

    return $result
}