Skip to content

Instantly share code, notes, and snippets.

@MagerValp
Created April 30, 2012 09:25
Show Gist options
  • Save MagerValp/2556800 to your computer and use it in GitHub Desktop.
Save MagerValp/2556800 to your computer and use it in GitHub Desktop.
This removes lines containing passwordAsUTF8String in /var/log/secure.log*
#!/bin/bash
#
# This removes lines containing passwordAsUTF8String in /var/log/secure.log*
templog=`mktemp -t securelog`
for logfile in /var/log/secure.log*; do
echo "Filtering passwords from $logfile"
if [ ${logfile##*.} == "bz2" ]; then
bzcat "$logfile" | grep -v passwordAsUTF > "$templog"
bzip2 -c "$templog" > "$logfile"
elif [ ${logfile##*.} == "gz" ]; then
gzcat "$logfile" | grep -v passwordAsUTF > "$templog"
gzip -c "$templog" > "$logfile"
else
grep -v passwordAsUTF "$logfile" > "$templog"
cat "$templog" > /var/log/secure.log
fi
done
rm -f "$templog"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment