zdiff Command in Linux with Examples

This tutorial explains Linux “zdiff” command, options and its usage with examples.

zcat – Expands a compressed file to standard output.

DESCRIPTION

zcat uncompresses either a list of files on the command line or its standard input and writes the uncompressed data on standard output. zcat will uncompress files whether they have a .gz suffix or not.

SYNOPSIS

zdiff [ diff_options ] file1 [ file2 ]

advertisement
advertisement

For optons refer to diff command tutorial

EXAMPLES

1. Simple Example

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
$ cat > file1.txt
This is line one
This is line two
 
$ cat > file2.txt
This is line 1
This is line two
 
$ diff file1.txt file2.txt
1c1
< This is line one
---
> This is line 1
 
$ gzip file1.txt file2.txt 
 
$ zdiff file1.txt.gz file2.txt.gz
1c1
< This is line one
---
> This is line 1

2. zdiff with -c option of diff command

$ zcat file1.txt.gz 
abc
def
ghi
$ zcat file2.txt.gz 
abc
ghi
klm
$ zdiff -c file1.txt.gz file2.txt.gz
*** /dev/fd/5	2013-12-26 11:08:57.341112539 -0800
--- -	2013-12-26 11:08:57.344296058 -0800
***************
*** 1,3 ****
  abc
- def
  ghi
--- 1,3 ----
  abc
  ghi
+ klm

For all other usages, the zdiff command works just as the diff command with the difference that it takes .gz files as input.

advertisement

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement
If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.