[Techtalk] line by line in bash

Brenda Bell k15a-list-linuxchix at theotherbell.com
Sun Jun 8 16:55:29 EST 2003


Quoting Maria Blackmore <mariab at cats.meow.at>:

> 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.

Or convert the file so it's easier to find a line.  tr '\n' ':' will change
the newlines to colons... and cut -d: -f1 would return the first "line".

-- 
Brenda
http://opensource.theotherbell.com



More information about the Techtalk mailing list