For Programmers: Free Programming Magazines  


Home > Archive > AWK > March 2006 > Adding lines









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Adding lines
Salve Håkedal

2006-03-06, 6:55 pm

I kind of know how to fill up lines to a predefined length
by using lenght(string on line) and printf to add whitespace.

But now I also want to add lines to a predefined height.
Is there an easy to understand trick to do this with (g)awk?

AwkNewbie
Joel Reicher

2006-03-06, 6:55 pm

Salve Håkedal <ikkjespam.salve@fiolinmaker.no> writes:

> I kind of know how to fill up lines to a predefined length
> by using lenght(string on line) and printf to add whitespace.
>
> But now I also want to add lines to a predefined height.
> Is there an easy to understand trick to do this with (g)awk?


The builting variable NR will tell you how many records (lines) you've
read so far, and you can keep a count of how many you've printed.

Or is there something more tricky you want to do? You don't even need
NR, in fact, although it makes for a nice shortcut.

Cheers,

- Joel
Salve Håkedal

2006-03-07, 6:58 pm

On 2006-03-06, Joel Reicher <joel@panacea.null.org> wrote:
> Salve Håkedal <ikkjespam.salve@fiolinmaker.no> writes:
>
>
> The builting variable NR will tell you how many records (lines) you've
> read so far, and you can keep a count of how many you've printed.
>
> Or is there something more tricky you want to do? You don't even need
> NR, in fact, although it makes for a nice shortcut.
>
> Cheers,
>
> - Joel

That's easy, thank you.
Salve Håkedal

2006-03-07, 6:58 pm

On 2006-03-06, Joel Reicher <joel@panacea.null.org> wrote:
> Salve Håkedal <ikkjespam.salve@fiolinmaker.no> writes:
>
>
> The builting variable NR will tell you how many records (lines) you've
> read so far, and you can keep a count of how many you've printed.
>
> Or is there something more tricky you want to do? You don't even need
> NR, in fact, although it makes for a nice shortcut.
>
> Cheers,
>
> - Joel

That's easy, thank you.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com