Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Dec 2000 23:38:56 -0800
From:      Doug Barton <DougB@gorean.org>
To:        Alex Blagoveschensky <alex@belpak.by>
Cc:        Dave Wilson <davew@sai.co.za>, freebsd-isp@FreeBSD.ORG
Subject:   Re: Off topic - shell skills
Message-ID:  <3A41B390.2250BB12@gorean.org>
References:  <NEBBJFIIGKGLPEBIJACLKEIJCJAA.davew@sai.co.za> <3A3DDE15.D8E377A9@belpak.by>

next in thread | previous in thread | raw e-mail | index | archive | help
	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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A41B390.2250BB12>