awk help
Jim Trigg
jtrigg at huiekin.org
Mon Apr 17 16:51:55 UTC 2017
On 2017-04-17 12:08, Andreas Perstinger wrote:
> On 2017-04-17 16:11, Ernie Luzar wrote:
>> When I first tested /^Address/ and /^ Hits/ produced no output. I
>> changed them to /Address/ and /Hits/ and this produced output. I
>> could not find any reference to the ^ sign, so I would like to know
>> what is it suppose to do?
>
> "^" inside a regular expression is an anchor and matches the beginning
> of the line. (See "man re_format" or e.g.
> http://www.regular-expressions.info/anchors.html ). In the example
> you've posted, the lines containing "Address" and "Hits" are indented
> which means there are spaces/tabs between the beginning of the line and
> these words. Thus the patterns don't match.
And I misread the original message and got the wrong number of indenting
spaces in my suggested patterns.
Just to be pedantic, in awk the anchor is the beginning of the *record*,
not the *line*.
--
Jim Trigg
More information about the freebsd-questions
mailing list