I am running the following 2 sed
commands. The first one adds newline characters where I want them, the second also adds newline characters where I want them, BUT also adds an extra one at the end of the file where there wasn't one before.
sed -e 's|\<LIST_G_STATEMENT>|&\
|g' ${XMLDIR}/statement_tmp_1.xml > ${XMLDIR}/statement_tmp_2.xml
sed -e 's|\</LIST_G_STATEMENT>|&\
|g' ${XMLDIR}/statement_tmp_2.xml > ${XMLDIR}/statement_tmp_3.xml
Using od -c
on all 3 of the files gives the following output.
statement_tmp_1.xml (no \n
at end of file)
1314700 T A T E M E N T > < / L I S T _
1314720 G _ S T A T E M E N T > < / G _
1314740 S E T U P > < / L I S T _ G _ S
1314760 E T U P > < / A R X S G P O >
1314777
statement_tmp_2.xml (no \n
at end of file)
1314700 S T A T E M E N T > < / L I S T
1314720 _ G _ S T A T E M E N T > < / G
1314740 _ S E T U P > < / L I S T _ G _
1314760 S E T U P > < / A R X S G P O >
1315000
statement_tmp_3.xml (\n
at end of file - where did it come from?)
1314700 S T A T E M E N T > < / L I S T
1314720 _ G _ S T A T E M E N T > \n < /
1314740 G _ S E T U P > < / L I S T _ G
1314760 _ S E T U P > < / A R X S G P O
1315000 > \n
1315002
I am running AIX 5.3
Basically, I either want it to stop adding the extra \n
, or find a way of removing it.
s|...|&\n|
just as well?\n
in the right hand side is not portable.perl
or other tool that can deal with binary data.\<LF>
is the traditional and POSIX way to add a LF character.\n
would typically substitute an
character in anything but GNUsed
.