Results 1 to 3 of 3
  1. #1
    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
    ......

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,446
    Do you think sed may be case-sensitive?
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Feb 2006
    Posts
    172
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •