$ seq 1 `cat a.txt | wc -l` > tmp.txt; diff a.txt tmp.txt; rm tmp.txt
とかでよくね