Skip to content

Instantly share code, notes, and snippets.

@brwyatt
Last active January 22, 2025 19:20
Show Gist options
  • Save brwyatt/c21a888d79927cb476a4 to your computer and use it in GitHub Desktop.
Save brwyatt/c21a888d79927cb476a4 to your computer and use it in GitHub Desktop.
BASH script to find the newest file under a directory structure
#!/bin/bash
if [[ "x${1}" == "x" ]]; then
dir="."
else
dir="${1}"
fi
find "${dir}" -type f -printf "%C@ %p\n" | sort -rn | head -n 1 | cut -d' ' -f2 | xargs ls -l | cut -d' ' -f6,7,8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment