I need create log files that are essentially date stamps with prefix
yp_ and suffix
.log, and a manipulated day number:
$ touch yp_$(echo "$(date +%Y%m%d)-10" | /usr/bin/bc -l).log $ ls yp_20150912.log # ... ok for today's date.
That's fine for today, but all hell breaks loose when the day's number is between 01 and 10 included. The result cannot be interpreted as a date stamp any longer.
E.g. just imagine that the day is the 8th of March, 2016, i.e. '20160308'. How do I code the above to make sure that subtracting 10 days will produce not '20150298' but '20150227' ? Also test yr answer with 19820103 ...
-- I looked at
apropos date spews out 161 hits that I also reviewed.
Can somebody help with that one-liner?