From 88691a4db0bb8b2d420c765e7f7e030f134dc345 Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Thu, 12 Oct 2023 09:22:24 +0200 Subject: [PATCH] add script for find last modified files --- find-latest-modified-files.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 find-latest-modified-files.sh diff --git a/find-latest-modified-files.sh b/find-latest-modified-files.sh new file mode 100755 index 0000000..c568509 --- /dev/null +++ b/find-latest-modified-files.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# find and list the latest modified files in a directory with subdirectories and times +# +# https://stackoverflow.com/questions/5566310/how-to-recursively-find-and-list-the-latest-modified-files-in-a-directory-with-s + +find $1 -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head -n 15 + +# alternative +# find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n 15 +