Computing.Net > Forums > Unix > Handling // character with sed

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Handling // character with sed

Reply to Message Icon

Name: bvsbabu
Date: October 10, 2006 at 07:57:02 Pacific
OS: AIX Unix
CPU/Ram: AIX
Product: HP
Comment:

I am trying to replace the text "*url" with the value "jdbc:oracle://localhost:1521;SID=dbinst".

The script I am using to replace the "*url" string is as below

`sed -e "s/$URL_UNIQ_TAG/$URL/" $ACT_FILE_NAME > $TEMP_FILE_NAME`

Here

$URL_UNIQ_TAG =*url

$URL=jdbc:oracle://localhost:1521;SID=dbinst

$ACT_FILE_NAME is the source file.


When I execute this, I am getting the following error

sed: command garbled: s/*URL/jdbc:oracle://localhost:1521;SID=dbinst/

Please help me..

Thanks in advance.




Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: October 10, 2006 at 09:33:03 Pacific
Reply:

I'm not understanding what your final output should look like, but maybe I can get you started. You have two issues (I'm using ksh):

1) To embed shell variables in a sed script you have to surround them with quotes:


sed 's/'"${URL_UNIQ_TAG}"'/'"${URL}"'/g' act_file_name

2) You have special characters in your data
that probably have to be escaped:
URL="jdbc:oracle:\/\/localhost:1521;SID=dbinst"



0

Response Number 2
Name: bvsbabu
Date: October 10, 2006 at 11:25:21 Pacific
Reply:

I can not edit the input as I don't know which format it is coming from. so I get the "jdbc:oracle:\\localhost:1521;SID=dbinst" value dynamically.

I even used the sed 's/'"${URL_UNIQ_TAG}"'/'"${URL}"'/g' act_file_name..

but no luck


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Handling // character with sed

pattern matching/replacing with sed www.computing.net/answers/unix/pattern-matchingreplacing-with-sed/6671.html

Problem with sed www.computing.net/answers/unix/problem-with-sed/3990.html

joining lines with sed www.computing.net/answers/unix/joining-lines-with-sed/6674.html