Comparación de dos archivos para encontrar palabras coincidentes en Linux

Lets say we have two files as follows

File A.txt

Karthick is not so intelligent He is not lazy

File B.txt

karthick is not so bad either He is hard worker

so in the two files above, the commone words are "karthick is not so" & "He is" in each of the lines. Is there any way to print all such common lines with either grep command or some linux command?

preguntado el 08 de enero de 11 a las 17:01

you can try diff, but it's match line, not word -

You can find the intersection of two files with either grep -f file1 file2 or comm -12 file1 file2. Note that both commands require each word to be on a separate line. -

1 Respuestas

Quieres usar el dwdiff utility :).

Ejemplo de uso:

dwdiff "File A.txt" "File B.txt"

It might take a little while to get used to it's output, but check http://linux.die.net/man/1/dwdiff para más detalles sobre eso.

There are also several visual diff applications out there, but I prefer using it on the command line.

Respondido el 08 de enero de 11 a las 20:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.