Maybe we can use the following regex instead, 'awk '$1 ~ /^127|localhost/ {print $0}'' is used to fix 'ff02::1 ip6-allnodes' case, and add 'g' option to modifity all hostname.
$ hostname=ubuntu $ echo '127.0.1.1 ubuntu.me.com ubuntu' |awk '$1 ~ /^127|localhost/ {print $0}' |sed "s/\s*\(${hostname}\)\(\s*\)/\tnewnode/g" 127.0.1.1 newnode.me.com newnode Addition, also need to remove "f ! echo "$RET" | grep -q 'ubuntu';" as Peter Wu said above -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1452202 Title: ubuntu preseed install fails to set a hostname To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/debian-installer/+bug/1452202/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs