Bash output inside the terminal : command not found

bash

Hi everyone,

I wanted to ask a question about the bash output inside the terminal

The following procedure generates a command not found :

TEST:~ SniperDMC$
TEST:~ SniperDMC$ $HOSTNAME
-bash: TEST.local: command not found

How to avoid this and beautify the output ?

Best regards

SniperDMC

Best Answer

Well, $HOSTNAME is a variable, and if you just write it on a single line and press enter, bash will simply replace it with the respective value, i.e. "TEST.local". Since "TEST.local" is not a valid command, bash will complain.

If you want to print the value of any bash variable, you should use echo, i.e. echo $HOSTNAME.

For a quick bash scripting tutorial regarding variables, see here for example.