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: Guang Mei <zlmei_at_hotmail.com>
Date: Mon, 03 Feb 2003 13:43:40 -0800
Message-ID: <F001.00542830.20030203134340@fatcity.com>


Hi:

I ended up solving my problem by changing my query in "get_ISI_tabs.sql" to:

select 'execute DBMS_STATS.GATHER_TABLE_STATS('''||owner||''','''||

        segment_name||''',cascade => TRUE);'   from ( select owner, replace (segment_name, '$','\$') segment_name,

          sum(bytes) from dba_segments s where segment_type like 'TABLE%' and

        owner = 'ISI' and
        s.partition_name is null

group by owner,segment_name
order by sum(s.bytes) desc);

Use of function "replace" solved my problem. But thanks for you help.

Guang

----Original Message Follows----
To: ORACLE-L_at_fatcity.com
CC: zlmei_at_hotmail.com
Date: Mon, 3 Feb 2003 13:14:38 -0800

Use the octal code for the character, and using the quoting mechanism of your choice:

$ = octal 044

echo '123$45$678' | sed -e "s#\044#\\\044#g"

Jared

"Guang Mei" <zlmei_at_hotmail.com>
Sent by: root_at_fatcity.com
  02/03/2003 12:09 PM
  Please respond to ORACLE-L

         To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
         cc:
         Subject:        Re: OT: unix script quetion: to replace $ with \$


Hi, Brian:

Thanks for your (and others) help. I can not use signle quotes in "echo" in my program. The reason is this:

I am trying to run table analyze in multiple treads (I found doing this reduce time by 50%). By doing this I run sh script "gather_ISI_table_stats_executeX.sh":

essex$ more gather_ISI_table_stats_executeX.sh #!/bin/sh

sqlplus -s isi/password @/oracle/dba/get_ISI_tabs.sql | awk '{print "echo \""$0"\
" | sqlplus -s isi/password"}' | /oracle/dba/executeX 3

Here executeX is a program to run multiple threads (3 in this case). The script "get_ISI_tabs.sql" is just a script to get all the tables in the schema. The problem is that there are Oracle Inter-Media tables like DR$TEST_CONTEXT$R which makes this whole script fail. I can not seem to find
a way to get around of this issue.

essex$ more get_ISI_tabs.sql
-- Script for listing analyze table commands in decreating size

select 'execute DBMS_STATS.GATHER_TABLE_STATS('''||owner||''','''||

         segment_name||''',cascade => TRUE);'    from ( select owner,segment_name, sum(bytes) from dba_segments s where segment_type like 'TABLE%' and

         owner = 'ISI' and
         s.partition_name is null

group by owner,segment_name
order by sum(s.bytes) desc);

exit;


Guang Mei

----Original Message Follows----
To: ORACLE-L_at_fatcity.com
CC: zlmei_at_hotmail.com
Date: Mon, 3 Feb 2003 12:58:01 -0700

Your first "echo" needs to be in single quotes or else it results in...

29912:oracle_at_mybox> echo "123$45$678"
123578

Once that is done this...

29912:oracle_at_mybox> echo '123$45$678' | sed 's/\$/\\$/g' 123\$45\$678

...or this...

29912:oracle_at_mybox> echo '123$45$678' | sed 's/\$/\\\$/g' 123\$45\$678

...will work

                        "Guang Mei"
                        <zlmei_at_hotmail.co        To:       Multiple
recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>
                        m>                       cc:
                        Sent by:                 Subject:  OT: unix script
quetion: to replace $ with \$
                        root_at_fatcity.com


                        02/03/03 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).


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail

--
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).


_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail


--
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).
Received on Mon Feb 03 2003 - 15:43:40 CST

Original text of this message

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