user3543599
user3543599

Reputation: 13

Sort data with linux shell

I try to sort data

aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa
aaaaaaa

to get 3 items per line and separate by ,. as usual ,i will use split --line=3 after that sort with paste -s x* -d',' >result ,any shorter way to achieve my goal . The result:

aaaaaaa,aaaaaaa,aaaaaaa
aaaaaaa,aaaaaaa,aaaaaaa
aaaaaaa,aaaaaaa,aaaaaaa
aaaaaaa

Thanks much.

Upvotes: 1

Views: 50

Answers (1)

BMW
BMW

Reputation: 45243

the sample data is terrible, can you update it? Otherwise, no one understands your question.

Here I try to guess your request:

sort file |paste - - -  -d,

for 100 per line

sort file |xargs -n100 |sed 's/ /,/g'

Upvotes: 1

Related Questions