0

I have a text (.qdp) file with many data stored. In some rows, the data are too many to be on just one line. Then, the program that saves the data, use a minus sign (-) to go on the new line, and continue the data writing, with two blank spaces at the beginning of the new line. How can I find and replace the minus plus the two blank spaces, in order to rewrite the data without any interruption? This is an example of what I have:

1 2 3 4 5 6 7-
  8 9 10

And here what I want:

1 2 3 4 5 6 7 8 9 10
2

If I understood correctly your problem this should work:

sed '/-$/ {N;s/-\n  / /}' your_file.qdp
  • Yep, it is this. How can I do it into the .qdp file? – Py-ser Feb 28 '14 at 8:08
  • @Py-ser - sed '/-$/ {N;s/-\n / /}' your_file.qdp > new_file.qdp – slm Feb 28 '14 at 8:16
  • So, must I create a new file? – Py-ser Feb 28 '14 at 8:24
  • 1
    @Py-ser You can use sed -i if you really want to replace directly in original file. – Laurentiu Roescu Feb 28 '14 at 8:32
  • use -i instead: sed -i.bak'/-$/ {N;s/-\n / /}' your_file.qdp – cuonglm Feb 28 '14 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.