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.
我该如何做一个shell脚本来做到这一点:脚本的调用将看到“/DataFolder”以列出所有文件*.INI,并将日期作为参数传递。如果可能,结果应仅保留文件名和文件更改时间,并且列表必须按升序排序。如果不传参数,我们取当前日期
谢谢。
我建议使用find这个:
find
find /DataFolder -type f -iname '*.ini*' \ -mtime +MINIMUM_DAYS_SINCE_MODIFICATION \ -printf "%TY%Tm%Td %f\n" \ | sort -n
这将输出修改时间与 YEAR MONTH DAY 连接,因此可以直接通过管道传输 info sort。
sort