Home Man
Search
Today's Posts
Register

The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

How to replace special characters in vi?

Tags
solaris

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 08-02-2011
How to replace special characters in vi?

Hi ,
I want to replace the special characters in the file.
For eg: cat abc
1234/4455/acb
234/k/lll/
234`fs`fd

I want to replace / and ` with the letter a and the output should like below. How to achieve this.
1234a4455aacb
234akallla
234afsafd
# 2  
Old 08-02-2011
Try:
Code:
:%s!/!a!g
:%s/`/a/g

"/" and "`" are not special in regular expressions. And you can use almost any non alphanum char as a separator for patterns in "s" command.
# 3  
Old 08-03-2011
Bingo!!

Correct answer dude!!!
Quote:
Originally Posted by yazu
Try:
Code:
:%s!/!a!g
:%s/`/a/g

"/" and "`" are not special in regular expressions. And you can use almost any non alphanum char as a separator for patterns in "s" command.
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to replace special characters? Ravi.K UNIX for Advanced & Expert Users 4 04-22-2017 03:04 AM
How to replace value of password tag in xml with blanks when special characters are there? saroopkris85 How to Post in the The UNIX and Linux Forums 7 10-27-2015 03:35 PM
Help to replace the string with special characters nikhil jain Shell Programming and Scripting 3 02-13-2015 07:16 AM
How to replace special characters? ken002 Shell Programming and Scripting 25 11-05-2012 09:10 AM
Replace special characters with Escape characters? laknar Shell Programming and Scripting 8 01-05-2012 11:40 PM
Replace special characters ratheeshjulk Shell Programming and Scripting 0 12-22-2011 08:18 PM
Replace new line with <br /> & escape special characters ted_chou12 Shell Programming and Scripting 2 02-07-2011 08:25 PM
Using sed to replace special characters nimo Shell Programming and Scripting 5 08-12-2010 02:42 AM
Find and replace special characters in a file sujithchandra UNIX for Dummies Questions & Answers 2 10-24-2008 06:59 AM
Replace Special characters in a file solai UNIX for Dummies Questions & Answers 1 07-13-2006 10:36 AM


All times are GMT -4. The time now is 01:12 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password