Linux: Deleting files keeping only lastest n-files in specific folder

PHOTO EMBED

Mon Aug 29 2022 14:08:16 GMT+0000 (UTC)

Saved by @marcopinero #bash

#bypassing [n] files, (we must use [n+1]):

$ find <folder> -maxdepth 1 -type f -printf "%T@ %Tc %p\n" | grep -v '/\.' | sort -r | tail -n +60 | grep -Po "\./.*"

$ for f in "`find -maxdepth 1 -type f -print0 | xargs -r0 stat -c %y\ %n | grep -v '\.\/\.' | sort -r | grep -Po '\./.*' | tail -n +61`"; do 
    printf "$f\n"
$ done
content_copyCOPY