|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
awk and next
Hi, I am having trouble with awk. I need to read in the first line and only keep it if the next x number of lines doesnt contain 9999 in it. This example is a file I want to get rid of. Code:
start -73.38300 40.10000 1988 1 30 9 5566
1.00000 4.91100 9999.00000
5.30000 3.81100 9999.00000
10.50000 4.23100 9999.00000
15.80000 4.40000 9999.00000
21.10000 3.67500 9999.00000
26.40000 5.18800 9999.00000
31.60000 3.14600 9999.00000
39.00000 3.87500 9999.00000
39.10000 3.73300 9999.00000This is an example of things I would like to keep Code:
start -73.60000 40.26700 1988 1 30 6 5564
1.00000 3.68000 31.66500
5.00000 3.67000 31.66900
10.00000 3.68000 31.65000
15.00000 3.68000 31.64800
20.00000 3.68000 31.64700
21.00000 3.68000 31.64700
start -73.08300 39.86700 1988 1 30 14 5568
1.00000 6.10000 32.80200
5.00000 6.10000 32.80100
10.00000 6.10000 32.79200
15.00000 6.10000 32.78900
20.00000 6.10000 32.78900
25.00000 6.11000 32.79000
30.00000 6.10000 32.78900
35.00000 6.10000 32.78900
40.00000 6.10000 32.78900
45.00000 6.10000 32.78800
50.00000 6.11000 32.79000
55.00000 6.11000 32.79000
60.00000 6.11000 32.79300
63.00000 6.11000 32.79200The output should be the same as the input. I was trying to use NEXT but I cant seem to get it to work. I hope thats clear Thanks for any suggestions |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Not sure what you exactly want; you can try this though in case it brings the desired output; I pasted your examples together to one file and added some more of those ranges with 9999. Code:
grep -v 9999 infile| awk '/^s/ {l=$0; next} !/9999/ {print l; print; l="" }'| grep -v ^$ |
| Sponsored Links | ||
|
|