Now we have gone over the most common names of tput that you will probably use, let’s see how we can use tput in scripts.
We can use the output of all tput names and store them inside more meaningful variable names. The format to do this is:
variable_name= `tput name`
To use the Boolean tput output use the if statement:
STATUS_LINE=‘tput hs‘ if $STATUS_LINE; then echo "your terminal has a status line" else echo "your terminal has NO status line" fi
Here’s a script that has assigned the tput bel and cl to more meaningful variable names.
$ pg tput1 #!/bin/sh BELL=`tput bel` CLEAR=`tput cl` echo $BELL echo $CLEAR
The following ...