[nycbug-talk] sed Question

Jan Schaumann jschauma at netmeister.org
Thu Mar 30 18:39:32 EST 2006


Kevin Reiter <tux at penguinnetwerx.net> wrote:
 
> #!/bin/sh
> 
> echo ""
> echo "Finding the fastest cvsup server."
> echo ""
> fastest_cvsup -c us | grep 1st | cut -d : -f 2 > server.txt
> sed 's/^[ \t]*//' server.txt > fast.txt
> fastest=`cat fast.txt`

You can do that without any temporary files (and one pipe less):

fastest=`fastest_cvsup -c us | awk '/1st/ {print $3;}'`
sed -e "s/host=cvsup.*FreeBSD\.org/host=$fastest/" ports-sup
      ^^^

Use regular quotes (") instead of ', otherwise the variable '$fastest'
won't be expanded.

-Jan

-- 
"You just come along with me and have a good time. The Galaxy's a
fun place. You'll need to have this fish in your ear."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
URL: <http://lists.nycbug.org/pipermail/talk/attachments/20060330/bfb7317b/attachment.bin>


More information about the talk mailing list