Reading and writing files interactively

This next script is similar to one in Chapter 5, Creating Interactive Scripts. It reads the file specified, displays a form, and allows the user to edit and then save it:

Chapter 7 - Script 6

#!/bin/sh # 6/2/2017 # Chapter 7 - Script 6 trap catchCtrlC INT # Initialize the trap # Subroutines catchCtrlC() { move 13 0 savefile movestr 23 0 "Script terminated by user." echo "" # carriage return exit 0 } cls() { tput clear } move() # move cursor to row, col { tput cup $1 $2 } movestr() # move cursor to row, col { tput cup $1 $2 echo -n "$3" # display string } checktermsize() { rc1=0 # default is no error if [[ $LINES -lt $1 || $COLUMNS -lt $2 ]] ; then rc1=1 # set return code fi return $rc1 } init() # set up the ...

Get Linux Shell Scripting Bootcamp now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.