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: " ?

2

1 Answer 1

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

or a more human readable format:

$(hn=$(hostname); echo "Hostname: $hn")
Sign up to request clarification or add additional context in comments.

1 Comment

Good job for pointing out the preferred readability of command substitution with $(...) rather than backticks, `...`.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.