{"id":2129,"date":"2015-05-10T22:49:08","date_gmt":"2015-05-10T14:49:08","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2129"},"modified":"2015-05-10T22:49:08","modified_gmt":"2015-05-10T14:49:08","slug":"zcatzgrepzdiff","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2129.html","title":{"rendered":"Zcat\/Zgrep\/Zdiff"},"content":{"rendered":"<h6>\u641c\u7d22\u5173\u952e\u5b57\uff1a<\/h6>\n<p>zgrep zcat<\/p>\n<h6>\u53c2\u8003\u5185\u5bb9\uff1a<\/h6>\n<p><span style=\"color: #0000ff;\"><strong>The old way&#8230;<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true\">$ gzip -d data.txt.gz\n$ cat data.txt\n$ less data.txt\n$ more data.txt<\/pre>\n<p><span style=\"color: #0000ff;\"><strong>The new way&#8230;<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true\">$ zcat data.txt.gz\n$ zless data.txt.gz\n$ zmore data.txt.gz<\/pre>\n<p><span style=\"color: #0000ff;\"><strong>Compare compressed files. The syntax is:<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true  \">$ zdiff file1.gz file2.gz\n$ zcmp file1.gz file2.gz<\/pre>\n<p class=\"lang:default decode:true \">==<\/p>\n<p class=\"lang:default decode:true \">\n<pre class=\"lang:default decode:true\">$ zegrep -w '^word1|word2' file.gz\n$ zgrep 'wordToSearch' file.gz\n$ zgrep '1.2.3.4' access_log_1.gz\n$ find \/path\/to\/dir\/ -iname '*.gz' -print0 | xargs -0 -I {} zgrep \"pattern\" {}\n\n$ zcat ABC\/myzippedfile1.txt.gz | grep \"pattern match\"\n\n$ zgrep -R --include=*.gz -H \"pattern match\" .\n\n$ find . -name \"*.gz\" -exec zgrep \"pattern match\" \\{\\} \\;\n\n$ find . -name \"*.gz\" -exec zcat \"{}\" + | grep \"pattern match\"\n\n$ zcat -r \/some\/dir\/here | grep \"pattern match\"<\/pre>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.cyberciti.biz\/tips\/decompress-and-expand-text-files.html\" target=\"_blank\">http:\/\/www.cyberciti.biz\/tips\/decompress-and-expand-text-files.html<\/a><\/li>\n<li><a href=\"http:\/\/www.thegeekstuff.com\/2009\/05\/zcat-zless-zgrep-zdiff-zcmp-zmore-gzip-file-operations-on-the-compressed-files\/\" target=\"_blank\">http:\/\/www.thegeekstuff.com\/2009\/05\/zcat-zless-zgrep-zdiff-zcmp-zmore-gzip-file-operations-on-the-compressed-files\/<\/a><\/li>\n<li><a href=\"http:\/\/blog.lysender.com\/2012\/01\/log-parsing-grep-cat-zgrep-and-zcat\/\" target=\"_blank\">http:\/\/blog.lysender.com\/2012\/01\/log-parsing-grep-cat-zgrep-and-zcat\/<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/1253816\/find-string-inside-a-gzipped-file-in-a-folder\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/1253816\/find-string-inside-a-gzipped-file-in-a-folder<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/unix.stackexchange.com\/questions\/131918\/is-it-possible-to-make-zcat-output-text-even-if-its-uncompressed\" target=\"_blank\">http:\/\/unix.stackexchange.com\/questions\/131918\/is-it-possible-to-make-zcat-output-text-even-if-its-uncompressed<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/www.perlmonks.org\/?node_id=538316\" target=\"_blank\">dynamic zcat and grep<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/9081\/grep-a-file-but-show-several-surrounding-lines\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/9081\/grep-a-file-but-show-several-surrounding-lines<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u641c\u7d22\u5173\u952e\u5b57\uff1a zgrep zcat \u53c2\u8003\u5185\u5bb9\uff1a The old way&#8230; $ gzip -d da [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[506,507,508],"class_list":["post-2129","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-zcat","tag-zdiff","tag-zgrep"],"views":3024,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2129"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2129\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}