[nycbug-talk] sed Question
Peter Wright
pete at nomadlogic.org
Thu Mar 30 18:34:42 EST 2006
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Thu, Mar 30, 2006 at 05:52:56PM -0500, Kevin Reiter wrote:
>> All,
>>
>> I know there are a few scripting gurus on this list who might be able to
>> help me out with this..
>>
>> I'm trying to write a script that does the following:
>>
>> 1. Runs 'fastest_cvsup -c us' to find the fastest cvsup server
>> 2. Assigns the value of "server.txt" (which is the fastest server) to a
>> variable and then searches my "ports-sup" file for the existing server,
>> and replaces it with the new one.
>
> I did it this way.
>
>
> #!/bin/sh
> FASTEST=$(fastest_cvsup -q -c us)
> sudo csup -h $FASTEST /usr/share/examples/cvsup/current-supfile
>
>
>
> However, before that I used to do (which seems more in line with what
> you're doing, although still a bit different)
>
>
> fastest_cvsup -c us > fcvs.txt
> tail -3 fcvs.txt | head -1 | cut -d: -f2 > host
> rm fcvs.txt
> FASTEST=$(cat host)
> sudo csup -h $FASTEST /usr/share/examples/cvsup/current-supfile
>
> You could of course, modify it for ports. Rather than replacing the
> server, I'm just using -h.
>
I like that approach. you could even do a and not need an intermediate file:
$host = `fastest_cvsup -c us | grep 1st | awk '{print $3}'`
cvsup -h $host /my/sup/file
-pete
ps-> yes i'm finally of gmail...woo hoo! ;p
--
~~oO00Oo~~
Peter Wright
pete at nomadlogic.org
www.nomadlogic.org/~pete
310.869.9459
More information about the talk
mailing list