View Single Post
Posts: 2,802 | Thanked: 4,491 times | Joined on Nov 2007
#30
Originally Posted by danramos View Post
One correction... the g in grep stands for 'globally match'...
It does, but strictly speaking isn't - g/re/p comes straight from ed(1)[1], and ed's g command accepts an address range (even though it defaults to the entire file). This goes back even to the oldest (V7) version I could find:

Code:
       (1,$)g/regular expression/command list
            In the global command, the first step is to mark every line  which
            matches  the  given regular expression.  Then for every such line,
            the given command list is executed with `.' initially set to  that
            line.   A single command or the first of multiple commands appears
            on the same line with the global command.  All lines of  a  multi-
            line  list except the last line must be ended with `\'.  A, i, and
            c commands and associated input are permitted; the `.' terminating
            input  mode  may be omitted if it would be on the last line of the
            command list.  The commands g and v are not permitted in the  com‐
            mand list.

[1] "Ed is the standard text editor."