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
- Next message: Geoffrey Clements: "Re: Preventing multiple invocations of script from accessing the same file"
- Previous message: Simon J. Rowe: "Re: Preventing multiple invocations of script from accessing the same file"
- In reply to: Meghavvarnam: "Re: Read strings from one file and search for them in a directory containing htm files"
- Next in thread: Ed Morton: "Re: Read strings from one file and search for them in a directory containing htm files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Geoffrey Clements: "Re: Preventing multiple invocations of script from accessing the same file"
- Previous message: Simon J. Rowe: "Re: Preventing multiple invocations of script from accessing the same file"
- In reply to: Meghavvarnam: "Re: Read strings from one file and search for them in a directory containing htm files"
- Next in thread: Ed Morton: "Re: Read strings from one file and search for them in a directory containing htm files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|