Chapter 12. Screenplay: The screen—funcs Library

One of the first scripts I wrote printed a data-entry form on a terminal screen. This meant positioning the cursor at 30 or more different places for each record, and displaying some pieces of information in bold or reverse text. The usual method of positioning the cursor and setting attributes such as bold and reverse involves tput, a Unix utility that outputs screen codes for the particular terminal or terminal emulation you are using. Even with processors running at multi-gigahertz speeds, calling an external command 30 times can produce a noticeable delay.

I took the easy way out and placed the cursor-positioning codes for our terminals in a printat function, and the printing attributes (bold, ...

Get Shell Scripting Recipes: A Problem-Solution Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.