Sample Header Ad - 728x90

How to color diff output?

91 votes
16 answers
117435 views
I wanted to format the Unix files conditionally, I am currently working on diff command and wanted to know if it is possible to format the text of the diff command output. Example: >Matched values should be displayed in green. Unmatched values should be displayed in red. Suppose I have two files file1 and file2 and my command is diff file1 file2 . Now I wanted that suppose output contain 5 mismatch then those mismatch should be displayed in Red color. How to achieve this using unix? In short "Change color to red for the output of diff command for values which mismatch"
Asked by Aman (1281 rep)
Apr 16, 2015, 10:11 AM
Last activity: Jul 25, 2025, 03:26 PM