[CentOS] OT: Script Help
Peter Eckel
lists at eckel-edv.deTue May 21 18:45:17 UTC 2013
- Previous message: [CentOS] OT: Script Help
- Next message: [CentOS] 6.4 on old PC not connecting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi James, perl -pne 's/^(CN=)(DATA\.OU=)((.*?)\.O=CO)$/$1$4_$2$3/' /file/name or, if you prefer in-place editing, perl -i.bak -pne 's/(CN=)(DATA\.OU=)((.*?)\.O=CO)/$1$4_$2$3/' /file/name which replaces the file with the modified version and keeps a .bak file around for security. Example: lagavulin:~ pete$ cat /tmp/test some text some text2 CN=DATA.OU=XYZ.O=CO some text3 some text4 some text some text2 CN=DATA.OU=RST.O=CO some text3 some text4 some text some text2 CN=DATA.OU=ABC.O=CO some text3 some text4 some text some text2 CN=DATA.OU=UVWXYZ.O=CO some text3 some text4 lagavulin:~ pete$ perl -pne 's/(CN=)(DATA\.OU=)((.*?)\.O=CO)/$1$4_$2$3/' /tmp/test some text some text2 CN=XYZ_DATA.OU=XYZ.O=CO some text3 some text4 some text some text2 CN=RST_DATA.OU=RST.O=CO some text3 some text4 some text some text2 CN=ABC_DATA.OU=ABC.O=CO some text3 some text4 some text some text2 CN=UVWXYZ_DATA.OU=UVWXYZ.O=CO some text3 some text4 I guess that's what you need. Best regards, Peter.
- Previous message: [CentOS] OT: Script Help
- Next message: [CentOS] 6.4 on old PC not connecting
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list