From owner-freebsd-isp Wed Dec 20 23:39:22 2000 From owner-freebsd-isp@FreeBSD.ORG Wed Dec 20 23:39:17 2000 Return-Path: Delivered-To: freebsd-isp@freebsd.org Received: from dt051n37.san.rr.com (dt051n37.san.rr.com [204.210.32.55]) by hub.freebsd.org (Postfix) with ESMTP id 3B35937B400 for ; Wed, 20 Dec 2000 23:39:17 -0800 (PST) Received: from gorean.org (Studded@master [10.0.0.2]) by dt051n37.san.rr.com (8.9.3/8.9.3) with ESMTP id XAA71573; Wed, 20 Dec 2000 23:38:56 -0800 (PST) (envelope-from DougB@gorean.org) Sender: doug@dt051n37.san.rr.com Message-ID: <3A41B390.2250BB12@gorean.org> Date: Wed, 20 Dec 2000 23:38:56 -0800 From: Doug Barton Organization: Triborough Bridge & Tunnel Authority X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.12 i386) X-Accept-Language: en MIME-Version: 1.0 To: Alex Blagoveschensky Cc: Dave Wilson , freebsd-isp@FreeBSD.ORG Subject: Re: Off topic - shell skills References: <3A3DDE15.D8E377A9@belpak.by> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-isp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org For future reference, this doesn't belong on -isp. It's really -questions material. Alex Blagoveschensky wrote: > Try this. But what will you do with Serial in SOA ? ;-) Easy, see below. > #!/bin/sh > for i in * > do > echo $i > cat $i | sed 's/10\.1\.1\.58/10\.0\.0\.1/' >$$ This is the prototypical "useless use of cat." You can call sed with the file as an argument. Also, naming a temp file by the pid can lead to confusion later if your process gets interrupted. > mv $$ $i Dangerous... what happens if your sed doesn't complete successfully? > done There are probably some flaws with the script below, but I use it all the time. In fact, I don't even bother to put it in a file anymore, I can type it out faster. :) Let's assume that you have your serial numbers on a line in the zone file that looks like this: 2000120101 ; Serial #!/bin/sh for file in *; do echo $file sed -e 's/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*Serial/2000122101 ; Serial/' \ -e 's/10\.1\.1\.58/10\.0\.0\.1/' > $file.sed && mv $file.sed $file done Obviously the pattern matching for the serial number itself could be simpler if you are confident you don't have any unusual instances... Doug -- "The most difficult thing in the world is to know how to do a thing and to watch someone else do it wrong without comment." -- Theodore H. White Do YOU Yahoo!? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isp" in the body of the message