#! /bin/bash
var = $(cat /proc/sys/kernel/hostname)
echo var
#! /bin/bash
var = $(cat /etc/hostname)
echo var
Reading from command and copy its output in bash variable.
#! /bin/bash
var = $(hostname -f) # return portion before dot
echo var