I want to use a command to be printed on the same line as the string. for example, i want to print something like:
hostname: cpu1
but when i use the command like this it doesnt work
echo 'hostname:' hostname
CodePudding user response:
This is what you should do:
echo "hostname: `hostname`"
Words enclosed in backticks are read by the command line as commands even when they are inside a string, like in this case.
Have a great day! :)
CodePudding user response:
You need to use $()
to evaluate:
echo 'hostname:' $(hostname)