OT - fun with sed
Chris Mohler
cr33dog at gmail.com
Wed Jun 11 22:40:53 UTC 2008
Hi list,
I have a list of zip codes and lat/long values. However, not every
zip code has lat/long and I'm trying to wee those out with sed.
Here's a sample chunk of my file:
78850
29.334701 N, 99.335343 W
78851
78852
78860
78861
29.379516 N, 99.126653 W
78870
29.297821 N, 99.627546 W
78872
28.950547 N, 99.850324 W
78873
29.756509 N, 99.766654 W
78877
78879
29.628266 N, 99.738479 W
So 78850 has lat/long but 78851, 78852, and 78860 do not. Pseudo-sed:
sed -e 'substitue/<zip code and newline>+<zip code and newline>/\2/global'
Is this the right approach? I've tried a few variations on this
monstrosity with no luck:
sed -e ':a;N;$!ba;s/\([0-9][0-9][0-9][0-9][0-9]\n]\)+\([[0-9][0-9][0-9][0-9][0-9]\n\)/\2/g'
Thanks,
Chris
More information about the ubuntu-users
mailing list