penguin/utils

my env utils

commit d22fc76b3032fc0c0d2586901383b7ccc90183a4

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-10-17T09:28:34Z
subjectgz support for catlog
commit d22fc76b3032fc0c0d2586901383b7ccc90183a4
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-10-17T09:28:34Z

    gz support for catlog
---
 bash/bashrc/sources/60_diagnostics | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/bash/bashrc/sources/60_diagnostics b/bash/bashrc/sources/60_diagnostics
index c3a3d1e..02b0127 100755
--- a/bash/bashrc/sources/60_diagnostics
+++ b/bash/bashrc/sources/60_diagnostics
@@ -2,12 +2,23 @@
 
 function catlog () {
     if [[ -z "$1" ]]; then
-        __func_head "FILE"
+        __func_head "[z] FILE"
         echo "  Will exclude:"
         cat ~/.settings/checklog_exclude | awk '{ print "    "$1 }'
         echo 
     else
+        GZIP=false
+        if [ "$1" == "z" ]; then
+            GZIP=true
+            shift
+        fi
+
         EXCLUDE=$(awk '{ printf("(%s)|", $1) }' ~/.settings/checklog_exclude | sed 's/|$//')
-        egrep -v $EXCLUDE $1
+
+        if $GZIP; then
+            gunzip -c $1 | egrep -v $EXCLUDE
+        else
+			egrep -v $EXCLUDE $1
+        fi
     fi
 }