[Techtalk] line by line in bash
Maria Blackmore
mariab at cats.meow.at
Sun Jun 8 20:49:23 EST 2003
Hi :)
On Sun, 8 Jun 2003, Hamster wrote:
> In essence it boils down to the ability to process a file one line at a
> time.
Why not use "wc -l" to find out how many lines there are in the file, and
then use that to form a loop using a counter and "while" or "until"
You can then use a combination of head and tail with the counter variable
to extract a single line from the file at a time in the loop, and iterate
through it.
To extract a single line from a file, say, the 5th line, you would use the
following line
head -5 somefile | tail -1
There you go, you can now iterate a line at a time through the file :)
Maria
More information about the Techtalk
mailing list