[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-isp
Subject: Re: Off topic - shell skills
From: Doug Barton <DougB () gorean ! org>
Date: 2000-12-21 7:38:56
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic