![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| compare files | danabo | Shell Programming and Scripting | 3 | 05-19-2008 01:09 PM |
| compare two files | charandevu | Shell Programming and Scripting | 7 | 03-30-2008 04:20 PM |
| Compare files | kharen11 | UNIX for Advanced & Expert Users | 25 | 03-14-2007 05:35 AM |
| Compare files | Berserk | Shell Programming and Scripting | 6 | 09-05-2005 05:04 AM |
| compare files | ingunix | UNIX for Dummies Questions & Answers | 3 | 05-24-2001 12:44 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Compare between two files
Hello. For example, I have a list like this inside a text file called "list.txt"
list.txt ----------------------------------------------------- 01-01-2009 15:50 grapes 2$ 01-01-2009 15:56 tea 4$ 04-01-2009 20:30 oranges 1$ 05-01-2009 17:20 carrots 3$ 05-01-2009 17:34 milk 5$ ----------------------------------------------------- I have another text file, "products.txt", full of lines like this: products.txt ------------------------ car grapes table chair oranges ------------------------ I'm looking for a Bash command able to compare "list.txt" with "products.txt" and if a word is found in both lists, as "grapes and oranges", then Bash could print another list like this: --------------------------------------------------------- 01-01-2009 15:50 grapes 2$ 04-01-2009 20:30 oranges 1$ --------------------------------------------------------- I'm able to do that, but using a macro in Excel, but I would like to do it with GNU/LInux and give up Windows. I have been trying with awk, sed, but I don't know how to do it. Thanks and excuse my very bad knowledge about bash and about English language. |
|
||||
|
Thank you very much for answering my question, dear jim mcnamara.
I'm afraid that code, grep -f, doesn't work very well because it confuses words like "car", located in the products.txt file, with words beginning with the letters car, like "carrots", located in the list.txt file. Anyway I think that your code "grep -f" can facilitate my job, but I must brush up later all the files, by hand, to erase the possible mistakes written in the output list. Again, thanks a lot for your answer. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|