Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道当文件数量超过设定限制时,是否有任何方法可以使用脚本压缩文件夹中的一组 .txt 文件。txt 文件由另一个脚本自动生成。
您可以使用数组大小来检测文件的数量:
limit=100 files=(*.txt) if (( ${#files[@]} > limit )) ; then zip archive.zip *.txt fi
听起来您想要logrotate一个自定义(非/etc)配置文件,其中包含按大小压缩/删除的规则。
logrotate
/etc