I'd like the output of the uniq command to be comma separated, so that instead of:
30 hello
31 world
36 hey_there
142 i_am_bigest
I'll get:
30,hello
31,world
36,hey_there
142,i_am_biggest
My input has no spaces, but just using sed
or tr
can be a problem since the number of leading spaces varies according to the number of decimal digits in the count.
Pipe the output to
sed -e 's/^ *//;s/ /,/'
This first removes the leading spaces (^ *
) then replaces the first space with a comma.