Shell Scripts

Although Chapter 25 covers the basic syntax and language of shell programming, look at a few additional examples of scripts that are often useful in day-to-day operation.

Changing Strings in Files with chstr

Users who maintain source code, client lists, and other records often want to launch a find-and-replace operation from the command line. It's useful to have a variant of chstr on UNIX hosts. Listing 26.2 gives one example.

Code Listing 26.2. chstr—A Simple Find-and-Replace Operation
 ######## # # See usage() definition, below, for more details. # # This implementation doesn't do well with complicated escape # sequences. That has been no more than a minor problem in # the real world. # ######## usage() { echo \ "chstr BEFORE ...

Get Red Hat® Linux® 7 Unleashed 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.