Forrest logo
back to the cmp tool

cmp:tldr:9792d

cmp: Compare files but output nothing, yield only the exit status.
$ cmp --quiet ${filename1} ${filename2}
try on your machine

The command "cmp --quiet ${filename1} ${filename2}" is used to compare the contents of two files, specified by the variables ${filename1} and ${filename2}. Here's an explanation of the different elements of the command:

  • "cmp": This is the command itself, which stands for "compare". It is used to compare files byte by byte.

  • "--quiet": This is an option or flag provided to the cmp command. It tells cmp to suppress any output, making it silent. If the files are different, cmp will exit with a non-zero status, indicating an error. If the files are the same, it will exit with a zero status, indicating success.

  • "${filename1}": This is a variable that represents the first file to be compared. It should be replaced with the actual filename or path of the file you want to compare.

  • "${filename2}": This is a variable that represents the second file to be compared. It should be replaced with the actual filename or path of the second file you want to compare.

Overall, this command compares the contents of the two files specified (${filename1} and ${filename2}) and does not produce any output. It primarily focuses on the exit status of the command to identify if the files are the same or different.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the cmp tool