z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Searching for strings

z/OS UNIX System Services User's Guide
SA23-2279-00

In a large document, searching for a particular text string can be very time consuming. The / command prompts for a string to search for in the file. When you press <Enter>, vi searches the file for the next occurrence of the string you entered.

To try searching for a string, first move to the top of vitest. Then type:
/Blu
and press <Enter>.

As soon as you enter /, it is displayed on the bottom of the screen. As you type the string Blu, it is echoed . You can use <Backspace> to fix mistakes as you type the search string. After you press <Enter>, the cursor moves to the first occurrence of the string.

The n command searches for the next occurrence of the last string you searched for. Try it now by entering:
n

The cursor should move to the next occurrence of the string, which is the th in the word with. You can also use N like n to search the other direction through the file.

If you just type a slash without anything after it, vi looks for the most recent word or phrase you searched for.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014