Last active
June 7, 2016 18:04
-
-
Save jhyland87/66ae0d7ce375c5e77743e69cf900f43a to your computer and use it in GitHub Desktop.
Getting the local IP, and mod the 2nd octet
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
#!/bin/bash | |
# From: http://unix.stackexchange.com/a/287364/157820 | |
nmcli con show eno16777984 | awk -F"/|[[:space:]]+" ' | |
/^ipv4.address/ { | |
if ($2 ~ /^10\.10/) { | |
sub(/10\.10/,"10.20",$2); | |
} else if ($2 ~ /^10\.20/) { | |
sub(/10\.20/,"10.10",$2); | |
}; | |
print $2; | |
};' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment