“zdiff” Command Usage Examples in Linux

«
»

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

zcat – Expands a compressed file to standard output.

DESCRIPTION

advertisement

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

advertisement
$ 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
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!
advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter