On Fri, 2002-09-20 at 09:06, Drew Tomlinson wrote: > I'm running Postfix and have it configured to send 450 errors if the > IP address of a mail server fails reverse lookup as described at > http://www.muine.org/~hoang/postfix.html. As part of this config, I > have a "override" file that is checked first. When I initially > created the file, I sorted my entries based upon reported domain > names. I have now decided that I would prefer to have the entries > listed in IP address order. > > Although I could fix the file manually, I know there are tools in the > OS that will do this for me and I'd like to learn how to use them. I > am guessing that a command line using cat, sort, and sed or awk is > what I need but I haven't been able to figure this out. >
If it was just IP addresses, it'd be no problem. Keeping the comments there is a little trickier. But I guess if you KNOW the data will be in that format (comment, list of IPs blank separator) you may get off a little more lightly than arbitray text. I would suggest looking at Perl - unless you have a perverse desire to learn sed and awk and still be limited in what you can do. I find Perl does it all and more, plus TMTOWTDI (There's More Than One Way To Do It - the Perl motto). Assuming you go the Perl route, start by setting the record separator to a blank line, then read each comment/IP in - I think a hash of comment and IP array would work. Then you can sort the IPs for each record, or across the board or whatever you want to do. I'm not sure how you will handle sorting an IP between two other IPs in the same black, but that's easy enough whatever you decide to do. I'm giving a broad overview, rather than telling you exactly what to do for a couple of reasons. One is that you wish to learn, and you'll learn better by doing it yourself. And the other is that I would have to do this myself first, and why duplicate the effort when you're going to do it? ;-) Hope that helps. Drop me a line if you need more detailed info. regards, Duncan Anker To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-questions" in the body of the message