Clean logging with BASH

Posted by Matt Krouse on Super User See other posts from Super User or by Matt Krouse
Published on 2013-06-27T20:36:10Z Indexed on 2013/06/27 22:23 UTC
Read the original article Hit count: 217

Filed under:
|

I have a script that deletes files 7 days or older and then logs them to a folder. It logs and deletes everything correctly but when I open up the log file for viewing, its very sloppy.

log=$HOME/Deleted/$(date) 
find $HOME/OldLogFiles/ -type f -mtime +7 -delete -print > "$log"

The log file is difficult to read

Example File Output: (when opened in notepad)

/home/u0146121/OldLogFiles/file1.txt/home/u0146121/OldLogFiles/file2.txt/home/u0146121/OldLogFiles/file3.txt

Is there anyway to log the file nicer and cleaner? Maybe with the Filename, date deleted, and how old it was?

Any suggestions help!

© Super User or respective owner

Related posts about bash

Related posts about logging