Find the answer to your Linux question:
Results 1 to 7 of 7
I want to convert this Code: SQL_STRING=`$ORACLE_HOME/bin/sqlplus -s ${user_name}/${password}@${sid} into this Code: SQL_STRING=`/usr/bin/sqlplus ${user_name}/${password}@"(description=(address=(host=1.14.20.31)(protocol=tcp)(port=1521))(connect_data=(sid=${sid})))" I need to replace this line in all files of a directory. I used sed for ...
  1. #1
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Question need help on find and replace entire line?

    I want to convert this
    Code:
    SQL_STRING=`$ORACLE_HOME/bin/sqlplus -s ${user_name}/${password}@${sid}
    into this

    Code:
    SQL_STRING=`/usr/bin/sqlplus ${user_name}/${password}@"(description=(address=(host=1.14.20.31)(protocol=tcp)(port=1521))(connect_data=(sid=${sid})))"
    I need to replace this line in all files of a directory.
    I used sed for replacing words but not for lines.

    Any help?
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  2. #2
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    sed replaces a pattern with a string. It doesn't matter whether the pattern matches just one word or an entire line.

  3. #3
    Just Joined!
    Join Date
    Aug 2008
    Posts
    2

    Thumbs up try this....

    perl -p -i -e 's\Orignal\Replace\g' `find *`

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Exclamation

    yes..but in my case i'm having special characters ..i tried escape characters but it didn't work for me
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  5. #5
    Linux Newbie
    Join Date
    Jul 2008
    Posts
    181
    Use the backslash ("\") to escape these characters. Moreover, both sed and perl allow you to use to delimit regular expressions with characters other than slash ("/").

  6. #6
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568

    Smile

    yes ..it woked....this time i did sed replacement step by step ...

    Code:
    sed -e 's/$ORACLE_HOME/ \/usr/g' -e 's/-s/ /g' -e 's/@${sid}/@\"(description=(address=(host=10.14.20.31)(protocol=tcp)(port=1521)(connect_data=(sid=${sid})))/g' f1.txt
    Thanks guyz ....
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  7. #7
    Just Joined!
    Join Date
    Nov 2007
    Posts
    27
    Try this you may find it usefull

    %s/oldline/newline/g

Posting Permissions

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