[CentOS] OT: Script Help

Tue May 21 12:30:57 UTC 2013
John Doe <jdmls at yahoo.com>

From: James Pifer <jep at obrien-pifer.com>

> I have a long file that has lines like this:
> some text
> some text2
> CN=DATA.OU=XYZ.O=CO
> some text3
> some text4
> 
> 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

IFS="."; cat file | while read L; do set $L; if [ "$1" = "CN=DATA" ]; then P1=${1#CN=}; P2=${2#OU=}; echo "CN=${P2}_$P1.$2.$3"; else echo $*; fi; done

JD