Changing / to - with vi | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Changing / to - with vi

UNIX for Dummies Questions & Answers


Tags
vim substitute

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-06-2010
SoVi3t SoVi3t is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 3 February 2011, 10:32 PM EST
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Changing / to - with vi

Hi just learning Unix in college now and this is my first post here, so I dunno if this goes here, or in the homework section technically.

Anywho, trying to change all the / in a file into - using vi...

i went into the command prompt, and put in :%s///-/g and it comes up with E488: Trailing characters.

Where did I go wrong lol?
Sponsored Links
    #2  
Old 03-06-2010
Scott's Avatar
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 24 November 2014, 12:17 AM EST
Location: Zürich
Posts: 8,489
Thanks: 333
Thanked 1,050 Times in 916 Posts
Hi.

It doesn't sound like much of a homework question!

Escape the / with a \

Code:
:%s/\//-/g

Sponsored Links
    #3  
Old 03-08-2010
ungalnanban's Avatar
ungalnanban ungalnanban is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 27 November 2013, 4:12 AM EST
Location: Chennai
Posts: 142
Thanks: 5
Thanked 26 Times in 7 Posts
MySQL

Normally we use the "/" is the delimiter between string and replace string for substitution .
if you want to replace the "/" (delimiter) character that time you need to escape the "/" using "\".

we can change the substitution delimiter instead of "/".
if we change the delimiter then no need to escape the "/" character.

see the following Example:


Code:
 :%s%/%-%g

[OR]

Code:
:%s#/#-#g

[OR]

Code:
:%s!/!-!g

[OR]

Code:
%s@/@-@g


Last edited by ungalnanban; 03-08-2010 at 01:17 AM.. Reason: spell mistake
The Following User Says Thank You to ungalnanban For This Useful Post:
mathbalaji (07-02-2012)
Sponsored Links
Closed 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
Changing txt Monkey Dean Shell Programming and Scripting 4 05-06-2009 06:26 PM
changing shell while using ssh amit1_x Shell Programming and Scripting 2 02-09-2009 11:30 AM
awk is changing my FS !! jolecanard Shell Programming and Scripting 4 10-04-2008 07:09 AM
Changing userID and Changing group and GID deal732 Shell Programming and Scripting 2 04-18-2007 11:09 AM
Changing IP's Hordak UNIX for Dummies Questions & Answers 2 08-03-2002 01:42 AM



All times are GMT -4. The time now is 02:38 AM.