Contents

How to Find Last Modified Files Recursively

Contents

In this post I will show a bash script which show how to find most recent modified files recursively in Linux using find command.


Script

last_modified_files.sh

echo -ne "\n"
echo -ne "date created  | time modified  | file name
------------------------------------------\n"
find . -mindepth 1 -printf '%T@\t%P\n'|  tail -n 10 |\
        sort -nr -k1|\
        awk -F\\t '
          {
            topdir=$2;
            gsub(/\/.*/, "", topdir);
            if (topdir=="") { topdir="." };
            if (!seen[topdir]) { 
              seen[topdir]=1;
              print strftime("%Y.%m.%d    | %Hh:%Mm",$1) "        | " $2;
            }
          }'

Example

chmod +x last_modified_files.sh
./last_modified_files.sh
Font