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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regexpr in SED

Status
Not open for further replies.

christiniaroelin

Programmer
Sep 15, 2004
26
US
i have the following sed :
sed -e "s/|| 'Ç' ||/,/g" input > output
where input is
infield1 || 'Ç' ||
in2 || 'Ç' ||
lpad ( in3 ||
in4 ||
) || 'Ç' ||
in4 || 'Ç' ||

the || 'Ç' || are the field delimiters. The expected ouput is:

infield1 ,
infield1 ,
in2,
lpad ( in3 ||
in4 ||
),
in4,

that is the or (||) should be retained where as the delimiters ahould be changed to commas( ,). The above seems to confuse between the regexpr. I tried by modifying the sed
to
sed -e "s/^|| 'Ç' ||$/,/g" input > output.
but without success.
please advice on the above.
Thanks a lot!
roelin

 
sed -e "s/\|\| 'Ç' \|\|/,/g" input > output

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
I tried with this modification but it still substitutes the || to ,.
thank you
roelin
 
strange.... works fine under Solaris' stock 'sed'....


vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Finally i got it working..i used he group operator
sed -e "s/(|| 'Ç' ||/),/g" input > output .
this works for me..
Thanks for your time and help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top