bzgrep command in Linux allows users to search a pattern or expression inside a bzip2-compressed files. Means, using this command, a user can invoke grep on .bz2 extension based files. All options specified are passed directly to grep, and in case if no files are specified, then the standard output file is decompressed and passed to grep. In other case, the specified files are decompressed and fed to grep if necessary.
In case if bzgrep command is invoked as bzegrep or bzfgrep, then egrep and fgrep is used instead of grep. In case if GREP environment is specified, bzgrep use it as grep program to be invoked.
Syntax to use bzgrep command in Linux
bzgrep [ grep_options ] [ -e ] pattern file_name..
Example of bzgrep commands
Just create a file named servo and compress it using bzip2. Then we use bzgrep command to search a pattern “tutorial”.
Cat > servo Servonode.com Linux and wordpress tutorial.
bzip2 servo bzgrep “tutorial” servo.bz2
Output: Linux and wordpress tutorial.
Nishant Verma is a senior web developer who love to share his knowledge about Linux, SysAdmin, and more other web handlers. Currently, he loves to write as content contributor for ServoNode.