Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to merge the following multiple lines of output so that they form a single line:

line 1:

,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,8,0,,0, ,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,1227,,,11,,0,,,,1,01,,,1,12769,,7707,0,,,,12769,,,12769,6,0,,,,10,,,1, 901,10800,14/04/13,,,4,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,12769,0,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,17 ,,,,,,,,,31685125704,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.901,19,0,.901,,,901,1,,,8767318,13790084045,1, 1304150024556817,,,,33399399,,,,,,,,,,,,901,1,,,,,,0,,0,,,,,,GSMT11B**S,,,4,,,,,,10800,14/04/1 3,10800,14/04/13,443867992,,,,,,,,1,0,,0,,,,,,,61409,51,,,9647507763683,,1001,1,0,,60,0,5,,N,,0,1,I, 1,,,,,,47,,,,,54,1,4,19,,29,1,1,1,3,1112,2,,Usage,Usage,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1, 1,1,1,1,34111,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0

...blank line...

line 2:

,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,8,0,,0, ,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,399,,,11,,0,,,,1,01,,,1,61,,67,0,,,,61,,,61,6,0,,,,10,,,1,74,10800,14/ 04/13,,,4,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,61,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,, 14/04/13,10800,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,17,,,,,,,,,9647703 026865,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.061667,19,0,.061667,,,74,1,,,8820807,13790084046,1,130415002 4556817,,,,33399399,,,,,,,,,,,,74,1,,,,,,0,,0,,,,,,GSMT11B**S,,,4,,,,,,10800,14/04/13,10800,14 /04/13,443867993,,,,,,,,1,0,,0,,,,,,,61409,51,,,9647503228592,,1001,1,0,,60,0,5,,N,,0,1,I,1,,,,,,20, ,,,,25,1,4,19,,19,1,1,1,3,980,2,,Usage,Usage,USG,,N,N,0,,1,,ASIA03I,90,,0GRI3,90,,,,,0,1,1,1,1,1,341 12,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0

...blank line...

line 3:

,,,1,,,,,,,,18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,42,1,121,1,17,10,21,1,,IU,8,0,,0, ,0,0,0,,,,,,,,,,,,,,,,,,,,,,,,327,,,11,,0,,,,1,01,,,1,12769,,7707,0,,,,12769,,,12769,6,0,,,,10,,,1,2 ,10800,14/04/13,,,4,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,,1001,,,,,,,,,,,01,,12769,0,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,14/04/13,10800,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,964750001210,,1001,,1,,0,,,,,,,,,,,,17,,, ,,,,,,96171254836,,,,1,,1,0,,,,,,,,,,,,,,,,,,19,0,.002,19,0,.002,,,2,1,,,8825322,13790084047,1,13041 50024556817,,,,33399399,,,,,,,,,,,,2,1,,,,,,0,,0,,,,,,GSMT11B**S,,,4,,,,,,10800,14/04/13,10800 ,14/04/13,443867994,,,,,,,,1,0,,0,,,,,,,61409,51,,,9647501378572,,1001,1,0,,60,0,5,,N,,0,1,I,1,,,,,, 47,,,,,54,1,4,19,,29,1,1,1,3,1112,2,,Usage,Usage,USG,,N,N,0,,1,,TRNT01I,90,,0GRI3,90,,,,,0,1,1,1,1,1 ,34113,437956,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,,,,H,,1,0,1,0

...blank line...

share|improve this question
4  
Please, give a better explanation of what you want to achieve. What is the input and what is the expected output? Also please use the formatting features of Stackexchange. –  Raphael Ahrens Sep 6 '13 at 10:22
add comment

closed as unclear what you're asking by Gilles, slm, jasonwryan, Anthon, Mat Sep 7 '13 at 6:47

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

If I understand your question correctly you have the following:

$ echo -e "line1\nline2\nline3\n"
line1
line2
line3

$

And you want this:

line1line2line3

So you should only need to remove the blank lines. A command like this should do it:

$ echo -e "line1\nline2\nline3\n" | paste -s -d ''
line1line2line3

I'm not sure where your output is being kept, but if it was in a file you chould use the above to merge the lines:

$ paste -s -d '' somefile.txt 
line1line2line3
share|improve this answer
add comment

Another approach would be to simply remove the new lines from your file:

echo $(tr -d '\n' < file) > newfile

I am using the echo to insert a final new line, if you dont even want that just run

tr -d '\n' < file > newfile
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.