I want to search for the "Remarks on" and print that line.
test 1 - if the next line (line 2) has a record number = 1, then I want to search again for "Remarks on"
test 2 - if next line (line 2) has $2 == "PD" then I want to search again for "Remarks on"
test 3 - if next line (line 2) has NR >1 then I want to print that line
go to next line (line 3)
repeat for test 1 ,2 and 3
-------here is the awk script - not complete
awk '
/Remarks on/ { # find phrase Remarks on
print $0 # print line
next #go to next line
}
# test 1
$2 == "PD" # if $2 = "PD" go to next search /Remarks on/
# test 2
NR = 1 # if nunber of records = 1 go to next search /Remarks on
# test 3
NR > 1 # if numnber of recors > 1 print line
{ print $0 #
next # if last (test 3) is true then go to next line
# test for 1 ,2 and 3
}
' example.txt > t2.txt
---- here is input
49035063810000 Remarks on PT Test 001 FRAC OIL WAS GELLED-FLUSH W/UNGELLED OIL ISIP 5900, SIP /15
49035063810000 MIN/ 5800
49035063810000 PD #002
49035063810000 Remarks on PT Test 002 FLUSHED W/CLEAR DIESEL OIL, ISIP 5700, SIP /15 MIN/ 5400
49035063810000 PD #003
49035063810000 Remarks on PT Test 003 FLOWED WELL 32 1/2 HRS-REC LO, SOME WTR & COND, GAS DECR TO
49035063810000 887 BY END OF TEST, STABALIZED AT 768 MCFD
4903506381000
49035063810000 PD #004
49035063810000 Remarks on PT Test 004 FRACT W/GEL DIESEL-FLUSHED W/9660 GALS CLEAR DIESEL ISIP
49035063810000 5200 SIP /15 MINS/ 5000 FLOWED 1020 MCFD DECR TO 362 MCFD
49035063810000 W/FRAC FLUID & SMALL AMT OF WTR CLEANED OUT PKR TO PB
49035063810000 10038
49035063810000 PD #005
49035063810000 Remarks on PT Test 005 GAUGES NOT STABALIZED-FLOWED 100 MCFD-1540 MCFD
49035063810000 PD #006
49035201240000 Remarks on IP Test 001 SIGW-IP NOT AVAILABLE
49035201240000
49035201240000 PD #001
49035205830000 Remarks on PT Test 001 FRAC W/125000# 40/60 SD & 175000# 20/40 SD
49035205830000
49035205830000 DST # 001
49035205830000 Show: S Formation: ROCK SPRINGS
49035205890000 Average Injection Rate:
49035206200000
49035206200000 PD #001
49035206200000 Remarks on PT Test 001 GAUGE NOT RPTD
---- this is what I want it to look like
49035063810000 Remarks on PT Test 001 FRAC OIL WAS GELLED-FLUSH W/UNGELLED OIL ISIP 5900, SIP /15
49035063810000 MIN/ 5800
49035063810000 Remarks on PT Test 002 FLUSHED W/CLEAR DIESEL OIL, ISIP 5700, SIP /15 MIN/ 5400
49035063810000 Remarks on PT Test 003 FLOWED WELL 32 1/2 HRS-REC LO, SOME WTR & COND, GAS DECR TO
49035063810000 887 BY END OF TEST, STABALIZED AT 768 MCFD
49035063810000 Remarks on PT Test 004 FRACT W/GEL DIESEL-FLUSHED W/9660 GALS CLEAR DIESEL ISIP
49035063810000 5200 SIP /15 MINS/ 5000 FLOWED 1020 MCFD DECR TO 362 MCFD
49035063810000 W/FRAC FLUID & SMALL AMT OF WTR CLEANED OUT PKR TO PB
49035063810000 10038
49035063810000 Remarks on PT Test 005 GAUGES NOT STABALIZED-FLOWED 100 MCFD-1540 MCFD
49035201240000 Remarks on IP Test 001 SIGW-IP NOT AVAILABLE
49035205830000 Remarks on PT Test 001 FRAC W/125000# 40/60 SD & 175000# 20/40 SD
49035206200000 Remarks on PT Test 001 GAUGE NOT RPTD
test 1 - if the next line (line 2) has a record number = 1, then I want to search again for "Remarks on"
test 2 - if next line (line 2) has $2 == "PD" then I want to search again for "Remarks on"
test 3 - if next line (line 2) has NR >1 then I want to print that line
go to next line (line 3)
repeat for test 1 ,2 and 3
-------here is the awk script - not complete
awk '
/Remarks on/ { # find phrase Remarks on
print $0 # print line
next #go to next line
}
# test 1
$2 == "PD" # if $2 = "PD" go to next search /Remarks on/
# test 2
NR = 1 # if nunber of records = 1 go to next search /Remarks on
# test 3
NR > 1 # if numnber of recors > 1 print line
{ print $0 #
next # if last (test 3) is true then go to next line
# test for 1 ,2 and 3
}
' example.txt > t2.txt
---- here is input
49035063810000 Remarks on PT Test 001 FRAC OIL WAS GELLED-FLUSH W/UNGELLED OIL ISIP 5900, SIP /15
49035063810000 MIN/ 5800
49035063810000 PD #002
49035063810000 Remarks on PT Test 002 FLUSHED W/CLEAR DIESEL OIL, ISIP 5700, SIP /15 MIN/ 5400
49035063810000 PD #003
49035063810000 Remarks on PT Test 003 FLOWED WELL 32 1/2 HRS-REC LO, SOME WTR & COND, GAS DECR TO
49035063810000 887 BY END OF TEST, STABALIZED AT 768 MCFD
4903506381000
49035063810000 PD #004
49035063810000 Remarks on PT Test 004 FRACT W/GEL DIESEL-FLUSHED W/9660 GALS CLEAR DIESEL ISIP
49035063810000 5200 SIP /15 MINS/ 5000 FLOWED 1020 MCFD DECR TO 362 MCFD
49035063810000 W/FRAC FLUID & SMALL AMT OF WTR CLEANED OUT PKR TO PB
49035063810000 10038
49035063810000 PD #005
49035063810000 Remarks on PT Test 005 GAUGES NOT STABALIZED-FLOWED 100 MCFD-1540 MCFD
49035063810000 PD #006
49035201240000 Remarks on IP Test 001 SIGW-IP NOT AVAILABLE
49035201240000
49035201240000 PD #001
49035205830000 Remarks on PT Test 001 FRAC W/125000# 40/60 SD & 175000# 20/40 SD
49035205830000
49035205830000 DST # 001
49035205830000 Show: S Formation: ROCK SPRINGS
49035205890000 Average Injection Rate:
49035206200000
49035206200000 PD #001
49035206200000 Remarks on PT Test 001 GAUGE NOT RPTD
---- this is what I want it to look like
49035063810000 Remarks on PT Test 001 FRAC OIL WAS GELLED-FLUSH W/UNGELLED OIL ISIP 5900, SIP /15
49035063810000 MIN/ 5800
49035063810000 Remarks on PT Test 002 FLUSHED W/CLEAR DIESEL OIL, ISIP 5700, SIP /15 MIN/ 5400
49035063810000 Remarks on PT Test 003 FLOWED WELL 32 1/2 HRS-REC LO, SOME WTR & COND, GAS DECR TO
49035063810000 887 BY END OF TEST, STABALIZED AT 768 MCFD
49035063810000 Remarks on PT Test 004 FRACT W/GEL DIESEL-FLUSHED W/9660 GALS CLEAR DIESEL ISIP
49035063810000 5200 SIP /15 MINS/ 5000 FLOWED 1020 MCFD DECR TO 362 MCFD
49035063810000 W/FRAC FLUID & SMALL AMT OF WTR CLEANED OUT PKR TO PB
49035063810000 10038
49035063810000 Remarks on PT Test 005 GAUGES NOT STABALIZED-FLOWED 100 MCFD-1540 MCFD
49035201240000 Remarks on IP Test 001 SIGW-IP NOT AVAILABLE
49035205830000 Remarks on PT Test 001 FRAC W/125000# 40/60 SD & 175000# 20/40 SD
49035206200000 Remarks on PT Test 001 GAUGE NOT RPTD