Urgent help needed on merging lines with similar words
Hi everyone,
I need help with a merging problem. Basically, I have a file with several lines (in this example 9 lines) such as:
Amie, Jay, Sasha, Rob, Kay
Mia, Frank
Jay, Nancy, Cecil
Paul, Ked, Nancy, 17, Fred
14, 16, 18, 20
9, 11
12, Frank
18, Peter, 62
Nancy, 27
A delimiter is always there (e.g. comma).
What I'm wanting is to merge lines which have similar elements (words/numbers/etc) in them, and get something like the file below:
Amie, Jay, Sasha, Rob, Kay, Nancy, Cecil, Paul, Ked, 17, Fred, 27
14, 16, 18, 20, Peter, 62
9, 11
Mia, Frank, 12
The ordering of lines is not important. In the resulting file, lines have nothing in common. The problem is finding an efficient way of doing this, especially when the files are large (3-30 MB of data).
Is there a shell script capable of doing this?
Appreciate all useful hints.
Last edited by awb221; 02-23-2009 at 08:54 PM..