variable
Bash HOSTNAME — host name
Automatically assigned host name of the current host. It can be changed as a shell variable without renaming the system, and is not an authenticated machine identity. This example avoids disclosing the actual name. Run in a fresh private directory with HOME set to that directory and LC_ALL=C. Expected output (one item per line): name present.
Formal Syntax & Structure
bash syntaxbash
${HOSTNAME}Return Value
string
Current value of the variable; expansion does not independently return an exit status.
Working Example
Example Snippetbash
[[ -n $HOSTNAME ]] || exit 1printf 'name present\n'