How to do grap data between two file in Linux?

Posted by user28167 on Super User See other posts from Super User or by user28167
Published on 2010-05-06T13:37:07Z Indexed on 2010/05/06 13:38 UTC
Read the original article Hit count: 234

Filed under:
|
|
|

I have two .rtf file.... The first one have this content:

Apple, Orange, Banana, Noodle, Chip

The Second File is something like this:

     Apple I love eat Apple.
     Banana I hate Banana.
     Zoo I want to go Zoo.
     Noodle Noodle can be a very very very very very very very very very very very long, but still is one line.
     Chip Don't eat so many chip. 
     Orange Orange is great, not Apple plx. Noodle
     Water Drinking water is boring.

The first file is a "key" of second file. In the second file, the first word is the key of each line. Each key and sentence in second file ONLY have one line. The Second File have many lines with key, but not all the key is shown on file1, but file1's key MUST in the second file. How can I get the result like this: (Need to sort by the key from File1)

  Apple, Apple I love eat Apple. 
  Orange, Orange is great, not Apple plx.
  Banana, I hate Banana. 
  Noodle, can be a very very very very very very very very very very very long, but still is one sentence. 
  Chip, Don't eat so many chip.

© Super User or respective owner

Related posts about linux

Related posts about command-line