So basically what I want to do is compare two file by line by column 2. How could I accomplish this?
File_1.txt:
User1 US
User2 US
User3 US
File_2.txt:
User1 US
User2 US
User3 NG
Output_File:
User3 has changed
command linetext processing
So basically what I want to do is compare two file by line by column 2. How could I accomplish this?
File_1.txt:
User1 US
User2 US
User3 US
File_2.txt:
User1 US
User2 US
User3 NG
Output_File:
User3 has changed
Best Answer
Look into the
diff
command. It's a good tool, and you can read all about it by typingman diff
into your terminal.The command you'll want to do is
diff File_1.txt File_2.txt
which will output the difference between the two and should look something like this:A quick note on reading the output from the third command: The 'arrows' (
<
and>
) refer to what the value of the line is in the left file (<
) vs the right file (>
), with the left file being the one you entered first on the command line, in this caseFile_1.txt
Additionally you might notice the 4th command is
diff ... | tee Output_File
this pipes the results fromdiff
into atee
, which then puts that output into a file, so that you can save it for later if you don't want to view it all on the console right that second.