命令行只保留最新5个文件

2023/05/12
cd xxx && rm `ls -t | tail -n +6`
cd xxx && res=`ls -t | tail -n +6` && if [ ! -z $res ]; then rm $res; fi

ls -t 时间最新的在前
ls -tr 时间最老的在后