G??”Go to the last line of the file.
1G??”Go to the first line of the file. (Use any number to go to that line in the file.)
Searching for Text
To search for the next occurrence of text in the file, use either the slash (/) or the question mark (?)
character. Follow the slash or question mark with a pattern (string of text) to search forward or
backward, respectively, for that pattern. Within the search, you can also use metacharacters. Here
are some examples:
/hello??”Searches forward for the word hello.
?goodbye??”Searches backward for the word goodbye.
/The.*foot??”Searches forward for a line that has the word The in it and also, after
that at some point, the word foot.
?[pP]rint??”Searches backward for either print or Print. Remember that case
matters in Linux, so make use of brackets to search for words that could have different
capitalization.
The vi editor was originally based on the ex editor, which didn??™t let you work in full-screen mode.
However, it did enable you to run commands that let you find and change text on one or more
lines at a time. When you type a colon and the cursor goes to the bottom of the screen, you are
78
Linux First Steps Part I
essentially in ex mode. Here is an example of some of those ex commands for searching for and
changing text.
Pages:
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242