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

  Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 03-06-2010
Scott's Unix or Linux Image
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 28 March 2015, 10:47 AM EDT
Location: Zürich
Posts: 8,531
Thanks: 336
Thanked 1,065 Times in 928 Posts
Hi.

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

Escape the / with a \

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

Sponsored Links
    #3  
Old Unix and Linux 03-08-2010
ungalnanban's Unix or Linux Image
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 12:17 AM.. Reason: spell mistake
The Following User Says Thank You to ungalnanban For This Useful Post:
mathbalaji (07-02-2012)
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 05:26 PM
changing shell while using ssh amit1_x Shell Programming and Scripting 2 02-09-2009 10:30 AM
awk is changing my FS !! jolecanard Shell Programming and Scripting 4 10-04-2008 06:09 AM
Changing userID and Changing group and GID deal732 Shell Programming and Scripting 2 04-18-2007 10:09 AM
Changing IP's Hordak UNIX for Dummies Questions & Answers 2 08-03-2002 12:42 AM



All times are GMT -4. The time now is 06:37 AM.