I have a file, which has data in one column and 200 rows (200*1).
I want to get this data in a single row with comma separated.
Example File
Paul
Pammy
Jacob
Robin
Output
Paul, Pammy, Jacob, Robin
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using
sed:Explanation:
I am no expert on
sed, but this is what the above one-liner means::a:labelcommand creates a named labela. This when used withbabranches to the label. This is useful for creating loops and escaping to the end of the script to print the current pattern space.NNjust appends the next line to the pattern space with\n.s/\n/, /Since the new line has been appended to the pattern space with a
\n, we use this substitution to replace the\nwith a,andspaceas per the requirements of OP.Test: