Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: OT: unix script quetion: to replace $ with \$

Re: OT: unix script quetion: to replace $ with \$

From: Ron Thomas <rthomas_at_hypercom.com>
Date: Mon, 03 Feb 2003 11:29:40 -0800
Message-ID: <F001.005425F7.20030203112940@fatcity.com>

Problem here is that sed treats $ as a special characer meaning end of line as well as the korn shell meaning variable replacement.

To avoid the shell evaluation, use ' not ". to avoid the sed special charater, escape it.

echo '123$45$678' | sed 's/\$/\\\$/g'

Ron Thomas
Hypercom, Inc
rthomas_at_hypercom.com
Each new user of a new system uncovers a new class of bugs. -- Kernighan

                                                                                                                                                 
                      zlmei_at_hotmail.com                                                                                                          
                      Sent by:                 To:       ORACLE-L_at_fatcity.com                                                                    
                      root_at_fatcity.com         cc:                                                                                               
                                               Subject:  OT: unix script quetion: to replace $ with \$                                           
                                                                                                                                                 
                      02/03/2003 11:39                                                                                                           
                      AM                                                                                                                         
                      Please respond to                                                                                                          
                      ORACLE-L                                                                                                                   
                                                                                                                                                 
                                                                                                                                                 




Hi:

I have a quick question about replacing "$" with "\$" on unix. I need to convert string "123$45$678" to "123\$45\$678" through a pipe. I tried with sed command, but could not get it to work:

essex$ echo "123$45$678" | sed s/"$"/"\$"/g 123578$
essex$ echo "123$45$678" | sed s/"$"/"\\$"/g 123578$

Maybe there is another syntax that I should use? TIA.

Guang Mei



MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Guang Mei
  INET: zlmei_at_hotmail.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Ron Thomas INET: rthomas_at_hypercom.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Mon Feb 03 2003 - 13:29:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US