linuxcommand-line-interface

Compare specific sections from two different files


I am on Linux and I have two files a.txt and b.txt that I would like to compare. However there is a catch.

  1. I know for a fact the the first few lines of both files are different and I don't care about the first few differences (They are irrelevant).

  2. I would like to make sure that after the first few lines, everything else is matching just fine.

I already looked up the command diff and it didn't have an option that would clip the comparison to specific sections


Solution

  • I managed to find to solve the issue by knowing exactly the number of differences in the first few lines and counting onwards from there.

    diff a.txt b.txt &> log.log
    wc -l <"log.log") != <known number of differences>