TABLE OF CONTENTS
::pwtk::egrep
SYNOPSIS
proc ::pwtk::egrep {pattern file {index ""}} {
PURPOSE
A simple egrep command (but without options). Various lines that matches the pattern are returned in the list. If index argument is specified only the index-th match (list element) is returned.
ARGUMENTS
- pattern -- pattern to grep for [pattern matching is that of Tcl's "regexp" command]
- file -- file to grep
- index -- [optional] which match to return; its meaning/syntax is the same as for Tcl's lindex command; 0 = first match; end = last match
SOURCE
set result "" pwtk::lineread line $file { if { [regexp $pattern $line] } { lappend result $line } } if { $index != "" } { set result [lindex $result $index] } return $result }