Created
March 26, 2011 05:31
-
-
Save benders/888048 to your computer and use it in GitHub Desktop.
Rename logs from logrotate style foo.1.gz to date style foo.2011-03-25.gz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ls -l --time-style="+%Y-%m-%d" *.?.gz | awk '{ print $7,$6 }' | \ | |
while read line; do | |
set -- $line | |
original=$1 | |
datestamp=$2 | |
filebase=`echo $original | rev | cut -f3- -d. | rev` | |
/bin/mv -vu $original $filebase.$datestamp.gz | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment