Screen manipulation
We'll see another script in the next section that uses a loop to put text on the screen:
Chapter 3 - Script 4
#!/bin/sh # # 5/2/2017 # echo "script4 - Linux Scripting Book" if [ $# -ne 1 ] ; then echo "Usage: script4 string" echo "Will display the string on every line." exit 255 fi tput clear # clear the screen x=1 while [ $x -le $LINES ] do echo "********** $1 **********" let x++ done exit 0
Before executing this script run the following command:
echo $LINES
If the number of lines in that terminal is not displayed run the following command:
export LINES=$LINES
Then proceed to run the script. The following is the output on my system when run with script4
Linux
:
Okay, so I agree this might not be terribly useful, but it does show a few things. The LINES
env var contains the current number of lines (or rows) in the current terminal. This can be useful for limiting output in more complex scripts and that will...