Changing / to - with vi


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Changing / to - with vi
# 1  
Old 03-06-2010
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?
# 2  
Old 03-06-2010
Hi.

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

Escape the / with a \
Code:
:%s/\//-/g

# 3  
Old 03-08-2010
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
These 2 Users Gave Thanks to ungalnanban For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing different value to single value

I have a input file like this select column1,column2 from tablename where column3='1000000001'; select column1,column2 from tablename where column3='1000000002'; select column1,column2 from tablename where column3='1000000003'; select column1,column2 from tablename where column3='1000000004';... (4 Replies)
Discussion started by: nsuresh316
4 Replies

2. Shell Programming and Scripting

password changing

Hi all Im trying to learn the basics of bash and am struggling with some file manipulation. I am trying to run a script that once you have logged in allows you to change your password which is held (along with the corresponding username) in a different file called usernames. When i try to run my... (2 Replies)
Discussion started by: somersetdan
2 Replies

3. Shell Programming and Scripting

Changing Name of File

Write a shell program to replace the starting alphabet "a" with "k" for the file names in the current directory. Note : Change only the file names starting with "a". Rest of the file names remains unchanged. Homework. Replies deleted. Closed. (0 Replies)
Discussion started by: shashwat2691
0 Replies

4. Solaris

Defaultrouter not changing !!

Hi experts I have to change the default router of some system I tried changing by deleing the existing route by following line #route delete default 172.24.2.101 then I added executed the below line to add the new router #route add default 172.24.1.254 ... (9 Replies)
Discussion started by: kumarmani
9 Replies

5. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

6. HP-UX

Changing the machine name

I work on a UNIX HP 10.20 system that recently crashed. I am new with UNIX but I pick things up quick. The system I work on consists of two computers with the same basic hardware config. I have been having trouble loading the program software it uses, NOT the UNIX software, so I used the a... (1 Reply)
Discussion started by: gizmoking
1 Replies

7. Post Here to Contact Site Administrators and Moderators

changing my nickname

Hello, is it possible to change my nickname? Thank you. (4 Replies)
Discussion started by: Bashar
4 Replies

8. Windows & DOS: Issues & Discussions

Changing IP address

Hi ,,, i just come across this forum and i make it a must to be pay a visit here everyday and through it am learning a lots of things which am sure i will be able to share later... So i have a prob with my pc when i try to change my Ip address in the dos command using ipconfig command i got a... (1 Reply)
Discussion started by: Lutchumaya
1 Replies

9. Shell Programming and Scripting

changing to a different file

Hi, At the moment, I have inserted an actual filename to conduct searches through it etc... Instead, I want the user to choose a filename and then do the searches against this file, instead of already having specified the file in the code. How would I do this? I tried doing the following, but it... (5 Replies)
Discussion started by: kev269
5 Replies

10. Solaris

changing password

Hi Someone logged on the system with a Normal user and changed the password , for this user , how can i know ? who changed the password from which terminal ? regards Georges (5 Replies)
Discussion started by: itsgeorge
5 Replies
Login or Register to Ask a Question