4

Use sed to fix broken newlines

view full story
linux-howto

http://unix.stackexchange.com – I have a folder full of files, each with many hundreds of lines. Many of these files have occasional broken newlines: when I open them in vim, many have ^M^L interspersed where newlines should be. In vim, I can run %s/^M^L/\r/g which will correct them. However, I don't want to have to do this to every file. So I'm trying to do this in a bash script via sed, but it hasn't worked. I've tried both: sed 's/^M^L/\r/g' filename and sed 's/^M^L/\ /g' filename Note: each time ^M^L appears here, I have done ctrl-v ctrl-m, not just shift-6 (^) M. What am I doing wrong? More to the point, wh (HowTos)