ฉันจำเป็นต้อง:
- สำรวจไดเรกทอรีและค้นหาโฟลเดอร์ย่อยทั้งหมดที่สร้างขึ้นสำหรับ> X days ago
- บีบอัดเนื้อหาของโฟลเดอร์เหล่านี้ภายในโฟลเดอร์ย่อยและลบเนื้อหาก่อนหน้า
ตัวอย่างไฟล์ strucutre ตั้งแต่ต้น:
root_folder:
    sub-dir (many of these):
        sub-sub-dir (many of these):
            content1 (can be file or folder)
            content2 (can be file or folder)
            content3 (can be file or folder)
ตัวอย่างไฟล์ strucutre หลังจากคำสั่งเสร็จสิ้น:
root_folder:
    sub-dir:
        sub-sub-dir:
            zipfile.zip
แต่! ฉันไม่ต้องการรวมโครงสร้างโฟลเดอร์ทั้งหมด (sub-dir / sub-sub-dir) ในไฟล์ zip ฉันต้องการให้ไฟล์ zip มีลักษณะดังนี้:
zip_file:
    content1 (no matter if it is a file or a folder with content in it)
    content2 (no matter if it is a file or a folder with content in it)
    content3 (no matter if it is a file or a folder with content in it)
แทน:
zip_file:
    sub-dir:
        sub-sub-dir:
            content1
            content2
            content3
คำสั่งที่ฉันใช้ไปไกลจะแก้ปัญหาทุกอย่างได้ แต่ส่วนโครงสร้างโฟลเดอร์ ... ดูเหมือนว่านี่ (ฉันไม่มีคำสั่งที่ถูกต้องต่อหน้าฉันตอนนี้ฉันอาจจะอัพเดทพรุ่งนี้
find * -mindepth X -maxdepth X -mtime +10 -exec zip -r -m \{}/zipfilename {} \;