Solved

Search and Replace in Vi Editor

Posted on 2007-11-18
4
8,343 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
4 Comments
 
LVL 84

Accepted Solution

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

Assisted Solution

by:Arthur_Mino
Arthur_Mino earned 30 total points
Comment Utility
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
Comment Utility
:%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
Comment Utility
Guys thanks for that :>)

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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now