Question

I am using bash shell on Solaris 5.10.Daily I get some files having name pattern yyyy_mm_dd(like 2012_12_21).I keep only 3 days files and I delete the rest of them.Now I require 3 days back date to delete it.please suggest me how to get a backdate in shell script.

Was it helpful?

Solution

The standard solution is to use find. If you really prefer to reinvent that particular wheel, date -d "3 days ago" will print the requested date.

find . -name '...' -mtime +3 -exec rm \+
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top