use 'gawk' if you can:
Code:
#
# set the RecordSeparator to '<CRM:'
#
# for the FIRST line - reevaluate the record equal to itself
# for any OTHER line - reevaluate the record appending the RecordSeparator
# to the beginning of the record.
#
# after the reevaluattion is done - PRINT the record. 'PRINT' is implicit as a
# result of the record re-evaluation.
#
gawk -v RS='<CRM:' '$1=(FNR==1) ? $1 : RS $1' myFile
or with any other awk without using an RS:
Code:
# for the FIRST line/record - print it out (withOUT a new line) and o to the next line
FNR==1 { printf ;next }
#
# for any OTHER (other than the first) line/record:
# if the line/record starts with '<CRM:' - print the new line '\n' followed by
# a line itself.
# if the line/record does NOT start with '<CRM:' - print the line withOUT
# a new line '\n'
{printf (/^<CRM:/) ? "\n" $0 : $0}
# print new line '\n' after the LAST line processed
END { printf "\n" }