Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!ub!acsu.buffalo.edu From: haozhou@acsu.buffalo.edu (Hao Zhou) Newsgroups: comp.unix.shell Subject: awk question Message-ID: <62322@eerie.acsu.Buffalo.EDU> Date: 28 Feb 91 02:57:36 GMT Sender: news@acsu.Buffalo.EDU Organization: SUNY Buffalo Lines: 21 Nntp-Posting-Host: autarch.acsu.buffalo.edu I am using awk to print some selected lines from a text file. What I want to to is to hold off the current line until next line comes in and a certain condition is satisfied before printing both lines. So I need to store the current line in some variable as follows: prev = 'initialization' awk '{{if (condition) \ printf("%s \n %s \n", $prev, $0)} {prev=$0}}' However the variable prev doesn't store the previous line. Instead the printf prints out twice the current line. What am I doing wrong? Thanks for any help on this problem. Hao -- Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET UUCP: rutgers!ub!haozhou