The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
CPU usage and memory usage mansoorulhaq High Level Programming 1 08-09-2007 01:55 PM
cpu usage gfhgfnhhn UNIX for Dummies Questions & Answers 4 09-17-2006 06:11 AM
Getting CPU Usage WG1 Shell Programming and Scripting 4 05-01-2006 05:07 AM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 03:35 AM
cpu usage sushaga Filesystems, Disks and Memory 0 04-06-2002 05:46 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 70
sed usage

Hi ,
I have a question. How do I replace 2 words in one line like this

IN CLO07 INDEX IN CLOIX07

to

IN CLO07_S02 INDEX IN CLOIX07_S02

But one thing to remember is that there are lots of words like CLODM001 .
So the only matching pattern is "IN CLO"

sample file is :

CREATE TABLE CLODM001.DIM_HOSPITAL (
HOSP_SYS_ID INTEGER NOT NULL ,
CONTR_MKT_NM VARCHAR(30) NOT NULL ,
CONTR_SUB_MKT_NM VARCHAR(30) NOT NULL
LOAD_DT DATE NOT NULL WITH DEFAULT CURRENT DATE ,
UPDT_DT DATE NOT NULL WITH DEFAULT CURRENT DATE )
COMPRESS YES
IN CLO07 INDEX IN CLOIX07 ;


I used this one but its not right right one .

sed -e 's/\(IN CLO[^"]*\)/\1_S02/g' db2look_DIM_HOSPITAL.ddl1 > db2look_DIM_HOSPITAL.ddl2

Thanks in advance ,
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-15-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,111
Code:
sed -e 's/\(IN CLO[^ ]*\)/\1_S02/g'
should perhaps work better.
Reply With Quote
  #3 (permalink)  
Old 05-16-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 70
Era,
It works fine for only one file. I am passing the many file for that change from CLO* to CLO*_S02 .
Here is the code part

if [ ${source_schema} = 'OPSDM001' ]
then
sed -e 's/\(TSO[^"]*\)/\1_S02/g' $TN.${ecmdate}.sql > $tmpfile_cln
sed -e 's/"//g' $tmpfile_cln > $TN.${ecmdate}.sql
elif [ ${source_schema} = 'DAYA' ]
then
sed -e 's/\(TEST[^"]*\)/\1_S02/g' $TN.${ecmdate}.sql > $tmpfile_cln
sed -e 's/"//g' $tmpfile_cln > $TN.${ecmdate}.sql
elif [ ${source_schema} = 'CLODM001' ]
then
sed -e 's/\(IN CLO[^ ]*\)/\1_S02/g' $TN.${ecmdate}.sql > $tmpfile_cln
sed -e 's/"//g' $tmpfile_cln > $TN.${ecmdate}.sql
elif [ ${source_schema} = 'UHCDM001' ]
then
sed -e 's/\(TSHL[^"]*\)/\1_S02/g' $TN.${ecmdate}.sql > $tmpfile_cln
sed -e 's/"//g' $tmpfile_cln > $TN.${ecmdate}.sql
else
echo " hi "
fi

This script works fine for other schemas but CLODM001 is not working at all. Am I missing something here too ?

Thanks for yoor help !
Reply With Quote
  #4 (permalink)  
Old 05-16-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,111
Where are the double quotes coming from, you are removing double quotes after the basic substitution, which suggests that something is adding double quotes somewhere earlier in the script. Then maybe the substitution should be different, too. If all the others are working then maybe you need to have ^" there after all. Or if you have double quotes in or around "IN" too then obviously they need to be taken into account.
Reply With Quote
  #5 (permalink)  
Old 05-16-2008
Registered User
 

Join Date: May 2008
Location: St. Louis
Posts: 70
You are right Era ,
I moved the file cleaning before CLO part and it works fine now .

Thanks !
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0