backticks in rc.conf
Giorgos Keramidas
keramida at freebsd.org
Tue Jul 21 11:46:38 UTC 2009
On Tue, 21 Jul 2009 12:24:09 +0100, chris scott <kraduk at googlemail.com> wrote:
>
> a=`echo $ifconfig_bge0 | /usr/bin/awk '{ for ( i=1 ; i <= NF; i++) { if ( $i
> ~ /[iI][nN][eE][tT]/ ) { sub(/\/.*/,"", $(i+1)); print $(i+1) } } }'`
> rsyncd_flags="--config=/etc/rsyncd.conf --address=$a"
This is far too complex for my taste. If you are certain that you will
have all the tools around (/usr /usr/local and so on), then it may be
simpler to use something like:
addr=$( ifconfig lagg0 | perl -ne 'print "$1\n" if (m/^.*inet\s+(\S+)\s.*$/);' )
This seems to work without all the looping/sub in awk:
$ ifconfig lagg0 | perl -ne 'print "$1\n" if (m/^.*inet\s+(\S+)\s.*$/);'
192.168.1.3
More information about the freebsd-questions
mailing list