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 ...
- 08-06-2008 #1
need help on find and replace entire line?
I want to convert this
into thisCode:SQL_STRING=`$ORACLE_HOME/bin/sqlplus -s ${user_name}/${password}@${sid}
I need to replace this line in all files of a directory.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 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
-------------------
- 08-06-2008 #2Linux 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.
- 08-06-2008 #3Just Joined!
- Join Date
- Aug 2008
- Posts
- 2
try this....
perl -p -i -e 's\Orignal\Replace\g' `find *`
- 08-06-2008 #4
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
-------------------
- 08-06-2008 #5Linux 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 ("/").
- 08-06-2008 #6
yes ..it woked....this time i did sed replacement step by step ...
Thanks guyz ....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- 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
-------------------
- 08-07-2008 #7Just Joined!
- Join Date
- Nov 2007
- Posts
- 27
Try this you may find it usefull
%s/oldline/newline/g


Reply With Quote