Searching and Replacing

A variation on the cut-and-paste action is the search-and-replace action. This is useful if you need to make changes to every instance of a string within a file. The first step is the search. Searching is something you will do even if you are not interested in performing a replace. The following command places the cursor on the first instance of the string Den:

/Den/

Notice that no : exists in front of it; it is a command-mode command. This command searches forward from the current cursor position to the end of the file. If you want to search backward, you can surround the search string with ? instead of /. If the search finds an instance of the string, and you want to search for the same string again, you can type the ...

Get Korn Shell Programming by Example 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.