Linux - Save only recent 10 folders and delete the rest

后端 未结 6 1750
借酒劲吻你
借酒劲吻你 2021-02-04 14:14

I have a folder that contains versions of my application, each time I upload a new version a new sub-folder is created for it, the sub-folder name is the current timestamp, here

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-04 14:58

    EDIT:

    find . -maxdepth 1 -type d ! -name \\.| sort | tac | sed -e '1,10d' | xargs rm -rf
    

提交回复
热议问题