Search code examples
shellsolaris-10

back date in shell script on solaris 5.10


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.


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 \+