Converting vertical items into Horizontal plz

Hi all im able to convert vertical into horizontal as follows using tr '\n' ','
to convert
1111
2222
3333
4444 as to 1111,2222,3333,4444,

but im getting comma at end.. i want to remove the comma at end..

using sed we can do.... but it is limited to some numbers only...

can anybody give me the alternate solution so that it can apply for n no of numbers (ex 10000 numbers) and remove the comman at the end..
as output below
1111,2222,3333,4444

Thanks in advance

Prakash

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

******************************************************

Not sure if I got the problem; example with GNU sed:

> cat infile
11111111111111
22222222222222
33333333333333
44444444444444
55555555555555
$> sed -e :a -e '{N; s/\n/,/g; ta}' infile
11111111111111,22222222222222,33333333333333,44444444444444,55555555555555

One way of doing it with Perl:

$
$ cat f1
1111
2222
3333
4444
$
$ perl -ne 'chomp; push @x,$_; END {print join ",", @x; print "\n"}' f1
1111,2222,3333,4444
$
$

tyler_durden

Hi.

For some versions of paste, e.g.paste (GNU coreutils) 6.10:

paste -d, -s infile

results:

1111,2222,3333,4444

I did *not* try it with thousands of lines ... cheers, drl

Edit 1:

This *did* work on 10,000 lines ... cheers, drl