Finding common words from 2 files using the Linux command and writing them to a new file.

Finding common words from 2 files using the Linux command and writing them to a new file.

Completed learning basic Linux commands so I have decided to implement it in a project which can find common words from 2 different files and create a new file that contains those words First, I start by creating a working directory I used the "mkdir" command for this and it as a working directory.

Screenshot (14).png

Then I created 2 new files inside a working directory using "cat >" and added a few words.

Screenshot (15).png

The next step is to find out common words for this purpose "diff" command comes into the picture and writes that output inside on temporary file.

Screenshot (16).png

In order to separate common and uncommon words, I used "grep" with " "(blank space )for common words) and "-" for uncommon words.

Screenshot (17).png

Still, it's not what I was expecting so I used "tail" command to write the last 2 elements in the output file.

Screenshot (18).png here is final output

Screenshot (18).png