Hi Guys!
I would like to create a shell script that checks how many files there are in a directory. If there are more than 20 then delete the ones that are older than 48 hours old.
so I have portions for a script, but I can't seem to make it work properly.
This will delete the files:
find /mydir/ -ctime 48 -exec rm -r {} \;
This will tell me how many files are in a directory:
find /mydir/ -type f | wc -l
But I can't make an if statement with "find /mydir/ -type f | wc -l" for some reason... please help!