[CentOS] OT: Script Help

Tue May 21 16:05:49 UTC 2013
Les Mikesell <lesmikesell at gmail.com>

On Sat, May 18, 2013 at 7:31 PM, James Pifer <jep at obrien-pifer.com> wrote:
>
> Let's say my original lines are:
> CN=DATA.OU=XYZ.O=CO
> CN=DATA.OU=XYY.OU=MEM.O=CO
> CN=DATA.OU=XZZ.OU=OOP.O=CO
>
> I want them to look like:
> CN=XYZ_DATA.OU=XYZ.O=CO
> CN=XYY_DATA.OU=XYY.OU=MEM.O=CO
> CN=XZZ_DATA.OU=XZZ.OU=OOP.O=CO
>
> So I need to take the data after the FIRST OU and stick in front of DATA
> with an _ in between. The rest of the line then remains the same.
>
> Hope it makes sense. Appreciate the help!

This should work as long as the first OU always follows CN=DATA.:

sed -e's/DATA.OU=\(\w*\)/\1_DATA.OU=\1/'

--
  Les Mikesell
     lesmikesell at gmail.com