Replace end of lines with commas in sed

Need to extract numbers and create a comma separated list:

$ sed -e :label -e N -e ‘s/\n/, /’ -e ‘s/[ |]//g’ -e tlabel <<xxxx
> |     919 |
> |    1027 |
> |    1593 |
> |    1595 |
> xxxx
919,1027,1593,1595

 

 

This entry was posted in unix and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>