On my Fedora 19 system, I am able to change the system hostname with hostnamectl. This allows me to set several things, such as the static (normal) hostname, as well as a "pretty" hostname.
Is there a simple command that retrieves the pretty hostname, from a bash prompt?
hostname returns the static hostname, and the man page shows no options to recover the pretty one.
awk -F= '/PRETTY/ {gsub(/"/,"");print $2}' /etc/os-releaseis simpler... – jasonwryan Aug 28 '15 at 09:43hostnamectl set-hostname --pretty '"MyPretty\\Name"',awk -F= '/PRETTY/ {gsub(/"/,"");print $2}' /etc/machine-info. The result is wrong. – Evgeny Aug 28 '15 at 10:14'"MyPretty\\Name"'as a pretty name? – jasonwryan Aug 28 '15 at 10:16sudo hostnamectl --pretty set-hostname "Lennart's Laptop"(example from the manpage) on Fedora 19.awk -F= '/PRETTY/ {gsub(/"/,"");print $2}'prints wrong resultLennart\'s Laptop. – Evgeny Aug 28 '15 at 10:26awk ... | sed ...too. thesed-only solution:sed 's/^[^=]*=//; s/^"//; s/"$//; s/\\\(.\)/\1/g' /etc/machine-info– Evgeny Aug 28 '15 at 12:43awkandsedare poor ideas for this type of configuration file. – JdeBP Jul 11 '18 at 20:45