Re: OT: Script Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Sat, May 18, 2013 at 1:15 PM, James Pifer <jep@xxxxxxxxxxxxxxxx> wrote:
> Sorry for the off topic, but don't a better resource. I'm not great at
> scripting, but need a quick script to modify a file.
>
> I have a long file that has lines like this:
>
> some text
> some text2
> CN=DATA.OU=XYZ.O=CO
> some text3
> some text4
>
> And this repeats, but XYZ changes. "DATA" is always called data. (it's
> being renamed basically)
>
> I need to change the middle line but leave the rest of the file as is
> like this:
>
> some text
> some text2
> CN=XYZ_DATA.OU=XYZ.O=CO
> some text3
> some text4
>
> Anyone know a quick way to do this? Any help is appreciated.

cat file | sed -e's/CN=DATA.OU=\(.*\)\.O=CO/CN=\1_DATA.OU=\1.O=CO/'
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux