Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substitution error

Status
Not open for further replies.
Joined
Sep 22, 2004
Messages
27
Location
US
I have the following numerous line in input file:
nvl(MP_MID_INIT_TXT, ' ') || 'M-G' ||
lpad(nvl(MP_SEQ_IMS_ID, 0), 3, 0) ||
lpad(nvl(MP_IMS_ID, 0), 7, 0) || 'M-G' ||
from which i need to delete the || 'M-G' || and || occurrances.
I tried with the following sed statements :
sed "s/^|| $||/ /g" outdat.sql > osql.sql
sed "s/|| 'M\-G' ||/ /g" /development/uda/sql/outdat.sql > osql.sql
but doesnt create the required output.
Could you please let me know as to what i m missing??
Thanks a lot again!
Roe
 
something like this [if I understand the requirement]:

sed -e "s/||//g;s/'M-G'//g" file.txt

If not, pls post the desired end result.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
input file record:
nvl(MP_MID_INIT_TXT, ' ') || 'M-G' ||
lpad(nvl(MP_SEQ_IMS_ID, 0), 3, 0) ||
lpad(nvl(MP_IMS_ID, 0), 7, 0) || 'M-G' ||

desired output:
nvl(MP_MID_INIT_TXT, ' ')
lpad(nvl(MP_SEQ_IMS_ID, 0), 3, 0)
lpad(nvl(MP_IMS_ID, 0), 7, 0)

that is to delete any occurances of || 'M-G' || and || .
I tried the sed statement that you has advised, but only got the following result:
nvl(MP_MID_INIT_TXT, ' ') 'M-G'
lpad(nvl(MP_SEQ_IMS_ID, 0), 3, 0)
lpad(nvl(MP_IMS_ID, 0), 7, 0) 'M-G'

Could you please let me know as to what i m missing??
Thanks a lot again!
Roe
 
intersting - I got the desired result back [Solaris stock sed]:

input said:
nvl(MP_MID_INIT_TXT, ' ') || 'M-G' ||
lpad(nvl(MP_SEQ_IMS_ID, 0), 3, 0) ||
lpad(nvl(MP_IMS_ID, 0), 7, 0) || 'M-G' ||
output said:
nvl(MP_MID_INIT_TXT, ' ')
lpad(nvl(MP_SEQ_IMS_ID, 0), 3, 0)
lpad(nvl(MP_IMS_ID, 0), 7, 0)

are you sure you executed 'sed' as posted?
what OS are you on?

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
i rechecked the sed that i executed : its "ditto" as the one you sent. but still the same output as before. Im on HP-UX.
Appreciate your time and help!
Thanks
roe
 
try this - just a wild guess:

sed -e "s/[|][|]//g;s/'M-G'//g" file.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
oh, I think I see what's happening - try this:
sed -e "s/||//g" -e "s/'M-G'//g" file.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I tried that too still the same. However the || gets deleted fine, except for the 'M-G' in || 'M-G' ||.
Thanks a lot again
roe
 
nope, i still have the same output. 'M-G' seems to be strange!!!
 
I hate to but in, but is it possible you guys are using ' and ` inconsistently?
 
seems like there are no back-ticks anywhere...

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
joe,

make sure are not control characters in the 'M-G' - seems like the pattern is not getting mapped.

in 'vi' do: ":set list" and examine the content of the file.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Which version of HP-UX ? Which shell ? Which EXACT command line ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
your are right, after vi :set list i see the control characters as || 'ú' ||$. Please let me know how to delet this??
Thank you all for your time and help!!
roe
 
i put the control character for pattern matching and whew!! finally its working. Thanks again !!
roe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top