I am trying to replace two lines in a file with one new line:
foo1.txt
aaa aaa
bbb bbb
ccc ccc
ddd ddd
bbb bbb
ddd ddd
after the replace the file should look like this
foo1.txt
aaa aaa
eee eee
ddd ddd
bbb bbb
ddd ddd
Is there a way with sed or some other command make this replace in all files of a folder
I have been trying with sed but without any success: sed 's/bbb\tbbb\nccc\tccc/eee\teee/g' foo*.txt
Even if this question should be already answered in this thread, I didn’t manage to make the “one-line-one-command” solution work.
This command:
seems not to work for me and doesn’t perform a multi-line replace. I had to split it in two different perl scripts, like this:
Try to see what works best for you.
EDIT:
With the new sample text, the only solution that works is the one by William Pursell