-1

If i have a Folder structure with 10 Sub dirs Each sub folder has the possibility to hold a version of a file (Older or newer) "Poor folder structure."

I was looking to use Find to locate all files that have been modified within a date range. i.e mtime -60

but i only want the most recent modified file to display (Path and filename) (Version and Datestamp would be a bonus but i can alter to display this) Unique Filename to display

i.e. In Dir1 and Dir2 and Dir3 File 1234.exe may be present, But in Dir2 its modified time is more recent that dir1 and Dir3

All my results have given me very mixed. I have been using

find | sed | ls | awk | sort and tail Also tried stat and head

for most recent. The list could be quite big (100-200 maybe)

0

You could do it as follow. Again, there are people who might disagree with me but this is how I'd have done it.

files=() 
while IFS= read -r
  do files+=("$REPLY"); done < <(find . -type f -mtime -60 -printf '%P\n')

for f in "${files[@]}"; do [[ $f -nt $latest ]] && latest=$f; done
printf 'My latest file is: %s ' "$latest"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.