I am working on converting a KornShell (ksh) script to Groovy. I have the following Find command – what would be a Groovy way to do something similar, without relying on Unix commands (I need this to work cross-platform, so I can not do a “blah blah”.execute()).
find <source directory> -name <file pattern> -type f -mtime +140 -level 0
This code searches for all files in the source directory (no subdirs) that match a file pattern and are older than 140 days.
Groovy provides some methods for searching through directories:
File.eachFilefor the-level 0case, orFile.eachFileRecursefor the general case. Example: