text substitution

P

pula58

I have a text file with many occurances of the following text:

dev/group

I want to replace the (above) text with the following:


$ dev/group

But, I am having trouble when I use this code:

s/dev/group/$ dev/group

due to use of $ and /

Any tips on how I can do the replacement?

Thanks

P
 
G

Gunnar Hjalmarsson

pula58 said:
I have a text file with many occurances of the following text:

dev/group

I want to replace the (above) text with the following:

$ dev/group

But, I am having trouble when I use this code:

s/dev/group/$ dev/group

due to use of $ and /

Any tips on how I can do the replacement?

s|(dev/group)|\$ $1|g;
 
T

Tad McClellan

pula58 said:
I have a text file with many occurances of the following text:

dev/group

I want to replace the (above) text with the following:


$ dev/group

But, I am having trouble when I use this code:

s/dev/group/$ dev/group

due to use of $ and /

Any tips on how I can do the replacement?


Put a backslash in front of the meta characters that you
want to be literal:

s/dev\/group/\$ dev\/group/;

or use single quote as the delimiter:

s'dev/group'$ dev/group';
 
P

pula58

Put a backslash in front of the meta characters that you
want to be literal:

s/dev\/group/\$ dev\/group/;

or use single quote as the delimiter:

s'dev/group'$ dev/group';

--
Tad McClellan SGML consulting
(e-mail address removed) Perl programming
Fort Worth, Texas- Hide quoted text -

- Show quoted text -

That did the trick, thank you very much (to you both)!

P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top