I understand to find the differences between files you would use
diff *file1 file2*
But say you only wanted to know the differences between the two files on lines that contained a specific word, say the word “linux” for example. How would you write the command for that? Would it be something like:
diff [linux] *file1 file2*
Or would you even use diff at all for this command?
Advertisement
Answer
Use the below command to find the diff between two files and filter the string “linux” diff
diff file1 file2 | grep 'linux' -B1 -A2