Created
July 31, 2017 18:21
-
-
Save jcppkkk/7741f2fedfd718fbdf6b96e8329678e2 to your computer and use it in GitHub Desktop.
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 | |
old=`hostname` | |
new="$1" | |
read -p "Change hostname from \"$old\" to \"$new\"? " -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
sudo true | |
set -v | |
sudo hostnamectl set-hostname $new | |
sudo sed -i"" "s#$old#$new#" /etc/hosts | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment