[Gllug] "ip" command

Russell Howe rhowe at siksai.co.uk
Sun Feb 5 23:55:02 UTC 2006


On Sat, Feb 04, 2006 at 11:48:35PM +0000, Nix wrote:
> > netmask_to_cidr() {
> > 	echo "$1"| (
> > 		IFS=.
> > 		read NM1 NM2 NM3 NM4
> > 
> > 		NMDEC="$(((NM1 << 24) + (NM2 << 16) + (NM3 << 8) + NM4 ))"
> > 
> > 		if [ "$NMDEC" -gt $((0xffffffff)) -o "$NMDEC" -lt 0 ]; then
> 
> Pedant: if you have functions and $(()), you certainly have [[ ]] as
> well.

Hm, neat. Didn't know about [[ ]]. What I'd really like to do, however,
is avoid the subshell, but I couldn't see a way to do it nicely.

-- 
Russell Howe       | Why be just another cog in the machine,
rhowe at siksai.co.uk | when you can be the spanner in the works?
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list