Girdhar Singh Rathore
Girdhar Singh Rathore

Reputation: 5615

find and replace a String in vi editor on linux?

i am trying to replace String with new String in Linux vi editor

:s/totel_email_count/total_email_count/g

but getting following error.

E486: Pattern not found: totel_email_count

Upvotes: 7

Views: 25595

Answers (2)

Sukhjinder Singh
Sukhjinder Singh

Reputation: 135

To find and replace with vi editor type following:-

Type : (colon) followed by %s/foo/bar/ and hit [Enter] key.

:%s/foo/bar/

for example:-

:%s/old_string/new_string/

Upvotes: 1

user156213
user156213

Reputation: 766

I'd guess the reason you're getting that error message is because you intend to replace the string on all lines, not just the current one. In order to search all lines, add a % to your command:

:%s/totel_email_count/total_email_count/g

Upvotes: 18

Related Questions