generate date based filenames
Most folks are aware that you can use:
FOO=`date +%Y%m%d%H%M%S`
to generate a date formatted string, but, did you also know that it is very good at calculating a date using expressions?
BAR=`date +%Y%m%d%H%M%S --date="1 day ago"`
BAZ=`date +%Y%m%d%H%M%S --date="+ 1 day 2 hours"`
very handy if you need to process logs for a previous date and/or time range
START=`date +%Y%m%d%H%M%S --date="1 day ago"`
END=`date +%Y%m%d%H%M%S --date="1 hour ago"`
Now actually extracting the matching log lines is for another tip...
Written by Mike Taylor
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#