Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am making a csv constructor but I have some problems.

I have files like this characteristics.tmp

1083108343
1083108360
1083108378
1083108386

I have to build to this format: Name, "1083108343 ,1083108360 , 1083108378,1083108386";
I tried this

cat characteristics.tmp| paste -s -d, -

I also tried tr ' ' ','

But the output is like if there is only one element. I check the file with xxd and the character 0d0a is as it should be in the end of every line? So why is not detecting the others?

,1083108386


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

1 Answer

Cyrus bro thank you very much. I have the solution may be useful for someone

The file have 0d0a in all end lines that is like windows works. That is why when i pass to xxd this 0d0a appears and bash works only with 0a for new line so I pass the file to dos2unix as you said and results the file is only with 0a that is the new line that is the way unix works.

BEFORE

xxd file.tmp

00000000: 3130 3633 3234 3234 3432 **0d0a** 1063242442..

AFTER dos2unix

00000000: 3130 3633 3234 3234 3432 **0a** 1063242442.

And finally all the commands like xargs,tr,paste works correct.

Thanks to everyone :D


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