#!/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
时间: 2024-10-06 12:57:01