2015-10-16

[SOLVED]delete-all-but-the-most-recent-x-files-in-bash

#11:17 07/04/2015
#http://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash
#ls -t | head -n 2: TOP 2 data newest
( ls -t | head -n 2 ; ls ) | sort | uniq -u | sed -e 's,.*,"&",g' | xargs rm -rf #Keep 2 newest

No comments:

Post a Comment