The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > 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 05:55 PM
cpu usage gfhgfnhhn UNIX for Dummies Questions & Answers 4 09-17-2006 10:11 AM
Getting CPU Usage WG1 Shell Programming and Scripting 4 05-01-2006 09:07 AM
Monitor CPU usage and Memory Usage Gajanad Bihani High Level Programming 2 03-09-2005 07:35 AM
cpu usage sushaga Filesystems, Disks and Memory 0 04-06-2002 09:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-16-2008
capri_drm capri_drm is offline
Registered User
  
 

Join Date: May 2008
Location: St. Louis
Posts: 78
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 ,
  #2 (permalink)  
Old 05-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

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

Join Date: May 2008
Location: St. Louis
Posts: 78
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 !
  #4 (permalink)  
Old 05-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
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.
  #5 (permalink)  
Old 05-16-2008
capri_drm capri_drm is offline
Registered User
  
 

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

Thanks !
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0