I have a file that looks like this:
dee 123
bee 555
dee 56
cee 29
dee 30
cee 13
I need the output like this:
dee 123,56,30
bee 555
cee 29,13
How can I perform this task using perl one-liners?
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.
Output:
Explanation:
-aautosplit input line on whitespace-lhandle newlines-nassumewhile(<>)loop around program@Farray comes from autosplit,$F[0]and$F[1]are the array elements.%ais where we store results, first column as keys, second in the value as an array}{the eskimo operator, with the-nswitch does the same as anENDblockIn the last section we just print the keys and values.