0
     `hn = 'hostname'
      echo "Hostname: $hn"`

This is what I did for the kernel version as well, but this is giving me a two line output with the hostname on top and then "Hostname:" below. So how do I get the output to be "Hostname: " ?

Tess
  • 19
  • 2
  • 2
    `hn=$(hostname)` bash does NOT allow spaces around `'='` You can just `echo "Hostname: $(hostname)"` – David C. Rankin Sep 03 '20 at 01:27
  • Does this answer your question? [Command not found error in Bash variable assignment](https://stackoverflow.com/questions/2268104/command-not-found-error-in-bash-variable-assignment) – David C. Rankin Sep 03 '20 at 01:30

1 Answers1

1
$(hn=`hostname`; echo "Hostname: $hn")

or a more human readable format:

$(hn=$(hostname); echo "Hostname: $hn")
ZYX Rhythm
  • 73
  • 7
  • 1
    Good job for pointing out the preferred readability of *command substitution* with `$(...)` rather than backticks, `\`...\``. – David C. Rankin Sep 03 '20 at 08:23