0

I have data like this:

A 


B

C  D


E 
F

G

H I

I want it to look like this:

A,B,C
D,E,F
G,H,I

How can I achieve this using command-line tools?


This question has each data-cell on its own line: How to convert rows to columns in unix

sdgfsdh
  • 33,689
  • 26
  • 132
  • 245
  • What is your exact input? What is your exact output? Without those, it is not easy to provide suggestions – Inian May 15 '18 at 13:45
  • .. and what did you try for yourself? – Inian May 15 '18 at 13:45
  • @Inian The data is too big (and confidential) to post on here. A solution I know how to do would involve JavaScript / Python, but I think it would be quicker to use existing commands – sdgfsdh May 15 '18 at 13:47

1 Answers1

1

Following command could help you.

xargs -n 3 <  Input_file |  tr ' ' ','
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • Sorry, I got my data a bit wrong. Sometimes the columns are on the same line and separated by spaces. – sdgfsdh May 15 '18 at 13:43
  • @sdgfsdh, please check once given links and see if they help you, let us know on same then. – RavinderSingh13 May 15 '18 at 13:44
  • my data is not as clean as in those links – sdgfsdh May 15 '18 at 13:46
  • @sdgfsdh: For the input given in question, the above answer should work. If the input is not as one in question, modify it to show us the actual question – Inian May 15 '18 at 13:46
  • 1
    @sdgfsdh: did you run the answer on your input in question, it produced a comma separated format as expected – Inian May 15 '18 at 13:48