Compare differences between 2 custom lists

  1. Create a list of the first items in ‘/tmp/1
  2. Create your second list in ‘/tmp/2
  3. Find items that are in /tmp/1, but not in /tmp/2
    • for i in $(cat /tmp/1);do grep “$i” /tmp/2 > /dev/null || echo $i;done
  4. Find items that are in /tmp/2, but not in /tmp/1
    • for i in $(cat /tmp/2);do grep -o “$i” /tmp/1 > /dev/null || echo $i;done

Compare difference between files

*** Very useful for configuration files – old vs new

  1. Define the 2 files you want to compare against (these variables will only be defined until you log out)
    • FILE1=”path/to/file1
    • FILE2=”path/to/file2
  1. Run this command to see the differences:
    • clear;echo “Lines in $FILE1 that are not in $FILE2”;grep -nFxvf $FILE2 $FILE1; echo “”;echo “Lines in $FILE2 that are not in $FILE1”;grep -nFxvf $FILE1 $FILE2

Leave a Reply

Your email address will not be published. Required fields are marked *