I am trying to print a output with specific format, where output is in a enclosed box. I am using "|" and "-" for creating it. The output I print in between the "|" are variables with Different number of characters. This is messing my format.
I have tried the below code
nodename=$(hostname)
cpu=$(cat /proc/cpuinfo | awk '/^processor/{print $3}' | wc -l)
echo " ------------------------------------------------------------------"
echo "| |"
echo "| This is Bash Scripting |"
echo "| |"
echo "| 1 - This Machine Name is $nodename |"
echo "| 2 - This Machine has $cpu CPU's |"
echo "| |"
echo " -------------------------------------------------------------------"
actual Result
" ------------------------------------------------------------------"
"| |"
"| This is Bash Scripting |"
"| |"
"| 1 - This Machine Name is test |"
"| 2 - This Machine has 8 CPU's |"
"| |"
" -------------------------------------------------------------------"
Expected result
" ------------------------------------------------------------------"
"| |"
"| This is Bash Scripting |"
"| |"
"| 1 - This Machine Name is test |"
"| 2 - This Machine has 8 CPU's |"
"| |"
" -------------------------------------------------------------------"