Сравнивайте с английским: нажмите на абзац — оригинал откроется в окне. Кнопка EN под абзацем показывает его прямо в тексте.
Содержание
Введение
Утилита сравнения компьютерных файлов
Computer file comparison utility
В вычислительной технике, `cmp` — это командная утилита в Unix и Unix-подобных операционных системах, которая сравнивает два файла любого типа и выводит результаты в стандартный поток вывода. По умолчанию, `cmp` не выводит никакой информации, если файлы идентичны; если они различаются, сообщается номер байта и строки, в которых обнаружено первое расхождение. Команда также доступна в командной оболочке OS 9.
In computing, cmp is a command line utility on Unix and Unix like operating systems that compares two files of any type and writes the results to the standard output. By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported. The command is also available in the OS 9 shell.
История
является частью X/Open Portability Guide начиная с выпуска 2 1987 года. Она была включена в первую версию POSIX.1 и Единую спецификацию Unix. Впервые она появилась в Unix версии 1. Версия команды cmp, входящая в состав GNU coreutils, была написана Торбьорном Гранлундом и Дэвидом Маккензи. Для Microsoft Windows команда доступна как отдельный пакет в составе коллекции UnxUtils, представляющей собой нативные порты Win32 для распространенных утилит, подобных GNU Unix. Команда также была портирована на операционную систему IBM i.
is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification. It first appeared in Version 1 Unix. The version of cmp bundled in GNU coreutils was written by Torbjorn Granlund and David MacKenzie. The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix like utilities. The command has also been ported to the IBM i operating system.
Выключатели
cmp может быть настроен с помощью переключателей командной строки. Переключатели, поддерживаемые известными реализациями cmp:
cmp may be qualified by the use of command line switches. The switches supported by notable implementations of cmp are:
Наименование Описание Unix Plan 9 Inferno FreeBSD Linux IBM i b, печать байтов Печатать различающиеся байты. Отображать управляющие байты как '^', за которым следует буква алфавита, и предварять байты с установленным старшим битом как 'M ' (что означает "мета"). ✔ h Не следовать символическим ссылкам. ✔ i SKIP, ignore initial=SKIP Пропускать первые SKIP байтов ввода. ✔ i SKIP1:SKIP2, ignore initial=SKIP1:SKIP2 Пропускать первые SKIP1 байтов FILE1 и первые SKIP2 байтов FILE2. ✔ l, verbose Выводить (десятичные) номера байтов и (восьмеричные) значения всех различающихся байтов вместо стандартного вывода. Также выводить сообщение EOF, если один файл короче другого. ✔ ✔ ✔ ✔ ✔ ✔ L Печатать номер строки первого различающегося байта. ✔ ✔ ✔ n LIMIT, bytes=LIMIT Сравнивать не более LIMIT байтов. ✔ s, quiet, silent Ничего не выводить; возвращать только код завершения. ✔ ✔ ✔ ✔ ✔ ✔ t Текстовый режим, в котором файлы открываются в текстовом режиме и преобразуются в CCSID задания перед сравнением байт за байтом. ✔ v, version Выводить информацию о версии. ✔ x Как l, но печатать в шестнадцатеричном формате и использовать ноль в качестве индекса для первого байта в файлах. ✔ z Для обычных файлов сначала сравнивать размеры файлов и прекращать сравнение, если они не равны. ✔ help Выводить справочное сообщение. ✔
Name Description Unix Plan 9 Inferno FreeBSD Linux IBM i b, print bytes Print the differing bytes. Display control bytes as a '^' followed by a letter of the alphabet and precede bytes that have the high bit set with 'M ' (which stands for "meta"). ✔ h Do not follow symbolic links. ✔ i SKIP, ignore initial=SKIP Skip the first SKIP bytes of input. ✔ i SKIP1:SKIP2, ignore initial=SKIP1:SKIP2 Skip the first SKIP1 bytes of FILE1 and the first SKIP2 bytes of FILE2. ✔ l, verbose Output the (decimal) byte numbers and (octal) values of all differing bytes, instead of the default standard output. Also, output the EOF message if one file is shorter than the other. ✔ ✔ ✔ ✔ ✔ ✔ L Print the line number of the first differing byte. ✔ ✔ ✔ n LIMIT, bytes=LIMIT Compare at most LIMIT bytes. ✔ s, quiet, silent Output nothing; yield exit status only. ✔ ✔ ✔ ✔ ✔ ✔ t Text mode where the files are opened in text mode and translated to the CCSID of the job before comparing byte for byte. ✔ v, version Output version info. ✔ x Like l but prints in hexadecimal and using zero as index for the first byte in the files. ✔ z For regular files compare file sizes first, and fail the comparison if they are not equal. ✔ help Outputs a help file. ✔
Операнды, представляющие собой количество байтов, обычно десятичные, но могут быть предварены '0' для восьмеричного и '0x' для шестнадцатеричного формата. За количеством байтов может следовать суффикс для указания кратного этому количеству; в этом случае пропущенное целое число понимается как 1. Буква 'iB' указывает множитель, использующий степени 1024. Буква 'B' указывает степени 1000. Например, 'n 4M' и 'n 4MiB' эквивалентны 'n 4194304', в то время как 'n 4MB' эквивалентен 'n 4000000'. Эта нотация совместима с префиксами SI для десятичных кратных и с префиксами IEC 60027 2 для двоичных кратных.
Operands that are byte counts are normally decimal, but may be preceded by '0' for octal and '0x' for hexadecimal. A byte count can be followed by a suffix to specify a multiple of that count; in this case an omitted integer is understood to be 1. A bare size letter, or one followed by 'iB', specifies a multiple using powers of 1024. A size letter followed by 'B' specifies powers of 1000 instead. For example, ' n 4M' and ' n 4MiB' are equivalent to ' n 4194304', whereas ' n 4MB' is equivalent to ' n 4000000'. This notation is upward compatible with the SI prefixes for decimal multiples and with the IEC 60027 2 prefixes for binary multiples.