Solved

Search and Replace in Vi Editor

Posted on 2007-11-18
4
8,361 Views
Last Modified: 2013-12-16
Hi guys hope you can help me :>)

I have a question on using VI Editor.

I often want to do search and replacements in a text file, and use VI to do this.

For example,

:1,$s/MindMaps/Algorithms

What the above does is to find all instances of MindMaps, and replace it with Algorithms.

What Im having trouble with is the following...

:1,$s/MindMaps/Algorithms/002/text

In the above, I want to replace the word

MindMaps

with

Algorithms/002/text

What I get is an error in VI Editor saying "Trailing characters"

Q. How do I do a replacement in Vi with forward slashes included in the replacement?

Thank you.
0
Comment
Question by:Simon336697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 440 total points
ID: 20310246
1,$s#MindMaps#Algorithms/002/text
0
 
LVL 6

Assisted Solution

by:Arthur_Mino
Arthur_Mino earned 30 total points
ID: 20310299
G'day,

I think you'll need the grep command here

Check this link out
http://lowfatlinux.com/linux-sed.html

Cheers,
Arthur
0
 
LVL 3

Assisted Solution

by:amirs80
amirs80 earned 30 total points
ID: 20310388
:%s$MindMaps$Algorithms/002/text
there are many other tech , by using sed is also is a tech
0
 
LVL 1

Author Comment

by:Simon336697
ID: 20310624
Guys thanks for that :>)

ozo...that was exactly what i was looking for.
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question