How to find yesterday’s date with bash…
I have a process that generates files daily. Rather than having to go delete them myself, I wanted to automate the task of removing the files. After all, the more the computer does for me, the less I have to do, right?
5 Mins of googling and I found this site. I am blantantly copying and pasting the post, this is NOT my post.
Date of yesterday in bash?
I recently had to hack a small shell script that would read files in a directory structure generated based on the date, something like 2007/08/16. The trick was that the script would look at yesterday’s file or files generated a few days ago.A quick search on info and here’s the magic command
FILE=”…$(date -d ‘yesterday’ +%Y/%m/%d)”
Interestingly, you can also use things like 3 days ago, next Monday, 2 months etc. Cool!







