di98mase wrote:
Hi,
I have browsed old messages but I have not found any good answer to how
to substitute a end of line character.
This is what I want to do:
I have a file that ends like
myArray[someBigSize] = {
.
.
0x78u, 0x0f
};
So I want sed to find the eol and replace it so that the file looks
like
0x78u, 0x0fu
};
i.e. the 'u' is added but the rest is keept intact.
This is what I tried to do
sed "s/\n\}\;/u\n\}\;/" < myFile.c
But this wont do it for me?
Why?
If you want to search only the last 3 lines for the replacement, you
may try:
perl -0777pe 's/(\S)([\n\s]*};\s*)\z/\1u\2/' myfile.txt
which slurps in the whole file as a string and then modifies it, or
tac myfile.txt | sed '3s/$/u/' | tac
looks clumsy, but it should work, :-)
Xicheng