Re: read input from beginning at eof?
- From: Ted Davis <tdavis@xxxxxxx>
- Date: Tue, 16 Jun 2009 15:21:08 -0500
On Tue, 16 Jun 2009 08:36:38 -0700, sws_chen wrote:
Hello,
I am new at awk (and programming in general) and would greatly appreciate
your help. I am writing a code that needs to read through an input file
49 times. Is there a way so that once the program reads to the eof of the
input, it will start reading again from the beginning of the file? Or
maybe once it reaches the eof it could set could set current line to a
previous line 'x' lines above? I eagerly await an answer, thank you.
Steven
Unless the file is *huge*, it doesn't need to be read more thna once: read
it into and array and then read the array as many times as needed.
{
Array[NR] = $0
}
END{
for( x = 1; x <= 49; x++ ) {
for( y = 1; y <= NR; y++ ) do something with Array[ y ] and x
}
}
--
T.E.D. (tdavis@xxxxxxx)
.
- References:
- read input from beginning at eof?
- From: sws_chen
- read input from beginning at eof?
- Prev by Date: Re: read input from beginning at eof?
- Next by Date: Re: read input from beginning at eof?
- Previous by thread: Re: read input from beginning at eof?
- Next by thread: Re: read input from beginning at eof?
- Index(es):
Relevant Pages
|