Moving the cursor with tput

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← Get screen width and hight with tputHomeDisplay centered text in the screen in reverse video →

You can use the tput command to set cursor position on screen. The syntax is as follows:

tput cup x, y

The x, y coordinates are respectively the horizontal and vertical addresses on a Linux computer display screen i.e. take x and/or y coordinates in the device's rows and columns. In this example, move the cursor to the 10th column (x) and the 5th row (y) on a device and display a message using read command as follows:

clear; tput cup 10 5; read -p 'Hello world! Press [Enter] key to continue...'

Sample output:

Moving the cursor with tput command
← Get screen width and hight with tputHomeDisplay centered text in the screen in reverse video →