Читать книгу Linux Bible - Christopher Negus - Страница 155
Searching for text
ОглавлениеTo search for the next or previous 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.
After you have entered a search term, simply type n or N to search again in the same direction (n
) or the opposite direction (N
) for the term.