Add ip2dec. - various - Various utilities developed at bitreich. HTML git clone git://bitreich.org/various/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/various/ DIR Log DIR Files DIR Refs DIR Tags --- DIR commit 99fee3542240698d2547ac178e4d9fb40cdc54d1 DIR parent c3f3b526c18fbeaf53985f3a5c6d11211b3fb1f7 HTML Author: Christoph Lohmann <20h@r-36.net> Date: Wed, 25 Aug 2021 15:59:14 +0200 Add ip2dec. Thanks IanJ! Diffstat: A ip2dec | 16 ++++++++++++++++ 1 file changed, 16 insertions(+), 0 deletions(-) --- DIR diff --git a/ip2dec b/ip2dec @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Convert IPv4 to decimal IPv4. +# + +if [ $# -lt 1 ]; +then + printf "usage: %s ipv4addr\n" "$(basename "$0")" >&2 + exit 1 +fi + +ipv4addr="$1" + +printf "%s\n" "${ipv4addr}" \ + | awk -F "." '{ printf "%d\n", (16777216*$1)+(65536*$2)+(256*$3)+$4 }' +