Auto dectect gzip for catlog
This commit is contained in:
parent
5087fdbc74
commit
d81aed5899
@ -1,24 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function catlog () {
|
function catlog () {
|
||||||
if [[ -z "$1" ]]; then
|
if [[ -z "$1" ]]; then
|
||||||
__func_head "[z] FILE"
|
__func_head "FILE"
|
||||||
echo " Will exclude:"
|
echo " Will exclude:"
|
||||||
cat ~/.settings/checklog_exclude | awk '{ print " "$1 }'
|
cat ~/.settings/checklog_exclude | awk '{ print " "$1 }'
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
GZIP=false
|
GZIP=
|
||||||
if [ "$1" == "z" ]; then
|
file "$1" | grep gzip > /dev/null && GZIP=true
|
||||||
GZIP=true
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
EXCLUDE=$(awk '{ printf("(%s)|", $1) }' ~/.settings/checklog_exclude | sed 's/|$//')
|
EXCLUDE=$(awk '{ printf("(%s)|", $1) }' ~/.settings/checklog_exclude | sed 's/|$//')
|
||||||
|
|
||||||
if $GZIP; then
|
if [ $GZIP ]; then
|
||||||
gunzip -c $1 | egrep -v $EXCLUDE
|
gunzip -c $1 | egrep -v $EXCLUDE
|
||||||
else
|
else
|
||||||
egrep -v $EXCLUDE $1
|
egrep -v $EXCLUDE $1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user