Both Linux and Unix like operating systems comes with z* commands. These command allows you to read gzip compressed text files using zless, zcat, zmore and friends command. The gzip command reduces the size of the files using Lempel-Ziv coding (LZ77). Whenever possible, each file is replaced by one with the extension .gz, while keeping the same ownership modes, access and modification times. z* commands has some cool usage too; such as display the current time in different zonename.
The old way...
Let us say you have a file called data.txt.gz. To display file you need to execute the following command:
gzip -d data.txt.gz
The new way...
Just use the zless or zmore command to display the contents of a file called data.txt.gz:
Concatenate compressed files and print on the screen without using the cat command. The syntax is:
zdiff / zcmp command
Compare compressed files. The syntax is:
zdiff file1.gz file2.gz
zcmp file1.gz file2.gz
zegrep / zfgrep / zgrep command
zless / zmore commands
zmore and zless is a filter which allows examination of compressed or plain text files one screenplay at a time on a screen. zmore works on files compressed with compress, pack or gzip, and also on uncompressed files. If a file does not exist, zmore looks for a file of the same name with the addition of a .gz, .z or .Z suffix.
Znew recompresses files from .Z (compress) format to .gz (gzip) format. If you want to recompress a file already in gzip format, rename the file to force a .Z extension then apply znew.
zdump command prints the current time in each zonename named on the command line. Let us say your current time zone is IST (Indian standard time) and like to see time current time for Los Angeles (USA - PDT), enter:
Fri Aug 31 20:51:39 IST 2007
Now display Los Angeles current time :
/usr/share/zoneinfo/America/Los_Angeles Fri Aug 31 08:20:31 2007 PDT
Search files in a ZIP archive for lines matching a pattern:
zipgrep *.cpp basesys.zip
- ls* Commands Are Even More Useful Than You May Have Thought: These Linux tips may come in handy when you need to find out information quickly without going through /proc or sysfs.
- Man pages for more info - zmore(1), zless(1), zgrep(1), zegrep(1), zdump(1), zdiff(1), zcmp(1), bash(1)
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop