Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Changing / to - with vi

UNIX for Dummies Questions & Answers


Tags
vim substitute

 
 
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: 7 December 2016, 12:24 PM EST
Location: Zürich
Posts: 8,598
Thanks: 343
Thanked 1,093 Times in 949 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: 21 November 2016, 4:44 AM EST
Location: Chennai
Posts: 142
Thanks: 5
Thanked 27 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 2 Users Say Thank You to ungalnanban For This Useful Post:
mathbalaji (07-02-2012), Saran Kumar (07-27-2016)
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 09:26 AM.