Gea Planet
Gea Planet

Reputation: 197

Why diff is not working as expected?

I have two files with a lot of paths and I want to compare them. But I don't know why it is not working with some of lines: The same line is in the snapshot1 and snapshot2 and diff continues showing them, why?

root@minino:/tmp/diffshot# cat snapshot1|grep "MARCOS/lapiz.png"
-rw-r--r-- 1 minino minino 35247 may 19  2013 /home/minino/Imágenes/FONDOS/MARCOS/lapiz.png

root@minino:/tmp/diffshot# cat snapshot2|grep "MARCOS/lapiz.png"
-rw-r--r-- 1 minino minino 35247 may 19  2013 /home/minino/Imágenes/FONDOS/MARCOS/lapiz.png

root@minino:/tmp/diffshot# diff snapshot1 snapshot2 |grep "MARCOS/lapiz.png"
< -rw-r--r-- 1 minino minino 35247 may 19  2013 /home/minino/Imágenes/FONDOS/MARCOS/lapiz.png
> -rw-r--r-- 1 minino minino 35247 may 19  2013 /home/minino/Imágenes/FONDOS/MARCOS/lapiz.png

Upvotes: 2

Views: 903

Answers (1)

sdayal
sdayal

Reputation: 1166

try sorting first

cat snapshot1 | sort | uniq > snapshot1sorted

cat snapshot2 | sort | uniq > snapshot2sorted

diff -w snapshot1sorted snapshot2sorted |grep "MARCOS/lapiz.png

Upvotes: 1

Related Questions