awk question

Hao Zhou haozhou at acsu.buffalo.edu
Thu Feb 28 13:57:36 AEST 1991


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 at acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu at UBVM.BITNET
UUCP: rutgers!ub!haozhou



More information about the Comp.unix.shell mailing list