Как сделать Сравните два файла слово за словом, и он должен показать, в какой строке и в какой позиции присутствуют различия.

Tuve este problema y descubrí (gracias a @datUser )que la coloración puede provocar que sucedan muchas cosas extrañas en los terminales. Puede eliminar esto para la ejecución de un solo comando prefijándolo con '\', así que intente iniciar mysql usando \mysql. Eso funcionó para mí.

-3
25.01.2017, 18:42
2 ответа

Вы можете использовать diff , чтобы увидеть, какие строки отличаются в каждом файле.

diff file1.txt file2.txt

, и в этом случае вы получите другую строку:

file1.txt:

"same line,

same line,

different line,

same line."

file2.txt:

"same line,

same line,

same line,

same line."

$> diff file1.txt file2.txt

< line 3 : different line,
----------------------
> line 3 :  same line,
0
28.01.2020, 05:18

Используйте cmp :

$ cat file1.txt
This file
is the same
as the other

$ cat file2.txt
This file
is almost the same
as the other

$ cmp file1.txt file2.txt
file1.txt file2.txt differ: char 14, line 2

char 14 относится к первому символу в файле , который отличается.

Для визуального представления разницы слов используйте wdiff :

$ wdiff file1.txt file2.txt
This file
is {+almost+} the same
as the other
5
28.01.2020, 05:18

Теги

Похожие вопросы