Groovy : μμ λμ§ NμΌμ΄ λλ νμΌλ€ μμ νκΈ°
νΉμ λλ ν 리 λ°μ μλ νμΌ μ€μμ μΌμ μκ°μ΄ μ§λ νμΌμ μμ νκ³ μ ν λ νμν μ€ν¬λ¦½νΈμ΄λ€. νμΌ μλ²λ₯Ό κ΄λ¦¬νλ€λ³΄λ©΄, μ£ΌκΈ°μ μΌλ‘ νμ μλ νμΌλ€μ μμ ν΄μΌ νλλ°, Unix(Linux) νκ²½μμλ find, rm λ±μ μ‘°ν©νμ¬ μ¬μ©ν μλ μλ€. κ·Έλ° κ²μ΄ μ¬μμΉ μκ³ , κ΅³μ΄ Groovy λ₯Ό μ΄μ©νλ €κ³ ν λ, νμ©νλ©΄ μ’κ² λ€.
final DAY_LIMIT = 2 // NμΌ final TARGET_DIR = "./" println("[Deleted Files]\n") new File(TARGET_DIR).eachFileRecurse { file -> if( file.file ) { def lastModified = new Date(file.lastModified()) def diffDay = new Date() - lastModified if(diffDay > DAY_LIMIT) { println(lastModified.format("YYYY-mm-dd") + " : $file") file.delete() } } }











