Re: Read strings from one file and search for them in a directory containing htm files

From: Janis Papanagnou (Janis_Papanagnou_at_hotmail.com)
Date: 11/28/05


Date: Mon, 28 Nov 2005 11:16:42 +0100

Meghavvarnam wrote:
>
> What does the line - NR==FNR{strings[$0]++;next} do.

'NR==FNR' is a condition that is true for the very first file on your
argument list. The pattern is used, e.g. for two-pass computing...

   awk -f yourprog datafile datafile

or for initialization purpose...

   awk -f yourprog initdatafile datafile1 datafile2 ...

'strings[$0]++' increments a counter for each line pattern, i.e. when
a line is present in the file multiple times the counter 'strings' for
the key $0 (the whole line) has the value how often the line occurred.

'next' skips the next patter/action statements and continues with the
next data record and the first pattern in the program.

Janis



Relevant Pages

  • match string by re using some pattern
    ... I'm trying to match few strings using some pattern ... How i can check which word was it in line before replacing it by (. ...
    (comp.lang.perl.misc)
  • Re: a problem about sequence of numbers
    ... lazybear wrote: ... efficent solution,can anyone help me out, thanks! ... Try computing the first few terms. ... The pattern isn't hard to ...
    (sci.math)