November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

VI – Search and Replace with a pathname

Find and replace with VI on a pathname is a bit tricky you ned to use escape characters.

In this case /bin/mail should be replaced with /usr/bin/mail

The command below would do it:

:%s/\/bin\/mail/\/usr\/bin\/mail/g

 

Find and Replace Example

Here is an example of find and replace with VI, this will replace every instance of the “findthistext” string in the file with “replacewithtext”. Neat saves lots of typing!

:%s/findthistext/replacewithtext/g

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>