Open In App

zdiff command in Linux with Examples

Last Updated : 31 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

The zdiff command in Linux is used to invoke the diff program on files compressed via gzip. All options specified are passed directly to diff. By utilizing “zdiff,” you can easily analyze differences between compressed files without the need to decompress them beforehand.

Important Points:

  • If only one file is specified, it is compared to the uncompressed contents of the specified file.
  • If two files are specified, their contents (uncompressed if necessary) are fed to diff.

Syntax of zdiff command in Linux

zdiff [ diff_options ] file1 [ file2]

Additional Options for “zdiff”

  • Depending on your Linux distribution or version, “zdiff” may offer additional options to enhance your file comparison experience. Refer to the respective documentation or manual pages for detailed information on these options.

Example 1:

In the below example, zdiff compares file1.gz and file2.gz and returns the lines in which the difference occurs.

Creating two files and compressing them.

Now comparing the two given files.

Example 2:

Command with only one parameter. In the example below, file1.gz is compared with its uncompressed contents i.e., file1 and returns the lines in which the difference occurs.

Replacing the contents of file1 while keeping the file1.gz same from Example 1.

Now executing the zdiff command with single parameter.

Conclusion

In this article we discussed the “zdiff” command in Linux which is used to compare compressed files without having to decompress them. It makes it easier to see the differences between files and gives us more options to customize the comparison. By learning how to use “zdiff,” you can quickly analyze and compare compressed files in Linux, making your file management tasks more efficient.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads