jwp@uwmacc.UUCP (Jeffrey W Percival) (11/26/86)
I have a text file of this form: header 1 ... 2 ... 3 ... header 4 ... 5 ... 6 ... and so on... the numbered lines have other information on them, and the same header occurs every Nth line. I wanted to change the frequency with which the header appears (every Mth line, say) so I have this awk script: { if ($1 == "PKT#") { header = "$0" next } else { if ($1 % 50 == 0) { print "" print $header } print $0 } } See, when I come across a header, I just want to stash it away. After every 50th line, I want to put that header out with a form feed. The problem is that the string variable "header" gets assigned every line. Instead of being a storage place for the header, it always contains the current value of $0. So instead of getting, for example, a form feed and a header and then line 50, I get a form feed and 2 copies of line 50. Is this an awk bug? -- Jeff Percival ...!uwvax!uwmacc!sal70!jwp or ...!uwmacc!jwp