Last active
October 16, 2019 09:15
-
-
Save jhamfler/c0599974b84218e4f23e07bb575f7ee7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# IPv4 is inside a String | |
echo "address is 127.0.0.1 ." | grep -Eo '((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' | |
# IPv4 string can only be an IPv4-address | |
echo "127.0.0.1" | grep -Eo '^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$' | |
# replace \n with " " | |
sed ':a;N;$!ba;s/\n/ /g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment