[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

how to reverse an IPv4



Hello list,

I wrote this script for reversing an IP:

#!/bin/bash

IP=$1

if [ -z $IP ];then
  echo "$0 IP"
  exit 1
fi

REVERSE=$(echo $IP|awk -F\. '{print $4.$3.$2.$1}')
echo $REVERSE


it won't work as the output below.

$ bin/rbl.sh 61.144.56.32
325614461


The "." was lost.

If I changed the awk line to:
REVERSE=$(echo $IP|awk -F\. '{print "$4.$3.$2.$1"}')


It becomes:

$ bin/rbl.sh 61.144.56.32
$4.$3.$2.$1



Can you help with this?
Thanks


Reply to: