-
Notifications
You must be signed in to change notification settings - Fork 0
/
uia.sh
executable file
·35 lines (33 loc) · 1.13 KB
/
uia.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/zsh -
#===============================================================================
#
# FILE: uia.sh
#
# USAGE: ./uia.sh
#
# DESCRIPTION:
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR: Cláudio Sampaio (Patola), [email protected]
# ORGANIZATION: IBM
# CREATED: 24-10-2012 05:26:28 BRST
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
for file in /var/log/*(.)
do
if [[ "$file" == *.gz && ! "$file" == *.tar.gz ]]
then
gzip -d "$file"
file="${file%.*}"
egrep -v 'kernel:.* sd [0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*: |usb|USB|removable disk|scsi.*Direct-Access' < "$file" > "${file}".newfile
cat "${file}".newfile > "$file" && rm "${file}".newfile
gzip -9 "${file}"
else
egrep -v 'kernel:.* sd [0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*:[0-9][0-9]*: |usb|USB|removable disk|scsi.*Direct-Access' < "$file" > "${file}".newfile
cat "${file}".newfile > "$file" && rm "${file}".newfile
fi
done