So basically what I want to do is compare two file by line by column 2. How could I accomplish this?
User1 US User2 US User3 US
User1 US User2 US User3 NG
User3 has changed
Look into the
The command you'll want to do is
Additionally you might notice the 4th command is
Or you can use Meld Diff
Install by running:
Example with full of text:
Litteraly sticking to the question (file1, file2, outputfile with "has changed" message) the script below works.
Copy the script into an empty file, save it as
With a few extra lines, you can make it either print to an outputfile, or to the terminal, depending on if the outputfile is defined:
To print to a file:
To print to the terminal window:
FWIW, I rather like what I get with side-by-side output from diff
would give something like:
In addition there is
To suppress either column you can use switches -1, -2 , and -3. Using -3 will show the lines that differ.
Bellow you can see the screenshot of the command in action.
There is just one requirement - the files must be sorted for them to be compared properly.