Wednesday, 11 September 2013

Conditional replacement of new line character with sed

Conditional replacement of new line character with sed

I have a corrupted text file in which I need to replace \n and/or \r with
\xa0 if next line (if exists) does no start with specific pattern DATA\t.
Can I do it with sed? Text file is about 1MB of size.



Data Example:
DATA 132942, "I love you", 2398, "Hi how are you"
DATA 78793, "It is
me", 4322, "My name is Frank"
DATA 24121, "Where
are
you", 52432, "I am
here"
DATA 43242, "End of story", 432432, "The end"
=>
DATA 132942, "I love you", 2398, "Hi how are you"
DATA 78793, "It is me", 4322, "My name is Frank"
DATA 24121, "Where are you", 52432, "I am here"
DATA 43242, "End of story", 432432, "The end"

No comments:

Post a Comment