[Gllug] hex IP addresses in /proc

Tethys sta296 at astradyne.co.uk
Tue Feb 14 17:17:24 UTC 2006


Julian Somers writes:

>Does anyone know the method to convert the strange hexadecimal IP  
>addresses in /proc (I'm concerned with /proc/net/ip_mr_cache, but  
>they are there in /proc/net/tcp as well) into good old IP addresses?

Just convert them to decimal and swap endianness:

	hexip=0201A8C0
	decip=
	sep=
	for i in 6 4 2 0
	do
		[ $i -eq 6 ] || sep=.
		decip="$decip$sep$((16#${hexip:$i:2}))"
	done

	echo $decip

Tet
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list