Version 3 of grep

Updated 2003-07-18 16:38:24

grep is the name of a common utility on many Unix or unix like systems.

Folklore says that the name represents a command that developers in the old days used to issue within their editor or other similar program:

   g/re/p

which was a global {regular expression} print command.

Grep reads through one or more input streams (stdin or files), searching for a string of text which represents some for of a regular expression, and, depending on options provided, may produce the matching lines of input.


RS wrote this tiny, and feature-poor, emulation for use on PocketPC (but it should run elsewhere too):

 proc grep {re args} {
    set files [eval glob -types f $args]
    foreach file $files {
       set fp [open $file]
       while {[gets $fp line] >= 0} {
          if [regexp -- $re $line] {
             if {[llength $files] > 1} {puts -nonewline $file:}
             puts $line
           }
       }
       close $fp
    }
 }

see also a grep-like utility - A little file searcher with GUI


category application