Skip to content

Instantly share code, notes, and snippets.

@karlbunch
Last active July 19, 2021 10:37
Show Gist options
  • Save karlbunch/7613794 to your computer and use it in GitHub Desktop.
Save karlbunch/7613794 to your computer and use it in GitHub Desktop.
Quick way to convert integer ip4 ip address to dot notation
#!/bin/bash
#
# long2ip - Bash example to convert integer ip to long
#
# Example: long2ip 201691728
#
long2ip() {
local ip=$1
echo $((ip >> 24 & 255))"."$((ip >> 16 & 255))"."$((ip >> 8 & 255 ))"."$((ip & 255))
}
long2ip $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment