O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

22.2. Deleting records

To delete records from a file you must first present the record to the user to make sure that this is the correct record to delete. When this is confirmed you can then proceed to delete the record from the file.

To delete a record we need to be able to do the following tasks:

1.
Search for the record.
2.
Display the record.
3.
Confirm deletion.
4.
Update the file.

To search for a record we will use the field surname. Once we have got a surname from the user on which to search we can then proceed. We could use grep or awk, but because our file will have no more than perhaps 100 records we shall read the file in and test for a match.

If your file is going to contain over a couple of hundred records, I advise you to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required