I'm creating a simple console based script using shell script.It will be run on my bash shell Its a simple menu based driven display some set of options.
Now I want to do center align the text depending on the screen size. How do I align the text at center of the screen?Please assis me
Finally I found the solution:)
COLUMNS=$(tput cols)
title="Hello world!"
printf "%*s\n" $(((${#title}+$COLUMNS)/2)) "$title"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With