Last active
July 19, 2021 10:37
-
-
Save karlbunch/7613794 to your computer and use it in GitHub Desktop.
Quick way to convert integer ip4 ip address to dot notation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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