Home > Unix > UNIX – Lesson 013 – vi editor – Simple Search and Search for text Patterns

UNIX – Lesson 013 – vi editor – Simple Search and Search for text Patterns


Search for Text: /, ?, n and N

  • /text     searches for text from the current line towards the end of the file
  • ?text     searches for text from the current line towards the beginning of the file
  • n           finds next occurrence of last search in the same direction
  • N           finds next occurrence of last search in reverse direction

===================================================================================

Search for Text Patterns

  • /[a-zA-Z0-9]     defines a class of characters to match from
  • /^text              searches for text at the beginning of a line
  • /text$              searches for text at the end of a line
  • /character*      searches for zero or more occurrences of  character

Example:
/[Tt]                    It searches for the next occurrence of the string “The” or “the”
/^[abc]*             It searches for line that begins with “a”,”b”,”c” followed by zero or more any character

Categories: Unix
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: