Article 565B6 Wanting to center text

Wanting to center text

by
billlove
from LinuxQuestions.org on (#565B6)
This code will justify the text "Start Program" in the left center of the terminal window. I'd like it in the center. If anyone has any suggestions, much appreciated.

cols=$( tput cols )
rows=$( tput lines )

message=Start Program

input_length=${#message}

half_input_length=$(( $input_length / 2 ))

middle_row=$(( $rows / 2 ))
middle_col=$(( ($col /2 ) - half_input_length ))

tput clear

tput cup $middle_row $middle_col
tput bold

echo Start Program

tput sgr0
tput cup $( tput lines ) 0latest?d=yIl2AUoC8zA latest?i=CbR4XvDd46Y:o_8AeWqFnXU:F7zBnMy latest?i=CbR4XvDd46Y:o_8AeWqFnXU:V_sGLiP latest?d=qj6IDK7rITs latest?i=CbR4XvDd46Y:o_8AeWqFnXU:gIN9vFwCbR4XvDd46Y
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments