Posted By: Anonymous
There are two files called “a.txt” and “b.txt” both have a list of words. Now I want to check which words are extra in “a.txt” and are not in “b.txt”.
I need a efficient algorithm as I need to compare two dictionaries.
Here is my solution for this :
mkdir temp mkdir results cp /usr/share/dict/american-english ~/temp/american-english-dictionary cp /usr/share/dict/british-english ~/temp/british-english-dictionary cat ~/temp/american-english-dictionary | wc -l > ~/results/count-american-english-dictionary cat ~/temp/british-english-dictionary | wc -l > ~/results/count-british-english-dictionary grep -Fxf ~/temp/american-english-dictionary ~/temp/british-english-dictionary > ~/results/common-english grep -Fxvf ~/results/common-english ~/temp/american-english-dictionary > ~/results/unique-american-english grep -Fxvf ~/results/common-english ~/temp/british-english-dictionary > ~/results/unique-british-english