Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

;

I need this:

22791;14336;22821;34653;21491;25522;33238;

EDIT

None of these commands is working perfectly.

Most of them let the data look like this:

22791

;14336

;22821

;34653

;21491

;25522
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.5k views
Welcome To Ask or Share your Answers For Others

1 Answer

tr --delete '
' < yourfile.txt
tr -d '
' < yourfile.txt

Edit:

If none of the commands posted here are working, then you have something other than a newline separating your fields. Possibly you have DOS/Windows line endings in the file (although I would expect the Perl solutions to work even in that case)?

Try:

tr -d "

" < yourfile.txt

If that doesn't work then you're going to have to inspect your file more closely (e.g. in a hex editor) to find out what characters are actually in there that you want to remove.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...