#!/bin/sh ls -lrt| awk '{if(NR<4 && NR!=1) printf("rm -rf %s ",$8)}' >rm2.sh chmod 755 rm2.sh ./rm2.sh rm rm2.sh
或
#!/bin/sh for i in `ls -lthr | head -3 |grep -v 'total'` do rm -rf $i done;
参考: https://blog.csdn.net/osyun/article/details/6650519
#!/bin/sh ls -lrt| awk '{if(NR<4 && NR!=1) printf("rm -rf %s ",$8)}' >rm2.sh chmod 755 rm2.sh ./rm2.sh rm rm2.sh
或
#!/bin/sh for i in `ls -lthr | head -3 |grep -v 'total'` do rm -rf $i done;
参考: https://blog.csdn.net/osyun/article/details/6650519