Urgent help needed on merging lines with similar words


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent help needed on merging lines with similar words
# 1  
Old 02-23-2009
Lightbulb 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..
# 2  
Old 02-23-2009
Do your own school work mate
# 3  
Old 02-23-2009
hi

try to grep numbers and words separately and use paste to print Smilie
simple
# 4  
Old 02-23-2009
Thanks for the PM awb221,

Your silly remark gave me a laugh, I always appreciate a laugh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging two columns from two files with similar names into a loop

I have two files like this: fileA.net A B C fileA.dat 1 2 3 and I want the output output_expected A 1 B 2 C 3 I know that the easier way is to do a paste fileA.net fileA.dat, but the problem is that I have 10,000 couple of files (fileB.net with fileB.dat; fileC.net with... (3 Replies)
Discussion started by: valente
3 Replies

2. Shell Programming and Scripting

match sentence and word adn fetch similar words in alist

Hi all, I have ot match sentence list and word list anf fetch similar words in a separate file second file with 2 columns So I want the output shuld be 2 columns like this (3 Replies)
Discussion started by: manigrover
3 Replies

3. Shell Programming and Scripting

Merging words splitted into characters with awk

I have an OCR output with some words splitted into single characters separated by blank spaces, and I want the same text with these words written correctly. Example: This is a text w i t h some s p l i t e d W o r d s . The regular expression for matching splitted words could be something... (5 Replies)
Discussion started by: dokamo
5 Replies

4. Shell Programming and Scripting

merging similar columns in a single line file

Hi Guys. I have tried the commands sort and join. But I couldn't able to to find the command for joining in a single line based on keys.My example inputs and outputs are like the following. Help would be appreciated.:D Input file a1tabXXXXXXX a2tabXXXXXXX a6tabYYYYYYYYY a71tabXXXXXXX... (7 Replies)
Discussion started by: repinementer
7 Replies

5. Shell Programming and Scripting

merging similar lines

Greetings, I have been trying to merge the following lines: Sat. May 9 8:00 PM Sat. May 9 8:00 PM CW Sat. May 9 8:00 PM CW Cursed Sat. May 9 9:00 PM Sat. May 9 9:00 PM CW Sat. May 9 9:00 PM CW Sanctuary Sat. May 16 8:00 PM Sat. May 16 8:00 PM CW Sat. May 16 8:00 PM CW Sanctuary Sat. May... (2 Replies)
Discussion started by: adambot
2 Replies

6. Shell Programming and Scripting

awk help needed in trying to count lines,words and characters

Hello, i am trying to write a script file in awk which yields me the number of lines,characters and words, i checked it many many times but i am not able to find any mistake in it. Please tell me where i went wrong. BEGIN{ print "Filename Lines Words Chars\n" } { filename=filename + 1... (2 Replies)
Discussion started by: salman4u
2 Replies

7. UNIX for Dummies Questions & Answers

merging 2 lines with awk and stripping first two words

Hey all i am pretty new to awk... here my problem. My input is something like this: type: NSR client; name: pegasus; save set: /, /var, /part, /part/part2, /testpartition, /foo/bar,... (9 Replies)
Discussion started by: bazzed
9 Replies

8. Shell Programming and Scripting

Urgent : Merge similar lines

Hi, I have a file like this. please notice that ./usr/orders1/order_new_2627 appears more than once, thus needs to be merged. I would like to merge the lines where the first column match so the output should be like this: Please help (2 Replies)
Discussion started by: rakeshou
2 Replies

9. Shell Programming and Scripting

Urgent Need Help! Merging lines in .txt file

I need to write a script that reads through an input .txt file and replaces the end value with the end value of the next line for lines that have distance <=4000. The first label line is not actually in the input. In the below example, 3217 is the distance from the end of the first line to the... (12 Replies)
Discussion started by: awknerd
12 Replies

10. UNIX for Dummies Questions & Answers

similar words

hi i have created a pipe which outputs a list of words such as: hello yay foo yah good goof and from this i want to find words which only differ by their last letters ie yay/yah and good/goof. i would only need to print out the first instance of the word. these words are not... (1 Reply)
Discussion started by: Streetrcr
1 Replies
Login or Register to Ask a Question