If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Unable to execute sed from file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Dec 2012
Posts: 3
Unable to execute sed from file

Hi,
I have a variable defined as below:

DBNAME=ident

Can someone let me know what is wrong with the below sed command? It is not substituting.

sed 's/CONNECT TO "$DBNAME"W/CONNECT TO $DBNAME/g' db2look_"$DBNAME"_ddl.sql

Contents of db2look_"$DBNAME"_ddl.sql :

-- This CLP file was created using DB2LOOK Version 8.2
-- Timestamp: Mon 17 Dec 09:40:24 2012
-- Database Name: IDENTW-- Database Manager Version: DB2/AIX64 Version 8.2.7
-- Database Codepage: 819
-- Database Collating Sequence is: UNIQUE


CONNECT TO IDENTW;
-- Mimic tablespace
......
Reply With Quote
  #2 (permalink)  
Old
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 5,333
Do you think sed may be case-sensitive?
__________________
---
"It does not work" is not a valid problem statement.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Feb 2006
Posts: 169
Try it like the below example:
Code:
$ cat t
-- This CLP file was created using DB2LOOK Version 8.2
-- Timestamp: Mon 17 Dec 09:40:24 2012
-- Database Name: IDENTW-- Database Manager Version: DB2/AIX64 Version 8.2.7
-- Database Codepage: 819
-- Database Collating Sequence is: UNIQUE


CONNECT TO IDENTW;
-- Mimic tablespace


$ CUR_DBNAME="IDENT"

$ NEW_DBNAME="ident"

$ sed "s/\(CONNECT TO \)${CUR_DBNAME}W/\1${NEW_DBNAME}/g" t
-- This CLP file was created using DB2LOOK Version 8.2
-- Timestamp: Mon 17 Dec 09:40:24 2012
-- Database Name: IDENTW-- Database Manager Version: DB2/AIX64 Version 8.2.7
-- Database Codepage: 819
-- Database Collating Sequence is: UNIQUE


CONNECT TO ident;
-- Mimic tablespace
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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