uniq -f (ignore first n fields – or with rev last n fields)

#find web access log files in backups – only take one from each date – put them together in date order in one file

#!/bin/bash
FOO=`find /backups/*/a/var/log/nginx -name "access.log*" -ls|cut -b 60-|sort -k 1 -k 2 -k 3|rev|uniq -f 1|rev|awk '{ print $4 }'`
for file in `ls -rt $FOO`; do
gzip -cd $file|grep website.com >> /var/tmp/joined.access.log
done

Leave a Reply