I'm writing a script to stat
all files in a directory, and then find specific files that were created yesterday and tell me if they are larger than a certain size or not.
So basically I need this to find that file, which is a .gz type file (and should have been last modified at least 24 hours ago) and have it check its size to make sure it's not under a certain number, say 4 kilobytes for example. And if it is, under that 4 kilobyte size, it needs to echo "Failure" or something like that, and if it was above that threshold, it needs to echo "Success" or something similar.
Eventually I'll have it send an email if it was a fail or success.
So far I have it stating all the files and finding the ones that have been modified in the last 24 hours, but since I'm such a newby, I'm lost at this point:
for file in /*; do
stat $file
done
find /* -mtime -1 -print
I have this running my whole computer right now, but it will eventually be ran on a specific directory.
-size
and-mtime
to get the right ones to print given your under/over 4k and before after 24hrs ago. I was not 100% how you wanted those. – Anthon Jun 17 '15 at 19:11-newermt 'yesterday'
to be useful if your system supports it – steeldriver Jun 17 '15 at 19:30