Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uwvax!uwmacc!jwp From: jwp@uwmacc.UUCP (Jeffrey W Percival) Newsgroups: comp.unix.questions Subject: 2.8BSD awk question Message-ID: <586@uwmacc.UUCP> Date: Wed, 26-Nov-86 14:44:22 EST Article-I.D.: uwmacc.586 Posted: Wed Nov 26 14:44:22 1986 Date-Received: Wed, 26-Nov-86 20:42:49 EST Organization: UWisconsin-Madison Academic Comp Center Lines: 41 Keywords: awk 2.8bsd strings 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