pattern matching over more lines

hi, i have a text file wich contains following informations:

1 Record 90 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-15 18:54:33)
1 YADM_20080101_A91645666_A91645666
4 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645666G001.jff
1 Record 91 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-15 18:55:36)
1 YADM_20080101_A91645690_A91645690
2 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645690G001.jff
1 Record 92 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-15 18:55:36)
1 YADM_20080101_A91645695_A91645695
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645695G001.jff
1 Record 93 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-16 16:13:13)
1 YADM_20080101_A91645701_A91645701
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645701G001.jff
3 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645701G002.jff
1 Record 94 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-15 18:55:36)
1 YADM_20080101_A91645705_A91645705
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645705G001.jff
1 Record 95 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-15 18:55:36)
1 YADM_20080101_A91645722_A91645722
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645722G001.jff
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645722G002.jff
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645722G003.jff
1 Record 96 in base GUJA_2008 (Created: 2008-01-14 19:00:38, Modified: 2008-01-15 18:55:36)
1 YADM_20080101_A91645756_A91645756
1 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645756G001.jff

Now i want to write a script which is searching between the lines Record...
If a *.jff line has a number, at the front of the line, which is greater than 1, then the line itself and the line after the "record.. line" for example, "YADM_20080101_A91645666_A91645666" should be printed.

The file should look like this after the pattern:

1 YADM_20080101_A91645666_A91645666
4 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645666G001.jff

1 YADM_20080101_A91645690_A91645690
2 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645690G001.jff

1 YADM_20080101_A91645701_A91645701
3 2008/01/15/ADM.ADM/20080101.ADM.ADM.A91645701G002.jff

is anyone able to help me?

This should do the job:

awk '
$2 ~ /^YADM/{s=$0} 
/jff$/ && $1 > 1{print s RS $0 RS}
' file

Regards

wow, i can't believe it! :smiley:
but i don't understand the complete awk command, please can you explain it to me so that i could do the job myselft the next time?

Sure!

$2 ~ /^YADM/{s=$0}

If the 2nd field begins with YADM copy the line to the variable s.

/jff$/ && $1 > 1{print s RS $0 RS}

If the current line ends with jff and the 1st field is greater then 1 print the variable s and the current line separated by record separators.

Regards