unfortunately are the tools under the differen UNIXes not standardized.
(busybox for example comes with very reduced parameters you can pass to commands)

linux: bash terminal one liner

# last modified/created file
find . -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "

# last 10 modified/created files (includes moved files)
# the "latest" file will be on the bottom of the list
find . -type f -printf '%T@ %p\n' | sort -n | tail -10 | cut -f2- -d" "

linux: script

find . -type f -printf "%T@\0%p\0" | awk '
    {
        if ($0>max) {
            max=$0; 
            getline mostrecent
        } else 
            getline
    } 
    END{print mostrecent}' RS='\0'

BSD/OSX:

find . -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" "

solaris:

find . -type f | sed 's/.*/"&"/' | xargs ls -E | awk '{ print $6," ",$7 }' | sort | tail -1

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin