How do I remove newlines from a text file?

后端 未结 19 2405
遇见更好的自我
遇见更好的自我 2020-11-29 17:34

I have the following data, and I need to put it all into one line.

I have this:

22791

;

14336

;

22821

;

34653

;

21491

;

25522

;

33238

;
         


        
19条回答
  •  情书的邮戳
    2020-11-29 18:03

    Assuming you only want to keep the digits and the semicolons, the following should do the trick assuming there are no major encoding issues, though it will also remove the very last "newline":

    $ tr -cd ";0-9"
    

    You can easily modify the above to include other characters, e.g. if you want to retain decimal points, commas, etc.

提交回复
热议问题