Solaris

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?

👤 Login to reply

    #1  
Old 08-02-2011
rogerben rogerben is offline
Users Awaiting Email Confirmation
 
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
Sponsored Links
    #2  
Old 08-02-2011
yazu yazu is offline
Registered User
 
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.
Sponsored Links
    #3  
Old 08-03-2011
vivek.goel.piet vivek.goel.piet is offline
Registered User
 
Bingo!!

Correct answer dude!!!
Quote:
Originally Posted by yazu View Post
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.
Sponsored Links
👤 Login to reply

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
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
Help with find and replace w/string containing special characters CAGIRL UNIX for Dummies Questions & Answers 4 10-07-2008 07:13 PM
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 02:53 AM.

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





Not a Forum Member?
Forgot Password?