#!/bin/bash read -p "Enter the new hostname:" newname oldname=$(cat /etc/sysconfig/network | awk -F "=" ‘{print $2}‘ | sed -n 2p) echo $oldname $newname sed -i "s/${oldname}/${newname}/g" /etc/hosts sed -i "s/${oldname}/${newname}/g" /etc/sysconfig/network
原文地址:http://xoyabc.blog.51cto.com/7401264/1657693