Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Programming in Linux _ Reading two lines down???

Posted by: Blackhat Dec 29 2008, 10:10 AM

Hello,

I'm trying to write a gawk file that will do the following:


Here's some sample input:


3000 1 40 2 2 2 0
0.00000E+00 0.00000E+00 0.50500E+00 0.89521E+00 -0.44468E+00 -0.29444E-01 0.30000E-01 0.10000E+01 0.00000E+00
2012 2 1.2 91 2 1 1 0
0.15202E+00 -0.75511E-01 0.50000E+00 0.89521E+00 -0.44468E+00 -0.29444E-01 0.30000E-01 0.10000E+01 0.56643E-03
4000 3 1.1 1 2 2 2 0
0.22390E+00 -0.11122E+00 0.49764E+00 0.89521E+00 -0.44468E+00 -0.29444E-01 0.30000E-01 0.10000E+01 0.83427E-03
4000 3 3000 -1 2 2 2 1
0.42874E+01 -0.21297E+01 0.36398E+00 -0.86774E+00 -0.49603E+00 -0.31255E-01 0.27344E-01 0.10000E+01 0.15976E-01
2012 3 3000 -1 2 2 2 2
0.53149E+00 -0.42768E+01 0.22869E+00 -0.30822E+00 -0.10727E+00 -0.94525E+00 0.26250E-01 0.10000E+01 0.30414E-01
2012 3 3000 -3 2 2 2 3
0.26409E+00 -0.43698E+01 -0.59136E+00 -0.30822E+00 -0.10727E+00 -0.94525E+00 0.26250E-01 0.10000E+01 0.40525E+00

I'd like to do the following:

if ($1 = "2012" && (2 lines down, not sure how to write this) != 2012)
print "Stuff"

so that in this example "Stuff" Would be printed only once and not when 2012 is followed immediately by 2012 again two lines down.


Any help on this would be greatly appreciated!

Thanks,
Blackhat

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)