<div dir="ltr">Thanks guys.  I must not be doing what you suggest correctly or maybe I did not describe the problem well (to edit the chosen lines in place in the source file).  In any case, after experimenting on a copy of the file without success I went ahead and did the edits manually to get the job done.  I hope neither of you spent too much time on it but I do appreciate the effort.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 2, 2013 at 7:08 AM, der.hans <span dir="ltr"><<a href="mailto:PLUGd@lufthans.com" target="_blank">PLUGd@lufthans.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 02. Jul, 2013 schwätzte Dazed_75 so:<br>
<br>
moin moin,<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have some C code with lines that look like:<br>
stuff1; stuff2; spPtr+=stuff3; maybesomestuff4<br>
<br>
I can find only the lines of interest using grep spPtr+=foo.c but I<br>
wondered if I could easily use sed to convert those lines to<br>
stuff1; spPtr+=stuff3; stuff2; maybesomestuff4<br>
<br>
so basically with ; as a delimiter, swapping group 2 and 3 but only for<br>
those lines containing "spPtr+="<br>
<br>
Any ideas?<br>
</blockquote>
<br></div>
$ echo "1; 2; 3; 4;" | sed -re 's/^([^;]+;)([^;]+;)([^;]+;)/\<u></u>1\3\2/'<br>
1; 3; 2; 4;<br>
$<br>
<br>
Combining the 3 capture groups into one is left as an exercise for the<br>
reader :).<br>
<br>
Obviously, if any of the fields contain a ;, then that match won't do what<br>
you're wanting on that line.<br>
<br>
ciao,<br>
<br>
der.hans<span class="HOEnZb"><font color="#888888"><br>
-- <br>
#  <a href="http://www.LuftHans.com/" target="_blank">http://www.LuftHans.com/</a>        <a href="http://www.LuftHans.com/Classes/" target="_blank">http://www.LuftHans.com/<u></u>Classes/</a><br>
#  Wer bereit ist, grundlegende Freiheiten aufzugeben, um sich<br>
#  kurzfristige Sicherheit zu verschaffen, der hat weder Freiheit<br>
#  noch Sicherheit verdient.  --  Benjamin Franklin  (1706 - 1790)</font></span><br>---------------------------------------------------<br>
PLUG-discuss mailing list - <a href="mailto:PLUG-discuss@lists.phxlinux.org">PLUG-discuss@lists.phxlinux.org</a><br>
To subscribe, unsubscribe, or to change your mail settings:<br>
<a href="http://lists.phxlinux.org/mailman/listinfo/plug-discuss" target="_blank">http://lists.phxlinux.org/mailman/listinfo/plug-discuss</a><br></blockquote></div><br><br clear="all"><br>-- <br>Dazed_75 a.k.a. Larry<br>
<br>Please protect my address like I protect yours. When sending messages to multiple recipients, use the BCC: 
(Blind carbon copy). Remove addresses from a forwarded message body before clicking Send. <br>
</div>